223 | | if printers and ugmask : |
224 | | self.reportingtool = openReporter(admin, "html", printers, ugmask.split(), isgroup) |
225 | | # self.body += "<pre>%s</pre>" % self.reportingtool.generateReport() |
226 | | self.body += "%s" % self.reportingtool.generateReport() |
| 227 | if not self.form.has_key("history") : |
| 228 | if printers and ugmask : |
| 229 | self.reportingtool = openReporter(admin, "html", printers, ugmask.split(), isgroup) |
| 230 | self.body += "%s" % self.reportingtool.generateReport() |
| 231 | else : |
| 232 | remuser = os.environ.get("REMOTE_USER", "root") |
| 233 | if remuser != "root" : |
| 234 | username = remuser |
| 235 | elif self.form.has_key("username") : |
| 236 | username = self.form["username"].value |
| 237 | else : |
| 238 | username = None |
| 239 | if username is not None : |
| 240 | user = self.storage.getUser(username) |
| 241 | else : |
| 242 | user =None |
| 243 | if self.form.has_key("printername") : |
| 244 | printer = self.storage.getPrinter(self.form["printername"].value) |
| 245 | else : |
| 246 | printer = None |
| 247 | if self.form.has_key("datelimit") : |
| 248 | datelimit = self.form["datelimit"].value |
| 249 | else : |
| 250 | datelimit = None |
| 251 | self.report = ["<h2>History</h2>"] |
| 252 | history = self.storage.retrieveHistory(user, printer, datelimit) |
| 253 | if not history : |
| 254 | self.report.append("<h3>Empty</h3>") |
| 255 | else : |
| 256 | self.report.append('<table class="pykotatable" border="1">') |
| 257 | headers = ["Date", "User", "Printer", "PageCounter", "JobId", "JobSize", "JobPrice", "Copies", "Title", "Filename", "Options", "Action"] |
| 258 | self.report.append('<tr class="pykotacolsheader">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers])) |
| 259 | oddeven = 0 |
| 260 | for job in history : |
| 261 | oddeven += 1 |
| 262 | if oddeven % 2 : |
| 263 | oddevenclass = "odd" |
| 264 | else : |
| 265 | oddevenclass = "even" |
| 266 | if job.JobAction == "DENY" : |
| 267 | oddevenclass = "deny" |
| 268 | elif job.JobAction == "WARN" : |
| 269 | oddevenclass = "warn" |
| 270 | self.report.append('<tr class="%s">%s</tr>' % (oddevenclass, "".join(["<td>%s</td>" % h for h in (job.JobDate, job.User.Name, job.Printer.Name, job.PrinterPageCounter, job.JobId, job.JobSize, job.JobPrice, job.JobCopies, job.JobTitle, job.JobFileName, job.JobOptions, job.JobAction)]))) |
| 271 | self.report.append('</table>') |
| 272 | dico = { "history" : 1, |
| 273 | "datelimit" : job.JobDate, |
| 274 | } |
| 275 | if user and user.Exists : |
| 276 | dico.update({ "username" : user.Name }) |
| 277 | if printer and printer.Exists : |
| 278 | dico.update({ "printername" : printer.Name }) |
| 279 | prevurl = "%s?%s" % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode(dico)) |
| 280 | self.report.append('<a href="%s">Previous page</a>' % prevurl) |
| 281 | self.body = "\n".join(self.report) |