pagination des factures
darcs-hash:20070503213624-f46e9-e18b5311aebc0783e2eb535051a1ec3fba53c0f0.gz
This commit is contained in:
parent
48ccd00b8b
commit
5c5b8c138b
2 changed files with 35 additions and 2 deletions
|
@ -61,7 +61,7 @@ class main(ModuleBase):
|
||||||
}
|
}
|
||||||
index.exposed = True
|
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]
|
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') ]
|
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') ]
|
||||||
|
@ -77,9 +77,29 @@ class main(ModuleBase):
|
||||||
aLine["intitule"] = ""
|
aLine["intitule"] = ""
|
||||||
histLst.append(aLine)
|
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 {
|
return {
|
||||||
'template' :'factures-historique',
|
'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'],
|
'stylesheets' :['cransFactures.css'],
|
||||||
'scripts' :[],
|
'scripts' :[],
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,19 @@
|
||||||
<div id="factureListDiv">
|
<div id="factureListDiv">
|
||||||
<h1>Historique</h1>
|
<h1>Historique</h1>
|
||||||
<div style="overflow:auto;">
|
<div style="overflow:auto;">
|
||||||
|
<div>
|
||||||
|
#if $prevPage
|
||||||
|
<a href="historique?page=$prevPage"><< moins vieux</a>
|
||||||
|
#else
|
||||||
|
<span class="off"><< moins vieux</span>
|
||||||
|
#end if
|
||||||
|
|
|
||||||
|
#if $nextPage
|
||||||
|
<a href="historique?page=$nextPage">plus vieux >></a>
|
||||||
|
#else
|
||||||
|
<span class="off">plus vieux >></span>
|
||||||
|
#end if
|
||||||
|
</div>
|
||||||
<table id="historique_sous" cellspacing="0">
|
<table id="historique_sous" cellspacing="0">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue