diff --git a/htdocs/compta/dons/edit.php b/htdocs/compta/dons/edit.php deleted file mode 100644 index 39207031fd1..00000000000 --- a/htdocs/compta/dons/edit.php +++ /dev/null @@ -1,167 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ - * - */ -require("./pre.inc.php"); -require("../../don.class.php"); -require("../../paiement.class.php"); - -if ($action == 'update') -{ - - if ($amount > 0) - { - - $don = new Don($db); - - $don->id = $_POST["rowid"]; - $don->prenom = $prenom; - $don->nom = $nom; - $don->statut = $_POST["statutid"]; - $don->societe = $societe; - $don->adresse = $adresse; - $don->amount = $amount; - $don->cp = $cp; - $don->ville = $ville; - $don->email = $email; - $don->date = mktime(12, 0 , 0, $remonth, $reday, $reyear); - $don->note = $note; - $don->pays = $pays; - $don->public = $public; - $don->projetid = $projetid; - $don->commentaire = $_POST["comment"]; - $don->modepaiementid = $modepaiement; - - if ($don->update($user->id) ) - { - Header("Location: fiche.php?rowid=$don->id&action=edit"); - } - } - else - { - print "Erreur"; - $action = "create"; - } -} - - -llxHeader(); - - -if ($rowid) -{ - - $don = new Don($db); - $don->id = $rowid; - $don->fetch($rowid); - - $sql = "SELECT s.nom,s.idp, f.amount, f.total, f.facnumber"; - $sql .= " FROM societe as s, ".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.idp"; - $sql .= " AND f.rowid = $facid"; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - if ($num) { - $obj = $db->fetch_object( 0); - - $total = $obj->total; - } - } - print_titre("Saisir un don"); - print "
"; - print ''; - - print ""; - print ""; - - print ""; - - print ''; - - print '"; - - print "\n"; - - print "\n"; - - print "\n"; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - print "
Date du don"; - print_date_select($don->date); - print "'.$langs->trans("Comments").' :
'; - print '
'.$langs->trans("Status").''; - - $listst[0] = "Promesse à valider"; - $listst[1] = "Promesse validée"; - $listst[2] = "Don payé"; - $listst[3] = "Don encaissé"; - - - $sel = new Form($db); - $sel->select_array("statutid",$listst,$don->statut); - - print "
Mode de paiement\n"; - - $paiement = new Paiement($db); - - $paiement->select("modepaiement","", $don->modepaiementid); - - print "
Projet\n"; - - $prj = new ProjetDon($db); - $listeprj = $prj->liste_array(); - - $sel = new Form($db); - $sel->select_array("projetid",$listeprj,$don->projetid); - - - print "
"; - print "
Don public
"; - print "
Prénom
Nom
Societe
Adresse'; - print '
CP Ville
Pays
Email
Montant euros
\n"; - -} - -$db->close(); - -llxFooter("Dernière modification $Date$ révision $Revision$"); -?> diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php index 22771c27413..7054c5e4e67 100644 --- a/htdocs/compta/dons/fiche.php +++ b/htdocs/compta/dons/fiche.php @@ -20,33 +20,81 @@ * $Source$ * */ + +/*! \file htdocs/compta/dons/fiche.php + \ingroup don + \brief Page de fiche de don + \version $Revision$ +*/ + require("./pre.inc.php"); require("../../don.class.php"); require("../../paiement.class.php"); -if ($action == 'add') -{ - if ($amount > 0) + +$mesg=""; + +if ($_POST["action"] == 'update') +{ + + if ($_POST["amount"] > 0) + { + + $don = new Don($db); + $don->id = $_POST["rowid"]; + $don->fetch($_POST["rowid"]); + + $don->prenom = $_POST["prenom"]; + $don->nom = $_POST["nom"]; + $don->societe = $_POST["societe"]; + $don->adresse = $_POST["adresse"]; + $don->amount = $_POST["amount"]; + $don->cp = $_POST["cp"]; + $don->ville = $_POST["ville"]; + $don->email = $_POST["email"]; + $don->date = mktime(12, 0 , 0, $remonth, $reday, $reyear); + $don->note = $_POST["note"]; + $don->pays = $_POST["pays"]; + $don->public = $_POST["public"]; + $don->projetid = $_POST["projetid"]; + $don->commentaire = $_POST["comment"]; + $don->modepaiementid = $_POST["modepaiement"]; + + if ($don->update($user->id) ) + { + Header("Location: index.php"); + } + } + else + { + $mesg="Montant non défini"; + } +} + +if ($_POST["action"] == 'add') +{ + + if ($_POST["amount"] > 0) { $don = new Don($db); - $don->prenom = $prenom; - $don->nom = $nom; - $don->societe = $societe; - $don->adresse = $adresse; - $don->amount = $amount; - $don->cp = $cp; - $don->ville = $ville; - $don->email = $email; + $don->prenom = $_POST["prenom"]; + $don->nom = $_POST["nom"]; + $don->societe = $_POST["societe"]; + $don->adresse = $_POST["adresse"]; + $don->amount = $_POST["amount"]; + $don->cp = $_POST["cp"]; + $don->ville = $_POST["ville"]; + $don->email = $_POST["email"]; $don->date = mktime(12, 0 , 0, $remonth, $reday, $reyear); - $don->note = $note; - $don->pays = $pays; - $don->public = $public; - $don->projetid = $projetid; + $don->note = $_POST["note"]; + $don->pays = $_POST["pays"]; + $don->public = $_POST["public"]; + $don->projetid = $_POST["projetid"]; $don->commentaire = $_POST["comment"]; - $don->modepaiementid = $modepaiement; + $don->modepaiementid = $_POST["modepaiement"]; if ($don->create($user->id) ) { @@ -55,45 +103,45 @@ if ($action == 'add') } else { - print "Erreur"; - $action = "create"; + $mesg="Montant non défini"; + $_GET["action"] = "create"; } } -if ($action == 'delete') +if ($_GET["action"] == 'delete') { $don = new Don($db); - $don->delete($rowid); - Header("Location: liste.php?statut=0"); + $don->delete($_GET["rowid"]); + Header("Location: liste.php"); } -if ($action == 'commentaire') +if ($_POST["action"] == 'commentaire') { $don = new Don($db); - $don->set_commentaire($rowid,$_POST["commentaire"]); - $action = "edit"; + $don->set_commentaire($_POST["rowid"],$_POST["commentaire"]); + $_GET["rowid"] = $_POST["rowid"]; } -if ($action == 'valid_promesse') +if ($_GET["action"] == 'valid_promesse') { $don = new Don($db); - if ($don->valid_promesse($rowid, $user->id)) + if ($don->valid_promesse($_GET["rowid"], $user->id)) { - Header("Location: liste.php?statut=0"); + Header("Location: liste.php"); } } -if ($action == 'set_paye') +if ($_GET["action"] == 'set_payed') { $don = new Don($db); - if ($don->set_paye($rowid, $modepaiement)) + if ($don->set_paye($_GET["rowid"], $modepaiement)) { - Header("Location: liste.php?statut=1"); + Header("Location: liste.php"); } } -if ($action == 'set_encaisse') +if ($_GET["action"] == 'set_encaisse') { $don = new Don($db); - if ($don->set_encaisse($rowid)) + if ($don->set_encaisse($_GET["rowid"])) { - Header("Location: liste.php?statut=2"); + Header("Location: liste.php"); } } @@ -101,39 +149,27 @@ if ($action == 'set_encaisse') llxHeader(); + /* ************************************************************************** */ /* */ /* Création d'une fiche don */ /* */ /* ************************************************************************** */ +if ($_GET["action"] == 'create') { -if ($action == 'create') { - - $sql = "SELECT s.nom,s.idp, f.amount, f.total, f.facnumber"; - $sql .= " FROM societe as s, ".MAIN_DB_PREFIX."facture as f WHERE f.fk_soc = s.idp"; - $sql .= " AND f.rowid = $facid"; - - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - if ($num) { - $obj = $db->fetch_object( 0); - - $total = $obj->total; - } - } print_titre("Saisir un don"); - print "
"; - print ''; + + print ''; + print '
'; - print ""; + print ''; print "".''; - print '"; print "\n"; - print "\n"; @@ -173,59 +207,125 @@ if ($action == 'create') { print "
"; print "\n"; - print "".''; - print "".''; - print "".''; - print "".'".''; + print "".''; + print "".''; + print "".''; - print "".''; - print "".''; - print "".''; - print "".''; - print "".''; - print "\n"; + print "".''; + print "".''; + print "".''; + print "".''; + print "".''; print "
Date du don'; print_date_select(); print ''.$langs->trans("Comments").' :
'; + print '
'.$langs->trans("Comments").' :
'; print "
Mode de paiement\n"; @@ -143,10 +179,8 @@ if ($action == 'create') { print "
Projet
".$langs->trans("Project")."
"; print "
Prénom
Nom
Societe
Adresse'; + $langs->load("companies"); + print "
'.$langs->trans("Company").'
'.$langs->trans("Firstname").'
'.$langs->trans("LastName").'
'.$langs->trans("Address").''; print '
CP Ville
Pays
Email
Montant euros
'.$langs->trans("Zip").' / '.$langs->trans("Town").'
'.$langs->trans("Country").'
'.$langs->trans("EMail").'
'.$langs->trans("Amount").' euros
\n"; - + print "\n"; } -/* ************************************************************************** */ -/* */ -/* Edition de la fiche don */ -/* */ -/* ************************************************************************** */ -if ($rowid > 0 && $action == 'edit') + + +/* ************************************************************ */ +/* */ +/* Fiche don en mode edition */ +/* */ +/* ************************************************************ */ + +if ($_GET["rowid"] && $_GET["action"] == 'edit') { $don = new Don($db); - $don->id = $rowid; - $don->fetch($rowid); + $don->id = $_GET["rowid"]; + $don->fetch($_GET["rowid"]); + + print_titre("Traitement du don"); + + print '
'; + print ''; + + print ''; + print ''; + + print "".''; + + print '"; + + print "\n"; + + print "\n"; + + $langs->load("companies"); + print "".''; + print "".''; + print "".''; + print "".''; + print "".''; + print "".''; + print "".''; + print "".''; + + print "\n"; + + print "".''; + + print "
Date du don'; + print_date_select($don->date); + print ''.$langs->trans("Comments").' :
'; + print "
".$langs->trans("Project")."
"; + print "
Don public
"; + print "
'.$langs->trans("Company").'
'.$langs->trans("Firstname").'
'.$langs->trans("LastName").'
'.$langs->trans("Address").''; + print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").'
'.$langs->trans("Country").'
'.$langs->trans("EMail").'
'.$langs->trans("Amount").' euros
Mode de paiement\n"; + $paiement = new Paiement($db); + $paiement->select("modepaiement","crédit"); + print "
\n"; + print "
\n"; + +} + + + +/* ************************************************************ */ +/* */ +/* Fiche don en mode visu */ +/* */ +/* ************************************************************ */ +if ($_GET["rowid"] && $_GET["action"] != 'edit') +{ + + $don = new Don($db); + $don->id = $_GET["rowid"]; + $don->fetch($_GET["rowid"]); print_titre("Traitement du don"); print "
"; - print ''; + print '
'; print ""; - print ''; - if ($don->statut == 1) - { - print "\n"; - } - - if ($don->statut > 1) - { - print "\n"; - } - print "".''; print "\n"; - print "".''; - print "".''; - print "".''; - print "".''; - print "".''; - print "".''; - print "".''; - print "".''; + print "".''; + print "".''; + print "".''; + print "".''; + print "".''; + print "".''; + print "".''; + print "".''; + if ($don->statut == 1) + { + print "\n"; + } + else + { + print "\n"; + } print "
Date du don"; print strftime("%d %B %Y",$don->date); print "'.$langs->trans("Comments").' :
'; + print '
'.$langs->trans("Comments").' :
'; print nl2br($don->commentaire).'
Mode de paiement"; - $paiement = new Paiement($db); - $paiement->select("modepaiement","crédit", $don->modepaiementid); - print "
Mode de paiement"; - print $don->modepaiement; - print "
Projet'.$don->projet.'
Don public"; @@ -234,98 +334,75 @@ if ($rowid > 0 && $action == 'edit') print "
Prénom'.$don->prenom.' 
Nom'.$don->nom.' 
Société'.$don->societe.' 
Adresse'.nl2br($don->adresse).' 
CP Ville'.$don->cp.' '.$don->ville.' 
Pays'.$don->pays.' 
Email'.$don->email.' 
Montant'.price($don->amount).' euros
'.$langs->trans("Company").''.$don->societe.'
'.$langs->trans("Firstname").''.$don->prenom.'
'.$langs->trans("LastName").''.$don->nom.'
'.$langs->trans("Address").''.nl2br($don->adresse).'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$don->cp.' '.$don->ville.'
'.$langs->trans("Country").''.$don->pays.'
'.$langs->trans("EMail").''.$don->email.'
'.$langs->trans("Amount").''.price($don->amount).' euros
Mode de paiement"; + $paiement = new Paiement($db); + $paiement->select("modepaiement","crédit", $don->modepaiementid); + print "
Mode de paiement"; + print $don->modepaiement; + print "
\n"; - + print "
\n"; - print "

"; - - /* - * Case 1 - */ - print ''; + /* + * Barre d'actions + * + */ + print '
'; + + print ''.$langs->trans('Edit').''; - /* - * Case 2 - */ - - if ($don->statut == 1 && $resteapayer > 0) + if ($don->statut == 1 && $resteapayer > 0) { - print "
"; - } - elseif ($don->statut == 0) - { - print ""; - } - elseif ($don->statut == 3) - { - print ""; - } - else - { - print ""; - } - /* - * Case 3 - */ - if ($don->statut == 1 && abs($resteapayer == 0) && $don->paye == 0) - { - print ""; - } - else - { - print ""; - } - /* - * Case 4 - */ - if ($don->statut == 0) - { - print ""; - } - elseif ($don->statut == 2) - { - print ""; - } - else - { - print ""; + print "Emettre un paiement"; } - print "
['.$langs->trans('Edit').'][Emettre un paiement][id&action=valid_promesse\">Valider la promesse][id\">Formulaire]-"; - - print ''; - print ''; - - print ''; - - print "-[id&action=delete\">Supprimer][id&action=set_encaisse\">Encaisser]-

"; -/* ************************************************************************** */ -/* */ -/* Commentaire */ -/* */ -/* ************************************************************************** */ + if ($don->statut == 0) + { + print "id&action=valid_promesse\">Valider la promesse"; + } + + if ($don->statut == 3) + { + print "id\">Formulaire"; + } + + if ($don->statut == 1 && abs($resteapayer == 0) && $don->paye == 0) + { + print "id&action=set_payed\">Classé payé"; + } + + if ($don->statut == 0) + { + print "id&action=delete\">".$langs->trans("Delete").""; + } + if ($don->statut == 2) + { + print "id&action=set_encaisse\">Encaisser"; + } + + print "
"; - print "

"; - print ''; - print ''; - print ''; - print "".''; - print "".''; - print "".''; - print '
'.$langs->trans("Comments").'
'; - } + + $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); diff --git a/htdocs/compta/dons/formulaire/fsfe.fr.php b/htdocs/compta/dons/formulaire/fsfe.fr.php index 42e49161456..5b5a06aa3d6 100644 --- a/htdocs/compta/dons/formulaire/fsfe.fr.php +++ b/htdocs/compta/dons/formulaire/fsfe.fr.php @@ -19,6 +19,14 @@ * $Source$ * */ + +/*! + \file htdocs/compta/dons/formulaire/fsfe.fr.php + \ingroup don + \brief Formulaire de don + \version $Revision$ +*/ + require("../../../main.inc.php"); echo ' @@ -40,8 +48,8 @@ require("../../../don.class.php"); setlocale(LC_TIME,"fr_FR"); $don = new Don($db); -$don->id = $rowid; -$don->fetch($rowid); +$don->id = $_GET["rowid"]; +$don->fetch($_GET["rowid"]); ?> diff --git a/htdocs/compta/dons/index.php b/htdocs/compta/dons/index.php index c65b4b6e2bb..15fdde1f470 100644 --- a/htdocs/compta/dons/index.php +++ b/htdocs/compta/dons/index.php @@ -20,8 +20,16 @@ * $Source$ * */ + +/*! \file htdocs/compta/dons/index.php + \ingroup don + \brief Page accueil espace don + \version $Revision$ +*/ + require("./pre.inc.php"); + llxHeader(); $sql = "SELECT sum(d.amount) as somme , d.fk_statut FROM ".MAIN_DB_PREFIX."don as d GROUP BY d.fk_statut"; @@ -44,7 +52,7 @@ if ($result) print_titre("Dons"); -print ''; +print '
'; print ''; print ""; print ""; diff --git a/htdocs/compta/dons/liste.php b/htdocs/compta/dons/liste.php index 778a3e636fa..583048ea6d6 100644 --- a/htdocs/compta/dons/liste.php +++ b/htdocs/compta/dons/liste.php @@ -1,5 +1,6 @@ + * Copyright (C) 2004 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +20,24 @@ * $Source$ * */ + +/*! + \file htdocs/compta/dons/liste.php + \ingroup don + \brief Page de liste des dons + \version $Revision$ +*/ + require("./pre.inc.php"); + llxHeader(); +$sortorder=$_GET["sortorder"]; +$sortfield=$_GET["sortfield"]; +$statut=$_GET["statut"]; +$page=$_GET["page"]; + if ($sortorder == "") { $sortorder="DESC"; } if ($sortfield == "") { $sortfield="d.datedon"; } @@ -32,13 +47,13 @@ $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; - +// Genere requete de liste des dons $sql = "SELECT d.rowid, ".$db->pdate("d.datedon")." as datedon, d.prenom, d.nom, d.societe, d.amount, p.libelle as projet"; -$sql .= " FROM ".MAIN_DB_PREFIX."don as d, ".MAIN_DB_PREFIX."don_projet as p"; -$sql .= " WHERE p.rowid = d.fk_don_projet"; -if (strlen($statut)) +$sql .= " FROM ".MAIN_DB_PREFIX."don as d left join ".MAIN_DB_PREFIX."don_projet as p"; +$sql .= " ON p.rowid = d.fk_don_projet WHERE 1 = 1"; +if (isset($_GET["statut"])) { - $sql .= " AND d.fk_statut = $statut"; + $sql .= " AND d.fk_statut = ".$_GET["statut"]; } $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset); @@ -56,9 +71,9 @@ if ($result) { print_barre_liste("Dons", $page, "liste.php", "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield"); } - print "
 Somme
"; + print "
"; - print ''; + print ''; print "'; - print "\n"; + print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print ''; + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print ''; print ""; $i++; @@ -93,8 +108,7 @@ if ($result) } else { - print $sql; - print $db->error(); + dolibarr_print_error($db); } diff --git a/htdocs/compta/dons/stats.php b/htdocs/compta/dons/stats.php index 7a69995a380..bdad6108a4d 100644 --- a/htdocs/compta/dons/stats.php +++ b/htdocs/compta/dons/stats.php @@ -20,6 +20,14 @@ * $Source$ * */ + +/*! + \file htdocs/compta/dons/stats.php + \ingroup don + \brief Page des statistiques de dons + \version $Revision$ +*/ + require("./pre.inc.php"); llxHeader(); @@ -28,14 +36,16 @@ llxHeader(); print_titre($langs->trans("Statistics")); $sql = "SELECT d.amount"; -$sql .= " FROM ".MAIN_DB_PREFIX."don as d, ".MAIN_DB_PREFIX."don_projet as p"; -$sql .= " WHERE p.rowid = d.fk_don_projet"; +$sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."don_projet as p"; +$sql .= " ON p.rowid = d.fk_don_projet"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); + $i=0; + $total=0; while ($i < $num) { $objp = $db->fetch_object( $i); @@ -43,20 +53,19 @@ if ($result) $i++; } - print "
"; print_liste_field_titre("Prénom","liste.php","d.prenom","&page=$page&statut=$statut"); print ""; @@ -71,20 +86,20 @@ if ($result) print ""; print_liste_field_titre("Montant","liste.php","d.amount","&page=$page&statut=$statut"); print ' 
rowid&action=edit\">".stripslashes($objp->prenom)."rowid&action=edit\">".stripslashes($objp->nom)."rowid&action=edit\">".stripslashes($objp->societe)."rowid&action=edit\">".strftime("%d %B %Y",$objp->datedon)."$objp->projet'.price($objp->amount).' 
rowid\">".stripslashes($objp->prenom)."rowid\">".stripslashes($objp->nom)."rowid\">".stripslashes($objp->societe)."rowid\">".strftime("%d %B %Y",$objp->datedon)."$objp->projet'.price($objp->amount).' 
"; + print '
'; print ""; - print ''; + print ''; print "".''; - print "".''; + print "".''; print ""; print "
Nombre de dons'.$i.'
Nombre de dons'.$num.'
'.$langs->trans("Total").''.price($total).'
Moyenne'.price($total / $i).'
'.$langs->trans("Average").''.price($total / ($num?$num:1)).'
"; } else { - print $sql; - print $db->error(); + pdolibarr_print_error($db); }