diff --git a/htdocs/adherents/edit.php b/htdocs/adherents/edit.php index c2680b7d495..0494d1c7637 100644 --- a/htdocs/adherents/edit.php +++ b/htdocs/adherents/edit.php @@ -26,7 +26,8 @@ require(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); require(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php"); -$adho = new AdherentOptions($db); +$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; +$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"]; /* * Enregistrer les modifs @@ -91,6 +92,7 @@ llxHeader(); if ($rowid) { + $adho = new AdherentOptions($db); $adh = new Adherent($db); $adh->id = $rowid; $adh->fetch($rowid); diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 134474ab7a5..e70e2620420 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -33,6 +33,7 @@ $adho = new AdherentOptions($db); $errmsg=''; $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; +$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"]; if ($_POST["action"] == 'sendinfo') @@ -94,12 +95,51 @@ if ($_POST["action"] == 'cotisation') if ($_POST["action"] == 'add') { $type=$_POST["type"]; + $nom=$_POST["nom"]; + $prenom=$_POST["prenom"]; + $societe=$_POST["societe"]; + $adresse=$_POST["adresse"]; + $cp=$_POST["cp"]; + $ville=$_POST["ville"]; + $naiss=$_POST["pays"]; + $email=$_POST["email"]; + $login=$_POST["login"]; + $pass=$_POST["pass"]; + $naiss=$_POST["naiss"]; + $naiss=$_POST["photo"]; + $naiss=$_POST["note"]; + $comment=$_POST["comment"]; + $morphy=$_POST["morphy"]; + + $adh = new Adherent($db); + $adh->prenom = $prenom; + $adh->nom = $nom; + $adh->societe = $societe; + $adh->adresse = $adresse; + $adh->cp = $cp; + $adh->ville = $ville; + $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; + foreach($_POST as $key => $value){ + if (ereg("^options_",$key)){ + $adh->array_options[$key]=$_POST[$key]; + } + } + + // Test validite des paramètres if(!isset($type) || $type==''){ $error+=1; $errmsg .="Le type d'adhérent n'est pas renseigné. Vous devez configurer les types d'adhérents avant de pouvoir les ajouter.
\n"; } - $login=$_POST["login"]; - // test si le login existe deja + // Test si le login existe deja if(!isset($login) || $login==''){ $error+=1; $errmsg .="Login vide. Veuillez en positionner un
\n"; @@ -134,34 +174,10 @@ if ($_POST["action"] == 'add') if (isset($public)){ $public=1; }else{ - $public=0; -} -if (!$error){ - // email a peu pres correct et le login n'existe pas - $adh = new Adherent($db); - $adh->statut = -1; - $adh->prenom = $prenom; - $adh->nom = $nom; - $adh->societe = $societe; - $adh->adresse = $adresse; - $adh->cp = $cp; - $adh->ville = $ville; - $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 = $_POST["comment"]; - $adh->morphy = $_POST["morphy"]; - - foreach($_POST as $key => $value){ - if (ereg("^options_",$key)){ - $adh->array_options[$key]=$_POST[$key]; - } + $public=0; } + if (!$error){ + // email a peu pres correct et le login n'existe pas if ($adh->create($user->id) ) { if ($cotisation > 0) @@ -195,7 +211,7 @@ if (!$error){ } } } - Header("Location: liste.php"); + Header("Location: liste.php?statut=-1"); } } } @@ -207,6 +223,9 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes) Header("Location: liste.php"); } +llxHeader(); + + if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes) { $adh = new Adherent($db, $rowid); @@ -252,8 +271,6 @@ if ($_POST["action"] == 'confirm_resign' && $_POST["confirm"] == yes) } } -llxHeader(); - if ($_POST["action"] == 'confirm_add_glasnost' && $_POST["confirm"] == yes) { $adh = new Adherent($db, $rowid); @@ -349,11 +366,6 @@ if ($action == 'create') { print ''; print 'Prénom'; - - - - - print 'Nom'; print 'Societe'; print 'Adresse'; diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index c2466fa606a..86a756f40a5 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -48,7 +48,7 @@ $AdherentsResilies=array(); $Cotisants=array(); # Liste les adherents -$sql = "SELECT count(*) as somme , t.libelle, d.statut FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; +$sql = "SELECT count(*) as somme , t.rowid, t.libelle, d.statut FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE d.fk_adherent_type = t.rowid GROUP BY t.libelle, d.statut"; $result = $db->query($sql); @@ -60,7 +60,7 @@ if ($result) while ($i < $num) { $objp = $db->fetch_object( $i); - $AdherentsAll[$objp->libelle]+=$objp->somme; + $AdherentsAll[$objp->libelle]=$objp->rowid; if ($objp->statut == -1) { $AdherentsAValider[$objp->libelle]=$objp->somme; } if ($objp->statut == 1) { $Adherents[$objp->libelle]=$objp->somme; } if ($objp->statut == 0) { $AdherentsResilies[$objp->libelle]=$objp->somme; } @@ -97,11 +97,11 @@ $SommeD=0; foreach ($AdherentsAll as $key=>$value){ $var=!$var; print ""; - print ''.$key.''; - print ''.$AdherentsAValider[$key].''; - print ''.$Adherents[$key].''; - print ''.$Cotisants[$key].''; - print ''.$AdherentsResilies[$key].''; + print ''.$key.''; + print ''.$AdherentsAValider[$key].''; + print ''.$Adherents[$key].''; + print ''.$Cotisants[$key].''; + print ''.($AdherentsResilies[$key]?$AdherentsResilies[$key]:0).''; print "\n"; $SommeA+=$AdherentsAValider[$key]; $SommeB+=$Adherents[$key]; @@ -121,7 +121,8 @@ print ""; print '
'; -print '
'; +// Formulaire recherche adhérent +print ''; print ''; print ''; print ''; @@ -138,8 +139,6 @@ print ''; print "
"; - - $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); diff --git a/htdocs/adherents/liste.php b/htdocs/adherents/liste.php index 8312e004f29..f36c821262c 100644 --- a/htdocs/adherents/liste.php +++ b/htdocs/adherents/liste.php @@ -31,6 +31,7 @@ llxHeader(); $sortorder=$_GET["sortorder"]; $sortfield=$_GET["sortfield"]; $page=$_GET["page"]; +$statut=isset($_GET["statut"])?$_GET["statut"]:1; if ($sortorder == "") { $sortorder="ASC"; } if ($sortfield == "") { $sortfield="d.nom"; } @@ -42,15 +43,16 @@ $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; -if (! isset($_GET["statut"])) -{ - $statut = 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 .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; -$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = $statut"; +$sql .= " WHERE d.fk_adherent_type = t.rowid "; +if ($_GET["type"]) { + $sql.=" AND t.rowid=".$_GET["type"]; +} +if (isset($_GET["statut"])) { + $sql.=" AND d.statut = $statut"; +} if ( $_POST["action"] == 'search') { if (isset($_POST['search']) && $_POST['search'] != ''){ @@ -66,17 +68,27 @@ if ($result) $i = 0; $titre="Liste des adhérents"; - if (isset($_GET["statut"]) && $_GET["statut"] == -1) { $titre="Liste des adhérents à valider"; } - if (isset($_GET["statut"]) && $_GET["statut"] == 1) { $titre="Liste des adhérents valides"; } - if (isset($_GET["statut"]) && $_GET["statut"] == 0) { $titre="Liste des adhérents résiliés"; } + if (isset($_GET["statut"])) { + if ($statut == -1) { $titre="Liste des adhérents à valider"; } + if ($statut == 1) { $titre="Liste des adhérents valides"; } + if ($statut == 0) { $titre="Liste des adhérents résiliés"; } + } + elseif ($_POST["action"] == 'search') { + $titre="Liste des adhérents répondant aux critères"; + } + + if ($_GET["type"]) { + $objp = $db->fetch_object(0); + $titre.=" (".$objp->type.")"; + } + + print_barre_liste($titre, $page, $PHP_SELF, "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield",$sortfield,$sortorder,'',$num); - print_barre_liste($titre, $page, $PHP_SELF, "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield"); print ""; print ''; print '\n"; @@ -106,8 +118,11 @@ if ($result) $var=True; while ($i < $num) { - $objp = $db->fetch_object($i); - + if ($_GET["type"] && $i==0) { # Fetch deja fait + } else { + $objp = $db->fetch_object($i); + } + $adh=new Adherent($db); $var=!$var; @@ -161,10 +176,9 @@ if ($result) print "
'; - // print_liste_field_titre("Prenom",$PHP_SELF,"d.prenom","&page=$page&statut=$statut"); print_liste_field_titre("Prenom Nom / Société",$PHP_SELF,"d.nom","&page=$page&statut=$statut"); print "

\n"; print ""; - print ''; - print ''; + print_barre_liste("", $page, $PHP_SELF, "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield",$sortfield,$sortorder,'',$num); + +// print_fleche_navigation($page,$PHP_SELF,"&statut=$statut&sortorder=$sortorder&sortfield=$sortfield",1); print "
'; - print_fleche_navigation($page,$PHP_SELF,"&statut=$statut&sortorder=$sortorder&sortfield=$sortfield",1); - print '

\n"; } diff --git a/htdocs/adherents/options.php b/htdocs/adherents/options.php index e1f7db823c8..05826a42142 100644 --- a/htdocs/adherents/options.php +++ b/htdocs/adherents/options.php @@ -1,6 +1,7 @@ - * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2003 Jean-Louis Bergamo + * 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 @@ -26,88 +27,94 @@ require(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php"); $adho = new AdherentOptions($db); $form = new Form($db); -if ($HTTP_POST_VARS["action"] == 'add' && $user->admin) +if ($_POST["action"] == 'add' && $user->admin) { - // type et taille non encore pris en compte => varchar(255) - if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_POST['attrname'])){ - $adho->create($_POST['attrname'],$_POST['type'],$_POST['size']); - } - if (isset($_POST['label'])){ - $adho->create_label($_POST['attrname'],$_POST['label']); - } - Header("Location: $PHP_SELF"); + if ($_POST["button"] != "Annuler") { + // Type et taille non encore pris en compte => varchar(255) + if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_POST['attrname'])){ + $adho->create($_POST['attrname'],$_POST['type'],$_POST['size']); + } + if (isset($_POST['label'])){ + $adho->create_label($_POST['attrname'],$_POST['label']); + } + } + Header("Location: ".$_SERVER["PHP_SELF"]); } -if ($HTTP_POST_VARS["action"] == 'update' && $user->admin) +if ($_POST["action"] == 'update' && $user->admin) { - //if ($adho->update($user->id) ) - // { - // } - if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_POST['attrname'])){ - $adho->update($_POST['attrname'],$_POST['type'],$_POST['size']); - } - if (isset($_POST['label'])){ - $adho->update_label($_POST['attrname'],$_POST['label']); - } - Header("Location: $PHP_SELF"); - + if ($_POST["button"] != "Annuler") { + if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_POST['attrname'])){ + $adho->update($_POST['attrname'],$_POST['type'],$_POST['size']); + } + if (isset($_POST['label'])){ + $adho->update_label($_POST['attrname'],$_POST['label']); + } + } + Header("Location: ".$_SERVER["PHP_SELF"]); } -if ($action == 'delete' && $user->admin) +# Suppression attribut +if ($_GET["action"] == 'delete' && $user->admin) { - if(isset($attrname) && preg_match("/^\w[a-zA-Z0-9-]*$/",$attrname)){ - $adho->delete($attrname); + if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-]*$/",$_GET["attrname"])){ + $adho->delete($_GET["attrname"]); } - Header("Location: $PHP_SELF"); + Header("Location: ".$_SERVER["PHP_SELF"]); } + llxHeader(); -print_titre("Configuration des champs optionnels"); -/* ************************************************************************** */ -/* */ -/* */ -/* */ -/* ************************************************************************** */ +//if ($_GET["action"] != 'create') { -$array_options=$adho->fetch_name_optionals(); -$array_label=$adho->fetch_name_optionals_label(); -if (sizeof($array_options)>0) -{ - print ""; - - print ''; - print ""; - print ""; - print ""; - print "\n"; - - $var=True; - foreach($adho->attribute_name as $key => $value) + print_titre("Configuration des champs optionnels"); + print '
'; + + /* ************************************************************************** */ + /* */ + /* */ + /* */ + /* ************************************************************************** */ + + $array_options=$adho->fetch_name_optionals(); + $array_label=$adho->fetch_name_optionals_label(); + if (sizeof($array_options)>0) { - $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print "\n"; - print ""; - // $i++; + print "
LibelleNom de l'attributtype  
".$adho->attribute_label[$key]." $key$valueEditerSupprimer
"; + + print ''; + print ""; + print ""; + print ""; + print "\n"; + + $var=True; + foreach($adho->attribute_name as $key => $value) + { + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print ""; + // $i++; + } + print "
LibelleNom de l'attributType 
".$adho->attribute_label[$key]." $key$value".img_edit().""; + print "  ".img_delete()."
"; + + /* + * Barre d'actions + * + */ + print '
'; + print "Nouvel attribut"; + print "
"; } - print ""; -} - - /* - * Barre d'actions - * - */ - print '
'; - print "Nouvel attribut"; - print "
"; - +//} /* ************************************************************************** */ /* */ @@ -115,39 +122,29 @@ if (sizeof($array_options)>0) /* */ /* ************************************************************************** */ - -if ($action == 'create') { +if ($_GET["action"] == 'create') { print_titre("Nouvel attribut"); + print '
'; + print "
"; - print ''; + print '
'; print ''; print ''; print ''; - - print ''; - - print ''; + print ''; - print ''; + print ''; print "\n"; print "
Libellé
Nom de l\'attribut (pas d\'espace et uniquement des carateres alphanumeriques)
Type (non pris en compte)'; - + print '
Type'; $form->select_array('type',array('varchar'=>'chaine', 'text'=>'texte', - 'integer'=>'entier', + 'int'=>'entier', 'date'=>'date', 'datetime'=>'date et heure')); - /* - print ''; - */ print '
taille
Taille
  '; + print '
\n"; @@ -158,41 +155,34 @@ if ($action == 'create') { /* Edition d'un champ optionnel */ /* */ /* ************************************************************************** */ -if (isset($attrname) && $attrname != '' && $action == 'edit') +if ($_GET["attrname"] && $_GET["action"] == 'edit') { print_titre("Edition du champ $attrname"); - print "
"; - print ''; - - print ''; - print ''; - print ''; - - print "
Libellé'.$adho->attribute_label[$attrname].' 
Nom de l\'attribut'.$attrname.' 
Type'.$adho->attribute_name[$attrname].' 
\n"; - + print '
'; /* * formulaire d'edition */ - print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print '
'; - print ''; - print ''; - list($type,$size)=preg_split('/\(|\)/',$adho->attribute_name[$attrname]); - print ''; + print ''; + list($type,$size)=preg_split('/\(|\)/',$adho->attribute_name[$_GET["attrname"]]); + print ''; // print ''; - print ''; - print ''; + print ''; + print ''; print '
Libellé
Nom de l\'attribut'.$attrname.' 
Type (non pris en compte)'; + print '
Libellé
Nom de l\'attribut'.$_GET["attrname"].' 
Type'; $form->select_array('type',array('varchar'=>'chaine', 'text'=>'texte', - 'integer'=>'entier', + 'int'=>'entier', 'date'=>'date', 'datetime'=>'date et heure'),$type); print '
Type (non pris en compte)
taille
Taille
  '; + print '
'; print "
"; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index f4efbf4563f..c0ae6e57c1b 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -1,6 +1,7 @@ - * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2003 Jean-Louis Bergamo + * 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 @@ -26,45 +27,43 @@ require(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); if ($_POST["action"] == 'add' && $user->admin) { + if ($_POST["button"] != "Annuler") { + $adht = new AdherentType($db); + + $adht->libelle = $_POST["libelle"]; + $adht->cotisation = $_POST["cotisation"]; + $adht->commentaire = $_POST["comment"]; + $adht->mail_valid = $_POST["mail_valid"]; + $adht->vote = $_POST["vote"]; - $adht = new AdherentType($db); - - $adht->libelle = $_POST["libelle"]; - $adht->cotisation = $_POST["cotisation"]; - $adht->commentaire = $_POST["comment"]; - $adht->mail_valid = $_POST["mail_valid"]; - $adht->vote = $_POST["vote"]; - - if ($adht->create($user->id) ) - { - Header("Location: type.php"); + if ($_POST["libelle"]) { $adht->create($user->id); } } + Header("Location: type.php"); } if ($_POST["action"] == 'update' && $user->admin) { - - $adht = new AdherentType($db); - $adht->id = $rowid; - $adht->libelle = $_POST["libelle"]; - $adht->cotisation = $_POST["cotisation"]; - $adht->commentaire = $_POST["comment"]; - $adht->mail_valid = $_POST["mail_valid"]; - $adht->vote = $_POST["vote"]; - - if ($adht->update($user->id) ) - { - Header("Location: type.php"); - } + if ($_POST["button"] != "Annuler") { + $adht = new AdherentType($db); + $adht->id = $_POST["rowid"];; + $adht->libelle = $_POST["libelle"]; + $adht->cotisation = $_POST["cotisation"]; + $adht->commentaire = $_POST["comment"]; + $adht->mail_valid = $_POST["mail_valid"]; + $adht->vote = $_POST["vote"]; + + $adht->update($user->id); + } + Header("Location: type.php"); } -if ($action == 'delete') +if ($_GET["action"] == 'delete') { $adh = new Adherent($db); $adh->delete($rowid); Header("Location: liste.php"); } -if ($action == 'commentaire') +if ($_GET["action"] == 'commentaire') { $don = new Don($db); $don->set_commentaire($rowid,$_POST["commentaire"]); @@ -75,7 +74,8 @@ if ($action == 'commentaire') llxHeader(); -print_titre("Configuration"); +print_titre("Configuration des types d'adhérents"); +print '
'; /* ************************************************************************** */ /* */ @@ -92,24 +92,24 @@ if ($result) $num = $db->num_rows(); $i = 0; - print ""; + print "
"; - print ''; + print ''; print ""; print ""; - print "\n"; + print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; - print ""; - print "\n"; - print ''; - print ''; - print ''; - print ''; + print ""; + print "\n"; + print ''; + print ''; + print ''; + print ''; print ""; $i++; } @@ -140,28 +140,13 @@ else /* ************************************************************************** */ -if ($action == 'create') { +if ($_GET["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("Nouveau type"); + print '
'; + print ""; - print '
IdLibelléCotisation ?Vote ? 
".$objp->rowid."'.$objp->libelle.''.$objp->cotisation.''.$objp->vote.'Editer
".$objp->rowid."'.$objp->libelle.''.$objp->cotisation.''.$objp->vote.''.img_edit().'
'; + print '
'; print ''; @@ -183,7 +168,9 @@ if ($action == 'create') { print '"; - print ''; + print ''; + print "\n"; print "
Mail d\'accueil :'; print "
 '; + print '
\n"; @@ -194,41 +181,22 @@ if ($action == 'create') { /* Edition de la fiche */ /* */ /* ************************************************************************** */ -if ($rowid > 0 && $action == 'edit') +if ($_GET["rowid"] > 0 && $_GET["action"] == 'edit') { $adht = new AdherentType($db); - $adht->id = $rowid; - $adht->fetch($rowid); + $adht->id = $_GET["rowid"]; + $adht->fetch($_GET["rowid"]); print_titre("Edition de la fiche"); - print "
"; - print ''; - - print ''; - print ''; - - print ''; - - print ''; - print ''; - - print ''; - - print ''; - - print "
Libellé'.$adht->libelle.' 
Soumis à cotisation'.$adht->cotisation.' 
Droit de vote'.$adht->vote.' 
Commentaires'; - print nl2br($adht->commentaire).' 
Mail d\'accueil'; - print nl2br($adht->mail_valid).' 
\n"; - + print '
'; /* - * * * */ - print ''; - print ''; + print ''; + print ''; print ''; print ''; @@ -251,7 +219,9 @@ if ($rowid > 0 && $action == 'edit') print '"; - print ''; + print ''; + print '
Mail d\'accueil :'; print "
 '; + print '
'; print "
";