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

This commit is contained in:
kevin 2022-04-06 15:09:01 +02:00
commit 0b29b92b44
92 changed files with 939 additions and 482 deletions

View File

@ -32,6 +32,7 @@ Following changes may create regressions for some external modules, but were nec
* verifCond('stringtoevaluate') now return false when string contains a bad syntax content instead of true.
* The deprecated method thirdparty_doc_create() has been removed. You can use the generateDocument() instead.
* All triggers with a name XXX_UPDATE have been rename with name XXX_MODIFY for code consistency purpose.
* Rename build_path_from_id_categ() into buildPathFromId() and set method to private
***** ChangeLog for 15.0.1 compared to 15.0.0 *****

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

@ -1141,10 +1141,10 @@ class Categorie extends CommonObject
}
// We add the fullpath property to each elements of first level (no parent exists)
dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG);
dol_syslog(get_class($this)."::get_full_arbo call to buildPathFromId", LOG_DEBUG);
foreach ($this->cats as $key => $val) {
//print 'key='.$key.'<br>'."\n";
$this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent)
$this->buildPathFromId($key, 0); // Process a branch from the root category key (this category has no parent)
}
// Include or exclude leaf including $markafterid from tree
@ -1174,7 +1174,6 @@ class Categorie extends CommonObject
return $this->cats;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* For category id_categ and its childs available in this->cats, define property fullpath and fulllabel.
* It is called by get_full_arbo()
@ -1185,19 +1184,18 @@ class Categorie extends CommonObject
* @return void
* @see get_full_arbo()
*/
public function build_path_from_id_categ($id_categ, $protection = 1000)
private function buildPathFromId($id_categ, $protection = 1000)
{
// phpcs:enable
dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
//dol_syslog(get_class($this)."::buildPathFromId id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
if (!empty($this->cats[$id_categ]['fullpath'])) {
// Already defined
dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING);
dol_syslog(get_class($this)."::buildPathFromId fullpath and fulllabel already defined", LOG_WARNING);
return;
}
// First build full array $motherof
//$this->load_motherof(); // Disabled because already done by caller of build_path_from_id_categ
//$this->load_motherof(); // Disabled because already done by caller of buildPathFromId
// $this->cats[$id_categ] is supposed to be already an array. We just want to complete it with property fullpath and fulllabel

View File

@ -162,7 +162,8 @@ if (empty($reshook)) {
// set accountancy code
if ($action == 'setcustomeraccountancycode') {
$result = $object->fetch($id);
$object->code_compta = GETPOST("customeraccountancycode");
$object->code_compta_client = GETPOST("customeraccountancycode");
$object->code_compta = $object->code_compta_client; // For Backward compatibility
$result = $object->update($object->id, $user, 1, 1, 0);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -360,9 +361,9 @@ if ($object->id > 0) {
print '<tr>';
print '<td>';
print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer);
print $form->editfieldkey("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer);
print '</td><td>';
print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta, $object, $user->rights->societe->creer);
print $form->editfieldval("CustomerAccountancyCode", 'customeraccountancycode', $object->code_compta_client, $object, $user->rights->societe->creer);
print '</td>';
print '</tr>';
}

View File

@ -62,7 +62,7 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
exit;
}
if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user->rights->societe->creer) {
if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && ($user->rights->societe->creer || $user->rights->facture->creer)) {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
@ -153,7 +153,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user-
}
}
if ($action == 'setremise' && $user->rights->societe->creer) {
if ($action == 'setremise' && ($user->rights->societe->creer || $user->rights->facture->creer)) {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
@ -192,7 +192,7 @@ if ($action == 'setremise' && $user->rights->societe->creer) {
}
}
if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && $user->rights->societe->creer) {
if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && ($user->rights->societe->creer || $user->rights->facture->creer)) {
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)

View File

@ -201,6 +201,7 @@ $arrayfields = array(
'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140),
'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>990),
'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>995),
'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999),
'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
);
// Extra fields
@ -441,7 +442,7 @@ $sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture
$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,';
$sql .= ' c.fk_cond_reglement,c.fk_mode_reglement,c.fk_shipping_method,';
$sql .= ' c.fk_input_reason';
$sql .= ' c.fk_input_reason, c.import_key';
if (($search_categ_cus > 0) || ($search_categ_cus == -2)) {
$sql .= ", cc.fk_categorie, cc.fk_soc";
}
@ -1275,6 +1276,11 @@ if ($resql) {
print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1);
print '</td>';
}
// Import key
if (!empty($arrayfields['c.import_key']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
print '</td>';
}
// Status
if (!empty($arrayfields['c.fk_statut']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone center">';
@ -1436,6 +1442,9 @@ if ($resql) {
if (!empty($arrayfields['c.facture']['checked'])) {
print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['c.import_key']['checked'])) {
print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['c.fk_statut']['checked'])) {
print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center ');
}
@ -2063,6 +2072,13 @@ if ($resql) {
$totalarray['nbfield']++;
}
}
// Import key
if (!empty($arrayfields['c.import_key']['checked'])) {
print '<td class="nowrap center">'.$obj->import_key.'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Status
if (!empty($arrayfields['c.fk_statut']['checked'])) {
print '<td class="nowrap center">'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).'</td>';

View File

@ -19,11 +19,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/accounting-files.php
* \ingroup compta
* \brief Page to show portoflio and files of a thirdparty and download it
*/
/**
* \file htdocs/compta/accounting-files.php
* \ingroup compta
* \brief Page to show portoflio and files of a thirdparty and download it
*/
if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file
if (!defined('NOTOKENRENEWAL')) {

View File

@ -65,7 +65,8 @@ $hookmanager->initHooks(array('bankcard', 'globalcard'));
// Security check
$id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha');
$fieldid = GETPOSTISSET("ref") ? 'ref' : 'rowid';
$fieldid = GETPOST("id") ? 'rowid' : 'ref';
$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
@ -724,7 +725,7 @@ if ($action == 'create') {
print '</table>';
if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) {
print '<div class="underbanner clearboth"></div>';
//print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">';

View File

@ -967,7 +967,7 @@ if ($action == 'create') {
// Title
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Title").'</td><td>';
print '<input class="flat quatrevingtpercent" type="text" name="title" value="'.dol_escape_htmltag(GETPOST("title", 'alphanohtml')).'">';
print '<input class="flat quatrevingtpercent" type="text" name="title" value="'.dol_escape_htmltag(GETPOST("title", 'alphanohtml')).'" autofocus>';
print '</td></tr>';
// Third party

View File

@ -737,7 +737,7 @@ if (empty($reshook)) {
// On verifie si aucun paiement n'a ete effectue
if ($ventilExportCompta == 0) {
if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) {
if (!empty($conf->global->INVOICE_CAN_BE_EDITED_EVEN_IF_PAYMENT_DONE) || ($resteapayer == $object->total_ttc && empty($object->paye))) {
$result = $object->setDraft($user, $idwarehouse);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -5340,13 +5340,13 @@ if ($action == 'create') {
$ventilExportCompta = $object->getVentilExportCompta();
if ($ventilExportCompta == 0) {
if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == price2num($object->total_ttc, 'MT', 1) && empty($object->paye))) {
if (!empty($conf->global->INVOICE_CAN_BE_EDITED_EVEN_IF_PAYMENT_DONE) || ($resteapayer == price2num($object->total_ttc, 'MT', 1) && empty($object->paye))) {
if (!$objectidnext && $object->is_last_in_cycle()) {
if ($usercanunvalidate) {
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&amp;action=modif', '', true, $params);
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif&token='.newToken(), '', true, $params);
} else {
$params['attr']['title'] = $langs->trans('NotEnoughPermissions');
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&amp;action=modif', '', false, $params);
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif&token='.newToken(), '', false, $params);
}
} elseif (!$object->is_last_in_cycle()) {
$params['attr']['title'] = $langs->trans('NotLastInCycle');

View File

@ -2130,7 +2130,7 @@ class FactureLigneRec extends CommonInvoiceLine
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET";
$sql .= " fk_facture = ".$this->fk_facture;
$sql .= " fk_facture = ".((int) $this->fk_facture);
$sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null");
$sql .= ", description='".$this->db->escape($this->desc)."'";
$sql .= ", price=".price2num($this->price);
@ -2142,10 +2142,10 @@ class FactureLigneRec extends CommonInvoiceLine
$sql .= ", localtax2_tx=".price2num($this->localtax2_tx);
$sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'";
$sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null");
$sql .= ", product_type=".$this->product_type;
$sql .= ", remise_percent='".price2num($this->remise_percent)."'";
$sql .= ", subprice='".price2num($this->subprice)."'";
$sql .= ", info_bits='".price2num($this->info_bits)."'";
$sql .= ", product_type=".((int) $this->product_type);
$sql .= ", remise_percent=".price2num($this->remise_percent);
$sql .= ", subprice=".price2num($this->subprice);
$sql .= ", info_bits=".price2num($this->info_bits);
$sql .= ", date_start_fill=".(int) $this->date_start_fill;
$sql .= ", date_end_fill=".(int) $this->date_end_fill;
if (empty($this->skip_update_total)) {

View File

@ -194,12 +194,12 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
$fieldstosearchall = array(
'f.ref'=>'Ref',
'f.ref_client'=>'RefCustomer',
'pd.description'=>'Description',
'f.note_public'=>'NotePublic',
's.nom'=>"ThirdParty",
's.name_alias'=>"AliasNameShort",
's.zip'=>"Zip",
's.town'=>"Town",
'f.note_public'=>'NotePublic',
'pd.description'=>'Description',
);
if (empty($user->socid)) {
$fieldstosearchall["f.note_private"] = "NotePrivate";
@ -568,11 +568,14 @@ $sql .= ' state.code_departement as state_code, state.nom as state_name,';
$sql .= ' country.code as country_code,';
$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
// TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0).
// A Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
// We disable this. It create a bug when searching with sall and sorting on status. Also it create performance troubles.
/*
if (!$sall) {
$sql .= ', SUM(pf.amount) as dynamount_payed, SUM(pf.multicurrency_amount) as multicurrency_dynamount_payed';
}
*/
if ($search_categ_cus && $search_categ_cus != -1) {
$sql .= ", cc.fk_categorie, cc.fk_soc";
}
@ -598,9 +601,13 @@ $sql .= ', '.MAIN_DB_PREFIX.'facture as f';
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
}
// We disable this. It create a bug when searching with sall and sorting on status. Also it create performance troubles.
/*
if (!$sall) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
}
*/
if ($sall || $search_product_category > 0) {
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture';
}
@ -798,6 +805,8 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
// We disable this. It create a bug when searching with sall and sorting on status. Also it create performance troubles.
/*
if (!$sall) {
$sql .= ' GROUP BY f.rowid, f.ref, ref_client, f.fk_soc, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total_ht, f.total_tva, f.total_ttc,';
$sql .= ' f.localtax1, f.localtax2,';
@ -827,6 +836,8 @@ if (!$sall) {
$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
} else {
*/
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
@ -1624,7 +1635,7 @@ if ($resql) {
print_liste_field_titre($arrayfields['f.note_private']['label'], $_SERVER["PHP_SELF"], "f.note_private", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
}
if (!empty($arrayfields['f.fk_statut']['checked'])) {
print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type", "", $param, 'class="right"', $sortfield, $sortorder);
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n";

View File

@ -1275,9 +1275,9 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) {
$model = $objecttmp->model_pdf;
$ret = $objecttmp->fetch($objecttmp->id); // Reload to get new records
// To be sure vars is defined
$hidedetails = !empty($hidedetails) ? $hidedetails : 0;
$hidedesc = !empty($hidedesc) ? $hidedesc : 0;
$hideref = !empty($hideref) ? $hideref : 0;
$hidedetails = !empty($hidedetails) ? $hidedetails : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = !empty($hidedesc) ? $hidedesc : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = !empty($hideref) ? $hideref : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
$moreparams = !empty($moreparams) ? $moreparams : null;
$result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
@ -1426,13 +1426,13 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) {
// To be sure vars is defined
if (empty($hidedetails)) {
$hidedetails = 0;
$hidedetails = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
}
if (empty($hidedesc)) {
$hidedesc = 0;
$hidedesc = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
}
if (empty($hideref)) {
$hideref = 0;
$hideref = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
}
if (empty($moreparams)) {
$moreparams = null;

View File

@ -131,7 +131,7 @@ class box_birthdays extends ModeleBoxes
}
if ($num == 0) {
$this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None"));
$this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text' => '<span class="opacitymedium">'.$langs->trans("None").'</span>');
}
$this->db->free($result);
@ -144,8 +144,8 @@ class box_birthdays extends ModeleBoxes
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'class="nohover opacitymedium left"',
'text' => $langs->trans("ReadPermissionNotAllowed")
'td' => 'class="nohover left"',
'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
);
}
}

View File

@ -128,7 +128,7 @@ class box_birthdays_members extends ModeleBoxes
}
if ($num == 0) {
$this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None"));
$this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text' => '<span class="opacitymedium">'.$langs->trans("None").'</span>');
}
$this->db->free($result);
@ -141,8 +141,8 @@ class box_birthdays_members extends ModeleBoxes
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'class="nohover opacitymedium left"',
'text' => $langs->trans("ReadPermissionNotAllowed")
'td' => 'class="nohover left"',
'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
);
}
}

View File

@ -5994,8 +5994,15 @@ abstract class CommonObject
$attributeLabel = $extrafields->attributes[$this->table_element]['label'][$attributeKey];
$attributeParam = $extrafields->attributes[$this->table_element]['param'][$attributeKey];
$attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey];
$attributeUnique = $extrafields->attributes[$this->table_element]['unique'][$attributeKey];
$attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey];
// If we clone, we have to clean unique extrafields to prevent duplicates.
// This behaviour can be prevented by external code by changing $this->context['createfromclone'] value in createFrom hook
if (! empty($this->context['createfromclone']) && $this->context['createfromclone'] == 'createfromclone' && ! empty($attributeUnique)) {
$new_array_options[$key] = null;
}
// Similar code than into insertExtraFields
if ($attributeRequired) {
$mandatorypb = false;

View File

@ -651,12 +651,13 @@ class Utils
* Warning: The command line is sanitize so can't contains any redirection char '>'. Use param $redirectionfile if you need it.
* @param string $outputfile A path for an output file (used only when method is 2). For example: $conf->admin->dir_temp.'/out.tmp';
* @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec', 2=Use the 'popen' method
* @param string $redirectionfile If defined, a redirection of output to this files is added.
* @param string $redirectionfile If defined, a redirection of output to this file is added.
* @param int $noescapecommand 1=Do not escape command. Warning: Using this parameter need you alreay sanitized the command. if not, it will lead to security vulnerability.
* This parameter is provided for backward compatibility with external modules. Always use 0 in core.
* @param string $redirectionfileerr If defined, a redirection of error is added to this file instead of to channel 1.
* @return array array('result'=>...,'output'=>...,'error'=>...). result = 0 means OK.
*/
public function executeCLI($command, $outputfile, $execmethod = 0, $redirectionfile = null, $noescapecommand = 0)
public function executeCLI($command, $outputfile, $execmethod = 0, $redirectionfile = null, $noescapecommand = 0, $redirectionfileerr = null)
{
global $conf, $langs;
@ -667,10 +668,17 @@ class Utils
if (empty($noescapecommand)) {
$command = escapeshellcmd($command);
}
if ($redirectionfile) {
$command .= " > ".dol_sanitizePathName($redirectionfile);
}
$command .= " 2>&1";
if ($redirectionfileerr && ($redirectionfileerr != $redirectionfile)) {
// If we ask a redirect of stderr on a given file not already used for stdout
$command .= " 2> ".dol_sanitizePathName($redirectionfileerr);
} else {
$command .= " 2>&1";
}
if (!empty($conf->global->MAIN_EXEC_USE_POPEN)) {
$execmethod = $conf->global->MAIN_EXEC_USE_POPEN;
@ -679,7 +687,7 @@ class Utils
$execmethod = 1;
}
//$execmethod=1;
dol_syslog("Utils::executeCLI execmethod=".$execmethod." system:".$command, LOG_DEBUG);
dol_syslog("Utils::executeCLI execmethod=".$execmethod." command=".$command, LOG_DEBUG);
$output_arr = array();
if ($execmethod == 1) {

View File

@ -0,0 +1,63 @@
<?php
if (empty($keyforclass) || empty($keyforclassfile) || empty($keyforelement)) {
//print $keyforclass.' - '.$keyforclassfile.' - '.$keyforelement;
dol_print_error('', 'include of file commonfieldsinimport.inc.php was done but var $keyforclass or $keyforclassfile or $keyforelement was not set');
exit;
}
if (empty($keyforalias)) {
$keyforalias = 't';
}
dol_include_once($keyforclassfile);
if (class_exists($keyforclass)) {
$tmpobject = new $keyforclass($this->db);
// Add common fields
foreach ($tmpobject->fields as $keyfield => $valuefield) {
$fieldname = $keyforalias.'.'.$keyfield;
$fieldlabel = ucfirst($valuefield['label']);
$typeFilter = "Text";
$typefield = preg_replace('/\(.*$/', '', $valuefield['type']); // double(24,8) -> double
switch ($typefield) {
case 'int':
case 'integer':
case 'double':
case 'price':
$typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
case 'timestamp':
$typeFilter = "Date";
break;
case 'boolean':
$typeFilter = "Boolean";
break;
/*
* case 'sellist':
* $tmp='';
* $tmpparam=jsonOrUnserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
* if ($tmpparam['options'] && is_array($tmpparam['options'])) {
* $tmpkeys=array_keys($tmpparam['options']);
* $tmp=array_shift($tmpkeys);
* }
* if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
* break;
*/
}
$helpfield = '';
if (!empty($valuefield['help'])) {
$helpfield = preg_replace('/\(.*$/', '', $valuefield['help']);
}
if ($valuefield['enabled']) {
$this->import_fields_array[$r][$fieldname] = $fieldlabel;
$this->import_TypeFields_array[$r][$fieldname] = $typeFilter;
$this->import_entities_array[$r][$fieldname] = $keyforelement;
$this->import_help_array[$r][$fieldname] = $helpfield;
}
}
} else {
dol_print_error($this->db, 'Failed to find class '.$keyforclass.', even after the include of '.$keyforclassfile);
}
// End add common fields

View File

@ -106,7 +106,7 @@ abstract class DoliDB implements Database
*/
public function idate($param, $gm = 'tzserver')
{
// TODO $param should be gmt, so we should add $gm to 'gmt' instead of default 'tzserver'
// TODO $param should be gmt, so we should have default $gm to 'gmt' instead of default 'tzserver'
return dol_print_date($param, "%Y-%m-%d %H:%M:%S", $gm);
}

View File

@ -12,7 +12,7 @@ if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) {
// Add extra fields
$sql = "SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields";
$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type != 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC';
$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".((int) $conf->entity).') ORDER BY pos ASC';
//print $sql;
$resql = $this->db->query($sql);
if ($resql) { // This can fail when class is used on old database (during migration for example)

View File

@ -0,0 +1,75 @@
<?php
// $keyforselect = name of main table
// keyforelement = name of picto
// $keyforaliasextra = a key to avoid conflict with extrafields of other objects
if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) {
//print $keyforselet.' - '.$keyforelement.' - '.$keyforaliasextra;
dol_print_error('', 'include of file extrafieldsinimport.inc.php was done but var $keyforselect or $keyforelement or $keyforaliasextra was not set');
exit;
}
// Add extra fields
$sql = "SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields";
$sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type <> 'separate' AND entity IN (0, ".((int) $conf->entity).') ORDER BY pos ASC';
//print $sql;
$resql = $this->db->query($sql);
if ($resql) { // This can fail when class is used on old database (during migration for example)
while ($obj = $this->db->fetch_object($resql)) {
$fieldname = $keyforaliasextra.'.'.$obj->name;
$fieldlabel = ucfirst($obj->label);
$typeFilter = "Text";
$typefield = preg_replace('/\(.*$/', '', $obj->type); // double(24,8) -> double
switch ($typefield) {
case 'int':
case 'integer':
case 'double':
case 'price':
$typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
case 'timestamp':
$typeFilter = "Date";
break;
case 'boolean':
$typeFilter = "Boolean";
break;
case 'checkbox':
case 'select':
if (!empty($conf->global->EXPORT_LABEL_FOR_SELECT)) {
$tmpparam = jsonOrUnserialize($obj->param); // $tmpparam may be array with 'options' = array(key1=>val1, key2=>val2 ...)
if ($tmpparam['options'] && is_array($tmpparam['options'])) {
$typeFilter = "Select:".$obj->param;
}
}
break;
case 'sellist':
$tmp = '';
$tmpparam = jsonOrUnserialize($obj->param); // $tmp may be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if (is_array($tmpparam) && array_key_exists('options', $tmpparam) && $tmpparam['options'] && is_array($tmpparam['options'])) {
$tmpkeys = array_keys($tmpparam['options']);
$tmp = array_shift($tmpkeys);
}
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) {
$typeFilter = "List:".$tmp;
}
break;
}
if ($obj->type != 'separate') {
// If not a computed field
if (empty($obj->fieldcomputed)) {
$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
$this->import_TypeFields_array[$r][$fieldname] = $typeFilter;
$this->import_entities_array[$r][$fieldname] = $keyforelement;
} else {
// If this is a computed field
$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
$this->import_TypeFields_array[$r][$fieldname] = $typeFilter.'Compute';
$this->import_entities_array[$r][$fieldname] = $keyforelement;
}
}
}
}
// End add axtra fields

View File

@ -42,6 +42,8 @@
function societe_prepare_head(Societe $object)
{
global $db, $langs, $conf, $user;
global $hookmanager;
$h = 0;
$head = array();

View File

@ -2083,65 +2083,115 @@ 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;
// We create output dir manually, so it uses the correct permission (When created by the archive->extract, dir is rwx for everybody).
dol_mkdir(dol_sanitizePathName($outputdir));
// 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);
dol_mkdir(dol_sanitizePathName($outputdir));
$outputfilename = escapeshellcmd(dol_sanitizePathName($outputdir).'/'.dol_sanitizeFileName($fileinfo["filename"]));
dol_delete_file($outputfilename.'.tmp');
dol_delete_file($outputfilename.'.err');
$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, $outputfilename.'.tmp', 0, $outputfilename.'.err', 0);
if ($resarray["result"] != 0) {
$resarray["error"] .= file_get_contents($outputfilename.'.err');
}
$zip->close();
return array();
} 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'=>'ErrorBadFileExtension');
}
$cmd = $program.' -dc '.escapeshellcmd(dol_sanitizePathName($fileinfo["dirname"]).'/'.dol_sanitizeFileName($fileinfo["basename"]));
$cmd .= ' > '.$outputfilename;
$resarray = $utils->executeCLI($cmd, $outputfilename.'.tmp', 0, null, 1, $outputfilename.'.err');
if ($resarray["result"] != 0) {
$errfilecontent = @file_get_contents($outputfilename.'.err');
if ($errfilecontent) {
$resarray["error"] .= " - ".$errfilecontent;
}
}
}
return $resarray["result"] != 0 ? array('error' => $resarray["error"]) : array();
}
return array('error'=>'ErrNoZipEngine');
return array('error'=>'ErrorBadFileExtension');
}

View File

@ -507,7 +507,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
}
// BorderTableActive
/* Disabled because not supported by md theme
if ($foruserprofile) {
} else {
$default = $langs->trans('No');
@ -525,7 +524,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
print '</td>';
print '</tr>';
}
*/
// Background color THEME_ELDY_BACKBODY
if ($foruserprofile) {

View File

@ -176,7 +176,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
* @param string $type Type of barcode (EAN, ISBN, ...)
* @return string Value if OK, '' if module not configured, <0 if KO
*/
public function getNextValue($objproduct = null, $type = '')
public function getNextValue($objproduct, $type = '')
{
global $db, $conf;

View File

@ -150,7 +150,7 @@ class mod_facture_mars extends ModeleNumRefFactures
* @param Societe $objsoc Object third party
* @param Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value
* @return string Value
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $invoice, $mode = 'next')
{

View File

@ -171,7 +171,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
$this->error = $numFinal;
}
return $numFinal;
return $numFinal;
}

View File

@ -185,7 +185,7 @@ class mod_facture_terre extends ModeleNumRefFactures
* @param Societe $objsoc Object third party
* @param Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value
* @return string Next ref value or last ref if $mode is 'last'
* @return string Next ref value or last ref if $mode is 'last', <= 0 if KO
*/
public function getNextValue($objsoc, $invoice, $mode = 'next')
{
@ -259,6 +259,8 @@ class mod_facture_terre extends ModeleNumRefFactures
} else {
dol_print_error('', 'Bad parameter for getNextValue');
}
return 0;
}
/**

View File

@ -132,10 +132,11 @@ abstract class ModeleNumRefFactures
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Objet societe
* @param Facture $facture Objet facture
* @param Facture $invoice Objet facture
* @param string $mode 'next' for next value or 'last' for last value
* @return string Value
*/
public function getNextValue($objsoc, $facture)
public function getNextValue($objsoc, $invoice, $mode = 'next')
{
global $langs;
return $langs->trans("NotAvailable");

View File

@ -122,9 +122,11 @@ abstract class ModeleNumRefFicheinter
/**
* Return the next assigned value
*
* @return string Value
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue()
public function getNextValue($objsoc = 0, $object = '')
{
global $langs;
return $langs->trans("NotAvailable");

View File

@ -117,11 +117,11 @@ class mod_holiday_immaculate extends ModelNumRefHolidays
/**
* Return next value
*
* @param Societe $user user object
* @param Societe $objsoc third party object
* @param Object $holiday holiday object
* @return string Value if OK, 0 if KO
*/
public function getNextValue($user, $holiday)
public function getNextValue($objsoc, $holiday)
{
global $db, $conf;
@ -134,7 +134,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays
return 0;
}
$numFinal = get_next_value($db, $mask, 'holiday', 'ref', '', $user, $holiday->date_create);
$numFinal = get_next_value($db, $mask, 'holiday', 'ref', '', $objsoc, $holiday->date_create);
return $numFinal;
}

View File

@ -126,10 +126,10 @@ class ModelNumRefHolidays
* Return next value
*
* @param Societe $objsoc third party object
* @param Object $contract contract object
* @return string Value
* @param Object $holiday Holiday object
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $contract)
public function getNextValue($objsoc, $holiday)
{
global $langs;
return $langs->trans("NotAvailable");

View File

@ -324,7 +324,8 @@ class ImportCsv extends ModeleImports
//dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid);
//var_dump($array_match_file_to_database);
//var_dump($arrayrecord);
//var_dump($arrayrecord); exit;
$array_match_database_to_file = array_flip($array_match_file_to_database);
$sort_array_match_file_to_database = $array_match_file_to_database;
ksort($sort_array_match_file_to_database);
@ -367,12 +368,15 @@ class ImportCsv extends ModeleImports
//dol_syslog("Table ".$tablename." check for entity into cache is ".$tablewithentity_cache[$tablename]);
}
// array of fields to column index
// Define array to convert fields ('c.ref', ...) into column index (1, ...)
$arrayfield = array();
foreach ($sort_array_match_file_to_database as $key => $val) {
$arrayfield[$val] = ($key - 1);
}
// $arrayrecord start at key 0
// $sort_array_match_file_to_database start at key 1
// Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom)
foreach ($sort_array_match_file_to_database as $key => $val) {
$fieldalias = preg_replace('/\..*$/i', '', $val);
@ -595,9 +599,24 @@ class ImportCsv extends ModeleImports
if (!empty($classModForNumber) && !empty($pathModForNumber) && is_readable(DOL_DOCUMENT_ROOT.$pathModForNumber)) {
require_once DOL_DOCUMENT_ROOT.$pathModForNumber;
$modForNumber = new $classModForNumber;
$defaultref = $modForNumber->getNextValue(null, null);
$tmpobject = null;
// Set the object when we can
if (!empty($objimport->array_import_convertvalue[0][$val]['classobject'])) {
$pathForObject = $objimport->array_import_convertvalue[0][$val]['pathobject'];
require_once DOL_DOCUMENT_ROOT.$pathForObject;
$tmpclassobject = $objimport->array_import_convertvalue[0][$val]['classobject'];
$tmpobject = new $tmpclassobject($this->db);
foreach ($arrayfield as $tmpkey => $tmpval) { // $arrayfield is array('c.ref'=>0, ...)
if (in_array($tmpkey, array('t.date', 'c.date_commande'))) {
$tmpobject->date = dol_stringtotime($arrayrecord[$arrayfield[$tmpkey]]['val'], 1);
}
}
}
$defaultref = $modForNumber->getNextValue(null, $tmpobject);
}
if (is_numeric($defaultref) && $defaultref <= 0) {
if (is_numeric($defaultref) && $defaultref <= 0) { // If error
$defaultref = '';
}
$newval = $defaultref;

View File

@ -367,7 +367,8 @@ class ImportXlsx extends ModeleImports
//dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid);
//var_dump($array_match_file_to_database);
//var_dump($arrayrecord);
//var_dump($arrayrecord); exit;
$array_match_database_to_file = array_flip($array_match_file_to_database);
$sort_array_match_file_to_database = $array_match_file_to_database;
ksort($sort_array_match_file_to_database);
@ -410,12 +411,15 @@ class ImportXlsx extends ModeleImports
//dol_syslog("Table ".$tablename." check for entity into cache is ".$tablewithentity_cache[$tablename]);
}
// array of fields to column index
// Define array to convert fields ('c.ref', ...) into column index (1, ...)
$arrayfield = array();
foreach ($sort_array_match_file_to_database as $key => $val) {
$arrayfield[$val] = ($key - 1);
$arrayfield[$val] = ($key);
}
// $arrayrecord start at key 1
// $sort_array_match_file_to_database start at key 1
// Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom)
foreach ($sort_array_match_file_to_database as $key => $val) {
$fieldalias = preg_replace('/\..*$/i', '', $val);
@ -619,7 +623,7 @@ class ImportXlsx extends ModeleImports
$this->thirpartyobject->get_codecompta('supplier');
$newval = $this->thirpartyobject->code_compta_fournisseur;
if (empty($newval)) {
$arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null"
$arrayrecord[($key)]['type'] = -1; // If we get empty value, we will use "null"
}
//print 'code_compta_fournisseur='.$newval;
}
@ -636,9 +640,24 @@ class ImportXlsx extends ModeleImports
if (!empty($classModForNumber) && !empty($pathModForNumber) && is_readable(DOL_DOCUMENT_ROOT.$pathModForNumber)) {
require_once DOL_DOCUMENT_ROOT.$pathModForNumber;
$modForNumber = new $classModForNumber;
$defaultref = $modForNumber->getNextValue(null, null);
$tmpobject = null;
// Set the object with the date property when we can
if (!empty($objimport->array_import_convertvalue[0][$val]['classobject'])) {
$pathForObject = $objimport->array_import_convertvalue[0][$val]['pathobject'];
require_once DOL_DOCUMENT_ROOT.$pathForObject;
$tmpclassobject = $objimport->array_import_convertvalue[0][$val]['classobject'];
$tmpobject = new $tmpclassobject($this->db);
foreach ($arrayfield as $tmpkey => $tmpval) { // $arrayfield is array('c.ref'=>1, ...)
if (in_array($tmpkey, array('t.date', 'c.date_commande'))) {
$tmpobject->date = dol_stringtotime($arrayrecord[$arrayfield[$tmpkey]]['val'], 1);
}
}
}
$defaultref = $modForNumber->getNextValue(null, $tmpobject);
}
if (is_numeric($defaultref) && $defaultref <= 0) {
if (is_numeric($defaultref) && $defaultref <= 0) { // If error
$defaultref = '';
}
$newval = $defaultref;

View File

@ -196,10 +196,10 @@ class modCommande extends DolibarrModules
's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom'=>'ParentCompany', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country',
'co.code'=>"CountryCode", 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id",
'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", 'c.date_commande'=>"OrderDate",
'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.remise_percent'=>"GlobalDiscount", 'c.total_ht'=>"TotalHT",
'c.date_livraison'=>"DateDeliveryPlanned", 'c.amount_ht'=>"Amount", 'c.total_ht'=>"TotalHT",
'c.total_ttc'=>"TotalTTC", 'c.facture'=>"Billed", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate',
'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin',
'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',
'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',
'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC",
'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel'
);
@ -220,7 +220,7 @@ class modCommande extends DolibarrModules
//$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label',
// 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",
// 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",
// 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.total_ht'=>"Numeric",
// 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",
// 'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",
// 'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text'
@ -228,7 +228,7 @@ class modCommande extends DolibarrModules
$this->export_TypeFields_array[$r] = array(
's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text',
's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.date_creation'=>"Date",
'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric",
'c.date_commande'=>"Date", 'c.date_livraison'=>"Date", 'c.amount_ht'=>"Numeric", 'c.total_ht'=>"Numeric",
'c.total_ttc'=>"Numeric", 'c.facture'=>"Boolean", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date', 'pj.ref'=>'Text',
'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric", 'cd.total_tva'=>"Numeric",
'cd.total_ttc'=>"Numeric", 'p.rowid'=>'List:product:ref::product', 'p.ref'=>'Text', 'p.label'=>'Text', 'd.nom'=>'Text',
@ -238,8 +238,8 @@ class modCommande extends DolibarrModules
's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company',
'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"order",
'c.ref'=>"order", 'c.ref_client'=>"order", 'c.fk_soc'=>"order", 'c.date_creation'=>"order", 'c.date_commande'=>"order", 'c.amount_ht'=>"order",
'c.remise_percent'=>"order", 'c.total_ht'=>"order", 'c.total_ttc'=>"order", 'c.facture'=>"order", 'c.fk_statut'=>"order", 'c.note'=>"order",
'c.date_livraison'=>"order", 'pj.ref'=>'project', 'cd.rowid'=>'order_line', 'cd.label'=>"order_line", 'cd.description'=>"order_line",
'c.total_ht'=>"order", 'c.total_ttc'=>"order", 'c.facture'=>"order", 'c.fk_statut'=>"order", 'c.note'=>"order",
'c.date_livraison'=>"order", 'pj.ref'=>'project', 'cd.rowid'=>'order_line', 'cd.description'=>"order_line",
'cd.product_type'=>'order_line', 'cd.tva_tx'=>"order_line", 'cd.qty'=>"order_line", 'cd.total_ht'=>"order_line", 'cd.total_tva'=>"order_line",
'cd.total_ttc'=>"order_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'
);
@ -296,18 +296,17 @@ class modCommande extends DolibarrModules
$this->import_entities_array[$r] = array();
$this->import_tables_array[$r] = array('c' => MAIN_DB_PREFIX.'commande', 'extra' => MAIN_DB_PREFIX.'commande_extrafields');
$this->import_tables_creator_array[$r] = array('c' => 'fk_user_author'); // Fields to store import user id
$import_sample = array();
$this->import_fields_array[$r] = array(
'c.ref' => 'Ref*',
'c.ref_client' => 'RefCustomer',
'c.fk_soc' => 'ThirdPartyName*',
'c.fk_projet' => 'ProjectId',
'c.date_creation' => 'DateCreation',
'c.date_valid' => 'DateValid',
'c.date_commande' => 'DateOrder',
'c.date_valid' => 'DateValidation',
'c.date_commande' => 'OrderDate*',
'c.fk_user_modif' => 'ModifiedById',
'c.fk_user_valid' => 'ValidatedById',
'c.fk_statut' => 'Status*',
'c.remise_percent' => 'GlobalDiscount',
'c.total_tva' => 'TotalTVA',
'c.total_ht' => 'TotalHT',
'c.total_ttc' => 'TotalTTC',
@ -317,7 +316,8 @@ class modCommande extends DolibarrModules
'c.date_livraison' => 'DeliveryDate',
'c.fk_cond_reglement' => 'Payment Condition',
'c.fk_mode_reglement' => 'Payment Mode',
'c.model_pdf' => 'Model'
'c.model_pdf' => 'Model',
'c.fk_statut' => 'Status*'
);
if (!empty($conf->multicurrency->enabled)) {
@ -327,51 +327,48 @@ class modCommande extends DolibarrModules
$this->import_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT';
$this->import_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
// Add extra fields
$import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'commande' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
$keyforselect = 'commande';
$keyforelement = 'order';
$keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
$import_extrafield_sample[$fieldname] = $fieldlabel;
}
}
// End add extra fields
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande'];
$this->import_regex_array[$r] = [
$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commande');
$this->import_regex_array[$r] = array(
'c.multicurrency_code' => 'code@'.MAIN_DB_PREFIX.'multicurrency'
];
$this->import_updatekeys_array[$r] = ['c.ref' => 'Ref'];
$this->import_convertvalue_array[$r] = [
'c.fk_soc' => [
);
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = array('c.ref' => 'Ref');
$this->import_convertvalue_array[$r] = array(
'c.ref' => array(
'rule'=>'getrefifauto',
'class'=>(empty($conf->global->COMMANDE_ADDON) ? 'mod_commande_marbre' : $conf->global->COMMANDE_ADDON),
'path'=>"/core/modules/commande/".(empty($conf->global->COMMANDE_ADDON) ? 'mod_commande_marbre' : $conf->global->COMMANDE_ADDON).'.php',
'classobject'=>'Commande',
'pathobject'=>'/commande/class/commande.class.php',
),
'c.fk_soc' => array(
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
],
'c.fk_user_valid' => [
),
'c.fk_user_valid' => array(
'rule' => 'fetchidfromref',
'file' => '/user/class/user.class.php',
'class' => 'User',
'method' => 'fetch',
'element' => 'user'
],
'c.fk_mode_reglement' => [
),
'c.fk_mode_reglement' => array(
'rule' => 'fetchidfromcodeorlabel',
'file' => '/compta/paiement/class/cpaiement.class.php',
'class' => 'Cpaiement',
'method' => 'fetch',
'element' => 'cpayment'
],
];
),
);
//Import CPV Lines
$r++;
@ -381,15 +378,13 @@ class modCommande extends DolibarrModules
$this->import_entities_array[$r] = array();
$this->import_tables_array[$r] = array('cd' => MAIN_DB_PREFIX.'commandedet', 'extra' => MAIN_DB_PREFIX.'commandedet_extrafields');
$this->import_fields_array[$r] = array(
'cd.fk_commande' => 'SalesOrder*',
'cd.fk_parent_line' => 'PrParentLine',
'cd.fk_commande' => 'CustomerOrder*',
'cd.fk_parent_line' => 'ParentLine',
'cd.fk_product' => 'IdProduct',
'cd.label' => 'Label',
'cd.description' => 'LineDescription',
'cd.tva_tx' => 'LineVATRate',
'cd.qty' => 'LineQty',
'cd.remise_percent' => 'Reduc. Percent',
'cd.remise' => 'Reduc.',
'cd.price' => 'Price',
'cd.subprice' => 'Sub Price',
'cd.total_ht' => 'LineTotalHT',
@ -410,17 +405,11 @@ class modCommande extends DolibarrModules
$this->import_fields_array[$r]['cd.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC';
}
// Add extra fields
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'commandedet' AND entity IN (0, ".$conf->entity.")";
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
$fieldname = 'extra.'.$obj->name;
$fieldlabel = ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
}
}
// End add extra fields
$import_extrafield_sample = array();
$keyforselect = 'commandedet';
$keyforelement = 'orderline';
$keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';
$this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'commandedet'];
$this->import_regex_array[$r] = [

View File

@ -276,7 +276,7 @@ class modFacture extends DolibarrModules
'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text',
'none.rest'=>"NumericCompute",
'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",
'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",
'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date",
'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text',
$alias_product_perentity . '.accountancy_code_sell'=>'Text',
@ -289,7 +289,7 @@ class modFacture extends DolibarrModules
$this->export_entities_array[$r] = array(
's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 'cd.nom'=>'company', 's.phone'=>'company',
's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',
's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.label'=>"invoice_line", 'fd.description'=>"invoice_line",
's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line",
'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line",
'fd.qty'=>"invoice_line", 'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>'invoice_line',
'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', $alias_product_perentity . '.accountancy_code_sell'=>'product',

View File

@ -612,7 +612,13 @@ class modFournisseur extends DolibarrModules
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = array('f.ref' => 'Ref');
$this->import_convertvalue_array[$r] = array(
//'c.ref'=>array('rule'=>'getrefifauto'),
'f.ref' => array(
'rule'=>'getrefifauto',
'class'=>(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ? 'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER),
'path'=>"/core/modules/supplier_invoice/".(empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER) ? 'mod_facture_fournisseur_cactus' : $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER).'.php',
'classobject'=>'FactureFournisseur',
'pathobject'=>'/fourn/class/fournisseur.facture.class.php',
),
'f.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),
'f.fk_account' => array('rule' => 'fetchidfromref', 'file' => '/compta/bank/class/account.class.php', 'class' => 'Account', 'method' => 'fetch', 'element' => 'bank_account'),
);
@ -626,9 +632,8 @@ class modFournisseur extends DolibarrModules
$this->import_tables_array[$r] = array('fd' => MAIN_DB_PREFIX.'facture_fourn_det', 'extra' => MAIN_DB_PREFIX.'facture_fourn_det_extrafields');
$this->import_fields_array[$r] = array(
'fd.fk_facture_fourn' => 'InvoiceRef*',
'fd.fk_parent_line' => 'FacParentLine',
'fd.fk_parent_line' => 'ParentLine',
'fd.fk_product' => 'IdProduct',
'fd.label' => 'Label',
'fd.description' => 'LineDescription',
'fd.pu_ht' => 'PriceUHT',
'fd.pu_ttc' => 'PriceUTTC',
@ -670,7 +675,6 @@ class modFournisseur extends DolibarrModules
'fd.fk_facture_fourn' => '(PROV001)',
'fd.fk_parent_line' => '',
'fd.fk_product' => '',
'fd.label' => '',
'fd.description' => 'Test Product',
'fd.pu_ht' => '50000',
'fd.pu_ttc' => '50000',
@ -720,7 +724,6 @@ class modFournisseur extends DolibarrModules
'c.source' => 'Source',
'c.fk_statut' => 'Status*',
'c.billed' => 'Billed(0/1)',
'c.remise_percent' => 'GlobalDiscount',
'c.total_tva' => 'TotalTVA',
'c.total_ht' => 'TotalHT',
'c.total_ttc' => 'TotalTTC',
@ -762,6 +765,13 @@ class modFournisseur extends DolibarrModules
$this->import_updatekeys_array[$r] = array('c.ref' => 'Ref');
$this->import_convertvalue_array[$r] = array(
'c.ref' => array(
'rule'=>'getrefifauto',
'class'=>(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ? 'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER),
'path'=>"/core/modules/supplier_order/".(empty($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER) ? 'mod_commande_fournisseur_muguet' : $conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER).'.php',
'classobject'=>'CommandeFournisseur',
'pathobject'=>'/fourn/class/fournisseur.commande.class.php',
),
'c.fk_soc' => array(
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
@ -788,14 +798,12 @@ class modFournisseur extends DolibarrModules
$this->import_tables_array[$r] = array('cd' => MAIN_DB_PREFIX.'commande_fournisseurdet', 'extra' => MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields');
$this->import_fields_array[$r] = array(
'cd.fk_commande' => 'PurchaseOrder*',
'cd.fk_parent_line' => 'PrParentLine',
'cd.fk_parent_line' => 'ParentLine',
'cd.fk_product' => 'IdProduct',
'cd.label' => 'Label',
'cd.description' => 'LineDescription',
'cd.tva_tx' => 'LineVATRate',
'cd.qty' => 'LineQty',
'cd.remise_percent' => 'Reduc. Percent',
'cd.remise' => 'Reduc.',
'cd.subprice' => 'Sub Price',
'cd.total_ht' => 'LineTotalHT',
'cd.total_tva' => 'LineTotalVAT',

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

@ -182,6 +182,13 @@ class modOpenSurvey extends DolibarrModules
*/
public function init($options = '')
{
global $conf, $langs;
$result = $this->_load_tables('/install/mysql/tables/', 'opensurvey');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}
// Permissions
$this->remove($options);

View File

@ -190,10 +190,10 @@ class modPropale extends DolibarrModules
$this->export_fields_array[$r] = array(
's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 'ps.nom'=>'ParentCompany', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'co.code'=>'CountryCode', 's.phone'=>'Phone',
's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_client'=>"RefCustomer",
'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal", 'c.remise_percent'=>"GlobalDiscount",
'c.fk_soc'=>"IdCompany", 'c.datec'=>"DateCreation", 'c.datep'=>"DatePropal", 'c.fin_validite'=>"DateEndPropal",
'c.total_ht'=>"TotalHT", 'c.total_ttc'=>"TotalTTC", 'c.fk_statut'=>'Status', 'c.note_public'=>"Note", 'c.date_livraison'=>'DeliveryDate',
'c.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin', 'c.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin',
'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.label'=>"Label", 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',
'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId', 'cd.description'=>"LineDescription", 'cd.product_type'=>'TypeOfLineServiceOrProduct',
'cd.tva_tx'=>"LineVATRate", 'cd.qty'=>"LineQty", 'cd.total_ht'=>"LineTotalHT", 'cd.total_tva'=>"LineTotalVAT", 'cd.total_ttc'=>"LineTotalTTC",
'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel'
);
@ -214,14 +214,14 @@ class modPropale extends DolibarrModules
//$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text',
// 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",
// 'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",
// 'c.fin_validite'=>"Date",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",
// 'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",
// 'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'
//);
$this->export_TypeFields_array[$r] = array(
's.nom'=>'Text', 'ps.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text',
's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_client'=>"Text", 'c.datec'=>"Date", 'c.datep'=>"Date", 'c.fin_validite'=>"Date",
'c.remise_percent'=>"Numeric", 'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date',
'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric", 'c.fk_statut'=>'Status', 'c.note_public'=>"Text", 'c.date_livraison'=>'Date',
'pj.ref'=>'Text', 'cd.description'=>"Text", 'cd.product_type'=>'Boolean', 'cd.tva_tx'=>"Numeric", 'cd.qty'=>"Numeric", 'cd.total_ht'=>"Numeric",
'cd.total_tva'=>"Numeric", 'cd.total_ttc'=>"Numeric", 'p.ref'=>'Text', 'p.label'=>'Text',
'c.entity'=>'List:entity:label:rowid',
@ -229,9 +229,9 @@ class modPropale extends DolibarrModules
$this->export_entities_array[$r] = array(
's.rowid'=>"company", 's.nom'=>'company', 'ps.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'co.code'=>'company', 's.phone'=>'company',
's.siren'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.siret'=>'company', 'c.rowid'=>"propal", 'c.ref'=>"propal", 'c.ref_client'=>"propal",
'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.remise_percent'=>"propal", 'c.total_ht'=>"propal",
'c.fk_soc'=>"propal", 'c.datec'=>"propal", 'c.datep'=>"propal", 'c.fin_validite'=>"propal", 'c.total_ht'=>"propal",
'c.total_ttc'=>"propal", 'c.fk_statut'=>"propal", 'c.note_public'=>"propal", 'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line',
'cd.label'=>"propal_line", 'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line",
'cd.description'=>"propal_line", 'cd.product_type'=>'propal_line', 'cd.tva_tx'=>"propal_line", 'cd.qty'=>"propal_line",
'cd.total_ht'=>"propal_line", 'cd.total_tva'=>"propal_line", 'cd.total_ttc'=>"propal_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'
);
$this->export_dependencies_array[$r] = array('propal_line'=>'cd.rowid', 'product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
@ -293,7 +293,6 @@ class modPropale extends DolibarrModules
'c.datec' => 'DateCreation',
'c.datep' => 'DatePropal',
'c.fin_validite' => 'DateEndPropal',
'c.remise_percent' => 'GlobalDiscount',
'c.total_ht' => 'TotalHT',
'c.total_ttc' => 'TotalTTC',
'c.fk_statut' => 'Status*',
@ -330,7 +329,6 @@ class modPropale extends DolibarrModules
'c.datec' => '2020-01-01',
'c.datep' => '2020-01-01',
'c.fin_validite' => '2020-01-01',
'c.remise_percent' => '',
'c.total_ht' => '0',
'c.total_ttc' => '0',
'c.fk_statut' => '1',
@ -344,16 +342,23 @@ class modPropale extends DolibarrModules
'c.multicurrency_total_ttc' => '0'
];
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = ['c.ref'=>'Ref'];
$this->import_convertvalue_array[$r] = [
'c.fk_soc' => [
$this->import_updatekeys_array[$r] = array('c.ref'=>'Ref');
$this->import_convertvalue_array[$r] = array(
'c.ref' => array(
'rule'=>'getrefifauto',
'class'=>(empty($conf->global->PROPALE_ADDON) ? 'mod_propale_marbre' : $conf->global->PROPALE_ADDON),
'path'=>"/core/modules/propale/".(empty($conf->global->PROPALE_ADDON) ? 'mod_propale_marbre' : $conf->global->PROPALE_ADDON).'.php',
'classobject'=>'Propal',
'pathobject'=>'/comm/propal/class/propal.class.php',
),
'c.fk_soc' => array(
'rule' => 'fetchidfromref',
'file' => '/societe/class/societe.class.php',
'class' => 'Societe',
'method' => 'fetch',
'element' => 'ThirdParty'
]
];
)
);
//Import Proposal Lines
$r++;
@ -367,15 +372,13 @@ class modPropale extends DolibarrModules
);
$this->import_fields_array[$r] = array(
'cd.fk_propal' => 'Proposal*',
'cd.fk_parent_line' => 'PrParentLine',
'cd.fk_parent_line' => 'ParentLine',
'cd.fk_product' => 'IdProduct',
'cd.label' => 'Label',
'cd.description' => 'LineDescription',
'cd.product_type' => 'TypeOfLineServiceOrProduct',
'cd.tva_tx' => 'LineVATRate',
'cd.qty' => 'LineQty',
'cd.remise_percent' => 'Reduc. Percent',
'cd.remise' => 'Reduc.',
'cd.price' => 'Price',
'cd.subprice' => 'Sub Price',
'cd.total_ht' => 'LineTotalHT',
@ -411,13 +414,11 @@ class modPropale extends DolibarrModules
'cd.fk_propal' => 'PROV(0001)',
'cd.fk_parent_line' => '',
'cd.fk_product' => '',
'cd.label' => '',
'cd.description' => 'Line description',
'cd.product_type' => '1',
'cd.tva_tx' => '0',
'cd.qty' => '2',
'cd.remise_percent' => '0',
'cd.remise' => '0',
'cd.price' => '',
'cd.subprice' => '5000',
'cd.total_ht' => '10000',

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

@ -128,7 +128,7 @@ class mod_lot_advanced extends ModeleNumRefBatch
/**
* Return next free value
*
* @param Societe $objsoc Object Societe
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/

View File

@ -93,11 +93,11 @@ class mod_lot_free extends ModeleNumRefBatch
/**
* Return an example of result returned by getNextValue
*
* @param product $objproduct Object product
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Return next value
*/
public function getNextValue($objproduct = 0, $type = -1)
public function getNextValue($objsoc, $object)
{
global $langs;
return '';

View File

@ -111,11 +111,11 @@ class mod_lot_standard extends ModeleNumRefBatch
/**
* Return next free value
*
* @param Product $objprod Object product
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($objprod, $object)
public function getNextValue($objsoc, $object)
{
global $db, $conf;

View File

@ -128,11 +128,11 @@ class mod_sn_advanced extends ModeleNumRefBatch
/**
* Return next free value
*
* @param Product $objprod Object product
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($objprod, $object)
public function getNextValue($objsoc, $object)
{
global $db, $conf;

View File

@ -92,11 +92,11 @@ class mod_sn_free extends ModeleNumRefBatch
/**
* Return an example of result returned by getNextValue
*
* @param product $objproduct Object product
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Return next value
*/
public function getNextValue($objproduct = 0, $type = -1)
public function getNextValue($objsoc, $object)
{
global $langs;
return '';

View File

@ -111,7 +111,7 @@ class mod_sn_standard extends ModeleNumRefBatch
/**
* Return next free value
*
* @param Societe $objsoc Object product
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/

View File

@ -96,10 +96,10 @@ class mod_reception_beryl extends ModelNumRefReception
* Return next value
*
* @param Societe $objsoc Third party object
* @param Object $shipment Shipment object
* @param Object $reception Reception object
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $shipment)
public function getNextValue($objsoc, $reception)
{
global $db, $conf;

View File

@ -110,10 +110,10 @@ abstract class ModelNumRefReception
* Returns next value assigned
*
* @param Societe $objsoc Third party object
* @param Object $shipment Shipment object
* @param Object $reception Reception object
* @return string Value
*/
public function getNextValue($objsoc, $shipment)
public function getNextValue($objsoc, $reception)
{
global $langs;
return $langs->trans("NotAvailable");

View File

@ -120,7 +120,7 @@ abstract class ModeleNumRefSuppliersInvoices
* @param string $mode 'next' for next value or 'last' for last value
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $object, $mode)
public function getNextValue($objsoc, $object, $mode = 'next')
{
global $langs;
return $langs->trans("NotAvailable");

View File

@ -120,9 +120,11 @@ abstract class ModeleNumRefSuppliersOrders
/** Returns next value assigned
*
* @return string Valeur
* @param Societe $objsoc Object third party
* @param Object $object Object
* @return string Valeur
*/
public function getNextValue()
public function getNextValue($objsoc = 0, $object = '')
{
global $langs;
return $langs->trans("NotAvailable");

View File

@ -120,9 +120,9 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Propal $supplier_proposal Object commercial proposal
* @return string Next value
* @param Societe $objsoc Object third party
* @param SupplierProposal $supplier_proposal Object commercial proposal
* @return string Next value
*/
public function getNextValue($objsoc, $supplier_proposal)
{

View File

@ -120,9 +120,9 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Propal $supplier_proposal Object supplier_proposal
* @return string Value if OK, 0 if KO
* @param Societe $objsoc Object third party
* @param SupplierProposal $supplier_proposal Object commercial proposal
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $supplier_proposal)
{

View File

@ -124,11 +124,11 @@ abstract class ModeleNumRefSupplierProposal
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Propal $propal Object commercial proposal
* @return string Valeur
* @param Societe $objsoc Object third party
* @param SupplierProposal $supplier_proposal Object commercial proposal
* @return string Valeur
*/
public function getNextValue($objsoc, $propal)
public function getNextValue($objsoc, $supplier_proposal)
{
global $langs;
return $langs->trans("NotAvailable");

View File

@ -119,7 +119,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos
* @param string $mode 'next' for next value or 'last' for last value
* @return string Value if KO, <0 if KO
*/
public function getNextValue($objsoc = 0, $invoice = null, $mode = 'next')
public function getNextValue($objsoc = null, $invoice = null, $mode = 'next')
{
global $db, $conf;

View File

@ -89,9 +89,12 @@ abstract class ModeleNumRefTakepos
/**
* Renvoi prochaine valeur attribuee
*
* @return string Valeur
* @param Societe $objsoc Object thirdparty
* @param Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value
* @return string Value if KO, <0 if KO
*/
public function getNextValue()
public function getNextValue($objsoc = null, $invoice = null, $mode = 'next')
{
global $langs;
return $langs->trans('NotAvailable');

View File

@ -115,11 +115,11 @@ abstract class ModeleNumRefTicket
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Valeur
* @param Societe $objsoc Object third party
* @param Ticket $ticket Object ticket
* @return string Valeur
*/
public function getNextValue($objsoc, $project)
public function getNextValue($objsoc, $ticket)
{
global $langs;
return $langs->trans("NotAvailable");

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

@ -627,10 +627,10 @@ class EcmDirectory extends CommonObject
* date_c Date creation
* fk_user_c User creation
* login_c Login creation
* fullpath Full path of id (Added by build_path_from_id_categ call)
* fullrelativename Full path name (Added by build_path_from_id_categ call)
* fulllabel Full label (Added by build_path_from_id_categ call)
* level Level of line (Added by build_path_from_id_categ call)
* fullpath Full path of id (Added by buildPathFromId call)
* fullrelativename Full path name (Added by buildPathFromId call)
* fulllabel Full label (Added by buildPathFromId call)
* level Level of line (Added by buildPathFromId call)
*
* @param int $force Force reload of full arbo even if already loaded in cache $this->cats
* @return array Tableau de array
@ -698,10 +698,10 @@ class EcmDirectory extends CommonObject
// We add properties fullxxx to all elements
foreach ($this->cats as $key => $val) {
if (isset($motherof[$key])) {
if (isset($this->motherof[$key])) {
continue;
}
$this->build_path_from_id_categ($key, 0);
$this->buildPathFromId($key, 0);
}
$this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
@ -710,7 +710,6 @@ class EcmDirectory extends CommonObject
return $this->cats;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Define properties fullpath, fullrelativename, fulllabel of a directory of array this->cats and all its childs.
* Separator between directories is always '/', whatever is OS.
@ -719,9 +718,8 @@ class EcmDirectory extends CommonObject
* @param int $protection Deep counter to avoid infinite loop
* @return void
*/
public function build_path_from_id_categ($id_categ, $protection = 0)
private function buildPathFromId($id_categ, $protection = 0)
{
// phpcs:enable
// Define fullpath
if (!empty($this->cats[$id_categ]['id_mere'])) {
$this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
@ -745,7 +743,7 @@ class EcmDirectory extends CommonObject
}
if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
$this->build_path_from_id_categ($val, $protection);
$this->buildPathFromId($val, $protection);
}
}
}

View File

@ -1336,6 +1336,15 @@ if (empty($reshook)) {
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
unset($qty);
unset($value_unit_ht);
unset($value_unit);
unset($vatrate);
unset($comments);
unset($fk_c_type_fees);
unset($fk_project);
unset($date);
}
//header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);

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

@ -299,40 +299,34 @@ class FactureFournisseurRec extends CommonInvoice
$sql .= ') VALUES (';
$sql .= "'".$this->db->escape($this->titre)."'";
$sql .= ", '".$this->db->escape($this->ref_supplier)."'";
$sql .= ', ' . (int) $conf->entity;
$sql .= ', ' . (int) $facfourn_src->socid;
$sql .= ", ".((int) $conf->entity);
$sql .= ", ".((int) $facfourn_src->socid);
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ', ' . (int) $this->suspended;
if (!empty(GETPOST('libelle'))) {
$sql .= ", '" . $this->db->escape(GETPOST('libelle')) . "'";
} elseif (! empty($this->libelle)) {
$sql .= ", '" . $this->db->escape($this->libelle) . "'";
} else {
$sql .= ", ''";
}
$sql .= ', ' .(!empty($facfourn_src->total_ttc) ? (float) $facfourn_src->total_ttc : '0'); // amount
$sql .= ', ' .(!empty($facfourn_src->remise) ? (float) $facfourn_src->remise : '0');
$sql .= ', ' . (int) $user->id;
$sql .= ', ' .(!empty($this->fk_project) ? $this->fk_project : 'NULL'); // Fields declarded on creation
$sql .= ', ' .(!empty($facfourn_src->fk_account) ? $facfourn_src->fk_account : 'NULL');
$sql .= ', ' .($this->cond_reglement_id > 0 ? (int) $this->cond_reglement_id : 'NULL');
$sql .= ', ' .($this->mode_reglement_id > 0 ? (int) $this->mode_reglement_id : 'NULL');
$sql .= ", '".($facfourn_src->date_echeance > 0 ? $this->db->idate($facfourn_src->date_echeance) : 'NULL')."'"; // date_lim_reglement
$sql .= ', ' .(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : 'NULL'); // Fields declarded on creation
$sql .= ', ' .(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : 'NULL'); // Fields declarded on creation
$sql .= ', ' .(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL'); // Fields declarded on creation
$sql .= ', ' . (int) $facfourn_src->fk_multicurrency;
$sql .= ", ".((int) $this->suspended);
$sql .= ", '".$this->db->escape($this->libelle)."'";
$sql .= ", " .(!empty($facfourn_src->total_ttc) ? (float) $facfourn_src->total_ttc : '0'); // amount
$sql .= ", " .(!empty($facfourn_src->remise) ? (float) $facfourn_src->remise : '0');
$sql .= ", " .((int) $user->id);
$sql .= ", " .(!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL');
$sql .= ", " .(!empty($facfourn_src->fk_account) ? ((int) $facfourn_src->fk_account) : 'NULL');
$sql .= ", " .($this->cond_reglement_id > 0 ? (int) $this->cond_reglement_id : 'NULL');
$sql .= ", " .($this->mode_reglement_id > 0 ? (int) $this->mode_reglement_id : 'NULL');
$sql .= ", ".($facfourn_src->date_echeance > 0 ? "'".$this->db->idate($facfourn_src->date_echeance)."'" : 'NULL'); // date_lim_reglement
$sql .= ", " .(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : 'NULL');
$sql .= ", " .(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : 'NULL');
$sql .= ", " .(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL');
$sql .= ", " . (int) $facfourn_src->fk_multicurrency;
$sql .= ", '".$this->db->escape($facfourn_src->multicurrency_code)."'";
$sql .= ', ' . (float) $facfourn_src->multicurrency_tx;
$sql .= ', ' . (int) $this->usenewprice; // Fields declarded on creation
$sql .= ', ' . (int) $this->frequency; // Fields declarded on creation
$sql .= ", '".$this->db->escape($this->unit_frequency)."'"; // Fields declarded on creation
$sql .= ', ' .(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL'); // Fields declarded on creation
$sql .= ', ' .(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL'); // Fields declarded on creation
$sql .= ', ' . (int) $this->nb_gen_done; // Fields declarded on creation
$sql .= ', ' . (int) $this->nb_gen_max; // Fields declarded on creation
$sql .= ', ' . (int) $this->auto_validate; // Fields declarded on creation
$sql .= ', ' . (int) $this->generate_pdf; // Fields declarded on creation
$sql .= ", " . (float) $facfourn_src->multicurrency_tx;
$sql .= ", " . (int) $this->usenewprice;
$sql .= ", " . (int) $this->frequency;
$sql .= ", '".$this->db->escape($this->unit_frequency)."'";
$sql .= ", " .(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL');
$sql .= ", " .(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL');
$sql .= ", " . (int) $this->nb_gen_done;
$sql .= ", " . (int) $this->nb_gen_max;
$sql .= ", " . (int) $this->auto_validate;
$sql .= ", " . (int) $this->generate_pdf;
$sql .= ')';
if ($this->db->query($sql)) {
@ -475,44 +469,43 @@ class FactureFournisseurRec extends CommonInvoice
$error = 0;
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_rec SET";
$sql .= ' titre = "' . (!empty($this->titre) ? $this->titre .'",' : '"",') ;
$sql .= ' ref_supplier = "'. (!empty($this->ref_supplier) ? $this->ref_supplier .'",' : '" ",');
$sql .= " entity = ". (!empty($this->entity) ? $this->entity : 1) . ',';
$sql .= " titre = '" . (!empty($this->titre) ? $this->db->escape($this->titre) : "")."'," ;
$sql .= " ref_supplier = '". (!empty($this->ref_supplier) ? $this->db->escape($this->ref_supplier) : "")."',";
$sql .= " entity = ". (!empty($this->entity) ? ((int) $this->entity) : 1) . ',';
if ($this->fk_soc > 0) $sql .= " fk_soc = ". (int) $this->fk_soc. ',';
$sql .= ' tms = "'. date('Y-m-d H:i:s', dol_now()) . '",';
$sql .= " suspended = ". (!empty($this->suspended) ? $this->suspended : 0) . ',';
$sql .= ' libelle = "'. (!empty($this->libelle) ? $this->libelle : 'NULL') . '",';
$sql .= " amount = ". (!empty($this->amount) ? $this->amount : 0.00) . ',';
$sql .= " remise = ". (!empty($this->remise) ? $this->remise : 'NULL') . ',';
$sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? $this->vat_src_code : 'NULL') . ',';
$sql .= " localtax1 = ". (!empty($this->localtax1) ? $this->localtax1 : 0.00) . ',';
$sql .= " localtax2 = ". (!empty($this->localtax2) ? $this->localtax2 : 0.00) . ',';
$sql .= " total_ht = ". (!empty($this->total_ht) ? $this->total_ht : 0.00) . ',';
$sql .= " total_tva = ". (!empty($this->total_tva) ? $this->total_tva : 0.00) . ',';
$sql .= " total_ttc = ". (!empty($this->total_ttc) ? $this->total_ttc : 0.00) . ',';
$sql .= " fk_user_modif = ". $user->id . ',';
$sql .= " fk_projet = ". (!empty($this->fk_project) ? $this->fk_project : 'NULL') . ',';
$sql .= " fk_account = ". (!empty($this->fk_account) ? $this->fk_account : 'NULL') . ',';
$sql .= " fk_mode_reglement = ". (!empty($this->mode_reglement_id) ? $this->mode_reglement_id : 'NULL') . ',';
$sql .= " fk_cond_reglement = ". (!empty($this->cond_reglement_id) ? $this->cond_reglement_id : 'NULL') . ',';
$sql .= " date_lim_reglement = ". (!empty($this->date_lim_reglement) ? '"'.date("Y-m-d H:i:s", $this->date_lim_reglement).'"' : 'NULL') . ',';
$sql .= ' note_private = "'. (!empty($this->note_private) ? $this->note_private : '') . '",';
$sql .= ' note_public = "'. (!empty($this->note_public) ? $this->note_public : '') . '",';
$sql .= ' modelpdf = "'. (!empty($this->model_pdf) ? $this->model_pdf : 'NULL') . '",';
$sql .= " fk_multicurrency = ". (!empty($this->fk_multicurrency) ? $this->fk_multicurrency : 'NULL') . ',';
$sql .= ' multicurrency_code = "'. (!empty($this->multicurrency_code) ? $this->multicurrency_code : 'NULL') . '",';
$sql .= " multicurrency_tx = ". (!empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1) . ',';
$sql .= " multicurrency_total_ht = ". (!empty($this->multicurrency_total_ht) ? $this->multicurrency_total_ht : 0.00) . ',';
$sql .= " multicurrency_total_tva = ". (!empty($this->multicurrency_total_tva) ? $this->multicurrency_total_tva : 0.00) . ',';
$sql .= " multicurrency_total_ttc = ". (!empty($this->multicurrency_total_ttc) ? $this->multicurrency_total_ttc : 0.00) . ',';
$sql .= " usenewprice = ". (!empty($this->usenewprice) ? $this->usenewprice : 0) . ',';
$sql .= " frequency = ". (!empty($this->frequency) ? $this->frequency : 0). ',';
$sql .= ' unit_frequency = "'. (!empty($this->unit_frequency) ? $this->unit_frequency : 0). '",';
$sql .= " date_when = ". (!empty($this->date_when) ? '"'.date("Y-m-d H:i:s", $this->date_when).'"' : 0) . ',';
$sql .= " date_last_gen = ". (!empty($this->date_last_gen) ? '"'.date("Y-m-d H:i:s", $this->date_last_gen).'"' : 0) . ',';
$sql .= " nb_gen_done = ". (!empty($this->nb_gen_done) ? $this->nb_gen_done : 0) . ',';
$sql .= " nb_gen_max = ". (!empty($this->nb_gen_max) ? $this->nb_gen_max : 0) . ',';
$sql .= " auto_validate = ". (!empty($this->auto_validate) ? $this->auto_validate : 0);
$sql .= " suspended = ". (!empty($this->suspended) ? ((int) $this->suspended) : 0) . ',';
$sql .= " libelle = ". (!empty($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : 'NULL') . ",";
$sql .= " amount = ". (!empty($this->amount) ? ((float) $this->amount) : 0.00) . ',';
$sql .= " remise = ". (!empty($this->remise) ? ((float) $this->remise) : 'NULL') . ',';
$sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? "'".$this->db->escape($this->vat_src_code)."'" : 'NULL') . ',';
$sql .= " localtax1 = ". (!empty($this->localtax1) ? ((float) $this->localtax1) : 0.00) . ',';
$sql .= " localtax2 = ". (!empty($this->localtax2) ? ((float) $this->localtax2) : 0.00) . ',';
$sql .= " total_ht = ". (!empty($this->total_ht) ? ((float) $this->total_ht) : 0.00) . ',';
$sql .= " total_tva = ". (!empty($this->total_tva) ? ((float) $this->total_tva) : 0.00) . ',';
$sql .= " total_ttc = ". (!empty($this->total_ttc) ? ((float) $this->total_ttc) : 0.00) . ',';
$sql .= " fk_user_modif = ". ((int) $user->id) . ',';
$sql .= " fk_projet = ". (!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL') . ',';
$sql .= " fk_account = ". (!empty($this->fk_account) ? ((int) $this->fk_account) : 'NULL') . ',';
$sql .= " fk_mode_reglement = ". (!empty($this->mode_reglement_id) ? ((int) $this->mode_reglement_id) : 'NULL') . ',';
$sql .= " fk_cond_reglement = ". (!empty($this->cond_reglement_id) ? ((int) $this->cond_reglement_id) : 'NULL') . ',';
$sql .= " date_lim_reglement = ". (!empty($this->date_lim_reglement) ? "'".$this->db->idate($this->date_lim_reglement)."'" : 'NULL') . ',';
$sql .= " note_private = '". (!empty($this->note_private) ? $this->db->escape($this->note_private) : '') . "',";
$sql .= " note_public = '". (!empty($this->note_public) ? $this->db->escape($this->note_public) : '') . "',";
$sql .= " modelpdf = ". (!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : 'NULL') . ",";
$sql .= " fk_multicurrency = ". (!empty($this->fk_multicurrency) ? ((int) $this->fk_multicurrency) : 'NULL') . ',';
$sql .= " multicurrency_code = ". (!empty($this->multicurrency_code) ? "'".$this->db->escape($this->multicurrency_code)."'" : 'NULL') . ",";
$sql .= " multicurrency_tx = ". (!empty($this->multicurrency_tx) ? ((float) $this->multicurrency_tx) : 1) . ',';
$sql .= " multicurrency_total_ht = ". (!empty($this->multicurrency_total_ht) ? ((float) $this->multicurrency_total_ht) : 0.00) . ',';
$sql .= " multicurrency_total_tva = ". (!empty($this->multicurrency_total_tva) ? ((float) $this->multicurrency_total_tva) : 0.00) . ',';
$sql .= " multicurrency_total_ttc = ". (!empty($this->multicurrency_total_ttc) ? ((float) $this->multicurrency_total_ttc) : 0.00) . ',';
$sql .= " usenewprice = ". (!empty($this->usenewprice) ? ((int) $this->usenewprice) : 0) . ',';
$sql .= " frequency = ". (!empty($this->frequency) ? ((int) $this->frequency) : 0). ',';
$sql .= " unit_frequency = '". (!empty($this->unit_frequency) ? $this->db->escape($this->unit_frequency) : ''). "',";
$sql .= " date_when = ". (!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL') . ',';
$sql .= " date_last_gen = ". (!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL') . ',';
$sql .= " nb_gen_done = ". (!empty($this->nb_gen_done) ? ((int) $this->nb_gen_done) : 0) . ',';
$sql .= " nb_gen_max = ". (!empty($this->nb_gen_max) ? ((int) $this->nb_gen_max) : 0) . ',';
$sql .= " auto_validate = ". (!empty($this->auto_validate) ? ((int) $this->auto_validate) : 0);
$sql .= " WHERE rowid = ". (int) $this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -1139,28 +1132,28 @@ class FactureFournisseurRec extends CommonInvoice
$sql .= ", ref = '" . $this->db->escape($ref) . "'";
$sql .= ", label = '" . $this->db->escape($label) . "'";
$sql .= ", description = '" . $this->db->escape($desc) . "'";
$sql .= ', pu_ht=' . price2num($pu_ht);
$sql .= ', qty=' . price2num($qty);
$sql .= ", remise_percent='" . price2num($remise_percent) . "'";
$sql .= ", vat_src_code='" . $this->db->escape($vat_src_code) . "'";
$sql .= ', tva_tx=' . price2num($txtva);
$sql .= ', localtax1_tx=' . (float) $txlocaltax1;
$sql .= ", localtax1_type='" . $this->db->escape($localtaxes_type[0]) . "'";
$sql .= ', localtax2_tx=' . (float) $txlocaltax2;
$sql .= ", localtax2_type='" . $this->db->escape($localtaxes_type[2]) . "'";
$sql .= ", total_ht='" . price2num($total_ht) . "'";
$sql .= ", total_tva='" . price2num($total_tva) . "'";
$sql .= ", total_localtax1='" . price2num($total_localtax1) . "'";
$sql .= ", total_localtax2='" . price2num($total_localtax2) . "'";
$sql .= ", total_ttc='" . price2num($total_ttc) . "'";
$sql .= ', product_type=' . (int) $product_type;
$sql .= ', date_start=' . (empty($date_start) ? 'NULL' : (int) $date_start);
$sql .= ', date_end=' . (empty($date_end) ? 'NULL' : (int) $date_end);
$sql .= ', info_bits=' . (int) $info_bits;
$sql .= ', special_code=' . (int) $special_code;
$sql .= ', rang=' . (int) $rang;
$sql .= ', fk_unit=' . ($fk_unit ? "'" . $this->db->escape($fk_unit) . "'" : 'null');
$sql .= ', fk_user_modif=' . (int) $user;
$sql .= ', pu_ht = ' . price2num($pu_ht);
$sql .= ', qty = ' . price2num($qty);
$sql .= ", remise_percent = '" . price2num($remise_percent) . "'";
$sql .= ", vat_src_code = '" . $this->db->escape($vat_src_code) . "'";
$sql .= ', tva_tx = ' . price2num($txtva);
$sql .= ', localtax1_tx = ' . (float) $txlocaltax1;
$sql .= ", localtax1_type = '" . $this->db->escape($localtaxes_type[0]) . "'";
$sql .= ', localtax2_tx = ' . (float) $txlocaltax2;
$sql .= ", localtax2_type = '" . $this->db->escape($localtaxes_type[2]) . "'";
$sql .= ", total_ht = '" . price2num($total_ht) . "'";
$sql .= ", total_tva = '" . price2num($total_tva) . "'";
$sql .= ", total_localtax1 = '" . price2num($total_localtax1) . "'";
$sql .= ", total_localtax2 = '" . price2num($total_localtax2) . "'";
$sql .= ", total_ttc = '" . price2num($total_ttc) . "'";
$sql .= ', product_type = ' . (int) $product_type;
$sql .= ', date_start = ' . (empty($date_start) ? 'NULL' : (int) $date_start);
$sql .= ', date_end = ' . (empty($date_end) ? 'NULL' : (int) $date_end);
$sql .= ', info_bits = ' . (int) $info_bits;
$sql .= ', special_code = ' . (int) $special_code;
$sql .= ', rang = ' . (int) $rang;
$sql .= ', fk_unit = ' . ($fk_unit ? "'" . $this->db->escape($fk_unit) . "'" : 'null');
$sql .= ', fk_user_modif = ' . (int) $user;
$sql .= ', multicurrency_subprice = '.price2num($pu_ht_devise);
$sql .= ', multicurrency_total_ht = '.price2num($multicurrency_total_ht);
$sql .= ', multicurrency_total_tva = '.price2num($multicurrency_total_tva);
@ -1766,14 +1759,15 @@ class FactureFournisseurRec extends CommonInvoice
return -2;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null');
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET frequency = ".($frequency ? ((int) $this->db->escape($frequency)) : "NULL");
if (!empty($unit)) {
$sql .= ', unit_frequency = '.$this->db->escape($unit);
$sql .= ", unit_frequency = '".$this->db->escape($unit)."'";
}
$sql .= ' WHERE rowid = ' . (int) $this->id;
$sql .= " WHERE rowid = ".((int) $this->id);
dol_syslog(get_class($this).'::setFrequencyAndUnit', LOG_DEBUG);
dol_syslog(get_class($this). '::setFrequencyAndUnit', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->frequency = $frequency;
if (!empty($unit)) {
@ -1781,7 +1775,7 @@ class FactureFournisseurRec extends CommonInvoice
}
return 1;
} else {
dol_print_error($this->db);
$this->error = $this->db->lasterror();
return -1;
}
}
@ -1796,17 +1790,18 @@ class FactureFournisseurRec extends CommonInvoice
public function setNextDate($date, $increment_nb_gen_done = 0)
{
if (!$this->table_element) {
dol_syslog(get_class($this). '::setNextDate was called on objet with property table_element not defined', LOG_ERR);
dol_syslog(get_class($this).'::setNextDate was called on objet with property table_element not defined', LOG_ERR);
return -1;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET date_when = ' .($date ? "'".$this->db->idate($date)."'" : 'null');
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET date_when = " .($date ? "'".$this->db->idate($date)."'" : "NULL");
if ($increment_nb_gen_done > 0) {
$sql .= ', nb_gen_done = nb_gen_done + 1';
$sql .= ", nb_gen_done = nb_gen_done + 1";
}
$sql .= ' WHERE rowid = ' . (int) $this->id;
$sql .= " WHERE rowid = " . (int) $this->id;
dol_syslog(get_class($this).'::setNextDate', LOG_DEBUG);
dol_syslog(get_class($this). '::setNextDate', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->date_when = $date;
if ($increment_nb_gen_done > 0) {
@ -1814,7 +1809,7 @@ class FactureFournisseurRec extends CommonInvoice
}
return 1;
} else {
dol_print_error($this->db);
$this->error = $this->db->lasterror();
return -1;
}
}
@ -1828,7 +1823,7 @@ class FactureFournisseurRec extends CommonInvoice
public function setMaxPeriod($nb)
{
if (!$this->table_element) {
dol_syslog(get_class($this). '::setMaxPeriod was called on objet with property table_element not defined', LOG_ERR);
dol_syslog(get_class($this).'::setMaxPeriod was called on objet with property table_element not defined', LOG_ERR);
return -1;
}
@ -1836,11 +1831,12 @@ class FactureFournisseurRec extends CommonInvoice
$nb = 0;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET nb_gen_max = '. (int) $nb;
$sql .= ' WHERE rowid = ' . (int) $this->id;
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET nb_gen_max = ". (int) $nb;
$sql .= " WHERE rowid = " . (int) $this->id;
dol_syslog(get_class($this).'::setMaxPeriod', LOG_DEBUG);
dol_syslog(get_class($this). '::setMaxPeriod', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->nb_gen_max = $nb;
return 1;
@ -1859,15 +1855,16 @@ class FactureFournisseurRec extends CommonInvoice
public function setAutoValidate($validate)
{
if (!$this->table_element) {
dol_syslog(get_class($this). '::setAutoValidate was called on objet with property table_element not defined', LOG_ERR);
dol_syslog(get_class($this).'::setAutoValidate was called on objet with property table_element not defined', LOG_ERR);
return -1;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET auto_validate = '.((int) $validate);
$sql .= ' WHERE rowid = ' . (int) $this->id;
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET auto_validate = ".((int) $validate);
$sql .= " WHERE rowid = " . (int) $this->id;
dol_syslog(get_class($this).'::setAutoValidate', LOG_DEBUG);
dol_syslog(get_class($this). '::setAutoValidate', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->auto_validate = $validate;
return 1;
@ -1886,15 +1883,16 @@ class FactureFournisseurRec extends CommonInvoice
public function setGeneratePdf($validate)
{
if (!$this->table_element) {
dol_syslog(get_class($this). '::setGeneratePdf was called on objet with property table_element not defined', LOG_ERR);
dol_syslog(get_class($this).'::setGeneratePdf was called on objet with property table_element not defined', LOG_ERR);
return -1;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET generate_pdf = '. (int) $validate;
$sql .= ' WHERE rowid = ' . (int) $this->id;
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET generate_pdf = ". (int) $validate;
$sql .= " WHERE rowid = " . (int) $this->id;
dol_syslog(get_class($this).'::setGeneratePdf', LOG_DEBUG);
dol_syslog(get_class($this). '::setGeneratePdf', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->generate_pdf = $validate;
return 1;
@ -1913,15 +1911,16 @@ class FactureFournisseurRec extends CommonInvoice
public function setModelPdf($model)
{
if (!$this->table_element) {
dol_syslog(get_class($this). '::setModelPdf was called on objet with property table_element not defined', LOG_ERR);
dol_syslog(get_class($this).'::setModelPdf was called on objet with property table_element not defined', LOG_ERR);
return -1;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET modelpdf = '".$this->db->escape($model)."'";
$sql .= ' WHERE rowid = ' . (int) $this->id;
$sql .= " WHERE rowid = " . (int) $this->id;
dol_syslog(get_class($this).'::setModelPdf', LOG_DEBUG);
dol_syslog(get_class($this). '::setModelPdf', LOG_DEBUG);
if ($this->db->query($sql)) {
$this->model_pdf = $model;
return 1;
@ -2144,8 +2143,8 @@ class FactureFournisseurLigneRec extends CommonObjectLine
$sql .= ' fk_facture_fourn = ' . (int) $this->fk_facture_fourn;
$sql .= ', fk_parent_line = ' . (int) $this->fk_parent;
$sql .= ', fk_product = ' . (int) $this->fk_product;
$sql .= ', ref = ' . (! empty($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : 'null');
$sql .= ", label = " . (! empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : 'null');
$sql .= ', ref = ' . (! empty($this->ref) ? "'" . $this->db->escape($this->ref) . "'" : 'NULL');
$sql .= ", label = " . (! empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : 'NULL');
$sql .= ", description = '" . $this->db->escape($this->description) . "'";
$sql .= ', pu_ht = ' . price2num($this->pu_ht);
$sql .= ', pu_ttc = ' . price2num($this->pu_ttc);
@ -2153,27 +2152,26 @@ class FactureFournisseurLigneRec extends CommonObjectLine
$sql .= ", remise_percent = '" . price2num($this->remise_percent) . "'";
$sql .= ', fk_remise_except = ' . (int) $this->fk_remise_except;
$sql .= ", vat_src_code = '" . $this->db->escape($this->vat_src_code) . "'";
$sql .= ', tva_tx =' . price2num($this->tva_tx);
$sql .= ', tva_tx = ' . price2num($this->tva_tx);
$sql .= ', localtax1_tx = ' . price2num($this->localtax1_tx);
$sql .= ", localtax1_type = '" . $this->db->escape($this->localtax1_type) . "'";
$sql .= ', localtax2_tx = ' . price2num($this->localtax2_tx);
$sql .= ", localtax2_type = '" . $this->db->escape($this->localtax2_type) . "'";
if (empty($this->skip_update_total)) {
$sql .= ', total_ht =' . price2num($this->total_ht);
$sql .= ', total_tva =' . price2num($this->total_tva);
$sql .= ', total_localtax1 =' . price2num($this->total_localtax1);
$sql .= ', total_localtax2 =' . price2num($this->total_localtax2);
$sql .= ', total_ttc =' . price2num($this->total_ttc);
$sql .= ', total_ht = ' . price2num($this->total_ht);
$sql .= ', total_tva = ' . price2num($this->total_tva);
$sql .= ', total_localtax1 = ' . price2num($this->total_localtax1);
$sql .= ', total_localtax2 = ' . price2num($this->total_localtax2);
$sql .= ', total_ttc = ' . price2num($this->total_ttc);
}
$sql .= ', product_type =' . (int) $this->product_type;
$sql .= ', date_start =' . (int) $this->date_start;
$sql .= ', date_end =' . (int) $this->date_end;
$sql .= ", info_bits ='" . price2num($this->info_bits) . "'";
$sql .= ', product_type = ' . (int) $this->product_type;
$sql .= ', date_start = ' . (int) $this->date_start;
$sql .= ', date_end = ' . (int) $this->date_end;
$sql .= ", info_bits = " . ((int) $this->info_bits);
$sql .= ', special_code =' . (int) $this->special_code;
$sql .= ', rang =' . (int) $this->rang;
$sql .= ', fk_unit =' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null');
$sql .= ', fk_user_modif =' . (int) $user;
$sql .= ', rang = ' . (int) $this->rang;
$sql .= ', fk_unit = ' .($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : 'null');
$sql .= ', fk_user_modif = ' . (int) $user;
$sql .= ' WHERE rowid = ' . (int) $this->id;
$this->db->begin();

View File

@ -373,10 +373,8 @@ if (empty($reshook)) {
$objecttmp->mode_reglement_id = $cmd->mode_reglement_id;
$objecttmp->fk_project = $cmd->fk_project;
$objecttmp->multicurrency_code = $cmd->multicurrency_code;
if (empty($createbills_onebythird)) {
$objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
$default_ref_supplier+=1;
}
$objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier;
$default_ref_supplier+=1;
$datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($datefacture)) {

View File

@ -99,6 +99,8 @@ ALTER TABLE llx_partnership ADD UNIQUE INDEX uk_fk_type_fk_member (fk_type, fk_m
-- v16
ALTER TABLE llx_facture ADD INDEX idx_facture_datef (datef);
ALTER TABLE llx_projet_task_time ADD COLUMN fk_product integer NULL;
INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_MODIFY','Customer proposal modified','Executed when a customer proposal is modified','propal',2);
@ -117,6 +119,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 +285,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

@ -29,6 +29,7 @@ ALTER TABLE llx_facture ADD INDEX idx_facture_fk_projet (fk_projet);
ALTER TABLE llx_facture ADD INDEX idx_facture_fk_account (fk_account);
ALTER TABLE llx_facture ADD INDEX idx_facture_fk_currency (fk_currency);
ALTER TABLE llx_facture ADD INDEX idx_facture_fk_statut (fk_statut);
ALTER TABLE llx_facture ADD INDEX idx_facture_datef (datef);
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
ALTER TABLE llx_facture ADD CONSTRAINT fk_facture_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);

View File

@ -26,7 +26,7 @@ create table llx_facture
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NOT NULL, -- invoice reference number
ref varchar(30) NOT NULL, -- invoice reference number
entity integer DEFAULT 1 NOT NULL, -- multi company id
ref_ext varchar(255), -- reference into an external system (not used by dolibarr)

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

@ -601,7 +601,6 @@ BILL_SUPPLIER_DELETEInDolibarr=Supplier invoice deleted
UnitPriceXQtyLessDiscount=Unit price x Qty - Discount
CustomersInvoicesArea=Customer billing area
SupplierInvoicesArea=Supplier billing area
FacParentLine=Invoice Line Parent
SituationTotalRayToRest=Remainder to pay without taxe
PDFSituationTitle=Situation n° %d
SituationTotalProgress=Total progress %d %%

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

@ -244,6 +244,7 @@ Designation=Description
DescriptionOfLine=Description of line
DateOfLine=Date of line
DurationOfLine=Duration of line
ParentLine=Parent line ID
Model=Doc template
DefaultModel=Default doc template
Action=Event

View File

@ -101,7 +101,6 @@ ConfirmMassValidationQuestion=Are you sure you want to validate the selected rec
ConfirmMassSignatureQuestion=Are you sure you want to sign the selected records ?
IdProposal=Proposal ID
IdProduct=Product ID
PrParentLine=Proposal Parent Line
LineBuyPriceHT=Buy Price Amount net of tax for line
SignPropal=Accept proposal
RefusePropal=Refuse proposal

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

@ -122,7 +122,7 @@ class MyObject extends CommonObject
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'notnull'=>0, 'position'=>600),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled'), 'validate'=>1),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>2000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled'), 'validate'=>1),
);
/**

View File

@ -382,20 +382,35 @@ class modMyModule extends DolibarrModules
$r = 1;
/* BEGIN MODULEBUILDER IMPORT MYOBJECT */
/*
$langs->load("mymodule@mymodule");
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='myobject@mymodule';
$keyforclass = 'MyObject'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobject@mymodule';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
$this->export_sql_end[$r] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
$r++; */
$langs->load("mymodule@mymodule");
$this->import_code[$r]=$this->rights_class.'_'.$r;
$this->import_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->import_icon[$r]='myobject@mymodule';
$this->import_tables_array[$r] = array('t' => MAIN_DB_PREFIX.'mymodule_myobject', 'extra' => MAIN_DB_PREFIX.'mymodule_myobject_extrafields');
$this->import_tables_creator_array[$r] = array('t' => 'fk_user_author'); // Fields to store import user id
$import_sample = array();
$keyforclass = 'MyObject'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobject@mymodule';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinimport.inc.php';
$import_extrafield_sample = array();
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinimport.inc.php';
$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'mymodule_myobject');
$this->import_regex_array[$r] = array();
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = array('t.ref' => 'Ref');
$this->import_convertvalue_array[$r] = array(
't.ref' => array(
'rule'=>'getrefifauto',
'class'=>(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON),
'path'=>"/core/modules/commande/".(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON).'.php'
'classobject'=>'MyObject',
'pathobject'=>'/mymodule/class/myobject.class.php',
),
't.fk_soc' => array('rule' => 'fetchidfromref', 'file' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty'),
't.fk_user_valid' => array('rule' => 'fetchidfromref', 'file' => '/user/class/user.class.php', 'class' => 'User', 'method' => 'fetch', 'element' => 'user'),
't.fk_mode_reglement' => array('rule' => 'fetchidfromcodeorlabel', 'file' => '/compta/paiement/class/cpaiement.class.php', 'class' => 'Cpaiement', 'method' => 'fetch', 'element' => 'cpayment'),
);
$r++; */
/* END MODULEBUILDER IMPORT MYOBJECT */
}

View File

@ -56,7 +56,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
} ?>
</td>
<td class="linkedcol-name nowraponall" ><?php echo $objectlink->getNomUrl(1); ?></td>
<td class="linkedcol-ref"></td>
<td class="linkedcol-ref tdoverflowmax100" title="<?php echo dol_escape_htmltag($objectlink->ref_supplier); ?>"><?php echo dol_escape_htmltag($objectlink->ref_supplier); ?></td>
<td class="linkedcol-date"><?php echo dol_print_date($objectlink->date_delivery, 'day'); ?></td>
<td class="linkedcol-amount right"><?php
if ($user->rights->reception->lire) {

View File

@ -119,7 +119,7 @@ $dol_no_mouse_hover = $conf->dol_no_mouse_hover;
$useboldtitle = (isset($conf->global->THEME_ELDY_USEBOLDTITLE) ? $conf->global->THEME_ELDY_USEBOLDTITLE : 0);
$borderwidth = 2;
$userborderontable = 1;
$userborderontable = getDolGlobalInt('THEME_ELDY_USEBORDERONTABLE');
// Case of option always editable
if (!isset($conf->global->THEME_ELDY_BACKBODY)) {
@ -3676,8 +3676,10 @@ div.colorback
margin-top: 5px;
}
.liste_titre_bydiv {
<?php if ($userborderontable) { ?>
border-right: 1px solid #ccc;
border-left: 1px solid #ccc;
<?php } ?>
}
table.liste, table.noborder, table.formdoc, div.noborder {
width: calc(100% - 2px); /* -2 to fix a bug. Without, a scroll appears due to overflow-x: auto; of div-table-responsive */
@ -3690,12 +3692,15 @@ table.liste, table.noborder, table.formdoc, div.noborder {
border-top-style: solid;
border-bottom-width: 1px;
border-bottom-color: #BBB;
border-bottom-color: #BBB;
border-bottom-style: solid;
<?php
if ($userborderontable) { ?>
border-right: 1px solid #ccc;
border-left: 1px solid #ccc;
<?php } ?>
margin: 0px 0px 20px 0px;
-webkit-border-radius: 0.1em;
@ -4074,7 +4079,9 @@ tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td {
/*
table.nobottomiftotal tr.liste_total td {
background-color: #fff;
<?php if (!$userborderontable) { ?>
border-bottom: 0px !important;
<?php } ?>
}
*/
div.liste_titre .tagtd {
@ -4099,10 +4106,11 @@ div.liste_titre {
border-top-style: solid;
}
div.liste_titre_bydiv {
<?php if ($userborderontable) { ?>
border-top-width: <?php echo $borderwidth ?>px;
border-top-color: var(--colortopbordertitle1);
border-top-style: solid;
<?php } ?>
border-collapse: collapse;
display: table;
padding: 2px 0px 2px 0;

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");

View File

@ -227,6 +227,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
if (! in_array($file['name'], array(
'objectline_view.tpl.php',
'extrafieldsinexport.inc.php',
'extrafieldsinimport.inc.php',
'DolQueryCollector.php'
))) {
// Must not found $this->db->

View File

@ -401,10 +401,14 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
$langs=$this->savlangs;
$db=$this->savdb;
// Format zip
print "\n";
print 'testDolCompressUnCompress zip'."\n";
$format='zip';
$filein=dirname(__FILE__).'/Example_import_company_1.csv';
$fileout=$conf->admin->dir_temp.'/test.'.$format;
$dirout=$conf->admin->dir_temp.'/test';
$dirout=$conf->admin->dir_temp.'/testdir'.$format;
dol_delete_file($fileout);
$count=0;
@ -417,18 +421,50 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
$conf->logbuffer=array();
$result=dol_compress_file($filein, $fileout, $format, $errorstring);
print __METHOD__." result=".$result."\n";
print __METHOD__." compress result=".$result."\n";
print join(', ', $conf->logbuffer);
$this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_file on ".$filein." into ".$fileout." : ".$errorstring);
$result=dol_uncompress($fileout, $dirout);
print __METHOD__." result=".join(',', $result)."\n";
print __METHOD__." uncompress result=".join(',', $result)."\n";
$this->assertEquals(0, count($result), "Pb with dol_uncompress_file of file ".$fileout);
// Format gz
print "\n";
print 'testDolCompressUnCompress gz'."\n";
$format='gz';
$filein=dirname(__FILE__).'/Example_import_company_1.csv';
$fileout=$conf->admin->dir_temp.'/test.'.$format;
$dirout=$conf->admin->dir_temp.'/testdir'.$format;
dol_delete_file($fileout);
$count=0;
dol_delete_dir_recursive($dirout, $count, 1);
$errorstring = '';
dol_mkdir($conf->admin->dir_temp);
$conf->global->MAIN_ENABLE_LOG_TO_HTML=1; $conf->syslog->enabled=1; $_REQUEST['logtohtml']=1;
$conf->logbuffer=array();
$result=dol_compress_file($filein, $fileout, $format, $errorstring);
print __METHOD__." compress result=".$result."\n";
print join(', ', $conf->logbuffer);
$this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_file on ".$filein." into ".$fileout." : ".$errorstring);
$result=dol_uncompress($fileout, $dirout);
print __METHOD__." uncompress result=".join(',', $result)."\n";
print join(', ', $conf->logbuffer);
$this->assertEquals(0, count($result), "Pb with dol_uncompress_file of file ".$fileout);
// Test compression of a directory
// $dirout is $conf->admin->dir_temp.'/testdirgz'
$excludefiles = '/(\.back|\.old|\.log|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i';
if (preg_match($excludefiles, 'a/temp/b')) { echo '----- Regex OK -----'."\n"; }
$result=dol_compress_dir($dirout, $conf->admin->dir_temp.'/testdir.zip', 'zip', $excludefiles);
print __METHOD__." result=".$result."\n";
$result=dol_compress_dir($dirout, $conf->admin->dir_temp.'/testcompressdirzip.zip', 'zip', $excludefiles);
print __METHOD__." dol_compress_dir result=".$result."\n";
print join(', ', $conf->logbuffer);
$this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_dir of ".$dirout." into ".$conf->admin->dir_temp.'/testdir.zip');
}
@ -466,6 +502,10 @@ class FilesLibTest extends PHPUnit\Framework\TestCase
$db=$this->savdb;
if (empty($user->rights->facture)) {
$user->rights->facture = new stdClass();
}
//$dummyuser=new User($db);
//$result=restrictedArea($dummyuser,'societe');