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

Annotation of /trunk/tntnet/dynamic/adm_customer_list.ecpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 83 - (hide annotations) (download)
Wed Nov 28 17:03:27 2007 UTC (16 years, 6 months ago) by torben
File size: 1178 byte(s)
Web - code sync


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     reply.setHeader("Refresh", "0; url=login");
26    
27     tntdb::Connection conn;
28    
29     conn = tntdb::connect(dburl); //letting exceptions flow up and to tntnet and let it display an error message
30    
31     std::string query = "SELECT id, name FROM customer ORDER BY name ASC";
32    
33     tntdb::Result res = conn.select(query);
34    
35     std::ostream& out = reply.out();
36     if (res.size() > 0)
37     {
38     out << "<ul>";
39     for (int i=0; i<res.size(); ++i)
40     {
41     int id = res[i].getInt(0);
42     std::string name = res[i].getString(1);
43     out << "<li>";
44     out << "<a href='adm_customer_edit?id=" << id << "'>" << name << "</a>";
45     out << " - <a href='adm_installation_list?id=" << id << "&name=" << name << "'>manage installations</a>";
46     out << "</li>";
47     }
48     out << "</ul>";
49     }
50     else
51     {
52     out << "<i>No customers found!</i>";
53     }
54     }>
55    
56     <&footer>
57     </&footer>

  ViewVC Help
Powered by ViewVC 1.1.20