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

Diff of /trunk/tntnet/dynamic/installationdetails.ecpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 104 by torben, Thu Nov 29 17:06:38 2007 UTC revision 122 by torben, Sun Dec 2 16:56:14 2007 UTC
# Line 3  Line 3 
3  #include <tntdb/connection.h>  #include <tntdb/connection.h>
4  #include <tntdb/result.h>  #include <tntdb/result.h>
5  #include <tntdb/row.h>  #include <tntdb/row.h>
6    
7    #include <sstream>
8    #include "common.h"
9    
10    
11    inline std::string convert_bool(bool input)
12    {
13            return input ? "on" : "off";
14    }
15    
16  </%pre>  </%pre>
17    
18  <%config>  <%config>
# Line 12  dburl; Line 22  dburl;
22  <&header title="Installation details">  <&header title="Installation details">
23  </&header>  </&header>
24    
25    <%args>
26    int id;
27    </%args>
28    
29  <h2>Installation details</h2>  <h2>Installation details</h2>
30    
31    
32  <{  <{
33  tntdb::Connection conn;  tntdb::Connection conn;
34    
35  conn = tntdb::connect(dburl); //letting exceptions flow up and to tntnet and let it display an error message  conn = tntdb::connect(dburl);
36    
37    std::stringstream query;
38    query << "SELECT c.name, c.address AS caddress, i.description, i.address AS iadress, i.furnacetype, i.updaterate, i.commerror ";
39    query << "FROM installation i INNER JOIN customer c ON c.id = i.customerid ";
40    query << "WHERE i.id = " << id;
41    
42    std::ostream& out = reply.out();
43    
44    tntdb::Result res = conn.select(query.str());
45    
46    if (res.size() >0 )
47    {
48    }>
49    
50            <table border=1 cellspacing=0 align='center'>
51            <tr>
52                    <td><b>Customer</b>: </td>
53                    <td><b><$ res[0].getString(0) $></b></td>
54            </tr>
55            <tr>
56                    <td>Customer address: &nbsp;</td>
57                    <td><$$ nl2br(res[0].getString(1)) $></td>
58            </tr>
59            <tr>
60                    <td><b>Installation: </b></td>
61                    <td><b><$ res[0].getString(2) $></b></td>
62            </tr>
63            <tr>
64                    <td>Location: </td>
65                    <td><$$ nl2br(res[0].getString(3)) $></td>
66            </tr>
67            <tr>
68                    <td>Furnace type: </td>
69                    <td><$ res[0].getString(4) $></td>
70            </tr>
71            <tr>
72                    <td>Update rate: </td>
73                    <td><$ res[0].getInt(5) $></td>
74            </tr>
75            <tr>
76                    <td>Comm. status: </td>
77                    <td><img src="bullet.php?rgb=<$ (res[0].getBool(6) ? "ff0000" : "00ff00") $>" alt="Status Indicator"></td>
78            </tr>
79    
80    
81            </table>
82    
83    
84            <p align="center"><img src="temperaturegraph?id=<$id$>" alt="Temperature graph"></p>
85    
86            <{
87            query.str(""); //reset stringstream
88            query << "SELECT messagenr, date_trunc('second', logtime) AS logtime, temperature, flamedetector, solidfuelempty, conveyorerror,powerfailure ";
89            query << "FROM logtable ";
90            query << "WHERE installationnr = " << id;
91            query << "ORDER BY messagenr DESC";
92            res = conn.select(query.str());
93    
94    
95            out << "<table border=1 cellspacing=0 align='center'>\n";
96            out << "<tr><th>&nbsp;Message#&nbsp;</th><th>&nbsp;Logtime&nbsp;</th><th>&nbsp;Temperature&nbsp;</th><th>&nbsp;Flamedetector&nbsp;</th><th>&nbsp;Solidfuel empty&nbsp;</th><th>&nbsp;Conveyor error&nbsp;</th><th>&nbsp;Power failure&nbsp;</th></tr>\n";
97    
98            for (int i=0; i<res.size(); ++i)
99            {
100                    int messagenr = res[i].getInt(0);
101                    std::string logtime = res[i].getString(1);
102                    int temperature = res[i].getInt(2);
103                    bool flamedetector = res[i].getBool(3);
104                    bool solidfuelempty = res[i].getBool(4);
105                    bool conveyorerror = res[i].getBool(5);
106                    bool powerfailure = res[i].getBool(6);
107    
108                    std::string critical = " class='critical'";
109    
110                    out << "<tr>";
111    
112                    out << "<td align='center'>" << messagenr << "</td>\n";
113                    out << "<td align='center'>" << logtime << "</td>\n";
114                    out << "<td align='center'" << (temperature >90 ? critical : "" ) << ">" << temperature << "</td>\n";
115                    out << "<td align='center'" << (flamedetector==false ? critical : "") << ">" << convert_bool(flamedetector) << "</td>\n";  
116                    out << "<td align='center'>" << convert_bool(solidfuelempty) << "</td>\n";
117                    out << "<td align='center'" << (conveyorerror==true ? critical : "") << ">" << convert_bool(conveyorerror) << "</td>\n";
118                    out << "<td align='center'" << (powerfailure==true ? critical : "") << ">" << convert_bool(powerfailure) << "</td>\n";
119                                    
120                    out << "</tr>";
121            }
122            out << "</table>\n";
123    
124    
125            }>
126    
127    
128    
129    <{
130    }
131    else
132    {
133            reply.out() << "<i>No installation with this ID</i>";
134    }
135    
136  }>  }>
137    

Legend:
Removed from v.104  
changed lines
  Added in v.122

  ViewVC Help
Powered by ViewVC 1.1.20