| 59 | def getPrinterTitle(self, printer) : |
| 60 | return _("*** Report for %s quota on printer %s") % ((self.isgroup and "group") or "user", printer.Name) |
| 61 | |
| 62 | def getPrinterGraceDelay(self, printer) : |
| 63 | return _("Pages grace time: %i days") % self.tool.config.getGraceDelay(printer.Name) |
| 64 | |
| 65 | def getPrinterPrices(self, printer) : |
| 66 | return (_("Price per job: %.3f") % (printer.PricePerJob or 0.0), _("Price per page: %.3f") % (printer.PricePerPage or 0.0)) |
| 67 | |
| 68 | def getReportHeader(self) : |
| 69 | if self.isgroup : |
| 70 | return _("Group used soft hard balance grace total paid") |
| 71 | else : |
| 72 | return _("User used soft hard balance grace total paid") |
| 73 | |
| 74 | def getPrinterRealPageCounter(self, printer) : |
| 75 | try : |
| 76 | msg = "%9i" % printer.LastJob.PrinterPageCounter |
| 77 | except TypeError : |
| 78 | msg = _("unknown") |
| 79 | return _("Real : %s") % msg |
| 80 | |
| 81 | def getTotals(self, total, totalmoney) : |
| 82 | return (_("Total : %9i") % (total or 0.0), ("%11s" % ("%7.2f" % (totalmoney or 0.0))[:11])) |
| 83 | |
| 84 | def getQuota(self, entry, quota) : |
| 85 | """Prints the quota information.""" |
| 86 | lifepagecounter = int(quota.LifePageCounter or 0) |
| 87 | pagecounter = int(quota.PageCounter or 0) |
| 88 | balance = float(entry.AccountBalance or 0.0) |
| 89 | lifetimepaid = float(entry.LifeTimePaid or 0.0) |
| 90 | |
| 91 | if entry.LimitBy and (entry.LimitBy.lower() == "balance") : |
| 92 | if balance <= 0 : |
| 93 | datelimit = "DENY" |
| 94 | reached = "+B" |
| 95 | else : |
| 96 | datelimit = "" |
| 97 | reached = "-B" |
| 98 | else : |
| 99 | if quota.DateLimit is not None : |
| 100 | now = DateTime.now() |
| 101 | datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit) |
| 102 | if now >= datelimit : |
| 103 | datelimit = "DENY" |
| 104 | elif (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) : |
| 105 | datelimit = "DENY" |
| 106 | elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) : |
| 107 | datelimit = "DENY" |
| 108 | else : |
| 109 | datelimit = "" |
| 110 | reached = (((quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) and "+") or "-") + "Q" |
| 111 | |
| 112 | strbalance = ("%5.2f" % balance)[:10] |
| 113 | strlifetimepaid = ("%6.2f" % lifetimepaid)[:10] |
| 114 | return (lifepagecounter, lifetimepaid, entry.Name, reached, pagecounter, str(quota.SoftLimit), str(quota.HardLimit), strbalance, str(datelimit)[:10], lifepagecounter, strlifetimepaid) |
| 115 | |