243 | | for printer in printers : |
244 | | print _("*** Report for %s quota on printer %s") % ((options["groups"] and "group") or "user", printer.Name) |
245 | | print _("Pages grace time: %i days") % self.config.getGraceDelay(printer.Name) |
246 | | if printer.PricePerJob is not None : |
247 | | print _("Price per job: %.3f") % printer.PricePerJob |
248 | | if printer.PricePerPage is not None : |
249 | | print _("Price per page: %.3f") % printer.PricePerPage |
250 | | total = 0 |
251 | | totalmoney = 0.0 |
252 | | if options["groups"] : |
253 | | print _("Group used soft hard balance grace total paid") |
254 | | print "------------------------------------------------------------------------------" |
255 | | for (group, grouppquota) in self.storage.getPrinterGroupsAndQuotas(printer, ugnames) : |
256 | | (pages, money) = self.printQuota(group, grouppquota) |
257 | | total += pages |
258 | | totalmoney += money |
259 | | else : |
260 | | # default is user quota report |
261 | | print _("User used soft hard balance grace total paid") |
262 | | print "------------------------------------------------------------------------------" |
263 | | for (user, userpquota) in self.storage.getPrinterUsersAndQuotas(printer, ugnames) : |
264 | | (pages, money) = self.printQuota(user, userpquota) |
265 | | total += pages |
266 | | totalmoney += money |
267 | | if total or totalmoney : |
268 | | print (" " * 50) + (_("Total : %9i") % total) + ("%11s" % ("%7.2f" % totalmoney)[:11]) |
269 | | try : |
270 | | msg = "%9i" % printer.LastJob.PrinterPageCounter |
271 | | except TypeError : |
272 | | msg = _("unknown") |
273 | | print (" " * 51) + (_("Real : %s") % msg) |
274 | | print |
275 | | if options["groups"] : |
276 | | print _("Totals may be inaccurate if some users are members of several groups.") |
277 | | |
278 | | def printQuota(self, entry, quota) : |
279 | | """Prints the quota information.""" |
280 | | lifepagecounter = int(quota.LifePageCounter or 0) |
281 | | pagecounter = int(quota.PageCounter or 0) |
282 | | balance = float(entry.AccountBalance or 0.0) |
283 | | lifetimepaid = float(entry.LifeTimePaid or 0.0) |
284 | | |
285 | | if quota.DateLimit is not None : |
286 | | now = DateTime.now() |
287 | | datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) |
288 | | if now >= datelimit : |
289 | | datelimit = "DENY" |
290 | | elif (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : |
291 | | datelimit = "DENY" |
292 | | elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : |
293 | | datelimit = "DENY" |
294 | | else : |
295 | | datelimit = "" |
297 | | if entry.LimitBy.lower() == "balance" : |
298 | | reached = (((balance <= 0) and "+") or "-") + "B" |
299 | | else : |
300 | | reached = (((quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) and "+") or "-") + "Q" |
301 | | |
302 | | strbalance = ("%5.2f" % balance)[:10] |
303 | | strlifetimepaid = ("%6.2f" % lifetimepaid)[:10] |
304 | | print "%-9.9s %s %7i %7s %7s %10s %-10.10s %8i %10s" % (entry.Name, reached, pagecounter, str(quota.SoftLimit), str(quota.HardLimit), strbalance, str(datelimit)[:10], lifepagecounter, strlifetimepaid) |
305 | | return (lifepagecounter, lifetimepaid) |
| 249 | self.reportingtool = reporter.openReporter(self, "text", printers, ugnames, (options["groups"] and 1) or 0) |
| 250 | print self.reportingtool.generateReport() |