* Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * * 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. */ /** * \file htdocs/adherents/fiche.php * \ingroup member * \brief Page of member * \version $Id$ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_options.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); $langs->load("companies"); $langs->load("bills"); $langs->load("members"); $langs->load("users"); // Security check if (! $user->rights->adherent->lire) accessforbidden(); $adh = new Adherent($db); $adho = new AdherentOptions($db); $errmsg=''; $action=GETPOST("action"); $rowid=GETPOST("rowid"); $typeid=GETPOST("typeid"); if ($rowid) { // Load member $result = $adh->fetch($rowid); // Define variables to know what current user can do on users $canadduser=($user->admin || $user->rights->user->user->creer); // Define variables to know what current user can do on properties of user linked to edited member if ($adh->user_id) { // $user est le user qui edite, $adh->user_id est l'id de l'utilisateur lies au membre edite $caneditfielduser=( (($user->id == $adh->user_id) && $user->rights->user->self->creer) || (($user->id != $adh->user_id) && $user->rights->user->user->creer) ); $caneditpassworduser=( (($user->id == $adh->user_id) && $user->rights->user->self->password) || (($user->id != $adh->user_id) && $user->rights->user->user->password) ); } } // Define variables to know what current user can do on members $canaddmember=$user->rights->adherent->creer; // Define variables to know what current user can do on properties of a member if ($rowid) { $caneditfieldmember=$user->rights->adherent->creer; } /* * Actions */ if ($_POST['action'] == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { $error=0; if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only { if ($_POST["userid"] != $user->id && $_POST["userid"] != $adh->user_id) { $error++; $mesg='
'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'
'; } } if (! $error) { if ($_POST["userid"] != $adh->user_id) // If link differs from currently in database { $result=$adh->setUserId($_POST["userid"]); if ($result < 0) dol_print_error($adh->db,$adh->error); $_POST['action']=''; $action=''; } } } if ($_POST['action'] == 'setsocid') { $error=0; if (! $error) { if ($_POST["socid"] != $adh->fk_soc) // If link differs from currently in database { $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; $sql.=" WHERE fk_soc = '".$_POST["socid"]."'"; $sql.=" AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj && $obj->rowid > 0) { $othermember=new Adherent($db); $othermember->fetch($obj->rowid); $thirdparty=new Societe($db); $thirdparty->fetch($_POST["socid"]); $error++; $errmsg='
'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->nom).'
'; } } if (! $error) { $result=$adh->setThirdPartyId($_POST["socid"]); if ($result < 0) dol_print_error($adh->db,$adh->error); $_POST['action']=''; $action=''; } } } } // Create user from a member if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer) { if ($result > 0) { // Creation user $nuser = new User($db); $result=$nuser->create_from_member($adh,$_POST["login"]); if ($result < 0) { $langs->load("errors"); $errmsg=$langs->trans($nuser->error); } } else { $errmsg=$adh->error; } } // Create third party from a member if ($_POST["action"] == 'confirm_create_thirdparty' && $_POST["confirm"] == 'yes' && $user->rights->societe->creer) { if ($result > 0) { // Creation user $company = new Societe($db); $result=$company->create_from_member($adh,$_POST["companyname"]); if ($result < 0) { $langs->load("errors"); $errmsg=$langs->trans($company->error); $errmsgs=$company->errors; } } else { $errmsg=$adh->error; } } if ($_REQUEST["action"] == 'confirm_sendinfo' && $_REQUEST["confirm"] == 'yes') { if ($adh->email) { $result=$adh->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent")); $mesg=$langs->trans("CardSent"); } } if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) { require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); $datenaiss=''; if (isset($_POST["naissday"]) && $_POST["naissday"] && isset($_POST["naissmonth"]) && $_POST["naissmonth"] && isset($_POST["naissyear"]) && $_POST["naissyear"]) { $datenaiss=dol_mktime(12, 0, 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]); } // Create new object if ($result > 0) { $adh->oldcopy=dol_clone($adh); // Change values $adh->civilite_id = trim($_POST["civilite_id"]); $adh->prenom = trim($_POST["prenom"]); $adh->nom = trim($_POST["nom"]); $adh->login = trim($_POST["login"]); $adh->pass = trim($_POST["pass"]); $adh->societe = trim($_POST["societe"]); $adh->adresse = trim($_POST["address"]); // deprecated $adh->address = trim($_POST["address"]); $adh->cp = trim($_POST["zipcode"]); // deprecated $adh->zip = trim($_POST["zipcode"]); $adh->ville = trim($_POST["town"]); // deprecated $adh->town = trim($_POST["town"]); $adh->fk_departement = $_POST["departement_id"]; $adh->pays_id = $_POST["pays_id"]; $adh->phone = trim($_POST["phone"]); $adh->phone_perso = trim($_POST["phone_perso"]); $adh->phone_mobile= trim($_POST["phone_mobile"]); $adh->email = trim($_POST["email"]); $adh->naiss = $datenaiss; $adh->typeid = $_POST["typeid"]; $adh->note = trim($_POST["comment"]); $adh->morphy = $_POST["morphy"]; $adh->amount = $_POST["amount"]; $adh->photo = ($_FILES['photo']['name']?$_FILES['photo']['name']:$adh->oldcopy->photo); // Get status and public property $adh->statut = $_POST["statut"]; $adh->public = $_POST["public"]; foreach($_POST as $key => $value) { if (preg_match("/^options_/",$key)) { //escape values from POST, at least with $db->escape, to avoid obvious SQL injections //(array_options is directly input in the DB in adherent.class.php::update()) $adh->array_options[$key]=$db->escape($_POST[$key]); } } // Check if we need to also synchronize user information $nosyncuser=0; if ($adh->user_id) // If linked to a user { if ($user->id != $adh->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1; // Disable synchronizing } // Check if we need to also synchronize password information $nosyncuserpass=0; if ($adh->user_id) // If linked to a user { if ($user->id != $adh->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1; // Disable synchronizing } $result=$adh->update($user,0,$nosyncuser,$nosyncuserpass); if ($result >= 0 && ! sizeof($adh->errors)) { if (!empty($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { $dir= $conf->adherent->dir_output . '/' . get_exdir($adh->id,2,0,1).'/photos/'; create_exdir($dir); if (@is_dir($dir)) { $newfile=$dir.'/'.$_FILES['photo']['name']; if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0) { $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; } else { // Create small thumbs for company (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); // Create mini thumbs for company (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); } } } $_GET["rowid"]=$adh->id; $_REQUEST["action"]=''; } else { if ($adh->error) $errmsg=$adh->error; else $errmsgs=$adh->errors; $action=''; } } } if ($_POST["action"] == 'add' && $user->rights->adherent->creer) { $datenaiss=''; if (isset($_POST["naissday"]) && $_POST["naissday"] && isset($_POST["naissmonth"]) && $_POST["naissmonth"] && isset($_POST["naissyear"]) && $_POST["naissyear"]) { $datenaiss=dol_mktime(12, 0, 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]); } $datecotisation=''; if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) { $datecotisation=dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); } $typeid=$_POST["typeid"]; $civilite_id=$_POST["civilite_id"]; $nom=$_POST["nom"]; $prenom=$_POST["prenom"]; $societe=$_POST["societe"]; $address=$_POST["address"]; $zip=$_POST["zipcode"]; $town=$_POST["town"]; $departement_id=$_POST["departement_id"]; $pays_id=$_POST["pays_id"]; $phone=$_POST["phone"]; $phone_perso=$_POST["phone_perso"]; $phone_mobile=$_POST["phone_mobile"]; $email=$_POST["member_email"]; $login=$_POST["member_login"]; $pass=$_POST["password"]; $photo=$_POST["photo"]; $comment=$_POST["comment"]; $morphy=$_POST["morphy"]; $cotisation=$_POST["cotisation"]; $public=$_POST["public"]; $userid=$_POST["userid"]; $socid=$_POST["socid"]; $adh->civilite_id = $civilite_id; $adh->prenom = $prenom; $adh->nom = $nom; $adh->societe = $societe; $adh->adresse = $address; // deprecated $adh->address = $address; $adh->cp = $zip; // deprecated $adh->zip = $zip; $adh->ville = $town; // deprecated $adh->town = $town; $adh->fk_departement = $departement_id; $adh->pays_id = $pays_id; $adh->phone = $phone; $adh->phone_perso = $phone_perso; $adh->phone_mobile= $phone_mobile; $adh->email = $email; $adh->login = $login; $adh->pass = $pass; $adh->naiss = $datenaiss; $adh->photo = $photo; $adh->typeid = $typeid; $adh->note = $comment; $adh->morphy = $morphy; $adh->user_id = $userid; $adh->fk_soc = $socid; $adh->public = $public; // Check parameters if (empty($morphy) || $morphy == "-1") { $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature"))."
\n"; } // Test si le login existe deja if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($login)) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->trans("Login"))."
\n"; } else { $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); } if ($num) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorLoginAlreadyExists",$login)."
\n"; } } if (empty($pass)) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Password"))."
\n"; } } if (empty($nom)) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."
\n"; } if ($morphy != 'mor' && (!isset($prenom) || $prenom=='')) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."
\n"; } if (! ($typeid > 0)) { // Keep () before ! $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"))."
\n"; } if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadEMail",$email)."
\n"; } $public=0; if (isset($public)) $public=1; if (! $error) { $db->begin(); // Email a peu pres correct et le login n'existe pas $result=$adh->create($user); if ($result > 0) { $db->commit(); $rowid=$adh->id; $action=''; } else { $db->rollback(); if ($adh->error) $errmsg=$adh->error; else $errmsgs=$adh->errors; $action = 'create'; } } else { $action = 'create'; } } if ($user->rights->adherent->supprimer && $_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes') { $result=$adh->delete($rowid); if ($result > 0) { Header("Location: liste.php"); exit; } else { $errmesg=$adh->error; } } if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes') { $result=$adh->validate($user); $adht = new AdherentType($db); $adht->fetch($adh->typeid); if ($result >= 0 && ! sizeof($adh->errors)) { // Send confirmation Email (selon param du type adherent sinon generique) if ($adh->email && $_POST["send_mail"]) { $result=$adh->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2); if ($result < 0) { $errmsg.=$adh->error; } } // 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."
\n"; } } else { if ($adh->error) $errmsg=$adh->error; else $errmsgs=$adh->errors; $action=''; } } if ($user->rights->adherent->supprimer && $_POST["action"] == 'confirm_resign' && $_POST["confirm"] == 'yes') { $result=$adh->resiliate($user); $adht = new AdherentType($db); $adht->fetch($adh->typeid); if ($result >= 0 && ! sizeof($adh->errors)) { if ($adh->email && $_POST["send_mail"]) { $result=$adh->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1); } if ($result < 0) { $errmsg.=$adh->error; } // 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."
\n"; } } else { if ($adh->error) $errmsg=$adh->error; else $errmsgs=$adh->errors; $action=''; } } if ($user->rights->adherent->supprimer && $_POST["action"] == 'confirm_del_spip' && $_POST["confirm"] == 'yes') { if (! sizeof($adh->errors)) { if(!$adh->del_to_spip()){ $errmsg.="Echec de la suppression de l'utilisateur dans spip: ".$adh->error."
\n"; } } } if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_add_spip' && $_POST["confirm"] == 'yes') { if (! sizeof($adh->errors)) { if (!$adh->add_to_spip()) { $errmsg.="Echec du rajout de l'utilisateur dans spip: ".$adh->error."
\n"; } } } /* * View */ llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); $html = new Form($db); $htmlcompany = new FormCompany($db); // fetch optionals attributes and labels $adho->fetch_name_optionals_label(); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($action == 'create') { /* ************************************************************************** */ /* */ /* Fiche creation */ /* */ /* ************************************************************************** */ $adh->fk_departement = $_POST["departement_id"]; // We set pays_id, pays_code and label for the selected country $adh->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; if ($adh->pays_id) { $sql = "SELECT rowid, code, libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; $sql.= " WHERE rowid = ".$adh->pays_id; $resql=$db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); } else { dol_print_error($db); } $adh->pays_id=$obj->rowid; $adh->pays_code=$obj->code; $adh->pays=$obj->libelle; } $adht = new AdherentType($db); print_fiche_titre($langs->trans("NewMember")); dol_htmloutput_errors($errmsg,$errmsgs); dol_htmloutput_mesg($mesg,$mesgs); if ($conf->use_javascript_ajax) { print "\n".''."\n"; } print '
'; print ''; print ''; print ''; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; } // Moral-Physique $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); print '\n"; // Type print '\n"; // Company print ''; // Civility print ''; print ''; // Nom print ''; print ''; // Prenom print ''; print ''; // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { include_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php'); $generated_password=getRandomPassword(''); print ''; } // Address print ''; // Zip / Town print ''; // Country $adh->pays_id=$adh->pays_id?$adh->pays_id:$mysoc->pays_id; print ''; // State if (empty($conf->global->MEMBER_DISABLE_STATE)) { print ''; } // Tel pro print ''; // Tel perso print ''; // Tel mobile print ''; // EMail print ''; // Date naissance print "\n"; // Profil public print "\n"; // Attribut optionnels foreach($adho->attribute_label as $key=>$value) { print "'."\n"; } /* // Third party Dolibarr if ($conf->societe->enabled) { print ''; } // Login Dolibarr print ''; */ print "
'.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">
'.$langs->trans("Nature")."\n"; print $html->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy, 1); print "
'.$langs->trans("MemberType").''; $listetype=$adht->liste_array(); if (sizeof($listetype)) { print $html->selectarray("typeid", $listetype, isset($_POST["typeid"])?$_POST["typeid"]:$typeid, 1); } else { print ''.$langs->trans("NoTypeDefinedGoToSetup").''; } print "
'.$langs->trans("Company").'societe).'">
'.$langs->trans("UserTitle").''; print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id,'civilite_id').'
'.$langs->trans("Lastname").'nom).'" size="40">
'.$langs->trans("Firstname").'prenom).'">
'.$langs->trans("Password").''; print ''; print '
'.$langs->trans("Address").''; print ''; print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; print $htmlcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$adh->zip),'zipcode',array('town','selectpays_id','departement_id'),6); print ' '; print $htmlcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$adh->town),'town',array('zipcode','selectpays_id','departement_id')); print '
'.$langs->trans('Country').''; $html->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$adh->pays_id,'pays_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print '
'.$langs->trans('State').''; if ($adh->pays_id) { $htmlcompany->select_departement(isset($_POST["departement_id"])?$_POST["departement_id"]:$adh->fk_departement,$adh->pays_code); } else { print $countrynotdefined; } print '
'.$langs->trans("PhonePro").'phone).'">
'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'phone_mobile).'">
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">
".$langs->trans("Birthday")."\n"; $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'formsoc'); print "
".$langs->trans("Public")."\n"; print $html->selectyesno("public",$adh->public,1); print "
".$value.'
'.$langs->trans("LinkedToDolibarrThirdParty").''; print $html->select_societes($adh->fk_soc,'socid','',1); print '
'.$langs->trans("LinkedToDolibarrUser").''; print $html->select_users($adh->user_id,'userid',1); print '
\n"; print '
'; print '
'; print "
\n"; } 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_name_optionals_label(); $adht = new AdherentType($db); $adht->fetch($adh->typeid); // We set pays_id, and pays_code label of the chosen country if (isset($_POST["pays"]) || $adh->pays_id) { $sql = "SELECT rowid, code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays"])?$_POST["pays"]:$adh->pays_id); $resql=$db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); } else { dol_print_error($db); } $adh->pays_id=$obj->rowid; $adh->pays_code=$obj->code; $adh->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } $head = member_prepare_head($adh); dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); dol_htmloutput_errors($errmsg,$errmsgs); if ($mesg) print '
'.$mesg.'
'; if ($conf->use_javascript_ajax) { print "\n".''."\n"; } $rowspan=17; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1; $rowspan+=sizeof($adho->attribute_label); if ($conf->societe->enabled) $rowspan++; print '
'; print ''; print ""; print ""; print "statut."\">"; print ''; // Ref print ''; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; } // Physique-Moral $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Morale"); print '"; // Photo print ''; // Type print '"; // Company print ''; // Civilite print ''; print ''; // Name print ''; print ''; // Firstname print ''; print ''; // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; } // Address print ''; // Zip / Town print ''; // Country $adh->pays_id=$adh->pays_id?$adh->pays_id:$mysoc->pays_id; print ''; // State if (empty($conf->global->MEMBER_DISABLE_STATE)) { print ''; } // Tel print ''; // Tel perso print ''; // Tel mobile print ''; // EMail print ''; // Date naissance print "\n"; // Profil public print "\n"; // Attributs supplementaires foreach($adho->attribute_label as $key=>$value) { print "\n"; } // Third party Dolibarr if ($conf->societe->enabled) { print ''; } // Login Dolibarr print ''; print ''; print '
'.$langs->trans("Ref").''.$adh->id.'
'.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">
'.$langs->trans("Nature").''; print $html->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy); print "'; print $html->showphoto('memberphoto',$adh)."\n"; if ($caneditfieldmember) { print '

'; print '
'.$langs->trans("PhotoFile").'
'; print ''; print '
'; } print '
'.$langs->trans("Type").''; if ($user->rights->adherent->creer) { print $html->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$adh->typeid)); } else { print $adht->getNomUrl(1); print ''; } print "
'.$langs->trans("Company").'societe).'">
'.$langs->trans("UserTitle").''; print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id)."\n"; print '
'.$langs->trans("Lastname").'nom).'">
'.$langs->trans("Firstname").'prenom).'">
'.$langs->trans("Password").'pass).'">
'.$langs->trans("Address").''; print ''; print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; print $htmlcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$adh->zip),'zipcode',array('town','selectpays_id','departement_id'),6); print ' '; print $htmlcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$adh->town),'town',array('zipcode','selectpays_id','departement_id')); print '
'.$langs->trans('Country').''; $html->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$adh->pays_id,'pays_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print '
'.$langs->trans('State').''; $htmlcompany->select_departement($adh->fk_departement,$adh->pays_code); print '
'.$langs->trans("PhonePro").'phone).'">
'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'phone_mobile).'">
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">
".$langs->trans("Birthday")."\n"; $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'formsoc'); print "
".$langs->trans("Public")."\n"; print $html->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$adh->public),1); print "
$valuearray_options["options_$key"]."\">
'.$langs->trans("LinkedToDolibarrThirdParty").''; if ($adh->fk_soc) { $company=new Societe($db); $result=$company->fetch($adh->fk_soc); print $company->getNomUrl(1); } else { print $langs->trans("NoThirdPartyAssociatedToMember"); } print '
'.$langs->trans("LinkedToDolibarrUser").''; if ($adh->user_id) { print $html->form_users($_SERVER['PHP_SELF'].'?rowid='.$adh->id,$adh->user_id,'none'); } else print $langs->trans("NoDolibarrAccess"); print '
'; print ''; print '       '; print ''; print '
'; print '
'; print ''; } if ($rowid && $action != 'edit') { /* ************************************************************************** */ /* */ /* Mode affichage */ /* */ /* ************************************************************************** */ $adh = new Adherent($db); $res=$adh->fetch($rowid); if ($res < 0) dol_print_error($db); $res=$adh->fetch_optionals($rowid); if ($res < 0) dol_print_error($db); $adht = new AdherentType($db); $res=$adht->fetch($adh->typeid); if ($res < 0) dol_print_error($db); /* * Affichage onglets */ $head = member_prepare_head($adh); dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); dol_htmloutput_errors($errmsg,$errmsgs); // Confirm create user if ($_GET["action"] == 'create_user') { $login=$adh->login; if (empty($login)) { // Full firstname and name separated with a dot : firstname.name include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php'); $login=dol_buildlogin($adh->nom,$adh->prenom); } if (empty($login)) $login=strtolower(substr($adh->prenom, 0, 4)) . strtolower(substr($adh->nom, 0, 4)); // Create a form array $formquestion=array( array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login) ); $text=$langs->trans("ConfirmCreateLogin").'
'; if ($conf->societe->enabled) { if ($adh->fk_soc > 0) $text.=$langs->trans("UserWillBeExternalUser"); else $text.=$langs->trans("UserWillBeInternalUser"); } $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$adh->id,$langs->trans("CreateDolibarrLogin"),$text,"confirm_create_user",$formquestion,'yes'); if ($ret == 'html') print '
'; } // Confirm create third party if ($_GET["action"] == 'create_thirdparty') { $name = $adh->getFullName($langs); if (! empty($name)) { if ($adh->societe) $name.=' ('.$adh->societe.')'; } else { $name=$adh->societe; } // Create a form array $formquestion=array( array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name)); $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$adh->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); if ($ret == 'html') print '
'; } // Confirm validate member if ($action == 'valid') { $langs->load("mails"); $adht = new AdherentType($db); $adht->fetch($adh->typeid); $subjecttosend=$adh->makeSubstitution($conf->global->ADHERENT_MAIL_VALID_SUBJECT); $texttosend=$adh->makeSubstitution($adht->getMailOnValid()); $tmp=$langs->trans("SendAnEMailToMember"); $tmp.=' ('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; $tmp.=$langs->trans("MailRecipient").': '.$adh->email.')'; $helpcontent=''; $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; $helpcontent.=''.$langs->trans("MailRecipient").': '.$adh->email.'
'."\n"; $helpcontent.=''.$langs->trans("Subject").':
'."\n"; $helpcontent.=$subjecttosend."\n"; $helpcontent.="
"; $helpcontent.=''.$langs->trans("Content").':
'; $helpcontent.=dol_htmlentitiesbr($texttosend)."\n"; $label=$html->textwithpicto($tmp,$helpcontent,1,'help'); // Cree un tableau formulaire $formquestion=array(); if ($adh->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false)); $ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1); if ($ret == 'html') print '
'; } // Confirm send card by mail if ($action == 'sendinfo') { $ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$adh->email),"confirm_sendinfo",'',0,1); if ($ret == 'html') print '
'; } // Confirm resiliate if ($action == 'resign') { $langs->load("mails"); $adht = new AdherentType($db); $adht->fetch($adh->typeid); $subjecttosend=$adh->makeSubstitution($conf->global->ADHERENT_MAIL_RESIL_SUBJECT); $texttosend=$adh->makeSubstitution($adht->getMailOnResiliate()); $tmp=$langs->trans("SendAnEMailToMember"); $tmp.=' ('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; $tmp.=$langs->trans("MailRecipient").': '.$adh->email.')'; $helpcontent=''; $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; $helpcontent.=''.$langs->trans("MailRecipient").': '.$adh->email.'
'."\n"; $helpcontent.=''.$langs->trans("Subject").':
'."\n"; $helpcontent.=$subjecttosend."\n"; $helpcontent.="
"; $helpcontent.=''.$langs->trans("Content").':
'; $helpcontent.=dol_htmlentitiesbr($texttosend)."\n"; $label=$html->textwithpicto($tmp,$helpcontent,1,'help'); // Cree un tableau formulaire $formquestion=array(); if ($adh->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?'true':'false')); $ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion); if ($ret == 'html') print '
'; } // Confirm remove member if ($action == 'delete') { $ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",'',0,1); if ($ret == 'html') print '
'; } /* * Confirm add in spip */ if ($action == 'add_spip') { $ret=$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"); if ($ret == 'html') print '
'; } /* * Confirm removed from spip */ if ($action == 'del_spip') { $ret=$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"); if ($ret == 'html') print '
'; } $rowspan=18+sizeof($adho->attribute_label); if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1; if ($conf->societe->enabled) $rowspan++; print ''; // Ref print ''; print ''; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; print ''; } // Morphy print ''; print ''; print ''; // Type print '\n"; // Company print ''; // Civility print ''; print ''; // Name print ''; print ''; // Firstname print ''; // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; } // Address print ''; // Zip / Town print ''; // Country print ''; // State print ''; // Tel pro. print ''; // Tel perso print ''; // Tel mobile print ''; // EMail print ''; // Date naissance print ''; // Public print ''; // Status print ''; // Other attributs foreach($adho->attribute_label as $key=>$value) { print "\n"; } // Third party Dolibarr if ($conf->societe->enabled) { print ''; } // Login Dolibarr print ''; print "
'.$langs->trans("Ref").''; print $html->showrefnav($adh,'rowid'); print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$adh->login.' 
'.$langs->trans("Nature").''.$adh->getmorphylib().''; print $html->showphoto('memberphoto',$adh); print '
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Company").''.$adh->societe.'
'.$langs->trans("UserTitle").''.$adh->getCivilityLabel().' 
'.$langs->trans("Lastname").''.$adh->nom.' 
'.$langs->trans("Firstname").''.$adh->prenom.' 
'.$langs->trans("Password").''.preg_replace('/./i','*',$adh->pass).'
'.$langs->trans("Address").''; dol_print_address($adh->address,'gmap','member',$adh->id); print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$adh->zip.' '.$adh->town.'
'.$langs->trans("Country").''; $img=picto_from_langcode($adh->pays_code); if ($img) print $img.' '; print getCountry($adh->pays_code); print '
'.$langs->trans('State').''.$adh->departement.'
'.$langs->trans("PhonePro").''.dol_print_phone($adh->phone,$adh->pays_code,0,$adh->fk_soc,1).'
'.$langs->trans("PhonePerso").''.dol_print_phone($adh->phone_perso,$adh->pays_code,0,$adh->fk_soc,1).'
'.$langs->trans("PhoneMobile").''.dol_print_phone($adh->phone_mobile,$adh->pays_code,0,$adh->fk_soc,1).'
'.$langs->trans("EMail").''.dol_print_email($adh->email,0,$adh->fk_soc,1).'
'.$langs->trans("Birthday").''.dol_print_date($adh->naiss,'day').'
'.$langs->trans("Public").''.yn($adh->public).'
'.$langs->trans("Status").''.$adh->getLibStatut(4).'
$value".$adh->array_options["options_$key"]." 
'; print ''; if ($_GET['action'] != 'editthirdparty' && $user->rights->adherent->creer) print ''; print '
'; print $langs->trans("LinkedToDolibarrThirdParty"); print 'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'
'; print '
'; if ($_GET['action'] == 'editthirdparty') { $htmlname='socid'; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print '
'; print $html->select_societes($adh->fk_soc,'socid','',1); print '
'; } else { if ($adh->fk_soc) { $company=new Societe($db); $result=$company->fetch($adh->fk_soc); print $company->getNomUrl(1); } else { print $langs->trans("NoThirdPartyAssociatedToMember"); } } print '
'; print ''; if ($_GET['action'] != 'editlogin' && $user->rights->adherent->creer) print ''; print '
'; print $langs->trans("LinkedToDolibarrUser"); print 'id.'">'.img_edit($langs->trans('SetLinkToUser'),1).'
'; print '
'; if ($_GET['action'] == 'editlogin') { /*$include=array(); if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only { $include=array($adh->user_id,$user->id); }*/ print $html->form_users($_SERVER['PHP_SELF'].'?rowid='.$adh->id,$adh->user_id,'userid',''); } else { if ($adh->user_id) { print $html->form_users($_SERVER['PHP_SELF'].'?rowid='.$adh->id,$adh->user_id,'none'); } else print $langs->trans("NoDolibarrAccess"); } print '
\n"; print "\n"; /* * Barre d'actions * */ print '
'; if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty') { // Modify if ($user->rights->adherent->creer) { print "".$langs->trans("Modify").""; } else { print "trans("NotEnoughPermissions"))."\">".$langs->trans("Modify").""; } // Valider if ($adh->statut == -1) { if ($user->rights->adherent->creer) { print "".$langs->trans("Validate")."\n"; } else { print "trans("NotEnoughPermissions"))."\">".$langs->trans("Validate").""; } } // Reactiver if ($adh->statut == 0) { if ($user->rights->adherent->creer) { print "".$langs->trans("Reenable")."\n"; } else { print "trans("NotEnoughPermissions"))."\">".$langs->trans("Reenable").""; } } // Envoi fiche par mail if ($adh->statut >= 1) { if ($user->rights->adherent->creer) { if ($adh->email) print "id&action=sendinfo\">".$langs->trans("SendCardByMail")."\n"; else print "trans("NoEMail"))."\">".$langs->trans("SendCardByMail")."\n"; } else { print "trans("NotEnoughPermissions"))."\">".$langs->trans("SendCardByMail").""; } } // Resilier if ($adh->statut >= 1) { if ($user->rights->adherent->supprimer) { print "".$langs->trans("Resiliate")."\n"; } else { print "trans("NotEnoughPermissions"))."\">".$langs->trans("Resiliate").""; } } // Create third party if ($conf->societe->enabled && ! $adh->fk_soc) { if ($user->rights->societe->creer) { if ($adh->statut != -1) print ''.$langs->trans("CreateDolibarrThirdParty").''; else print ''.$langs->trans("CreateDolibarrThirdParty").''; } else { print "trans("NotEnoughPermissions"))."\">".$langs->trans("CreateDolibarrThirdParty").""; } } // Create user if (! $user->societe_id && ! $adh->user_id) { if ($user->rights->user->user->creer) { if ($adh->statut != -1) print ''.$langs->trans("CreateDolibarrLogin").''; else print ''.$langs->trans("CreateDolibarrLogin").''; } else { print "trans("NotEnoughPermissions"))."\">".$langs->trans("CreateDolibarrLogin").""; } } // Delete if ($user->rights->adherent->supprimer) { print "id&action=delete\">".$langs->trans("Delete")."\n"; } else { print "trans("NotEnoughPermissions"))."\">".$langs->trans("Delete").""; } // Action SPIP if ($conf->global->ADHERENT_USE_SPIP) { $isinspip=$adh->is_in_spip(); if ($isinspip == 1) { print "id&action=del_spip\">".$langs->trans("DeleteIntoSpip")."\n"; } if ($isinspip == 0) { print "id&action=add_spip\">".$langs->trans("AddIntoSpip")."\n"; } if ($isinspip == -1) { print '
Failed to connect to SPIP: '.$adh->error.''; } } } print '
'; print "
\n"; } $db->close(); llxFooter('$Date$ - $Revision$'); ?>