diff --git a/intranet/modules/factures/main.py b/intranet/modules/factures/main.py index 2a8e0048..1837994e 100755 --- a/intranet/modules/factures/main.py +++ b/intranet/modules/factures/main.py @@ -61,7 +61,7 @@ class main(ModuleBase): } index.exposed = True - def historique(self): + def historique(self, page = 1, items_per_page = 20): adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0] lst = [ x for x in adh.historique() if x.split(u' : ',1)[1].startswith(u'credit') or x.split(u' : ',1)[1].startswith(u'debit') ] @@ -76,10 +76,30 @@ class main(ModuleBase): except Exception: aLine["intitule"] = "" histLst.append(aLine) + + histLst.reverse() + page = int(page) + items_per_page = int(items_per_page) + if page == 1: + prevPage = None + else: + prevPage = page - 1 + + if page * items_per_page >= histLst.__len__(): + nextPage = None + else: + nextPage = page + 1 + offset = items_per_page * ( page - 1) + return { 'template' :'factures-historique', - 'values' :{'liste':lst, 'historic_items':histLst}, + 'values' :{ + 'liste':lst, + 'historic_items':histLst[offset:offset + items_per_page], + 'nextPage':nextPage, + 'prevPage':prevPage + }, 'stylesheets' :['cransFactures.css'], 'scripts' :[], } diff --git a/intranet/modules/factures/templates/factures-historique.tmpl b/intranet/modules/factures/templates/factures-historique.tmpl index 065725d9..93b45cd3 100644 --- a/intranet/modules/factures/templates/factures-historique.tmpl +++ b/intranet/modules/factures/templates/factures-historique.tmpl @@ -10,6 +10,19 @@
Date |
---|