* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2005 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 * 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$ */ /** \file htdocs/adherents/index.php \ingroup adherent \brief Page accueil module adherents */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); $langs->load("companies"); $langs->load("members"); llxHeader(); $staticmember=new Adherent($db); print_fiche_titre($langs->trans("MembersArea")); print ''; print ''; print ''; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $var=True; $Adherents=array(); $AdherentsAValider=array(); $AdherentsResilies=array(); $AdherentType=array(); $Cotisants=array(); # Liste les adherents $sql = "SELECT count(*) as somme , t.rowid, t.libelle, t.cotisation, d.statut"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE d.fk_adherent_type = t.rowid"; $sql .= " GROUP BY t.rowid, t.libelle, t.cotisation, d.statut"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); $adhtype=new AdherentType($db); $adhtype->id=$objp->rowid; $adhtype->cotisation=$objp->cotisation; $adhtype->libelle=$objp->libelle; $AdherentType[$objp->rowid]=$adhtype; if ($objp->statut == -1) { $AdherentsAValider[$objp->rowid]=$objp->somme; } if ($objp->statut == 1) { $Adherents[$objp->rowid]=$objp->somme; } if ($objp->statut == 0) { $AdherentsResilies[$objp->rowid]=$objp->somme; } if ($objp->cotisation != 'yes') { $Cotisants[$objp->rowid]=$Adherents[$objp->rowid]=$objp->somme; } else { $Cotisants[$objp->rowid]=0; // Calculé plus loin } $i++; } $db->free($result); } # Liste les cotisants a jour $sql = "SELECT count(*) as somme , d.fk_adherent_type"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.= " WHERE d.statut = 1 AND d.datefin >= now()"; $sql.= " GROUP BY d.fk_adherent_type"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); $Cotisants[$objp->fk_adherent_type]=$objp->somme; $i++; } $db->free(); } $SommeA=0; $SommeB=0; $SommeC=0; $SommeD=0; foreach ($AdherentType as $key => $adhtype) { $var=!$var; print ""; print ''; print ''; print ''; print ''; print ''; print "\n"; $SommeA+=isset($AdherentsAValider[$key])?$AdherentsAValider[$key]:0; $SommeB+=isset($Adherents[$key])?$Adherents[$key]-$Cotisants[$key]:0; $SommeC+=isset($Cotisants[$key])?$Cotisants[$key]:0; $SommeD+=isset($AdherentsResilies[$key])?$AdherentsResilies[$key]:0; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "
'.$langs->trans("Type").''.$langs->trans("MembersStatusToValid").''.$langs->trans("MembersStatusNotPayed").''.$langs->trans("MembersStatusPayed").''.$langs->trans("MembersStatusResiliated").'
'.img_object($langs->trans("ShowType"),"group").' '.$adhtype->libelle.''.(isset($AdherentsAValider[$key])?$AdherentsAValider[$key]:'').' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).''.(isset($Adherents[$key])?$Adherents[$key]-$Cotisants[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).''.(isset($Cotisants[$key])?$Cotisants[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,mktime(),3).''.(isset($AdherentsResilies[$key])?$AdherentsResilies[$key]:'').' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'
'.$langs->trans("Total").' '.$SommeA.' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).''.$SommeB.' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).''.$SommeC.' '.$staticmember->LibStatut(1,$adhtype->cotisation,mktime(),3).''.$SommeD.' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'
\n"; print '
'; print '
'; // Formulaire recherche adhérent print '
'; print ''; print ''; print ''; print ''; print "\n"; $var=false; print ""; print ''; print ""; print ''; print "
'.$langs->trans("SearchAMember").'
'; print $langs->trans("Name").':'; print '
'; print $langs->trans("Other").':'; print '
"; print '
'; $Total=array(); $Number=array(); $tot=0; $numb=0; $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); if ($result) { $num = $db->num_rows($result); $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); $year=strftime("%Y",$objp->dateadh); $Total[$year]+=$objp->cotisation; $Number[$year]+=1; $tot+=$objp->cotisation; $numb+=1; $i++; } } print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $var=true; krsort($Total); foreach ($Total as $key=>$value) { $var=!$var; print "\n"; } // Total print '\n"; print "
'.$langs->trans("Year").''.$langs->trans("Subscriptions").''.$langs->trans("Number").''.$langs->trans("Average").'
$key".price($value)."".$Number[$key]."".price($value/$Number[$key])."
'.$langs->trans("Total").''.price($tot)."".$numb."".price($numb>0?($tot/$numb):0)."

\n"; print '
'; $db->close(); llxFooter('$Date$ - $Revision$'); ?>