diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 7ca413a0c4a..df281e9bf09 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -52,7 +52,7 @@ $userid=GETPOST('userid','int'); $socid=GETPOST('socid','int'); // Security check -$result=restrictedArea($user,'adherent',$rowid); +$result=restrictedArea($user,'adherent',$rowid,'','','fk_soc', 'rowid', $objcanvas); if (! empty($conf->mailmanspip->enabled)) { @@ -66,6 +66,17 @@ if (! empty($conf->mailmanspip->enabled)) $object = new Adherent($db); $extrafields = new ExtraFields($db); +// Get object canvas (By default, this is not defined, so standard usage of dolibarr) +$object->getCanvas($socid); +$canvas = $object->canvas?$object->canvas:GETPOST("canvas"); +$objcanvas=''; +if (! empty($canvas)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('adherent', 'card', $canvas); +} + $errmsg=''; $errmsgs=array(); if ($rowid > 0) @@ -104,7 +115,7 @@ $hookmanager->initHooks(array('membercard')); * Actions */ -$parameters=array('socid'=>$socid); +$parameters=array('socid'=>$socid, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) @@ -129,6 +140,8 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights } } } +else $object->canvas=$canvas; + if ($action == 'setsocid') { $error=0; @@ -184,6 +197,7 @@ if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user $errmsg=$object->error; } } +else $object->canvas=$canvas; // Create third party from a member if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) @@ -206,6 +220,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights $errmsg=$object->error; } } +else $object->canvas=$canvas; if ($action == 'confirm_sendinfo' && $confirm == 'yes') { @@ -677,925 +692,944 @@ llxHeader('',$langs->trans("Member"),$help_url); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -if ($action == 'create') +if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { - /* ************************************************************************** */ - /* */ - /* Fiche creation */ - /* */ - /* ************************************************************************** */ - $object->fk_departement = $_POST["departement_id"]; - - // 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->pays_code=$tmparray['code']; - $object->pays=$tmparray['code']; - $object->country_code=$tmparray['code']; - $object->country=$tmparray['label']; - } - - $adht = new AdherentType($db); - - print_fiche_titre($langs->trans("NewMember")); - - dol_htmloutput_mesg($errmsg,$errmsgs,'error'); - 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 ''; - - // Lastname - print ''; - print ''; - - // Firstname - print ''; - print ''; - - // Password - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generated_password=getRandomPassword(''); - 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 ''; - } - - // Tel pro - print ''; - - // Tel perso - print ''; - - // Tel mobile - print ''; - - // EMail - print ''; - - // Birthday - print "\n"; - - // Profil public - print "\n"; - - // 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)) - { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?GETPOST('options_'.$key,'alpha'):$object->array_options["options_".$key]); - print ''."\n"; - } - } - - /* - // Third party Dolibarr - if (! empty($conf->societe->enabled)) - { - print ''; - } - - // Login Dolibarr - 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('civilite_id','int')?GETPOST('civilite_id','int'):$object->civilite_id,'civilite_id').'
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$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','departement_id'),6); - print ' '; - print $formcompany->select_ziptown((GETPOST('town','alpha')?GETPOST('town','alpha'):$object->town),'town',array('zipcode','selectcountry_id','departement_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("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'.$langs->trans('State').''; - if ($object->country_id) - { - print $formcompany->select_state(GETPOST('departement_id','int')?GETPOST('departement_id','int'):$object->fk_departement,$object->country_code); - } - else - { - print $countrynotdefined; - } - print '
'.$langs->trans("PhonePro").'
'.$langs->trans("PhonePerso").'
'.$langs->trans("PhoneMobile").'
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'
".$langs->trans("Birthday")."\n"; - $form->select_date(($object->naiss ? $object->naiss : -1),'naiss','','',1,'formsoc'); - print "
".$langs->trans("Public")."\n"; - print $form->selectyesno("public",$object->public,1); - print "
'.$label.''; - print $extrafields->showInputField($key,$value); - print '
'.$langs->trans("LinkedToDolibarrThirdParty").''; - print $form->select_company($object->fk_soc,'socid','',1); - print '
'.$langs->trans("LinkedToDolibarrUser").''; - print $form->select_users($object->user_id,'userid',1); - print '
\n"; - print '
'; - - print '
'; - - print "
\n"; - + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + if (empty($object->error) && $socid) + { + $object = new Adherent($db); + $object->fetch($socid); + } + $objcanvas->assign_values($action, $socid); // Set value for templates + $objcanvas->display_canvas($action); // Show template } - -if ($action == 'edit') +else { - /******************************************** - * - * Fiche en mode edition - * - ********************************************/ + // ----------------------------------------- + // When used in standard 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 - if (isset($_POST["pays"]) || $object->country_id) + if ($action == 'create') { - $sql = "SELECT rowid, code, libelle as label from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays"])?$_POST["pays"]:$object->country_id); - $resql=$db->query($sql); - if ($resql) + /* ************************************************************************** */ + /* */ + /* Fiche creation */ + /* */ + /* ************************************************************************** */ + $object->fk_departement = $_POST["departement_id"]; + + // 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) { - $obj = $db->fetch_object($resql); - } - else - { - dol_print_error($db); - } - $object->pays_id=$obj->rowid; - $object->pays_code=$obj->code; - $object->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; - $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); - - dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); - - dol_htmloutput_errors($errmsg,$errmsgs); - dol_htmloutput_mesg($mesg); - - 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 ''; - - 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 - //$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 ''; - } - - // Tel - print ''; - - // Tel perso - print ''; - - // Tel mobile - print ''; - - // EMail - print ''; - - // Date naissance - print "\n"; - - // Profil public - print "\n"; - - // 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)) - { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print ''."\n"; - } - } - - // 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["civilite_id"])?$_POST["civilite_id"]:$object->civilite_id)."\n"; - print '
'.$langs->trans("Lastname").'lastname).'">
'.$langs->trans("Firstname").'firstname).'">
'.$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','departement_id'),6); - print ' '; - print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','departement_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("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'.$langs->trans('State').''; - print $formcompany->select_state($object->fk_departement,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).'">
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">
".$langs->trans("Birthday")."\n"; - $form->select_date(($object->naiss ? $object->naiss : -1),'naiss','','',1,'formsoc'); - print "
".$langs->trans("Public")."\n"; - print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1); - print "
'.$label.''; - print $extrafields->showInputField($key,$value); - 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) - { - print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none'); - } - else print $langs->trans("NoDolibarrAccess"); - print '
'; - - print '
'; - print ''; - print '       '; - print ''; - print ''; - - print ''; -} - -if ($rowid && $action != 'edit') -{ - dol_htmloutput_mesg($mesg); - - /* ************************************************************************** */ - /* */ - /* Mode affichage */ - /* */ - /* ************************************************************************** */ - - $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; } - - - /* - * Affichage onglets - */ - $head = member_prepare_head($object); - - dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); - - dol_htmloutput_errors($errmsg,$errmsgs); - - // Confirm create user - if ($_GET["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"); - } - $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrLogin"),$text,"confirm_create_user",$formquestion,'yes'); - if ($ret == 'html') print '
'; - } - - // Confirm create third party - if ($_GET["action"] == 'create_thirdparty') - { - $name = $object->getFullName($langs); - if (! empty($name)) - { - if ($object->societe) $name.=' ('.$object->societe.')'; - } - else - { - $name=$object->societe; + $tmparray=getCountry($object->country_id,'all'); + $object->pays_code=$tmparray['code']; + $object->pays=$tmparray['code']; + $object->country_code=$tmparray['code']; + $object->country=$tmparray['label']; } - // Create a form array - $formquestion=array( array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name)); + $adht = new AdherentType($db); - $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); - if ($ret == 'html') print '
'; - } + print_fiche_titre($langs->trans("NewMember")); - // Confirm validate member - if ($action == 'valid') - { - $langs->load("mails"); + dol_htmloutput_mesg($errmsg,$errmsgs,'error'); + dol_htmloutput_mesg($mesg,$mesgs); - $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'); - - // Cree un tableau formulaire - $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->global->ADHERENT_USE_MAILMAN)) { $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>''); } - if (! empty($conf->global->ADHERENT_USE_SPIP)) { $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>''); } - print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1); - } - - // Confirm send card by mail - if ($action == 'sendinfo') - { - print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1); - } - - // Confirm resiliate - 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' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?'true':'false')); - if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); - $ret=$form->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') - { - $formquestion=array(); - if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); - $ret=$form->form_confirm("fiche.php?rowid=".$rowid,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1); - if ($ret == 'html') print '
'; - } - - /* - * Confirm add in spip - */ - if ($action == 'add_spip') - { - $ret=$form->form_confirm("fiche.php?rowid=".$rowid, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip'); - if ($ret == 'html') print '
'; - } - - /* - * Confirm removed from spip - */ - if ($action == 'del_spip') - { - $ret=$form->form_confirm("fiche.php?rowid=$rowid", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip'); - if ($ret == 'html') print '
'; - } - - $rowspan=17; - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; - if (! empty($conf->societe->enabled)) $rowspan++; - - print ''; - - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; - print ''; - - $showphoto=''; - - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { - print ''; - print $showphoto; $showphoto=''; - print ''; - } - - // Morphy - print ''; - print $showphoto; $showphoto=''; - 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 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)) - { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=$object->array_options["options_$key"]; - print "\n"; - } - } - - // Third party Dolibarr - if (! empty($conf->societe->enabled)) - { - 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("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->departement.'
'.$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("EMail").''.dol_print_email($object->email,0,$object->fk_soc,1).'
'.$langs->trans("Birthday").''.dol_print_date($object->naiss,'day').'
'.$langs->trans("Public").''.yn($object->public).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
".$label.""; - print $extrafields->showOutputField($key,$value); - print "
'; - 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') + if ($conf->use_javascript_ajax) { - $htmlname='socid'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + } + + // Login Dolibarr + print ''; + */ + + print "
'; + 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 ''; + + // Lastname + print ''; + print ''; + + // Firstname + print ''; + print ''; + + // Password + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $generated_password=getRandomPassword(''); + 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 ''; + } + + // Tel pro + print ''; + + // Tel perso + print ''; + + // Tel mobile + print ''; + + // EMail + print ''; + + // Birthday + print "\n"; + + // Profil public + print "\n"; + + // 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)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?GETPOST('options_'.$key,'alpha'):$object->array_options["options_".$key]); + print ''."\n"; + } + } + + /* + // Third party Dolibarr + if (! empty($conf->societe->enabled)) + { + 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('civilite_id','int')?GETPOST('civilite_id','int'):$object->civilite_id,'civilite_id').'
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$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','departement_id'),6); + print ' '; + print $formcompany->select_ziptown((GETPOST('town','alpha')?GETPOST('town','alpha'):$object->town),'town',array('zipcode','selectcountry_id','departement_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("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; + if ($object->country_id) + { + print $formcompany->select_state(GETPOST('departement_id','int')?GETPOST('departement_id','int'):$object->fk_departement,$object->country_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans("PhonePro").'
'.$langs->trans("PhonePerso").'
'.$langs->trans("PhoneMobile").'
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'
".$langs->trans("Birthday")."\n"; + $form->select_date(($object->naiss ? $object->naiss : -1),'naiss','','',1,'formsoc'); + print "
".$langs->trans("Public")."\n"; + print $form->selectyesno("public",$object->public,1); + print "
'.$label.''; + print $extrafields->showInputField($key,$value); + print '
'.$langs->trans("LinkedToDolibarrThirdParty").''; print $form->select_company($object->fk_soc,'socid','',1); - print '
'; + print '
'.$langs->trans("LinkedToDolibarrUser").''; + print $form->select_users($object->user_id,'userid',1); + print '
\n"; + print '
'; + + print '
'; + + print "\n"; + + } + + if ($action == 'edit') + { + /******************************************** + * + * Fiche en mode edition + * + ********************************************/ + + $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 + if (isset($_POST["pays"]) || $object->country_id) + { + $sql = "SELECT rowid, code, libelle as label from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays"])?$_POST["pays"]:$object->country_id); + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $object->pays_id=$obj->rowid; + $object->pays_code=$obj->code; + $object->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; + $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); + + dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); + + dol_htmloutput_errors($errmsg,$errmsgs); + dol_htmloutput_mesg($mesg); + + 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 ''; + + 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 ''; - } + print ""; - // Login Dolibarr - 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 + //$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 ''; + } + + // Tel + print ''; + + // Tel perso + print ''; + + // Tel mobile + print ''; + + // EMail + print ''; + + // Date naissance + print "\n"; + + // Profil public + print "\n"; + + // 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)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print ''."\n"; + } + } + + // 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 { - if ($object->fk_soc) - { - $company=new Societe($db); - $result=$company->fetch($object->fk_soc); - print $company->getNomUrl(1); - } - else - { - print $langs->trans("NoThirdPartyAssociatedToMember"); - } + print $adht->getNomUrl(1); + print ''; } - print '
'; - print ''; - if ($_GET['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 ($_GET['action'] == 'editlogin') - { - print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid',''); - } - else - { + // Company + print '
'.$langs->trans("Company").'societe).'">
'.$langs->trans("UserTitle").''; + print $formcompany->select_civility(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$object->civilite_id)."\n"; + print '
'.$langs->trans("Lastname").'lastname).'">
'.$langs->trans("Firstname").'firstname).'">
'.$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','departement_id'),6); + print ' '; + print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','departement_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("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; + print $formcompany->select_state($object->fk_departement,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).'">
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">
".$langs->trans("Birthday")."\n"; + $form->select_date(($object->naiss ? $object->naiss : -1),'naiss','','',1,'formsoc'); + print "
".$langs->trans("Public")."\n"; + print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1); + print "
'.$label.''; + print $extrafields->showInputField($key,$value); + 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) { print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none'); } else print $langs->trans("NoDolibarrAccess"); + print '
'; + + print '
'; + print ''; + print '       '; + print ''; + print ''; + + print ''; } - print '
\n"; + if ($rowid && $action != 'edit') + { + dol_htmloutput_mesg($mesg); - print "\n"; + /* ************************************************************************** */ + /* */ + /* Mode affichage */ + /* */ + /* ************************************************************************** */ + + $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; } - /* - * Barre d'actions - * - */ - print '
'; + /* + * Affichage onglets + */ + $head = member_prepare_head($object); - if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty') - { - // Modify - if ($user->rights->adherent->creer) + dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); + + dol_htmloutput_errors($errmsg,$errmsgs); + + // Confirm create user + if ($_GET["action"] == 'create_user') { - print "".$langs->trans("Modify").""; - } - else - { - print "trans("NotEnoughPermissions"))."\">".$langs->trans("Modify").""; + $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"); + } + $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrLogin"),$text,"confirm_create_user",$formquestion,'yes'); + if ($ret == 'html') print '
'; } - // Valider - if ($object->statut == -1) + // Confirm create third party + if ($_GET["action"] == 'create_thirdparty') { - if ($user->rights->adherent->creer) + $name = $object->getFullName($langs); + if (! empty($name)) { - print "".$langs->trans("Validate")."\n"; + if ($object->societe) $name.=' ('.$object->societe.')'; } else { - print "trans("NotEnoughPermissions"))."\">".$langs->trans("Validate").""; + $name=$object->societe; + } + + // Create a form array + $formquestion=array( array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name)); + + $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$object->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($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'); + + // Cree un tableau formulaire + $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->global->ADHERENT_USE_MAILMAN)) { $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"),'value'=>''); } + if (! empty($conf->global->ADHERENT_USE_SPIP)) { $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>''); } + print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1); + } + + // Confirm send card by mail + if ($action == 'sendinfo') + { + print $form->formconfirm("fiche.php?rowid=".$rowid,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1); + } + + // Confirm resiliate + 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' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?'true':'false')); + if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); + $ret=$form->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') + { + $formquestion=array(); + if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); + $ret=$form->form_confirm("fiche.php?rowid=".$rowid,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1); + if ($ret == 'html') print '
'; + } + + /* + * Confirm add in spip + */ + if ($action == 'add_spip') + { + $ret=$form->form_confirm("fiche.php?rowid=".$rowid, $langs->trans('AddIntoSpip'), $langs->trans('AddIntoSpipConfirmation'), 'confirm_add_spip'); + if ($ret == 'html') print '
'; + } + + /* + * Confirm removed from spip + */ + if ($action == 'del_spip') + { + $ret=$form->form_confirm("fiche.php?rowid=$rowid", $langs->trans('DeleteIntoSpip'), $langs->trans('DeleteIntoSpipConfirmation'), 'confirm_del_spip'); + if ($ret == 'html') print '
'; + } + + $rowspan=17; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; + if (! empty($conf->societe->enabled)) $rowspan++; + + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + print ''; + + $showphoto=''; + + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print ''; + print $showphoto; $showphoto=''; + print ''; + } + + // Morphy + print ''; + print $showphoto; $showphoto=''; + 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 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)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=$object->array_options["options_$key"]; + print "\n"; } } - // Reactiver - if ($object->statut == 0) + // Third party Dolibarr + if (! empty($conf->societe->enabled)) { - if ($user->rights->adherent->creer) + print ''; } - // Create user - if (! $user->societe_id && ! $object->user_id) + // 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("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->departement.'
'.$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("EMail").''.dol_print_email($object->email,0,$object->fk_soc,1).'
'.$langs->trans("Birthday").''.dol_print_date($object->naiss,'day').'
'.$langs->trans("Public").''.yn($object->public).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
".$label.""; + print $extrafields->showOutputField($key,$value); + print "
'; + 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') { - print "".$langs->trans("Reenable")."\n"; - } - else - { - print "trans("NotEnoughPermissions"))."\">".$langs->trans("Reenable").""; - } - } - - // Send card by email - if ($user->rights->adherent->creer) - { - if ($object->statut >= 1) - { - if ($object->email) print "id&action=sendinfo\">".$langs->trans("SendCardByMail")."\n"; - else print "trans("NoEMail"))."\">".$langs->trans("SendCardByMail")."\n"; - } - else - { - print "trans("ValidateBefore"))."\">".$langs->trans("SendCardByMail").""; - } - } - else - { - print "trans("NotEnoughPermissions"))."\">".$langs->trans("SendCardByMail").""; - } - - // Resilier - if ($object->statut >= 1) - { - if ($user->rights->adherent->supprimer) - { - print "".$langs->trans("Resiliate")."\n"; - } - else - { - print "trans("NotEnoughPermissions"))."\">".$langs->trans("Resiliate").""; - } - } - - // Create third party - if (! empty($conf->societe->enabled) && ! $object->fk_soc) - { - if ($user->rights->societe->creer) - { - if ($object->statut != -1) print ''.$langs->trans("CreateDolibarrThirdParty").''; - else print ''.$langs->trans("CreateDolibarrThirdParty").''; + $htmlname='socid'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $form->select_company($object->fk_soc,'socid','',1); + print '
'; } else { - print "trans("NotEnoughPermissions"))."\">".$langs->trans("CreateDolibarrThirdParty").""; + 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 ($_GET['action'] != 'editlogin' && $user->rights->adherent->creer) { + print ''; + } + print '
'; + print $langs->trans("LinkedToDolibarrUser"); + print ''; if ($user->rights->user->user->creer) { - if ($object->statut != -1) print ''.$langs->trans("CreateDolibarrLogin").''; - else print ''.$langs->trans("CreateDolibarrLogin").''; + print 'id.'">'.img_edit($langs->trans('SetLinkToUser'),1).''; + } + print '
'; + print '
'; + if ($_GET['action'] == 'editlogin') + { + print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid',''); + } + else + { + if ($object->user_id) + { + print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->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("CreateDolibarrLogin").""; + print "trans("NotEnoughPermissions"))."\">".$langs->trans("Modify").""; } + + // Valider + if ($object->statut == -1) + { + if ($user->rights->adherent->creer) + { + print "".$langs->trans("Validate")."\n"; + } + else + { + print "trans("NotEnoughPermissions"))."\">".$langs->trans("Validate").""; + } + } + + // Reactiver + if ($object->statut == 0) + { + if ($user->rights->adherent->creer) + { + print "".$langs->trans("Reenable")."\n"; + } + else + { + print "trans("NotEnoughPermissions"))."\">".$langs->trans("Reenable").""; + } + } + + // Send card by email + if ($user->rights->adherent->creer) + { + if ($object->statut >= 1) + { + if ($object->email) print "id&action=sendinfo\">".$langs->trans("SendCardByMail")."\n"; + else print "trans("NoEMail"))."\">".$langs->trans("SendCardByMail")."\n"; + } + else + { + print "trans("ValidateBefore"))."\">".$langs->trans("SendCardByMail").""; + } + } + else + { + print "trans("NotEnoughPermissions"))."\">".$langs->trans("SendCardByMail").""; + } + + // Resilier + if ($object->statut >= 1) + { + if ($user->rights->adherent->supprimer) + { + print "".$langs->trans("Resiliate")."\n"; + } + else + { + print "trans("NotEnoughPermissions"))."\">".$langs->trans("Resiliate").""; + } + } + + // Create third party + if (! empty($conf->societe->enabled) && ! $object->fk_soc) + { + if ($user->rights->societe->creer) + { + if ($object->statut != -1) print ''.$langs->trans("CreateDolibarrThirdParty").''; + else print ''.$langs->trans("CreateDolibarrThirdParty").''; + } + else + { + print "trans("NotEnoughPermissions"))."\">".$langs->trans("CreateDolibarrThirdParty").""; + } + } + + // Create user + if (! $user->societe_id && ! $object->user_id) + { + if ($user->rights->user->user->creer) + { + if ($object->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 (! empty($conf->mailmanspip->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) + { + $isinspip = $mailmanspip->is_in_spip($object); + + 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 '

'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.''; + } + } + } - // Delete - if ($user->rights->adherent->supprimer) - { - print "id&action=delete\">".$langs->trans("Delete")."\n"; - } - else - { - print "trans("NotEnoughPermissions"))."\">".$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 "id&action=del_spip\">".$langs->trans("DeleteIntoSpip")."\n"; - } - if ($isinspip == 0) - { - print "id&action=add_spip\">".$langs->trans("AddIntoSpip")."\n"; - } - if ($isinspip == -1) - { - print '

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