From aec4cef5de4f8e4cc3b63d4f112bed5f66f8f42e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Fri, 19 May 2017 12:58:38 +0200 Subject: [PATCH] Clean some code for type of event deprecated since 3.3 --- htdocs/admin/mails.php | 4 +- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 1 - htdocs/compta/facture/card.php | 1 - htdocs/contrat/card.php | 1 - htdocs/core/actions_massactions.inc.php | 8 +- htdocs/core/actions_sendmails.inc.php | 43 +- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/core/lib/usergroups.lib.php | 2 +- ...terface_50_modAgenda_ActionsAuto.class.php | 58 +- htdocs/expedition/card.php | 1 - htdocs/fichinter/card.php | 2 - htdocs/fourn/commande/card.php | 1 - htdocs/fourn/facture/card.php | 1 - .../install/mysql/data/llx_c_actioncomm.sql | 12 +- .../install/mysql/migration/5.0.0-6.0.0.sql | 3 +- htdocs/langs/en_US/main.lang | 1 + htdocs/societe/card.php | 1 - htdocs/supplier_proposal/card.php | 1 - htdocs/theme/eldy/style.css.php | 1 + htdocs/theme/md/style.css.php | 3 +- htdocs/user/card.php | 1122 +++++++++-------- 22 files changed, 612 insertions(+), 659 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 219cd85c2fe..03cce1dff09 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -86,8 +86,8 @@ if ($action == 'update' && empty($_POST["cancel"])) // Actions to send emails $id=0; -$actiontypecode=''; -$trigger_name=''; +$actiontypecode=''; // Not an event for agenda +$trigger_name=''; // Disable triggers $paramname='id'; $mode='emailfortest'; $trackid=(($action == 'testhtml')?"testhtml":"test"); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 0ee995e4784..df86464281a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -644,7 +644,7 @@ if (empty($reshook)) */ // Actions to send emails - $actiontypecode='AC_PROP'; + $actiontypecode='AC_OTH_AUTO'; $trigger_name='PROPAL_SENTBYMAIL'; $paramname='id'; $mode='emailfromproposal'; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 07f25b40ed8..fe91f0b6ff8 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1259,7 +1259,6 @@ if (empty($reshook)) // Actions to send emails - $actiontypecode='AC_COM'; $trigger_name='ORDER_SENTBYMAIL'; $paramname='id'; $mode='emailfromorder'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 02b67c814ef..4835b53b277 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1911,7 +1911,6 @@ if (empty($reshook)) // Actions to send emails if (empty($id)) $id=$facid; - $actiontypecode='AC_FAC'; $trigger_name='BILL_SENTBYMAIL'; $paramname='id'; $mode='emailfrominvoice'; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 0e0f8c84090..f00816e9d4b 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -953,7 +953,6 @@ if (empty($reshook)) */ // Actions to send emails - $actiontypecode='AC_CONT'; $trigger_name='CONTRACT_SENTBYMAIL'; $paramname='id'; $mode='emailfromcontract'; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 58e47a29ec8..92d1011b923 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -274,12 +274,12 @@ if (! $error && $massaction == 'confirm_presend') // Insert logs into agenda foreach($listofqualifiedinvoice as $invid => $object) { - if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; + /*if ($objectclass == 'Propale') $actiontypecode='AC_PROP'; if ($objectclass == 'Commande') $actiontypecode='AC_COM'; if ($objectclass == 'Facture') $actiontypecode='AC_FAC'; if ($objectclass == 'Supplier_Proposal') $actiontypecode='AC_SUP_PRO'; if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD'; - if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV'; + if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/ $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) @@ -289,10 +289,10 @@ if (! $error && $massaction == 'confirm_presend') $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); $actionmsg = dol_concatdesc($actionmsg, $message); } - + $actionmsg2=''; + // Initialisation donnees $object->sendtoid = 0; - $object->actiontypecode = $actiontypecode; $object->actionmsg = $actionmsg; // Long text $object->actionmsg2 = $actionmsg2; // Short text $object->fk_element = $invid; diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index cf50d05d6bf..dded23e6cbf 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -23,11 +23,11 @@ // $mysoc must be defined // $id must be defined -// $actiontypecode must be defined // $paramname must be defined // $mode must be defined -// $object and $uobject may be defined. - +// $trigger_name must be set (can be '') +// $actiontypecode can be set +// $object and $uobject may be defined /* * Add file in email form @@ -155,7 +155,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } - else dol_print_error('','Use actions_sendmails.in.php for a type that is not supported'); + else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); } else $thirdparty = $mysoc; @@ -347,7 +347,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $error=0; - // FIXME This must be moved into a trigger for action $trigger_name + // FIXME This must be moved into the trigger for action $trigger_name if (! empty($conf->dolimail->enabled)) { $mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ? @@ -370,21 +370,26 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Initialisation of datas if (is_object($object)) { - $object->socid = $sendtosocid; // To link to a company - $object->sendtoid = $sendtoid; // To link to contacts/addresses. This is an array. - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; // Long text - $object->actionmsg2 = $actionmsg2; // Short text + if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically + + $object->socid = $sendtosocid; // To link to a company + $object->sendtoid = $sendtoid; // To link to contacts/addresses. This is an array. + $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $object->actionmsg = $actionmsg; // Long text + $object->actionmsg2 = $actionmsg2; // Short text $object->trackid = $trackid; $object->fk_element = $object->id; $object->elementtype = $object->element; // Call of triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $errors=$interface->errors; + if (! empty($trigger_name)) + { + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $errors=$interface->errors; + } } } @@ -398,8 +403,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - if ($conf->dolimail->enabled) header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id.'&'.($paramname2?$paramname2:'mid').'='.$parm2val); - else header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id); + if ($conf->dolimail->enabled) + { + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val); + exit; + } + header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'')); exit; } } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 020382095a3..3641ac87cef 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -297,7 +297,7 @@ class FormMail extends Form $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); //var_dump($arraydefaultmessage); - $out.= "\n<!-- Begin form mail -->\n"; + $out.= "\n".'<!-- Begin form mail --><div id="mailformdiv"></div>'."\n"; if ($this->withform == 1) { $out.= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'#formmail">'."\n"; diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 2cea718dcc0..f48974acb02 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -145,7 +145,7 @@ function user_prepare_head($object) { // Bank $head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id; - $head[$h][1] = $langs->trans("BankAccounts"); + $head[$h][1] = $langs->trans("HR"); $head[$h][2] = 'bank'; $h++; } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 9da1ada59ad..1160fb2625d 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -76,6 +76,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("agenda"); + if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO'; + // Actions if ($action == 'COMPANY_CREATE') { @@ -83,7 +85,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("companies"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->name); $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->name); if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")"; @@ -97,7 +98,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - if (empty($object->actiontypecode)) $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) dol_syslog('Trigger called with property actionmsg2 on object not defined', LOG_ERR); // Parameters $object->sendtoid defined by caller @@ -109,7 +109,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("contracts"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -121,7 +120,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("propal"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -133,7 +131,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("propal"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref); if (empty($object->actionmsg)) { @@ -149,7 +146,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("propal"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref); @@ -161,7 +157,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("propal"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClassifiedBilledInDolibarr",$object->ref); @@ -173,7 +168,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("propal"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref); @@ -184,7 +178,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("agenda"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -196,7 +189,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderDeliveredInDolibarr",$object->ref); @@ -208,7 +200,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderBilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderBilledInDolibarr",$object->ref); @@ -220,7 +211,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderCanceledInDolibarr",$object->ref); @@ -232,7 +222,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref); if (empty($object->actionmsg)) { @@ -248,7 +237,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("bills"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -260,7 +248,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("bills"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); @@ -272,7 +259,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("bills"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref); if (empty($object->actionmsg)) { @@ -289,7 +275,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("bills"); // Values for this action can't be defined by caller. - $object->actiontypecode='AC_OTH_AUTO'; $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); @@ -301,7 +286,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("bills"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); @@ -313,7 +297,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("interventions"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionCreatedInDolibarr",$object->ref); @@ -327,7 +310,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("interventions"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -341,7 +323,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("interventions"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionModifiedInDolibarr",$object->ref); @@ -355,7 +336,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("interventions"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref); @@ -368,7 +348,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("interventions"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilledInDolibarr",$object->ref); @@ -380,7 +359,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("interventions"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionClassifiedUnbilledInDolibarr",$object->ref); @@ -392,7 +370,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("interventions"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InterventionDeletedInDolibarr",$object->ref); @@ -406,7 +383,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("sendings"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",($object->newref?$object->newref:$object->ref)); if (empty($object->actionmsg)) { @@ -422,7 +398,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("sendings"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref); if (empty($object->actionmsg)) { @@ -438,7 +413,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("OrderCreatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -450,7 +424,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -462,7 +435,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref); @@ -474,7 +446,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref); @@ -486,7 +457,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("SupplierOrderSubmitedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -498,7 +468,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("SupplierOrderReceivedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -511,7 +480,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("bills"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref); if (empty($object->actionmsg)) { @@ -528,7 +496,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("bills"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderClassifiedBilled",$object->ref); if (empty($object->actionmsg)) { @@ -543,7 +510,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("bills"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); @@ -555,7 +521,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("bills"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); @@ -568,7 +533,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("bills"); $langs->load("orders"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref); if (empty($object->actionmsg)) { @@ -584,7 +548,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("bills"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref); @@ -596,7 +559,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("bills"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref); @@ -610,7 +572,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("members"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); @@ -624,7 +585,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("members"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberModifiedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("MemberModifiedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); @@ -638,7 +598,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("members"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); @@ -654,7 +613,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("members"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); @@ -668,7 +626,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("members"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); @@ -684,7 +641,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("projects"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref; @@ -696,8 +652,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("projects"); - $object->actiontypecode='AC_OTH_AUTO'; - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("ProjectValidatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref; @@ -709,7 +663,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("projects"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProjectModifiedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("ProjectModifieddInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; @@ -723,8 +676,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("projects"); - $object->actiontypecode='AC_OTH_AUTO'; - if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("TaskCreatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; @@ -737,7 +688,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("projects"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskModifiedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("TaskModifieddInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; @@ -750,7 +700,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("other"); $langs->load("projects"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("TaskDeletedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; @@ -763,7 +712,6 @@ class InterfaceActionsAuto extends DolibarrTriggers $langs->load("agenda"); $langs->load("other"); - $object->actiontypecode='AC_OTH_AUTO'; if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities($action."InDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities($action."InDolibarr",$object->ref); @@ -805,7 +753,7 @@ class InterfaceActionsAuto extends DolibarrTriggers // Insertion action require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); - $actioncomm->type_code = $object->actiontypecode; // code of parent table llx_c_actioncomm (will be deprecated) + $actioncomm->type_code = $object->actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; // TODO Replace with $actioncomm->email_msgid ? $object->email_content : $object->actionmsg diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index a0280ce9e39..fdd477cc63d 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -595,7 +595,6 @@ if (empty($reshook)) // Actions to send emails if (empty($id)) $id=$facid; - $actiontypecode='AC_SHIP'; $trigger_name='SHIPPING_SENTBYMAIL'; $paramname='id'; $mode='emailfromshipment'; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 91e094c1a50..51cd5a62d3f 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -719,8 +719,6 @@ if (empty($reshook)) */ // Actions to send emails - $actiontypecode='AC_OTH_AUTO'; - $trigger_name='FICHINTER_SENTBYMAIL'; $paramname='id'; $mode='emailfromintervention'; $trackid='int'.$object->id; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 378fab9f50c..a6f0cc248f1 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1154,7 +1154,6 @@ if (empty($reshook)) */ // Actions to send emails - $actiontypecode='AC_SUP_ORD'; $trigger_name='ORDER_SUPPLIER_SENTBYMAIL'; $paramname='id'; $mode='emailfromsupplierorder'; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index bda155efe88..04e6ea98481 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1188,7 +1188,6 @@ if (empty($reshook)) */ // Actions to send emails - $actiontypecode='AC_SUP_INV'; $trigger_name='BILL_SUPPLIER_SENTBYMAIL'; $paramname='id'; $mode='emailfromsupplierinvoice'; diff --git a/htdocs/install/mysql/data/llx_c_actioncomm.sql b/htdocs/install/mysql/data/llx_c_actioncomm.sql index 2b84ee6ff82..6b89ed74dd2 100644 --- a/htdocs/install/mysql/data/llx_c_actioncomm.sql +++ b/htdocs/install/mysql/data/llx_c_actioncomm.sql @@ -38,12 +38,12 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 5,'AC_RDV','system','Rendez-vous',NULL, 1, 1); insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values (11,'AC_INT','system','Intervention on site',NULL, 1, 4); -- Code kept for backward compatibility < 3.3 -insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 3,'AC_PROP','systemauto', 'Send commercial proposal by email','propal',0,10); -insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 8,'AC_COM','systemauto','Send customer order by email','order', 0,8); -insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 9,'AC_FAC','systemauto', 'Send customer invoice by email','invoice',0,6); -insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 10,'AC_SHIP','systemauto', 'Send shipping by email','shipping',0,11); -insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 30,'AC_SUP_ORD','systemauto','Send supplier order by email','order_supplier',0,9); -insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 31,'AC_SUP_INV','systemauto','Send supplier invoice by email','invoice_supplier',0,7); +--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 3,'AC_PROP','systemauto', 'Send commercial proposal by email','propal',0,10); +--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 8,'AC_COM','systemauto','Send customer order by email','order', 0,8); +--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 9,'AC_FAC','systemauto', 'Send customer invoice by email','invoice',0,6); +--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 10,'AC_SHIP','systemauto', 'Send shipping by email','shipping',0,11); +--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 30,'AC_SUP_ORD','systemauto','Send supplier order by email','order_supplier',0,9); +--insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 31,'AC_SUP_INV','systemauto','Send supplier invoice by email','invoice_supplier',0,7); -- Code used from 3.3+ when type of event is not used insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 40,'AC_OTH_AUTO','systemauto','Other (automatically inserted events)',NULL, 1, 20); insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 50,'AC_OTH','system','Other (manually inserted events)',NULL, 1, 5); diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 6ba7707b249..725eca55daa 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -296,7 +296,6 @@ ALTER TABLE llx_events MODIFY COLUMN ip varchar(250); ALTER TABLE llx_facture ADD COLUMN fk_fac_rec_source integer; - - +DELETE from llx_c_actioncomm where code in ('AC_PROP','AC_COM','AC_FAC','AC_SHIP','AC_SUP_ORD','AC_SUP_INV') AND id NOT IN (SELECT DISTINCT fk_action FROM llx_actioncomm); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 79927cc888c..a5f2ddf1e7e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -771,6 +771,7 @@ ModuleBuilder=Module Builder SetMultiCurrencyCode=Set currency BulkActions=Bulk actions ClickToShowHelp=Click to show tooltip help +HR=HR # Week day Monday=Monday Tuesday=Tuesday diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 5a53a2c6ed2..14e8e4b4679 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -750,7 +750,6 @@ if (empty($reshook)) // Actions to send emails $id=$socid; - $actiontypecode='AC_OTH_AUTO'; $trigger_name='COMPANY_SENTBYMAIL'; $paramname='socid'; $mode='emailfromthirdparty'; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index d36b471a721..86c350ecc22 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -466,7 +466,6 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $actiontypecode='AC_ASKPRICE'; $trigger_name='SUPPLIER_PROPOSAL_SENTBYMAIL'; $paramname='id'; $mode='emailfromsupplierproposal'; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 66f880da786..4ae7d400a09 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1101,6 +1101,7 @@ div.nopadding { padding-top: 1px; padding-bottom: 1px; width: 44px; + text-align:center; } div.attacharea { padding-top: 18px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 04732ef0305..2beef147c02 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1145,6 +1145,7 @@ img.hideonsmartphone.pictoactionview { padding-top: 1px; padding-bottom: 1px; width: 44px; + text-align:center; } div.attacharea { padding-top: 18px; @@ -3054,7 +3055,7 @@ div.info { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; - background: #EaE4Ea; + background: #868; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index d98ef682e90..9249e8f295e 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -593,7 +593,6 @@ if (empty($reshook)) { } // Actions to send emails - $actiontypecode='AC_OTH_AUTO'; $trigger_name='USER_SENTBYMAIL'; $paramname='id'; // Name of param key to open the card $mode='emailfromuser'; @@ -1005,14 +1004,6 @@ if (($action == 'create') || ($action == 'adduserldap')) } print '</td></tr>'; - // Signature - print '<tr><td class="tdtop">'.$langs->trans("Signature").'</td>'; - print '<td>'; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('signature',GETPOST('signature'),'',138,'dolibarr_mailings','In',true,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%'); - print $doleditor->Create(1); - print '</td></tr>'; - // Multicompany if (! empty($conf->multicompany->enabled)) { @@ -1028,6 +1019,15 @@ if (($action == 'create') || ($action == 'adduserldap')) } } + // Accountancy code + if ($conf->accounting->enabled) + { + print '<tr><td>'.$langs->trans("AccountancyCode").'</td>'; + print '<td>'; + print '<input size="30" type="text" name="accountancy_code" value="'.GETPOST('accountancy_code').'">'; + print '</td></tr>'; + } + // Hierarchy print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>'; print '<td>'; @@ -1035,7 +1035,8 @@ if (($action == 'create') || ($action == 'adduserldap')) print '</td>'; print "</tr>\n"; - if ($conf->salaries->enabled && ! empty($user->rights->salaries->read)) + if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) + || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); @@ -1081,15 +1082,6 @@ if (($action == 'create') || ($action == 'adduserldap')) print '</td>'; print "</tr>\n"; - // Accountancy code - if ($conf->accounting->enabled) - { - print '<tr><td>'.$langs->trans("AccountancyCode").'</td>'; - print '<td>'; - print '<input size="30" type="text" name="accountancy_code" value="'.GETPOST('accountancy_code').'">'; - print '</td></tr>'; - } - // User color if (! empty($conf->agenda->enabled)) { @@ -1108,6 +1100,14 @@ if (($action == 'create') || ($action == 'adduserldap')) null, '90%' ); print "</td></tr>"; } + + // Other attributes + $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } // Note print '<tr><td class="tdtop">'; @@ -1118,15 +1118,15 @@ if (($action == 'create') || ($action == 'adduserldap')) $doleditor->Create(); print "</td></tr>\n"; - // Other attributes - $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields,'edit'); - } - - print "</table>\n"; + // Signature + print '<tr><td class="tdtop">'.$langs->trans("Signature").'</td>'; + print '<td>'; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('signature',GETPOST('signature'),'',138,'dolibarr_mailings','In',true,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%'); + print $doleditor->Create(1); + print '</td></tr>'; + + print "</table>\n"; dol_fiche_end(); @@ -1379,11 +1379,15 @@ else print '</td></tr>'."\n"; } - // Signature - print '<tr><td class="tdtop">'.$langs->trans('Signature').'</td><td>'; - print dol_htmlentitiesbr($object->signature); - print "</td></tr>\n"; - + // Accountancy code + if ($conf->accounting->enabled) + { + print '<tr><td>'.$langs->trans("AccountancyCode").'</td>'; + print '<td>'.$object->accountancy_code.'</td></tr>'; + } + + // TODO Move this into RH Tab (visible if RH module on) + // Hierarchy print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>'; print '<td>'; @@ -1396,7 +1400,8 @@ else print '</td>'; print "</tr>\n"; - if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) + if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) + || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); @@ -1435,13 +1440,6 @@ else print '</td>'; print "</tr>\n"; - // Accountancy code - if ($conf->accounting->enabled) - { - print '<tr><td>'.$langs->trans("AccountancyCode").'</td>'; - print '<td>'.$object->accountancy_code.'</td>'; - } - // Date employment print '<tr><td>'.$langs->trans("DateEmployment").'</td>'; print '<td>'; @@ -1449,7 +1447,7 @@ else print '</td>'; print "</tr>\n"; - print '</table>'; + print '</table>'; print '</div>'; print '<div class="fichehalfright"><div class="ficheaddleft">'; @@ -1567,7 +1565,12 @@ else print '</tr>'."\n"; } - print "</table>\n"; + // Signature + print '<tr><td class="tdtop">'.$langs->trans('Signature').'</td><td>'; + print dol_htmlentitiesbr($object->signature); + print "</td></tr>\n"; + + print "</table>\n"; print '</div>'; print '</div></div>'; @@ -1772,586 +1775,574 @@ else dol_fiche_end(); } - } - - if (GETPOST('action','aZ09') != 'presend' && GETPOST('action','aZ09') != 'send') - { - /* - * List of groups of user - */ - if ($canreadgroup) + if (GETPOST('action','aZ09') != 'presend' && GETPOST('action','aZ09') != 'send') { - print load_fiche_titre($langs->trans("ListOfGroupsForUser"),'',''); - - // On selectionne les groupes auquel fait parti le user - $exclude = array(); - - $usergroup=new UserGroup($db); - $groupslist = $usergroup->listGroupsForUser($object->id); - - if (! empty($groupslist)) + /* + * List of groups of user + */ + + if ($canreadgroup) { - if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))) + print load_fiche_titre($langs->trans("ListOfGroupsForUser"),'',''); + + // On selectionne les groupes auquel fait parti le user + $exclude = array(); + + $usergroup=new UserGroup($db); + $groupslist = $usergroup->listGroupsForUser($object->id); + + if (! empty($groupslist)) { - foreach($groupslist as $groupforuser) + if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))) { - $exclude[]=$groupforuser->id; + foreach($groupslist as $groupforuser) + { + $exclude[]=$groupforuser->id; + } } } - } - - if ($caneditgroup) - { - print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'."\n"; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />'; - print '<input type="hidden" name="action" value="addgroup" />'; - } - - print '<table class="noborder" width="100%">'."\n"; - print '<tr class="liste_titre"><th class="liste_titre" width="25%">'.$langs->trans("Groups").'</th>'."\n"; - if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print '<td class="liste_titre" width="25%">'.$langs->trans("Entity").'</td>'; - } - print '<th align="right">'; - if ($caneditgroup) - { - print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); - print ' '; - // Multicompany - if (! empty($conf->multicompany->enabled)) + + if ($caneditgroup) { - if ($conf->entity == 1 && $conf->multicompany->transverse_mode) - { - print '</td><td>'.$langs->trans("Entity").'</td>'; - print "<td>".$mc->select_entities($conf->entity); - } - else - { - print '<input type="hidden" name="entity" value="'.$conf->entity.'" />'; - } + print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'."\n"; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />'; + print '<input type="hidden" name="action" value="addgroup" />'; } - else + + print '<table class="noborder" width="100%">'."\n"; + print '<tr class="liste_titre"><th class="liste_titre" width="25%">'.$langs->trans("Groups").'</th>'."\n"; + if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { - print '<input type="hidden" name="entity" value="'.$conf->entity.'" />'; + print '<td class="liste_titre" width="25%">'.$langs->trans("Entity").'</td>'; } - print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />'; - } - print '</th></tr>'."\n"; - - /* - * Groups assigned to user - */ - if (! empty($groupslist)) - { - foreach($groupslist as $group) + print '<th align="right">'; + if ($caneditgroup) { - - - print '<tr class="oddeven">'; - print '<td>'; - if ($caneditgroup) - { - print '<a href="'.DOL_URL_ROOT.'/user/group/card.php?id='.$group->id.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$group->name.'</a>'; - } - else - { - print img_object($langs->trans("ShowGroup"),"group").' '.$group->name; - } - print '</td>'; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); + print ' '; + // Multicompany + if (! empty($conf->multicompany->enabled)) { - print '<td class="valeur">'; - if (! empty($group->usergroup_entity)) - { - $nb=0; - foreach($group->usergroup_entity as $group_entity) - { - $mc->getInfo($group_entity); - print ($nb > 0 ? ', ' : '').$mc->label; - print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removegroup&group='.$group->id.'&entity='.$group_entity.'">'; - print img_delete($langs->trans("RemoveFromGroup")); - print '</a>'; - $nb++; - } - } - } - print '<td align="right">'; - if ($caneditgroup && empty($conf->multicompany->transverse_mode)) - { - print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removegroup&group='.$group->id.'">'; - print img_delete($langs->trans("RemoveFromGroup")); - print '</a>'; + if ($conf->entity == 1 && $conf->multicompany->transverse_mode) + { + print '</td><td>'.$langs->trans("Entity").'</td>'; + print "<td>".$mc->select_entities($conf->entity); + } + else + { + print '<input type="hidden" name="entity" value="'.$conf->entity.'" />'; + } } else { - print " "; + print '<input type="hidden" name="entity" value="'.$conf->entity.'" />'; } - print "</td></tr>\n"; - } - } - else - { - print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; - } - - print "</table>"; - - if ($caneditgroup) - { - print '</form>'; - } - print "<br>"; - } - - /* - * Fiche en mode edition - */ - if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id))) - { - print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST" name="updateuser" enctype="multipart/form-data">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="update">'; - print '<input type="hidden" name="entity" value="'.$object->entity.'">'; - - dol_fiche_head($head, 'user', $title, 0, 'user'); - - print '<table width="100%" class="border">'; - - // Ref/ID - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) - { - print '<tr><td>'.$langs->trans("Ref").'</td>'; - print '<td>'; - print $object->id; - print '</td>'; - print '</tr>'; - } - - // Lastname - print "<tr>"; - print '<td class="fieldrequired">'.$langs->trans("Lastname").'</td>'; - print '<td>'; - if ($caneditfield && !$object->ldap_sid) - { - print '<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.'">'; - } - else - { - print '<input type="hidden" name="lastname" value="'.$object->lastname.'">'; - print $object->lastname; - } - print '</td>'; - print '</tr>'; - - // Firstname - print "<tr>".'<td>'.$langs->trans("Firstname").'</td>'; - print '<td>'; - if ($caneditfield && !$object->ldap_sid) - { - print '<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.'">'; - } - else - { - print '<input type="hidden" name="firstname" value="'.$object->firstname.'">'; - print $object->firstname; - } - 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>'; - - // Login - print "<tr>".'<td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>'; - print '<td>'; - if ($user->admin && !$object->ldap_sid) - { - print '<input size="12" maxlength="24" type="text" class="flat" name="login" value="'.$object->login.'">'; - } - else - { - print '<input type="hidden" name="login" value="'.$object->login.'">'; - print $object->login; - } - print '</td>'; - print '</tr>'; - - // Pass - print '<tr><td>'.$langs->trans("Password").'</td>'; - print '<td>'; - if ($object->ldap_sid) - { - $text=$langs->trans("DomainPassword"); - } - else if ($caneditpassword) - { - $text='<input size="12" maxlength="32" type="password" class="flat" name="password" value="'.$object->pass.'" autocomplete="off">'; - if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http') - { - $text=$form->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning'); + print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />'; } - } - else - { - $text=preg_replace('/./i','*',$object->pass); - } - print $text; - print "</td></tr>\n"; + print '</th></tr>'."\n"; - // API key - if(! empty($conf->api->enabled) && $user->admin) { - print '<tr><td>'.$langs->trans("ApiKey").'</td>'; - print '<td>'; - print '<input class="minwidth100" maxsize="32" type="text" id="api_key" name="api_key" value="'.$object->api_key.'" autocomplete="off">'; - if (! empty($conf->use_javascript_ajax)) - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); - print '</td></tr>'; - } - - // Administrator - print '<tr><td>'.$langs->trans("Administrator").'</td>'; - if ($object->societe_id > 0) - { - $langs->load("admin"); - print '<td>'; - print '<input type="hidden" name="admin" value="'.$object->admin.'">'.yn($object->admin); - print ' ('.$langs->trans("ExternalUser").')'; - print '</td></tr>'; - } - else - { - print '<td>'; - $nbAdmin = $user->getNbOfUsers('active','',1); - $nbSuperAdmin = $user->getNbOfUsers('active','superadmin',1); - //var_dump($nbAdmin); - //var_dump($nbSuperAdmin); - if ($user->admin // Need to be admin to allow downgrade of an admin - && ($user->id != $object->id) // Don't downgrade ourself - && ( - (empty($conf->multicompany->enabled) && $nbAdmin >= 1) - || (! empty($conf->multicompany->enabled) && ($object->entity > 0 || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone - ) - ) + /* + * Groups assigned to user + */ + if (! empty($groupslist)) { - print $form->selectyesno('admin',$object->admin,1); - - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) + foreach($groupslist as $group) { - if ($conf->use_javascript_ajax) + + + print '<tr class="oddeven">'; + print '<td>'; + if ($caneditgroup) { - print '<script type="text/javascript"> - $(function() { - var admin = $("select[name=admin]").val(); - if (admin == 0) { - $("input[name=superadmin]") - .prop("disabled", true) - .prop("checked", false); - } - if ($("input[name=superadmin]").is(":checked")) { - $("select[name=entity]") - .prop("disabled", true); - } - $("select[name=admin]").change(function() { - if ( $(this).val() == 0 ) { - $("input[name=superadmin]") - .prop("disabled", true) - .prop("checked", false); - $("select[name=entity]") - .prop("disabled", false); - } else { - $("input[name=superadmin]") - .prop("disabled", false); - } - }); - $("input[name=superadmin]").change(function() { - if ( $(this).is(":checked")) { - $("select[name=entity]") - .prop("disabled", true); - } else { - $("select[name=entity]") - .prop("disabled", false); - } - }); - }); - </script>'; + print '<a href="'.DOL_URL_ROOT.'/user/group/card.php?id='.$group->id.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$group->name.'</a>'; } - - $checked=(($object->admin && ! $object->entity) ? ' checked' : ''); - print '<input type="checkbox" name="superadmin" value="1"'.$checked.' /> '.$langs->trans("SuperAdministrator"); + else + { + print img_object($langs->trans("ShowGroup"),"group").' '.$group->name; + } + print '</td>'; + if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print '<td class="valeur">'; + if (! empty($group->usergroup_entity)) + { + $nb=0; + foreach($group->usergroup_entity as $group_entity) + { + $mc->getInfo($group_entity); + print ($nb > 0 ? ', ' : '').$mc->label; + print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removegroup&group='.$group->id.'&entity='.$group_entity.'">'; + print img_delete($langs->trans("RemoveFromGroup")); + print '</a>'; + $nb++; + } + } + } + print '<td align="right">'; + if ($caneditgroup && empty($conf->multicompany->transverse_mode)) + { + print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=removegroup&group='.$group->id.'">'; + print img_delete($langs->trans("RemoveFromGroup")); + print '</a>'; + } + else + { + print " "; + } + print "</td></tr>\n"; } } else { - $yn = yn($object->admin); - print '<input type="hidden" name="admin" value="'.$object->admin.'">'; - print '<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).'">'; - if (! empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning'); - else print $yn; + print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; } - print '</td></tr>'; - } - // Type - print '<tr><td>'.$langs->trans("Type").'</td>'; - print '<td>'; - if ($user->id == $object->id || ! $user->admin) - { - $type=$langs->trans("Internal"); - if ($object->societe_id) $type=$langs->trans("External"); - print $form->textwithpicto($type,$langs->trans("InternalExternalDesc")); - if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; - } - else - { - $type=0; - if ($object->contact_id) $type=$object->contact_id; - print $form->selectcontacts(0,$type,'contactid',2,'','',1,'',false,1); - if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; + print "</table>"; + + if ($caneditgroup) + { + print '</form>'; + } + print "<br>"; } - print '</td></tr>'; - - // Address - print '<tr><td class="tdtop">'.fieldLabel('Address','address').'</td>'; - print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">'; - print $object->address; - print '</textarea></td></tr>'; - - // Zip - print '<tr><td>'.fieldLabel('Zip','zipcode').'</td><td>'; - print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); - print '</td></tr>'; - - // Town - print '<tr><td>'.fieldLabel('Town','town').'</td><td>'; - print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - print '</td></tr>'; - - // Country - print '<tr><td>'.fieldLabel('Country','selectcounty_id').'</td><td>'; - print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); - print '</td></tr>'; - - // State - if (empty($conf->global->USER_DISABLE_STATE)) + } + } + + /* + * Fiche en mode edition + */ + if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id))) + { + print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST" name="updateuser" enctype="multipart/form-data">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="action" value="update">'; + print '<input type="hidden" name="entity" value="'.$object->entity.'">'; + + dol_fiche_head($head, 'user', $title, 0, 'user'); + + print '<table width="100%" class="border">'; + + // Ref/ID + if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + { + print '<tr><td>'.$langs->trans("Ref").'</td>'; + print '<td>'; + print $object->id; + print '</td>'; + print '</tr>'; + } + + // Lastname + print "<tr>"; + print '<td class="fieldrequired">'.$langs->trans("Lastname").'</td>'; + print '<td>'; + if ($caneditfield && !$object->ldap_sid) + { + print '<input class="minwidth100" type="text" class="flat" name="lastname" value="'.$object->lastname.'">'; + } + else + { + print '<input type="hidden" name="lastname" value="'.$object->lastname.'">'; + print $object->lastname; + } + print '</td>'; + print '</tr>'; + + // Firstname + print "<tr>".'<td>'.$langs->trans("Firstname").'</td>'; + print '<td>'; + if ($caneditfield && !$object->ldap_sid) + { + print '<input class="minwidth100" type="text" class="flat" name="firstname" value="'.$object->firstname.'">'; + } + else + { + print '<input type="hidden" name="firstname" value="'.$object->firstname.'">'; + print $object->firstname; + } + 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>'; + + // Login + print "<tr>".'<td><span class="fieldrequired">'.$langs->trans("Login").'</span></td>'; + print '<td>'; + if ($user->admin && !$object->ldap_sid) + { + print '<input size="12" maxlength="24" type="text" class="flat" name="login" value="'.$object->login.'">'; + } + else + { + print '<input type="hidden" name="login" value="'.$object->login.'">'; + print $object->login; + } + print '</td>'; + print '</tr>'; + + // Pass + print '<tr><td>'.$langs->trans("Password").'</td>'; + print '<td>'; + if ($object->ldap_sid) + { + $text=$langs->trans("DomainPassword"); + } + else if ($caneditpassword) + { + $text='<input size="12" maxlength="32" type="password" class="flat" name="password" value="'.$object->pass.'" autocomplete="off">'; + if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http') { - print '<tr><td class="tdoverflow">'.fieldLabel('State','state_id').'</td><td>'; - print $formcompany->select_state($object->state_id,$object->country_code, 'state_id'); - print '</td></tr>'; + $text=$form->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning'); } - - // Tel pro - print "<tr>".'<td>'.$langs->trans("PhonePro").'</td>'; + } + else + { + $text=preg_replace('/./i','*',$object->pass); + } + print $text; + print "</td></tr>\n"; + + // API key + if(! empty($conf->api->enabled) && $user->admin) + { + print '<tr><td>'.$langs->trans("ApiKey").'</td>'; print '<td>'; - if ($caneditfield && empty($object->ldap_sid)) - { - print '<input size="20" type="text" name="office_phone" class="flat" value="'.$object->office_phone.'">'; - } - else - { - print '<input type="hidden" name="office_phone" value="'.$object->office_phone.'">'; - print $object->office_phone; - } + print '<input class="minwidth300" maxsize="32" type="text" id="api_key" name="api_key" value="'.$object->api_key.'" autocomplete="off">'; + if (! empty($conf->use_javascript_ajax)) + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); print '</td></tr>'; - - // Tel mobile - print "<tr>".'<td>'.$langs->trans("PhoneMobile").'</td>'; + } + + // Administrator + print '<tr><td>'.$langs->trans("Administrator").'</td>'; + if ($object->societe_id > 0) + { + $langs->load("admin"); print '<td>'; - if ($caneditfield && empty($object->ldap_sid)) - { - print '<input size="20" type="text" name="user_mobile" class="flat" value="'.$object->user_mobile.'">'; - } - else - { - print '<input type="hidden" name="user_mobile" value="'.$object->user_mobile.'">'; - print $object->user_mobile; - } + print '<input type="hidden" name="admin" value="'.$object->admin.'">'.yn($object->admin); + print ' ('.$langs->trans("ExternalUser").')'; print '</td></tr>'; - - // Fax - print "<tr>".'<td>'.$langs->trans("Fax").'</td>'; + } + else + { print '<td>'; - if ($caneditfield && empty($object->ldap_sid)) + $nbAdmin = $user->getNbOfUsers('active','',1); + $nbSuperAdmin = $user->getNbOfUsers('active','superadmin',1); + //var_dump($nbAdmin); + //var_dump($nbSuperAdmin); + if ($user->admin // Need to be admin to allow downgrade of an admin + && ($user->id != $object->id) // Don't downgrade ourself + && ( + (empty($conf->multicompany->enabled) && $nbAdmin >= 1) + || (! empty($conf->multicompany->enabled) && ($object->entity > 0 || $nbSuperAdmin > 1)) // Don't downgrade a superadmin if alone + ) + ) { - print '<input size="20" type="text" name="office_fax" class="flat" value="'.$object->office_fax.'">'; + print $form->selectyesno('admin',$object->admin,1); + + if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) + { + if ($conf->use_javascript_ajax) + { + print '<script type="text/javascript"> + $(function() { + var admin = $("select[name=admin]").val(); + if (admin == 0) { + $("input[name=superadmin]") + .prop("disabled", true) + .prop("checked", false); + } + if ($("input[name=superadmin]").is(":checked")) { + $("select[name=entity]") + .prop("disabled", true); + } + $("select[name=admin]").change(function() { + if ( $(this).val() == 0 ) { + $("input[name=superadmin]") + .prop("disabled", true) + .prop("checked", false); + $("select[name=entity]") + .prop("disabled", false); + } else { + $("input[name=superadmin]") + .prop("disabled", false); + } + }); + $("input[name=superadmin]").change(function() { + if ( $(this).is(":checked")) { + $("select[name=entity]") + .prop("disabled", true); + } else { + $("select[name=entity]") + .prop("disabled", false); + } + }); + }); + </script>'; + } + + $checked=(($object->admin && ! $object->entity) ? ' checked' : ''); + print '<input type="checkbox" name="superadmin" value="1"'.$checked.' /> '.$langs->trans("SuperAdministrator"); + } } else { - print '<input type="hidden" name="office_fax" value="'.$object->office_fax.'">'; - print $object->office_fax; + $yn = yn($object->admin); + print '<input type="hidden" name="admin" value="'.$object->admin.'">'; + print '<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).'">'; + if (! empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning'); + else print $yn; } print '</td></tr>'; - - // Skype - if (! empty($conf->skype->enabled)) - { - print '<tr><td>'.$langs->trans("Skype").'</td>'; - print '<td>'; - if ($caneditfield && empty($object->ldap_sid)) - { - print '<input size="40" type="text" name="skype" class="flat" value="'.$object->skype.'">'; - } - else - { - print '<input type="hidden" name="skype" value="'.$object->skype.'">'; - print $object->skype; - } - print '</td></tr>'; - } - - // EMail - print "<tr>".'<td'.(! empty($conf->global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").'</td>'; + } + + // Type + print '<tr><td>'.$langs->trans("Type").'</td>'; + print '<td>'; + if ($user->id == $object->id || ! $user->admin) + { + $type=$langs->trans("Internal"); + if ($object->societe_id) $type=$langs->trans("External"); + print $form->textwithpicto($type,$langs->trans("InternalExternalDesc")); + if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; + } + else + { + $type=0; + if ($object->contact_id) $type=$object->contact_id; + print $form->selectcontacts(0,$type,'contactid',2,'','',1,'',false,1); + if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; + } + print '</td></tr>'; + + // Address + print '<tr><td class="tdtop">'.fieldLabel('Address','address').'</td>'; + print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">'; + print $object->address; + print '</textarea></td></tr>'; + + // Zip + print '<tr><td>'.fieldLabel('Zip','zipcode').'</td><td>'; + print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + print '</td></tr>'; + + // Town + print '<tr><td>'.fieldLabel('Town','town').'</td><td>'; + print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print '</td></tr>'; + + // Country + print '<tr><td>'.fieldLabel('Country','selectcounty_id').'</td><td>'; + print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + print '</td></tr>'; + + // State + if (empty($conf->global->USER_DISABLE_STATE)) + { + print '<tr><td class="tdoverflow">'.fieldLabel('State','state_id').'</td><td>'; + print $formcompany->select_state($object->state_id,$object->country_code, 'state_id'); + print '</td></tr>'; + } + + // Tel pro + print "<tr>".'<td>'.$langs->trans("PhonePro").'</td>'; + print '<td>'; + if ($caneditfield && empty($object->ldap_sid)) + { + print '<input size="20" type="text" name="office_phone" class="flat" value="'.$object->office_phone.'">'; + } + else + { + print '<input type="hidden" name="office_phone" value="'.$object->office_phone.'">'; + print $object->office_phone; + } + print '</td></tr>'; + + // Tel mobile + print "<tr>".'<td>'.$langs->trans("PhoneMobile").'</td>'; + print '<td>'; + if ($caneditfield && empty($object->ldap_sid)) + { + print '<input size="20" type="text" name="user_mobile" class="flat" value="'.$object->user_mobile.'">'; + } + else + { + print '<input type="hidden" name="user_mobile" value="'.$object->user_mobile.'">'; + print $object->user_mobile; + } + print '</td></tr>'; + + // Fax + print "<tr>".'<td>'.$langs->trans("Fax").'</td>'; + print '<td>'; + if ($caneditfield && empty($object->ldap_sid)) + { + print '<input size="20" type="text" name="office_fax" class="flat" value="'.$object->office_fax.'">'; + } + else + { + print '<input type="hidden" name="office_fax" value="'.$object->office_fax.'">'; + print $object->office_fax; + } + print '</td></tr>'; + + // Skype + if (! empty($conf->skype->enabled)) + { + print '<tr><td>'.$langs->trans("Skype").'</td>'; print '<td>'; if ($caneditfield && empty($object->ldap_sid)) { - print '<input class="minwidth100" type="text" name="email" class="flat" value="'.$object->email.'">'; + print '<input size="40" type="text" name="skype" class="flat" value="'.$object->skype.'">'; } else { - print '<input type="hidden" name="email" value="'.$object->email.'">'; - print $object->email; + print '<input type="hidden" name="skype" value="'.$object->skype.'">'; + print $object->skype; } print '</td></tr>'; - - // Signature - print "<tr>".'<td class="tdtop">'.$langs->trans("Signature").'</td>'; + } + + // EMail + print "<tr>".'<td'.(! empty($conf->global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").'</td>'; + print '<td>'; + if ($caneditfield && empty($object->ldap_sid)) + { + print '<input class="minwidth100" type="text" name="email" class="flat" value="'.$object->email.'">'; + } + else + { + print '<input type="hidden" name="email" value="'.$object->email.'">'; + print $object->email; + } + print '</td></tr>'; + + // OpenID url + if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) + { + print "<tr>".'<td>'.$langs->trans("OpenIDURL").'</td>'; print '<td>'; if ($caneditfield) { - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('signature',$object->signature,'',138,'dolibarr_mailings','In',false,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%'); - print $doleditor->Create(1); + print '<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.'">'; } else - { - print dol_htmlentitiesbr($object->signature); - } - print '</td></tr>'; - - // OpenID url - if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) { - print "<tr>".'<td>'.$langs->trans("OpenIDURL").'</td>'; - print '<td>'; - if ($caneditfield) - { - print '<input class="minwidth100" type="url" name="openid" class="flat" value="'.$object->openid.'">'; - } - else - { - print '<input type="hidden" name="openid" value="'.$object->openid.'">'; - print $object->openid; - } - print '</td></tr>'; + print '<input type="hidden" name="openid" value="'.$object->openid.'">'; + print $object->openid; } - - // Hierarchy - print '<tr><td>'.$langs->trans("HierarchicalResponsible").'</td>'; + print '</td></tr>'; + } + + // Accountancy code + if ($conf->accounting->enabled) + { + print "<tr>"; + print '<td>'.$langs->trans("AccountancyCode").'</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'); + print '<input size="30" type="text" class="flat" name="accountancy_code" value="'.$object->accountancy_code.'">'; } 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 '<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.'">'; + print $object->accountancy_code; } print '</td>'; - print "</tr>\n"; - - if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->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"; - - // Accountancy code - if ($conf->accounting->enabled) - { - print "<tr>"; - print '<td>'.$langs->trans("AccountancyCode").'</td>'; - print '<td>'; - if ($caneditfield) - { - print '<input size="30" type="text" class="flat" name="accountancy_code" value="'.$object->accountancy_code.'">'; - } - else - { - print '<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.'">'; - print $object->accountancy_code; - } - print '</td>'; - print "</tr>"; - } - + print "</tr>"; + } + + // 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)) { @@ -2461,6 +2452,21 @@ else print $object->showOptionals($extrafields,'edit'); } + // Signature + print "<tr>".'<td class="tdtop">'.$langs->trans("Signature").'</td>'; + print '<td>'; + if ($caneditfield) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('signature',$object->signature,'',138,'dolibarr_mailings','In',false,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%'); + print $doleditor->Create(1); + } + else + { + print dol_htmlentitiesbr($object->signature); + } + print '</td></tr>'; + print '</table>'; dol_fiche_end(); @@ -2501,8 +2507,6 @@ else print '</div></div></div>'; - } - } if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) $ldap->close(); -- GitLab