root / pykota / trunk / pykota / reporters / html.py @ 1257

Revision 1257, 3.9 kB (checked in by jalet, 20 years ago)

Copyright year changed.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1# PyKota
2# -*- coding: ISO-8859-15 -*-
3
4# PyKota - Print Quotas for CUPS and LPRng
5#
6# (c) 2003-2004 Jerome Alet <alet@librelogiciel.com>
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20#
21# $Id$
22#
23# $Log$
24# Revision 1.5  2004/01/08 14:10:33  jalet
25# Copyright year changed.
26#
27# Revision 1.4  2004/01/06 15:51:46  jalet
28# Code factorization
29#
30# Revision 1.3  2003/12/27 16:49:25  uid67467
31# Should be ok now.
32#
33# Revision 1.1  2003/12/02 14:41:17  jalet
34# And as always, I forgot most of the new files :-)
35#
36#
37#
38
39from mx import DateTime
40
41from pykota.reporter import BaseReporter, PyKotaReporterError
42   
43class Reporter(BaseReporter) :   
44    """HTML reporter."""
45    def generateReport(self) :
46        """Produces a simple HTML report."""
47        self.report = []
48        if self.isgroup :
49            prefix = "Group"
50        else :   
51            prefix = "User"
52        for printer in self.printers :
53            self.report.append('<h2 class="printername">%s</h2>' % self.getPrinterTitle(printer))
54            self.report.append('<h3 class="printergracedelay">%s</h3>' % self.getPrinterGraceDelay(printer))
55            (pjob, ppage) = self.getPrinterPrices(printer)
56            self.report.append('<h4 class="priceperjob">%s</h4>' % pjob)
57            self.report.append('<h4 class="priceperpage">%s</h4>' % ppage)
58            total = 0
59            totalmoney = 0.0
60            self.report.append('<table class="pykotatable" border="1">')
61            headers = self.getReportHeader().split()
62            headers.insert(1, "LimitBy")
63            self.report.append('<tr class="pykotacolsheader">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers]))
64            oddeven = 0
65            for (entry, entrypquota) in getattr(self.tool.storage, "getPrinter%ssAndQuotas" % prefix)(printer, self.ugnames) :
66                oddeven += 1
67                if oddeven % 2 :
68                    oddevenclass = "odd"
69                else :   
70                    oddevenclass = "even"
71                (pages, money, name, reached, pagecounter, soft, hard, balance, datelimit, lifepagecounter, lifetimepaid) = self.getQuota(entry, entrypquota)
72                if datelimit :
73                    if datelimit == "DENY" :
74                        oddevenclass = "deny"
75                    else :   
76                        oddevenclass = "warn"
77                self.report.append('<tr class="%s">%s</tr>' % (oddevenclass, "".join(["<td>%s</td>" % h for h in (name, reached, pagecounter, soft, hard, balance, datelimit or "&nbsp;", lifepagecounter, lifetimepaid)])))
78                total += pages
79                totalmoney += money
80               
81            if total or totalmoney :       
82                (tpage, tmoney) = self.getTotals(total, totalmoney)
83                self.report.append('<tr class="totals"><td colspan="7">&nbsp;</td><td align="right">%s</td><td align="right">%s</td></tr>' % (tpage, tmoney))
84            self.report.append('<tr class="realpagecounter"><td colspan="7">&nbsp;</td><td align="right">%s</td></tr>' % self.getPrinterRealPageCounter(printer))
85            self.report.append('</table>')
86        if self.isgroup :   
87            self.report.append('<p class="warning">%s</p>' % _("Totals may be inaccurate if some users are members of several groups."))
88        return "\n".join(self.report)   
89                       
Note: See TracBrowser for help on using the browser.