/[H9]/trunk/tntnet/dynamic/adm_customer_edit.ecpp
ViewVC logotype

Diff of /trunk/tntnet/dynamic/adm_customer_edit.ecpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 93 by torben, Thu Nov 29 07:34:54 2007 UTC revision 190 by torben, Fri Dec 7 16:34:10 2007 UTC
# Line 15  dburl; Line 15  dburl;
15    
16  <%session scope="global">  <%session scope="global">
17  std::string userName;  std::string userName;
 bool isAdmin;  
18  </%session>  </%session>
19    
20  <%args>  <%args>
21  int id;  int id;
22  </%args>  </%args>
23    
24    <{
25    if (userName.size() == 0)
26    {
27            reply.setHeader("Location", "index");
28            return HTTP_MOVED_TEMPORARILY;
29    }
30    }>
31    
32    
33  <&header title="Customer Administration">  <&header title="Customer Administration">
34  </&header>  </&header>
35    
36    
   
37  <{  <{
38    
 if (userName.size() == 0)  
 {  
     reply.setHeader("Refresh", "0; url=login");  
         return HTTP_OK;  
 }  
   
39  if (id == -1)  if (id == -1)
40          reply.out() << "<h2>New Customer</h2>\n";          reply.out() << "<h2>New Customer</h2>\n";
41  else  else
# Line 42  else Line 43  else
43    
44  reply.out() << "<a href='adm_customer_list'>";  reply.out() << "<a href='adm_customer_list'>";
45  reply.sout() << "<< back to customer list";  reply.sout() << "<< back to customer list";
46  reply.out() << "</a><br>";  reply.out() << "</a><br><br>";
47    
48  tntdb::Connection conn = tntdb::connect(dburl);  tntdb::Connection conn = tntdb::connect(dburl);
49    
# Line 64  if (submit == "1") Line 65  if (submit == "1")
65    
66                  //tntdb::Value v = conn.selectValue("SELECT lastval()"); //get the auto-generated id                  //tntdb::Value v = conn.selectValue("SELECT lastval()"); //get the auto-generated id
67                  //id = v.getInt();                  //id = v.getInt();
68                  reply.setHeader("Refresh", "0; url=adm_customer_list");  
69                  return HTTP_OK;                  reply.setHeader("Location", "adm_customer_list");
70                    return HTTP_MOVED_TEMPORARILY;
71          }          }
72          else          else
73          {          {
74                  tntdb::Statement st = conn.prepare("UPDATE customer SET name=:v1, address=:v2, phonenr=:v3, contactperson=:v4 WHERE id=:v5");                  tntdb::Statement st = conn.prepare("UPDATE customer SET name=:v1, address=:v2, phonenr=:v3, contactperson=:v4 WHERE id=:v5");
75                  st.setString("v1", form_name).setString("v2", form_address).setString("v3", form_phone).setString("v4", form_contact).setInt("v5", id);                  st.setString("v1", form_name).setString("v2", form_address).setString("v3", form_phone).setString("v4", form_contact).setInt("v5", id);
76                  st.execute();                  st.execute();
77    
78                    reply.out() << "<i>Customer updated</i><br>\n";
79          }          }
80    
81  }  }
# Line 109  if (showForm) Line 113  if (showForm)
113  {  {
114  }>  }>
115    
116  <form method="post" action="adm_customer_edit">  <script type="text/javascript" language="JavaScript" src="/md5.js"></script>
117    <script type="text/javascript" language="JavaScript" src="/trim.js"></script>
118    <script type="text/javascript">
119    
120    function validateCustomerForm()
121    {
122            var form = document.customerform;
123            form.name.value = trim(form.name.value);
124    
125            if (form.name.value.length < 3)
126            {
127                    alert("Name must at least be 3 characters");
128                    return false;
129            }
130    
131            return true;
132    }
133    
134    </script>
135    
136    <form method="post" action="adm_customer_edit" name="customerform" onsubmit="return validateCustomerForm();">
137  <table border="0">  <table border="0">
138  <tr>  <tr>
139    <td>Name: </td>    <td>Name: </td>
# Line 136  if (showForm) Line 160  if (showForm)
160  <input type="hidden" name="submit" value="1">  <input type="hidden" name="submit" value="1">
161  </form>  </form>
162    
163    <{
164    if (id != -1)
165    {
166    }>
167    <br>
168  <br>  <br>
169  <form method="post" action="adm_customer_delete">  <form method="post" action="adm_customer_delete" onsubmit="return confirm('Are you sure?\\nThis will delete all related installations and logdata','Delete customer');">
170  <input type="hidden" name="id" value="<$ id $>">  <input type="hidden" name="id" value="<$ id $>">
171  <input type="submit" value="Delete">  <input type="submit" value="Delete this customer">
172  </form>  </form>
173    
174  <{  <{
175  }  } //fi (id != -1)
176    } //fi (showForm)
   
177  }>  }>
178    
179  <&footer>  <&footer>

Legend:
Removed from v.93  
changed lines
  Added in v.190

  ViewVC Help
Powered by ViewVC 1.1.20