158 | | if not self.form.has_key("history") : |
159 | | if printers and ugmask : |
160 | | self.reportingtool = openReporter(admin, "html", printers, ugmask.split(), isgroup) |
161 | | self.body += "%s" % self.reportingtool.generateReport() |
162 | | else : |
163 | | if remuser != "root" : |
164 | | username = remuser |
165 | | elif self.form.has_key("username") : |
166 | | username = self.form["username"].value |
167 | | else : |
168 | | username = None |
169 | | if username is not None : |
170 | | user = self.storage.getUser(username) |
171 | | else : |
172 | | user =None |
173 | | if self.form.has_key("printername") : |
174 | | printer = self.storage.getPrinter(self.form["printername"].value) |
175 | | else : |
176 | | printer = None |
177 | | if self.form.has_key("datelimit") : |
178 | | datelimit = self.form["datelimit"].value |
179 | | else : |
180 | | datelimit = None |
181 | | if self.form.has_key("hostname") : |
182 | | hostname = self.form["hostname"].value |
183 | | else : |
184 | | hostname = None |
185 | | if self.form.has_key("billingcode") : |
186 | | billingcode = self.form["billingcode"].value |
187 | | else : |
188 | | billingcode = None |
189 | | self.report = ["<h2>%s</h2>" % _("History")] |
190 | | history = self.storage.retrieveHistory(user, printer, datelimit, hostname, billingcode) |
191 | | if not history : |
192 | | self.report.append("<h3>%s</h3>" % _("Empty")) |
193 | | else : |
194 | | self.report.append('<table class="pykotatable" border="1">') |
195 | | headers = [_("Date"), _("Action"), _("User"), _("Printer"), \ |
196 | | _("Hostname"), _("JobId"), _("JobSize"), \ |
197 | | _("JobPrice"), _("Copies"), _("JobBytes"), \ |
198 | | _("PageCounter"), _("Title"), _("Filename"), \ |
199 | | _("Options"), _("MD5Sum"), _("BillingCode"), \ |
200 | | _("Pages")] |
201 | | self.report.append('<tr class="pykotacolsheader">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers])) |
202 | | oddeven = 0 |
203 | | for job in history : |
204 | | oddeven += 1 |
205 | | if oddeven % 2 : |
206 | | oddevenclass = "odd" |
207 | | else : |
208 | | oddevenclass = "even" |
209 | | if job.JobAction == "DENY" : |
210 | | oddevenclass = "deny" |
211 | | elif job.JobAction == "WARN" : |
212 | | oddevenclass = "warn" |
213 | | username_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "username" : job.UserName}), job.UserName) |
214 | | printername_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "printername" : job.PrinterName}), job.PrinterName) |
215 | | if job.JobHostName : |
216 | | hostname_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "hostname" : job.JobHostName}), job.JobHostName) |
217 | | else : |
218 | | hostname_url = None |
219 | | if job.JobBillingCode : |
220 | | billingcode_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "billingcode" : job.JobBillingCode}), job.JobBillingCode) |
221 | | else : |
222 | | billingcode_url = None |
223 | | self.report.append('<tr class="%s">%s</tr>' % \ |
224 | | (oddevenclass, \ |
225 | | "".join(["<td>%s</td>" % (h or " ") \ |
226 | | for h in (job.JobDate[:19], \ |
227 | | job.JobAction, \ |
228 | | username_url, \ |
229 | | printername_url, \ |
230 | | hostname_url, \ |
231 | | job.JobId, \ |
232 | | job.JobSize, \ |
233 | | job.JobPrice, \ |
234 | | job.JobCopies, \ |
235 | | job.JobSizeBytes, \ |
236 | | job.PrinterPageCounter, \ |
237 | | job.JobTitle, \ |
238 | | job.JobFileName, \ |
239 | | job.JobOptions, \ |
240 | | job.JobMD5Sum, \ |
241 | | billingcode_url, \ |
242 | | job.JobPages)]))) |
243 | | self.report.append('</table>') |
244 | | dico = { "history" : 1, |
245 | | "datelimit" : job.JobDate, |
246 | | } |
247 | | if user and user.Exists : |
248 | | dico.update({ "username" : user.Name }) |
249 | | if printer and printer.Exists : |
250 | | dico.update({ "printername" : printer.Name }) |
251 | | if hostname : |
252 | | dico.update({ "hostname" : hostname }) |
253 | | prevurl = "%s?%s" % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode(dico)) |
254 | | self.report.append('<a href="%s">%s</a>' % (prevurl, _("Previous page"))) |
255 | | self.body = "\n".join(self.report) |
| 158 | try : |
| 159 | if not self.form.has_key("history") : |
| 160 | if printers and ugmask : |
| 161 | self.reportingtool = openReporter(admin, "html", printers, ugmask.split(), isgroup) |
| 162 | self.body += "%s" % self.reportingtool.generateReport() |
| 163 | else : |
| 164 | if remuser != "root" : |
| 165 | username = remuser |
| 166 | elif self.form.has_key("username") : |
| 167 | username = self.form["username"].value |
| 168 | else : |
| 169 | username = None |
| 170 | if username is not None : |
| 171 | user = self.storage.getUser(username) |
| 172 | else : |
| 173 | user =None |
| 174 | if self.form.has_key("printername") : |
| 175 | printer = self.storage.getPrinter(self.form["printername"].value) |
| 176 | else : |
| 177 | printer = None |
| 178 | if self.form.has_key("datelimit") : |
| 179 | datelimit = self.form["datelimit"].value |
| 180 | else : |
| 181 | datelimit = None |
| 182 | if self.form.has_key("hostname") : |
| 183 | hostname = self.form["hostname"].value |
| 184 | else : |
| 185 | hostname = None |
| 186 | if self.form.has_key("billingcode") : |
| 187 | billingcode = self.form["billingcode"].value |
| 188 | else : |
| 189 | billingcode = None |
| 190 | self.report = ["<h2>%s</h2>" % _("History")] |
| 191 | history = self.storage.retrieveHistory(user, printer, datelimit, hostname, billingcode) |
| 192 | if not history : |
| 193 | self.report.append("<h3>%s</h3>" % _("Empty")) |
| 194 | else : |
| 195 | self.report.append('<table class="pykotatable" border="1">') |
| 196 | headers = [_("Date"), _("Action"), _("User"), _("Printer"), \ |
| 197 | _("Hostname"), _("JobId"), _("JobSize"), \ |
| 198 | _("JobPrice"), _("Copies"), _("JobBytes"), \ |
| 199 | _("PageCounter"), _("Title"), _("Filename"), \ |
| 200 | _("Options"), _("MD5Sum"), _("BillingCode"), \ |
| 201 | _("Pages")] |
| 202 | self.report.append('<tr class="pykotacolsheader">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers])) |
| 203 | oddeven = 0 |
| 204 | for job in history : |
| 205 | oddeven += 1 |
| 206 | if oddeven % 2 : |
| 207 | oddevenclass = "odd" |
| 208 | else : |
| 209 | oddevenclass = "even" |
| 210 | if job.JobAction == "DENY" : |
| 211 | oddevenclass = "deny" |
| 212 | elif job.JobAction == "WARN" : |
| 213 | oddevenclass = "warn" |
| 214 | username_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "username" : job.UserName}), job.UserName) |
| 215 | printername_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "printername" : job.PrinterName}), job.PrinterName) |
| 216 | if job.JobHostName : |
| 217 | hostname_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "hostname" : job.JobHostName}), job.JobHostName) |
| 218 | else : |
| 219 | hostname_url = None |
| 220 | if job.JobBillingCode : |
| 221 | billingcode_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "billingcode" : job.JobBillingCode}), job.JobBillingCode) |
| 222 | else : |
| 223 | billingcode_url = None |
| 224 | self.report.append('<tr class="%s">%s</tr>' % \ |
| 225 | (oddevenclass, \ |
| 226 | "".join(["<td>%s</td>" % (h or " ") \ |
| 227 | for h in (job.JobDate[:19], \ |
| 228 | job.JobAction, \ |
| 229 | username_url, \ |
| 230 | printername_url, \ |
| 231 | hostname_url, \ |
| 232 | job.JobId, \ |
| 233 | job.JobSize, \ |
| 234 | job.JobPrice, \ |
| 235 | job.JobCopies, \ |
| 236 | job.JobSizeBytes, \ |
| 237 | job.PrinterPageCounter, \ |
| 238 | job.JobTitle, \ |
| 239 | job.JobFileName, \ |
| 240 | job.JobOptions, \ |
| 241 | job.JobMD5Sum, \ |
| 242 | billingcode_url, \ |
| 243 | job.JobPages)]))) |
| 244 | self.report.append('</table>') |
| 245 | dico = { "history" : 1, |
| 246 | "datelimit" : job.JobDate, |
| 247 | } |
| 248 | if user and user.Exists : |
| 249 | dico.update({ "username" : user.Name }) |
| 250 | if printer and printer.Exists : |
| 251 | dico.update({ "printername" : printer.Name }) |
| 252 | if hostname : |
| 253 | dico.update({ "hostname" : hostname }) |
| 254 | prevurl = "%s?%s" % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode(dico)) |
| 255 | self.report.append('<a href="%s">%s</a>' % (prevurl, _("Previous page"))) |
| 256 | self.body = "\n".join(self.report) |
| 257 | except : |
| 258 | self.body += '<p><font color="red">%s</font></p>' % self.crashed("CGI Error").replace("\n", "<br />") |