13 |
std::string userName; |
std::string userName; |
14 |
</%session> |
</%session> |
15 |
|
|
16 |
|
<{ |
17 |
|
if (userName.size() == 0) |
18 |
|
{ |
19 |
|
reply.setHeader("Location", "index"); |
20 |
|
return HTTP_MOVED_TEMPORARILY; |
21 |
|
} |
22 |
|
}> |
23 |
|
|
24 |
<&header title="Customer administration"> |
<&header title="Customer administration"> |
25 |
</&header> |
</&header> |
26 |
<h2>Customers administration</h2> |
<h2>Customers administration</h2> |
27 |
|
|
28 |
<a href="adm_customer_edit?id=-1">Create new customer</a><br> |
<a href="adm_customer_edit?id=-1">Create new customer</a><br> |
29 |
|
<br> |
30 |
|
|
31 |
<{ |
<{ |
32 |
|
tntdb::Connection conn = tntdb::connectCached(dburl); |
|
if (userName.size() == 0) |
|
|
{ |
|
|
reply.setHeader("Refresh", "0; url=login"); |
|
|
return HTTP_OK; |
|
|
} |
|
|
|
|
|
tntdb::Connection conn; |
|
|
|
|
|
conn = tntdb::connect(dburl); //letting exceptions flow up and to tntnet and let it display an error message |
|
33 |
|
|
34 |
std::string query = "SELECT id, name FROM customer ORDER BY name ASC"; |
std::string query = "SELECT id, name FROM customer ORDER BY name ASC"; |
35 |
|
|
38 |
std::ostream& out = reply.out(); |
std::ostream& out = reply.out(); |
39 |
if (res.size() > 0) |
if (res.size() > 0) |
40 |
{ |
{ |
41 |
out << "<ul>"; |
out << "<table border='1' cellspacing='0'>"; |
42 |
for (int i=0; i<res.size(); ++i) |
for (unsigned i=0; i<res.size(); ++i) |
43 |
{ |
{ |
44 |
int id = res[i].getInt(0); |
int id = res[i].getInt(0); |
45 |
std::string name = res[i].getString(1); |
std::string name = res[i].getString(1); |
46 |
out << "<li>"; |
out << "<tr><td> " << name << " </td>"; |
47 |
out << "<a href='adm_customer_edit?id=" << id << "'>" << name << "</a>"; |
out << "<td> <a href='adm_customer_edit?id=" << id << "'>edit customer</a>"; |
48 |
out << " - <a href='adm_installation_list?id=" << id << "&name=" << name << "'>manage installations</a>"; |
out << " </td>\n<td> "; |
49 |
out << "</li>"; |
out << "<a href='adm_installation_list?customerid=" << id << "&name=" << name << "'>manage installations</a>"; |
50 |
|
out << " </td></tr>"; |
51 |
} |
} |
52 |
out << "</ul>"; |
out << "</table>"; |
53 |
} |
} |
54 |
else |
else |
55 |
{ |
{ |