2004-10-19 20:58:50 +02:00
< ? php
2004-07-30 12:13:11 +02:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2004-06-26 20:23:03 +02:00
* Copyright ( C ) 2002 - 2003 Jean - Louis Bergamo < jlb @ j1b . org >
* Copyright ( C ) 2004 Laurent Destailleur < eldy @ users . sourceforge . net >
2003-01-15 01:03:47 +01:00
*
2002-12-28 19:12:22 +01:00
* 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 $
*
*/
2004-08-14 14:37:59 +02:00
/*! \file htdocs / adherents / fiche . php
\ingroup adherent
\brief Page d 'ajout, edition, suppression d' une fiche adh<EFBFBD> rent
\version $Revision $
*/
2003-09-01 00:05:54 +02:00
require ( " ./pre.inc.php " );
2004-07-17 01:35:53 +02:00
2004-07-31 15:34:32 +02:00
$langs -> load ( " companies " );
2004-09-25 13:02:10 +02:00
$langs -> load ( " bills " );
2004-07-31 15:34:32 +02:00
2005-01-12 21:22:20 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /adherents/adherent.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /adherents/adherent_type.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /adherents/adherent_options.class.php " );
require_once ( DOL_DOCUMENT_ROOT . " /adherents/XML-RPC.functions.php " );
require_once ( DOL_DOCUMENT_ROOT . " /compta/bank/account.class.php " );
2002-12-28 19:12:22 +01:00
2003-02-19 18:47:22 +01:00
$adho = new AdherentOptions ( $db );
2003-03-05 18:22:02 +01:00
$errmsg = '' ;
2002-12-28 19:12:22 +01:00
2004-07-17 01:35:53 +02:00
$action = isset ( $_GET [ " action " ]) ? $_GET [ " action " ] : $_POST [ " action " ];
2004-07-17 14:41:15 +02:00
$rowid = isset ( $_GET [ " rowid " ]) ? $_GET [ " rowid " ] : $_POST [ " rowid " ];
2004-07-17 01:35:53 +02:00
if ( $_POST [ " action " ] == 'sendinfo' )
2003-09-03 17:21:06 +02:00
{
2004-07-17 01:35:53 +02:00
$adh = new Adherent ( $db );
$adh -> id = $rowid ;
$adh -> fetch ( $rowid );
$adh -> send_an_email ( $adh -> email , " Voici le contenu de votre fiche \n \n %INFOS% \n \n " , " Contenu de votre fiche adherent " );
2003-09-03 17:21:06 +02:00
}
2004-07-17 01:35:53 +02:00
if ( $_POST [ " action " ] == 'cotisation' )
2002-12-28 19:12:22 +01:00
{
2004-07-17 01:35:53 +02:00
$adh = new Adherent ( $db );
$adh -> id = $rowid ;
$adh -> fetch ( $rowid );
if ( $cotisation >= 0 )
{
// 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 ){
$dateop = strftime ( " %Y%m%d " , time ());
//$dateop="$reyear$remonth$reday";
$amount = $cotisation ;
$acct = new Account ( $db , ADHERENT_BANK_ACCOUNT );
2004-11-18 00:15:40 +01:00
$insertid = $acct -> addline ( $dateop , $_POST [ " operation " ], $_POST [ " label " ], $amount , $_POST [ " num_chq " ], ADHERENT_BANK_CATEGORIE , $user );
2004-07-17 01:35:53 +02:00
if ( $insertid == '' )
{
2004-11-12 15:37:38 +01:00
dolibarr_print_error ( $db );
2004-07-17 01:35:53 +02:00
}
else
{
// met a jour la table cotisation
$sql = " UPDATE " . MAIN_DB_PREFIX . " cotisation SET fk_bank= $insertid WHERE rowid= $crowid " ;
$result = $db -> query ( $sql );
if ( $result )
{
2004-07-30 12:13:11 +02:00
//Header("Location: fiche.php");
2004-07-17 01:35:53 +02:00
}
else
{
2004-11-12 15:37:38 +01:00
dolibarr_print_error ( $db );
2004-07-17 01:35:53 +02:00
}
}
}
}
$action = " edit " ;
2002-12-28 19:12:22 +01:00
}
2002-12-30 16:13:28 +01:00
2004-07-17 01:35:53 +02:00
if ( $_POST [ " action " ] == 'add' )
2002-12-28 19:12:22 +01:00
{
2004-07-17 01:35:53 +02:00
$type = $_POST [ " type " ];
2004-07-17 14:41:15 +02:00
$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<61> tres
2004-07-17 01:35:53 +02:00
if ( ! isset ( $type ) || $type == '' ){
$error += 1 ;
$errmsg .= " Le type d'adh<64> rent n'est pas renseign<67> . Vous devez configurer les types d'adh<64> rents avant de pouvoir les ajouter.<br> \n " ;
}
2004-07-17 14:41:15 +02:00
// Test si le login existe deja
2004-07-17 01:35:53 +02:00
if ( ! isset ( $login ) || $login == '' ){
$error += 1 ;
$errmsg .= " Login vide. Veuillez en positionner un<br> \n " ;
}
$sql = " SELECT login FROM " . MAIN_DB_PREFIX . " adherent WHERE login=' $login '; " ;
$result = $db -> query ( $sql );
if ( $result ) {
$num = $db -> num_rows ();
}
2004-11-12 15:37:38 +01:00
if ( ! isset ( $nom ) || ! isset ( $prenom ) || $prenom == '' || $nom == '' ) {
2004-07-17 01:35:53 +02:00
$error += 1 ;
2004-11-12 15:37:38 +01:00
$errmsg .= " Nom et Pr<50> nom obligatoires<br> \n " ;
2004-07-17 01:35:53 +02:00
}
2004-11-12 15:37:38 +01:00
if ( ADHERENT_MAIL_REQUIRED && ADHERENT_MAIL_REQUIRED == 1 && ! ValidEMail ( $email )) {
2004-07-17 01:35:53 +02:00
$error += 1 ;
$errmsg .= " Adresse Email invalide<br> \n " ;
}
2004-11-12 15:37:38 +01:00
if ( $num != 0 ) {
2004-07-17 01:35:53 +02:00
$error += 1 ;
2004-11-12 15:37:38 +01:00
$errmsg .= " Login deja utilise. Veuillez en changer<br> \n " ;
2004-07-17 01:35:53 +02:00
}
2004-11-12 15:37:38 +01:00
if ( ! isset ( $pass ) || $pass == '' ) {
2004-07-17 01:35:53 +02:00
$error += 1 ;
$errmsg .= " Password invalide<br> \n " ;
}
if ( isset ( $naiss ) && $naiss != '' ){
2004-11-12 15:37:38 +01:00
if ( ! preg_match ( " /^ \ d \ d \ d \ d- \ d \ d- \ d \ d $ / " , $naiss )) {
2004-07-17 01:35:53 +02:00
$error += 1 ;
$errmsg .= " Date de naissance invalide (Format AAAA-MM-JJ)<br> \n " ;
}
}
2004-11-12 15:37:38 +01:00
if ( isset ( $public )) {
2004-07-17 01:35:53 +02:00
$public = 1 ;
2004-11-12 15:37:38 +01:00
} else {
2004-07-17 14:41:15 +02:00
$public = 0 ;
2004-07-17 01:35:53 +02:00
}
2004-11-12 15:37:38 +01:00
if ( ! $error ) {
2004-09-25 13:02:10 +02:00
// Email a peu pres correct et le login n'existe pas
2004-11-12 15:37:38 +01:00
if ( $adh -> create ( $user -> id ))
2004-07-17 01:35:53 +02:00
{
if ( $cotisation > 0 )
{
$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 ){
$dateop = strftime ( " %Y%m%d " , time ());
//$dateop="$reyear$remonth$reday";
$amount = $cotisation ;
$acct = new Account ( $db , ADHERENT_BANK_ACCOUNT );
$insertid = $acct -> addline ( $dateop , $_POST [ " operation " ], $_POST [ " label " ], $amount , $_POST [ " num_chq " ], ADHERENT_BANK_CATEGORIE );
if ( $insertid == '' )
{
2004-09-25 13:02:10 +02:00
dolibarr_print_error ( $db );
2004-07-17 01:35:53 +02:00
}
else
{
// met a jour la table cotisation
$sql = " UPDATE " . MAIN_DB_PREFIX . " cotisation SET fk_bank= $insertid WHERE rowid= $crowid " ;
$result = $db -> query ( $sql );
if ( $result )
{
2004-07-30 12:13:11 +02:00
//Header("Location: fiche.php");
2004-07-17 01:35:53 +02:00
}
else
{
2004-09-25 13:02:10 +02:00
dolibarr_print_error ( $db );
2004-07-17 01:35:53 +02:00
}
}
}
}
2004-07-17 14:41:15 +02:00
Header ( " Location: liste.php?statut=-1 " );
2004-07-17 01:35:53 +02:00
}
2004-09-25 13:02:10 +02:00
else {
dolibarr_print_error ( $db );
}
2004-07-17 01:35:53 +02:00
}
2002-12-28 19:12:22 +01:00
}
2002-12-30 16:13:28 +01:00
2004-06-26 20:23:03 +02:00
if ( $_POST [ " action " ] == 'confirm_delete' && $_POST [ " confirm " ] == yes )
2002-12-28 19:12:22 +01:00
{
2004-07-17 01:35:53 +02:00
$adh = new Adherent ( $db );
$adh -> delete ( $rowid );
Header ( " Location: liste.php " );
2002-12-28 19:12:22 +01:00
}
2004-07-17 14:41:15 +02:00
llxHeader ();
2004-06-26 20:23:03 +02:00
if ( $_POST [ " action " ] == 'confirm_valid' && $_POST [ " confirm " ] == yes )
2002-12-30 17:29:21 +01:00
{
2004-07-17 01:35:53 +02:00
$adh = new Adherent ( $db , $rowid );
$adh -> validate ( $user -> id );
$adh -> fetch ( $rowid );
2003-03-04 16:23:13 +01:00
2004-07-17 01:35:53 +02:00
$adht = new AdherentType ( $db );
$adht -> fetch ( $adh -> typeid );
2003-03-04 16:23:13 +01:00
2004-07-17 01:35:53 +02:00
if ( isset ( $adht -> mail_valid ) && $adht -> mail_valid != '' )
2003-03-04 16:23:13 +01:00
{
2004-07-17 01:35:53 +02:00
$adh -> send_an_email ( $adh -> email , $adht -> mail_valid , $conf -> adherent -> email_valid_subject );
2003-03-04 16:23:13 +01:00
}
2004-07-17 01:35:53 +02:00
else
2003-03-04 16:23:13 +01:00
{
2004-07-17 01:35:53 +02:00
$adh -> send_an_email ( $adh -> email , $conf -> adherent -> email_valid , $conf -> adherent -> email_valid_subject );
2003-03-04 16:23:13 +01:00
}
2004-07-17 01:35:53 +02:00
// rajoute l'utilisateur dans les divers abonnements ..
if ( ! $adh -> add_to_abo ( $adht ))
2003-03-05 18:22:02 +01:00
{
2004-07-17 01:35:53 +02:00
// error
$errmsg .= " echec du rajout de l'utilisateur aux abonnements: " . $adh -> errostr . " <BR> \n " ;
2003-03-05 18:22:02 +01:00
}
2004-07-17 01:35:53 +02:00
2002-12-30 17:29:21 +01:00
}
2004-06-26 20:23:03 +02:00
if ( $_POST [ " action " ] == 'confirm_resign' && $_POST [ " confirm " ] == yes )
2002-12-30 22:07:11 +01:00
{
2004-07-17 01:35:53 +02:00
$adh = new Adherent ( $db , $rowid );
$adh -> resiliate ( $user -> id );
$adh -> fetch ( $rowid );
2003-03-04 16:23:13 +01:00
2004-07-17 01:35:53 +02:00
$adht = new AdherentType ( $db );
$adht -> fetch ( $adh -> typeid );
2003-03-07 19:53:17 +01:00
2004-07-17 01:35:53 +02:00
$adh -> send_an_email ( $adh -> email , $conf -> adherent -> email_resil , $conf -> adherent -> email_resil_subject );
2003-03-04 16:23:13 +01:00
2004-07-17 01:35:53 +02:00
// supprime l'utilisateur des divers abonnements ..
if ( ! $adh -> del_to_abo ( $adht ))
2003-03-05 18:22:02 +01:00
{
2004-07-17 01:35:53 +02:00
// error
$errmsg .= " echec de la suppression de l'utilisateur aux abonnements: " . $adh -> errostr . " <BR> \n " ;
2003-03-05 18:22:02 +01:00
}
2002-12-30 22:07:11 +01:00
}
2004-06-26 20:23:03 +02:00
if ( $_POST [ " action " ] == 'confirm_add_glasnost' && $_POST [ " confirm " ] == yes )
2003-03-06 20:33:23 +01:00
{
2004-07-17 01:35:53 +02:00
$adh = new Adherent ( $db , $rowid );
$adh -> fetch ( $rowid );
$adht = new AdherentType ( $db );
$adht -> fetch ( $adh -> typeid );
if ( $adht -> vote == 'yes' ){
define ( " XMLRPC_DEBUG " , 1 );
if ( ! $adh -> add_to_glasnost ()){
$errmsg .= " Echec du rajout de l'utilisateur dans glasnost: " . $adh -> errostr . " <BR> \n " ;
}
if ( defined ( 'MAIN_DEBUG' ) && MAIN_DEBUG == 1 ){
XMLRPC_debug_print ();
}
}
2003-03-06 20:33:23 +01:00
}
2004-06-26 20:23:03 +02:00
if ( $_POST [ " action " ] == 'confirm_del_glasnost' && $_POST [ " confirm " ] == yes )
2003-03-06 20:33:23 +01:00
{
2004-07-17 01:35:53 +02:00
$adh = new Adherent ( $db , $rowid );
$adh -> fetch ( $rowid );
$adht = new AdherentType ( $db );
$adht -> fetch ( $adh -> typeid );
if ( $adht -> vote == 'yes' ){
define ( " XMLRPC_DEBUG " , 1 );
if ( ! $adh -> del_to_glasnost ()){
$errmsg .= " Echec de la suppression de l'utilisateur dans glasnost: " . $adh -> errostr . " <BR> \n " ;
}
if ( defined ( 'MAIN_DEBUG' ) && MAIN_DEBUG == 1 ){
XMLRPC_debug_print ();
}
}
2003-03-06 20:33:23 +01:00
}
2003-03-07 19:53:17 +01:00
2004-06-26 20:23:03 +02:00
if ( $_POST [ " action " ] == 'confirm_del_spip' && $_POST [ " confirm " ] == yes )
2003-03-07 19:53:17 +01:00
{
2004-07-17 01:35:53 +02:00
$adh = new Adherent ( $db , $rowid );
$adh -> fetch ( $rowid );
if ( ! $adh -> del_to_spip ()){
$errmsg .= " Echec de la suppression de l'utilisateur dans spip: " . $adh -> errostr . " <BR> \n " ;
}
2003-03-07 19:53:17 +01:00
}
2004-06-26 20:23:03 +02:00
if ( $_POST [ " action " ] == 'confirm_add_spip' && $_POST [ " confirm " ] == yes )
2003-03-07 19:53:17 +01:00
{
2004-07-17 01:35:53 +02:00
$adh = new Adherent ( $db , $rowid );
$adh -> fetch ( $rowid );
if ( ! $adh -> add_to_spip ()){
$errmsg .= " Echec du rajout de l'utilisateur dans spip: " . $adh -> errostr . " <BR> \n " ;
}
2003-03-07 19:53:17 +01:00
}
2002-12-28 19:12:22 +01:00
/* ************************************************************************** */
/* */
2002-12-30 16:13:28 +01:00
/* Cr<43> ation d'une fiche */
2002-12-28 19:12:22 +01:00
/* */
/* ************************************************************************** */
2003-08-12 19:36:17 +02:00
if ( $errmsg != '' )
{
2004-11-12 15:37:38 +01:00
print '<table class="border" width="100%">' ;
2004-07-17 01:35:53 +02:00
print '<th>Erreur dans l\'execution du formulaire</th>' ;
print " <tr><td class= \" error \" ><b> $errmsg </b></td></tr> \n " ;
print '</table>' ;
2003-03-05 18:22:02 +01:00
}
2002-12-28 19:12:22 +01:00
2003-02-19 18:47:22 +01:00
// fetch optionals attributes and labels
$adho -> fetch_optionals ();
2002-12-28 19:12:22 +01:00
if ( $action == 'create' ) {
2004-11-12 15:37:38 +01:00
print_titre ( $langs -> trans ( " NewMember " ));
2004-07-30 12:13:11 +02:00
print " <form action= \" fiche.php \" method= \" post \" > \n " ;
2004-11-12 15:37:38 +01:00
print '<table class="border" width="100%">' ;
2004-07-17 01:35:53 +02:00
print '<input type="hidden" name="action" value="add">' ;
$htmls = new Form ( $db );
$adht = new AdherentType ( $db );
2004-08-29 21:03:50 +02:00
print '<tr><td width="15%">' . $langs -> trans ( " Type " ) . '</td><td width="35%">' ;
2004-07-17 01:35:53 +02:00
$htmls -> select_array ( " type " , $adht -> liste_array ());
print " </td> \n " ;
2004-08-29 21:03:50 +02:00
print '<td width="50%" valign="top">' . $langs -> trans ( " Comments " ) . ' :</td></tr>' ;
2004-07-17 01:35:53 +02:00
$morphys [ " phy " ] = " Physique " ;
$morphys [ " mor " ] = " Morale " ;
print " <tr><td>Personne</td><td> \n " ;
$htmls -> select_array ( " morphy " , $morphys );
print " </td> \n " ;
print '<td valign="top" rowspan="13"><textarea name="comment" wrap="soft" cols="40" rows="25"></textarea></td></tr>' ;
2004-11-12 15:37:38 +01:00
print '<tr><td>' . $langs -> trans ( " Firstname " ) . '*</td><td><input type="text" name="prenom" size="40"></td></tr>' ;
2004-12-10 20:57:46 +01:00
print '<tr><td>' . $langs -> trans ( " Lastname " ) . '*</td><td><input type="text" name="nom" size="40"></td></tr>' ;
2004-09-25 13:02:10 +02:00
print '<tr><td>' . $langs -> trans ( " Company " ) . '</td><td><input type="text" name="societe" size="40"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Address " ) . '</td><td>' ;
2004-07-17 01:35:53 +02:00
print '<textarea name="adresse" wrap="soft" cols="40" rows="3"></textarea></td></tr>' ;
2004-09-25 13:02:10 +02:00
print '<tr><td>' . $langs -> trans ( " Zip " ) . ' / ' . $langs -> trans ( " Town " ) . '</td><td><input type="text" name="cp" size="8"> <input type="text" name="ville" size="40"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Country " ) . '</td><td><input type="text" name="pays" size="40"></td></tr>' ;
2004-11-12 15:37:38 +01:00
print '<tr><td>' . $langs -> trans ( " EMail " ) . ( ADHERENT_MAIL_REQUIRED && ADHERENT_MAIL_REQUIRED == 1 ? '*' : '' ) . '</td><td><input type="text" name="email" size="40"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Login " ) . '*</td><td><input type="text" name="login" size="40"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Password " ) . '*</td><td><input type="password" name="pass" size="40"></td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Birthday " ) . '<br>(AAAA-MM-JJ)</td><td><input type="text" name="naiss" size="10"></td></tr>' ;
2004-07-17 01:35:53 +02:00
print '<tr><td>Url photo</td><td><input type="text" name="photo" size="40"></td></tr>' ;
foreach ( $adho -> attribute_label as $key => $value ){
print " <tr><td> $value </td><td><input type= \" text \" name= \" options_ $key\ " size = \ " 40 \" ></td></tr> \n " ;
}
print " <tr><td>Date de cotisation</td><td> \n " ;
print_date_select ();
print " </td></tr> \n " ;
2004-09-25 13:02:10 +02:00
print '<tr><td>Mode de paiment</td><td>' ;
2004-07-17 01:35:53 +02:00
print '<select name="operation">' ;
2004-09-25 13:02:10 +02:00
print '<option value="CHQ" selected>Ch<43> que' ;
2004-07-17 01:35:53 +02:00
print '<option value="CB">Carte Bleue' ;
print '<option value="DEP">Espece' ;
print '<option value="TIP">TIP' ;
print '<option value="PRE">PRE' ;
print '<option value="VIR">Virement' ;
print '</select>' ;
// $paiement = new Paiement($db);
// $paiement->select("modepaiement","cr<63> dit");
2003-09-05 16:11:38 +02:00
print " </td></tr> \n " ;
2004-07-17 01:35:53 +02:00
if ( defined ( " ADHERENT_BANK_USE " ) && ADHERENT_BANK_USE != 0 &&
defined ( " ADHERENT_BANK_USE_AUTO " ) && ADHERENT_BANK_USE_AUTO != 0 ){
print " <tr><td>Numero de cheque</td><td> \n " ;
print '<input name="num_chq" type="text" size="6">' ;
print " </td></tr> \n " ;
}
print '<tr><td>Cotisation</td><td><input type="text" name="cotisation" size="6"> euros</td></tr>' ;
if ( defined ( " ADHERENT_BANK_USE " ) && ADHERENT_BANK_USE != 0 && defined ( " ADHERENT_BANK_USE_AUTO " ) && ADHERENT_BANK_USE_AUTO != 0 ){
2004-09-25 13:02:10 +02:00
print '<tr><td>' . $langs -> trans ( " Label " ) . '</td><td><input name="label" type="text" size=20 value="Cotisation " ></td></tr>' ;
2004-07-17 01:35:53 +02:00
}
2004-07-31 15:34:32 +02:00
print '<tr><td colspan="2" align="center"><input type="submit" value="' . $langs -> trans ( " Add " ) . '"></td></tr>' ;
2004-07-17 01:35:53 +02:00
print " </form> \n " ;
print " </table> \n " ;
}
2002-12-28 19:12:22 +01:00
/* ************************************************************************** */
/* */
2002-12-30 16:13:28 +01:00
/* Edition de la fiche */
2002-12-28 19:12:22 +01:00
/* */
/* ************************************************************************** */
2002-12-30 16:13:28 +01:00
if ( $rowid > 0 )
2002-12-28 19:12:22 +01:00
{
2004-07-17 01:35:53 +02:00
$adh = new Adherent ( $db );
$adh -> id = $rowid ;
$adh -> fetch ( $rowid );
$adh -> fetch_optionals ( $rowid );
2002-12-28 19:12:22 +01:00
2004-07-17 01:35:53 +02:00
$adht = new AdherentType ( $db );
$adht -> fetch ( $adh -> typeid );
2002-12-28 19:12:22 +01:00
2004-07-17 01:35:53 +02:00
$html = new Form ( $db );
2002-12-28 19:12:22 +01:00
2004-07-17 01:35:53 +02:00
/*
* Affichage onglets
*/
$h = 0 ;
2003-01-10 16:18:06 +01:00
2004-07-17 01:35:53 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/adherents/fiche.php?rowid=' . $rowid ;
2004-11-12 15:37:38 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Member " );
2004-07-17 01:35:53 +02:00
$hselected = $h ;
$h ++ ;
2003-01-10 16:18:06 +01:00
2004-07-17 01:35:53 +02:00
dolibarr_fiche_head ( $head , $hselected , $societe -> nom );
2003-01-10 16:18:06 +01:00
2004-07-17 01:35:53 +02:00
/*
* Confirmation de la suppression de l ' adh<EFBFBD> rent
*/
if ( $action == 'delete' )
2003-01-10 16:18:06 +01:00
{
2004-07-30 12:13:11 +02:00
$html -> form_confirm ( " fiche.php?rowid= $rowid " , " Supprimer un adh<64> rent " , " Etes-vous s<> r de vouloir supprimer cet adh<64> rent (La suppression d'un adh<64> rent entraine la suppression de toutes ses cotisations !) " , " confirm_delete " );
2004-07-17 01:35:53 +02:00
}
2003-01-10 16:18:06 +01:00
2004-07-17 01:35:53 +02:00
/*
* Confirmation de la validation
*/
if ( $action == 'valid' )
2003-03-06 20:33:23 +01:00
{
2004-07-30 12:13:11 +02:00
$html -> form_confirm ( " fiche.php?rowid= $rowid " , " Valider un adh<64> rent " , " Etes-vous s<> r de vouloir valider cet adh<64> rent ? " , " confirm_valid " );
2004-07-17 01:35:53 +02:00
}
2003-03-06 20:33:23 +01:00
2004-07-17 01:35:53 +02:00
/*
* Confirmation de la R<EFBFBD> siliation
*/
if ( $action == 'resign' )
2003-03-06 20:33:23 +01:00
{
2004-07-30 12:13:11 +02:00
$html -> form_confirm ( " fiche.php?rowid= $rowid " , " R<EFBFBD> silier une adh<64> sion " , " Etes-vous s<> r de vouloir r<> silier cet adh<64> rent ? " , " confirm_resign " );
2004-07-17 01:35:53 +02:00
}
2003-03-06 20:33:23 +01:00
2004-07-17 01:35:53 +02:00
/*
* Confirmation de l ' ajout dans glasnost
*/
if ( $action == 'add_glasnost' )
2003-03-07 19:53:17 +01:00
{
2004-07-30 12:13:11 +02:00
$html -> form_confirm ( " fiche.php?rowid= $rowid " , " Ajouter dans glasnost " , " Etes-vous sur de vouloir ajouter cet adh<64> rent dans glasnost ? (serveur : " . ADHERENT_GLASNOST_SERVEUR . " ) " , " confirm_add_glasnost " );
2004-07-17 01:35:53 +02:00
}
2003-03-07 19:53:17 +01:00
2004-07-17 01:35:53 +02:00
/*
* Confirmation de la suppression dans glasnost
*/
if ( $action == 'del_glasnost' )
2003-03-07 19:53:17 +01:00
{
2004-07-30 12:13:11 +02:00
$html -> form_confirm ( " fiche.php?rowid= $rowid " , " Supprimer dans glasnost " , " Etes-vous sur de vouloir effacer cet adh<64> rent dans glasnost ? (serveur : " . ADHERENT_GLASNOST_SERVEUR . " ) " , " confirm_del_glasnost " );
2004-07-17 01:35:53 +02:00
}
2003-03-07 19:53:17 +01:00
2004-07-17 01:35:53 +02:00
/*
* Confirmation de l ' ajout dans spip
*/
if ( $action == 'add_spip' )
{
2004-07-30 12:13:11 +02:00
$html -> form_confirm ( " fiche.php?rowid= $rowid " , " Ajouter dans spip " , " Etes-vous sur de vouloir ajouter cet adh<64> rent dans spip ? (serveur : " . ADHERENT_SPIP_SERVEUR . " ) " , " confirm_add_spip " );
2003-03-06 20:33:23 +01:00
}
2002-12-28 19:12:22 +01:00
2004-07-17 01:35:53 +02:00
/*
* Confirmation de la suppression dans spip
*/
if ( $action == 'del_spip' )
{
2004-07-30 12:13:11 +02:00
$html -> form_confirm ( " fiche.php?rowid= $rowid " , " Supprimer dans spip " , " Etes-vous sur de vouloir effacer cet adh<64> 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<64> rent dans glasnost ? (serveur : " . ADHERENT_GLASNOST_SERVEUR . " ) " , " confirm_del_spip " );
2004-07-17 01:35:53 +02:00
}
2002-12-30 17:29:21 +01:00
2002-12-28 19:12:22 +01:00
2004-07-30 12:13:11 +02:00
print " <form action= \" fiche.php \" method= \" post \" > \n " ;
2004-09-25 13:02:10 +02:00
print '<table class="border" width="100%">' ;
2002-12-30 17:29:21 +01:00
2004-11-12 15:37:38 +01:00
print '<tr><td>' . $langs -> trans ( " Ref " ) . '</td><td class="valeur">' . $adh -> id . ' </td>' ;
2004-08-29 21:03:50 +02:00
print '<td valign="top" width="50%">' . $langs -> trans ( " Comments " ) . '</tr>' ;
2003-01-10 16:18:06 +01:00
2004-11-12 15:37:38 +01:00
print '<tr><td>' . $langs -> trans ( " Type " ) . '*</td><td class="valeur">' . $adh -> type . " </td> \n " ;
2003-03-07 19:53:17 +01:00
2004-07-17 01:35:53 +02:00
print '<td rowspan="' . ( 13 + count ( $adh -> array_options )) . '" valign="top" width="50%">' ;
print nl2br ( $adh -> commentaire ) . ' </td></tr>' ;
2003-03-07 19:53:17 +01:00
2004-07-17 01:35:53 +02:00
print '<tr><td>Personne</td><td class="valeur">' . $adh -> getmorphylib () . ' </td></tr>' ;
2003-03-07 19:53:17 +01:00
2004-11-12 15:37:38 +01:00
print '<tr><td width="15%">' . $langs -> trans ( " Firstname " ) . '*</td><td class="valeur" width="35%">' . $adh -> prenom . ' </td></tr>' ;
2003-01-10 16:18:06 +01:00
2004-12-10 20:57:46 +01:00
print '<tr><td>' . $langs -> trans ( " Lastname " ) . '*</td><td class="valeur">' . $adh -> nom . ' </td></tr>' ;
2002-12-30 17:29:21 +01:00
2004-09-25 13:02:10 +02:00
print '<tr><td>' . $langs -> trans ( " Company " ) . '</td><td class="valeur">' . $adh -> societe . ' </td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Address " ) . '</td><td class="valeur">' . nl2br ( $adh -> adresse ) . ' </td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Zip " ) . ' / ' . $langs -> trans ( " Town " ) . '</td><td class="valeur">' . $adh -> cp . ' ' . $adh -> ville . ' </td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Country " ) . '</td><td class="valeur">' . $adh -> pays . ' </td></tr>' ;
2004-11-12 15:37:38 +01:00
print '<tr><td>' . $langs -> trans ( " EMail " ) . ( ADHERENT_MAIL_REQUIRED && ADHERENT_MAIL_REQUIRED == 1 ? '*' : '' ) . '</td><td class="valeur">' . $adh -> email . ' </td></tr>' ;
print '<tr><td>' . $langs -> trans ( " Login " ) . '*</td><td class="valeur">' . $adh -> login . ' </td></tr>' ;
2004-07-17 01:35:53 +02:00
// print '<tr><td>Pass</td><td class="valeur">'.$adh->pass.' </td></tr>';
2004-11-12 15:37:38 +01:00
print '<tr><td>' . $langs -> trans ( " Birthday " ) . '</td><td class="valeur">' . $adh -> naiss . ' </td></tr>' ;
2004-07-17 01:35:53 +02:00
print '<tr><td>URL Photo</td><td class="valeur">' . $adh -> photo . ' </td></tr>' ;
print '<tr><td>Public ?</td><td class="valeur">' ;
if ( $adh -> public == 1 ){
print 'Yes' ;
} else {
2003-01-28 18:34:15 +01:00
print " No " ;
2004-07-17 01:35:53 +02:00
}
print ' </td></tr>' ;
2002-12-28 19:12:22 +01:00
2004-07-17 01:35:53 +02:00
foreach ( $adho -> attribute_label as $key => $value ){
2003-02-19 18:47:22 +01:00
print " <tr><td> $value </td><td> " . $adh -> array_options [ " options_ $key " ] . " </td></tr> \n " ;
2004-07-17 01:35:53 +02:00
}
2002-12-28 19:12:22 +01:00
2004-07-17 01:35:53 +02:00
print " </table> \n " ;
2004-11-12 15:37:38 +01:00
print " <br> " ;
2004-07-17 01:35:53 +02:00
print " </div> \n " ;
2004-11-12 15:37:38 +01:00
2004-07-17 01:35:53 +02:00
/*
* Barre d ' actions
*
*/
print '<div class="tabsAction">' ;
2004-11-12 15:37:38 +01:00
print " <a class= \" tabAction \" href= \" edit.php?rowid= $rowid\ " > " . $langs->trans ( " Edit " ). " </ a > " ;
2004-07-17 01:35:53 +02:00
2004-11-12 15:37:38 +01:00
if ( $adh -> statut < 1 )
{
print " <a class= \" tabAction \" href= \" fiche.php?rowid= $rowid &action=valid \" >Valider l'adh<64> sion</a> \n " ;
}
2004-07-17 01:35:53 +02:00
2004-11-12 15:37:38 +01:00
if ( $adh -> statut == 1 )
{
print " <a class= \" tabAction \" href= \" fiche.php?rowid= $rowid &action=resign \" >R<> silier l'adh<64> sion</a> \n " ;
}
2004-07-17 01:35:53 +02:00
2004-11-12 15:37:38 +01:00
print " <a class= \" tabAction \" href= \" fiche.php?rowid= $adh->id &action=delete \" > " . $langs -> trans ( " Delete " ) . " </a> \n " ;
2004-07-17 01:35:53 +02:00
2004-11-12 15:37:38 +01:00
// Envoi fiche par mail
print " <a class= \" tabAction \" href= \" fiche.php?rowid= $adh->id &action=sendinfo \" >Envoyer sa fiche a l'adh<64> rent</a> \n " ;
2004-07-17 01:35:53 +02:00
2004-11-12 15:37:38 +01:00
// Action Glasnost
if ( $adht -> vote == 'yes' && defined ( " ADHERENT_USE_GLASNOST " ) && ADHERENT_USE_GLASNOST == 1 )
{
define ( " XMLRPC_DEBUG " , 1 );
$isinglasnost = $adh -> is_in_glasnost ();
if ( $isinglasnost == 1 )
{
2004-07-30 12:13:11 +02:00
print " <a class= \" tabAction \" href= \" fiche.php?rowid= $adh->id &action=del_glasnost \" >Suppression dans Glasnost</a> \n " ;
2004-07-17 01:35:53 +02:00
}
2004-11-12 15:37:38 +01:00
if ( $isinglasnost == 0 ) {
print " <a class= \" tabAction \" href= \" fiche.php?rowid= $adh->id &action=add_glasnost \" >Ajout dans Glasnost</a> \n " ;
}
if ( $isinglasnost == - 1 ) {
print '<br><font class="error">Failed to connect to SPIP: ' . $adh -> errorstr . '</font>' ;
}
}
2004-07-17 01:35:53 +02:00
2004-11-12 15:37:38 +01:00
// Action SPIP
if ( defined ( " ADHERENT_USE_SPIP " ) && ADHERENT_USE_SPIP == 1 )
{
$isinspip = $adh -> is_in_spip ();
if ( $isinspip == 1 )
{
print " <a class= \" tabAction \" href= \" fiche.php?rowid= $adh->id &action=del_spip \" >Suppression dans Spip</a> \n " ;
}
if ( $isinspip == 0 )
{
2004-07-30 12:13:11 +02:00
print " <a class= \" tabAction \" href= \" fiche.php?rowid= $adh->id &action=add_spip \" >Ajout dans Spip</a> \n " ;
2004-07-17 01:35:53 +02:00
}
2004-11-12 15:37:38 +01:00
if ( $isinspip == - 1 ) {
print '<br><font class="error">Failed to connect to SPIP: ' . $adh -> errorstr . '</font>' ;
}
2004-07-17 01:35:53 +02:00
}
print '</div>' ;
print " <br> \n " ;
/*
* Bandeau des cotisations
*
*/
2004-11-12 15:37:38 +01:00
print '<table class="border" width="100%">' ;
2004-07-17 01:35:53 +02:00
print '<tr>' ;
if ( defined ( " ADHERENT_BANK_USE " ) && ADHERENT_BANK_USE != 0 &&
defined ( " ADHERENT_BANK_USE_AUTO " ) && ADHERENT_BANK_USE_AUTO != 0 ){
print '<td rowspan="8" valign="top">' ;
} else {
print '<td rowspan="6" valign="top">' ;
}
/*
*
* Liste des cotisations
*
*/
$sql = " SELECT d.rowid, d.prenom, d.nom, d.societe, 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 AND d.rowid= $rowid " ;
$result = $db -> query ( $sql );
if ( $result )
{
$num = $db -> num_rows ();
$i = 0 ;
2004-11-12 15:37:38 +01:00
print " <table class= \" noborder \" width= \" 100% \" > \n " ;
2004-07-17 01:35:53 +02:00
print '<tr class="liste_titre">' ;
print " <td>Date cotisations</td> \n " ;
print " <td align= \" right \" >Montant</TD> \n " ;
print " </tr> \n " ;
$var = True ;
while ( $i < $num )
2002-12-28 19:12:22 +01:00
{
2004-10-23 18:55:07 +02:00
$objp = $db -> fetch_object ( $result );
2004-07-17 01:35:53 +02:00
$var =! $var ;
print " <tr $bc[$var] > " ;
print " <td> " . dolibarr_print_date ( $objp -> dateadh ) . " </td> \n " ;
print '<td align="right">' . price ( $objp -> cotisation ) . '</td>' ;
print " </tr> " ;
$i ++ ;
2002-12-28 19:12:22 +01:00
}
2004-07-17 01:35:53 +02:00
print " </table> " ;
}
else
{
print $sql ;
print $db -> error ();
}
2002-12-30 16:13:28 +01:00
2004-07-17 01:35:53 +02:00
print '</td>' ;
2003-01-15 01:03:47 +01:00
2004-07-17 01:35:53 +02:00
/*
* Ajout d ' une nouvelle cotis
*
*/
if ( $user -> admin )
{
print '<form method="post" action="fiche.php">' ;
print '<input type="hidden" name="action" value="cotisation">' ;
print '<input type="hidden" name="rowid" value="' . $rowid . '">' ;
print '<td width="15%">Fin adh<64> sion</td>' ;
if ( $adh -> datefin < time ())
{
print '<td width="35%">' ;
print dolibarr_print_date ( $adh -> datefin ) . " " . img_warning ();
}
else
2002-12-30 17:29:21 +01:00
{
2004-07-17 01:35:53 +02:00
print '<td width="35%">' ;
print dolibarr_print_date ( $adh -> datefin );
}
print '</td>' ;
print '</tr>' ;
print '<tr><td colspan="2">Nouvelle adh<64> sion</td></tr>' ;
print " <tr><td>Date de cotisation</td><td> \n " ;
if ( $adh -> datefin > 0 )
{
print_date_select ( $adh -> datefin + ( 3600 * 24 ));
}
else
{
print_date_select ();
}
print " </td></tr> " ;
print " <tr><td>Mode de paiement</td><td> \n " ;
print_type_paiement_select ( $db , 'operation' );
print " </td></tr> \n " ;
if ( defined ( " ADHERENT_BANK_USE " ) && ADHERENT_BANK_USE != 0 &&
defined ( " ADHERENT_BANK_USE_AUTO " ) && ADHERENT_BANK_USE_AUTO != 0 ){
print " <tr><td>Numero de cheque</td><td> \n " ;
print '<input name="num_chq" type="text" size="6">' ;
print " </td></tr> \n " ;
}
print '<tr><td>Cotisation</td><td colspan="2"><input type="text" name="cotisation" size="6"> euros</td></tr>' ;
if ( defined ( " ADHERENT_BANK_USE " ) && ADHERENT_BANK_USE != 0 &&
defined ( " ADHERENT_BANK_USE_AUTO " ) && ADHERENT_BANK_USE_AUTO != 0 ){
print '<tr><td>Libelle</td><td colspan="2"><input name="label" type="text" size=20 value="Cotisation ' . stripslashes ( $adh -> prenom ) . ' ' . stripslashes ( $adh -> nom ) . ' ' . strftime ( " %Y " , $adh -> datefin ) . '" ></td></tr>' ;
}
2004-08-29 18:11:37 +02:00
print '<tr><td colspan="2" align="center"><input type="submit" value="' . $langs -> trans ( " Save " ) . '"</td></tr>' ;
2004-07-17 01:35:53 +02:00
print " </form> \n " ;
}
print '</table>' ;
2003-01-15 01:03:47 +01:00
2002-12-28 19:12:22 +01:00
}
$db -> close ();
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>