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 >
2008-04-07 17:32:24 +02:00
* Copyright ( C ) 2004 - 2008 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 .
*/
2004-08-14 14:37:59 +02:00
2005-03-05 19:45:40 +01:00
/**
\file htdocs / adherents / fiche . php
2004-08-14 14:37:59 +02:00
\ingroup adherent
2007-12-26 11:09:30 +01:00
\brief Page d 'ajout, edition, suppression d' une fiche adherent
2008-01-25 18:40:07 +01:00
\version $Id $
2004-08-14 14:37:59 +02:00
*/
2003-09-01 00:05:54 +02:00
require ( " ./pre.inc.php " );
2006-11-20 02:13:13 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/member.lib.php " );
2008-01-11 11:25:26 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/company.lib.php " );
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 " );
2006-11-26 19:24:53 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /adherents/cotisation.class.php " );
2005-01-12 21:22:20 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /compta/bank/account.class.php " );
2002-12-28 19:12:22 +01:00
2005-03-05 19:45:40 +01:00
$langs -> load ( " companies " );
$langs -> load ( " bills " );
$langs -> load ( " members " );
2005-04-16 15:32:33 +02:00
$langs -> load ( " users " );
2005-03-05 19:45:40 +01:00
2007-09-08 11:02:22 +02:00
// Defini si peux creer un utilisateur ou gerer groupe sur un utilisateur
$canadduser = $user -> rights -> adherent -> creer ;
// Defini si peux lire/modifier info user ou mot de passe
if ( $_GET [ " rowid " ])
{
$caneditfield = $user -> rights -> adherent -> creer ;
$caneditpassword = $user -> rights -> adherent -> creer ;
}
if ( ! $user -> rights -> adherent -> lire )
{
accessforbidden ();
}
2006-11-26 08:00:14 +01:00
$adh = new Adherent ( $db );
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 " ];
2006-03-23 17:02:52 +01:00
$typeid = isset ( $_GET [ " typeid " ]) ? $_GET [ " typeid " ] : $_POST [ " typeid " ];
2004-07-17 01:35:53 +02:00
2006-03-18 00:27:30 +01:00
/*
* Actions
*/
2007-04-27 00:01:10 +02:00
// Creation utilisateur depuis adherent
if ( $user -> rights -> user -> user -> creer )
{
if ( $_GET [ " action " ] == 'create_user' )
{
// Recuperation contact actuel
$adh = new Adherent ( $db );
$result = $adh -> fetch ( $_GET [ " rowid " ]);
if ( $result > 0 )
{
// Creation user
$nuser = new User ( $db );
$result = $nuser -> create_from_member ( $adh );
if ( $result < 0 )
{
$msg = $nuser -> error ;
}
}
else
{
$msg = $adh -> error ;
}
}
}
2006-11-19 18:22:01 +01:00
if ( $_POST [ " action " ] == 'confirm_sendinfo' && $_POST [ " confirm " ] == 'yes' )
2003-09-03 17:21:06 +02:00
{
2004-07-17 01:35:53 +02:00
$adh -> id = $rowid ;
$adh -> fetch ( $rowid );
2007-02-11 17:32:29 +01:00
if ( $adh -> email )
{
2007-10-04 21:59:21 +02:00
$result = $adh -> send_an_email ( " Voici le contenu de votre fiche \n \n %INFOS% \n \n " , " Contenu de votre fiche adherent " );
2007-02-11 17:32:29 +01:00
}
2003-09-03 17:21:06 +02:00
}
2008-01-25 18:40:07 +01:00
if ( $_REQUEST [ " action " ] == 'update' && ! $_POST [ " cancel " ])
2006-03-18 00:27:30 +01:00
{
2007-05-02 12:45:30 +02:00
$result = $adh -> fetch ( $_POST [ " rowid " ]);
2008-01-25 18:40:07 +01:00
// If change (allowed on all members) or (allowed on myself and i am edited memeber)
if ( $user -> rights -> adherent -> creer || ( $user -> rights -> adherent -> self -> creer && $adh -> user_id == $user -> id ))
2006-11-26 19:24:53 +01:00
{
2008-01-25 18:40:07 +01:00
$datenaiss = '' ;
if ( isset ( $_POST [ " naissday " ]) && $_POST [ " naissday " ]
&& isset ( $_POST [ " naissmonth " ]) && $_POST [ " naissmonth " ]
&& isset ( $_POST [ " naissyear " ]) && $_POST [ " naissyear " ])
2006-03-18 00:27:30 +01:00
{
2008-01-25 18:40:07 +01:00
$datenaiss = dolibarr_mktime ( 12 , 0 , 0 , $_POST [ " naissmonth " ], $_POST [ " naissday " ], $_POST [ " naissyear " ]);
2006-03-18 00:27:30 +01:00
}
2008-01-25 18:40:07 +01:00
//print $_POST["naissmonth"].", ".$_POST["naissday"].", ".$_POST["naissyear"]." ".$datenaiss." ".adodb_strftime('%Y-%m-%d %H:%M:%S',$datenaiss);
2007-09-08 11:02:22 +02:00
2008-01-25 18:40:07 +01:00
// Charge objet actuel
if ( $result > 0 )
2007-02-27 21:40:19 +01:00
{
2008-01-25 18:40:07 +01:00
// Modifie valeures
$adh -> prenom = $_POST [ " prenom " ];
$adh -> nom = $_POST [ " nom " ];
$adh -> fullname = trim ( $adh -> prenom . ' ' . $adh -> nom );
$adh -> login = $_POST [ " login " ];
$adh -> pass = $_POST [ " pass " ];
$adh -> societe = $_POST [ " societe " ];
$adh -> adresse = $_POST [ " adresse " ];
$adh -> cp = $_POST [ " cp " ];
$adh -> ville = $_POST [ " ville " ];
$adh -> pays_id = $_POST [ " pays " ];
$adh -> phone = $_POST [ " phone " ];
$adh -> phone_perso = $_POST [ " phone_perso " ];
$adh -> phone_mobile = $_POST [ " phone_mobile " ];
$adh -> email = $_POST [ " email " ];
$adh -> naiss = $datenaiss ;
$adh -> typeid = $_POST [ " type " ];
2008-03-21 01:27:37 +01:00
$adh -> note = $_POST [ " comment " ];
2008-01-25 18:40:07 +01:00
$adh -> morphy = $_POST [ " morphy " ];
$adh -> amount = $_POST [ " amount " ];
// recuperation du statut et public
$adh -> statut = $_POST [ " statut " ];
$adh -> public = $_POST [ " public " ];
foreach ( $_POST as $key => $value )
2007-09-08 11:02:22 +02:00
{
2008-01-25 18:40:07 +01:00
if ( ereg ( " ^options_ " , $key ))
2007-09-08 11:02:22 +02:00
{
2008-01-25 18:40:07 +01:00
//escape values from POST, at least with addslashes, to avoid obvious SQL injections
//(array_options is directly input in the DB in adherent.class.php::update())
$adh -> array_options [ $key ] = addslashes ( $_POST [ $key ]);
2007-09-08 11:02:22 +02:00
}
2008-01-25 18:40:07 +01:00
}
$result = $adh -> update ( $user , 0 );
if ( $result >= 0 && ! sizeof ( $adh -> errors ))
{
if ( isset ( $_FILES [ 'photo' ][ 'tmp_name' ]) && trim ( $_FILES [ 'photo' ][ 'tmp_name' ]))
2007-09-08 11:02:22 +02:00
{
2008-01-25 18:40:07 +01:00
// If photo is provided
if ( ! is_dir ( $conf -> adherent -> dir_output ))
2007-09-08 11:02:22 +02:00
{
2008-01-25 18:40:07 +01:00
create_exdir ( $conf -> adherent -> dir_output );
}
if ( is_dir ( $conf -> adherent -> dir_output ))
{
$newfile = $conf -> adherent -> dir_output . " / " . $adh -> id . " .jpg " ;
2008-10-14 02:16:28 +02:00
if ( ! dol_move_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ], $newfile , 1 ) > 0 )
2008-01-25 18:40:07 +01:00
{
$message .= '<div class="error">' . $langs -> trans ( " ErrorFailedToSaveFile " ) . '</div>' ;
}
2007-09-08 11:02:22 +02:00
}
}
2008-04-17 13:30:04 +02:00
$_GET [ " rowid " ] = $adh -> id ;
$_REQUEST [ " action " ] = '' ;
2007-05-02 12:45:30 +02:00
}
else
2007-02-11 17:32:29 +01:00
{
2008-01-25 18:40:07 +01:00
if ( $adh -> error )
{
$errmsg = $adh -> error ;
}
else
2007-05-02 12:45:30 +02:00
{
2008-01-25 18:40:07 +01:00
foreach ( $adh -> errors as $error )
{
if ( $errmsg ) $errmsg .= '<br>' ;
$errmsg .= $error ;
}
2007-05-02 12:45:30 +02:00
}
2008-01-25 18:40:07 +01:00
$action = '' ;
2007-02-11 17:32:29 +01:00
}
}
2006-11-26 19:24:53 +01:00
}
2006-03-18 00:27:30 +01:00
}
2007-05-26 17:36:46 +02:00
if ( $user -> rights -> adherent -> creer && $_POST [ " action " ] == 'add' )
2002-12-28 19:12:22 +01:00
{
2006-03-18 00:27:30 +01:00
$datenaiss = '' ;
2007-01-16 20:43:02 +01:00
if ( isset ( $_POST [ " naissday " ]) && $_POST [ " naissday " ]
&& isset ( $_POST [ " naissmonth " ]) && $_POST [ " naissmonth " ]
&& isset ( $_POST [ " naissyear " ]) && $_POST [ " naissyear " ])
{
$datenaiss = dolibarr_mktime ( 12 , 0 , 0 , $_POST [ " naissmonth " ], $_POST [ " naissday " ], $_POST [ " naissyear " ]);
}
2006-03-18 00:27:30 +01:00
$datecotisation = '' ;
2007-01-16 12:24:38 +01:00
if ( isset ( $_POST [ " reday " ]) && isset ( $_POST [ " remonth " ]) && isset ( $_POST [ " reyear " ]))
{
2007-01-16 20:43:02 +01:00
$datecotisation = dolibarr_mktime ( 12 , 0 , 0 , $_POST [ " remonth " ], $_POST [ " reday " ], $_POST [ " reyear " ]);
2006-03-18 00:27:30 +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 " ];
2006-11-26 08:00:14 +01:00
$pays_id = $_POST [ " pays_id " ];
2006-11-26 03:59:09 +01:00
$phone = $_POST [ " phone " ];
$phone_perso = $_POST [ " phone_perso " ];
$phone_mobile = $_POST [ " phone_mobile " ];
2006-03-18 00:27:30 +01:00
$email = $_POST [ " member_email " ];
$login = $_POST [ " member_login " ];
2007-02-27 21:40:19 +01:00
$pass = $_POST [ " password " ];
2005-08-11 20:24:58 +02:00
$photo = $_POST [ " photo " ];
2004-07-17 14:41:15 +02:00
$comment = $_POST [ " comment " ];
$morphy = $_POST [ " morphy " ];
2005-03-05 19:45:40 +01:00
$cotisation = $_POST [ " cotisation " ];
2004-07-17 14:41:15 +02:00
$adh -> prenom = $prenom ;
$adh -> nom = $nom ;
$adh -> societe = $societe ;
$adh -> adresse = $adresse ;
$adh -> cp = $cp ;
$adh -> ville = $ville ;
2006-11-26 08:00:14 +01:00
$adh -> pays_id = $pays_id ;
2006-11-26 03:59:09 +01:00
$adh -> phone = $phone ;
$adh -> phone_perso = $phone_perso ;
$adh -> phone_mobile = $phone_mobile ;
2004-07-17 14:41:15 +02:00
$adh -> email = $email ;
$adh -> login = $login ;
$adh -> pass = $pass ;
2006-03-18 00:27:30 +01:00
$adh -> naiss = $datenaiss ;
2004-07-17 14:41:15 +02:00
$adh -> photo = $photo ;
$adh -> typeid = $type ;
2008-03-21 01:27:37 +01:00
$adh -> note = $comment ;
2004-07-17 14:41:15 +02:00
$adh -> morphy = $morphy ;
foreach ( $_POST as $key => $value ){
if ( ereg ( " ^options_ " , $key )){
2007-01-16 12:24:38 +01:00
//escape values from POST, at least with addslashes, to avoid obvious SQL injections
//(array_options is directly input in the DB in adherent.class.php::update())
$adh -> array_options [ $key ] = addslashes ( $_POST [ $key ]);
2004-07-17 14:41:15 +02:00
}
}
2007-12-26 11:09:30 +01:00
// Test validite des parametres
2004-07-17 01:35:53 +02:00
if ( ! isset ( $type ) || $type == '' ){
2005-04-16 15:10:06 +02:00
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorMemberTypeNotDefined " ) . " <br> \n " ;
2004-07-17 01:35:53 +02:00
}
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 == '' ){
2005-04-16 15:10:06 +02:00
$error ++ ;
2005-03-05 19:45:40 +01:00
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> trans ( " Login " )) . " <br> \n " ;
2004-07-17 01:35:53 +02:00
}
2005-04-16 15:10:06 +02:00
else {
2007-02-27 21:40:19 +01:00
$sql = " SELECT login FROM " . MAIN_DB_PREFIX . " adherent WHERE login=' " . $login . " ' " ;
2005-04-16 15:10:06 +02:00
$result = $db -> query ( $sql );
if ( $result ) {
$num = $db -> num_rows ( $result );
}
if ( $num ) {
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorLoginAlreadyExists " , $login ) . " <br> \n " ;
}
2005-03-05 19:45:40 +01:00
}
if ( ! isset ( $nom ) || $nom == '' ) {
2005-04-16 15:10:06 +02:00
$error ++ ;
2006-12-20 02:20:19 +01:00
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Lastname " )) . " <br> \n " ;
2004-07-17 01:35:53 +02:00
}
2007-06-14 23:16:18 +02:00
if ( $morphy != 'mor' && ( ! isset ( $prenom ) || $prenom == '' )) {
$error ++ ;
2006-12-20 02:20:19 +01:00
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Firstname " )) . " <br> \n " ;
2004-07-17 01:35:53 +02:00
}
2005-12-07 23:56:57 +01:00
if ( $conf -> global -> ADHERENT_MAIL_REQUIRED && ! ValidEMail ( $email )) {
2005-04-16 15:10:06 +02:00
$error ++ ;
$errmsg .= $langs -> trans ( " ErrorBadEMail " , $email ) . " <br> \n " ;
2004-07-17 01:35:53 +02:00
}
2004-11-12 15:37:38 +01:00
if ( ! isset ( $pass ) || $pass == '' ) {
2005-04-16 15:10:06 +02:00
$error ++ ;
2006-12-20 02:20:19 +01:00
$errmsg .= $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Password " )) . " <br> \n " ;
2004-07-17 01:35:53 +02:00
}
2006-03-18 00:27:30 +01:00
$public = 0 ;
if ( isset ( $public )) $public = 1 ;
2004-09-25 13:02:10 +02:00
2006-11-26 08:53:07 +01:00
if ( ! $error )
2005-08-11 20:24:58 +02:00
{
2007-02-27 21:40:19 +01:00
$db -> begin ();
// Email a peu pres correct et le login n'existe pas
$result = $adh -> create ( $user );
if ( $result > 0 )
2004-07-17 01:35:53 +02:00
{
2007-02-27 21:40:19 +01:00
if ( $cotisation > 0 )
2005-03-05 19:45:40 +01:00
{
2006-03-18 00:27:30 +01:00
$crowid = $adh -> cotisation ( $datecotisation , $cotisation );
2005-03-05 19:45:40 +01:00
// insertion dans la gestion banquaire si configure pour
2006-03-18 00:27:30 +01:00
if ( $global -> conf -> ADHERENT_BANK_USE )
2005-08-11 20:24:58 +02:00
{
2007-02-04 22:23:58 +01:00
$dateop = time ();
2005-03-05 19:45:40 +01:00
$amount = $cotisation ;
2005-08-11 20:24:58 +02:00
$acct = new Account ( $db , $_POST [ " accountid " ]);
$insertid = $acct -> addline ( $dateop , $_POST [ " operation " ], $_POST [ " label " ], $amount , $_POST [ " num_chq " ], '' , $user );
2005-03-05 19:45:40 +01:00
if ( $insertid == '' )
2004-07-17 01:35:53 +02:00
{
2005-03-05 19:45:40 +01:00
dolibarr_print_error ( $db );
2004-07-17 01:35:53 +02:00
}
else
{
2005-03-05 19:45:40 +01:00
// met a jour la table cotisation
2006-03-18 00:27:30 +01:00
$sql = " UPDATE " . MAIN_DB_PREFIX . " cotisation " ;
$sql .= " SET fk_bank= $insertid WHERE rowid= $crowid " ;
2005-03-05 19:45:40 +01:00
$result = $db -> query ( $sql );
if ( $result )
{
//Header("Location: fiche.php");
}
else
{
dolibarr_print_error ( $db );
}
2004-07-17 01:35:53 +02:00
}
}
}
2007-02-27 21:40:19 +01:00
$db -> commit ();
2005-03-05 19:45:40 +01:00
Header ( " Location: liste.php?statut=-1 " );
2006-03-18 00:27:30 +01:00
exit ;
2005-03-05 19:45:40 +01:00
}
2007-02-27 21:40:19 +01:00
else
{
$db -> rollback ();
2007-02-27 22:40:09 +01:00
if ( $adh -> error ) $errmsg = $adh -> error ;
else $errmsg = $adh -> errors [ 0 ];
2007-02-27 21:40:19 +01:00
$action = 'create' ;
2004-07-17 01:35:53 +02:00
}
}
2004-09-25 13:02:10 +02:00
else {
2005-03-05 19:45:40 +01:00
$action = 'create' ;
2004-09-25 13:02:10 +02:00
}
2004-07-17 01:35:53 +02:00
}
2002-12-30 16:13:28 +01:00
2007-05-26 17:36:46 +02:00
if ( $user -> rights -> adherent -> supprimer && $_POST [ " action " ] == 'confirm_delete' && $_POST [ " confirm " ] == 'yes' )
2002-12-28 19:12:22 +01:00
{
2007-05-03 00:31:51 +02:00
$result = $adh -> fetch ( $rowid );
2006-11-26 08:00:14 +01:00
$result = $adh -> delete ( $rowid );
if ( $result > 0 )
{
Header ( " Location: liste.php " );
exit ;
}
else
{
$mesg = $adh -> error ;
}
2002-12-28 19:12:22 +01:00
}
2007-05-26 17:36:46 +02:00
if ( $user -> rights -> adherent -> creer && $_POST [ " action " ] == 'confirm_valid' && $_POST [ " confirm " ] == 'yes' )
2002-12-30 17:29:21 +01:00
{
2007-05-03 00:31:51 +02:00
$result = $adh -> fetch ( $rowid );
$result = $adh -> validate ( $user );
2007-02-11 17:32:29 +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
2007-02-11 17:32:29 +01:00
if ( $result >= 0 && ! sizeof ( $adh -> errors ))
{
2007-05-03 00:31:51 +02:00
// Envoi mail validation (selon param du type adherent sinon generique)
2007-10-04 20:29:29 +02:00
if ( $adh -> email && $_POST [ " send_mail " ])
2007-05-03 00:31:51 +02:00
{
if ( isset ( $adht -> mail_valid ) && $adht -> mail_valid )
{
2007-10-04 21:59:21 +02:00
$result = $adh -> send_an_email ( $adht -> mail_valid , $conf -> global -> ADHERENT_MAIL_VALID_SUBJECT , array (), array (), array (), " " , " " , 0 , 2 );
2007-05-03 00:31:51 +02:00
}
else
{
2007-10-04 21:59:21 +02:00
$result = $adh -> send_an_email ( $conf -> global -> ADHERENT_MAIL_VALID , $conf -> global -> ADHERENT_MAIL_VALID_SUBJECT , array (), array (), array (), " " , " " , 0 , 2 );
2007-05-03 00:31:51 +02:00
}
if ( $result < 0 )
{
$errmsg .= $adh -> error ;
}
}
2007-02-11 17:32:29 +01:00
2007-05-03 00:31:51 +02:00
// Rajoute l'utilisateur dans les divers abonnements (mailman, spip, etc...)
if ( $adh -> add_to_abo ( $adht ) < 0 )
{
// error
$errmsg .= " Echec du rajout de l'utilisateur aux abonnements mailman: " . $adh -> error . " <BR> \n " ;
}
2007-02-11 17:32:29 +01:00
}
else
{
2007-05-03 00:31:51 +02:00
// \TODO Mettre fonction qui fabrique errmsg depuis this->error||this->errors
2007-02-11 17:32:29 +01:00
if ( $adh -> error )
{
$errmsg = $adh -> error ;
}
else
{
foreach ( $adh -> errors as $error )
{
if ( $errmsg ) $errmsg .= '<br>' ;
$errmsg .= $error ;
}
}
$action = '' ;
}
2002-12-30 17:29:21 +01:00
}
2007-05-26 17:36:46 +02:00
if ( $user -> rights -> adherent -> supprimer && $_POST [ " action " ] == 'confirm_resign' && $_POST [ " confirm " ] == 'yes' )
2002-12-30 22:07:11 +01:00
{
2007-05-03 00:31:51 +02:00
$result = $adh -> fetch ( $rowid );
$result = $adh -> resiliate ( $user );
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
2007-05-03 00:31:51 +02:00
if ( $result >= 0 && ! sizeof ( $adh -> errors ))
2007-02-11 17:32:29 +01:00
{
2007-10-04 20:29:29 +02:00
if ( $adh -> email && $_POST [ " send_mail " ])
2007-05-03 00:31:51 +02:00
{
2008-03-21 01:27:37 +01:00
$result = $adh -> send_an_email ( $conf -> global -> ADHERENT_MAIL_RESIL , $conf -> global -> ADHERENT_MAIL_RESIL_SUBJECT , array (), array (), array (), " " , " " , 0 , - 1 );
2007-05-03 00:31:51 +02:00
}
2007-10-04 21:01:28 +02:00
if ( $result < 0 )
{
$errmsg .= $adh -> error ;
}
2007-05-03 00:31:51 +02:00
// supprime l'utilisateur des divers abonnements ..
if ( ! $adh -> del_to_abo ( $adht ))
{
// error
$errmsg .= " Echec de la suppression de l'utilisateur aux abonnements mailman: " . $adh -> error . " <BR> \n " ;
}
}
else
{
// \TODO Mettre fonction qui fabrique errmsg depuis this->error||this->errors
if ( $adh -> error )
{
$errmsg = $adh -> error ;
}
else
{
foreach ( $adh -> errors as $error )
{
if ( $errmsg ) $errmsg .= '<br>' ;
$errmsg .= $error ;
}
}
$action = '' ;
2007-02-11 17:32:29 +01:00
}
2002-12-30 22:07:11 +01:00
}
2007-05-26 17:36:46 +02:00
if ( $user -> rights -> adherent -> supprimer && $_POST [ " action " ] == 'confirm_del_spip' && $_POST [ " confirm " ] == 'yes' )
2003-03-07 19:53:17 +01:00
{
2007-05-03 00:31:51 +02:00
$result = $adh -> fetch ( $rowid );
if ( $result >= 0 && ! sizeof ( $adh -> errors ))
{
if ( ! $adh -> del_to_spip ()){
$errmsg .= " Echec de la suppression de l'utilisateur dans spip: " . $adh -> error . " <BR> \n " ;
}
}
2003-03-07 19:53:17 +01:00
}
2007-05-26 17:36:46 +02:00
if ( $user -> rights -> adherent -> creer && $_POST [ " action " ] == 'confirm_add_spip' && $_POST [ " confirm " ] == 'yes' )
2003-03-07 19:53:17 +01:00
{
2007-05-03 00:31:51 +02:00
$result = $adh -> fetch ( $rowid );
if ( $result >= 0 && ! sizeof ( $adh -> errors ))
{
if ( ! $adh -> add_to_spip ())
{
$errmsg .= " Echec du rajout de l'utilisateur dans spip: " . $adh -> error . " <BR> \n " ;
}
}
2003-03-07 19:53:17 +01:00
}
2005-04-16 15:10:06 +02:00
2006-03-18 00:27:30 +01:00
/*
*
*/
2005-04-16 15:10:06 +02:00
2006-03-18 00:27:30 +01:00
llxHeader ();
2005-04-16 15:10:06 +02:00
2006-03-23 17:02:52 +01:00
if ( $errmsg )
2003-08-12 19:36:17 +02:00
{
2006-03-18 00:27:30 +01:00
print '<div class="error">' . $errmsg . '</div>' ;
print " \n " ;
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 ();
2005-03-05 19:45:40 +01:00
2005-04-16 15:10:06 +02:00
2006-03-18 00:27:30 +01:00
if ( $action == 'edit' )
{
/********************************************
*
* Fiche en mode edition
*
********************************************/
$adho = new AdherentOptions ( $db );
$adh = new Adherent ( $db );
$adh -> id = $rowid ;
$adh -> fetch ( $rowid );
// fetch optionals value
$adh -> fetch_optionals ( $rowid );
// fetch optionals attributes and labels
$adho -> fetch_optionals ();
$adht = new AdherentType ( $db );
2008-01-25 18:40:07 +01:00
$adht -> fetch ( $adh -> typeid );
2006-03-18 00:27:30 +01:00
2006-11-26 19:24:53 +01:00
/*
* Affichage onglets
*/
$head = member_prepare_head ( $adh );
2007-02-03 23:40:04 +01:00
dolibarr_fiche_head ( $head , 'general' , $langs -> trans ( " Member " ));
2006-03-18 00:27:30 +01:00
2007-09-08 11:02:22 +02:00
print '<form name="update" action="' . $_SERVER [ " PHP_SELF " ] . '" method="post" enctype="multipart/form-data">' ;
2006-03-18 00:27:30 +01:00
print " <input type= \" hidden \" name= \" action \" value= \" update \" > " ;
print " <input type= \" hidden \" name= \" rowid \" value= \" $rowid\ " > " ;
print " <input type= \" hidden \" name= \" statut \" value= \" " . $adh -> statut . " \" > " ;
2007-01-21 23:35:27 +01:00
2006-03-18 00:27:30 +01:00
$htmls = new Form ( $db );
2006-11-26 03:59:09 +01:00
2007-09-15 04:28:29 +02:00
print '<table class="border" width="100%">' ;
2006-11-26 03:59:09 +01:00
// Ref
print '<tr><td>' . $langs -> trans ( " Ref " ) . '</td><td class="valeur" colspan="2">' . $adh -> id . ' </td></tr>' ;
2006-03-18 00:27:30 +01:00
2006-04-01 04:07:58 +02:00
// Nom
2007-09-08 11:02:22 +02:00
print '<tr><td>' . $langs -> trans ( " Lastname " ) . '*</td><td><input type="text" name="nom" size="40" value="' . $adh -> nom . '"></td>' ;
2007-05-21 00:53:11 +02:00
// Photo
2007-09-08 11:02:22 +02:00
$rowspan = 16 ;
2007-05-21 00:53:11 +02:00
$rowspan += sizeof ( $adho -> attribute_label );
2007-09-08 11:02:22 +02:00
print '<td align="center" valign="middle" width="25%" rowspan="' . $rowspan . '">' ;
if ( file_exists ( $conf -> adherent -> dir_output . " / " . $adh -> id . " .jpg " ))
{
print '<img width="100" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=memberphoto&file=' . $adh -> id . '.jpg">' ;
}
else
{
print '<img src="' . DOL_URL_ROOT . '/theme/common/nophoto.jpg">' ;
}
if ( $caneditfield )
{
print '<br><br><table class="noborder"><tr><td>' . $langs -> trans ( " PhotoFile " ) . '</td></tr>' ;
print '<tr><td>' ;
print '<input type="file" class="flat" name="photo">' ;
print '</td></tr></table>' ;
}
2007-05-21 00:53:11 +02:00
print '</td>' ;
print '</tr>' ;
2006-04-01 04:07:58 +02:00
// Prenom
2007-09-08 11:02:22 +02:00
print '<tr><td width="20%">' . $langs -> trans ( " Firstname " ) . '*</td><td width="35%"><input type="text" name="prenom" size="40" value="' . $adh -> prenom . '"></td>' ;
2007-05-21 00:53:11 +02:00
print '</tr>' ;
2006-03-18 00:27:30 +01:00
2006-11-26 03:59:09 +01:00
// Login
2007-09-15 04:28:29 +02:00
print '<tr><td>' . $langs -> trans ( " Login " ) . '*</td><td><input type="text" name="login" size="30" value="' . $adh -> login . '"></td></tr>' ;
2006-11-26 03:59:09 +01:00
// Password
2007-09-15 04:28:29 +02:00
print '<tr><td>' . $langs -> trans ( " Password " ) . '*</td><td><input type="password" name="pass" size="30" value="' . $adh -> pass . '"></td></tr>' ;
2006-11-26 03:59:09 +01:00
2006-04-01 04:07:58 +02:00
// Type
2007-09-08 11:02:22 +02:00
print '<tr><td>' . $langs -> trans ( " Type " ) . '*</td><td>' ;
2008-01-25 18:40:07 +01:00
if ( $user -> rights -> adherent -> creer ) // If $user->rights->adherent->self->creer, we do not allow.
{
$htmls -> select_array ( " type " , $adht -> liste_array (), $adh -> typeid );
}
else
{
print $adht -> getNomUrl ( 1 );
print '<input type="hidden" name="type" value="' . $adh -> typeid . '">' ;
}
2006-04-01 04:07:58 +02:00
print " </td></tr> " ;
2006-03-18 00:27:30 +01:00
2006-04-01 04:07:58 +02:00
// Physique-Moral
2006-03-18 00:27:30 +01:00
$morphys [ " phy " ] = $langs -> trans ( " Physical " );
$morphys [ " mor " ] = $langs -> trans ( " Morale " );
2007-09-08 11:02:22 +02:00
print " <tr><td> " . $langs -> trans ( " Person " ) . " *</td><td> " ;
2006-03-18 00:27:30 +01:00
$htmls -> select_array ( " morphy " , $morphys , $adh -> morphy );
2006-04-01 04:07:58 +02:00
print " </td></tr> " ;
2006-03-18 00:27:30 +01:00
2007-12-26 11:09:30 +01:00
// Societe
2006-03-18 00:27:30 +01:00
print '<tr><td>' . $langs -> trans ( " Company " ) . '</td><td><input type="text" name="societe" size="40" value="' . $adh -> societe . '"></td></tr>' ;
2006-04-01 04:07:58 +02:00
// Adresse
2006-03-18 00:27:30 +01:00
print '<tr><td>' . $langs -> trans ( " Address " ) . '</td><td>' ;
print '<textarea name="adresse" wrap="soft" cols="40" rows="2">' . $adh -> adresse . '</textarea></td></tr>' ;
2006-11-26 03:59:09 +01:00
// Cp
2006-03-18 00:27:30 +01:00
print '<tr><td>' . $langs -> trans ( " Zip " ) . '/' . $langs -> trans ( " Town " ) . '</td><td><input type="text" name="cp" size="6" value="' . $adh -> cp . '"> <input type="text" name="ville" size="32" value="' . $adh -> ville . '"></td></tr>' ;
2006-11-26 03:59:09 +01:00
// Pays
2006-03-18 00:27:30 +01:00
print '<tr><td>' . $langs -> trans ( " Country " ) . '</td><td>' ;
$htmls -> select_pays ( $adh -> pays_code ? $adh -> pays_code : $mysoc -> pays_code , 'pays' );
print '</td></tr>' ;
2006-11-26 03:59:09 +01:00
// Tel
print '<tr><td>' . $langs -> trans ( " PhonePro " ) . '</td><td><input type="text" name="phone" size="20" value="' . $adh -> phone . '"></td></tr>' ;
// Tel perso
print '<tr><td>' . $langs -> trans ( " PhonePerso " ) . '</td><td><input type="text" name="phone_perso" size="20" value="' . $adh -> phone_perso . '"></td></tr>' ;
2006-03-18 00:27:30 +01:00
2006-11-26 03:59:09 +01:00
// Tel mobile
print '<tr><td>' . $langs -> trans ( " PhoneMobile " ) . '</td><td><input type="text" name="phone_mobile" size="20" value="' . $adh -> phone_mobile . '"></td></tr>' ;
// EMail
print '<tr><td>' . $langs -> trans ( " EMail " ) . ( $conf -> global -> ADHERENT_MAIL_REQUIRED ? '*' : '' ) . '</td><td><input type="text" name="email" size="40" value="' . $adh -> email . '"></td></tr>' ;
2006-03-18 00:27:30 +01:00
// Date naissance
print " <tr><td> " . $langs -> trans ( " Birthday " ) . " </td><td> \n " ;
2006-11-26 08:00:14 +01:00
$htmls -> select_date (( $adh -> naiss ? $adh -> naiss : - 1 ), 'naiss' , '' , '' , 1 , 'update' );
2006-03-18 00:27:30 +01:00
print " </td></tr> \n " ;
2006-11-26 19:24:53 +01:00
// Profil public
print " <tr><td> " . $langs -> trans ( " Public " ) . " </td><td> \n " ;
2007-05-04 10:26:01 +02:00
print $htmls -> selectyesno ( " public " , $adh -> public , 1 );
2006-11-26 19:24:53 +01:00
print " </td></tr> \n " ;
2007-12-26 11:09:30 +01:00
// Attributs supplementaires
2007-01-21 23:23:49 +01:00
foreach ( $adho -> attribute_label as $key => $value )
{
print " <tr><td> $value </td><td><input type= \" text \" name= \" options_ $key\ " size = \ " 40 \" value= \" " . $adh -> array_options [ " options_ $key " ] . " \" ></td></tr> \n " ;
}
2006-11-26 19:24:53 +01:00
print '<tr><td colspan="3" align="center">' ;
print '<input type="submit" class="button" name="submit" value="' . $langs -> trans ( " Save " ) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2006-03-18 00:27:30 +01:00
print '</td></tr>' ;
2006-11-26 19:24:53 +01:00
2006-03-18 00:27:30 +01:00
print '</table>' ;
2007-09-15 04:28:29 +02:00
2006-03-18 00:27:30 +01:00
print '</form>' ;
print '</div>' ;
}
2005-04-16 15:10:06 +02:00
if ( $action == 'create' )
{
2006-03-18 00:27:30 +01:00
/* ************************************************************************** */
/* */
2007-12-26 11:09:30 +01:00
/* Fiche creation */
2006-03-18 00:27:30 +01:00
/* */
/* ************************************************************************** */
$htmls = new Form ( $db );
$adht = new AdherentType ( $db );
2002-12-28 19:12:22 +01:00
2004-11-12 15:37:38 +01:00
print_titre ( $langs -> trans ( " NewMember " ));
2006-04-01 04:07:58 +02:00
2007-09-08 11:02:22 +02:00
print '<form name="add" action="fiche.php" method="post" enctype="multipart/form-data">' ;
2004-07-17 01:35:53 +02:00
print '<input type="hidden" name="action" value="add">' ;
2006-03-18 00:27:30 +01:00
print '<table class="border" width="100%">' ;
2004-07-17 01:35:53 +02:00
2006-11-20 02:13:13 +01:00
// Nom
2006-04-01 04:07:58 +02:00
print '<tr><td>' . $langs -> trans ( " Lastname " ) . '*</td><td><input type="text" name="nom" value="' . $adh -> nom . '" size="40"></td>' ;
2007-05-21 00:53:11 +02:00
print '</tr>' ;
2006-04-01 04:07:58 +02:00
2006-11-20 02:13:13 +01:00
// Prenom
2006-04-01 04:07:58 +02:00
print '<tr><td>' . $langs -> trans ( " Firstname " ) . '*</td><td><input type="text" name="prenom" size="40" value="' . $adh -> prenom . '"></td>' ;
2007-05-21 00:53:11 +02:00
print '</tr>' ;
2006-04-01 04:07:58 +02:00
2006-11-20 02:13:13 +01:00
// Login
print '<tr><td>' . $langs -> trans ( " Login " ) . '*</td><td><input type="text" name="member_login" size="40" value="' . $adh -> login . '"></td></tr>' ;
2007-02-03 23:40:04 +01:00
// Mot de passe
2007-02-27 21:40:19 +01:00
$generated_password = '' ;
if ( $conf -> global -> USER_PASSWORD_GENERATED )
{
$nomclass = " modGeneratePass " . ucfirst ( $conf -> global -> USER_PASSWORD_GENERATED );
$nomfichier = $nomclass . " .class.php " ;
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
require_once ( DOL_DOCUMENT_ROOT . " /includes/modules/security/generate/ " . $nomfichier );
2008-04-10 01:07:13 +02:00
$genhandler = new $nomclass ( $db , $conf , $langs , $user );
2007-02-27 21:40:19 +01:00
$generated_password = $genhandler -> getNewGeneratedPassword ();
}
print '<tr><td>' . $langs -> trans ( " Password " ) . '*</td><td>' ;
print '<input size="30" maxsize="32" type="text" name="password" value="' . $generated_password . '">' ;
print '</td></tr>' ;
2006-11-20 02:13:13 +01:00
2006-04-01 04:07:58 +02:00
// Type
2006-11-21 23:51:05 +01:00
print '<tr><td>' . $langs -> trans ( " MemberType " ) . '*</td><td>' ;
2005-04-16 15:10:06 +02:00
$listetype = $adht -> liste_array ();
2006-11-26 22:17:26 +01:00
if ( sizeof ( $listetype ))
{
2006-03-23 17:02:52 +01:00
$htmls -> select_array ( " type " , $listetype , $typeid );
2005-04-16 15:10:06 +02:00
} else {
print '<font class="error">' . $langs -> trans ( " NoTypeDefinedGoToSetup " ) . '</font>' ;
}
2004-07-17 01:35:53 +02:00
print " </td> \n " ;
2006-04-01 04:07:58 +02:00
// Moral-Physique
2004-07-17 01:35:53 +02:00
$morphys [ " phy " ] = " Physique " ;
$morphys [ " mor " ] = " Morale " ;
2006-04-01 04:07:58 +02:00
print " <tr><td> " . $langs -> trans ( " Person " ) . " *</td><td> \n " ;
2007-06-14 23:16:18 +02:00
$htmls -> select_array ( " morphy " , $morphys , $adh -> morphy );
2004-07-17 01:35:53 +02:00
print " </td> \n " ;
2005-08-11 20:24:58 +02:00
print '<tr><td>' . $langs -> trans ( " Company " ) . '</td><td><input type="text" name="societe" size="40" value="' . $adh -> societe . '"></td></tr>' ;
2006-11-20 02:13:13 +01:00
// Adresse
2005-08-11 20:24:58 +02:00
print '<tr><td valign="top">' . $langs -> trans ( " Address " ) . '</td><td>' ;
2006-11-26 03:59:09 +01:00
print '<textarea name="adresse" wrap="soft" cols="40" rows="2">' . $adh -> adresse . '</textarea></td></tr>' ;
2006-11-20 02:13:13 +01:00
2006-11-26 03:59:09 +01:00
// CP / Ville
2006-03-18 00:27:30 +01: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="32" value="' . $adh -> ville . '"></td></tr>' ;
2006-11-20 02:13:13 +01:00
2006-11-26 03:59:09 +01:00
// Pays
2005-08-11 20:24:58 +02:00
print '<tr><td>' . $langs -> trans ( " Country " ) . '</td><td>' ;
2006-11-26 08:00:14 +01:00
$htmls -> select_pays ( $adh -> pays_id ? $adh -> pays_id : $mysoc -> pays_id , 'pays_id' );
2005-08-11 20:24:58 +02:00
print '</td></tr>' ;
2006-11-20 02:13:13 +01:00
2006-11-26 03:59:09 +01:00
// Tel pro
print '<tr><td>' . $langs -> trans ( " PhonePro " ) . '</td><td><input type="text" name="phone" size="20" value="' . $adh -> phone . '"></td></tr>' ;
// Tel perso
print '<tr><td>' . $langs -> trans ( " PhonePerso " ) . '</td><td><input type="text" name="phone_perso" size="20" value="' . $adh -> phone_perso . '"></td></tr>' ;
// Tel mobile
print '<tr><td>' . $langs -> trans ( " PhoneMobile " ) . '</td><td><input type="text" name="phone_mobile" size="20" value="' . $adh -> phone_mobile . '"></td></tr>' ;
2006-11-20 02:13:13 +01:00
// EMail
2006-03-18 00:27:30 +01:00
print '<tr><td>' . $langs -> trans ( " EMail " ) . ( $conf -> global -> ADHERENT_MAIL_REQUIRED ? '*' : '' ) . '</td><td><input type="text" name="member_email" size="40" value="' . $adh -> email . '"></td></tr>' ;
// Date naissance
print " <tr><td> " . $langs -> trans ( " Birthday " ) . " </td><td> \n " ;
2006-11-26 03:59:09 +01:00
$htmls -> select_date (( $adh -> naiss ? $adh -> naiss : - 1 ), 'naiss' , '' , '' , 1 , 'add' );
2006-03-18 00:27:30 +01:00
print " </td></tr> \n " ;
2007-09-08 11:02:22 +02:00
// Attribut optionnels
2006-11-26 22:17:26 +01:00
foreach ( $adho -> attribute_label as $key => $value )
{
2004-07-17 01:35:53 +02:00
print " <tr><td> $value </td><td><input type= \" text \" name= \" options_ $key\ " size = \ " 40 \" ></td></tr> \n " ;
}
2006-11-26 08:00:14 +01:00
// Profil public
print " <tr><td> " . $langs -> trans ( " Public " ) . " </td><td> \n " ;
2007-05-04 10:26:01 +02:00
print $htmls -> selectyesno ( " public " , $adh -> public , 1 );
2006-11-26 08:00:14 +01:00
print " </td></tr> \n " ;
2005-08-11 20:24:58 +02:00
print " </table> \n " ;
print '<br>' ;
2004-07-17 01:35:53 +02:00
2005-09-06 22:58:14 +02:00
print '<center><input type="submit" class="button" value="' . $langs -> trans ( " AddMember " ) . '"></center>' ;
2004-07-17 01:35:53 +02:00
2005-08-11 20:24:58 +02:00
print " </form> \n " ;
2004-07-17 01:35:53 +02:00
}
2005-03-05 19:45:40 +01:00
2006-03-18 00:27:30 +01:00
if ( $rowid && $action != 'edit' )
2002-12-28 19:12:22 +01:00
{
2006-03-18 00:27:30 +01:00
/* ************************************************************************** */
/* */
/* Mode affichage */
/* */
/* ************************************************************************** */
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
2006-11-20 02:13:13 +01:00
/*
* Affichage onglets
*/
$head = member_prepare_head ( $adh );
2003-01-10 16:18:06 +01:00
2007-02-03 23:40:04 +01:00
dolibarr_fiche_head ( $head , 'general' , $langs -> trans ( " Member " ));
2003-01-10 16:18:06 +01:00
2007-04-27 00:01:10 +02:00
if ( $msg ) print '<div class="error">' . $msg . '</div>' ;
2003-01-10 16:18:06 +01:00
2007-02-07 21:54:00 +01:00
2007-12-26 11:09:30 +01:00
// Confirmation de la suppression de l'adherent
2004-07-17 01:35:53 +02:00
if ( $action == 'delete' )
2003-01-10 16:18:06 +01:00
{
2007-02-03 23:40:04 +01:00
$html -> form_confirm ( " fiche.php?rowid= $rowid " , $langs -> trans ( " DeleteMember " ), $langs -> trans ( " ConfirmDeleteMember " ), " confirm_delete " );
2005-08-11 20:24:58 +02:00
print '<br>' ;
2004-07-17 01:35:53 +02:00
}
2003-01-10 16:18:06 +01:00
2006-03-18 00:27:30 +01:00
// Confirmation de la validation
2004-07-17 01:35:53 +02:00
if ( $action == 'valid' )
2003-03-06 20:33:23 +01:00
{
2007-12-26 11:09:30 +01:00
// Cree un tableau formulaire
2007-10-04 20:29:29 +02:00
$formquestion = array ();
if ( $adh -> email ) $formquestion [ 0 ] = array ( 'type' => 'checkbox' , 'name' => 'send_mail' , 'label' => $langs -> trans ( " SendAnEMailToMember " , $adh -> email ), 'value' => 'true' );
$html -> form_confirm ( " fiche.php?rowid= $rowid " , $langs -> trans ( " ValidateMember " ), $langs -> trans ( " ConfirmValidateMember " ), " confirm_valid " , $formquestion );
2005-08-11 20:24:58 +02:00
print '<br>' ;
2004-07-17 01:35:53 +02:00
}
2003-03-06 20:33:23 +01:00
2006-11-19 18:22:01 +01:00
// Confirmation de l'envoi fiche par mail
if ( $action == 'sendinfo' )
{
$html -> form_confirm ( " fiche.php?rowid= $rowid " , $langs -> trans ( " SendCardByMail " ), $langs -> trans ( " ConfirmSendCardByMail " ), " confirm_sendinfo " );
print '<br>' ;
}
2007-12-26 11:09:30 +01:00
// Confirmation de la Resiliation
2004-07-17 01:35:53 +02:00
if ( $action == 'resign' )
2003-03-06 20:33:23 +01:00
{
2007-12-26 11:09:30 +01:00
// Cree un tableau formulaire
2007-10-04 20:29:29 +02:00
$formquestion = array ();
if ( $adh -> email ) $formquestion [ 0 ] = array ( 'type' => 'checkbox' , 'name' => 'send_mail' , 'label' => $langs -> trans ( " SendAnEMailToMember " , $adh -> email ), 'value' => 'false' );
$html -> form_confirm ( " fiche.php?rowid= $rowid " , $langs -> trans ( " ResiliateMember " ), $langs -> trans ( " ConfirmResiliateMember " ), " confirm_resign " , $formquestion );
2005-08-11 20:24:58 +02:00
print '<br>' ;
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 spip
*/
if ( $action == 'add_spip' )
{
2007-12-26 11:09:30 +01:00
$html -> form_confirm ( " fiche.php?rowid= $rowid " , " Ajouter dans spip " , " Etes-vous sur de vouloir ajouter cet adherent dans spip ? (serveur : " . ADHERENT_SPIP_SERVEUR . " ) " , " confirm_add_spip " );
2005-08-11 20:24:58 +02:00
print '<br>' ;
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' )
{
2007-12-26 11:09:30 +01:00
$html -> form_confirm ( " fiche.php?rowid= $rowid " , " Supprimer dans spip " , " Etes-vous sur de vouloir effacer cet adherent dans spip ? (serveur : " . ADHERENT_SPIP_SERVEUR . " ) " , " confirm_del_spip " );
2005-08-11 20:24:58 +02:00
print '<br>' ;
2004-07-17 01:35:53 +02:00
}
2002-12-30 17:29:21 +01:00
2002-12-28 19:12:22 +01:00
2007-09-08 11:02:22 +02:00
print '<form action="fiche.php" method="post" enctype="multipart/form-data">' ;
2006-11-20 02:13:13 +01:00
print '<table class="border" width="100%">' ;
2002-12-30 17:29:21 +01:00
2006-11-20 02:13:13 +01:00
// Ref
2007-02-07 21:54:00 +01:00
print '<tr><td width="20%">' . $langs -> trans ( " Ref " ) . '</td>' ;
2007-05-21 00:53:11 +02:00
print '<td class="valeur" colspan="2">' ;
2007-07-29 12:32:07 +02:00
print $html -> showrefnav ( $adh , 'rowid' );
2007-02-07 21:54:00 +01:00
print '</td></tr>' ;
2003-01-10 16:18:06 +01:00
2006-11-20 02:13:13 +01:00
// Nom
2007-09-08 11:02:22 +02:00
print '<tr><td>' . $langs -> trans ( " Lastname " ) . '</td><td class="valeur" colspan="2">' . $adh -> nom . ' </td>' ;
2007-05-21 00:53:11 +02:00
print '</tr>' ;
2003-03-07 19:53:17 +01:00
2006-11-20 02:13:13 +01:00
// Prenom
2007-09-08 11:02:22 +02:00
print '<tr><td>' . $langs -> trans ( " Firstname " ) . '</td><td class="valeur" colspan="2">' . $adh -> prenom . ' </td></tr>' ;
2003-03-07 19:53:17 +01:00
2006-11-20 02:13:13 +01:00
// Login
2007-09-08 11:02:22 +02:00
print '<tr><td>' . $langs -> trans ( " Login " ) . '</td><td class="valeur">' . $adh -> login . ' </td>' ;
$rowspan = 16 + sizeof ( $adho -> attribute_label );
print '<td rowspan="' . $rowspan . '" align="center" valign="middle" width="25%">' ;
if ( file_exists ( $conf -> adherent -> dir_output . " / " . $adh -> id . " .jpg " ))
{
print '<img width="100" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=memberphoto&file=' . $adh -> id . '.jpg">' ;
}
else
{
print '<img width="100" src="' . DOL_URL_ROOT . '/theme/common/nophoto.jpg">' ;
}
print '</td>' ;
print '</tr>' ;
2007-02-03 23:40:04 +01:00
// Password
print '<tr><td>' . $langs -> trans ( " Password " ) . '</td><td>' . eregi_replace ( '.' , '*' , $adh -> pass ) . '</td></tr>' ;
2006-11-20 02:13:13 +01:00
// Type
2007-02-28 00:06:18 +01:00
print '<tr><td>' . $langs -> trans ( " Type " ) . '</td><td class="valeur">' . $adht -> getNomUrl ( 1 ) . " </td></tr> \n " ;
2006-11-26 03:59:09 +01:00
// Morphy
2006-04-01 04:07:58 +02:00
print '<tr><td>' . $langs -> trans ( " Person " ) . '</td><td class="valeur">' . $adh -> getmorphylib () . '</td></tr>' ;
2002-12-30 17:29:21 +01:00
2006-11-26 03:59:09 +01:00
// Tiers
2004-09-25 13:02:10 +02:00
print '<tr><td>' . $langs -> trans ( " Company " ) . '</td><td class="valeur">' . $adh -> societe . ' </td></tr>' ;
2006-11-26 03:59:09 +01:00
// Adresse
2004-09-25 13:02:10 +02:00
print '<tr><td>' . $langs -> trans ( " Address " ) . '</td><td class="valeur">' . nl2br ( $adh -> adresse ) . ' </td></tr>' ;
2006-11-26 03:59:09 +01:00
// CP / Ville
2004-09-25 13:02:10 +02:00
print '<tr><td>' . $langs -> trans ( " Zip " ) . ' / ' . $langs -> trans ( " Town " ) . '</td><td class="valeur">' . $adh -> cp . ' ' . $adh -> ville . ' </td></tr>' ;
2006-11-26 08:00:14 +01:00
2006-11-26 03:59:09 +01:00
// Pays
2008-01-11 11:25:26 +01:00
print '<tr><td>' . $langs -> trans ( " Country " ) . '</td><td class="valeur">' . getCountryLabel ( $adh -> pays_id ) . '</td></tr>' ;
2006-11-26 03:59:09 +01:00
// Tel pro.
print '<tr><td>' . $langs -> trans ( " PhonePro " ) . '</td><td class="valeur">' . $adh -> phone . '</td></tr>' ;
// Tel perso
print '<tr><td>' . $langs -> trans ( " PhonePerso " ) . '</td><td class="valeur">' . $adh -> phone_perso . '</td></tr>' ;
// Tel mobile
print '<tr><td>' . $langs -> trans ( " PhoneMobile " ) . '</td><td class="valeur">' . $adh -> phone_mobile . '</td></tr>' ;
// EMail
2007-09-08 11:02:22 +02:00
print '<tr><td>' . $langs -> trans ( " EMail " ) . '</td><td class="valeur">' . $adh -> email . ' </td></tr>' ;
2006-11-26 03:59:09 +01:00
// Date naissance
2006-11-26 19:24:53 +01:00
print '<tr><td>' . $langs -> trans ( " Birthday " ) . '</td><td class="valeur">' . dolibarr_print_date ( $adh -> naiss , 'day' ) . ' </td></tr>' ;
2006-11-26 03:59:09 +01:00
// Public
2006-11-26 08:00:14 +01:00
print '<tr><td>' . $langs -> trans ( " Public " ) . '</td><td class="valeur">' . yn ( $adh -> public ) . '</td></tr>' ;
2006-11-26 03:59:09 +01:00
// Status
2006-03-18 00:27:30 +01:00
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td class="valeur">' . $adh -> getLibStatut ( 4 ) . '</td></tr>' ;
2007-04-27 00:01:10 +02:00
// Login Dolibarr
print '<tr><td>' . $langs -> trans ( " DolibarrLogin " ) . '</td><td class="valeur">' ;
if ( $adh -> user_id )
{
$dolibarr_user = new User ( $db );
$dolibarr_user -> id = $adh -> user_id ;
$result = $dolibarr_user -> fetch ();
print $dolibarr_user -> getLoginUrl ( 1 );
}
else print $langs -> trans ( " NoDolibarrAccess " );
print '</td></tr>' ;
2005-03-05 19:45:40 +01:00
2006-11-26 03:59:09 +01:00
// Autres attributs
2008-10-14 02:16:28 +02:00
foreach ( $adho -> attribute_label as $key => $value )
{
2005-03-05 19:45:40 +01:00
print " <tr><td> $value </td><td> " . $adh -> array_options [ " options_ $key " ] . " </td></tr> \n " ;
2004-11-12 15:37:38 +01:00
}
2005-03-05 19:45:40 +01:00
print " </table> \n " ;
2006-11-20 02:13:13 +01:00
print '</form>' ;
2005-03-05 19:45:40 +01:00
print " </div> \n " ;
2004-07-17 01:35:53 +02:00
2005-03-05 19:45:40 +01:00
/*
* Barre d ' actions
*
*/
print '<div class="tabsAction">' ;
2008-04-07 17:32:24 +02:00
// Modify
if ( $user -> rights -> adherent -> creer || ( $user -> rights -> adherent -> self -> creer && $adh -> user_id == $user -> id ))
2006-11-19 18:16:39 +01:00
{
2008-01-11 00:59:58 +01:00
print " <a class= \" butAction \" href= \" fiche.php?rowid= $rowid &action=edit \" > " . $langs -> trans ( " Modify " ) . " </a> " ;
2004-07-17 01:35:53 +02:00
}
2008-01-25 18:40:07 +01:00
else
{
print " <font class= \" butActionRefused \" href= \" # \" > " . $langs -> trans ( " Modify " ) . " </font> " ;
}
2007-05-26 04:18:06 +02:00
2008-01-25 18:40:07 +01:00
// Valider
if ( $adh -> statut == - 1 )
2007-05-26 04:18:06 +02:00
{
2008-01-25 18:40:07 +01:00
if ( $user -> rights -> adherent -> creer )
{
print " <a class= \" butAction \" href= \" fiche.php?rowid= $rowid &action=valid \" > " . $langs -> trans ( " Validate " ) . " </a> \n " ;
}
else
{
print " <font class= \" butActionRefused \" href= \" # \" > " . $langs -> trans ( " Validate " ) . " </font> " ;
}
2007-05-26 04:18:06 +02:00
}
2008-01-25 18:40:07 +01:00
// Reactiver
if ( $adh -> statut == 0 )
2007-05-26 04:18:06 +02:00
{
2008-01-25 18:40:07 +01:00
if ( $user -> rights -> adherent -> creer )
{
2007-05-26 04:18:06 +02:00
print " <a class= \" butAction \" href= \" fiche.php?rowid= $rowid &action=valid \" > " . $langs -> trans ( " Reenable " ) . " </a> \n " ;
}
2008-01-25 18:40:07 +01:00
else
{
print " <font class= \" butActionRefused \" href= \" # \" > " . $langs -> trans ( " Reenable " ) . " </font> " ;
}
2007-05-26 04:18:06 +02:00
}
2008-01-25 18:40:07 +01:00
// Envoi fiche par mail
if ( $adh -> statut >= 1 && $adh -> email )
2007-05-26 04:18:06 +02:00
{
2008-01-25 18:40:07 +01:00
if ( $user -> rights -> adherent -> creer )
2007-05-26 04:18:06 +02:00
{
print " <a class= \" butAction \" href= \" fiche.php?rowid= $adh->id &action=sendinfo \" > " . $langs -> trans ( " SendCardByMail " ) . " </a> \n " ;
}
2008-01-25 18:40:07 +01:00
else
{
print " <font class= \" butActionRefused \" href= \" # \" > " . $langs -> trans ( " SendCardByMail " ) . " </font> " ;
}
2007-05-26 04:18:06 +02:00
}
2008-01-25 18:40:07 +01:00
// Resilier
if ( $adh -> statut >= 1 )
2007-05-26 04:18:06 +02:00
{
2008-01-25 18:40:07 +01:00
if ( $user -> rights -> adherent -> supprimer )
{
2007-05-26 04:18:06 +02:00
print " <a class= \" butAction \" href= \" fiche.php?rowid= $rowid &action=resign \" > " . $langs -> trans ( " Resiliate " ) . " </a> \n " ;
}
2008-01-25 18:40:07 +01:00
else
{
print " <font class= \" butActionRefused \" href= \" # \" > " . $langs -> trans ( " Resiliate " ) . " </font> " ;
}
2007-05-26 04:18:06 +02:00
}
2008-04-07 17:32:24 +02:00
// Create user
2008-01-25 18:40:07 +01:00
if ( ! $user -> societe_id && ! $adh -> user_id )
2007-04-27 00:01:10 +02:00
{
2008-01-25 18:40:07 +01:00
if ( $user -> rights -> user -> user -> creer )
2007-04-27 00:01:10 +02:00
{
2008-01-25 18:40:07 +01:00
print '<a class="butAction" href="fiche.php?rowid=' . $adh -> id . '&action=create_user">' . $langs -> trans ( " CreateDolibarrLogin " ) . '</a>' ;
}
else
{
print " <font class= \" butActionRefused \" href= \" # \" > " . $langs -> trans ( " CreateDolibarrLogin " ) . " </font> " ;
2007-04-27 00:01:10 +02:00
}
}
2005-03-05 19:45:40 +01:00
// Supprimer
2006-11-19 18:30:11 +01:00
if ( $user -> rights -> adherent -> supprimer )
{
2005-08-11 20:24:58 +02:00
print " <a class= \" butActionDelete \" href= \" fiche.php?rowid= $adh->id &action=delete \" > " . $langs -> trans ( " Delete " ) . " </a> \n " ;
2004-11-12 15:37:38 +01:00
}
2008-01-25 18:40:07 +01:00
else
{
print " <font class= \" butActionRefused \" href= \" # \" > " . $langs -> trans ( " Delete " ) . " </font> " ;
}
2005-03-05 19:45:40 +01:00
// Action SPIP
2006-04-01 04:07:58 +02:00
if ( $conf -> global -> ADHERENT_USE_SPIP )
2002-12-30 17:29:21 +01:00
{
2005-03-05 19:45:40 +01:00
$isinspip = $adh -> is_in_spip ();
if ( $isinspip == 1 )
{
2007-05-26 20:16:58 +02:00
print " <a class= \" butAction \" href= \" fiche.php?rowid= $adh->id &action=del_spip \" >Suppression dans Spip</a> \n " ;
2005-03-05 19:45:40 +01:00
}
if ( $isinspip == 0 )
{
2007-05-26 20:16:58 +02:00
print " <a class= \" butAction \" href= \" fiche.php?rowid= $adh->id &action=add_spip \" >Ajout dans Spip</a> \n " ;
2005-03-05 19:45:40 +01:00
}
if ( $isinspip == - 1 ) {
2006-11-19 18:16:39 +01:00
print '<br><font class="error">Failed to connect to SPIP: ' . $adh -> error . '</font>' ;
2005-03-05 19:45:40 +01:00
}
2004-07-17 01:35:53 +02:00
}
2005-03-05 19:45:40 +01:00
print '</div>' ;
print " <br> \n " ;
/*
* Bandeau des cotisations
*
*/
print '<table border=0 width="100%">' ;
print '<tr>' ;
2006-11-26 22:17:26 +01:00
print '<td valign="top" width="50%">' ;
2005-03-05 19:45:40 +01:00
2006-11-26 22:17:26 +01:00
print '</td><td valign="top">' ;
2004-07-17 01:35:53 +02:00
2005-03-05 19:45:40 +01:00
print '</td></tr>' ;
print '</table>' ;
2004-07-17 01:35:53 +02:00
}
2002-12-28 19:12:22 +01:00
$db -> close ();
2005-04-16 15:10:06 +02:00
llxFooter ( '$Date$ - $Revision$' );
2002-12-28 19:12:22 +01:00
?>