ajout d'une interfece pour grer les factures (pour les imprimeurs)
darcs-hash:20061206020450-f46e9-809c94407b18245622411b886802adcf1a827861.gz
This commit is contained in:
parent
5f4a61091f
commit
5460829233
7 changed files with 343 additions and 24 deletions
|
@ -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:
|
||||
|
|
|
@ -16,6 +16,8 @@ templatesEngine.on = True
|
|||
|
||||
[/digicode]
|
||||
crans.droits="Imprimeur"
|
||||
[/gestionFactures]
|
||||
crans.droits="Imprimeur"
|
||||
|
||||
[/static]
|
||||
sessionAuthenticateFilter.on=False
|
||||
|
|
132
intranet/pages/gestionFactures.py
Executable file
132
intranet/pages/gestionFactures.py
Executable file
|
@ -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
|
|
@ -2,18 +2,15 @@
|
|||
* <!-- disposition générale -->
|
||||
********************************************/
|
||||
#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;
|
||||
}
|
||||
|
||||
/********************************************
|
||||
* <!-- factures - recherche -->
|
||||
********************************************/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,10 @@ $sys.path.append(cherrypy.config.get('rootDir'))
|
|||
<img src="/static/images/icon_digicode.png" alt="icon" />
|
||||
<span>Digicode</span>
|
||||
</a></li>
|
||||
<li><a href="/gestionFactures">
|
||||
<img src="/static/images/icon_gestionFactures.png" alt="icon" />
|
||||
<span>Gestion factures</span>
|
||||
</a></li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
<div class="visualClear"></div>
|
||||
|
|
127
intranet/templates/factures-gestion.tmpl
Normal file
127
intranet/templates/factures-gestion.tmpl
Normal file
|
@ -0,0 +1,127 @@
|
|||
<div id="messagePlaceHolder"></div>
|
||||
|
||||
#if $getVar('message', False)
|
||||
#if $message != ''
|
||||
<script type="text/javascript">Crans.messages.setMessage('$message.replace("\'","\\\'")')</script>
|
||||
#end if
|
||||
#end if
|
||||
|
||||
#if $getVar('error', False)
|
||||
#if $error != ''
|
||||
<script type="text/javascript">Crans.messages.setMessage('$error.replace("\'","\\\'")', 'errorMessage')</script>
|
||||
#end if
|
||||
#end if
|
||||
|
||||
<script type="text/javascript">
|
||||
function showDetail(id){
|
||||
slideDown(id, {duration:0.4});
|
||||
var element = document.getElementById("togglelink" + id);
|
||||
element.onclick=null;
|
||||
element.style.backgroundPosition='bottom left';
|
||||
setTimeout("var element = document.getElementById(\'togglelink" + id + "\');element.onclick=function () {hideDetail(\'" + id + "\'); return false;};",450);
|
||||
return false;
|
||||
}
|
||||
function hideDetail(id){
|
||||
slideUp(id, {duration:0.4});
|
||||
var element = document.getElementById("togglelink" + id);
|
||||
element.onclick=null;
|
||||
element.style.backgroundPosition="top left";
|
||||
setTimeout("var element = document.getElementById(\'togglelink" + id + "\');element.onclick=function () {showDetail(\'" + id + "\'); return false;};",450);
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<div id="globalDiv">
|
||||
<form action="search" method="post" class="search">
|
||||
<h3>Recherche</h3>
|
||||
#for an_input in $form
|
||||
<label for="$an_input.name">$an_input.label :</label><input type="text" name="$an_input.name" value="$an_input.value" /><br />
|
||||
#end for
|
||||
<input class="button" type="submit" value="Chercher" />
|
||||
</form>
|
||||
|
||||
|
||||
#if $getVar('listeFactures', "n/a") != "n/a"
|
||||
<div id="factureListDiv">
|
||||
<h1>Résultats de la recherche</h1>
|
||||
#for f in $listeFactures
|
||||
#if $f.payee
|
||||
<div class="factureRow facturePayee">
|
||||
#else
|
||||
<div class="factureRow factureNonPayee">
|
||||
#end if
|
||||
<div class="factureSummary">
|
||||
<span class="intitule">
|
||||
#if $f.details.__len__() > 1
|
||||
<a href="#" class="linkToggle" id="togglelinkfacture$f.no" onclick="showDetail('facture$f.no'); return false;"></a>
|
||||
#end if
|
||||
[fid : $f.no] $f.intitule
|
||||
#if not $f.payee
|
||||
(non payée)
|
||||
#end if
|
||||
|
||||
</span>
|
||||
<span class="montant">
|
||||
$f.montant €
|
||||
</span>
|
||||
<span class="note" style="float:left;clear: left;">Adhérent : $f.adherent</span>
|
||||
#if not $f.payee
|
||||
<span class="actions">
|
||||
<a href="delFacture?fid=$f.no">Supprimer</a>
|
||||
<a href="crediteFacture?fid=$f.no">Créditer</a>
|
||||
</span>
|
||||
#else
|
||||
<span class="note" style="float:right;clear:right;">Payée</span>
|
||||
#end if
|
||||
|
||||
</div>
|
||||
#if $f.details.__len__() > 1
|
||||
<div id="facture$f.no" style="display:none;">
|
||||
<table cellspacing="0" border="0" class="factureDetails">
|
||||
<tr>
|
||||
<th style="width:80%">Description</th>
|
||||
<th>Prix unitaire</th>
|
||||
<th>Quantité</th>
|
||||
<th>total</th>
|
||||
</tr>
|
||||
#for unDetail in $f.details
|
||||
<tr>
|
||||
<td>$unDetail.intitule</td>
|
||||
<td>$unDetail.prixUnitaire €</td>
|
||||
<td>$unDetail.quantite</td>
|
||||
<td>$unDetail.prixTotal €</td>
|
||||
</tr>
|
||||
#end for
|
||||
<tr>
|
||||
<td colspan="3" class="tdTotalDetailIntitule">
|
||||
Total
|
||||
</td>
|
||||
<td class="tdTotalDetail">$f.montant €</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
#end if
|
||||
#end for
|
||||
|
||||
#if $listeFactures == []
|
||||
<div class="factureRow tdNoFactures">
|
||||
AUCUN RÉSULTAT
|
||||
</div>
|
||||
#end if
|
||||
</div>
|
||||
#else
|
||||
<div id="factureListDiv">
|
||||
<h1>Gestion des factures</h1>
|
||||
<div class="help_text">
|
||||
<p>Interface de gestion des factures.</p>
|
||||
<p> Permet à qui de droit de supprimer et de créditer les factures des adhérents.</p>
|
||||
<p> La recherche ne prend en compte qu'un seul paramètre. (dans l'ordre de priorité : fid, login et aid) </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
#end if
|
||||
|
||||
|
||||
</div>
|
|
@ -28,7 +28,12 @@ function hideDetail(id){
|
|||
</script>
|
||||
|
||||
|
||||
<div id="globalDiv" style="padding-left:200px;">
|
||||
<div id="globalDiv">
|
||||
<ul id="actionMenu">
|
||||
<li><a href="index">Mes factures PayPal</a></li>
|
||||
<li><a href="historique">Historique des transactions</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="factureListDiv">
|
||||
<h1>Mes factures PayPal</h1>
|
||||
<!-- <table id="listeFactures" cellspacing="0" border="0"> -->
|
||||
|
@ -98,9 +103,5 @@ function hideDetail(id){
|
|||
</div>
|
||||
#end if
|
||||
</div>
|
||||
<ul id="actionMenu">
|
||||
<li><a href="index">Mes factures PayPal</a></li>
|
||||
<li><a href="historique">Historique des transactions</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue