Ajout des modules initiaux

darcs-hash:20070124114812-f46e9-171ef12f1e1b89ae005adf4aab6f6535fb9289e6.gz
This commit is contained in:
gdetrez 2007-01-24 12:48:12 +01:00
parent 8713311bc1
commit ed3ab40ccd
80 changed files with 4852 additions and 5 deletions

100
intranet/modules/factures/main.py Executable file
View file

@ -0,0 +1,100 @@
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
# ##################################################################################################### #
# Factures
# ##################################################################################################### #
# Description:
# Affiche la liste des factures et l'historique de débits/crédits de l'adhérent.
# Informations:
#
# Pages:
# index:liste des factures
# historique: historique des débits/crédits
#
# ##################################################################################################### #
import cherrypy, sys, os, datetime
from ClassesIntranet.ModuleBase import ModuleBase
class main(ModuleBase):
def title(self):
return "Factures"
def icon(self):
return "icon.png"
def index(self, message = '', error = ''):
adh = cherrypy.session['LDAP'].search('uid=' + cherrypy.session['uid'])['adherent'][0]
t = {}
t['message'] = message
t['error'] = error
############## liste des factures ##############
listeFactures = []
for f in adh.factures():
facture = {}
facture['no'] = f.numero()
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()]
facture['montant'] = f.total()
facture['paypal'] = f.urlPaypal(useSandbox = cherrypy.config.get("paypal.useSandbox", False),
businessMail = cherrypy.config.get("paypal.businessAdress", "paypal@crans.org"),
return_page = "https://intranet.crans.org/monCompte/paypalReturn",
cancel_return_page = "https://intranet.crans.org/monCompte/paypalCancel",
)
facture['payee'] = f.recuPaiement()
listeFactures.append(facture)
t['listeFactures'] = listeFactures
return {
'template' :'factures',
'values' :t,
'stylesheets' :['cransFactures.css'],
'scripts' :[],
}
index.exposed = True
def historique(self):
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') ]
histLst = []
for anItem in lst:
aLine = {}
aLine["date"] = anItem.split(u",")[0]
aLine["type"] = anItem.split(u' : ',2)[1].split(u' ')[0]
aLine["montant"] = anItem.split(u' : ',2)[1].split(u' ')[1]
try:
aLine["intitule"] = anItem.split(u'[')[1].split(u']')[0]
except Exception:
aLine["intitule"] = ""
histLst.append(aLine)
return {
'template' :'factures-historique',
'values' :{'liste':lst, 'historic_items':histLst},
'stylesheets' :['cransFactures.css'],
'scripts' :[],
}
historique.exposed = True
def delFacture(self, no):
try:
# trrouver la factures
fact = cherrypy.session['LDAP'].search('fid=' + no, 'w')['facture'][0]
#verifier qu'elle appartient bien a l'adherent
if not fact.proprietaire().mail() == cherrypy.session['uid']:
raise Exception, "Impossible de supprimer cette facture"
# la supprimer
fact.delete()
except Exception, e:
cherrypy.log(str(e), "FACTURES", 1)
return self.index()
delFacture.exposed = True

View file

@ -0,0 +1,205 @@
/********************************************
* <!-- disposition générale -->
********************************************/
#globalDiv {
//padding-left:20%;
position: relative;
}
ul#actionMenu {
list-style-type:none;
width:18%;
padding:0;
float:left;
}
h1 {
font-size:1.4em;
margin:2px;
}
td, tr {
margin:0;
}
#factureListDiv {
padding:5px;
background:#fad163;
float:left;
width:75%;
}
#factureListDiv table#listeFactures {
padding:0;
width:100%;
}
.factureRow {
margin:2px;
position:relative;
}
.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;
}
.factureRow .factureSummary span.montant {
float:right;
text-align:right;
}
.tdNoFactures {
text-align:center;
font-size:1.2em;
background-color:#fff7D7;
color:#666;
margin:0;
padding:5px;
}
.facturePayee {
}
.factureNonPayee .factureSummary {
color:red;
}
.actions {
display:block;
float:right;
font-size:0.9em;
font-weight:normal;
}
.actions a {
margin:2px 10px;
}
/********************************************
* <!-- factures - details -->
********************************************/
table.factureDetails {
background: #fff7D7 url(fondFacturesDetails.png) repeat-x top;
padding:1%;
width:96%;
margin:0 1% 10px 1%;
}
.tdTotalDetail,
.tdTotalDetailIntitule {
border-top:thin black solid;
}
.tdTotalDetailIntitule {
text-align:right;
font-weight:bold;
}
table.factureDetails th {
border-bottom:thin black solid;
}
table.factureDetails th,
table.factureDetails td {
border-right:thin black solid;
margin:0;
padding:5px 20px;
}
/********************************************
* <!-- factures - divers -->
********************************************/
.note {
display:block;
font-size:small;
margin:3px;
font-weight:normal;
}
.note {
color:#666
}
.linkToggle {
display:block;
float:left;
height:15px;
width:15px;
background:transparent url(fl.png) top left;
margin-right:1px;
}
/********************************************
* <!-- factures - historique -->
********************************************/
table#historique_sous {
width:100%;
}
table#historique_sous td {
background:#fff7D7;
padding:5px;
text-align:center;
border-top:2px #fad163 solid;
}
table#historique_sous th {
background:#fff7D7;
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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

@ -0,0 +1,45 @@
<div id="messagePlaceHolder"></div>
<div id="globalDiv" onclick="setMessage();">
<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>Historique</h1>
<div style="overflow:auto;">
<table id="historique_sous" cellspacing="0">
<tr>
<th>Date</th>
<th>Intitul&eacute;</th>
<th>D&eacute;bit</th>
<th>Cr&eacute;dit</th>
</tr>
#for anItem in $historic_items
<tr>
<td>$anItem.date</td>
<td>$anItem.intitule</td>
#if $anItem.type=="debit"
<td>$anItem.montant</td>
#else
<td>&nbsp;<!-- evite que opera fasse des trucs bizarres... --></td>
#end if
#if $anItem.type=="credit"
<td>$anItem.montant</td>
#else
<td>&nbsp;<!-- evite que opera fasse des trucs bizarres... --></td>
#end if
</tr>
#end for
#if $historic_items == []
<tr><td colspan="4" style="color:gray;">
AUCUNE TRANSACTION ENREGISTR&Eacute;E
</td></tr>
#end if
</table>
</div>
<!-- ********************** Menu ********************** -->
</div>
</div>

View file

@ -0,0 +1,107 @@
<div id="messagePlaceHolder"></div>
#if $message != ''
<script type="text/javascript">setMessage('$message.replace("\'","\\\'")')</script>
#end if
#if $error != ''
<script type="text/javascript">setMessage('$error.replace("\'","\\\'")', 'errorMessage')</script>
#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">
<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"> -->
#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
$f.intitule
#if not $f.payee
(non pay&eacute;e)
#end if
</span>
<span class="montant">
$f.montant&nbsp;&euro;
</span>
<span class="note" style="float:left;clear: left;">Cr&eacute;e le -</span>
#if not $f.payee
<span class="actions">
<a href="delFacture?no=$f.no">Annuler</a>
<a href="$f.paypal">Payer avec PayPal</a>
</span>
#else
<span class="note" style="float:right;clear:right;">Pay&eacute;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&eacute;</th>
<th>total</th>
</tr>
#for unDetail in $f.details
<tr>
<td>$unDetail.intitule</td>
<td>$unDetail.prixUnitaire&nbsp;&euro;</td>
<td>$unDetail.quantite</td>
<td>$unDetail.prixTotal&nbsp;&euro;</td>
</tr>
#end for
<tr>
<td colspan="3" class="tdTotalDetailIntitule">
Total
</td>
<td class="tdTotalDetail">$f.montant&nbsp;&euro;</td>
</tr>
</table>
</div>
</div>
#end if
#end for
#if $listeFactures == []
<div class="factureRow tdNoFactures">
AUCUNE TRANSACTION PAYPAL ENREGISTR&Eacute;E
</div>
#end if
</div>
</div>