Index: pykota/trunk/NEWS
===================================================================
--- pykota/trunk/NEWS (revision 2219)
+++ pykota/trunk/NEWS (revision 2220)
@@ -24,4 +24,7 @@
     - 1.22alpha8 :
     
+        - Clicking on the billing code in printquota.cgi's job history
+          now shows all jobs matching this billing code.
+          
         - Fixed the dump in CUPS' page_log format which didn't
           dump the oldest entry.
Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 2218)
+++ pykota/trunk/pykota/storages/sql.py (revision 2220)
@@ -498,5 +498,5 @@
         self.doModify("DELETE FROM printergroupsmembers WHERE groupid=%s AND printerid=%s" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident)))
         
-    def retrieveHistory(self, user=None, printer=None, datelimit=None, hostname=None, limit=100) :    
+    def retrieveHistory(self, user=None, printer=None, datelimit=None, hostname=None, billingcode=None, limit=100) :
         """Retrieves all print jobs for user on printer (or all) before date, limited to first 100 results."""
         query = "SELECT jobhistory.*,username,printername FROM jobhistory,users,printers WHERE users.id=userid AND printers.id=printerid"
@@ -508,4 +508,6 @@
         if hostname is not None :    
             where.append("hostname=%s" % self.doQuote(hostname))
+        if billingcode is not None :    
+            where.append("billingcode=%s" % self.doQuote(self.userCharsetToDatabase(billingcode)))
         if datelimit is not None :    
             where.append("jobdate<=%s" % self.doQuote(datelimit))
Index: pykota/trunk/cgi-bin/printquota.cgi
===================================================================
--- pykota/trunk/cgi-bin/printquota.cgi (revision 2210)
+++ pykota/trunk/cgi-bin/printquota.cgi (revision 2220)
@@ -183,6 +183,10 @@
             else :    
                 hostname = None
+            if self.form.has_key("billingcode") :    
+                billingcode = self.form["billingcode"].value
+            else :    
+                billingcode = None
             self.report = ["<h2>%s</h2>" % _("History")]    
-            history = self.storage.retrieveHistory(user, printer, datelimit, hostname)
+            history = self.storage.retrieveHistory(user, printer, datelimit, hostname, billingcode)
             if not history :
                 self.report.append("<h3>%s</h3>" % _("Empty"))
@@ -213,5 +217,28 @@
                     else :    
                         hostname_url = None
-                    self.report.append('<tr class="%s">%s</tr>' % (oddevenclass, "".join(["<td>%s</td>" % (h or "&nbsp;") for h in (job.JobDate[:19], job.JobAction, username_url, printername_url, hostname_url, job.JobId, job.JobSize, job.JobPrice, job.JobCopies, job.JobSizeBytes, job.PrinterPageCounter, job.JobTitle, job.JobFileName, job.JobOptions, job.JobMD5Sum, job.JobBillingCode, job.JobPages)])))
+                    if job.JobBillingCode :
+                        billingcode_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "billingcode" : job.JobBillingCode}), job.JobBillingCode)
+                    else :    
+                        billingcode_url = None
+                    self.report.append('<tr class="%s">%s</tr>' % \
+                                          (oddevenclass, \
+                                           "".join(["<td>%s</td>" % (h or "&nbsp;") \
+                                              for h in (job.JobDate[:19], \
+                                                        job.JobAction, \
+                                                        username_url, \
+                                                        printername_url, \
+                                                        hostname_url, \
+                                                        job.JobId, \
+                                                        job.JobSize, \
+                                                        job.JobPrice, \
+                                                        job.JobCopies, \
+                                                        job.JobSizeBytes, \
+                                                        job.PrinterPageCounter, \
+                                                        job.JobTitle, \
+                                                        job.JobFileName, \
+                                                        job.JobOptions, \
+                                                        job.JobMD5Sum, \
+                                                        billingcode_url, \
+                                                        job.JobPages)])))
                 self.report.append('</table>')
                 dico = { "history" : 1,
