213 | | for (printerid, printer) in printers : |
214 | | print _("*** Report for %s quota on printer %s") % ((options["groups"] and "group") or "user", printer) |
215 | | print _("Pages grace time: %i days") % self.config.getGraceDelay(printer) |
216 | | prices = self.storage.getPrinterPrices(printerid) |
217 | | if prices is None : |
218 | | (perpage, perjob) = (None, None) |
219 | | else : |
220 | | (perpage, perjob) = prices |
221 | | if perjob is not None : |
222 | | print _("Price per job: %.3f") % perjob |
223 | | if perpage is not None : |
224 | | print _("Price per page: %.3f") % perpage |
| 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 |
230 | | for (ident, name) in (self.storage.getPrinterGroups(printerid) or []) : |
231 | | quota = self.storage.getGroupPQuota(ident, printerid) |
232 | | balance = self.storage.getGroupBalance(ident) |
233 | | limitby = self.storage.getGroupLimitBy(ident) |
234 | | (pages, money) = self.printQuota(name, quota, balance, limitby) |
| 255 | for (group, grouppquota) in self.storage.getPrinterGroupsAndQuotas(printer, ugnames) : |
| 256 | (pages, money) = self.printQuota(group, grouppquota) |
241 | | for (ident, name) in (self.storage.getPrinterUsers(printerid) or []) : |
242 | | quota = self.storage.getUserPQuota(ident, printerid) |
243 | | balance = self.storage.getUserBalance(ident) |
244 | | limitby = self.storage.getUserLimitBy(ident) |
245 | | (pages, money) = self.printQuota(name, quota, balance, limitby) |
| 263 | for (user, userpquota) in self.storage.getPrinterUsersAndQuotas(printer, ugnames) : |
| 264 | (pages, money) = self.printQuota(user, userpquota) |
262 | | if quota is not None : |
263 | | lifepagecounter = quota["lifepagecounter"] or 0 |
264 | | pagecounter = quota["pagecounter"] or 0 |
265 | | softlimit = quota["softlimit"] |
266 | | hardlimit = quota["hardlimit"] |
267 | | datelimit = quota["datelimit"] |
268 | | if balance is not None : |
269 | | (balance, lifetimepaid) = balance |
270 | | else : |
271 | | (balance, lifetimepaid) = (0.0, 0.0) |
272 | | if datelimit is not None : |
273 | | now = DateTime.now() |
274 | | datelimit = DateTime.ISO.ParseDateTime(datelimit) |
275 | | if now >= datelimit : |
276 | | datelimit = "DENY" |
277 | | else : |
278 | | datelimit = "" |
279 | | if limitby == "balance" : |
280 | | reached = (((balance <= 0) and "+") or "-") + "B" |
281 | | else : |
282 | | reached = (((softlimit is not None) and (pagecounter >= softlimit) and "+") or "-") + "Q" |
283 | | balance = balance or 0.0 |
284 | | lifetimepaid = lifetimepaid or 0.0 |
285 | | strbalance = ("%5.2f" % balance)[:10] |
286 | | strlifetimepaid = ("%6.2f" % lifetimepaid)[:10] |
287 | | print "%-9.9s %s %7i %7s %7s %10s %-10.10s %8i %10s" % (name, reached, pagecounter, str(softlimit), str(hardlimit), strbalance, str(datelimit)[:10], lifepagecounter, strlifetimepaid) |
288 | | return (lifepagecounter, lifetimepaid) |
| 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" |
290 | | return (0, 0) |
291 | | |
| 295 | datelimit = "" |
| 296 | |
| 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) |