diff --git a/gestion/tools/liste_adh.py b/gestion/tools/liste_adh.py new file mode 100755 index 00000000..dc119424 --- /dev/null +++ b/gestion/tools/liste_adh.py @@ -0,0 +1,76 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-15 -*- + +import sys +sys.path.append('/usr/scripts/gestion') +from ldap_crans import crans_ldap, decode +db = crans_ldap() + +bats = 'ABCGHIJMP' + +def titre (bat) : + if bat == 'P' : + return 'Pavillon des jardins' + elif bat == '?' : + return 'Autres (extérieurs et chambres invalides)' + else : + return 'Bâtiment %s' % bat + +# création de la liste vide +########################### + +liste = {} +for bat in bats + '?' : + liste[bat] = [] + +# remplissage de la liste +######################### + +# les batiments +for bat in bats : + adhs = db.search( 'chbre=%s*&paiement=ok' % bat )['adherent'] + for adh in adhs : + liste[bat].append( u'%s %s' % ( adh.nom(), adh.prenom() ) ) + +# les extérieurs +adhs = db.search( 'paiement=ok' )['adherent'] +for adh in adhs : + if not adh.chbre()[0] in bats : + liste['?'].append( u'%s %s' % ( adh.nom(), adh.prenom() ) ) + +# création du fichier tex +######################### + +print """\\documentclass[a4paper,11pt]{article} +\\usepackage[T1]{fontenc} +\\usepackage[francais]{babel} +\\usepackage{longtable} +\\usepackage{geometry} +\\usepackage{fancyheadings} +\\geometry{ hmargin=2cm, vmargin=4cm } + +\\begin{document} +\\lhead{A.G.O. du CR@NS} +\\rhead{21 avril 2005} +\\pagestyle{fancy} +""" + +for bat in bats + '?' : + # entete du batiment + print """\\section{%(bat)s}\n +\\chead{\emph{%(bat)s}} +\\begin{longtable}{| p{2.5in} | p{1.5in} |} +\\hline +\\textbf{Nom Prenom} & \\textbf{Signature} \\\\ +\\hline +\\endhead""" % {'bat' : titre(bat) } + + # ajout des adhérents + liste[bat].sort() + for adh in liste[bat] : + print (u'%s& \\\\\n\\hline' % adh).encode('iso 8859-15') + + # fin du batiment + print "\\end{longtable}\n" + +print "\\end{document}"