1 |
torben |
83 |
<%pre> |
2 |
|
|
#include <tntdb/connect.h> |
3 |
|
|
#include <tntdb/connection.h> |
4 |
|
|
#include <tntdb/result.h> |
5 |
|
|
#include <tntdb/row.h> |
6 |
|
|
</%pre> |
7 |
|
|
|
8 |
|
|
<%config> |
9 |
|
|
dburl; |
10 |
|
|
</%config> |
11 |
|
|
|
12 |
|
|
<%session scope="global"> |
13 |
|
|
std::string userName; |
14 |
|
|
</%session> |
15 |
|
|
|
16 |
|
|
<&header title="Customer administration"> |
17 |
|
|
</&header> |
18 |
|
|
<h2>Customers administration</h2> |
19 |
|
|
|
20 |
|
|
<a href="adm_customer_edit?id=-1">Create new customer</a><br> |
21 |
|
|
|
22 |
|
|
<{ |
23 |
|
|
|
24 |
|
|
if (userName.size() == 0) |
25 |
torben |
92 |
{ |
26 |
torben |
83 |
reply.setHeader("Refresh", "0; url=login"); |
27 |
torben |
92 |
return HTTP_OK; |
28 |
|
|
} |
29 |
torben |
83 |
|
30 |
|
|
tntdb::Connection conn; |
31 |
|
|
|
32 |
|
|
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"; |
35 |
|
|
|
36 |
|
|
tntdb::Result res = conn.select(query); |
37 |
|
|
|
38 |
|
|
std::ostream& out = reply.out(); |
39 |
|
|
if (res.size() > 0) |
40 |
|
|
{ |
41 |
|
|
out << "<ul>"; |
42 |
|
|
for (int i=0; i<res.size(); ++i) |
43 |
|
|
{ |
44 |
|
|
int id = res[i].getInt(0); |
45 |
|
|
std::string name = res[i].getString(1); |
46 |
|
|
out << "<li>"; |
47 |
|
|
out << "<a href='adm_customer_edit?id=" << id << "'>" << name << "</a>"; |
48 |
|
|
out << " - <a href='adm_installation_list?id=" << id << "&name=" << name << "'>manage installations</a>"; |
49 |
|
|
out << "</li>"; |
50 |
|
|
} |
51 |
|
|
out << "</ul>"; |
52 |
|
|
} |
53 |
|
|
else |
54 |
|
|
{ |
55 |
|
|
out << "<i>No customers found!</i>"; |
56 |
|
|
} |
57 |
|
|
}> |
58 |
|
|
|
59 |
|
|
<&footer> |
60 |
|
|
</&footer> |