* Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Marcos GarcĂ­a * Copyright (C) 2012-2013 Philippe Grand * Copyright (C) 2015 Alexandre Spangaro * * 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 3 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, see . */ /** * \file htdocs/adherents/card.php * \ingroup member * \brief Page of member */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/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/cotisation.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.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"); $langs->load('other'); $action=GETPOST('action','alpha'); $cancel=GETPOST('cancel'); $backtopage=GETPOST('backtopage','alpha'); $confirm=GETPOST('confirm','alpha'); $rowid=GETPOST('rowid','int'); $typeid=GETPOST('typeid','int'); $userid=GETPOST('userid','int'); $socid=GETPOST('socid','int'); if (! empty($conf->mailmanspip->enabled)) { include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; $langs->load('mailmanspip'); $mailmanspip = new MailmanSpip($db); } $object = new Adherent($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($rowid); $canvas = $object->canvas?$object->canvas:GETPOST("canvas"); $objcanvas=null; if (! empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('adherent', 'membercard', $canvas); } // Security check $result=restrictedArea($user, 'adherent', $rowid, '', '', 'fk_soc', 'rowid', $objcanvas); if ($rowid > 0) { // Load member $result = $object->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 ($object->user_id) { // $user est le user qui edite, $object->user_id est l'id de l'utilisateur lies au membre edite $caneditfielduser=((($user->id == $object->user_id) && $user->rights->user->self->creer) || (($user->id != $object->user_id) && $user->rights->user->user->creer)); $caneditpassworduser=((($user->id == $object->user_id) && $user->rights->user->self->password) || (($user->id != $object->user_id) && $user->rights->user->user->password)); } } // Define variables to determine what the current user can do on the members $canaddmember=$user->rights->adherent->creer; // Define variables to determine what the current user can do on the properties of a member if ($rowid) { $caneditfieldmember=$user->rights->adherent->creer; } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('membercard','globalcard')); /* * Actions */ if ($cancel) $action=''; $parameters=array('rowid'=>$rowid, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { if ($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 ($userid != $user->id && $userid != $object->user_id) { $error++; setEventMessage($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), 'errors'); } } if (! $error) { if ($userid != $object->user_id) // If link differs from currently in database { $result=$object->setUserId($userid); if ($result < 0) dol_print_error($object->db,$object->error); $action=''; } } } if ($action == 'setsocid') { $error=0; if (! $error) { if ($socid != $object->fk_soc) // If link differs from currently in database { $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; $sql.=" WHERE fk_soc = '".$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($socid); $error++; setEventMessage($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), 'errors'); } } if (! $error) { $result=$object->setThirdPartyId($socid); if ($result < 0) dol_print_error($object->db,$object->error); $action=''; } } } } // Create user from a member if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) { if ($result > 0) { // Creation user $nuser = new User($db); $result=$nuser->create_from_member($object,GETPOST('login')); if ($result < 0) { $langs->load("errors"); setEventMessage($langs->trans($nuser->error), 'errors'); } } else { setEventMessage($object->error, 'errors'); } } // Create third party from a member if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { if ($result > 0) { // Creation user $company = new Societe($db); $result=$company->create_from_member($object,GETPOST('companyname')); if ($result < 0) { $langs->load("errors"); setEventMessage($langs->trans($company->error), 'errors'); setEventMessage($company->errors, 'errors'); } } else { setEventMessage($object->error, 'errors'); } } if ($action == 'confirm_sendinfo' && $confirm == 'yes') { if ($object->email) { $from=$conf->email_from; if (! empty($conf->global->ADHERENT_MAIL_FROM)) $from=$conf->global->ADHERENT_MAIL_FROM; $result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent")); $langs->load("mails"); setEventMessage($langs->trans("MailSuccessfulySent", $from, $object->email)); } } if ($action == 'update' && ! $cancel && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $birthdate=''; if (isset($_POST["birthday"]) && $_POST["birthday"] && isset($_POST["birthmonth"]) && $_POST["birthmonth"] && isset($_POST["birthyear"]) && $_POST["birthyear"]) { $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); } $lastname=$_POST["lastname"]; $firstname=$_POST["firstname"]; $morphy=$morphy=$_POST["morphy"]; if ($morphy != 'mor' && empty($lastname)) { $error++; $langs->load("errors"); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname")), 'errors'); } if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { $error++; $langs->load("errors"); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname")), 'errors'); } // Create new object if ($result > 0 && ! $error) { $object->oldcopy=dol_clone($object); // Change values $object->civility_id = trim($_POST["civility_id"]); $object->firstname = trim($_POST["firstname"]); $object->lastname = trim($_POST["lastname"]); $object->login = trim($_POST["login"]); $object->pass = trim($_POST["pass"]); $object->societe = trim($_POST["societe"]); $object->company = trim($_POST["societe"]); $object->address = trim($_POST["address"]); $object->zip = trim($_POST["zipcode"]); $object->town = trim($_POST["town"]); $object->state_id = $_POST["state_id"]; $object->country_id = $_POST["country_id"]; $object->phone = trim($_POST["phone"]); $object->phone_perso = trim($_POST["phone_perso"]); $object->phone_mobile= trim($_POST["phone_mobile"]); $object->email = trim($_POST["email"]); $object->skype = trim($_POST["skype"]); $object->birth = $birthdate; $object->typeid = $_POST["typeid"]; //$object->note = trim($_POST["comment"]); $object->morphy = $_POST["morphy"]; if (GETPOST('deletephoto')) $object->photo=''; elseif (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); // Get status and public property $object->statut = $_POST["statut"]; $object->public = $_POST["public"]; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; // Check if we need to also synchronize user information $nosyncuser=0; if ($object->user_id) // If linked to a user { if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1; // Disable synchronizing } // Check if we need to also synchronize password information $nosyncuserpass=0; if ($object->user_id) // If linked to a user { if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1; // Disable synchronizing } $result=$object->update($user,0,$nosyncuser,$nosyncuserpass); if ($result >= 0 && ! count($object->errors)) { // Categories association // First we delete all categories association $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_member'; $sql .= ' WHERE fk_member = ' . $object->id; $resql = $db->query($sql); if (! $resql) dol_print_error($db); // Then we add the associated categories $categories = GETPOST('memcats', 'array'); if (! empty($categories)) { $cat = new Categorie($db); foreach ($categories as $id_category) { $cat->fetch($id_category); $cat->add_type($object, 'member'); } } // Logo/Photo save $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1,$object,'member').'/photos'; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) { if (GETPOST('deletephoto')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'member').'/photos/'.$object->photo; $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'member').'/photos/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } if (image_format_supported($_FILES['photo']['name']) > 0) { dol_mkdir($dir); if (@is_dir($dir)) { $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0) { setEventMessage($langs->trans("ErrorFailedToSaveFile"), 'errors'); } 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); } } } else { setEventMessage("ErrorBadImageFormat", 'errors'); } } else { switch($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form $errors[] = "ErrorFileSizeTooLarge"; break; case 3: //uploaded file was only partially uploaded $errors[] = "ErrorFilePartiallyUploaded"; break; } } $rowid=$object->id; $action=''; if (! empty($backtopage)) { header("Location: ".$backtopage); exit; } } else { if ($object->error) { setEventMessage($object->error, 'errors'); } else { setEventMessage($object->errors, 'errors'); } $action=''; } } else { $action='edit'; } } if ($action == 'add' && $user->rights->adherent->creer) { if ($canvas) $object->canvas=$canvas; $birthdate=''; if (isset($_POST["birthday"]) && $_POST["birthday"] && isset($_POST["birthmonth"]) && $_POST["birthmonth"] && isset($_POST["birthyear"]) && $_POST["birthyear"]) { $birthdate=dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); } $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"]; $civility_id=$_POST["civility_id"]; $lastname=$_POST["lastname"]; $firstname=$_POST["firstname"]; $societe=$_POST["societe"]; $address=$_POST["address"]; $zip=$_POST["zipcode"]; $town=$_POST["town"]; $state_id=$_POST["state_id"]; $country_id=$_POST["country_id"]; $phone=$_POST["phone"]; $phone_perso=$_POST["phone_perso"]; $phone_mobile=$_POST["phone_mobile"]; $skype=$_POST["member_skype"]; $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"]; $object->civility_id = $civility_id; $object->firstname = $firstname; $object->lastname = $lastname; $object->societe = $societe; $object->address = $address; $object->zip = $zip; $object->town = $town; $object->state_id = $state_id; $object->country_id = $country_id; $object->phone = $phone; $object->phone_perso = $phone_perso; $object->phone_mobile= $phone_mobile; $object->skype = $skype; $object->email = $email; $object->login = $login; $object->pass = $pass; $object->birth = $birthdate; $object->photo = $photo; $object->typeid = $typeid; //$object->note = $comment; $object->morphy = $morphy; $object->user_id = $userid; $object->fk_soc = $socid; $object->public = $public; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; // Check parameters if (empty($morphy) || $morphy == "-1") { $error++; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature")), 'errors'); } // Test si le login existe deja if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($login)) { $error++; setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Login")), 'errors'); } 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"); setEventMessage($langs->trans("ErrorLoginAlreadyExists",$login), 'errors'); } } if (empty($pass)) { $error++; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Password")), 'errors'); } } if ($morphy != 'mor' && empty($lastname)) { $error++; $langs->load("errors"); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname")), 'errors'); } if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { $error++; $langs->load("errors"); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname")), 'errors'); } if (! ($typeid > 0)) { // Keep () before ! $error++; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); } if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) { $error++; $langs->load("errors"); setEventMessage($langs->trans("ErrorBadEMail",$email), 'errors'); } $public=0; if (isset($public)) $public=1; if (! $error) { $db->begin(); // Email a peu pres correct et le login n'existe pas $result=$object->create($user); if ($result > 0) { // Categories association $memcats = GETPOST('memcats', 'array'); if (! empty($memcats)) { $cat = new Categorie($db); foreach ($memcats as $id_category) { $cat->fetch($id_category); $cat->add_type($object, 'member'); } } $db->commit(); $rowid=$object->id; $action=''; } else { $db->rollback(); if ($object->error) { setEventMessage($object->error, 'errors'); } else { setEventMessage($object->errors, 'errors'); } $action = 'create'; } } else { $action = 'create'; } } if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { $result=$object->delete($rowid); if ($result > 0) { if (! empty($backtopage)) { header("Location: ".$backtopage); exit; } else { header("Location: list.php"); exit; } } else { $errmesg=$object->error; } } if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') { $error=0; $db->begin(); $adht = new AdherentType($db); $adht->fetch($object->typeid); $result=$object->validate($user); if ($result >= 0 && ! count($object->errors)) { // Send confirmation Email (selon param du type adherent sinon generique) if ($object->email && GETPOST("send_mail")) { $result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2); if ($result < 0) { $error++; setEventMessage($object->error, 'errors'); } } } else { $error++; if ($object->error) { setEventMessage($object->error, 'errors'); } else { setEventMessage($object->errors, 'errors'); } } if (! $error) { $db->commit(); } else { $db->rollback(); } $action=''; } if ($user->rights->adherent->supprimer && $action == 'confirm_resign') { $error = 0; if ($confirm == 'yes') { $adht = new AdherentType($db); $adht->fetch($object->typeid); $result=$object->resiliate($user); if ($result >= 0 && ! count($object->errors)) { if ($object->email && GETPOST("send_mail")) { $result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1); } if ($result < 0) { $error++; setEventMessage($object->error, 'errors'); } } else { $error++; if ($object->error) { setEventMessage($object->error, 'errors'); } else { setEventMessage($object->errors, 'errors'); } $action=''; } } if (! empty($backtopage) && ! $error) { header("Location: ".$backtopage); exit; } } // SPIP Management if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') { if (! count($object->errors)) { if (!$mailmanspip->del_to_spip($object)) { setEventMessage($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, 'errors'); } } } if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') { if (! count($object->errors)) { if (!$mailmanspip->add_to_spip($object)) { setEventMessage($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, 'errors'); } } } } /* * View */ $form = new Form($db); $formcompany = new FormCompany($db); $help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; llxHeader('',$langs->trans("Member"),$help_url); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- if (empty($object->error) && $rowid) { $object = new Adherent($db); $result=$object->fetch($rowid); if ($result <= 0) dol_print_error('',$object->error); } $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->display_canvas($action); // Show template } else { // ----------------------------------------- // When used in standard mode // ----------------------------------------- if ($action == 'create') { /* ************************************************************************** */ /* */ /* Creation mode */ /* */ /* ************************************************************************** */ $object->canvas=$canvas; $object->state_id = GETPOST('state_id', 'int'); // We set country_id, country_code and country for the selected country $object->country_id=GETPOST('country_id','int')?GETPOST('country_id','int'):$mysoc->country_id; if ($object->country_id) { $tmparray=getCountry($object->country_id,'all'); $object->country_code=$tmparray['code']; $object->country=$tmparray['label']; } $adht = new AdherentType($db); print_fiche_titre($langs->trans("NewMember")); if ($conf->use_javascript_ajax) { print "\n".''."\n"; } print '
'; print ''; print ''; dol_fiche_head(''); 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 ''; // Lastname print ''; print ''; // Firstname print ''; print ''; // EMail print ''; // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $generated_password=getRandomPassword(false); print ''; } // Address print ''; // Zip / Town print ''; // Country $object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; print ''; // State if (empty($conf->global->MEMBER_DISABLE_STATE)) { print ''; } // Pro phone print ''; // Personal phone print ''; // Mobile phone print ''; // Skype if (! empty($conf->skype->enabled)) { print ''; } // Birthday print "\n"; // Public profil print "\n"; // Categories if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { print '"; } // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); } /* // Third party Dolibarr if (! empty($conf->societe->enabled)) { print ''; } // Login Dolibarr print ''; */ print ''; print "
'.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">
'.$langs->trans("Nature")."\n"; print $form->selectarray("morphy", $morphys, GETPOST('morphy','alpha')?GETPOST('morphy','alpha'):$object->morphy, 1); print "
'.$langs->trans("MemberType").''; $listetype=$adht->liste_array(); if (count($listetype)) { print $form->selectarray("typeid", $listetype, GETPOST('typeid','int')?GETPOST('typeid','int'):$typeid, count($listetype)>1?1:0); } else { print ''.$langs->trans("NoTypeDefinedGoToSetup").''; } print "
'.$langs->trans("Company").'
'.$langs->trans("UserTitle").''; print $formcompany->select_civility(GETPOST('civility_id','int')?GETPOST('civility_id','int'):$object->civility_id,'civility_id').'
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'
'.$langs->trans("Password").''; print ''; print '
'.$langs->trans("Address").''; print ''; print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; print $formcompany->select_ziptown((GETPOST('zipcode','alpha')?GETPOST('zipcode','alpha'):$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6); print ' '; print $formcompany->select_ziptown((GETPOST('town','alpha')?GETPOST('town','alpha'):$object->town),'town',array('zipcode','selectcountry_id','state_id')); print '
'.$langs->trans('Country').''; print $form->select_country(GETPOST('country_id','alpha')?GETPOST('country_id','alpha'):$object->country_id,'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'.$langs->trans('State').''; if ($object->country_id) { print $formcompany->select_state(GETPOST('state_id','int')?GETPOST('state_id','int'):$object->state_id,$object->country_code); } else { print $countrynotdefined; } print '
'.$langs->trans("PhonePro").'
'.$langs->trans("PhonePerso").'
'.$langs->trans("PhoneMobile").'
'.$langs->trans("Skype").'
".$langs->trans("Birthday")."\n"; $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc'); print "
".$langs->trans("Public")."\n"; print $form->selectyesno("public",$object->public,1); print "
' . fieldLabel('Categories', 'memcars') . ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, 'parent', null, null, 1); print $form->multiselectarray('memcats', $cate_arbo, GETPOST('memcats', 'array'), null, null, null, null, '100%'); print "
'.$langs->trans("LinkedToDolibarrThirdParty").''; print $form->select_company($object->fk_soc,'socid','',1); print '
'.$langs->trans("LinkedToDolibarrUser").''; print $form->select_dolusers($object->user_id,'userid',1); print '
\n"; dol_fiche_end(); print '
'; print ''; print '     '; print ''; print '
'; print "
\n"; } if ($action == 'edit') { /******************************************** * * Edition mode * ********************************************/ $res=$object->fetch($rowid); if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); if ($res < 0) { dol_print_error($db); exit; } $adht = new AdherentType($db); $adht->fetch($object->typeid); // We set country_id, and country_code, country of the chosen country $country=GETPOST('country','int'); if (!empty($country) || $object->country_id) { $sql = "SELECT rowid, code, label from ".MAIN_DB_PREFIX."c_country where rowid = ".(!empty($country)?$country:$object->country_id); $resql=$db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); } else { dol_print_error($db); } $object->country_id=$obj->rowid; $object->country_code=$obj->code; $object->country=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; } $head = member_prepare_head($object); if ($conf->use_javascript_ajax) { print "\n".''."\n"; } $rowspan=15; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; if (! empty($conf->societe->enabled)) $rowspan++; print '
'; print ''; print ''; print ''; print ''; if ($backtopage) print ''; dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); 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 ''; // Civility print ''; print ''; // Lastname print ''; print ''; // Firstname print ''; print ''; // EMail print ''; // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; } // Address print ''; // Zip / Town print ''; // Country //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined print ''; // State if (empty($conf->global->MEMBER_DISABLE_STATE)) { print ''; } // Pro phone print ''; // Personal phone print ''; // Mobile phone print ''; // Skype if (! empty($conf->skype->enabled)) { print ''; } // Birthday print "\n"; // Public profil print "\n"; // Categories if (! empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { print ''; print '"; } // Other attributes $parameters=array("colspan"=>2); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit',$parameters); } // Third party Dolibarr if (! empty($conf->societe->enabled)) { print ''; } // Login Dolibarr print ''; print '
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">
'.$langs->trans("Nature").''; print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); print "'; print $form->showphoto('memberphoto',$object)."\n"; if ($caneditfieldmember) { if ($object->photo) print "
\n"; print ''; if ($object->photo) print ''; print ''; print ''; print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; } print '
'.$langs->trans("Type").''; if ($user->rights->adherent->creer) { print $form->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->typeid)); } else { print $adht->getNomUrl(1); print ''; } print "
'.$langs->trans("Company").'societe).'">
'.$langs->trans("UserTitle").''; print $formcompany->select_civility(isset($_POST["civility_id"])?$_POST["civility_id"]:$object->civility_id)."\n"; print '
'.$langs->trans("Lastname").'lastname).'">
'.$langs->trans("Firstname").'firstname).'">
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">
'.$langs->trans("Password").'pass).'">
'.$langs->trans("Address").''; print ''; print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6); print ' '; print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id')); print '
'.$langs->trans('Country').''; print $form->select_country(isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id,'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'.$langs->trans('State').''; print $formcompany->select_state($object->state_id,isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id); print '
'.$langs->trans("PhonePro").'phone).'">
'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'phone_mobile).'">
'.$langs->trans("Skype").'skype).'">
".$langs->trans("Birthday")."\n"; $form->select_date(($object->birth ? $object->birth : -1),'birth','','',1,'formsoc'); print "
".$langs->trans("Public")."\n"; print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1); print "
' . fieldLabel('Categories', 'memcats') . ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_MEMBER); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } print $form->multiselectarray('memcats', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); print "
'.$langs->trans("LinkedToDolibarrThirdParty").''; if ($object->fk_soc) { $company=new Societe($db); $result=$company->fetch($object->fk_soc); print $company->getNomUrl(1); } else { print $langs->trans("NoThirdPartyAssociatedToMember"); } print '
'.$langs->trans("LinkedToDolibarrUser").''; if ($object->user_id) { $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none'); } else print $langs->trans("NoDolibarrAccess"); print '
'; dol_fiche_end(); print '
'; print ''; print '     '; print ''; print '
'; print '
'; } if ($rowid && $action != 'edit') { /* ************************************************************************** */ /* */ /* View mode */ /* */ /* ************************************************************************** */ $res=$object->fetch($rowid); if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); if ($res < 0) { dol_print_error($db); exit; } $adht = new AdherentType($db); $res=$adht->fetch($object->typeid); if ($res < 0) { dol_print_error($db); exit; } /* * Show tabs */ $head = member_prepare_head($object); dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); // Confirm create user if ($action == 'create_user') { $login=$object->login; if (empty($login)) { // Full firstname and name separated with a dot : firstname.name include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $login=dol_buildlogin($object->lastname,$object->firstname); } if (empty($login)) $login=strtolower(substr($object->firstname, 0, 4)) . strtolower(substr($object->lastname, 0, 4)); // Create a form array $formquestion=array( array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login) ); $text=$langs->trans("ConfirmCreateLogin").'
'; if (! empty($conf->societe->enabled)) { if ($object->fk_soc > 0) $text.=$langs->trans("UserWillBeExternalUser"); else $text.=$langs->trans("UserWillBeInternalUser"); } print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrLogin"),$text,"confirm_create_user",$formquestion,'yes'); } // Confirm create third party if ($action == 'create_thirdparty') { $name = $object->getFullName($langs); if (! empty($name)) { if ($object->societe) $name.=' ('.$object->societe.')'; } else { $name=$object->societe; } // Create a form array $formquestion=array( array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name)); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); } // Confirm validate member if ($action == 'valid') { $langs->load("mails"); $adht = new AdherentType($db); $adht->fetch($object->typeid); $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_VALID_SUBJECT); $texttosend=$object->makeSubstitution($adht->getMailOnValid()); $tmp=$langs->trans("SendAnEMailToMember"); $tmp.='
('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; $tmp.=$langs->trans("MailRecipient").': '.$object->email.')'; $helpcontent=''; $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; $helpcontent.=''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent.=''.$langs->trans("Subject").':
'."\n"; $helpcontent.=$subjecttosend."\n"; $helpcontent.="
"; $helpcontent.=''.$langs->trans("Content").':
'; $helpcontent.=dol_htmlentitiesbr($texttosend)."\n"; $label=$form->textwithpicto($tmp,$helpcontent,1,'help'); // Create form popup $formquestion=array(); if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false)); if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_MAILMAN)) { $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>''); } if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) { $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>''); } print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1,1); } // Confirm send card by mail if ($action == 'sendinfo') { print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1); } // Confirm terminate if ($action == 'resign') { $langs->load("mails"); $adht = new AdherentType($db); $adht->fetch($object->typeid); $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_RESIL_SUBJECT); $texttosend=$object->makeSubstitution($adht->getMailOnResiliate()); $tmp=$langs->trans("SendAnEMailToMember"); $tmp.='
('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; $tmp.=$langs->trans("MailRecipient").': '.$object->email.')'; $helpcontent=''; $helpcontent.=''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; $helpcontent.=''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent.=''.$langs->trans("Subject").':
'."\n"; $helpcontent.=$subjecttosend."\n"; $helpcontent.="
"; $helpcontent.=''.$langs->trans("Content").':
'; $helpcontent.=dol_htmlentitiesbr($texttosend)."\n"; $label=$form->textwithpicto($tmp,$helpcontent,1,'help'); // Cree un tableau formulaire $formquestion=array(); if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false')); if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion,'no',1); } // Confirm remove member if ($action == 'delete') { $formquestion=array(); if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); print $form->formconfirm("card.php?rowid=".$rowid,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1); } /* * Confirm add in spip */ if ($action == 'add_spip') { print $form->formconfirm("card.php?rowid=".$rowid, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip'); } /* * Confirm removed from spip */ if ($action == 'del_spip') { print $form->formconfirm("card.php?rowid=$rowid", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip'); } $rowspan=17; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; if (! empty($conf->societe->enabled)) $rowspan++; if (! empty($conf->skype->enabled)) $rowspan++; print ''; $linkback = ''.$langs->trans("BackToList").''; // Ref print ''; print ''; $showphoto=''; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''; // Photo print $showphoto; $showphoto=''; print ''; } // Morphy print ''; print $showphoto; $showphoto=''; print ''; // Type print '\n"; // Company print ''; // Civility print ''; print ''; // Lastname print ''; print ''; // Firstname print ''; // EMail 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 ''; // Skype if (! empty($conf->skype->enabled)) { print ''; } // Birthday print ''; // Public print ''; // Status print ''; // Categories if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { print ''; print ''; } // Other attributes $parameters=array('colspan'=>2); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'view', $parameters); } // Third party Dolibarr if (! empty($conf->societe->enabled)) { print ''; } // Login Dolibarr print ''; print "
'.$langs->trans("Ref").''; print $form->showrefnav($object, 'rowid', $linkback); print '
'; $showphoto.=$form->showphoto('memberphoto',$object); $showphoto.='
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$object->login.' 
'.$langs->trans("Nature").''.$object->getmorphylib().'
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Company").''.$object->societe.'
'.$langs->trans("UserTitle").''.$object->getCivilityLabel().' 
'.$langs->trans("Lastname").''.$object->lastname.' 
'.$langs->trans("Firstname").''.$object->firstname.' 
'.$langs->trans("EMail").''.dol_print_email($object->email,0,$object->fk_soc,1).'
'.$langs->trans("Password").''.preg_replace('/./i','*',$object->pass).'
'.$langs->trans("Address").''; dol_print_address($object->address,'gmap','member',$object->id); print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'
'.$langs->trans("Country").''; $img=picto_from_langcode($object->country_code); if ($img) print $img.' '; print getCountry($object->country_code); print '
'.$langs->trans('State').''.$object->state.'
'.$langs->trans("PhonePro").''.dol_print_phone($object->phone,$object->country_code,0,$object->fk_soc,1).'
'.$langs->trans("PhonePerso").''.dol_print_phone($object->phone_perso,$object->country_code,0,$object->fk_soc,1).'
'.$langs->trans("PhoneMobile").''.dol_print_phone($object->phone_mobile,$object->country_code,0,$object->fk_soc,1).'
'.$langs->trans("Skype").''.dol_print_skype($object->skype,0,$object->fk_soc,1).'
'.$langs->trans("Birthday").''.dol_print_date($object->birth,'day').'
'.$langs->trans("Public").''.yn($object->public).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
' . $langs->trans("Categories") . ''; print $form->showCategories($object->id, 'member', 1); print '
'; print ''; if ($action != 'editthirdparty' && $user->rights->adherent->creer) print ''; print '
'; print $langs->trans("LinkedToDolibarrThirdParty"); print 'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'
'; print '
'; if ($action == 'editthirdparty') { $htmlname='socid'; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print '
'; print $form->select_company($object->fk_soc,'socid','',1); print '
'; } else { if ($object->fk_soc) { $company=new Societe($db); $result=$company->fetch($object->fk_soc); print $company->getNomUrl(1); } else { print $langs->trans("NoThirdPartyAssociatedToMember"); } } print '
'; print ''; if ($action != 'editlogin' && $user->rights->adherent->creer) { print ''; } print '
'; print $langs->trans("LinkedToDolibarrUser"); print ''; if ($user->rights->user->user->creer) { print 'id.'">'.img_edit($langs->trans('SetLinkToUser'),1).''; } print '
'; print '
'; if ($action == 'editlogin') { $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid',''); } else { if ($object->user_id) { $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none'); } else print $langs->trans("NoDolibarrAccess"); } print '
\n"; print "\n"; /* * Hotbar */ print '
'; if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty') { // Modify if ($user->rights->adherent->creer) { print '"; } else { print '
'.$langs->trans("Modify").'
'; } // Validate if ($object->statut == -1) { if ($user->rights->adherent->creer) { print '\n"; } else { print '
'.$langs->trans("Validate").'
'; } } // Reactivate if ($object->statut == 0) { if ($user->rights->adherent->creer) { print '\n"; } else { print '
'.$langs->trans("Reenable")."
"; } } // Send card by email if ($user->rights->adherent->creer) { if ($object->statut >= 1) { if ($object->email) print '\n"; else print '\n"; } else { print '
'.$langs->trans("SendCardByMail")."
"; } } else { print '
'.$langs->trans("SendCardByMail")."
"; } // Terminate if ($object->statut >= 1) { if ($user->rights->adherent->supprimer) { print '\n"; } else { print '
'.$langs->trans("Resiliate")."
"; } } // Create third party if (! empty($conf->societe->enabled) && ! $object->fk_soc) { if ($user->rights->societe->creer) { if ($object->statut != -1) print ''; else print ''; } else { print '
'.$langs->trans("CreateDolibarrThirdParty")."
"; } } // Create user if (! $user->societe_id && ! $object->user_id) { if ($user->rights->user->user->creer) { if ($object->statut != -1) print ''; else print ''; } else { print '
'.$langs->trans("CreateDolibarrLogin")."
"; } } // Delete if ($user->rights->adherent->supprimer) { print '\n"; } else { print '
'.$langs->trans("Delete")."
"; } // Action SPIP if (! empty($conf->mailmanspip->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) { $isinspip = $mailmanspip->is_in_spip($object); if ($isinspip == 1) { print '\n"; } if ($isinspip == 0) { print '\n"; } } } print '
'; if ($isinspip == -1) { print '

'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.''; } print "
\n"; } } llxFooter(); $db->close();