* Copyright (C) 2003 Jean-Louis Bergamo * * 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(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php"); llxHeader(); if ($action == 'add') { $datepaye = $db->idate(mktime(12, 0 , 0, $pmonth, $pday, $pyear)); $paiement = new Paiement($db); $paiement->facid = $facid; $paiement->datepaye = $datepaye; $paiement->amount = $amount; $paiement->author = $author; $paiement->paiementid = $paiementid; $paiement->num_paiement = $num_paiement; $paiement->note = $note; $paiement->create(); $action = ''; } // Insertion de la cotisation dans le compte banquaire if ($HTTP_POST_VARS["action"] == '2bank' && $HTTP_POST_VARS["rowid"] !=''){ if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0){ $dateop=strftime("%Y%m%d",time()); $sql="SELECT cotisation FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid=".$HTTP_POST_VARS["rowid"]." "; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); if ($num>0) { $objp = $db->fetch_object(0); $amount=$objp->cotisation; $acct=new Account($db,ADHERENT_BANK_ACCOUNT); $insertid=$acct->addline($dateop, $HTTP_POST_VARS["operation"], $HTTP_POST_VARS["label"], $amount, $HTTP_POST_VARS["num_chq"],ADHERENT_BANK_CATEGORIE); if ($insertid == '') { print "

Probleme d'insertion : ".$db->error(); } else { // met a jour la table cotisation $sql="UPDATE ".MAIN_DB_PREFIX."cotisation SET fk_bank=$insertid WHERE rowid=".$HTTP_POST_VARS["rowid"]." "; $result = $db->query($sql); if ($result) { //Header("Location: $PHP_SELF"); } else { print "

Probleme d'insertion $sql : ".$db->error(); } } } else { print "

Probleme SQL : $sql : ".$db->error(); } } else { print "

Probleme SQL : $sql : ".$db->error(); } } } if ($sortorder == "") { $sortorder="DESC"; } if ($sortfield == "") { $sortfield="c.dateadh"; } if ($page == -1) { $page = 0 ; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; $sql = "SELECT c.cotisation, ".$db->pdate("c.dateadh")." as dateadh"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c"; $sql .= " WHERE d.rowid = c.fk_adherent"; if(isset($date_select) && $date_select != ''){ $sql .= " AND dateadh LIKE '$date_select%'"; } $result = $db->query($sql); $Total=array(); $Number=array(); if ($result) { $num = $db->num_rows(); $i = 0; while ($i < $num) { $objp = $db->fetch_object( $i); $Total[strftime("%Y",$objp->dateadh)]+=price($objp->cotisation); $Number[strftime("%Y",$objp->dateadh)]+=1; $i++; } } $sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, c.cotisation, ".$db->pdate("c.dateadh")." as dateadh, c.fk_bank as bank, c.rowid as crowid"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c"; $sql .= " WHERE d.rowid = c.fk_adherent"; if(isset($date_select) && $date_select != ''){ $sql .= " AND dateadh LIKE '$date_select%'"; } $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; print_barre_liste("Liste des cotisations", $page, $PHP_SELF, "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield"); print "\n"; print ''; print ""; print ''; print ""; print "\n"; print "\n"; foreach ($Total as $key=>$value){ $var=!$var; print "\n"; } print "
AnneeMontantNombreMoyenne
$key".price($value)."".$Number[$key]."".price($value/$Number[$key])."

\n"; print ""; print ''; //print ""; print '\n"; //print ""; print '\n"; //print ""; print '\n"; if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0){ print '\n"; } print "\n"; $var=True; $total=0; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; print ''; //$Total[strftime("%Y",$objp->dateadh)]+=price($objp->cotisation); $total+=price($objp->cotisation); /* if ($objp->societe != ''){ print "\n"; }else{ print "\n"; } */ print "\n"; if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0){ if ($objp->bank !='' ){ print ""; }else{ print ""; // print ""; print ''; print "\n"; print "\n"; } } print ""; $i++; } $var=!$var; print ""; print "\n"; print "\n"; // print "\n"; print "\n"; print "\n"; print "
Date'; print_liste_field_titre("Date
",$PHP_SELF,"c.dateadh","&page=$page&statut=$statut"); print "
Montant'; print_liste_field_titre("Montant
",$PHP_SELF,"c.cotisation","&page=$page&statut=$statut"); print "
Prenom Nom / Société'; // print_liste_field_titre("Prenom",$PHP_SELF,"d.prenom","&page=$page&statut=$statut"); print_liste_field_titre("Prenom Nom
",$PHP_SELF,"d.nom","&page=$page&statut=$statut"); // print " / Société"; print "
'; // print_liste_field_titre("Bank",$PHP_SELF,"c.fk_bank","&page=$page&statut=$statut"); print 'Bank
(Type,Numéro,Libelle)'; print "
rowid&action=edit\">".strftime("%d %B %Y",$objp->dateadh)."'.price($objp->cotisation).'rowid&action=edit\">".stripslashes($objp->prenom)." ".stripslashes($objp->nom)." /
".stripslashes($objp->societe)."
rowid&action=edit\">".stripslashes($objp->prenom)." ".stripslashes($objp->nom)."rowid&action=edit\">".stripslashes($objp->prenom)." ".stripslashes($objp->nom)."Deposé"; print "
"; print ''; print ''; print ''; print ' - '; print "prenom)." ".stripslashes($objp->nom)." ".strftime("%Y",$objp->dateadh)."\" >\n"; // print "
Total".price($total)." "; print_fleche_navigation($page,$PHP_SELF,"&statut=$statut&sortorder=$sortorder&sortfield=$sortfield",1); print "
"; print "
\n"; } else { print $sql; print $db->error(); } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>