--- trunk/tntnet/dynamic/adm_customer_edit.ecpp 2007/11/28 23:19:28 90
+++ trunk/tntnet/dynamic/adm_customer_edit.ecpp 2007/11/29 13:59:21 101
@@ -22,16 +22,21 @@
int id;
%args>
+<{
+if (userName.size() == 0)
+{
+ reply.setHeader("Location", "index");
+ return HTTP_MOVED_TEMPORARILY;
+}
+}>
+
+
<&header title="Customer Administration">
&header>
-
<{
-if (userName.size() == 0)
- reply.setHeader("Refresh", "0; url=login");
-
if (id == -1)
reply.out() << "
New Customer
\n";
else
@@ -47,10 +52,10 @@
std::string submit = qparam.param("submit");
if (submit == "1")
{
- std::string form_name = qparam.param("name");
- std::string form_address = qparam.param("address");
- std::string form_phone = qparam.param("phone");
- std::string form_contact = qparam.param("contact");
+ std::string form_name = trim(qparam.param("name"));
+ std::string form_address = trim(qparam.param("address"));
+ std::string form_phone = trim(qparam.param("phone"));
+ std::string form_contact = trim(qparam.param("contact"));
if (id == -1)
@@ -61,14 +66,17 @@
//tntdb::Value v = conn.selectValue("SELECT lastval()"); //get the auto-generated id
//id = v.getInt();
- reply.setHeader("Refresh", "0; url=adm_customer_list");
- return HTTP_OK;
+
+ reply.setHeader("Location", "adm_customer_list");
+ return HTTP_MOVED_TEMPORARILY;
}
else
{
tntdb::Statement st = conn.prepare("UPDATE customer SET name=:v1, address=:v2, phonenr=:v3, contactperson=:v4 WHERE id=:v5");
st.setString("v1", form_name).setString("v2", form_address).setString("v3", form_phone).setString("v4", form_contact).setInt("v5", id);
st.execute();
+
+ reply.out() << "Customer updated
\n";
}
}