Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into

develop
This commit is contained in:
Laurent Destailleur 2022-04-05 15:24:15 +02:00
commit 17c719e760
16 changed files with 244 additions and 103 deletions

View File

@ -71,6 +71,12 @@ $workflowcodes = array(
'enabled'=>(!empty($conf->commande->enabled) && !empty($conf->facture->enabled)),
'picto'=>'bill'
),
'WORKFLOW_TICKET_CREATE_INTERVENTION' => array (
'family'=>'create',
'position'=>25,
'enabled'=>(!empty($conf->ticket->enabled) && !empty($conf->ficheinter->enabled)),
'picto'=>'ticket'
),
'separator1'=>array('family'=>'separator', 'position'=>25, 'title'=>''),

View File

@ -2083,65 +2083,102 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring
*/
function dol_uncompress($inputfile, $outputdir)
{
global $conf, $langs;
global $conf, $langs, $db;
if (defined('ODTPHP_PATHTOPCLZIP') && empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_UNCOMPRESS)) {
dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
$archive = new PclZip($inputfile);
$fileinfo = pathinfo($inputfile);
$fileinfo["extension"] = strtolower($fileinfo["extension"]);
// Extract into outputdir, but only files that match the regex '/^((?!\.\.).)*$/' that means "does not include .."
$result = $archive->extract(PCLZIP_OPT_PATH, $outputdir, PCLZIP_OPT_BY_PREG, '/^((?!\.\.).)*$/');
if ($fileinfo["extension"] == "zip") {
if (defined('ODTPHP_PATHTOPCLZIP') && empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_UNCOMPRESS)) {
dol_syslog("Constant ODTPHP_PATHTOPCLZIP for pclzip library is set to ".ODTPHP_PATHTOPCLZIP.", so we use Pclzip to unzip into ".$outputdir);
include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php';
$archive = new PclZip($inputfile);
if (!is_array($result) && $result <= 0) {
return array('error'=>$archive->errorInfo(true));
} else {
$ok = 1;
$errmsg = '';
// Loop on each file to check result for unzipping file
foreach ($result as $key => $val) {
if ($val['status'] == 'path_creation_fail') {
$langs->load("errors");
$ok = 0;
$errmsg = $langs->trans("ErrorFailToCreateDir", $val['filename']);
break;
// Extract into outputdir, but only files that match the regex '/^((?!\.\.).)*$/' that means "does not include .."
$result = $archive->extract(PCLZIP_OPT_PATH, $outputdir, PCLZIP_OPT_BY_PREG, '/^((?!\.\.).)*$/');
if (!is_array($result) && $result <= 0) {
return array('error'=>$archive->errorInfo(true));
} else {
$ok = 1;
$errmsg = '';
// Loop on each file to check result for unzipping file
foreach ($result as $key => $val) {
if ($val['status'] == 'path_creation_fail') {
$langs->load("errors");
$ok = 0;
$errmsg = $langs->trans("ErrorFailToCreateDir", $val['filename']);
break;
}
}
if ($ok) {
return array();
} else {
return array('error'=>$errmsg);
}
}
}
if ($ok) {
if (class_exists('ZipArchive')) { // Must install php-zip to have it
dol_syslog("Class ZipArchive is set so we unzip using ZipArchive to unzip into ".$outputdir);
$zip = new ZipArchive;
$res = $zip->open($inputfile);
if ($res === true) {
//$zip->extractTo($outputdir.'/');
// We must extract one file at time so we can check that file name does not contains '..' to avoid transversal path of zip built for example using
// python3 path_traversal_archiver.py <Created_file_name> test.zip -l 10 -p tmp/
// with -l is the range of dot to go back in path.
// and path_traversal_archiver.py found at https://github.com/Alamot/code-snippets/blob/master/path_traversal/path_traversal_archiver.py
for ($i = 0; $i < $zip->numFiles; $i++) {
if (preg_match('/\.\./', $zip->getNameIndex($i))) {
dol_syslog("Warning: Try to unzip a file with a transversal path ".$zip->getNameIndex($i), LOG_WARNING);
continue; // Discard the file
}
$zip->extractTo($outputdir.'/', array($zip->getNameIndex($i)));
}
$zip->close();
return array();
} else {
return array('error'=>$errmsg);
return array('error'=>'ErrUnzipFails');
}
}
}
if (class_exists('ZipArchive')) { // Must install php-zip to have it
dol_syslog("Class ZipArchive is set so we unzip using ZipArchive to unzip into ".$outputdir);
$zip = new ZipArchive;
$res = $zip->open($inputfile);
if ($res === true) {
//$zip->extractTo($outputdir.'/');
// We must extract one file at time so we can check that file name does not contains '..' to avoid transversal path of zip built for example using
// python3 path_traversal_archiver.py <Created_file_name> test.zip -l 10 -p tmp/
// with -l is the range of dot to go back in path.
// and path_traversal_archiver.py found at https://github.com/Alamot/code-snippets/blob/master/path_traversal/path_traversal_archiver.py
for ($i = 0; $i < $zip->numFiles; $i++) {
if (preg_match('/\.\./', $zip->getNameIndex($i))) {
dol_syslog("Warning: Try to unzip a file with a transversal path ".$zip->getNameIndex($i), LOG_WARNING);
continue; // Discard the file
}
$zip->extractTo($outputdir.'/', array($zip->getNameIndex($i)));
}
return array('error'=>'ErrNoZipEngine');
} elseif (in_array($fileinfo["extension"], array('gz', 'bz2', 'zst'))) {
include_once DOL_DOCUMENT_ROOT."/core/class/utils.class.php";
$utils = new Utils($db);
$zip->close();
return array();
$extension = strtolower(pathinfo($fileinfo["filename"], PATHINFO_EXTENSION));
if ($extension == "tar") {
$cmd = 'tar -C '.escapeshellcmd(dol_sanitizePathName($outputdir)).' -xvf '.escapeshellcmd(dol_sanitizePathName($fileinfo["dirname"]).'/'.dol_sanitizeFileName($fileinfo["basename"]));
$resarray = $utils->executeCLI($cmd, $outputdir);
} else {
return array('error'=>'ErrUnzipFails');
$program = "";
if ($fileinfo["extension"] == "gz") {
$program = 'gzip';
} elseif ($fileinfo["extension"] == "bz2") {
$program = 'bzip2';
} elseif ($fileinfo["extension"] == "zst") {
$program = 'zstd';
} else {
return array('error'=>'ErrFileExtension');
}
$cmd = $program.' -dc '.escapeshellcmd(dol_sanitizePathName($fileinfo["dirname"]).'/'.dol_sanitizeFileName($fileinfo["basename"]));
$outputfilename = escapeshellcmd(dol_sanitizePathName($outputdir).'/'.dol_sanitizeFileName($fileinfo["filename"]));
$resarray = $utils->executeCLI($cmd, $outputfilename, 0, $outputfilename);
if ($resarray["output"] == 2) {
$resarray["error"] = "ErrFilePermOrFileNotFound";
}
if ($resarray["output"] == 1) {
$resarray["error"] = "Error";
}
}
return $resarray["output"] != 0 ? $resarray["error"] : array();
}
return array('error'=>'ErrNoZipEngine');
return array('error'=>'ErrFileExtension');
}

View File

@ -214,28 +214,28 @@ class modHRM extends DolibarrModules
$r++;
// Evaluation
$this->rights[$r][0] = 4020; // Permission id (must not be already used)
$this->rights[$r][0] = 4021; // Permission id (must not be already used)
$this->rights[$r][1] = 'Read evaluations'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->read)
$r++;
$this->rights[$r][0] = 4021; // Permission id (must not be already used)
$this->rights[$r][0] = 4022; // Permission id (must not be already used)
$this->rights[$r][1] = 'Create/modify your evaluation'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation';
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->write)
$r++;
$this->rights[$r][0] = 4022; // Permission id (must not be already used)
$this->rights[$r][0] = 4023; // Permission id (must not be already used)
$this->rights[$r][1] = 'Validate evaluation'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation_advance';
$this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->evaluation->validate)
$r++;
$this->rights[$r][0] = 4023; // Permission id (must not be already used)
$this->rights[$r][0] = 4025; // Permission id (must not be already used)
$this->rights[$r][1] = 'Delete evaluations'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation';
@ -243,12 +243,28 @@ class modHRM extends DolibarrModules
$r++;
// Comparison
$this->rights[$r][0] = 4030; // Permission id (must not be already used)
$this->rights[$r][0] = 4028; // Permission id (must not be already used)
$this->rights[$r][1] = 'See comparison menu'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'compare_advance';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->compare_advance->read)
$r++;
// Read employee
$this->rights[$r][0] = 4031; // Permission id (must not be already used)
$this->rights[$r][1] = 'Read personal information'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'read_personal_information';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->read_personal_information->read)
$r++;
// Write employee
$this->rights[$r][0] = 4032; // Permission id (must not be already used)
$this->rights[$r][1] = 'Write personal information'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'write_personal_information';
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->write_personal_information->write)
$r++;
}
/**

View File

@ -95,7 +95,8 @@ class modWorkflow extends DolibarrModules
8=>array('WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 'chaine', '1', 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER', 0, 'current', 0),
9=>array('WORKFLOW_BILL_ON_RECEPTION', 'chaine', '1', 'WORKFLOW_BILL_ON_RECEPTION', 0, 'current', 0),
10=>array('WORKFLOW_TICKET_LINK_CONTRACT', 'chaine', '0', 'Automatically link a ticket to available contracts', 0, 'current', 0),
11=>array('WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS', 'chaine', '0', 'Search among parent companies contracts when automatically linking a ticket to available contracts', 0, 'current', 0)
11=>array('WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS', 'chaine', '0', 'Search among parent companies contracts when automatically linking a ticket to available contracts', 0, 'current', 0),
11=>array('WORKFLOW_TICKET_CREATE_INTERVENTION', 'chaine', '1', 'WORKFLOW_TICKET_CREATE_INTERVENTION', 0, 'current', 0)
);
// Boxes

View File

@ -435,7 +435,6 @@ class InterfaceWorkflowManager extends DolibarrTriggers
$number_contracts_found = 0;
foreach ($company_ids as $company_id) {
$contrat->socid = $company_id;
$list = $contrat->getListOfContracts($option = 'all', $status = [Contrat::STATUS_DRAFT, Contrat::STATUS_VALIDATED], $product_categories = [$conf->global->TICKET_PRODUCT_CATEGORY], $line_status = [ContratLigne::STATUS_INITIAL, ContratLigne::STATUS_OPEN]);
if (is_array($list) && !empty($list)) {
$number_contracts_found = count($list);
@ -457,6 +456,28 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if (empty(NOLOGIN)) setEventMessage($langs->trans('TicketNoContractFoundToLink'), 'mesgs');
}
}
// Automatically create intervention
if (!empty($conf->ficheinter->enabled) && !empty($conf->ticket->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_TICKET_CREATE_INTERVENTION)) {
$fichinter = new Fichinter($this->db);
$fichinter->socid = (int) $object->fk_soc;
$fichinter->fk_project = $projectid;
$fichinter->fk_contrat = (int) $object->fk_contract;
$fichinter->author = $user->id;
$fichinter->model_pdf = (!empty($conf->global->FICHEINTER_ADDON_PDF)) ? $conf->global->FICHEINTER_ADDON_PDF : 'soleil';
$fichinter->origin = $object->element;
$fichinter->origin_id = $object->id;
// Extrafields
$extrafields = new ExtraFields($this->db);
$extrafields->fetch_name_optionals_label($fichinter->table_element);
$array_options = $extrafields->getOptionalsFromPost($fichinter->table_element);
$fichinter->array_options = $array_options;
$id = $fichinter->create($user);
if ($id <= 0) {
setEventMessages($fichinter->error, null, 'errors');
}
}
}
return 0;
}

View File

@ -255,7 +255,7 @@ class Fichinter extends CommonObject
}
if ($this->socid <= 0) {
$this->error = 'ErrorBadParameterForFunc';
$this->error = 'ErrorFicheinterCompanyDoesNotExist';
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
}

View File

@ -117,6 +117,7 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) value
ALTER TABLE llx_ticket ADD COLUMN date_last_msg_sent datetime AFTER date_read;
UPDATE llx_const SET name = 'WORKFLOW_TICKET_LINK_CONTRACT' WHERE name = 'TICKET_AUTO_ASSIGN_CONTRACT_CREATE';
UPDATE llx_const SET name = 'WORKFLOW_TICKET_CREATE_INTERVENTION' WHERE name = 'TICKET_AUTO_CREATE_FICHINTER_CREATE';
CREATE TABLE llx_stock_mouvement_extrafields (
rowid integer AUTO_INCREMENT PRIMARY KEY,
@ -282,6 +283,8 @@ ALTER TABLE llx_bank_account ADD COLUMN pti_in_ctti smallint DEFAULT 0 AFTER dom
-- Set default ticket type to OTHER if no default exists
UPDATE llx_c_ticket_type SET use_default=1 WHERE code='OTHER' AND NOT EXISTS(SELECT * FROM (SELECT * FROM llx_c_ticket_type) AS t WHERE use_default=1);
ALTER TABLE llx_user ADD COLUMN ref_employee varchar(50) DEFAULT NULL;
ALTER TABLE llx_user ADD COLUMN national_registration_number varchar(50) DEFAULT NULL;
ALTER TABLE llx_propal ADD last_main_doc VARCHAR(255) NULL AFTER model_pdf;

View File

@ -108,5 +108,7 @@ create table llx_user
import_key varchar(14), -- import key
default_range integer,
default_c_exp_tax_cat integer,
employee_number varchar(50),
national_registration_number varchar(50),
fk_warehouse integer -- default warehouse os user
)ENGINE=innodb;

View File

@ -972,6 +972,8 @@ Permission4021=Create/modify your evaluation
Permission4022=Validate evaluation
Permission4023=Delete evaluation
Permission4030=See comparison menu
Permission4031=Read personal information
Permission4032=Write personal information
Permission10001=Read website content
Permission10002=Create/modify website content (html and javascript content)
Permission10003=Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers.

View File

@ -51,6 +51,8 @@ CivilityCode=Civility code
RegisteredOffice=Registered office
Lastname=Last name
Firstname=First name
RefEmployee=Employee reference
NationalRegistrationNumber=National registration number
PostOrFunction=Job position
UserTitle=Title
NatureOfThirdParty=Nature of Third party

View File

@ -67,3 +67,4 @@ ToCreateAPredefinedIntervention=To create a predefined or recurring intervention
ConfirmReopenIntervention=Are you sure you want to open back the intervention <b>%s</b>?
GenerateInter=Generate intervention
FichinterNoContractLinked=Intervention %s has been created without a linked contract.
ErrorFicheinterCompanyDoesNotExist=Company does not exist. Intervention has not been created.

View File

@ -7,6 +7,7 @@ descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a sales order after a
descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed (the new invoice will have same amount as the proposal)
descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Automatically create a customer invoice after a contract is validated
descWORKFLOW_ORDER_AUTOCREATE_INVOICE=Automatically create a customer invoice after a sales order is closed (the new invoice will have same amount as the order)
descWORKFLOW_TICKET_CREATE_INTERVENTION=On ticket creation, automatically create an intervention.
# Autoclassify customer proposal or order
descWORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL=Classify linked source proposal as billed when sales order is set to billed (and if the amount of the order is the same as the total amount of the signed linked proposal)
descWORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL=Classify linked source proposal as billed when customer invoice is validated (and if the amount of the invoice is the same as the total amount of the signed linked proposal)

View File

@ -254,28 +254,6 @@ if (empty($reshook)) {
$result = $object->assignUser($user, $user->id, 1);
$object->add_contact($user->id, "SUPPORTTEC", 'internal');
}
// Auto create fiche intervention
if (!empty($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE)) {
$fichinter = new Fichinter($db);
$fichinter->socid = $object->fk_soc;
$fichinter->fk_project = $projectid;
$fichinter->fk_contrat = $object->fk_contract;
$fichinter->author = $user->id;
$fichinter->model_pdf = 'soleil';
$fichinter->origin = $object->element;
$fichinter->origin_id = $object->id;
// Extrafields
$extrafields->fetch_name_optionals_label($fichinter->table_element);
$array_options = $extrafields->getOptionalsFromPost($fichinter->table_element);
$fichinter->array_options = $array_options;
$id = $fichinter->create($user);
if ($id <= 0) {
setEventMessages($fichinter->error, null, 'errors');
}
}
}
if (!$error) {

View File

@ -78,8 +78,8 @@ if (empty($account->userid)) {
// Define value to know what current user can do on users
$canadduser = (!empty($user->admin) || $user->rights->user->user->creer);
$canreaduser = (!empty($user->admin) || $user->rights->user->user->lire);
$canadduser = (!empty($user->admin) || $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
$canreaduser = (!empty($user->admin) || $user->rights->user->user->lire || $user->rights->hrm->read_personal_information->read);
$permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || !empty($user->rights->user->creer));
// Ok if user->rights->salaries->read or user->rights->hrm->read
@ -230,6 +230,24 @@ if ($action == 'setpersonal_mobile' && $canadduser && !$cancel) {
}
}
// update ref_employee
if ($action == 'setref_employee' && $canadduser && !$cancel) {
$object->ref_employee = (string) GETPOST('ref_employee', 'alphanohtml');
$result = $object->update($user);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// update national_registration_number
if ($action == 'setnational_registration_number' && $canadduser && !$cancel) {
$object->national_registration_number = (string) GETPOST('national_registration_number', 'alphanohtml');
$result = $object->update($user);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
// update default_c_exp_tax_cat
if ($action == 'setdefault_c_exp_tax_cat' && $canadduser) {
@ -263,7 +281,7 @@ llxHeader(null, $langs->trans("BankAccounts"));
$head = user_prepare_head($object);
if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) {
if ($id && $bankid && $action == 'edit' && ($user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write)) {
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
@ -428,31 +446,37 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
print "</tr>\n";
// Date of birth
print '<tr>';
print '<td>';
print $form->editfieldkey("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer);
print '</td><td>';
print $form->editfieldval("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer, 'day', $object->birth);
print '</td>';
print "</tr>\n";
if ($user->rights->hrm->read_personal_information->read || $user->rights->hrm->write_personal_information->write) {
print '<tr>';
print '<td>';
print $form->editfieldkey("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer);
print '</td><td>';
print $form->editfieldval("DateOfBirth", 'birth', $object->birth, $object, $user->rights->user->user->creer, 'day', $object->birth);
print '</td>';
print "</tr>\n";
}
// Personal email
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer);
print '</td><td>';
print $form->editfieldval("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer, 'email', '', null, null, '', 0, 'dol_print_email');
print '</td>';
print '</tr>';
if ($user->rights->hrm->read_personal_information->read || $user->rights->hrm->write_personal_information->write) {
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
print '</td><td>';
print $form->editfieldval("UserPersonalEmail", 'personal_email', $object->personal_email, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'email', '', null, null, '', 0, 'dol_print_email');
print '</td>';
print '</tr>';
}
// Personal phone
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer);
print '</td><td>';
print $form->editfieldval("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer, 'string', '', null, null, '', 0, 'dol_print_phone');
print '</td>';
print '</tr>';
if ($user->rights->hrm->read_personal_information->read || $user->rights->hrm->write_personal_information->write) {
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
print '</td><td>';
print $form->editfieldval("UserPersonalMobile", 'personal_mobile', $object->personal_mobile, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'string', '', null, null, '', 0, 'dol_print_phone');
print '</td>';
print '</tr>';
}
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
print '<tr class="nowrap">';
@ -502,6 +526,34 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
print '</tr>';
}
// Accountancy code
if (!empty($conf->accounting->enabled)) {
print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
print '<td>'.$object->accountancy_code.'</td></tr>';
}
// Employee Number
if ($user->rights->hrm->read_personal_information->read || $user->rights->hrm->write_personal_information->write) {
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
print '</td><td>';
print $form->editfieldval("RefEmployee", 'ref_employee', $object->ref_employee, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'string', $object->ref_employee);
print '</td>';
print '</tr>';
}
// National registration number
if ($user->rights->hrm->read_personal_information->read || $user->rights->hrm->write_personal_information->write) {
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write);
print '</td><td>';
print $form->editfieldval("NationalRegistrationNumber", 'national_registration_number', $object->national_registration_number, $object, $user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write, 'string', $object->national_registration_number);
print '</td>';
print '</tr>';
}
print '</table>';
print '</div><div class="fichehalfright">';

View File

@ -247,6 +247,8 @@ if (empty($reshook)) {
$object->civility_code = GETPOST("civility_code", 'aZ09');
$object->lastname = GETPOST("lastname", 'alphanohtml');
$object->firstname = GETPOST("firstname", 'alphanohtml');
$object->ref_employee = GETPOST("ref_employee", 'alphanohtml');
$object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml');
$object->login = GETPOST("login", 'alphanohtml');
$object->api_key = GETPOST("api_key", 'alphanohtml');
$object->gender = GETPOST("gender", 'aZ09');
@ -402,6 +404,8 @@ if (empty($reshook)) {
$object->civility_code = GETPOST("civility_code", 'aZ09');
$object->lastname = GETPOST("lastname", 'alphanohtml');
$object->firstname = GETPOST("firstname", 'alphanohtml');
$object->ref_employee = GETPOST("ref_employee", 'alphanohtml');
$object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml');
$object->gender = GETPOST("gender", 'aZ09');
$object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields
$object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key;
@ -1576,12 +1580,6 @@ if ($action == 'create' || $action == 'adduserldap') {
print '</td></tr>';
}
// Accountancy code
if (!empty($conf->accounting->enabled)) {
print '<tr><td>'.$langs->trans("AccountancyCode").'</td>';
print '<td>'.$object->accountancy_code.'</td></tr>';
}
print '</table>';
print '</div>';

View File

@ -339,6 +339,17 @@ class User extends CommonObject
public $dateemploymentend; // Define date of employment end by company
public $default_c_exp_tax_cat;
/**
* @var string ref for employee
*/
public $ref_employee;
/**
* @var string national registration number
*/
public $national_registration_number;
public $default_range;
/**
@ -350,6 +361,8 @@ class User extends CommonObject
'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'lastname'=>array('type'=>'varchar(50)', 'label'=>'LastName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1),
'firstname'=>array('type'=>'varchar(50)', 'label'=>'FirstName', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
'ref_employee'=>array('type'=>'varchar(50)', 'label'=>'ref_employee', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30, 'searchall'=>1),
'national_registration_number'=>array('type'=>'varchar(50)', 'label'=>'national_registration_number', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40, 'searchall'=>1)
);
@ -437,6 +450,8 @@ class User extends CommonObject
$sql .= " u.fk_warehouse,";
$sql .= " u.ref_ext,";
$sql .= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode
$sql .= " u.national_registration_number,";
$sql .= " u.ref_employee,";
$sql .= " c.code as country_code, c.label as country,";
$sql .= " d.code_departement as state_code, d.nom as state";
$sql .= " FROM ".$this->db->prefix()."user as u";
@ -488,6 +503,8 @@ class User extends CommonObject
$this->civility_code = $obj->civility_code;
$this->lastname = $obj->lastname;
$this->firstname = $obj->firstname;
$this->ref_employee = $obj->ref_employee;
$this->national_registration_number = $obj->national_registration_number;
$this->employee = $obj->employee;
@ -1755,6 +1772,8 @@ class User extends CommonObject
$this->civility_code = trim($this->civility_code);
$this->lastname = trim($this->lastname);
$this->firstname = trim($this->firstname);
$this->ref_employee = trim($this->ref_employee);
$this->national_registration_number = trim($this->national_registration_number);
$this->employee = $this->employee ? $this->employee : 0;
$this->login = trim($this->login);
$this->gender = trim($this->gender);
@ -1847,6 +1866,8 @@ class User extends CommonObject
$sql .= " civility = '".$this->db->escape($this->civility_code)."'";
$sql .= ", lastname = '".$this->db->escape($this->lastname)."'";
$sql .= ", firstname = '".$this->db->escape($this->firstname)."'";
$sql .= ", ref_employee = '".$this->db->escape($this->ref_employee)."'";
$sql .= ", national_registration_number = '".$this->db->escape($this->national_registration_number)."'";
$sql .= ", employee = ".(int) $this->employee;
$sql .= ", login = '".$this->db->escape($this->login)."'";
$sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null");