/[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 90 by torben, Wed Nov 28 23:19:28 2007 UTC revision 101 by torben, Thu Nov 29 13:59:21 2007 UTC
# Line 22  bool isAdmin; Line 22  bool isAdmin;
22  int id;  int id;
23  </%args>  </%args>
24    
25    <{
26    if (userName.size() == 0)
27    {
28            reply.setHeader("Location", "index");
29            return HTTP_MOVED_TEMPORARILY;
30    }
31    }>
32    
33    
34  <&header title="Customer Administration">  <&header title="Customer Administration">
35  </&header>  </&header>
36    
37    
   
38  <{  <{
39    
 if (userName.size() == 0)  
     reply.setHeader("Refresh", "0; url=login");  
   
40  if (id == -1)  if (id == -1)
41          reply.out() << "<h2>New Customer</h2>\n";          reply.out() << "<h2>New Customer</h2>\n";
42  else  else
# Line 47  tntdb::Connection conn = tntdb::connect( Line 52  tntdb::Connection conn = tntdb::connect(
52  std::string submit = qparam.param("submit");  std::string submit = qparam.param("submit");
53  if (submit == "1")  if (submit == "1")
54  {  {
55          std::string form_name = qparam.param("name");          std::string form_name = trim(qparam.param("name"));
56          std::string form_address = qparam.param("address");          std::string form_address = trim(qparam.param("address"));
57          std::string form_phone = qparam.param("phone");          std::string form_phone = trim(qparam.param("phone"));
58          std::string form_contact = qparam.param("contact");          std::string form_contact = trim(qparam.param("contact"));
59    
60    
61          if (id == -1)          if (id == -1)
# Line 61  if (submit == "1") Line 66  if (submit == "1")
66    
67                  //tntdb::Value v = conn.selectValue("SELECT lastval()"); //get the auto-generated id                  //tntdb::Value v = conn.selectValue("SELECT lastval()"); //get the auto-generated id
68                  //id = v.getInt();                  //id = v.getInt();
69                  reply.setHeader("Refresh", "0; url=adm_customer_list");  
70                  return HTTP_OK;                  reply.setHeader("Location", "adm_customer_list");
71                    return HTTP_MOVED_TEMPORARILY;
72          }          }
73          else          else
74          {          {
75                  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");
76                  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);
77                  st.execute();                  st.execute();
78    
79                    reply.out() << "<i>Customer updated</i><br>\n";
80          }          }
81    
82  }  }

Legend:
Removed from v.90  
changed lines
  Added in v.101

  ViewVC Help
Powered by ViewVC 1.1.20