diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php
index e481e1c2f31..fc50cce23bc 100644
--- a/htdocs/adherents/adherent.class.php
+++ b/htdocs/adherents/adherent.class.php
@@ -52,6 +52,8 @@ class Adherent
var $adresse;
var $cp;
var $ville;
+ var $pays_id;
+ var $pays_code;
var $pays;
var $typeid;
var $morphy;
@@ -98,6 +100,7 @@ class Adherent
\remarks %INFOS% : l'ensemble des attributs de cet adherent
\remarks %SERVEUR% : URL du serveur web
\remarks etc..
+ \todo Utiliser classe CMailFile
*/
function send_an_email($recipients,$text,$subject="Vos coordonnees sur %SERVEUR%")
@@ -169,21 +172,22 @@ class Adherent
/**
- \brief fonction qui renvoie la nature physique ou morale d'un adherent
- \param morphy nature physique ou morale de l'adhérent
+ \brief Renvoie le libelle traduit de la nature d'un adherent (physique ou morale)
+ \param morphy Nature physique ou morale de l'adhérent
*/
function getmorphylib($morphy='')
{
+ global $langs;
if (! $morphy) { $morphy=$this->morphy; }
- if ($morphy == 'phy') { return "Physique"; }
- if ($morphy == 'mor') { return "Morale"; }
+ if ($morphy == 'phy') { return $langs->trans("Physical"); }
+ if ($morphy == 'mor') { return $langs->trans("Moral"); }
return $morphy;
}
/**
- \brief fonction qui vérifie les données entrées
- \param minimum
+ \brief Vérifie les données entrées
+ \param minimum
*/
function check($minimum=0)
@@ -318,8 +322,8 @@ class Adherent
function update()
{
- $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET ";
- $sql .= "prenom = '".$this->prenom ."'";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
+ $sql .= " prenom = '".$this->prenom ."'";
$sql .= ",nom='" .$this->nom."'";
$sql .= ",societe='".$this->societe."'";
$sql .= ",adresse='".$this->adresse."'";
@@ -330,7 +334,8 @@ class Adherent
$sql .= ",email='" .$this->email."'";
$sql .= ",login='" .$this->login."'";
$sql .= ",pass='" .$this->pass."'";
- $sql .= ",naiss='" .$this->naiss."'";
+ if ($this->naiss) $sql .= ",naiss='" .$this->naiss."'";
+ else $sql .= ",naiss=null";
$sql .= ",photo='" .$this->photo."'";
$sql .= ",public='" .$this->public."'";
$sql .= ",statut=" .$this->statut;
@@ -454,55 +459,61 @@ class Adherent
}
-/**
- \brief fonction qui récupére l'adhérent en donnant son rowid
- \param rowid
-*/
- function fetch($rowid)
- {
- $sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, d.statut, d.public, d.adresse, d.cp, d.ville, d.pays, d.note, d.email, d.login, d.pass, d.naiss, d.photo, d.fk_adherent_type, d.morphy, t.libelle as type";
- $sql .= ",".$this->db->pdate("d.datefin")." as datefin";
- $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
- $sql .= " WHERE d.rowid = $rowid AND d.fk_adherent_type = t.rowid";
-
- $result=$this->db->query( $sql);
-
- if ($result)
- {
- if ($this->db->num_rows())
- {
-
- $obj = $this->db->fetch_object($result);
-
- $this->id = $obj->rowid;
- $this->typeid = $obj->fk_adherent_type;
- $this->type = $obj->type;
- $this->statut = $obj->statut;
- $this->public = $obj->public;
- $this->date = $obj->datedon;
- $this->prenom = stripslashes($obj->prenom);
- $this->nom = stripslashes($obj->nom);
- $this->societe = stripslashes($obj->societe);
- $this->adresse = stripslashes($obj->adresse);
- $this->cp = stripslashes($obj->cp);
- $this->ville = stripslashes($obj->ville);
- $this->email = stripslashes($obj->email);
- $this->login = stripslashes($obj->login);
- $this->pass = stripslashes($obj->pass);
- $this->naiss = stripslashes($obj->naiss);
- $this->photo = stripslashes($obj->photo);
- $this->pays = stripslashes($obj->pays);
- $this->datefin = $obj->datefin;
- $this->commentaire = stripslashes($obj->note);
- $this->morphy = $obj->morphy;
- }
- }
- else
- {
- dolibarr_print_error($this->db);
- }
+ /**
+ \brief fonction qui récupére l'adhérent en donnant son rowid
+ \param rowid
+ */
+ function fetch($rowid)
+ {
+ global $langs;
+
+ $sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, d.statut, d.public, d.adresse, d.cp, d.ville, d.note, d.email, d.login, d.pass, d.naiss, d.photo, d.fk_adherent_type, d.morphy, t.libelle as type";
+ $sql .= ",".$this->db->pdate("d.datefin")." as datefin";
+ $sql .= ", d.pays, p.rowid as pays_id, p.code as pays_code, p.libelle as pays_lib";
+ $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid";
+ $sql .= " WHERE d.rowid = $rowid AND d.fk_adherent_type = t.rowid";
- }
+ $result=$this->db->query( $sql);
+ if ($result)
+ {
+ if ($this->db->num_rows($result))
+ {
+ $obj = $this->db->fetch_object($result);
+
+ $this->id = $obj->rowid;
+ $this->typeid = $obj->fk_adherent_type;
+ $this->type = $obj->type;
+ $this->statut = $obj->statut;
+ $this->public = $obj->public;
+ $this->date = $obj->datedon;
+ $this->prenom = stripslashes($obj->prenom);
+ $this->nom = stripslashes($obj->nom);
+ $this->societe = stripslashes($obj->societe);
+ $this->adresse = stripslashes($obj->adresse);
+ $this->cp = stripslashes($obj->cp);
+ $this->ville = stripslashes($obj->ville);
+ $this->pays_id = $obj->pays_id;
+ $this->pays_code = $obj->pays_code;
+ if ($langs->trans("Country".$obj->pays_code) != "Country".$obj->pays_code) $this->pays = $langs->trans("Country".$obj->pays_code);
+ elseif ($obj->pays_lib) $this->pays=$obj->pays_lib;
+ else $this->pays=$obj->pays;
+ $this->email = stripslashes($obj->email);
+ $this->login = stripslashes($obj->login);
+ $this->pass = stripslashes($obj->pass);
+ $this->naiss = stripslashes($obj->naiss);
+ $this->photo = stripslashes($obj->photo);
+ $this->datefin = $obj->datefin;
+ $this->commentaire = stripslashes($obj->note);
+ $this->morphy = $obj->morphy;
+ }
+ }
+ else
+ {
+ dolibarr_print_error($this->db);
+ }
+
+ }
/**
@@ -580,49 +591,57 @@ class Adherent
}
-/**
- \brief fonction qui insère la cotisation dans la base de données
- \param date
- \param montant
-*/
-
- function cotisation($date, $montant)
-
- {
-
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, dateadh, cotisation)";
- $sql .= " VALUES ($this->id, ".$this->db->idate($date).", $montant)";
-
- $result=$this->db->query( $sql);
-
- if ($result)
+ /**
+ \brief Fonction qui insère la cotisation dans la base de données
+ \param date Date cotisation
+ \param montant Montant cotisation
+ \return int rowid de l'entrée ajoutée, <0 si erreur
+ */
+ function cotisation($date, $montant)
{
- if ( $this->db->affected_rows() )
+ $this->db->begin();
+
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, datec, dateadh, cotisation)";
+ $sql .= " VALUES ($this->id, now(), ".$this->db->idate($date).", $montant)";
+
+ $result=$this->db->query($sql);
+ if ($result)
{
- $rowid=$this->db->last_insert_id(MAIN_DB_PREFIX."cotisation");
- $datefin = mktime(12, 0 , 0,
- strftime("%m",$date),
- strftime("%d",$date),
- strftime("%Y",$date)+1) - (24 * 3600);
-
- $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET datefin = ".$this->db->idate($datefin)." WHERE rowid =". $this->id;
-
- if ( $this->db->query( $sql) )
+ if ( $this->db->affected_rows($result) )
{
- return $rowid;
+ $rowid=$this->db->last_insert_id(MAIN_DB_PREFIX."cotisation");
+ $datefin = mktime(12, 0 , 0,
+ strftime("%m",$date),
+ strftime("%d",$date),
+ strftime("%Y",$date)+1) - (24 * 3600);
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET datefin = ".$this->db->idate($datefin)." WHERE rowid =". $this->id;
+ if ( $this->db->query( $sql) )
+ {
+ $this->db->commit();
+ return $rowid;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -3;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -2;
}
}
else
{
- return 0;
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -1;
}
}
- else
- {
- dolibarr_print_error($this->db);
- return 0;
- }
- }
/**
\brief fonction qui vérifie que l'utilisateur est valide
diff --git a/htdocs/adherents/cotisations.php b/htdocs/adherents/cotisations.php
index bda6e28401f..3a19bb21dd6 100644
--- a/htdocs/adherents/cotisations.php
+++ b/htdocs/adherents/cotisations.php
@@ -30,118 +30,95 @@
*/
require("./pre.inc.php");
-
require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
+$sortorder=$_GET["sortorder"];
+$sortfield=$_GET["sortfield"];
+$page=$_GET["page"];
+$filter=$_GET["filter"];
+$statut=isset($_GET["statut"])?$_GET["statut"]:1;
+
+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;
+
+$date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"];
+
+
+
+// Insertion de la cotisation dans le compte banquaire
+if ($_POST["action"] == '2bank' && $_POST["rowid"] !='')
+{
+ if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0)
+ {
+
+ // \todo Créer une facture et enregistrer son paiement
+
+
+ $dateop=strftime("%Y%m%d",time());
+ $sql="SELECT cotisation FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid=".$_POST["rowid"]." ";
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $num = $db->num_rows($result);
+ if ($num>0)
+ {
+ $objp = $db->fetch_object($result);
+ $amount=$objp->cotisation;
+ $acct=new Account($db,ADHERENT_BANK_ACCOUNT);
+ $insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"],ADHERENT_BANK_CATEGORIE,$user);
+ if ($insertid == '')
+ {
+ dolibarr_print_error($db);
+ }
+ else
+ {
+ // met a jour la table cotisation
+ $sql="UPDATE ".MAIN_DB_PREFIX."cotisation SET fk_bank=$insertid WHERE rowid=".$_POST["rowid"]." ";
+ $result = $db->query($sql);
+ if ($result)
+ {
+ //Header("Location: cotisations.php");
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+ }
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+
+ }
+}
+
+
+
llxHeader();
-// \todo Cette partie de code semble non utilisée
-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 = '';
-
-}
+$params="&select_date=".$select_date;
+print_barre_liste($langs->trans("ListOfSubscriptions"), $page, "cotisations.php", $params, $sortfield, $sortorder,'',$num);
-// Insertion de la cotisation dans le compte banquaire
-if ($_POST["action"] == '2bank' && $_POST["rowid"] !=''){
- if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0){
-
- // \todo Créer une facture et enregistrer son paiement
-
-
- $dateop=strftime("%Y%m%d",time());
- $sql="SELECT cotisation FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid=".$_POST["rowid"]." ";
- $result = $db->query($sql);
- if ($result)
- {
- $num = $db->num_rows();
- if ($num>0)
- {
- $objp = $db->fetch_object($result);
- $amount=$objp->cotisation;
- $acct=new Account($db,ADHERENT_BANK_ACCOUNT);
- $insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"],ADHERENT_BANK_CATEGORIE,$user);
- if ($insertid == '')
- {
- dolibarr_print_error($db);
- }
- else
- {
- // met a jour la table cotisation
- $sql="UPDATE ".MAIN_DB_PREFIX."cotisation SET fk_bank=$insertid WHERE rowid=".$_POST["rowid"]." ";
- $result = $db->query($sql);
- if ($result)
- {
- //Header("Location: cotisations.php");
- }
- else
- {
- dolibarr_print_error($db);
- }
- }
- }
- else
- {
- dolibarr_print_error($db);
- }
- }
- else
- {
- dolibarr_print_error($db);
- }
-
- }
-}
-
-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($result);
- $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";
+// Liste des cotisations
+$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, b.fk_account,";
+$sql.= " c.cotisation, ".$db->pdate("c.dateadh")." as dateadh, c.fk_bank as bank, c.rowid as crowid,";
+$sql.= " b.fk_account";
+$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
+$sql.= " WHERE d.rowid = c.fk_adherent";
if(isset($date_select) && $date_select != ''){
$sql .= " AND dateadh LIKE '$date_select%'";
}
@@ -152,86 +129,66 @@ if ($result)
{
$num = $db->num_rows($result);
$i = 0;
-
- print_barre_liste($langs->trans("ListOfSubscriptions"), $page, "cotisations.php", "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield");
- print "
\n";
- print '';
- print ''.$langs->trans("Year").' ';
- print ''.$langs->trans("Amount").' ';
- print ''.$langs->trans("Number").' ';
- print ''.$langs->trans("Average").' ';
- print " \n";
-
- foreach ($Total as $key=>$value){
- $var=!$var;
- print "$key ".price($value)." ".$Number[$key]." ".price($value/$Number[$key])." \n";
- }
- print "
\n";
-
-
- // Liste des cotisations
print '';
print '';
- print_liste_field_titre($langs->trans("Name"),"cotisations.php","d.nom","&page=$page&statut=$statut");
- print_liste_field_titre($langs->trans("Date"),"cotisations.php","c.dateadh","&page=$page&statut=$statut");
- print_liste_field_titre($langs->trans("Amount"),"cotisations.php","c.cotisation","&page=$page&statut=$statut","","align=\"right\"");
-
- if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0){
- print '';
- // print_liste_field_titre("Bank","cotisations.php","c.fk_bank","&page=$page&statut=$statut");
- print 'Bank (Type,Numéro,Libelle)';
- print " \n";
+ print_liste_field_titre($langs->trans("Date"),"cotisations.php","c.dateadh","&page=$page&statut=$statut","","",$sortfield);
+ print_liste_field_titre($langs->trans("Name"),"cotisations.php","d.nom","&page=$page&statut=$statut","","",$sortfield);
+ print_liste_field_titre($langs->trans("Amount"),"cotisations.php","c.cotisation","&page=$page&statut=$statut","","align=\"right\"",$sortfield);
+ if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0)
+ {
+ print_liste_field_titre($langs->trans("Bank"),"cotisations.php","b.fk_account","&page=$page&statut=$statut","","",$sortfield);
}
print " \n";
$var=true;
$total=0;
while ($i < $num)
+ {
+ $objp = $db->fetch_object($result);
+ $total+=price($objp->cotisation);
+
+ $var=!$var;
+ print "";
+ print "".dolibarr_print_date($objp->dateadh)." \n";
+ print "rowid&action=edit\">".img_object($langs->trans("ShowMember"),"user").' '.stripslashes($objp->prenom)." ".stripslashes($objp->nom)." \n";
+ print ''.price($objp->cotisation).' ';
+ if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0)
{
- $objp = $db->fetch_object($result);
- $total+=price($objp->cotisation);
-
- $var=!$var;
- print " ";
- print "rowid&action=edit\">".stripslashes($objp->prenom)." ".stripslashes($objp->nom)." \n";
- print "".strftime("%d %B %Y",$objp->dateadh)." \n";
- print ''.price($objp->cotisation).' ';
- if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0){
- if ($objp->bank !='' ){
- print "Deposé ";
- }else{
- print "";
- print "\n";
- print " \n";
- }
- }
- print " ";
- $i++;
+ if ($objp->fk_account)
+ {
+ $acc=new Account($db);
+ $acc->fetch($objp->fk_account);
+ print ''.$acc->label.' ';
+ }
+ else
+ {
+ print "";
+ print "\n";
+ print " \n";
+ }
}
+ print "";
+ $i++;
+ }
$var=!$var;
- print "";
+ print ' ';
print "".$langs->trans("Total")." \n";
print " \n";
print "".price($total)." \n";
+ print ' ';
print " \n";
print "
";
print " \n";
@@ -246,5 +203,5 @@ else
$db->close();
-llxFooter("Dernière modification $Date$ révision $Revision$ ");
+llxFooter('$Date$ - $Revision$');
?>
diff --git a/htdocs/adherents/edit.php b/htdocs/adherents/edit.php
index 869ca2ecf66..bcb908796d9 100644
--- a/htdocs/adherents/edit.php
+++ b/htdocs/adherents/edit.php
@@ -1,7 +1,7 @@
* Copyright (C) 2002 Jean-Louis Bergamo
- * Copyright (C) 2004 Laurent Destailleur
+ * 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
@@ -128,7 +128,19 @@ if ($rowid)
$adht = new AdherentType($db);
- print_titre($langs->trans("EditMember"));
+
+ /*
+ * Affichage onglets
+ */
+ $h = 0;
+
+ $head[$h][0] = DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$rowid;
+ $head[$h][1] = $langs->trans("MemberCard");
+ $hselected=$h;
+ $h++;
+
+ dolibarr_fiche_head($head, $hselected, $adh->fullname);
+
print "';
+
+ print '';
}
$db->close();
-llxFooter("Dernière modification $Date$ révision $Revision$ ");
+llxFooter('$Date$ - $Revision$');
?>
diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index e25cfe61ac9..eebec62f5eb 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -67,27 +67,30 @@ if ($_POST["action"] == 'cotisation')
$adh = new Adherent($db);
$adh->id = $rowid;
$adh->fetch($rowid);
- if ($cotisation >= 0)
+ if ($cotisation > 0)
{
+ $db->begin();
+
// rajout du nouveau cotisant dans les listes qui vont bien
// if (defined("ADHERENT_MAILMAN_LISTS_COTISANT") && ADHERENT_MAILMAN_LISTS_COTISANT!='' && $adh->datefin == "0000-00-00 00:00:00"){
if (defined("ADHERENT_MAILMAN_LISTS_COTISANT") && ADHERENT_MAILMAN_LISTS_COTISANT!='' && $adh->datefin == 0){
$adh->add_to_mailman(ADHERENT_MAILMAN_LISTS_COTISANT);
}
+
$crowid=$adh->cotisation(mktime(12, 0 , 0, $remonth, $reday, $reyear), $cotisation);
- if (defined("ADHERENT_MAIL_COTIS") && defined("ADHERENT_MAIL_COTIS_SUBJECT")){
- $adh->send_an_email($adh->email,ADHERENT_MAIL_COTIS,ADHERENT_MAIL_COTIS_SUBJECT);
- }
+
// insertion dans la gestion banquaire si configure pour
- if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0 &&
- defined("ADHERENT_BANK_USE_AUTO") && ADHERENT_BANK_USE_AUTO !=0){
+ if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE)
+ {
+ $acct=new Account($db,$_POST["accountid"]);
+
$dateop=strftime("%Y%m%d",time());
$amount=$cotisation;
- $acct=new Account($db,ADHERENT_BANK_ACCOUNT);
- $insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"],ADHERENT_BANK_CATEGORIE,$user);
- if ($insertid == '')
+ $insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"], '', $user);
+ if ($insertid <= 0)
{
- dolibarr_print_error($db);
+ $db->rollback();
+ dolibarr_print_error($db,$acct->error);
}
else
{
@@ -96,14 +99,25 @@ if ($_POST["action"] == 'cotisation')
$result = $db->query($sql);
if ($result)
{
+ $db->commit();
//Header("Location: fiche.php");
}
else
{
+ $db->rollback();
dolibarr_print_error($db);
}
}
}
+ else
+ {
+ $db->commit();
+ }
+
+ if (defined("ADHERENT_MAIL_COTIS") && defined("ADHERENT_MAIL_COTIS_SUBJECT")){
+ $adh->send_an_email($adh->email,ADHERENT_MAIL_COTIS,ADHERENT_MAIL_COTIS_SUBJECT);
+ }
+
}
$action = "edit";
}
@@ -117,13 +131,13 @@ if ($_POST["action"] == 'add')
$adresse=$_POST["adresse"];
$cp=$_POST["cp"];
$ville=$_POST["ville"];
- $naiss=$_POST["pays"];
+ $pays=$_POST["pays"];
$email=$_POST["email"];
$login=$_POST["login"];
$pass=$_POST["pass"];
$naiss=$_POST["naiss"];
- $naiss=$_POST["photo"];
- $naiss=$_POST["note"];
+ $photo=$_POST["photo"];
+ $note=$_POST["note"];
$comment=$_POST["comment"];
$morphy=$_POST["morphy"];
$reday=$_POST["reday"];
@@ -138,13 +152,13 @@ if ($_POST["action"] == 'add')
$adh->adresse = $adresse;
$adh->cp = $cp;
$adh->ville = $ville;
+ $adh->pays = $pays;
$adh->email = $email;
$adh->login = $login;
$adh->pass = $pass;
$adh->naiss = $naiss;
$adh->photo = $photo;
$adh->note = $note;
- $adh->pays = $pays;
$adh->typeid = $type;
$adh->commentaire = $comment;
$adh->morphy = $morphy;
@@ -202,8 +216,9 @@ if ($_POST["action"] == 'add')
} else {
$public=0;
}
- if (!$error) {
+ if (!$error)
+ {
// Email a peu pres correct et le login n'existe pas
if ($adh->create($user->id))
{
@@ -211,12 +226,12 @@ if ($_POST["action"] == 'add')
{
$crowid=$adh->cotisation(mktime(12, 0 , 0, $remonth, $reday, $reyear), $cotisation);
// insertion dans la gestion banquaire si configure pour
- if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0 &&
- defined("ADHERENT_BANK_USE_AUTO") && ADHERENT_BANK_USE_AUTO !=0){
+ if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE)
+ {
$dateop=strftime("%Y%m%d",time());
$amount=$cotisation;
- $acct=new Account($db,ADHERENT_BANK_ACCOUNT);
- $insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"],ADHERENT_BANK_CATEGORIE);
+ $acct=new Account($db,$_POST["accountid"]);
+ $insertid=$acct->addline($dateop, $_POST["operation"], $_POST["label"], $amount, $_POST["num_chq"], '', $user);
if ($insertid == '')
{
dolibarr_print_error($db);
@@ -401,59 +416,58 @@ if ($action == 'create')
$htmls->select_array("morphy", $morphys);
print "\n";
- print ' ';
+ print ' ';
- print ''.$langs->trans("Firstname").'* ';
- print ''.$langs->trans("Lastname").'* ';
- print ''.$langs->trans("Company").' ';
- print ''.$langs->trans("Address").' ';
- print ' ';
- print ''.$langs->trans("Zip").' / '.$langs->trans("Town").' ';
- print ''.$langs->trans("Country").' ';
- print ''.$langs->trans("EMail").(ADHERENT_MAIL_REQUIRED&&ADHERENT_MAIL_REQUIRED==1?'*':'').' ';
- print ''.$langs->trans("Login").'* ';
- print ''.$langs->trans("Password").'* ';
- print ''.$langs->trans("Birthday").' ('.$langs->trans("DateFormatYYYYMMDD").') ';
+ print ''.$langs->trans("Firstname").'* ';
+ print ''.$langs->trans("Lastname").'* ';
+ print ''.$langs->trans("Company").' ';
+ print ''.$langs->trans("Address").' ';
+ print ' ';
+ print ''.$langs->trans("Zip").' / '.$langs->trans("Town").' ';
+ print ''.$langs->trans("Country").' ';
+ $htmls->select_pays($adh->pays?$adh->pays:MAIN_INFO_SOCIETE_PAYS,'pays');
+ print ' ';
+ print ''.$langs->trans("EMail").(ADHERENT_MAIL_REQUIRED&&ADHERENT_MAIL_REQUIRED==1?'*':'').' ';
+ print ''.$langs->trans("Login").'* ';
+ print ''.$langs->trans("Password").'* ';
+ print ''.$langs->trans("Birthday").' ('.$langs->trans("DateFormatYYYYMMDD").') ';
print 'Url photo ';
foreach($adho->attribute_label as $key=>$value){
print "$value \n";
}
+ print "\n";
+ print ' ';
+ // Boite cotisations
+ print '\n";
+ print ' ';
+
+ print ' ';
+ print "\n";
}
@@ -476,12 +490,12 @@ if ($rowid)
$html = new Form($db);
/*
- * Affichage onglets
- */
+ * Affichage onglets
+ */
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$rowid;
- $head[$h][1] = $langs->trans("Member");
+ $head[$h][1] = $langs->trans("MemberCard");
$hselected=$h;
$h++;
@@ -492,7 +506,8 @@ if ($rowid)
*/
if ($action == 'delete')
{
- $html->form_confirm("fiche.php?rowid=$rowid","Supprimer un adhérent","Etes-vous sûr de vouloir supprimer cet adhérent (La suppression d'un adhérent entraine la suppression de toutes ses cotisations !)","confirm_delete");
+ $html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_delete");
+ print ' ';
}
/*
@@ -500,7 +515,8 @@ if ($rowid)
*/
if ($action == 'valid')
{
- $html->form_confirm("fiche.php?rowid=$rowid","Valider un adhérent","Etes-vous sûr de vouloir valider cet adhérent ?","confirm_valid");
+ $html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid");
+ print ' ';
}
/*
@@ -508,7 +524,8 @@ if ($rowid)
*/
if ($action == 'resign')
{
- $html->form_confirm("fiche.php?rowid=$rowid","Résilier une adhésion","Etes-vous sûr de vouloir résilier cet adhérent ?","confirm_resign");
+ $html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign");
+ print ' ';
}
/*
@@ -517,6 +534,7 @@ if ($rowid)
if ($action == 'add_glasnost')
{
$html->form_confirm("fiche.php?rowid=$rowid","Ajouter dans glasnost","Etes-vous sur de vouloir ajouter cet adhérent dans glasnost ? (serveur : ".ADHERENT_GLASNOST_SERVEUR.")","confirm_add_glasnost");
+ print ' ';
}
/*
@@ -525,6 +543,7 @@ if ($rowid)
if ($action == 'del_glasnost')
{
$html->form_confirm("fiche.php?rowid=$rowid","Supprimer dans glasnost","Etes-vous sur de vouloir effacer cet adhérent dans glasnost ? (serveur : ".ADHERENT_GLASNOST_SERVEUR.")","confirm_del_glasnost");
+ print ' ';
}
/*
@@ -533,6 +552,7 @@ if ($rowid)
if ($action == 'add_spip')
{
$html->form_confirm("fiche.php?rowid=$rowid","Ajouter dans spip","Etes-vous sur de vouloir ajouter cet adhérent dans spip ? (serveur : ".ADHERENT_SPIP_SERVEUR.")","confirm_add_spip");
+ print ' ';
}
/*
@@ -542,6 +562,7 @@ if ($rowid)
{
$html->form_confirm("fiche.php?rowid=$rowid","Supprimer dans spip","Etes-vous sur de vouloir effacer cet adhérent dans spip ? (serveur : ".ADHERENT_SPIP_SERVEUR.")","confirm_del_spip");
$html->form_confirm("fiche.php?rowid=$rowid","Ajouter dans glasnost","Etes-vous sur de vouloir ajouter cet adhérent dans glasnost ? (serveur : ".ADHERENT_GLASNOST_SERVEUR.")","confirm_del_spip");
+ print ' ';
}
@@ -556,7 +577,7 @@ if ($rowid)
print '';
print nl2br($adh->commentaire).' ';
- print 'Personne '.$adh->getmorphylib().' ';
+ print ''.$langs->trans("Person").' '.$adh->getmorphylib().' ';
print ''.$langs->trans("Firstname").'* '.$adh->prenom.' ';
@@ -565,7 +586,7 @@ if ($rowid)
print ''.$langs->trans("Company").' '.$adh->societe.' ';
print ''.$langs->trans("Address").' '.nl2br($adh->adresse).' ';
print ''.$langs->trans("Zip").' / '.$langs->trans("Town").' '.$adh->cp.' '.$adh->ville.' ';
- print ''.$langs->trans("Country").' '.$adh->pays.' ';
+ print ''.$langs->trans("Country").' '.$adh->pays.' ';
print ''.$langs->trans("EMail").(ADHERENT_MAIL_REQUIRED&&ADHERENT_MAIL_REQUIRED==1?'*':'').' '.$adh->email.' ';
print ''.$langs->trans("Login").'* '.$adh->login.' ';
// print 'Pass '.$adh->pass.' ';
@@ -583,7 +604,6 @@ if ($rowid)
print '';
print "\n";
- print " ";
print "\n";
@@ -595,26 +615,26 @@ if ($rowid)
print '';
- print "
".$langs->trans("Edit")." ";
+ print "
".$langs->trans("Edit")." ";
// Valider
if ($adh->statut < 1)
{
- print "
".$langs->trans("Validate")." \n";
+ print "
".$langs->trans("Validate")." \n";
}
// Envoi fiche par mail
- print "
id&action=sendinfo\">".$langs->trans("SendCardByMail")." \n";
+ print "
id&action=sendinfo\">".$langs->trans("SendCardByMail")." \n";
// Résilier
if ($adh->statut == 1)
{
- print "
".$langs->trans("Resiliate")." \n";
+ print "
".$langs->trans("Resiliate")." \n";
}
// Supprimer
if ($user->admin) {
- print "
id&action=delete\">".$langs->trans("Delete")." \n";
+ print "
id&action=delete\">".$langs->trans("Delete")." \n";
}
// Action Glasnost
@@ -684,7 +704,7 @@ if ($rowid)
print "
\n";
print '';
- print "Date cotisations \n";
+ print ''.$langs->trans("DateSubscription").' ';
print "".$langs->trans("Amount")." \n";
print " \n";
@@ -711,10 +731,8 @@ if ($rowid)
/*
* Ajout d'une nouvelle cotisation
- *
*/
- // \todo Ajout du droit adherent cotisation
- if ($user->rights->adherent->cotisation || 1==1)
+ if ($user->rights->adherent->cotisation->creer)
{
print "\n";
@@ -723,22 +741,28 @@ if ($rowid)
print ' ';
print ''.$langs->trans("SubscriptionEndDate").' ';
- if ($adh->datefin < time())
+ print '';
+ if ($adh->datefin)
{
- print ' ';
- print dolibarr_print_date($adh->datefin)." ".img_warning($langs->trans("Late"));
+ if ($adh->datefin < time())
+ {
+ print dolibarr_print_date($adh->datefin)." ".img_warning($langs->trans("Late"));
+ }
+ else
+ {
+ print dolibarr_print_date($adh->datefin);
+ }
}
else
{
- print ' ';
- print dolibarr_print_date($adh->datefin);
+ print $langs->trans("SubscriptionNotReceived")." ".img_warning($langs->trans("Late"));
}
print ' ';
print ' ';
- print ''.$langs->trans("NewCotisation").' ';
+ print ''.$langs->trans("NewCotisation").' ';
- print "Date de cotisation \n";
+ print ' '.$langs->trans("DateSubscription").' ';
if ($adh->datefin > 0)
{
$html->select_date($adh->datefin + (3600*24));
@@ -750,21 +774,25 @@ if ($rowid)
print " ";
- print "Mode de paiement \n";
- print_type_paiement_select($db,'operation');
- print " \n";
-
- if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0 &&
- defined("ADHERENT_BANK_USE_AUTO") && ADHERENT_BANK_USE_AUTO !=0){
- print "Numero de cheque \n";
- print ' ';
+ print ' '.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->monnaie).' ';
+
+ if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE)
+ {
+ print ''.$langs->trans("PaymentMode").' ';
+ $html->select_types_paiements('','operation');
print " \n";
+
+ print ''.$langs->trans("FinancialAccount").' ';
+ $html->select_comptes('','accountid');
+ print " \n";
+
+ print ''.$langs->trans("Numero").' ';
+ print ' ';
+ print " \n";
+
+ print ''.$langs->trans("Label").' prenom).' '.stripslashes($adh->nom).' '.strftime("%Y",$adh->datefin).'" > ';
}
- print ''.$langs->trans("Subscription").' '.$langs->trans("Currency".$conf->monnaie).' ';
- if (defined("ADHERENT_BANK_USE") && ADHERENT_BANK_USE !=0 &&
- defined("ADHERENT_BANK_USE_AUTO") && ADHERENT_BANK_USE_AUTO !=0){
- print ''.$langs->trans("Label").' datefin).'" > ';
- }
+
print ' ';
print '';
diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php
index da7197193a9..aea3871a861 100644
--- a/htdocs/adherents/index.php
+++ b/htdocs/adherents/index.php
@@ -23,9 +23,9 @@
*/
/**
- \file htdocs/adherents/index.php
- \ingroup adherent
- \brief Page accueil module adherents
+ \file htdocs/adherents/index.php
+ \ingroup adherent
+ \brief Page accueil module adherents
*/
@@ -38,10 +38,15 @@ $langs->load("members");
llxHeader();
-print_titre($langs->trans("MembersArea"));
-print ' ';
+print_fiche_titre($langs->trans("MembersArea"));
-print '';
+print '';
+
+print '';
+
+
+
+print '';
print '';
print ''.$langs->trans("Type").' ';
print ''.$langs->trans("MembersStatusToValid").' ';
@@ -112,19 +117,18 @@ $SommeD=0;
foreach ($AdherentsAll as $key=>$value){
$var=!$var;
print " ";
- print ''.$key.' ';
- print ''.$AdherentsAValider[$key].' ';
- print ''.$Adherents[$key].' ';
- print ''.$Cotisants[$key].' ';
- print ''.($AdherentsResilies[$key]?$AdherentsResilies[$key]:0).' ';
+ print ''.img_object($langs->trans("ShowType"),"group").' '.$key.' ';
+ print ''.(isset($AdherentsAValider[$key])?$AdherentsAValider[$key]:'').' ';
+ print ''.(isset($Adherents[$key])?$Adherents[$key]:'').' ';
+ print ''.(isset($Cotisants[$key])?$Cotisants[$key]:'').' ';
+ print ''.(isset($AdherentsResilies[$key])?$AdherentsResilies[$key]:'').' ';
print " \n";
- $SommeA+=$AdherentsAValider[$key];
- $SommeB+=$Adherents[$key];
- $SommeC+=$Cotisants[$key];
- $SommeD+=$AdherentsResilies[$key];
+ $SommeA+=isset($AdherentsAValider[$key])?$AdherentsAValider[$key]:0;
+ $SommeB+=isset($Adherents[$key])?$Adherents[$key]:0;
+ $SommeC+=isset($Cotisants[$key])?$Cotisants[$key]:0;
+ $SommeD+=isset($AdherentsResilies[$key])?$AdherentsResilies[$key]:0;
}
-$var=!$var;
-print "";
+print ' ';
print ' '.$langs->trans("Total").' ';
print ''.$SommeA.' ';
print ''.$SommeB.' ';
@@ -136,24 +140,80 @@ print "
";
print ' ';
+
+print ' ';
+print '';
+
+
// Formulaire recherche adhérent
print '';
print ' ';
-print '';
+print '";
+print '';
+
+$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();
+$tot=0;
+$numb=0;
+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 ''.$langs->trans("Year").' ';
+print ''.$langs->trans("Subscriptions").' ';
+print ''.$langs->trans("Number").' ';
+print ''.$langs->trans("Average").' ';
+print " \n";
+
+$var=true;
+foreach ($Total as $key=>$value)
+{
+ $var=!$var;
+ print "$key ".price($value)." ".$Number[$key]." ".price($value/$Number[$key])." \n";
+}
+
+// Total
+print ''.$langs->trans("Total").' '.price($tot)." ".$numb." ".price($tot/$numb)." \n";
+print "
\n";
+
+print ' ';
+print '
';
+
$db->close();
llxFooter('$Date$ - $Revision$');
diff --git a/htdocs/adherents/liste.php b/htdocs/adherents/liste.php
index 94450b73837..45d2f3779be 100644
--- a/htdocs/adherents/liste.php
+++ b/htdocs/adherents/liste.php
@@ -39,20 +39,18 @@ llxHeader();
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
$page=$_GET["page"];
+$filter=$_GET["filter"];
$statut=isset($_GET["statut"])?$_GET["statut"]:1;
if (! $sortorder) { $sortorder="ASC"; }
if (! $sortfield) { $sortfield="d.nom"; }
-
if ($page == -1) { $page = 0 ; }
-
$offset = $conf->liste_limit * $page ;
-
$pageprev = $page - 1;
$pagenext = $page + 1;
-$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, ".$db->pdate("d.datefin")." as datefin";
-$sql .= " , d.email, t.libelle as type, d.morphy, d.statut, t.cotisation";
+$sql = "SELECT d.rowid, d.prenom, d.nom, d.societe, ".$db->pdate("d.datefin")." as datefin,";
+$sql .= " d.email, d.fk_adherent_type as type_id, t.libelle as type, d.morphy, d.statut, t.cotisation";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
$sql .= " WHERE d.fk_adherent_type = t.rowid ";
if ($_GET["type"]) {
@@ -64,111 +62,119 @@ if (isset($_GET["statut"])) {
if ( $_POST["action"] == 'search')
{
if (isset($_POST['search']) && $_POST['search'] != ''){
- $sql .= " AND (d.prenom LIKE '%".$_POST['search']."%' OR d.nom LIKE '%".$_POST['search']."%')";
+ $sql.= " AND (d.prenom LIKE '%".$_POST['search']."%' OR d.nom LIKE '%".$_POST['search']."%')";
}
}
+if ($filter == 'uptodate') {
+ $sql.=" AND datefin >= sysdate()";
+}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset);
$result = $db->query($sql);
if ($result)
{
- $num = $db->num_rows();
- $i = 0;
-
- $titre=$langs->trans("MembersList");
- if (isset($_GET["statut"])) {
- if ($statut == -1) { $titre=$langs->trans("MembersListToValid"); }
- if ($statut == 1) { $titre=$langs->trans("MembersListValid"); }
- if ($statut == 0) { $titre=$langs->trans("MembersListResiliated"); }
- }
- elseif ($_POST["action"] == 'search') {
- $titre="Liste des adhérents répondant aux critères";
- }
+ $num = $db->num_rows($result);
+ $i = 0;
- if ($_GET["type"]) {
- $objp = $db->fetch_object($result);
- $titre.=" (".$objp->type.")";
- }
-
- print_barre_liste($titre, $page, "liste.php", "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield",$sortfield,$sortorder,'',$num);
-
- print "";
-
- print '';
- print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),"liste.php","d.nom","&page=$page&statut=$statut","","",$sortfield);
- print_liste_field_titre($langs->trans("DateAbonment"),"liste.php","t.cotisation","&page=$page&statut=$statut","","",$sortfield);
- print_liste_field_titre($langs->trans("EMail"),"liste.php","d.email","&page=$page&statut=$statut","","",$sortfield);
- print_liste_field_titre($langs->trans("Type"),"liste.php","t.libelle","&page=$page&statut=$statut","","",$sortfield);
- print_liste_field_titre($langs->trans("Person"),"liste.php","d.morphy","&page=$page&statut=$statut","","",$sortfield);
- print_liste_field_titre($langs->trans("Status"),"liste.php","d.statut","&page=$page&statut=$statut","","",$sortfield);
- print "".$langs->trans("Action")." \n";
- print " \n";
-
- $var=True;
- while ($i < $num)
- {
- if ($_GET["type"] && $i==0) { # Fetch deja fait
- } else {
- $objp = $db->fetch_object($result);
- }
-
- $adh=new Adherent($db);
-
- $var=!$var;
- print "";
- if ($objp->societe != ''){
- print "rowid&action=edit\">".stripslashes($objp->prenom)." ".stripslashes($objp->nom)." / ".stripslashes($objp->societe)." \n";
- }else{
- print "rowid&action=edit\">".stripslashes($objp->prenom)." ".stripslashes($objp->nom)." \n";
- }
- print "";
- if ($objp->cotisation == 'yes')
- {
- if ($objp->datefin < time())
- {
- print dolibarr_print_date($objp->datefin)." - Cotisation non recue ".img_warning()." \n";
- }
- else
- {
- print dolibarr_print_date($objp->datefin)."\n";
- }
- }
- else
- {
- print " ";
- }
-
- print "$objp->email \n";
- print "$objp->type \n";
- print "".$adh->getmorphylib($objp->morphy)." \n";
- print "";
-
- if ($objp->statut == -1) print '';
- print $adh->LibStatut($objp->statut);
- if ($objp->statut == -1) print ' ';
-
- print " ";
- print "rowid&action=edit\">".img_edit()." ";
- print "rowid&action=resign\">".img_disable($langs->trans("Resiliate"))." rowid&action=delete\">".img_delete()." \n";
- print " ";
- $i++;
+ $titre=$langs->trans("MembersList");
+ if (isset($_GET["statut"])) {
+ if ($statut == -1) { $titre=$langs->trans("MembersListToValid"); }
+ if ($statut == 1) { $titre=$langs->trans("MembersListValid"); }
+ if ($statut == 0) { $titre=$langs->trans("MembersListResiliated"); }
+ }
+ elseif ($_POST["action"] == 'search') {
+ $titre="Liste des adhérents répondant aux critères";
}
- print "
\n";
- print "";
-
- print_barre_liste("", $page, "liste.php", "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield",$sortfield,$sortorder,'',$num);
- print "
\n";
+ if ($_GET["type"]) {
+ $objp = $db->fetch_object($result);
+ $titre.=" (".$objp->type.")";
+ }
-}
+ print_barre_liste($titre, $page, "liste.php", "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield",$sortfield,$sortorder,'',$num);
+
+ print "";
+
+ print '';
+ print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),"liste.php","d.nom","&page=$page&statut=$statut","","",$sortfield);
+ print_liste_field_titre($langs->trans("DateAbonment"),"liste.php","t.cotisation","&page=$page&statut=$statut","","",$sortfield);
+ print_liste_field_titre($langs->trans("EMail"),"liste.php","d.email","&page=$page&statut=$statut","","",$sortfield);
+ print_liste_field_titre($langs->trans("Type"),"liste.php","t.libelle","&page=$page&statut=$statut","","",$sortfield);
+ print_liste_field_titre($langs->trans("Person"),"liste.php","d.morphy","&page=$page&statut=$statut","","",$sortfield);
+ print_liste_field_titre($langs->trans("Status"),"liste.php","d.statut","&page=$page&statut=$statut","","",$sortfield);
+ print "".$langs->trans("Action")." \n";
+ print " \n";
+
+ $var=True;
+ while ($i < $num)
+ {
+ if ($_GET["type"] && $i==0) { # Fetch deja fait
+ } else {
+ $objp = $db->fetch_object($result);
+ }
+
+ $adh=new Adherent($db);
+
+ $var=!$var;
+ print "";
+ if ($objp->societe != ''){
+ print "rowid&action=edit\">".img_object($langs->trans("ShowAdherent"),"user").' '.stripslashes($objp->prenom)." ".stripslashes($objp->nom)." / ".stripslashes($objp->societe)." \n";
+ }else{
+ print "rowid&action=edit\">".img_object($langs->trans("ShowAdherent"),"user").' '.stripslashes($objp->prenom)." ".stripslashes($objp->nom)." \n";
+ }
+ print "";
+ if ($objp->cotisation == 'yes')
+ {
+ if ($objp->datefin)
+ {
+ if ($objp->datefin < time())
+ {
+ print dolibarr_print_date($objp->datefin)." - ".$langs->trans("SubscriptionLate")." ".img_warning()." \n";
+ }
+ else
+ {
+ print dolibarr_print_date($objp->datefin)."\n";
+ }
+ }
+ else {
+ print $langs->trans("SubscriptionNotReceived")." ".img_warning()."\n";
+ }
+ }
+ else
+ {
+ print " ";
+ }
+
+ print "$objp->email \n";
+ print ''.img_object($langs->trans("ShowType"),"group").' '.$objp->type.' ';
+ print "".$adh->getmorphylib($objp->morphy)." \n";
+
+ // Statut
+ print "";
+ print $adh->LibStatut($objp->statut);
+ print " ";
+
+ print "rowid&action=edit\">".img_edit()." ";
+ print "rowid&action=resign\">".img_disable($langs->trans("Resiliate"))." rowid&action=delete\">".img_delete()." \n";
+ print " ";
+ $i++;
+ }
+ print "
\n";
+ print "";
+
+ print_barre_liste("", $page, "liste.php", "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield",$sortfield,$sortorder,'',$num);
+
+ print "
\n";
+
+ }
else
{
- print $sql;
- print $db->error();
+ dolibarr_print_error($db);
}
$db->close();
-llxFooter("Dernière modification $Date$ révision $Revision$ ");
+llxFooter('$Date$ - $Revision$');
+
?>
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index fc747c55cae..8b86e68d63f 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -35,6 +35,9 @@ require(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
$langs->load("members");
+$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
+
+
if ($_POST["action"] == 'add' && $user->admin)
{
@@ -62,7 +65,7 @@ if ($_POST["action"] == 'update' && $user->admin)
{
if ($_POST["button"] != $langs->trans("Cancel")) {
$adht = new AdherentType($db);
- $adht->id = $_POST["rowid"];;
+ $adht->id = $_POST["rowid"];
$adht->libelle = $_POST["libelle"];
$adht->cotisation = $yesno[$_POST["cotisation"]];
$adht->commentaire = $_POST["comment"];
@@ -70,8 +73,10 @@ if ($_POST["action"] == 'update' && $user->admin)
$adht->vote = $yesno[$_POST["vote"]];
$adht->update($user->id);
+
+ Header("Location: type.php?rowid=".$_POST["rowid"]);
+ exit;
}
- Header("Location: type.php");
}
if ($_GET["action"] == 'delete')
@@ -99,7 +104,7 @@ llxHeader();
/* */
/* ************************************************************************** */
-if ($_GET["action"] != 'create' && $_GET["action"] != 'edit') {
+if (! $rowid && $_GET["action"] != 'create' && $_GET["action"] != 'edit') {
print_titre($langs->trans("MembersTypeSetup"));
print ' ';
@@ -117,7 +122,7 @@ if ($_GET["action"] != 'create' && $_GET["action"] != 'edit') {
print '';
print '';
- print "Id ";
+ print ''.$langs->trans("Ref").' ';
print ''.$langs->trans("Label").' '.$langs->trans("SubscriptionRequired").' ';
print ''.$langs->trans("VoteAllowed").' ';
print " \n";
@@ -128,7 +133,7 @@ if ($_GET["action"] != 'create' && $_GET["action"] != 'edit') {
$objp = $db->fetch_object($result);
$var=!$var;
print "";
- print "".$objp->rowid." \n";
+ print ''.img_object($langs->trans("ShwoType"),'group').' '.$objp->rowid.' ';
print ''.$objp->libelle.' ';
print ''.$langs->trans($objp->cotisation).' ';
print ''.$langs->trans($objp->vote).' ';
@@ -157,7 +162,7 @@ if ($_GET["action"] != 'create' && $_GET["action"] != 'edit') {
/* ************************************************************************** */
/* */
-/* Création d'une fiche don */
+/* Création d'un type adherent */
/* */
/* ************************************************************************** */
@@ -202,47 +207,106 @@ if ($_GET["action"] == 'create') {
/* Edition de la fiche */
/* */
/* ************************************************************************** */
-if ($_GET["rowid"] > 0 && $_GET["action"] == 'edit')
+if ($rowid > 0)
{
- $htmls = new Form($db);
+ if ($_GET["action"] != 'edit')
+ {
+ $adht = new AdherentType($db);
+ $adht->id = $rowid;
+ $adht->fetch($rowid);
- $adht = new AdherentType($db);
- $adht->id = $_GET["rowid"];
- $adht->fetch($_GET["rowid"]);
- print_titre($langs->trans("EditType"));
- print ' ';
-
- print '';
- print ' ';
- print ' ';
- print '';
- print " ";
-
+ $h=0;
+
+ $head[$h][0] = $_SERVER["PHP_SELF"].'?rowid='.$adht->id;
+ $head[$h][1] = $langs->trans("MemberType").': '.$adht->libelle;
+ $h++;
+
+ dolibarr_fiche_head($head, 0, '');
+
+
+ print '';
+ print ' ';
+ print ' ';
+ print '';
+ print " ";
+ }
}
$db->close();
-llxFooter("Dernière modification $Date$ révision $Revision$ ");
+llxFooter('$Date$ - $Revision$');
?>