Fix sync contact - external user
This commit is contained in:
parent
feaff433b8
commit
f504716501
@ -267,9 +267,10 @@ class Contact extends CommonObject
|
||||
* @param User $user Objet user making change
|
||||
* @param int $notrigger 0=no, 1=yes
|
||||
* @param string $action Current action for hookmanager
|
||||
* @param int $nosyncuser No sync linked user (external users and contacts are linked)
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update($id, $user=null, $notrigger=0, $action='update')
|
||||
function update($id, $user=null, $notrigger=0, $action='update', $nosyncuser=0)
|
||||
{
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
@ -353,12 +354,69 @@ class Contact extends CommonObject
|
||||
}
|
||||
else if ($reshook < 0) $error++;
|
||||
|
||||
if (! $error && $this->user_id > 0)
|
||||
{
|
||||
$tmpobj = new User($this->db);
|
||||
$tmpobj->fetch($this->user_id);
|
||||
$usermustbemodified = 0;
|
||||
if ($tmpobj->office_phone != $this->phone_pro)
|
||||
{
|
||||
$tmpobj->office_phone = $this->phone_pro;
|
||||
$usermustbemodified++;
|
||||
}
|
||||
if ($tmpobj->office_fax != $this->fax)
|
||||
{
|
||||
$tmpobj->office_fax = $this->fax;
|
||||
$usermustbemodified++;
|
||||
}
|
||||
if ($tmpobj->address != $this->address)
|
||||
{
|
||||
$tmpobj->address = $this->address;
|
||||
$usermustbemodified++;
|
||||
}
|
||||
if ($tmpobj->town != $this->town)
|
||||
{
|
||||
$tmpobj->town = $this->town;
|
||||
$usermustbemodified++;
|
||||
}
|
||||
if ($tmpobj->zip != $this->zip)
|
||||
{
|
||||
$tmpobj->zip = $this->zip;
|
||||
$usermustbemodified++;
|
||||
}
|
||||
if ($tmpobj->zip != $this->zip)
|
||||
{
|
||||
$tmpobj->state_id=$this->state_id;
|
||||
$usermustbemodified++;
|
||||
}
|
||||
if ($tmpobj->country_id != $this->country_id)
|
||||
{
|
||||
$tmpobj->country_id = $this->country_id;
|
||||
$usermustbemodified++;
|
||||
}
|
||||
if ($tmpobj->email != $this->email)
|
||||
{
|
||||
$tmpobj->email = $this->email;
|
||||
$usermustbemodified++;
|
||||
}
|
||||
if ($tmpobj->skype != $this->skype)
|
||||
{
|
||||
$tmpobj->skype = $this->skype;
|
||||
$usermustbemodified++;
|
||||
}
|
||||
if ($usermustbemodified)
|
||||
{
|
||||
$result=$tmpobj->update($user, 0, 1, 1, 1);
|
||||
if ($result < 0) { $error++; }
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && ! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('CONTACT_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('CONTACT_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
|
||||
@ -505,18 +505,18 @@ abstract class CommonObject
|
||||
if (! empty($this->phone_perso)) {
|
||||
$out.=dol_print_phone($this->phone_perso,$this->country_code,$contactid,$thirdpartyid,'AC_TEL',' ','phone',$langs->trans("PhonePerso")); $outdone++;
|
||||
}
|
||||
if (! empty($this->fax)) {
|
||||
$out.=dol_print_phone($this->fax,$this->country_code,$contactid,$thirdpartyid,'AC_FAX',' ','fax',$langs->trans("Fax")); $outdone++;
|
||||
}
|
||||
if (! empty($this->office_phone)) {
|
||||
$out.=dol_print_phone($this->office_phone,$this->country_code,$contactid,$thirdpartyid,'AC_TEL',' ','phone',$langs->trans("PhonePro")); $outdone++;
|
||||
}
|
||||
if (! empty($this->user_mobile)) {
|
||||
$out.=dol_print_phone($this->user_mobile,$this->country_code,$contactid,$thirdpartyid,'AC_TEL',' ','mobile',$langs->trans("PhoneMobile")); $outdone++;
|
||||
}
|
||||
if (! empty($this->office_fax)) {
|
||||
if (! empty($this->fax)) {
|
||||
$out.=dol_print_phone($this->fax,$this->country_code,$contactid,$thirdpartyid,'AC_FAX',' ','fax',$langs->trans("Fax")); $outdone++;
|
||||
}
|
||||
if (! empty($this->office_fax)) {
|
||||
$out.=dol_print_phone($this->office_fax,$this->country_code,$contactid,$thirdpartyid,'AC_FAX',' ','fax',$langs->trans("Fax")); $outdone++;
|
||||
}
|
||||
|
||||
$out.='<div style="clear: both;"></div>';
|
||||
$outdone=0;
|
||||
|
||||
@ -413,7 +413,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
if (!$error && GETPOSTISSET('contactid')) {
|
||||
$contactid = GETPOST('contactid', 'int');
|
||||
$contactid = GETPOST('contactid', 'int');
|
||||
|
||||
if ($contactid > 0) {
|
||||
$contact = new Contact($db);
|
||||
@ -765,33 +765,6 @@ if ($action == 'create' || $action == 'adduserldap')
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Employee
|
||||
$defaultemployee=1;
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('Employee').'</td><td>';
|
||||
print $form->selectyesno("employee",(GETPOST('employee')!=''?GETPOST('employee'):$defaultemployee),1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Position/Job
|
||||
print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
|
||||
print '<td>';
|
||||
print '<input class="maxwidth200" type="text" name="job" value="'.GETPOST('job').'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Gender
|
||||
print '<tr><td>'.$langs->trans("Gender").'</td>';
|
||||
print '<td>';
|
||||
$arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
|
||||
print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Date employment
|
||||
print '<tr><td>'.$langs->trans("DateToBirth").'</td>';
|
||||
print '<td>';
|
||||
echo $form->select_date(GETPOST('birth'),'birth',0,0,1,'createuser',1,0,1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Login
|
||||
print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>';
|
||||
print '<td>';
|
||||
@ -912,8 +885,33 @@ if ($action == 'create' || $action == 'adduserldap')
|
||||
print $form->textwithpicto($langs->trans("Internal"),$langs->trans("InternalExternalDesc"), 1, 'help', '', 0, 2);
|
||||
print '</td></tr>';
|
||||
|
||||
// Gender
|
||||
print '<tr><td>'.$langs->trans("Gender").'</td>';
|
||||
print '<td>';
|
||||
$arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
|
||||
print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Employee
|
||||
$defaultemployee=1;
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('Employee').'</td><td>';
|
||||
print $form->selectyesno("employee",(GETPOST('employee')!=''?GETPOST('employee'):$defaultemployee),1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Hierarchy
|
||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("HierarchicalResponsible").'</td>';
|
||||
print '<td>';
|
||||
print $form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300');
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print '</table><hr><table class="border centpercent">';
|
||||
|
||||
|
||||
// Address
|
||||
print '<tr><td class="tdtop">'.fieldLabel('Address','address').'</td>';
|
||||
print '<tr><td class="tdtop titlefieldcreate">'.fieldLabel('Address','address').'</td>';
|
||||
print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
|
||||
print $object->address;
|
||||
print '</textarea></td></tr>';
|
||||
@ -1024,62 +1022,6 @@ if ($action == 'create' || $action == 'adduserldap')
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
|
||||
|
||||
// Hierarchy
|
||||
print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>';
|
||||
print '<td>';
|
||||
print $form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300');
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|
||||
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
|
||||
{
|
||||
$langs->load("salaries");
|
||||
|
||||
// THM
|
||||
print '<tr><td>';
|
||||
$text=$langs->trans("THM");
|
||||
print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="thm" value="'.GETPOST('thm').'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// TJM
|
||||
print '<tr><td>';
|
||||
$text=$langs->trans("TJM");
|
||||
print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="tjm" value="'.GETPOST('tjm').'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Salary
|
||||
print '<tr><td>'.$langs->trans("Salary").'</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="salary" value="'.GETPOST('salary').'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
// Weeklyhours
|
||||
print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="weeklyhours" value="'.GETPOST('weeklyhours').'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Date employment
|
||||
print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
|
||||
print '<td>';
|
||||
echo $form->select_date(GETPOST('dateemployment'),'dateemployment',0,0,1,'form'.'dateemployment',1,0,1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// User color
|
||||
if (! empty($conf->agenda->enabled))
|
||||
{
|
||||
@ -1143,6 +1085,73 @@ if ($action == 'create' || $action == 'adduserldap')
|
||||
print $doleditor->Create(1);
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table><hr><table class="border centpercent">';
|
||||
|
||||
|
||||
// TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
|
||||
|
||||
// Position/Job
|
||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("PostOrFunction").'</td>';
|
||||
print '<td>';
|
||||
print '<input class="maxwidth200" type="text" name="job" value="'.GETPOST('job').'">';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|
||||
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
|
||||
{
|
||||
$langs->load("salaries");
|
||||
|
||||
// THM
|
||||
print '<tr><td>';
|
||||
$text=$langs->trans("THM");
|
||||
print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="thm" value="'.GETPOST('thm').'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// TJM
|
||||
print '<tr><td>';
|
||||
$text=$langs->trans("TJM");
|
||||
print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="tjm" value="'.GETPOST('tjm').'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Salary
|
||||
print '<tr><td>'.$langs->trans("Salary").'</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="salary" value="'.GETPOST('salary').'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
// Weeklyhours
|
||||
print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="weeklyhours" value="'.GETPOST('weeklyhours').'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Date employment
|
||||
print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
|
||||
print '<td>';
|
||||
echo $form->select_date(GETPOST('dateemployment'),'dateemployment',0,0,1,'form'.'dateemployment',1,0,1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Date birth
|
||||
print '<tr><td>'.$langs->trans("DateToBirth").'</td>';
|
||||
print '<td>';
|
||||
echo $form->select_date(GETPOST('birth'),'birth',0,0,1,'createuser',1,0,1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
dol_fiche_end();
|
||||
@ -1337,31 +1346,8 @@ else
|
||||
}
|
||||
print '</tr>'."\n";
|
||||
|
||||
// Employee
|
||||
print '<tr><td>'.$langs->trans("Employee").'</td><td colspan="2">';
|
||||
print yn($object->employee);
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Position/Job
|
||||
print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
|
||||
print '<td>'.$object->job.'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
// Gender
|
||||
print '<tr><td>'.$langs->trans("Gender").'</td>';
|
||||
print '<td>';
|
||||
if ($object->gender) print $langs->trans("Gender".$object->gender);
|
||||
print '</td></tr>';
|
||||
|
||||
// Date of birth
|
||||
print '<tr><td>'.$langs->trans("DateToBirth").'</td>';
|
||||
print '<td>';
|
||||
print dol_print_date($object->birth, 'day');
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// API key
|
||||
if(! empty($conf->api->enabled) && $user->admin) {
|
||||
if (! empty($conf->api->enabled) && $user->admin) {
|
||||
print '<tr><td>'.$langs->trans("ApiKey").'</td>';
|
||||
print '<td>';
|
||||
if (! empty($object->api_key)) print preg_replace('/./','*',$object->api_key);
|
||||
@ -1403,12 +1389,16 @@ else
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
|
||||
// Accountancy code
|
||||
if ($conf->accounting->enabled)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
|
||||
print '<td>'.$object->accountancy_code.'</td></tr>';
|
||||
}
|
||||
// Gender
|
||||
print '<tr><td>'.$langs->trans("Gender").'</td>';
|
||||
print '<td>';
|
||||
if ($object->gender) print $langs->trans("Gender".$object->gender);
|
||||
print '</td></tr>';
|
||||
|
||||
// Employee
|
||||
print '<tr><td>'.$langs->trans("Employee").'</td><td colspan="2">';
|
||||
print yn($object->employee);
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// TODO Move this into tab RH, visible when salarie or RH is visible (HierarchicalResponsible must be on both tab)
|
||||
|
||||
@ -1424,6 +1414,11 @@ else
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Position/Job
|
||||
print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
|
||||
print '<td>'.$object->job.'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
//$childids = $user->getAllChildIds(1);
|
||||
|
||||
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|
||||
@ -1475,6 +1470,20 @@ else
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Date of birth
|
||||
print '<tr><td>'.$langs->trans("DateToBirth").'</td>';
|
||||
print '<td>';
|
||||
print dol_print_date($object->birth, 'day');
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Accountancy code
|
||||
if ($conf->accounting->enabled)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
|
||||
print '<td>'.$object->accountancy_code.'</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
@ -1818,7 +1827,7 @@ else
|
||||
// Ref/ID
|
||||
if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td>';
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td>';
|
||||
print '<td>';
|
||||
print $object->id;
|
||||
print '</td>';
|
||||
@ -1827,7 +1836,7 @@ else
|
||||
|
||||
// Lastname
|
||||
print "<tr>";
|
||||
print '<td class="fieldrequired">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td class="titlefield fieldrequired">'.$langs->trans("Lastname").'</td>';
|
||||
print '<td>';
|
||||
if ($caneditfield && !$object->ldap_sid)
|
||||
{
|
||||
@ -1855,40 +1864,6 @@ else
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Employee
|
||||
print '<tr>';
|
||||
print '<td>'.fieldLabel('Employee','employee',0).'</td><td>';
|
||||
print $form->selectyesno("employee",$object->employee,1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Position/Job
|
||||
print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
|
||||
print '<td>';
|
||||
if ($caneditfield)
|
||||
{
|
||||
print '<input size="30" type="text" name="job" value="'.$object->job.'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="job" value="'.$object->job.'">';
|
||||
print $object->job;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Gender
|
||||
print '<tr><td>'.$langs->trans("Gender").'</td>';
|
||||
print '<td>';
|
||||
$arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
|
||||
print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Date birth
|
||||
print '<tr><td>'.$langs->trans("DateToBirth").'</td>';
|
||||
print '<td>';
|
||||
echo $form->select_date(GETPOST('birth')?GETPOST('birth'):$object->birth,'birth',0,0,1,'updateuser',1,0,1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Login
|
||||
print "<tr>".'<td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>';
|
||||
print '<td>';
|
||||
@ -2039,8 +2014,42 @@ else
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Gender
|
||||
print '<tr><td>'.$langs->trans("Gender").'</td>';
|
||||
print '<td>';
|
||||
$arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
|
||||
print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Employee
|
||||
print '<tr>';
|
||||
print '<td>'.fieldLabel('Employee','employee',0).'</td><td>';
|
||||
print $form->selectyesno("employee",$object->employee,1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Hierarchy
|
||||
print '<tr><td class="titlefield">'.$langs->trans("HierarchicalResponsible").'</td>';
|
||||
print '<td>';
|
||||
if ($caneditfield)
|
||||
{
|
||||
print $form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300');
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="fk_user" value="'.$object->fk_user.'">';
|
||||
$huser=new User($db);
|
||||
$huser->fetch($object->fk_user);
|
||||
print $huser->getNomUrl(1);
|
||||
}
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print '</table><hr><table class="border centpercent">';
|
||||
|
||||
|
||||
// Address
|
||||
print '<tr><td class="tdtop">'.fieldLabel('Address','address').'</td>';
|
||||
print '<tr><td class="tdtop titlefield">'.fieldLabel('Address','address').'</td>';
|
||||
print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
|
||||
print $object->address;
|
||||
print '</textarea></td></tr>';
|
||||
@ -2159,6 +2168,8 @@ else
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table><hr><table class="border centpercent">';
|
||||
|
||||
// Accountancy code
|
||||
if ($conf->accounting->enabled)
|
||||
{
|
||||
@ -2178,72 +2189,6 @@ else
|
||||
print "</tr>";
|
||||
}
|
||||
|
||||
// TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
|
||||
|
||||
// Hierarchy
|
||||
print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>';
|
||||
print '<td>';
|
||||
if ($caneditfield)
|
||||
{
|
||||
print $form->select_dolusers($object->fk_user, 'fk_user', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300');
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="fk_user" value="'.$object->fk_user.'">';
|
||||
$huser=new User($db);
|
||||
$huser->fetch($object->fk_user);
|
||||
print $huser->getNomUrl(1);
|
||||
}
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|
||||
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
|
||||
{
|
||||
$langs->load("salaries");
|
||||
|
||||
// THM
|
||||
print '<tr><td>';
|
||||
$text=$langs->trans("THM");
|
||||
print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="thm" value="'.price2num(GETPOST('thm')?GETPOST('thm'):$object->thm).'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// TJM
|
||||
print '<tr><td>';
|
||||
$text=$langs->trans("TJM");
|
||||
print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="tjm" value="'.price2num(GETPOST('tjm')?GETPOST('tjm'):$object->tjm).'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Salary
|
||||
print '<tr><td>'.$langs->trans("Salary").'</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="salary" value="'.price2num(GETPOST('salary')?GETPOST('salary'):$object->salary).'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
// Weeklyhours
|
||||
print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="weeklyhours" value="'.price2num(GETPOST('weeklyhours')?GETPOST('weeklyhours'):$object->weeklyhours).'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Date employment
|
||||
print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
|
||||
print '<td>';
|
||||
echo $form->select_date(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment,'dateemployment',0,0,1,'form'.'dateemployment',1,0,1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// User color
|
||||
if (! empty($conf->agenda->enabled))
|
||||
{
|
||||
@ -2372,6 +2317,80 @@ else
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '</table><hr><table class="border centpercent">';
|
||||
|
||||
|
||||
// TODO Move this into tab RH (HierarchicalResponsible must be on both tab)
|
||||
|
||||
// Position/Job
|
||||
print '<tr><td class="titlefield">'.$langs->trans("PostOrFunction").'</td>';
|
||||
print '<td>';
|
||||
if ($caneditfield)
|
||||
{
|
||||
print '<input size="30" type="text" name="job" value="'.$object->job.'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="job" value="'.$object->job.'">';
|
||||
print $object->job;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|
||||
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
|
||||
{
|
||||
$langs->load("salaries");
|
||||
|
||||
// THM
|
||||
print '<tr><td>';
|
||||
$text=$langs->trans("THM");
|
||||
print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="thm" value="'.price2num(GETPOST('thm')?GETPOST('thm'):$object->thm).'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// TJM
|
||||
print '<tr><td>';
|
||||
$text=$langs->trans("TJM");
|
||||
print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="tjm" value="'.price2num(GETPOST('tjm')?GETPOST('tjm'):$object->tjm).'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Salary
|
||||
print '<tr><td>'.$langs->trans("Salary").'</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="salary" value="'.price2num(GETPOST('salary')?GETPOST('salary'):$object->salary).'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
// Weeklyhours
|
||||
print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
|
||||
print '<td>';
|
||||
print '<input size="8" type="text" name="weeklyhours" value="'.price2num(GETPOST('weeklyhours')?GETPOST('weeklyhours'):$object->weeklyhours).'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Date employment
|
||||
print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
|
||||
print '<td>';
|
||||
echo $form->select_date(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment,'dateemployment',0,0,1,'form'.'dateemployment',1,0,1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Date birth
|
||||
print '<tr><td>'.$langs->trans("DateToBirth").'</td>';
|
||||
print '<td>';
|
||||
echo $form->select_date(GETPOST('birth')?GETPOST('birth'):$object->birth,'birth',0,0,1,'updateuser',1,0,1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
@ -1011,7 +1011,7 @@ class User extends CommonObject
|
||||
* @param int $notrigger 1=do not execute triggers, 0 otherwise
|
||||
* @return int <0 if KO, id of created user if OK
|
||||
*/
|
||||
function create($user,$notrigger=0)
|
||||
function create($user, $notrigger=0)
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $mysoc;
|
||||
@ -1337,9 +1337,10 @@ class User extends CommonObject
|
||||
* @param int $notrigger 1 ne declenche pas les triggers, 0 sinon
|
||||
* @param int $nosyncmember 0=Synchronize linked member (standard info), 1=Do not synchronize linked member
|
||||
* @param int $nosyncmemberpass 0=Synchronize linked member (password), 1=Do not synchronize linked member
|
||||
* @param int $nosynccontact 0=Synchronize linked contact, 1=Do not synchronize linked contact
|
||||
* @return int <0 si KO, >=0 si OK
|
||||
*/
|
||||
function update($user,$notrigger=0,$nosyncmember=0,$nosyncmemberpass=0)
|
||||
function update($user, $notrigger=0, $nosyncmember=0, $nosyncmemberpass=0, $nosynccontact=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@ -1474,7 +1475,7 @@ class User extends CommonObject
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
|
||||
// This user is linked with a member, so we also update members informations
|
||||
// This user is linked with a member, so we also update member information
|
||||
// if this is an update.
|
||||
$adh=new Adherent($this->db);
|
||||
$result=$adh->fetch($this->fk_member);
|
||||
@ -1496,8 +1497,6 @@ class User extends CommonObject
|
||||
$adh->phone=$this->office_phone;
|
||||
$adh->phone_mobile=$this->user_mobile;
|
||||
|
||||
$adh->note=$this->note;
|
||||
|
||||
$adh->user_id=$this->id;
|
||||
$adh->user_login=$this->login;
|
||||
|
||||
@ -1517,6 +1516,61 @@ class User extends CommonObject
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->contact_id > 0 && ! $nosynccontact)
|
||||
{
|
||||
dol_syslog(get_class($this)."::update user is linked with a contact. We try to update contact too.", LOG_DEBUG);
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
|
||||
// This user is linked with a contact, so we also update contact information
|
||||
// if this is an update.
|
||||
$tmpobj=new Contact($this->db);
|
||||
$result=$tmpobj->fetch($this->contact_id);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
$tmpobj->firstname=$this->firstname;
|
||||
$tmpobj->lastname=$this->lastname;
|
||||
$tmpobj->login=$this->login;
|
||||
$tmpobj->gender=$this->gender;
|
||||
$tmpobj->birth=$this->birth;
|
||||
|
||||
//$tmpobj->pass=$this->pass;
|
||||
|
||||
//$tmpobj->societe=(empty($tmpobj->societe) && $this->societe_id ? $this->societe_id : $tmpobj->societe);
|
||||
|
||||
$tmpobj->email=$this->email;
|
||||
$tmpobj->skype=$this->skype;
|
||||
$tmpobj->phone_pro=$this->office_phone;
|
||||
$tmpobj->phone_mobile=$this->user_mobile;
|
||||
$tmpobj->fax=$this->office_fax;
|
||||
|
||||
$tmpobj->address=$this->address;
|
||||
$tmpobj->town=$this->town;
|
||||
$tmpobj->zip=$this->zip;
|
||||
$tmpobj->state_id=$this->state_id;
|
||||
$tmpobj->country_id=$this->country_id;
|
||||
|
||||
$tmpobj->user_id=$this->id;
|
||||
$tmpobj->user_login=$this->login;
|
||||
|
||||
$result=$tmpobj->update($tmpobj->id, $user, 0, 'update', 1);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$tmpobj->error;
|
||||
$this->errors=$tmpobj->errors;
|
||||
dol_syslog(get_class($this)."::update error after calling adh->update to sync it with user: ".$this->error, LOG_ERR);
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$tmpobj->error;
|
||||
$this->errors=$tmpobj->errors;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$action='update';
|
||||
|
||||
@ -1622,7 +1622,7 @@ $head = array();
|
||||
|
||||
|
||||
/*
|
||||
* Edit Site HTML header of CSS
|
||||
* Edit Site HTML header and CSS
|
||||
*/
|
||||
|
||||
if ($action == 'editcss')
|
||||
@ -1672,7 +1672,12 @@ if ($action == 'editcss')
|
||||
$htmlheadercontent.='<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />'."\n";
|
||||
$htmlheadercontent.="</html>";
|
||||
}
|
||||
else $htmlheadercontent='<html>'."\n".trim($htmlheadercontent)."\n".'</html>';
|
||||
else
|
||||
{
|
||||
$htmlheadercontent = preg_replace('/^\s*<html>/ims', '', $htmlheadercontent);
|
||||
$htmlheadercontent = preg_replace('/<\/html>\s*$/ims', '', $htmlheadercontent);
|
||||
$htmlheadercontent='<html>'."\n".trim($htmlheadercontent)."\n".'</html>';
|
||||
}
|
||||
|
||||
if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha'))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user