From 5460829233560d9b12e9dadf7f555335807aa394 Mon Sep 17 00:00:00 2001 From: gdetrez Date: Wed, 6 Dec 2006 03:04:50 +0100 Subject: [PATCH] ajout d'une interfece pour grer les factures (pour les imprimeurs) darcs-hash:20061206020450-f46e9-809c94407b18245622411b886802adcf1a827861.gz --- intranet/Root.py | 17 +-- intranet/conf/intranet.cfg | 2 + intranet/pages/gestionFactures.py | 132 +++++++++++++++++++++++ intranet/static/css/cransFactures.css | 74 ++++++++++--- intranet/templates/accueil.tmpl | 4 + intranet/templates/factures-gestion.tmpl | 127 ++++++++++++++++++++++ intranet/templates/factures.tmpl | 11 +- 7 files changed, 343 insertions(+), 24 deletions(-) create mode 100755 intranet/pages/gestionFactures.py create mode 100644 intranet/templates/factures-gestion.tmpl diff --git a/intranet/Root.py b/intranet/Root.py index 84adf59a..1a453daa 100755 --- a/intranet/Root.py +++ b/intranet/Root.py @@ -98,6 +98,7 @@ class Intranet: __ldap = None def __init__(self): from pages import monCompte, impression, factures, digicode, mesmachines + from pages import gestionFactures self.__ldap = cherrypy.config.configMap["global"]["crans_ldap"] # liste des modules disponibles @@ -106,11 +107,10 @@ class Intranet: self.impression = impression.root() self.digicode = digicode.root() self.mesMachines = mesmachines.root() - + self.gestionFactures = gestionFactures.root() + # liste des modules en developpement #if (cherrypy.config.configMap["global"]["server.environment"] == "development"): - - _cpFilterList = [TemplatesFilter(), DOMFilter(), VerifDroitsFilter()] @@ -133,9 +133,9 @@ class Intranet: def send_error_repport(self, **kw): - # on récupère tout de suite le traceback + # on récupère tout de suite le traceback tb = crans.utils.exceptions.formatExc() - # entêtes du mail + # entêtes du mail exp = "intranet" dest = cherrypy.config.get("mail.bugreport", "nounous@crans.org") subject = "Rapport de Bug" @@ -171,7 +171,7 @@ Ceci est un rapport de bug envoye par l'intranet. text += "\n= Traceback =\n" text += tb - #on signe, quand même ! + #on signe, quand même ! text += "\n-- \nRoot.py pour l'intranet\n" quickSend(exp, dest, subject, text) @@ -189,6 +189,9 @@ Ceci est un rapport de bug envoye par l'intranet. test.exposed = True def _cp_on_http_error(self, status, message): + if (cherrypy.config.configMap["global"]["server.environment"] == "development"): + cherrypy._cputil._cp_on_http_error(status, message) + return if status==403: cherrypy.response.body = { 'template':'error403', @@ -203,7 +206,7 @@ Ceci est un rapport de bug envoye par l'intranet. } elif status==500: self.send_error_repport(status = status, message = message ) - # les filtres ne sont pas appliqués, on le fait à la main... + # les filtres ne sont pas appliqués, on le fait à la main... from plugins.templatesfilter import TemplatesFilter TemplatesFilter().goWithThisDict({'template':'error', 'values':{'status':status, 'message':message }}) else: diff --git a/intranet/conf/intranet.cfg b/intranet/conf/intranet.cfg index a85c6775..2468afff 100644 --- a/intranet/conf/intranet.cfg +++ b/intranet/conf/intranet.cfg @@ -16,6 +16,8 @@ templatesEngine.on = True [/digicode] crans.droits="Imprimeur" +[/gestionFactures] +crans.droits="Imprimeur" [/static] sessionAuthenticateFilter.on=False diff --git a/intranet/pages/gestionFactures.py b/intranet/pages/gestionFactures.py new file mode 100755 index 00000000..6394697f --- /dev/null +++ b/intranet/pages/gestionFactures.py @@ -0,0 +1,132 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-15 -*- +# ##################################################################################################### # +# Factures (gestion) +# ##################################################################################################### # +# Description: +# Permet de chercher dans les facture, d'en créditer et d'en supprimer +# Informations: +# +# Pages: +# index:afiche le formulaire et les factures +# +# ##################################################################################################### # +import cherrypy, sys, os, datetime +import crans.cp + +class root: + + def index(self, message = '', erreur = ''): + if cherrypy.session.has_key('gestion_factures-current_search'): + del cherrypy.session['gestion_factures-current_search'] + return self.displayTemplate() + index.exposed = True + + def search(self, fid=None, uid=None, aid=None): + cherrypy.session['gestion_factures-current_search'] = { + "fid":fid, + "uid":uid, + "aid":aid, + } + return self.displayTemplate() + search.exposed = True + + + + def displayTemplate(self, message = '', erreur = ''): + t = {} + t['message'] = message + t['error'] = erreur + if cherrypy.session.has_key('gestion_factures-current_search'): + fid = cherrypy.session['gestion_factures-current_search']['fid'] + uid = cherrypy.session['gestion_factures-current_search']['uid'] + aid = cherrypy.session['gestion_factures-current_search']['aid'] + t['listeFactures'] = self.buildInvoiceList( + fid = fid, + uid = uid, + aid = aid, + ) + + else: + fid = "" + uid = "" + aid = "" + t["form"] = [] + t["form"]+= [{'name':'fid', 'label':'fid', 'value':fid}] + t["form"]+= [{'name':'uid', 'label':'login', 'value':uid}] + t["form"]+= [{'name':'aid', 'label':'aid', 'value':aid}] + + return { + 'template' :'factures-gestion', + 'values' :t, + 'stylesheets' :['cransFactures.css'], + } + + + + + def buildInvoiceList(self, fid=None, uid=None, aid=None): + ############## liste des factures ############## + if fid: + search_string = "fid=%s" % str(fid) + liste_factures_ldap = cherrypy.session['LDAP'].search(search_string)['facture'] + elif uid: + search_string = "uid=%s" % str(uid) + try: + liste_factures_ldap = cherrypy.session['LDAP'].search(search_string)['adherent'][0].factures() + except: + liste_factures_ldap = [] + elif aid: + search_string = "aid=%s" % str(aid) + try: + liste_factures_ldap = cherrypy.session['LDAP'].search(search_string)['adherent'][0].factures() + except: + liste_factures_ldap = [] + else: + return [] + liste_factures_affichees = [] + for f in liste_factures_ldap: + facture = {} + facture['no'] = f.numero() + facture['adherent'] = f.proprietaire().mail() + facture['montant'] = f.total() + facture['payee'] = f.recuPaiement() + facture['intitule'] = f.articles()[0]['designation'] + facture['details'] = [ + { + 'intitule':art['designation'], + 'quantite':art['nombre'], + 'prixUnitaire':art['pu'], + 'prixTotal':art['pu']*art['nombre'], + } for art in f.articles()] + liste_factures_affichees.append(facture) + + + return liste_factures_affichees + + def delFacture(self, fid): + try: + # trrouver la factures + fact = cherrypy.session['LDAP'].search('fid=' + fid, 'w')['facture'][0] + # la supprimer + fact.delete() + except Exception, e: + crans.cp.log(unicode(e), "GESTION FACTURES", 1) + return self.index(erreur=u"Problème lors de la suppression") + crans.cp.log(u"Facture supprimée [fid=%s]" % fid, "GESTION FACTURES") + return self.index(message=u"Facture suprimée") + delFacture.exposed = True + + def crediteFacture(self, fid): + try: + # trrouver la factures + fact = cherrypy.session['LDAP'].search('fid=' + fid, 'w')['facture'][0] + # la supprimer + fact.recuPaiement(cherrypy.session['uid']) + fact.save() + except Exception, e: + crans.cp.log("pb crédit", "GESTION FACTURES", 1) + return self.index(erreur=u"Problème lors du crédit") + crans.cp.log("Facture créditée [fid=%s]" % fid, "GESTION FACTURES") + return self.index(message=u"Facture créditée") + crediteFacture.exposed = True diff --git a/intranet/static/css/cransFactures.css b/intranet/static/css/cransFactures.css index e3ed9357..dda0af9f 100644 --- a/intranet/static/css/cransFactures.css +++ b/intranet/static/css/cransFactures.css @@ -2,18 +2,15 @@ * ********************************************/ #globalDiv { - padding-left:200px; + //padding-left:20%; position: relative; } ul#actionMenu { - list-style-type:none; - position:absolute; - width:190px; - top:0; - left:0; - margin:20px; - padding:0; + list-style-type:none; + width:18%; + padding:0; + float:left; } h1 { @@ -27,6 +24,8 @@ td, tr { #factureListDiv { padding:5px; background:#fad163; + float:left; + width:75%; } #factureListDiv table#listeFactures { @@ -39,12 +38,20 @@ td, tr { position:relative; } -.factureRow .factureSummary { - height:30px; - font-weight:bold; - padding:10px 20px; +.help_text { background:#fff7D7; + font-weight:normal; + padding:10px 20px; + } + +.factureRow .factureSummary { + background:#fff7D7; + height:30px; + font-weight:bold; + padding:10px 20px; +} + .factureRow .factureSummary span.intitule { float:left; } @@ -153,3 +160,46 @@ table#historique_sous th { padding:5px; text-decoration:underline; } + +/******************************************** + * +********************************************/ + +form.search { + display:block; + border: thin black solid; + padding:.2em 1em; + float:left; + //position:absolute; + width:18%; + //top:0; + //left:0; + margin:0 1%; +} + +form.search input { + max-width:95%; + margin:.3em; + float:left; + border: thin gray solid; +} + +form.search label { + padding-top:7px; + display:block; + width:4em; + float:left; + clear:left; +font-weight:bold; +} + +form.search h3 { + margin:.2em 0; +} + +form.search input.button { + margin:.5em; + text-align:center; + clear:left; +} + diff --git a/intranet/templates/accueil.tmpl b/intranet/templates/accueil.tmpl index b7b5cdf3..dcdf295e 100644 --- a/intranet/templates/accueil.tmpl +++ b/intranet/templates/accueil.tmpl @@ -36,6 +36,10 @@ $sys.path.append(cherrypy.config.get('rootDir')) icon Digicode +
  • + icon + Gestion factures +
  • diff --git a/intranet/templates/factures-gestion.tmpl b/intranet/templates/factures-gestion.tmpl new file mode 100644 index 00000000..b97a19db --- /dev/null +++ b/intranet/templates/factures-gestion.tmpl @@ -0,0 +1,127 @@ +
    + +#if $getVar('message', False) +#if $message != '' + +#end if +#end if + +#if $getVar('error', False) +#if $error != '' + +#end if +#end if + + + + +
    + + + +#if $getVar('listeFactures', "n/a") != "n/a" +
    +

    Résultats de la recherche

    + #for f in $listeFactures + #if $f.payee +
    + #else +
    + #end if +
    + + #if $f.details.__len__() > 1 + + #end if + [fid : $f.no] $f.intitule + #if not $f.payee + (non payée) + #end if + + + + $f.montant € + + Adhérent : $f.adherent + #if not $f.payee + + Supprimer + Créditer + + #else + Payée + #end if + +
    + #if $f.details.__len__() > 1 + +
    + #end if + #end for + + #if $listeFactures == [] +
    + AUCUN RÉSULTAT +
    + #end if +
    +#else +
    +

    Gestion des factures

    +
    +

    Interface de gestion des factures.

    +

    Permet à qui de droit de supprimer et de créditer les factures des adhérents.

    +

    La recherche ne prend en compte qu'un seul paramètre. (dans l'ordre de priorité : fid, login et aid)

    +
    +
    + +#end if + + +
    diff --git a/intranet/templates/factures.tmpl b/intranet/templates/factures.tmpl index f5505057..7551fcc8 100644 --- a/intranet/templates/factures.tmpl +++ b/intranet/templates/factures.tmpl @@ -28,7 +28,12 @@ function hideDetail(id){ -
    +
    + +

    Mes factures PayPal

    @@ -98,9 +103,5 @@ function hideDetail(id){
    #end if
    -