diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index be17ae45074..313408e7cde 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -30,12 +30,12 @@ require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); -require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); -require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php"); -require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php"); -require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php"); -require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php"); +require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); +require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"); +require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_options.class.php"); +require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php"); +require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); $langs->load("companies"); $langs->load("bills"); @@ -144,7 +144,7 @@ if ($_POST['action'] == 'setsocid') $thirdparty=new Societe($db); $thirdparty->fetch($_POST["socid"]); $error++; - $mesg='
'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->fullname,$othermember->login,$thirdparty->nom).'
'; + $mesg='
'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->nom).'
'; } } @@ -212,6 +212,8 @@ if ($_REQUEST["action"] == 'confirm_sendinfo' && $_REQUEST["confirm"] == 'yes') if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) { + require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); + $datenaiss=''; if (isset($_POST["naissday"]) && $_POST["naissday"] && isset($_POST["naissmonth"]) && $_POST["naissmonth"] @@ -229,7 +231,6 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe $adh->civilite_id = trim($_POST["civilite_id"]); $adh->prenom = trim($_POST["prenom"]); $adh->nom = trim($_POST["nom"]); - $adh->fullname = trim($adh->prenom.' '.$adh->nom); $adh->login = trim($_POST["login"]); $adh->pass = trim($_POST["pass"]); @@ -237,7 +238,9 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe $adh->adresse = trim($_POST["adresse"]); $adh->cp = trim($_POST["cp"]); $adh->ville = trim($_POST["ville"]); - $adh->pays_id = $_POST["pays"]; + + $adh->fk_departement = $_POST["departement_id"]; + $adh->pays_id = $_POST["pays"]; $adh->phone = trim($_POST["phone"]); $adh->phone_perso = trim($_POST["phone_perso"]); @@ -251,7 +254,7 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe $adh->amount = $_POST["amount"]; - $adh->photo = $_FILES['photo']['name']; + $adh->photo = ($_FILES['photo']['name']?$_FILES['photo']['name']:$adh->oldcopy->photo); // Get status and public property $adh->statut = $_POST["statut"]; @@ -284,7 +287,7 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe $result=$adh->update($user,0,$nosyncuser,$nosyncuserpass); if ($result >= 0 && ! sizeof($adh->errors)) { - if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) + if (!empty($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { $dir= $conf->adherent->dir_output . '/' . get_exdir($adh->id,2,0,1); @@ -293,7 +296,7 @@ if ($_REQUEST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->adhe if (@is_dir($dir)) { $newfile=$dir.'/'.$_FILES['photo']['name']; - if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1) > 0) + if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0) { $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; } @@ -355,6 +358,7 @@ if ($_POST["action"] == 'add' && $user->rights->adherent->creer) $adresse=$_POST["adresse"]; $cp=$_POST["cp"]; $ville=$_POST["ville"]; + $departement_id=$_POST["departement_id"]; $pays_id=$_POST["pays_id"]; $phone=$_POST["phone"]; @@ -379,6 +383,7 @@ if ($_POST["action"] == 'add' && $user->rights->adherent->creer) $adh->adresse = $adresse; $adh->cp = $cp; $adh->ville = $ville; + $adh->fk_departement = $departement_id; $adh->pays_id = $pays_id; $adh->phone = $phone; $adh->phone_perso = $phone_perso; @@ -658,6 +663,8 @@ $htmlcompany = new FormCompany($db); // fetch optionals attributes and labels $adho->fetch_name_optionals_label(); +$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + if ($action == 'edit') { @@ -680,9 +687,24 @@ if ($action == 'edit') $adht->fetch($adh->typeid); - /* - * Affichage onglets - */ + // We set pays_id, and pays_code label of the chosen country + if (isset($_POST["pays"]) || $adh->pays_id) + { + $sql = "SELECT rowid, code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays"])?$_POST["pays"]:$adh->pays_id); + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $adh->pays_id=$obj->rowid; + $adh->pays_code=$obj->code; + $adh->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + } + $head = member_prepare_head($adh); dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); @@ -694,11 +716,11 @@ if ($action == 'edit') if ($mesg) print '
'.$mesg.'
'; - $rowspan=15; + $rowspan=17; $rowspan+=sizeof($adho->attribute_label); if ($conf->societe->enabled) $rowspan++; - print '
'; + print ''; print ''; print ""; print ""; @@ -713,20 +735,20 @@ if ($action == 'edit') $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Morale"); print ''.$langs->trans("Person").''; - $html->select_array("morphy", $morphys, $adh->morphy); + $html->select_array("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy); print ""; // Societe - print ''.$langs->trans("Company").''; + print ''.$langs->trans("Company").'societe).'">'; // Civilite print ''.$langs->trans("UserTitle").''; - print $htmlcompany->select_civilite($adh->civilite_id); + print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id)."\n"; print ''; // Photo print ''; - print $html->showphoto('memberphoto',$adh); + print $html->showphoto('memberphoto',$adh)."\n"; if ($caneditfieldmember) { print '

'; @@ -737,25 +759,25 @@ if ($action == 'edit') print ''; print ''; - // Nom - print ''; + // Name + print ''; print ''; - // Prenom - print ''; + // Firstname + print ''; print ''; // Login - print ''; + print ''; // Password - print ''; + print ''; // Type print ''; + print ''; - // Cp - print ''; + // Zip / Town + print ''; // Country print ''; + + // State + print ''; // Tel - print ''; + print ''; // Tel perso - print ''; + print ''; // Tel mobile - print ''; + print ''; // EMail - print ''; + print ''; // Date naissance print "\n"; // Profil public print "\n"; // Attributs supplementaires @@ -831,7 +859,7 @@ if ($action == 'edit') print ''; print ''; @@ -850,6 +878,28 @@ if ($action == 'create') /* Fiche creation */ /* */ /* ************************************************************************** */ + $adh->fk_departement = $_POST["departement_id"]; + + // We set pays_id, pays_code and label for the selected country + $adh->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; + if ($adh->pays_id) + { + $sql = "SELECT rowid, code, libelle"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; + $sql.= " WHERE rowid = ".$adh->pays_id; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $adh->pays_id=$obj->rowid; + $adh->pays_code=$obj->code; + $adh->pays=$obj->libelle; + } $adht = new AdherentType($db); @@ -861,37 +911,37 @@ if ($action == 'create') } if ($mesg) print '
'.$mesg.'
'; - print ''; + print ''; print ''; print ''; print '
'.$langs->trans("PhotoFile").'
'.$langs->trans("Lastname").'
'.$langs->trans("Lastname").'nom).'">
'.$langs->trans("Firstname").'
'.$langs->trans("Firstname").'prenom).'">
'.$langs->trans("Login").'
'.$langs->trans("Login").'login).'">
'.$langs->trans("Password").'
'.$langs->trans("Password").'pass).'">
'.$langs->trans("Type").''; if ($user->rights->adherent->creer) { - $html->select_array("typeid", $adht->liste_array(), $adh->typeid); + $html->select_array("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$adh->typeid)); } else { @@ -766,36 +788,42 @@ if ($action == 'edit') // Address print '
'.$langs->trans("Address").''; - print '
'.$langs->trans("Zip").'/'.$langs->trans("Town").'
'.$langs->trans("Zip").'/'.$langs->trans("Town").'cp).'"> ville).'">
'.$langs->trans("Country").''; - $html->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays'); + $html->select_pays(isset($_POST["pays"])?$_POST["pays"]:$adh->pays_id,'pays',$conf->use_javascript_ajax?' onChange="company_save_refresh_edit()"':''); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; + $htmlcompany->select_departement($adh->fk_departement,$adh->pays_code); print '
'.$langs->trans("PhonePro").'
'.$langs->trans("PhonePro").'phone).'">
'.$langs->trans("PhonePerso").'
'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'
'.$langs->trans("PhoneMobile").'phone_mobile).'">
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">
".$langs->trans("Birthday")."\n"; - $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'update'); + $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'formsoc'); print "
".$langs->trans("Public")."\n"; - print $html->selectyesno("public",$adh->public,1); + print $html->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$adh->public),1); print "
'; - print ''; + print ''; print '       '; print ''; print '
'; // Moral-Physique - $morphys["phy"] = "Physique"; - $morphys["mor"] = "Morale"; + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Moral"); print '\n"; // Company - print ''; + print ''; // Civility print ''; + print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id,'civilite_id').''; print ''; // Nom - print ''; + print ''; print ''; // Prenom - print ''; + print ''; print ''; // Login - print ''; + print ''; // Mot de passe $generated_password=''; @@ -913,7 +963,7 @@ if ($action == 'create') $listetype=$adht->liste_array(); if (sizeof($listetype)) { - $html->select_array("typeid", $listetype, $typeid, 1); + $html->select_array("typeid", $listetype, isset($_POST["typeid"])?$_POST["typeid"]:$typeid, 1); } else { print ''.$langs->trans("NoTypeDefinedGoToSetup").''; } @@ -921,31 +971,45 @@ if ($action == 'create') // Address print ''; + print ''; // CP / Ville - print ''; + print ''; - // Pays - print ''; + // Country + $adh->pays_id=$adh->pays_id?$adh->pays_id:$mysoc->pays_id; + print ''; + + // State + print ''; // Tel pro - print ''; + print ''; // Tel perso - print ''; + print ''; // Tel mobile - print ''; + print ''; // EMail - print ''; + print ''; // Date naissance print "\n"; // Profil public @@ -956,7 +1020,7 @@ if ($action == 'create') // Attribut optionnels foreach($adho->attribute_label as $key=>$value) { - print "\n"; + print "'."\n"; } /* @@ -1112,7 +1176,7 @@ if ($rowid && $action != 'edit') if ($ret == 'html') print '
'; } - $rowspan=14+sizeof($adho->attribute_label); + $rowspan=15+sizeof($adho->attribute_label); if ($conf->societe->enabled) $rowspan++; print ''; @@ -1134,11 +1198,11 @@ if ($rowid && $action != 'edit') print ''; print ''; - // Nom + // Name print ''; print ''; - // Prenom + // Firstname print ''; // Login @@ -1157,11 +1221,18 @@ if ($rowid && $action != 'edit') // Address print ''; - // CP / Ville + // Zip / Town print ''; - // Pays - print ''; + // Country + print ''; + + // State + print ''; // Tel pro. print ''; @@ -1307,11 +1378,12 @@ if ($rowid && $action != 'edit') } // Envoi fiche par mail - if ($adh->statut >= 1 && $adh->email) + if ($adh->statut >= 1) { if ($user->rights->adherent->creer) { - print "id&action=sendinfo\">".$langs->trans("SendCardByMail")."\n"; + if ($adh->email) print "id&action=sendinfo\">".$langs->trans("SendCardByMail")."\n"; + else print "trans("NoEMail"))."\">".$langs->trans("SendCardByMail")."\n"; } else { @@ -1338,7 +1410,7 @@ if ($rowid && $action != 'edit') if ($user->rights->societe->creer) { if ($adh->statut != -1) print ''.$langs->trans("CreateDolibarrThirdParty").''; - else print ''.$langs->trans("CreateDolibarrLogin").''; + else print ''.$langs->trans("CreateDolibarrThirdParty").''; } else { @@ -1376,11 +1448,11 @@ if ($rowid && $action != 'edit') $isinspip=$adh->is_in_spip(); if ($isinspip == 1) { - print "id&action=del_spip\">Suppression dans Spip\n"; + print "id&action=del_spip\">".$langs->trans("DeleteIntoSpip")."\n"; } if ($isinspip == 0) { - print "id&action=add_spip\">Ajout dans Spip\n"; + print "id&action=add_spip\">".$langs->trans("AddIntoSpip")."\n"; } if ($isinspip == -1) { print '
Failed to connect to SPIP: '.$adh->error.'';
'.$langs->trans("Person")."\n"; - $html->select_array("morphy", $morphys, $adh->morphy, 1); + $html->select_array("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy, 1); print "
'.$langs->trans("Company").'
'.$langs->trans("Company").'societe).'">
'.$langs->trans("UserTitle").''; - print $htmlcompany->select_civilite($adh->civilite_id,'civilite_id').'
'.$langs->trans("Lastname").'
'.$langs->trans("Lastname").'nom).'" size="40">
'.$langs->trans("Firstname").'
'.$langs->trans("Firstname").'prenom).'">
'.$langs->trans("Login").'
'.$langs->trans("Login").'login).'">
'.$langs->trans("Address").''; - print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").'
'.$langs->trans("Zip").' / '.$langs->trans("Town").'cp).'"> ville).'">
'.$langs->trans("Country").''; - $html->select_pays($adh->pays_id ? $adh->pays_id : $mysoc->pays_id,'pays_id'); - print '
'.$langs->trans("Country").''; + $html->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$adh->pays_id,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':''); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; + if ($adh->pays_id) + { + $htmlcompany->select_departement(isset($_POST["departement_id"])?$_POST["departement_id"]:$adh->fk_departement,$adh->pays_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans("PhonePro").'
'.$langs->trans("PhonePro").'phone).'">
'.$langs->trans("PhonePerso").'
'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'
'.$langs->trans("PhoneMobile").'phone_mobile).'">
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">
".$langs->trans("Birthday")."\n"; - $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'add'); + $html->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'formsoc'); print "
$value
".$value.'
'.$langs->trans("UserTitle").''.$adh->getCivilityLabel().' 
'.$langs->trans("Lastname").''.$adh->nom.' 
'.$langs->trans("Firstname").''.$adh->prenom.' 
'.$langs->trans("Address").''.nl2br($adh->adresse).'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$adh->cp.' '.$adh->ville.'
'.$langs->trans("Country").''.getCountryLabel($adh->pays_id).'
'.$langs->trans("Country").''; + $img=picto_from_langcode($adh->pays_code); + if ($img) print $img.' '; + print getCountry($adh->pays_code); + print '
'.$langs->trans('State').''.$adh->departement.'
'.$langs->trans("PhonePro").''.dol_print_phone($adh->phone,$adh->pays_code,0,$adh->fk_soc,1).'