From 2fdc6d9461bbc8b6943ac8e6ecad5e65ba86cda5 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 4 Jun 2021 11:35:12 +0200 Subject: [PATCH 001/113] NEW : rewrite bind accountancy code finding on customer invoice --- htdocs/accountancy/admin/account.php | 2 +- .../class/accountingaccount.class.php | 556 ++++++++++++------ htdocs/accountancy/customer/list.php | 189 ++---- 3 files changed, 420 insertions(+), 327 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 6f510ad3706..1f7f8892cad 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -195,7 +195,7 @@ if (empty($reshook)) { } elseif ($action == 'enable' && $permissiontoadd) { if ($accounting->fetch($id)) { $mode = GETPOST('mode', 'int'); - $result = $accounting->account_activate($id, $mode); + $result = $accounting->accountActivate($id, $mode); } $action = 'update'; if ($result < 0) { diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 28601380ac1..c4a11fb6565 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -26,6 +26,9 @@ * \brief File of class to manage accounting accounts */ +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; /** * Class to manage accounting accounts */ @@ -140,6 +143,11 @@ class AccountingAccount extends CommonObject */ public $reconcilable; + /** + * @var array cache array + */ + private $accountingaccount_codetotid_cache = array(); + /** * Constructor * @@ -150,83 +158,14 @@ class AccountingAccount extends CommonObject global $conf; $this->db = $db; - $this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; // Used to add a filter in Form::showrefnav method - } - - /** - * Load record in memory - * - * @param int $rowid Id - * @param string $account_number Account number - * @param int|boolean $limittocurrentchart 1 or true=Load record only if it is into current active char of account - * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code). - * @return int <0 if KO, 0 if not found, Id of record if OK and found - */ - public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') - { - global $conf; - - if ($rowid || $account_number) { - $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconcilable"; - $sql .= ", ca.label as category_label"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as a"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid"; - $sql .= " WHERE"; - if ($rowid) { - $sql .= " a.rowid = ".(int) $rowid; - } elseif ($account_number) { - $sql .= " a.account_number = '".$this->db->escape($account_number)."'"; - $sql .= " AND a.entity = ".$conf->entity; - } - if (!empty($limittocurrentchart)) { - $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$this->db->escape($conf->global->CHARTOFACCOUNTS).')'; - } - if (!empty($limittoachartaccount)) { - $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; - } - - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); - - if ($obj) { - $this->id = $obj->rowid; - $this->rowid = $obj->rowid; - $this->ref = $obj->account_number; - $this->datec = $obj->datec; - $this->tms = $obj->tms; - $this->fk_pcg_version = $obj->fk_pcg_version; - $this->pcg_type = $obj->pcg_type; - $this->account_number = $obj->account_number; - $this->account_parent = $obj->account_parent; - $this->label = $obj->label; - $this->labelshort = $obj->labelshort; - $this->account_category = $obj->fk_accounting_category; - $this->account_category_label = $obj->category_label; - $this->fk_user_author = $obj->fk_user_author; - $this->fk_user_modif = $obj->fk_user_modif; - $this->active = $obj->active; - $this->status = $obj->active; - $this->reconcilable = $obj->reconcilable; - - return $this->id; - } else { - return 0; - } - } else { - $this->error = "Error ".$this->db->lasterror(); - $this->errors[] = "Error ".$this->db->lasterror(); - } - } - return -1; + $this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; // Used to add a filter in Form::showrefnav method } /** * Insert new accounting account in chart of accounts * - * @param User $user User making action - * @param int $notrigger Disable triggers + * @param User $user User making action + * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ public function create($user, $notrigger = 0) @@ -259,7 +198,7 @@ class AccountingAccount extends CommonObject // Put here code to add control on parameters values // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_account("; + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_account("; $sql .= "datec"; $sql .= ", entity"; $sql .= ", fk_pcg_version"; @@ -273,31 +212,31 @@ class AccountingAccount extends CommonObject $sql .= ", active"; $sql .= ", reconcilable"; $sql .= ") VALUES ("; - $sql .= " '".$this->db->idate($now)."'"; - $sql .= ", ".$conf->entity; - $sql .= ", ".(empty($this->fk_pcg_version) ? 'NULL' : "'".$this->db->escape($this->fk_pcg_version)."'"); - $sql .= ", ".(empty($this->pcg_type) ? 'NULL' : "'".$this->db->escape($this->pcg_type)."'"); - $sql .= ", ".(empty($this->account_number) ? 'NULL' : "'".$this->db->escape($this->account_number)."'"); - $sql .= ", ".(empty($this->account_parent) ? 0 : (int) $this->account_parent); - $sql .= ", ".(empty($this->label) ? "''" : "'".$this->db->escape($this->label)."'"); - $sql .= ", ".(empty($this->labelshort) ? "''" : "'".$this->db->escape($this->labelshort)."'"); - $sql .= ", ".(empty($this->account_category) ? 0 : (int) $this->account_category); - $sql .= ", ".$user->id; - $sql .= ", ".(int) $this->active; - $sql .= ", ".(int) $this->reconcilable; + $sql .= " '" . $this->db->idate($now) . "'"; + $sql .= ", " . $conf->entity; + $sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'"); + $sql .= ", " . (empty($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'"); + $sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->db->escape($this->account_number) . "'"); + $sql .= ", " . (empty($this->account_parent) ? 0 : (int) $this->account_parent); + $sql .= ", " . (empty($this->label) ? "''" : "'" . $this->db->escape($this->label) . "'"); + $sql .= ", " . (empty($this->labelshort) ? "''" : "'" . $this->db->escape($this->labelshort) . "'"); + $sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category); + $sql .= ", " . $user->id; + $sql .= ", " . (int) $this->active; + $sql .= ", " . (int) $this->reconcilable; $sql .= ")"; $this->db->begin(); - dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; - $this->errors[] = "Error ".$this->db->lasterror(); + $this->errors[] = "Error " . $this->db->lasterror(); } if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_account"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_account"); // Uncomment this and change MYOBJECT to your own tag if you // want this action to call a trigger. @@ -313,8 +252,8 @@ class AccountingAccount extends CommonObject // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -327,7 +266,7 @@ class AccountingAccount extends CommonObject /** * Update record * - * @param User $user Use making update + * @param User $user Use making update * @return int <0 if KO, >0 if OK */ public function update($user) @@ -339,20 +278,20 @@ class AccountingAccount extends CommonObject $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account "; - $sql .= " SET fk_pcg_version = ".($this->fk_pcg_version ? "'".$this->db->escape($this->fk_pcg_version)."'" : "null"); - $sql .= " , pcg_type = ".($this->pcg_type ? "'".$this->db->escape($this->pcg_type)."'" : "null"); - $sql .= " , account_number = '".$this->db->escape($this->account_number)."'"; - $sql .= " , account_parent = ".(int) $this->account_parent; - $sql .= " , label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "''"); - $sql .= " , labelshort = ".($this->labelshort ? "'".$this->db->escape($this->labelshort)."'" : "''"); - $sql .= " , fk_accounting_category = ".(empty($this->account_category) ? 0 : (int) $this->account_category); - $sql .= " , fk_user_modif = ".((int) $user->id); - $sql .= " , active = ".(int) $this->active; - $sql .= " , reconcilable = ".(int) $this->reconcilable; - $sql .= " WHERE rowid = ".((int) $this->id); + $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; + $sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null"); + $sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null"); + $sql .= " , account_number = '" . $this->db->escape($this->account_number) . "'"; + $sql .= " , account_parent = " . (int) $this->account_parent; + $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "''"); + $sql .= " , labelshort = " . ($this->labelshort ? "'" . $this->db->escape($this->labelshort) . "'" : "''"); + $sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category); + $sql .= " , fk_user_modif = " . ((int) $user->id); + $sql .= " , active = " . (int) $this->active; + $sql .= " , reconcilable = " . (int) $this->reconcilable; + $sql .= " WHERE rowid = " . ((int) $this->id); - dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $this->db->commit(); @@ -364,38 +303,6 @@ class AccountingAccount extends CommonObject } } - /** - * Check usage of accounting code - * - * @return int <0 if KO, >0 if OK - */ - public function checkUsage() - { - global $langs; - - $sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet"; - $sql .= " WHERE fk_code_ventilation=".$this->id.")"; - $sql .= "UNION"; - $sql .= " (SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facture_fourn_det"; - $sql .= " WHERE fk_code_ventilation=".$this->id.")"; - - dol_syslog(get_class($this)."::checkUsage sql=".$sql, LOG_DEBUG); - $resql = $this->db->query($sql); - - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num > 0) { - $this->error = $langs->trans('ErrorAccountancyCodeIsAlreadyUse'); - return 0; - } else { - return 1; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - /** * Delete object in database * @@ -413,22 +320,22 @@ class AccountingAccount extends CommonObject $this->db->begin(); if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."accounting_account"; - $sql .= " WHERE rowid=".((int) $this->id); + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_account"; + $sql .= " WHERE rowid=" . ((int) $this->id); - dol_syslog(get_class($this)."::delete sql=".$sql); + dol_syslog(get_class($this) . "::delete sql=" . $sql); $resql = $this->db->query($sql); if (!$resql) { $error++; - $this->errors[] = "Error ".$this->db->lasterror(); + $this->errors[] = "Error " . $this->db->lasterror(); } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); + $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); } $this->db->rollback(); return -1 * $error; @@ -441,23 +348,55 @@ class AccountingAccount extends CommonObject } } + /** + * Check usage of accounting code + * + * @return int <0 if KO, >0 if OK + */ + public function checkUsage() + { + global $langs; + + $sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet"; + $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; + $sql .= "UNION"; + $sql .= " (SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det"; + $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; + + dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG); + $resql = $this->db->query($sql); + + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num > 0) { + $this->error = $langs->trans('ErrorAccountancyCodeIsAlreadyUse'); + return 0; + } else { + return 1; + } + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + /** * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $withlabel 0=No label, 1=Include label of account - * @param int $nourl 1=Disable url - * @param string $moretitle Add more text to title tooltip - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) - * @param string $option 'ledger', 'journals', 'accountcard' - * @return string String with URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $withlabel 0=No label, 1=Include label of account + * @param int $nourl 1=Disable url + * @param string $moretitle Add more text to title tooltip + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) + * @param string $option 'ledger', 'journals', 'accountcard' + * @return string String with URL */ public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') { global $langs, $conf; - require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; if (!empty($conf->dol_no_mouse_hover)) { $notooltip = 1; // Force disable tooltips @@ -465,15 +404,16 @@ class AccountingAccount extends CommonObject $result = ''; - $url = ''; $labelurl = ''; + $url = ''; + $labelurl = ''; if (empty($option) || $option == 'ledger') { - $url = DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start='.urlencode($this->account_number).'&search_accountancy_code_end='.urlencode($this->account_number); + $url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . urlencode($this->account_number) . '&search_accountancy_code_end=' . urlencode($this->account_number); $labelurl = $langs->trans("ShowAccountingAccountInLedger"); } elseif ($option == 'journals') { - $url = DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?search_accountancy_code_start='.urlencode($this->account_number).'&search_accountancy_code_end='.urlencode($this->account_number); + $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . urlencode($this->account_number) . '&search_accountancy_code_end=' . urlencode($this->account_number); $labelurl = $langs->trans("ShowAccountingAccountInJournals"); } elseif ($option == 'accountcard') { - $url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.urlencode($this->id); + $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . urlencode($this->id); $labelurl = $langs->trans("ShowAccountingAccount"); } @@ -495,29 +435,29 @@ class AccountingAccount extends CommonObject $labeltoshow = $this->labelshort; } - $label = ''.$labelurl.''; + $label = '' . $labelurl . ''; if (!empty($this->account_number)) { - $label .= '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); + $label .= '
' . $langs->trans('AccountAccounting') . ': ' . length_accountg($this->account_number); } if (!empty($labeltoshow)) { - $label .= '
'.$langs->trans('Label').': '.$labeltoshow; + $label .= '
' . $langs->trans('Label') . ': ' . $labeltoshow; } if ($moretitle) { - $label .= ' - '.$moretitle; + $label .= ' - ' . $moretitle; } $linkclose = ''; if (empty($notooltip)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $labelurl; - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"'; $linkclose .= ' class="classfortooltip"'; } - $linkstart = ''; + $linkstart = ''; $linkend = ''; if ($nourl) { @@ -528,17 +468,17 @@ class AccountingAccount extends CommonObject $label_link = length_accountg($this->account_number); if ($withlabel) { - $label_link .= ' - '.($nourl ? '' : '').$labeltoshow.($nourl ? '' : ''); + $label_link .= ' - ' . ($nourl ? '' : '') . $labeltoshow . ($nourl ? '' : ''); } if ($withpicto) { - $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend); + $result .= ($linkstart . img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1) . $linkend); } if ($withpicto && $withpicto != 2) { $result .= ' '; } if ($withpicto != 2) { - $result .= $linkstart.$label_link.$linkend; + $result .= $linkstart . $label_link . $linkend; } return $result; } @@ -552,10 +492,10 @@ class AccountingAccount extends CommonObject public function info($id) { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a'; - $sql .= ' WHERE a.rowid = '.((int) $id); + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a'; + $sql .= ' WHERE a.rowid = ' . ((int) $id); - dol_syslog(get_class($this).'::info sql='.$sql); + dol_syslog(get_class($this) . '::info sql=' . $sql); $result = $this->db->query($sql); if ($result) { @@ -584,8 +524,8 @@ class AccountingAccount extends CommonObject /** * Deactivate an account (for status active or status reconcilable) * - * @param int $id Id - * @param int $mode 0=field active, 1=field reconcilable + * @param int $id Id + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ public function accountDeactivate($id, $mode = 0) @@ -600,11 +540,11 @@ class AccountingAccount extends CommonObject if ($result > 0) { $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account "; - $sql .= "SET ".$fieldtouse." = '0'"; - $sql .= " WHERE rowid = ".$this->db->escape($id); + $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account "; + $sql .= "SET " . $fieldtouse . " = '0'"; + $sql .= " WHERE rowid = " . $this->db->escape($id); - dol_syslog(get_class($this)."::accountDeactivate ".$fieldtouse." sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::accountDeactivate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -620,15 +560,15 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Account activated * - * @param int $id Id - * @param int $mode 0=field active, 1=field reconcilable + * @param int $id Id + * @param int $mode 0=field active, 1=field reconcilable * @return int <0 if KO, >0 if OK */ - public function account_activate($id, $mode = 0) + public function accountActivate($id, $mode = 0) { // phpcs:enable $this->db->begin(); @@ -638,11 +578,11 @@ class AccountingAccount extends CommonObject $fieldtouse = 'reconcilable'; } - $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account"; - $sql .= " SET ".$fieldtouse." = '1'"; - $sql .= " WHERE rowid = ".$this->db->escape($id); + $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account"; + $sql .= " SET " . $fieldtouse . " = '1'"; + $sql .= " WHERE rowid = " . $this->db->escape($id); - dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::accountActivate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $this->db->commit(); @@ -654,12 +594,11 @@ class AccountingAccount extends CommonObject } } - /** * Retourne le libelle du statut d'un user (actif, inactif) * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -670,9 +609,9 @@ class AccountingAccount extends CommonObject /** * Renvoi le libelle d'un statut donne * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { @@ -694,9 +633,9 @@ class AccountingAccount extends CommonObject } } elseif ($mode == 2) { if ($status == 1) { - return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); + return img_picto($langs->trans('Enabled'), 'statut4') . ' ' . $langs->trans('Enabled'); } elseif ($status == 0) { - return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + return img_picto($langs->trans('Disabled'), 'statut5') . ' ' . $langs->trans('Disabled'); } } elseif ($mode == 3) { if ($status == 1) { @@ -706,16 +645,241 @@ class AccountingAccount extends CommonObject } } elseif ($mode == 4) { if ($status == 1) { - return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); + return img_picto($langs->trans('Enabled'), 'statut4') . ' ' . $langs->trans('Enabled'); } elseif ($status == 0) { - return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + return img_picto($langs->trans('Disabled'), 'statut5') . ' ' . $langs->trans('Disabled'); } } elseif ($mode == 5) { if ($status == 1) { - return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); + return $langs->trans('Enabled') . ' ' . img_picto($langs->trans('Enabled'), 'statut4'); } elseif ($status == 0) { - return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + return $langs->trans('Disabled') . ' ' . img_picto($langs->trans('Disabled'), 'statut5'); } } } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + + /** + * Return Suggest accounting accounts to bind + * + * @param Societe $thirdparty Societe Object seller or Buyers + * @param Product $product Product object sell or buy + * @param Facture $facture Facture + * @param FactureLigne $factureDet Facture Det + * @param array $accountingAccount array of Account account + * + * @return array Accounting accounts suggested + */ + public function getAccountingCodeToBind(Societe $thirdparty, Product $product, Facture $facture, FactureLigne $factureDet, $accountingAccount = array()) + { + global $mysoc, $conf; + global $hookmanager; + + // Instantiate hooks for external modules + $hookmanager->initHooks(array('accoutancyBindingCalculation')); + + // Execute hook accoutancyBindingCalculation + $parameters = array('thirdparty' => $thirdparty, 'product' => $product, 'facture' => $facture, 'factureDet' => $factureDet ,'accountingAccount'=>$accountingAccount); + $reshook = $hookmanager->executeHooks('accoutancyBindingCalculation', $parameters); // Note that $action and $object may have been modified by some hooks + + if (empty($reshook)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + $isBuyerInEEC = isInEEC($thirdparty); + $isSellerInEEC = isInEEC($mysoc); + $code_sell_l = ''; + $code_sell_p = ''; + $code_sell_t = ''; + $suggestedid = ''; + + // Level 1: Search suggested default account for product/service + $suggestedaccountingaccountbydefaultfor = ''; + if ($factureDet->product_type == 1) { + if ($thirdparty->country_code == $mysoc->country_code || empty($thirdparty->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with a VAT + $code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($thirdparty->tva_intra)) { // European intravat sale, without VAT intra community number + $code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; + } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eec'; + } else { // Foreign sale + $code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'export'; + } + } + } elseif ($factureDet->product_type == 0) { + if ($thirdparty->country_code == $mysoc->country_code || empty($thirdparty->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with a VAT + $code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($thirdparty->tva_intra)) { // European intravat sale, without VAT intra community number + $code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; + } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eec'; + } else { + $code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'export'; + } + } + } + if ($code_sell_l == -1) { + $code_sell_l = ''; + } + + // Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding) + $suggestedaccountingaccountfor = ''; + if (($thirdparty->country_code == $mysoc->country_code) || empty($thirdparty->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $code_sell_p = $product->accountancy_code_sell; + $suggestedid = $accountingAccount['dom']; + $suggestedaccountingaccountfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with VAT + $code_sell_p = $product->accountancy_code_sell; + $suggestedid = $accountingAccount['dom']; + $suggestedaccountingaccountfor = 'eecwithvat'; + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($thirdparty->tva_intra)) { // European intravat sale, without VAT intra community number + $code_sell_p = $product->accountancy_code_sell; + $suggestedid = $accountingAccount['dom']; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? + $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; + } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $code_sell_p = $product->accountancy_code_sell_intra; + $suggestedid = $accountingAccount['intra']; + $suggestedaccountingaccountfor = 'eec'; + } else { // Foreign sale + $code_sell_p = $product->accountancy_code_sell_export; + $suggestedid = $accountingAccount['export']; + $suggestedaccountingaccountfor = 'export'; + } + } + + // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) + if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { + if (!empty($thirdparty->code_compta)) { + $code_sell_t = $thirdparty->code_compta; + $suggestedid = $accountingAccount['thirdparty']; + $suggestedaccountingaccountfor = ''; + } + } + + // Manage Deposit + if ($factureDet->desc == "(DEPOSIT)") { + $accountdeposittoventilated = new self($this->db); + $result = $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); + if ($result < 0) { + return -1; + } + + $code_sell_l = $accountdeposittoventilated->ref; + $suggestedid = $accountdeposittoventilated->rowid; + } + + if (empty($suggestedid) && empty($code_sell_p) && !empty($code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) { + if (empty($this->accountingaccount_codetotid_cache[$code_sell_l])) { + $tmpaccount = new self($this->db); + $result = $tmpaccount->fetch(0, $code_sell_l, 1); + if ($result < 0) { + return -1; + } + if ($tmpaccount->id > 0) { + $suggestedid = $tmpaccount->id; + } + $this->accountingaccount_codetotid_cache[$code_sell_l] = $tmpaccount->id; + } else { + $suggestedid = $this->accountingaccount_codetotid_cache[$code_sell_l]; + } + } + } else { + if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) { + return $hookmanager->resArray; + } + } + return array( + 'suggestedaccountingaccountbydefaultfor' => $suggestedaccountingaccountbydefaultfor, + 'suggestedaccountingaccountfor' => $suggestedaccountingaccountfor, + 'suggestedid' => $suggestedid, + 'code_sell_l' => $code_sell_l, + 'code_sell_p' => $code_sell_p, + 'code_sell_t' => $code_sell_t, + ); + } + + /** + * Load record in memory + * + * @param int $rowid Id + * @param string $account_number Account number + * @param int|boolean $limittocurrentchart 1 or true=Load record only if it is into current active char of account + * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code). + * @return int <0 if KO, 0 if not found, Id of record if OK and found + */ + public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') + { + global $conf; + + if ($rowid || $account_number) { + $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconcilable"; + $sql .= ", ca.label as category_label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as ca ON a.fk_accounting_category = ca.rowid"; + $sql .= " WHERE"; + if ($rowid) { + $sql .= " a.rowid = " . (int) $rowid; + } elseif ($account_number) { + $sql .= " a.account_number = '" . $this->db->escape($account_number) . "'"; + $sql .= " AND a.entity = " . $conf->entity; + } + if (!empty($limittocurrentchart)) { + $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $this->db->escape($conf->global->CHARTOFACCOUNTS) . ')'; + } + if (!empty($limittoachartaccount)) { + $sql .= " AND a.fk_pcg_version = '" . $this->db->escape($limittoachartaccount) . "'"; + } + + dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + + if ($obj) { + $this->id = $obj->rowid; + $this->rowid = $obj->rowid; + $this->ref = $obj->account_number; + $this->datec = $obj->datec; + $this->tms = $obj->tms; + $this->fk_pcg_version = $obj->fk_pcg_version; + $this->pcg_type = $obj->pcg_type; + $this->account_number = $obj->account_number; + $this->account_parent = $obj->account_parent; + $this->label = $obj->label; + $this->labelshort = $obj->labelshort; + $this->account_category = $obj->fk_accounting_category; + $this->account_category_label = $obj->category_label; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_modif = $obj->fk_user_modif; + $this->active = $obj->active; + $this->status = $obj->active; + $this->reconcilable = $obj->reconcilable; + + return $this->id; + } else { + return 0; + } + } else { + $this->error = "Error " . $this->db->lasterror(); + $this->errors[] = "Error " . $this->db->lasterror(); + } + } + return -1; + } } diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 4df8d6b9b15..e165cc3d8b1 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -45,6 +45,7 @@ $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); +$optioncss = GETPOST('optioncss', 'alpha'); // Select Box $mesCasesCochees = GETPOST('toselect', 'array'); @@ -96,6 +97,7 @@ if (!$sortorder) { $hookmanager->initHooks(array('accountancycustomerlist')); $formaccounting = new FormAccounting($db); +$accountingAccount = new AccountingAccount($db); $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); @@ -510,17 +512,17 @@ if ($result) { $thirdpartystatic = new Societe($db); $facture_static = new Facture($db); + $facture_static_det = new FactureLigne($db); $product_static = new Product($db); - $isSellerInEEC = isInEEC($mysoc); $accountingaccount_codetotid_cache = array(); while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); - $objp->code_sell_l = ''; - $objp->code_sell_p = ''; + $code_sell_l = ''; + $code_sell_p = ''; $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; @@ -532,6 +534,8 @@ if ($result) { $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; $thirdpartystatic->email = $objp->email; $thirdpartystatic->country_code = $objp->country_code; + $thirdpartystatic->tva_intra = $objp->tva_intra; + $thirdpartystatic->code_compta = $objp->company_code_sell; $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; @@ -545,158 +549,96 @@ if ($result) { $product_static->accountancy_code_buy = $objp->code_buy; $product_static->accountancy_code_buy_intra = $objp->code_buy_intra; $product_static->accountancy_code_buy_export = $objp->code_buy_export; + $product_static->tva_tx = $objp->tva_tx_prod; + $product_static->tva_tx = $objp->tva_tx_prod; $facture_static->ref = $objp->ref; $facture_static->id = $objp->facid; $facture_static->type = $objp->ftype; + $facture_static->datef = $objp->datef; + + $facture_static_det->id = $objp->rowid; + $facture_static_det->total_ht = $objp->total_ht; + $facture_static_det->tva_tx = $objp->tva_tx_line; + $facture_static_det->vat_src_code = $objp->vat_src_code; + $facture_static_det->product_type = $objp->type_l; + $facture_static_det->desc = $objp->description; + + $accoutinAccountArray = array( + 'dom'=>$objp->aarowid, + 'intra'=>$objp->aarowid_intra, + 'export'=>$objp->aarowid_export, + 'thirdparty' =>$objp->aarowid_thirdparty); $code_sell_p_notset = ''; $code_sell_t_notset = ''; - $objp->aarowid_suggest = ''; // Will be set later - $isBuyerInEEC = isInEEC($objp); - - // Level 1: Search suggested default account for product/service - $suggestedaccountingaccountbydefaultfor = ''; - if ($objp->type_l == 1) { - if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = ''; - } else { - if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; - } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'eec'; - } else { // Foreign sale - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'export'; - } - } - } elseif ($objp->type_l == 0) { - if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = ''; - } else { - if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; - } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'eec'; - } else { - $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : ''); - $suggestedaccountingaccountbydefaultfor = 'export'; - } - } - } - if ($objp->code_sell_l == -1) { - $objp->code_sell_l = ''; - } - - // Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding) - $suggestedaccountingaccountfor = ''; - if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = $objp->aarowid; - $suggestedaccountingaccountfor = ''; + $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $product_static, $facture_static, $facture_static_det, $accoutinAccountArray); + if (!is_array($return) && $return<0) { + setEventMessage($accountingAccount->error, 'errors'); } else { - if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = $objp->aarowid; - $suggestedaccountingaccountfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? - $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; - } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_p = $objp->code_sell_intra; - $objp->aarowid_suggest = $objp->aarowid_intra; - $suggestedaccountingaccountfor = 'eec'; - } else { // Foreign sale - $objp->code_sell_p = $objp->code_sell_export; - $objp->aarowid_suggest = $objp->aarowid_export; - $suggestedaccountingaccountfor = 'export'; - } + $suggestedid=$return['suggestedid']; + $suggestedaccountingaccountfor=$return['suggestedaccountingaccountfor']; + $suggestedaccountingaccountbydefaultfor=$return['suggestedaccountingaccountbydefaultfor']; + $code_sell_l=$return['code_sell_l']; + $code_sell_p=$return['code_sell_p']; + $code_sell_t=$return['code_sell_t']; } - // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) - if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { - if (!empty($objp->company_code_sell)) { - $objp->code_sell_t = $objp->company_code_sell; - $objp->aarowid_suggest = $objp->aarowid_thirdparty; - $suggestedaccountingaccountfor = ''; - } - } - - // Manage Deposit - if ($objp->description == "(DEPOSIT)") { - $accountdeposittoventilated = new AccountingAccount($db); - $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); - $objp->code_sell_l = $accountdeposittoventilated->ref; - $objp->aarowid_suggest = $accountdeposittoventilated->rowid; - } - - if (!empty($objp->code_sell_p)) { + if (!empty($code_sell_p)) { // Value was defined previously } else { $code_sell_p_notset = 'color:orange'; } - if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) { + if (empty($code_sell_l) && empty($code_sell_p)) { $code_sell_p_notset = 'color:red'; } if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber' && empty($code_sell_p_notset)) { $code_sell_p_notset = 'color:orange'; } - // $objp->code_sell_l is now default code of product/service - // $objp->code_sell_p is now code of product/service - // $objp->code_sell_t is now code of thirdparty + // $code_sell_l is now default code of product/service + // $code_sell_p is now code of product/service + // $code_sell_t is now code of thirdparty print ''; // Line id - print ''.$objp->rowid.''; + print ''.$facture_static_det->id.''; // Ref Invoice print ''.$facture_static->getNomUrl(1).''; - print ''.dol_print_date($db->jdate($objp->datef), 'day').''; + print ''.dol_print_date($db->jdate($facture_static->datef), 'day').''; // Ref Product print ''; if ($product_static->id > 0) { print $product_static->getNomUrl(1); } - if ($objp->product_label) { - print '
'.$objp->product_label.''; + if ($product_static->label) { + print '
'.$product_static->label.''; } print ''; // Description print ''; - $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); + $text = dolGetFirstLineOfText(dol_string_nohtmltag($facture_static_det->desc)); $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; - print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description); + print $form->textwithtooltip(dol_trunc($text, $trunclength), $facture_static_det->desc); print ''; print ''; - print price($objp->total_ht); + print price($facture_static_det->total_ht); print ''; // Vat rate - if ($objp->vat_tx_l != $objp->vat_tx_p) { + $code_vat_differ=''; + if ($product_static->tva_tx !== $facture_static_det->tva_tx) { $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; } print ''; - print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')); + print vatrate($facture_static_det->tva_tx.($facture_static_det->vat_src_code ? ' ('.$facture_static_det->vat_src_code.')' : '')); print ''; // Thirdparty @@ -704,27 +646,27 @@ if ($result) { // Country print ''; - $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; + $labelcountry = ($thirdpartystatic->country_code && ($langs->trans("Country".$thirdpartystatic->country_code) != "Country".$thirdpartystatic->country_code)) ? $langs->trans("Country".$thirdpartystatic->country_code) : $objp->country_label; print $labelcountry; print ''; // VAT Num - print ''.$objp->tva_intra.''; + print ''.$thirdpartystatic->tva_intra.''; // Found accounts print ''; - $s = '1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; + $s = '1. '.(($facture_static_det->product_type == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountbydefaultfor == 'eec') { $shelp .= $langs->trans("SaleEEC"); } elseif ($suggestedaccountingaccountbydefaultfor == 'export') { $shelp .= $langs->trans("SaleExport"); } - $s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : ''.$langs->trans("NotDefined").''); + $s .= ($code_sell_l > 0 ? length_accountg($code_sell_l) : ''.$langs->trans("NotDefined").''); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); - if ($objp->product_id > 0) { + if ($product_static->id > 0) { print '
'; - $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $s = '2. '.(($facture_static_det->product_type == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; $ttype = 'help'; if ($suggestedaccountingaccountfor == 'eec') { $shelp = $langs->trans("SaleEEC"); @@ -736,12 +678,12 @@ if ($result) { } elseif ($suggestedaccountingaccountfor == 'export') { $shelp = $langs->trans("SaleExport"); } - $s .= (empty($objp->code_sell_p) ? ''.$langs->trans("NotDefined").'' : length_accountg($objp->code_sell_p)); + $s .= (empty($code_sell_p) ? ''.$langs->trans("NotDefined").'' : length_accountg($code_sell_p)); print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1); } else { if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { print '
'; - $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; + $s = '2. '.(($facture_static_det->product_type == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; $s .= $langs->trans("NotDefined"); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); @@ -749,29 +691,16 @@ if ($result) { } if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { print '
'; - $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': '; + $s = '3. '.(($facture_static_det->product_type == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': '; $shelp = ''; - $s .= ($objp->code_sell_t > 0 ? length_accountg($objp->code_sell_t) : ''.$langs->trans("NotDefined").''); + $s .= ($code_sell_t > 0 ? length_accountg($code_sell_t) : ''.$langs->trans("NotDefined").''); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); } print ''; // Suggested accounting account print ''; - $suggestedid = $objp->aarowid_suggest; - if (empty($suggestedid) && empty($objp->code_sell_p) && !empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) { - if (empty($accountingaccount_codetotid_cache[$objp->code_sell_l])) { - $tmpaccount = new AccountingAccount($db); - $tmpaccount->fetch(0, $objp->code_sell_l, 1); - if ($tmpaccount->id > 0) { - $suggestedid = $tmpaccount->id; - } - $accountingaccount_codetotid_cache[$objp->code_sell_l] = $tmpaccount->id; - } else { - $suggestedid = $accountingaccount_codetotid_cache[$objp->code_sell_l]; - } - } - print $formaccounting->select_account($suggestedid, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); + print $formaccounting->select_account($suggestedid, 'codeventil'.$facture_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; // Column with checkbox @@ -780,7 +709,7 @@ if ($result) { if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') { $ischecked = 0; } - print ''; + print ''; print ''; print ''; From 729ca70bf396d05b3cf75abe5a28b2fafcf92df7 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 4 Jun 2021 12:20:52 +0200 Subject: [PATCH 002/113] NEW : rewrite bind accountancy code finding on sales invoice --- .../class/accountingaccount.class.php | 15 +-- htdocs/accountancy/customer/index.php | 101 ++++++++++++------ htdocs/accountancy/customer/list.php | 6 +- htdocs/societe/card.php | 12 ++- 4 files changed, 90 insertions(+), 44 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index c4a11fb6565..9f5c7799037 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -739,24 +739,24 @@ class AccountingAccount extends CommonObject // Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding) $suggestedaccountingaccountfor = ''; - if (($thirdparty->country_code == $mysoc->country_code) || empty($thirdparty->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + if ((($thirdparty->country_code == $mysoc->country_code) || empty($thirdparty->country_code)) && !empty($product->accountancy_code_sell)) { // If buyer in same country than seller (if not defined, we assume it is same country) $code_sell_p = $product->accountancy_code_sell; $suggestedid = $accountingAccount['dom']; - $suggestedaccountingaccountfor = ''; + $suggestedaccountingaccountfor = 'prodserv'; } else { - if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with VAT + if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0 && !empty($product->accountancy_code_sell)) { // European intravat sale, but with VAT $code_sell_p = $product->accountancy_code_sell; $suggestedid = $accountingAccount['dom']; $suggestedaccountingaccountfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($thirdparty->tva_intra)) { // European intravat sale, without VAT intra community number + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($thirdparty->tva_intra) && !empty($product->accountancy_code_sell)) { // European intravat sale, without VAT intra community number $code_sell_p = $product->accountancy_code_sell; $suggestedid = $accountingAccount['dom']; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; - } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + } elseif ($isSellerInEEC && $isBuyerInEEC && !empty($product->accountancy_code_sell_intra)) { // European intravat sale $code_sell_p = $product->accountancy_code_sell_intra; $suggestedid = $accountingAccount['intra']; $suggestedaccountingaccountfor = 'eec'; - } else { // Foreign sale + } elseif (!empty($product->accountancy_code_sell_export)) { // Foreign sale $code_sell_p = $product->accountancy_code_sell_export; $suggestedid = $accountingAccount['export']; $suggestedaccountingaccountfor = 'export'; @@ -768,7 +768,7 @@ class AccountingAccount extends CommonObject if (!empty($thirdparty->code_compta)) { $code_sell_t = $thirdparty->code_compta; $suggestedid = $accountingAccount['thirdparty']; - $suggestedaccountingaccountfor = ''; + $suggestedaccountingaccountfor = 'thridparty'; } } @@ -782,6 +782,7 @@ class AccountingAccount extends CommonObject $code_sell_l = $accountdeposittoventilated->ref; $suggestedid = $accountdeposittoventilated->rowid; + $suggestedaccountingaccountfor = 'deposit'; } if (empty($suggestedid) && empty($code_sell_p) && !empty($code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) { diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index d33f5e12312..2bb2903eefa 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); @@ -46,6 +47,7 @@ if (!$user->rights->accounting->bind->write) { accessforbidden(); } +$accountingAccount = new AccountingAccount($db); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) { @@ -166,49 +168,82 @@ if ($action == 'validatehistory') { $isSellerInEEC = isInEEC($mysoc); + $thirdpartystatic = new Societe($db); + $facture_static = new Facture($db); + $facture_static_det = new FactureLigne($db); + $product_static = new Product($db); + $i = 0; while ($i < min($num_lines, 10000)) { // No more than 10000 at once $objp = $db->fetch_object($result); - $isBuyerInEEC = isInEEC($objp); // This make a database request but there is a cache into $conf->cache['country_code_in_EEC'] + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_compta_client = $objp->code_compta_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->country_code = $objp->country_code; + $thirdpartystatic->tva_intra = $objp->tva_intra; + $thirdpartystatic->code_compta = $objp->company_code_sell; - // Level 2: Search suggested account for product/service (similar code exists in page list.php to make manual binding) - $suggestedaccountingaccountfor = ''; - if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = $objp->aarowid; - $suggestedaccountingaccountfor = ''; + $product_static->ref = $objp->product_ref; + $product_static->id = $objp->product_id; + $product_static->type = $objp->type; + $product_static->label = $objp->product_label; + $product_static->status = $objp->status; + $product_static->status_buy = $objp->status_buy; + $product_static->accountancy_code_sell = $objp->code_sell; + $product_static->accountancy_code_sell_intra = $objp->code_sell_intra; + $product_static->accountancy_code_sell_export = $objp->code_sell_export; + $product_static->accountancy_code_buy = $objp->code_buy; + $product_static->accountancy_code_buy_intra = $objp->code_buy_intra; + $product_static->accountancy_code_buy_export = $objp->code_buy_export; + $product_static->tva_tx = $objp->tva_tx_prod; + $product_static->tva_tx = $objp->tva_tx_prod; + + $facture_static->ref = $objp->ref; + $facture_static->id = $objp->facid; + $facture_static->type = $objp->ftype; + $facture_static->datef = $objp->datef; + + $facture_static_det->id = $objp->rowid; + $facture_static_det->total_ht = $objp->total_ht; + $facture_static_det->tva_tx = $objp->tva_tx_line; + $facture_static_det->vat_src_code = $objp->vat_src_code; + $facture_static_det->product_type = $objp->type_l; + $facture_static_det->desc = $objp->description; + + $accoutinAccountArray = array( + 'dom'=>$objp->aarowid, + 'intra'=>$objp->aarowid_intra, + 'export'=>$objp->aarowid_export, + 'thirdparty' =>$objp->aarowid_thirdparty); + + $code_sell_p_notset = ''; + $code_sell_t_notset = ''; + + $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $product_static, $facture_static, $facture_static_det, $accoutinAccountArray); + if (!is_array($return) && $return<0) { + setEventMessage($accountingAccount->error, 'errors'); } else { - if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = $objp->aarowid; - $suggestedaccountingaccountfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number - $objp->code_sell_p = $objp->code_sell; - $objp->aarowid_suggest = 0; // There is a doubt, no automatic binding - $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; - } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_p = $objp->code_sell_intra; - $objp->aarowid_suggest = $objp->aarowid_intra; - $suggestedaccountingaccountfor = 'eec'; - } else { // Foreign sale - $objp->code_sell_p = $objp->code_sell_export; - $objp->aarowid_suggest = $objp->aarowid_export; - $suggestedaccountingaccountfor = 'export'; + $suggestedid=$return['suggestedid']; + $suggestedaccountingaccountfor=$return['suggestedaccountingaccountfor']; + + if (!empty($suggestedid) && $suggestedaccountingaccountfor<>'') { + $suggestedid=$return['suggestedid']; + } else { + $suggestedid=0; } } - // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) - if (!empty($objp->company_code_sell)) { - $objp->code_sell_t = $objp->company_code_sell; - $objp->aarowid_suggest = $objp->aarowid_thirdparty; - $suggestedaccountingaccountfor = ''; - } - - if ($objp->aarowid_suggest > 0) { + if ($suggestedid > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; - $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); - $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $objp->rowid); + $sqlupdate .= " SET fk_code_ventilation = ".((int) $suggestedid); + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $facture_static_det->id); $resqlupdate = $db->query($sqlupdate); if (!$resqlupdate) { diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index e165cc3d8b1..c58df26edc2 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -584,6 +584,7 @@ if ($result) { $code_sell_p=$return['code_sell_p']; $code_sell_t=$return['code_sell_t']; } + //var_dump($return); if (!empty($code_sell_p)) { // Value was defined previously @@ -705,8 +706,9 @@ if ($result) { // Column with checkbox print ''; - $ischecked = $objp->aarowid_suggest; - if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') { + if (!empty($suggestedid) && $suggestedaccountingaccountfor<>'') { + $ischecked=1; + } elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') { $ischecked = 0; } print ''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index aa8205bfa99..1c7871d4b1c 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -490,10 +490,18 @@ if (empty($reshook)) { $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); if (GETPOSTISSET('accountancy_code_sell')) { - $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); + if (GETPOST('accountancy_code_sell', 'int')==-1) { + $object->accountancy_code_sell = 0; + } else { + $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'int'); + } } if (GETPOSTISSET('accountancy_code_buy')) { - $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + if (GETPOST('accountancy_code_buy', 'int')==-1) { + $object->accountancy_code_buy = 0; + } else { + $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'int'); + } } // Incoterms From ac6e108be6e5643dfd993a7be283b64e2f97b872 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 4 Jun 2021 12:27:49 +0200 Subject: [PATCH 003/113] fix syntax --- .../class/accountingaccount.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 9f5c7799037..1827549020f 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -800,19 +800,19 @@ class AccountingAccount extends CommonObject $suggestedid = $this->accountingaccount_codetotid_cache[$code_sell_l]; } } + return array( + 'suggestedaccountingaccountbydefaultfor' => $suggestedaccountingaccountbydefaultfor, + 'suggestedaccountingaccountfor' => $suggestedaccountingaccountfor, + 'suggestedid' => $suggestedid, + 'code_sell_l' => $code_sell_l, + 'code_sell_p' => $code_sell_p, + 'code_sell_t' => $code_sell_t, + ); } else { if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) { return $hookmanager->resArray; } } - return array( - 'suggestedaccountingaccountbydefaultfor' => $suggestedaccountingaccountbydefaultfor, - 'suggestedaccountingaccountfor' => $suggestedaccountingaccountfor, - 'suggestedid' => $suggestedid, - 'code_sell_l' => $code_sell_l, - 'code_sell_p' => $code_sell_p, - 'code_sell_t' => $code_sell_t, - ); } /** From 709a2975637759716e745943645d408e7b3f93c7 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 30 Aug 2021 14:45:42 +0200 Subject: [PATCH 004/113] NEW : Allow drag and drop on kits --- htdocs/core/ajax/row.php | 2 + htdocs/core/class/commonobject.class.php | 11 +++-- htdocs/langs/en_US/products.lang | 3 +- htdocs/langs/fr_FR/products.lang | 1 + htdocs/product/class/product.class.php | 59 +++++++++++++++++------- htdocs/product/composition/card.php | 28 +++++++++-- 6 files changed, 79 insertions(+), 25 deletions(-) diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 95518cbbf66..1afd5f8b206 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -99,6 +99,8 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) $perm = 1; } elseif ($table_element_line == 'ecm_files' && $fk_element == 'fk_ticket' && !empty($user->rights->ticket->write)) { $perm = 1; + } elseif ($table_element_line == 'product_association' && $fk_element == 'fk_product' && !empty($user->rights->produit->creer)) { + $perm = 1; } else { $tmparray = explode('_', $table_element_line); $tmpmodule = $tmparray[0]; $tmpobject = preg_replace('/line$/', '', $tmparray[1]); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5cdb83194f4..22aa26ceb62 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3021,7 +3021,7 @@ abstract class CommonObject * * @param int $rowid Id of line * @param int $rang Position - * @return void + * @return int */ public function updateRangOfLine($rowid, $rang) { @@ -3037,10 +3037,13 @@ abstract class CommonObject dol_syslog(get_class($this)."::updateRangOfLine", LOG_DEBUG); if (!$this->db->query($sql)) { dol_print_error($this->db); + return -1; + } else { + $parameters=array('rowid'=>$rowid, 'rang'=>$rang, 'fieldposition' => $fieldposition); + $action=''; + $reshook = $hookmanager->executeHooks('afterRankOfLineUpdate', $parameters, $this, $action); + return 1; } - $parameters=array('rowid'=>$rowid, 'rang'=>$rang, 'fieldposition' => $fieldposition); - $action=''; - $reshook = $hookmanager->executeHooks('afterRankOfLineUpdate', $parameters, $this, $action); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index ae199f4136b..31aa253af93 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -400,4 +400,5 @@ DeleteLinkedProduct=Delete the child product linked to the combination PMPValue=Weighted average price PMPValueShort=WAP DefaultBOM=Default BOM -DefaultBOMDesc=The default BOM recommended to use to manufacture this product. This field can be set only if nature of product is '%s'. \ No newline at end of file +DefaultBOMDesc=The default BOM recommended to use to manufacture this product. This field can be set only if nature of product is '%s'. +Rank=Rank diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 013d75d2ec0..f67cfd8423d 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -399,3 +399,4 @@ ProductSupplierExtraFields=Attributs supplémentaires (Prix fournisseur) DeleteLinkedProduct=Supprimer le produit enfant lié à la combinaison PMPValue=Prix moyen pondéré (PMP) PMPValueShort=PMP +Rank=Rang diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e51c553809d..5681cf2571a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4014,22 +4014,27 @@ class Product extends CommonObject dol_print_error($this->db); return -1; } else { - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - if ($num > 0) { - $this->error = "isFatherOfThis"; + //Selection of the highest row + $sql = 'SELECT MAX(rang) as max_rank FROM '.MAIN_DB_PREFIX.'product_association'; + $sql .= ' WHERE fk_product_pere = '.$id_pere; + $resql = $this->db->query($sql); + if ($resql > 0) { + $obj = $this->db->fetch_object($resql); + $rank = $obj->max_rank + 1; + //Addition of a product with the highest rank +1 + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)'; + $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$qty.', '.$incdec.', '.$rank.')'; + if (! $this->db->query($sql)) { + dol_print_error($this->db); return -1; - } else { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec)'; - $sql .= ' VALUES ('.((int) $id_pere).', '.((int) $id_fils).', '.((float) $qty).', '.((int) $incdec).')'; - if (!$this->db->query($sql)) { - dol_print_error($this->db); - return -1; - } else { - return 1; - } } + else + { + return 1; + } + } else { + dol_print_error($this->db); + return -1; } } } @@ -4102,6 +4107,24 @@ class Product extends CommonObject return -1; } + //Updated ranks so that none are missing + $sqlrank = 'SELECT rowid, rang FROM '.MAIN_DB_PREFIX.'product_association'; + $sqlrank.= ' WHERE fk_product_pere = '.$fk_parent; + $sqlrank.= ' ORDER BY rang'; + $resqlrank = $this->db->query($sqlrank); + if ($resqlrank) { + $cpt = 0; + while ($objrank = $this->db->fetch_object($resqlrank)){ + $cpt++; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_association'; + $sql.= ' SET rang ='.$cpt; + $sql.= ' WHERE rowid ='.$objrank->rowid; + if (! $this->db->query($sql)) { + dol_print_error($this->db); + return -1; + } + } + } return 1; } @@ -4666,12 +4689,14 @@ class Product extends CommonObject } $sql = "SELECT p.rowid, p.ref, p.label as label, p.fk_product_type,"; - $sql .= " pa.qty as qty, pa.fk_product_fils as id, pa.incdec"; + $sql .= " pa.qty as qty, pa.fk_product_fils as id, pa.incdec,"; + $sql .= " pa.rowid as fk_association, pa.rang"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."product_association as pa"; $sql .= " WHERE p.rowid = pa.fk_product_fils"; $sql .= " AND pa.fk_product_pere = ".((int) $id); $sql .= " AND pa.fk_product_fils <> ".((int) $id); // This should not happens, it is to avoid infinite loop if it happens + $sql.= " ORDER BY pa.rang"; dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG); @@ -4698,7 +4723,9 @@ class Product extends CommonObject 2=>$rec['fk_product_type'], 3=>$this->db->escape($rec['label']), 4=>$rec['incdec'], - 5=>$rec['ref'] + 5=>$rec['ref'], + 6=>$rec['fk_association'], + 7=>$rec['rang'] ); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); //$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 000e5da6cbc..d1e59482d44 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -132,6 +132,8 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se setEventMessages('RecordSaved', null); } $action = ''; + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; } @@ -268,8 +270,18 @@ if ($id > 0 || !empty($ref)) { $prodsfather = $object->getFather(); // Parent Products $object->get_sousproduits_arbo(); // Load $object->sousprods + $parent_label = $object->label; $prods_arbo = $object->get_arbo_each_prod(); + $tmpid = $id; + if (! empty($conf->use_javascript_ajax)) { + $nboflines = $prods_arbo; + $table_element_line='product_association'; + + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + $id = $tmpid; + $nbofsubsubproducts = count($prods_arbo); // This include sub sub product into nb $prodschild = $object->getChildsArbo($id, 1); $nbofsubproducts = count($prodschild); // This include only first level of childs @@ -323,9 +335,10 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; - print ''; + print '
'; - print ''; + print ''; + print ''; print ''; print ''; print ''; @@ -335,6 +348,7 @@ if ($id > 0 || !empty($ref)) { } print ''; print ''; + print ''; print ''."\n"; $totalsell = 0; @@ -343,7 +357,9 @@ if ($id > 0 || !empty($ref)) { $productstatic->fetch($value['id']); if ($value['level'] <= 1) { - print ''; + print ''; + + print ''; $notdefined = 0; $nb_of_subproduct = $value['nb']; @@ -407,6 +423,8 @@ if ($id > 0 || !empty($ref)) { print ''; } + print ''; print ''."\n"; } else { $hide = ''; @@ -414,10 +432,11 @@ if ($id > 0 || !empty($ref)) { $hide = ' hideobject'; // By default, we do not show this. It makes screen very difficult to understand } - print ''; + print ''; //$productstatic->ref=$value['label']; $productstatic->ref = $value['ref']; + print ''; print ''; print ''; + print ''; print ''."\n"; } From 73b4f0df51ee6ca9b030c8436e411e0efe41587f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 30 Aug 2021 13:38:55 +0000 Subject: [PATCH 005/113] Fixing style errors. --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5681cf2571a..27582a533bd 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4114,7 +4114,7 @@ class Product extends CommonObject $resqlrank = $this->db->query($sqlrank); if ($resqlrank) { $cpt = 0; - while ($objrank = $this->db->fetch_object($resqlrank)){ + while ($objrank = $this->db->fetch_object($resqlrank)) { $cpt++; $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_association'; $sql.= ' SET rang ='.$cpt; From 317876eb0c3b6d0ed11f78c50be12dccecabf9ae Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 30 Aug 2021 15:48:22 +0200 Subject: [PATCH 006/113] NEW : Update SQL : install and migration --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 1 + htdocs/install/mysql/tables/llx_product_association.sql | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 1d9dd28f9d7..349b7e3a617 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -57,6 +57,7 @@ ALTER TABLE llx_categorie_ticket ADD CONSTRAINT fk_categorie_ticket_categorie_ro ALTER TABLE llx_categorie_ticket ADD CONSTRAINT fk_categorie_ticket_ticket_rowid FOREIGN KEY (fk_ticket) REFERENCES llx_ticket (rowid); ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN ref_fourn varchar(128); ALTER TABLE llx_product_customer_price MODIFY COLUMN ref_customer varchar(128); +ALTER TABLE llx_product_association ADD COLUMN rang int; -- -- add action trigger INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('ORDER_SUPPLIER_CANCEL','Supplier order request canceled','Executed when a supplier order is canceled','order_supplier',13); diff --git a/htdocs/install/mysql/tables/llx_product_association.sql b/htdocs/install/mysql/tables/llx_product_association.sql index 91cc14882f1..5447446695f 100644 --- a/htdocs/install/mysql/tables/llx_product_association.sql +++ b/htdocs/install/mysql/tables/llx_product_association.sql @@ -23,6 +23,7 @@ create table llx_product_association fk_product_pere integer NOT NULL DEFAULT 0, -- id du produit maitre fk_product_fils integer NOT NULL DEFAULT 0, -- id du sous-produit qty double NULL, - incdec integer DEFAULT 1 -- when set to 1 changing stock of product will change stock of linked product too + incdec integer DEFAULT 1, -- when set to 1 changing stock of product will change stock of linked product too + range integer, )ENGINE=innodb; From 7794a01a0b3fe65e46518276675b3d56e2b6df32 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 30 Aug 2021 15:51:59 +0200 Subject: [PATCH 007/113] FIX : Stickler-ci --- htdocs/product/class/product.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 27582a533bd..c41228bbd4a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4027,9 +4027,7 @@ class Product extends CommonObject if (! $this->db->query($sql)) { dol_print_error($this->db); return -1; - } - else - { + } else { return 1; } } else { From 08364d249247682d2c270d0dd99184e3ff315a0e Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 30 Aug 2021 16:08:07 +0200 Subject: [PATCH 008/113] FIX : Travis --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c41228bbd4a..82bf28cb7ca 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4023,7 +4023,7 @@ class Product extends CommonObject $rank = $obj->max_rank + 1; //Addition of a product with the highest rank +1 $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)'; - $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$qty.', '.$incdec.', '.$rank.')'; + $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$this->db->escape($qty).', '.$incdec.', '.$rank.')'; if (! $this->db->query($sql)) { dol_print_error($this->db); return -1; From fb183f4f5d45e928ac898fa5e758f834f6fe5b34 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 30 Aug 2021 16:13:51 +0200 Subject: [PATCH 009/113] FIX : Travis --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 82bf28cb7ca..4d8990a12f1 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4023,7 +4023,7 @@ class Product extends CommonObject $rank = $obj->max_rank + 1; //Addition of a product with the highest rank +1 $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)'; - $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$this->db->escape($qty).', '.$incdec.', '.$rank.')'; + $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$qty.', '.$incdec.', '.$this->db->escape($rank).')'; if (! $this->db->query($sql)) { dol_print_error($this->db); return -1; From f44ae62eb34b2fe794f901013eb20f95311f369d Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 30 Aug 2021 16:59:09 +0200 Subject: [PATCH 010/113] FIX : Travis --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4d8990a12f1..bc348925244 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4107,7 +4107,7 @@ class Product extends CommonObject //Updated ranks so that none are missing $sqlrank = 'SELECT rowid, rang FROM '.MAIN_DB_PREFIX.'product_association'; - $sqlrank.= ' WHERE fk_product_pere = '.$fk_parent; + $sqlrank.= ' WHERE fk_product_pere = '.$this->db->escape($fk_parent); $sqlrank.= ' ORDER BY rang'; $resqlrank = $this->db->query($sqlrank); if ($resqlrank) { From 58845082b1a861e2d643350801ee8e14eb7cd5a0 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 30 Aug 2021 17:20:50 +0200 Subject: [PATCH 011/113] FIX : Travis --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bc348925244..508059e9e34 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4116,7 +4116,7 @@ class Product extends CommonObject $cpt++; $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_association'; $sql.= ' SET rang ='.$cpt; - $sql.= ' WHERE rowid ='.$objrank->rowid; + $sql.= ' WHERE rowid ='.$this->db->escape($objrank->rowid); if (! $this->db->query($sql)) { dol_print_error($this->db); return -1; From ef2bb99476090a7600d19fc2ef71c10b4d46af35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Sep 2021 16:29:08 +0200 Subject: [PATCH 012/113] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 22aa26ceb62..70effea53b3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3021,7 +3021,7 @@ abstract class CommonObject * * @param int $rowid Id of line * @param int $rang Position - * @return int + * @return int <0 if KO, >0 if OK */ public function updateRangOfLine($rowid, $rang) { From 3b236f677d68031c6e2e3597d512bc9b3d45fa30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Sep 2021 16:31:16 +0200 Subject: [PATCH 013/113] Update llx_product_association.sql --- htdocs/install/mysql/tables/llx_product_association.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_product_association.sql b/htdocs/install/mysql/tables/llx_product_association.sql index 5447446695f..f97e2aa6a0b 100644 --- a/htdocs/install/mysql/tables/llx_product_association.sql +++ b/htdocs/install/mysql/tables/llx_product_association.sql @@ -24,6 +24,6 @@ create table llx_product_association fk_product_fils integer NOT NULL DEFAULT 0, -- id du sous-produit qty double NULL, incdec integer DEFAULT 1, -- when set to 1 changing stock of product will change stock of linked product too - range integer, + rang integer DEFAULT 0 )ENGINE=innodb; From 4b7b54e196f8d07246d4d73bb199129182a6dbcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Sep 2021 16:32:25 +0200 Subject: [PATCH 014/113] Update 14.0.0-15.0.0.sql --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 349b7e3a617..cd6cbeae3e6 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -57,7 +57,7 @@ ALTER TABLE llx_categorie_ticket ADD CONSTRAINT fk_categorie_ticket_categorie_ro ALTER TABLE llx_categorie_ticket ADD CONSTRAINT fk_categorie_ticket_ticket_rowid FOREIGN KEY (fk_ticket) REFERENCES llx_ticket (rowid); ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN ref_fourn varchar(128); ALTER TABLE llx_product_customer_price MODIFY COLUMN ref_customer varchar(128); -ALTER TABLE llx_product_association ADD COLUMN rang int; +ALTER TABLE llx_product_association ADD COLUMN rang integer DEFAULT 0; -- -- add action trigger INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('ORDER_SUPPLIER_CANCEL','Supplier order request canceled','Executed when a supplier order is canceled','order_supplier',13); From e7eb17177db432f54856897f2d1e7d97b8ebc0ea Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 10 Sep 2021 15:52:54 +0200 Subject: [PATCH 015/113] merge --- .../class/accountingaccount.class.php | 101 ------------------ 1 file changed, 101 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index ff9dcf14cdb..7ec07d1f15b 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -449,38 +449,6 @@ class AccountingAccount extends CommonObject } } - /** - * Check usage of accounting code - * - * @return int <0 if KO, >0 if OK - */ - public function checkUsage() - { - global $langs; - - $sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet"; - $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; - $sql .= "UNION"; - $sql .= " (SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; - - dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG); - $resql = $this->db->query($sql); - - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num > 0) { - $this->error = $langs->trans('ErrorAccountancyCodeIsAlreadyUse'); - return 0; - } else { - return 1; - } - } else { - $this->error = $this->db->lasterror(); - return -1; - } - } - /** * Return clicable name (with picto eventually) * @@ -915,73 +883,4 @@ class AccountingAccount extends CommonObject } } } - - /** - * Load record in memory - * - * @param int $rowid Id - * @param string $account_number Account number - * @param int|boolean $limittocurrentchart 1 or true=Load record only if it is into current active char of account - * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code). - * @return int <0 if KO, 0 if not found, Id of record if OK and found - */ - public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') - { - global $conf; - - if ($rowid || $account_number) { - $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconcilable"; - $sql .= ", ca.label as category_label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as ca ON a.fk_accounting_category = ca.rowid"; - $sql .= " WHERE"; - if ($rowid) { - $sql .= " a.rowid = " . (int) $rowid; - } elseif ($account_number) { - $sql .= " a.account_number = '" . $this->db->escape($account_number) . "'"; - $sql .= " AND a.entity = " . $conf->entity; - } - if (!empty($limittocurrentchart)) { - $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $this->db->escape($conf->global->CHARTOFACCOUNTS) . ')'; - } - if (!empty($limittoachartaccount)) { - $sql .= " AND a.fk_pcg_version = '" . $this->db->escape($limittoachartaccount) . "'"; - } - - dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); - - if ($obj) { - $this->id = $obj->rowid; - $this->rowid = $obj->rowid; - $this->ref = $obj->account_number; - $this->datec = $obj->datec; - $this->tms = $obj->tms; - $this->fk_pcg_version = $obj->fk_pcg_version; - $this->pcg_type = $obj->pcg_type; - $this->account_number = $obj->account_number; - $this->account_parent = $obj->account_parent; - $this->label = $obj->label; - $this->labelshort = $obj->labelshort; - $this->account_category = $obj->fk_accounting_category; - $this->account_category_label = $obj->category_label; - $this->fk_user_author = $obj->fk_user_author; - $this->fk_user_modif = $obj->fk_user_modif; - $this->active = $obj->active; - $this->status = $obj->active; - $this->reconcilable = $obj->reconcilable; - - return $this->id; - } else { - return 0; - } - } else { - $this->error = "Error " . $this->db->lasterror(); - $this->errors[] = "Error " . $this->db->lasterror(); - } - } - return -1; - } } From 5e2d8eac2b13bbce11fbf4a9d4094cec5a369b87 Mon Sep 17 00:00:00 2001 From: Laurent De Coninck Date: Mon, 20 Sep 2021 22:51:43 +0200 Subject: [PATCH 016/113] Allow to edit the header of receipt by using HTML In the current version the WYSIWYG oesn't allow any HTML by thus fix you can use any button from the wysiwyg and it displays on the receipe. [see: X] --- htdocs/takepos/admin/receipt.php | 4 ++-- htdocs/takepos/receipt.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index 01873d317c4..61fd71bdf29 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -42,8 +42,8 @@ if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'none'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'none'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_RECEIPT_NAME", GETPOST('TAKEPOS_RECEIPT_NAME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SHOW_CUSTOMER", GETPOST('TAKEPOS_SHOW_CUSTOMER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity); diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 6a305362839..a37c4a6c880 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -109,7 +109,7 @@ if (!empty($conf->global->TAKEPOS_HEADER) || !empty($conf->global->{$constFreeTe $substitutionarray = getCommonSubstitutionArray($langs); if (!empty($conf->global->TAKEPOS_HEADER)) $newfreetext .= make_substitutions($conf->global->TAKEPOS_HEADER, $substitutionarray); if (!empty($conf->global->{$constFreeText})) $newfreetext .= make_substitutions($conf->global->{$constFreeText}, $substitutionarray); - print $newfreetext; + print nl2br($newfreetext); } ?>

From 70e66627fed60b611adda6d1fab22f4647580914 Mon Sep 17 00:00:00 2001 From: Laurent De Coninck Date: Wed, 22 Sep 2021 20:14:47 +0200 Subject: [PATCH 017/113] restrict the html --- htdocs/takepos/admin/receipt.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index 61fd71bdf29..3350da50104 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -42,8 +42,8 @@ if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'none'), 'chaine', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'none'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'restricthtml'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'restricthtml'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_RECEIPT_NAME", GETPOST('TAKEPOS_RECEIPT_NAME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SHOW_CUSTOMER", GETPOST('TAKEPOS_SHOW_CUSTOMER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity); From 77d64e4fe2d2eea9be6f5a305c28bd4251d4be87 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 25 Sep 2021 12:13:06 +0200 Subject: [PATCH 018/113] NEW API list of staff units --- htdocs/api/class/api_setup.class.php | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index f5f301e9c16..faccf512ed8 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1278,6 +1278,65 @@ class Setup extends DolibarrApi return $list; } + + /** + * Get the list of staff. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param int $active Staff is active or not {@min 0} {@max 1} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return array List of staff + * + * @url GET dictionary/staff + * + * @throws RestException + */ + public function getListOfStaff($sortfield = "id", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + { + $list = array(); + + //TODO link with multicurrency module + $sql = "SELECT t.id, t.code, t.libelle, t.active, t.module"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif as t"; + $sql .= " WHERE t.active = ".((int) $active); + // Add sql filters + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql .= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of staff: '.$this->db->lasterror()); + } + + return $list; + } /** * Get the list of social networks. From 6b820ae4c5461044cad4bfc2e04d29c75ccbfd22 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 25 Sep 2021 10:16:29 +0000 Subject: [PATCH 019/113] Fixing style errors. --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index faccf512ed8..b957feda82c 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1278,7 +1278,7 @@ class Setup extends DolibarrApi return $list; } - + /** * Get the list of staff. * From 07bdc534dbfd2749f538302809d327566b0f84b7 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 27 Sep 2021 10:34:31 +0200 Subject: [PATCH 020/113] NEW : integration HRM sql and migrations files --- .../install/mysql/migration/14.0.0-15.0.0.sql | 218 ++++++++++++++++++ .../mysql/tables/llx_hrm_evaluation.key.sql | 29 +++ .../mysql/tables/llx_hrm_evaluation.sql | 37 +++ .../llx_hrm_evaluation_extrafields.key.sql | 21 ++ .../tables/llx_hrm_evaluation_extrafields.sql | 25 ++ .../tables/llx_hrm_evaluationdet.key.sql | 29 +++ .../mysql/tables/llx_hrm_evaluationdet.sql | 32 +++ .../llx_hrm_evaluationdet_extrafields.key.sql | 21 ++ .../llx_hrm_evaluationdet_extrafields.sql | 24 ++ .../install/mysql/tables/llx_hrm_job.key.sql | 27 +++ htdocs/install/mysql/tables/llx_hrm_job.sql | 32 +++ .../tables/llx_hrm_job_extrafields.key.sql | 21 ++ .../mysql/tables/llx_hrm_job_extrafields.sql | 25 ++ .../mysql/tables/llx_hrm_position.key.sql | 27 +++ .../install/mysql/tables/llx_hrm_position.sql | 36 +++ .../llx_hrm_position_extrafields.key.sql | 21 ++ .../tables/llx_hrm_position_extrafields.sql | 25 ++ .../mysql/tables/llx_hrm_skill.key.sql | 28 +++ htdocs/install/mysql/tables/llx_hrm_skill.sql | 35 +++ .../tables/llx_hrm_skill_extrafields.key.sql | 21 ++ .../tables/llx_hrm_skill_extrafields.sql | 25 ++ .../mysql/tables/llx_hrm_skilldet.key.sql | 27 +++ .../install/mysql/tables/llx_hrm_skilldet.sql | 28 +++ .../llx_hrm_skilldet_extrafields.key.sql | 21 ++ .../tables/llx_hrm_skilldet_extrafields.sql | 24 ++ .../mysql/tables/llx_hrm_skillrank.key.sql | 27 +++ .../mysql/tables/llx_hrm_skillrank.sql | 30 +++ 27 files changed, 916 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_hrm_evaluation.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_evaluation.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_evaluationdet.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_evaluationdet.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_job.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_job.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_job_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_job_extrafields.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_position.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_position.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_position_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_position_extrafields.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_skill.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_skill.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_skill_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_skill_extrafields.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_skilldet.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_skilldet.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_skillrank.key.sql create mode 100644 htdocs/install/mysql/tables/llx_hrm_skillrank.sql diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 9555bcd15da..951f9bf2bd1 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -128,3 +128,221 @@ ALTER TABLE llx_product_lot ADD COLUMN barcode varchar(180) DEFAULT NULL; ALTER TABLE llx_product_lot ADD COLUMN fk_barcode_type integer DEFAULT NULL; ALTER TABLE llx_projet ADD COLUMN max_attendees integer DEFAULT 0; + +-- START GRH/HRM MODULE + + +CREATE TABLE llx_hrm_evaluation( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + label varchar(255), + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status smallint NOT NULL, + date_eval date, + fk_user integer NOT NULL, + fk_job integer NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; +ALTER TABLE llx_hrm_evaluation ADD INDEX idx_hrm_evaluation_rowid (rowid); +ALTER TABLE llx_hrm_evaluation ADD INDEX idx_hrm_evaluation_ref (ref); +ALTER TABLE llx_hrm_evaluation ADD CONSTRAINT llx_hrm_evaluation_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_hrm_evaluation ADD INDEX idx_hrm_evaluation_status (status); + + +create table llx_hrm_evaluation_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_hrm_evaluation_extrafields ADD INDEX idx_evaluation_fk_object(fk_object); + + +CREATE TABLE llx_hrm_evaluationdet( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + fk_skill integer NOT NULL, + fk_evaluation integer NOT NULL, + rank integer NOT NULL, + required_rank integer NOT NULL, + import_key varchar(14) + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; + +ALTER TABLE llx_hrm_evaluationdet ADD INDEX idx_hrm_evaluationdet_rowid (rowid); +ALTER TABLE llx_hrm_evaluationdet ADD CONSTRAINT llx_hrm_evaluationdet_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_hrm_evaluationdet ADD INDEX idx_hrm_evaluationdet_fk_skill (fk_skill); +ALTER TABLE llx_hrm_evaluationdet ADD INDEX idx_hrm_evaluationdet_fk_evaluation (fk_evaluation); + + +create table llx_hrm_evaluationdet_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_hrm_evaluationdet_extrafields ADD INDEX idx_evaluationdet_fk_object(fk_object); + + + + +CREATE TABLE llx_hrm_job( + + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + label varchar(255) NOT NULL, + description text, + date_creation datetime NOT NULL, + tms timestamp, + deplacement varchar(255), + note_public text, + note_private text, + fk_user_creat integer, + fk_user_modif integer + +) ENGINE=innodb; + +ALTER TABLE llx_hrm_job ADD INDEX idx_hrm_job_rowid (rowid); +ALTER TABLE llx_hrm_job ADD INDEX idx_hrm_job_label (label); + + +create table llx_hrm_job_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_hrm_job_extrafields ADD INDEX idx_job_fk_object(fk_object); + + + +CREATE TABLE llx_hrm_position( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + -- ref varchar(128) NOT NULL, + description text, + date_creation datetime NOT NULL, + tms timestamp, + fk_contrat integer, + fk_user integer NOT NULL, + fk_job integer NOT NULL, + date_start date, + date_end date, + commentaire_abandon varchar(255), + note_public text, + note_private text, + fk_user_creat integer, + fk_user_modif integer + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; + +ALTER TABLE llx_hrm_position ADD INDEX idx_hrm_position_rowid (rowid); +-- ALTER TABLE llx_hrm_position ADD INDEX idx_hrm_position_ref (ref); + + +create table llx_hrm_position_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_hrm_position_extrafields ADD INDEX idx_position_fk_object(fk_object); + + + +CREATE TABLE llx_hrm_skill( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + label varchar(255), + description text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + required_level integer NOT NULL, + date_validite integer NOT NULL, + temps_theorique double(24,8) NOT NULL, + skill_type integer NOT NULL, + note_public text, + note_private text + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; + +ALTER TABLE llx_hrm_skill ADD INDEX idx_hrm_skill_rowid (rowid); +ALTER TABLE llx_hrm_skill ADD CONSTRAINT llx_hrm_skill_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_hrm_skill ADD INDEX idx_hrm_skill_skill_type (skill_type); + +create table llx_hrm_skill_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_hrm_skill_extrafields ADD INDEX idx_skill_fk_object(fk_object); + + +CREATE TABLE llx_hrm_skilldet( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + description text, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + fk_skill integer NOT NULL, + rank integer + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; + +ALTER TABLE llx_hrm_skilldet ADD INDEX idx_hrm_skilldet_rowid (rowid); +ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); + +create table llx_hrm_skilldet_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_hrm_skilldet_extrafields ADD INDEX idx_skilldet_fk_object(fk_object); + + +CREATE TABLE llx_hrm_skillrank( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + fk_skill integer NOT NULL, + rank integer NOT NULL, + fk_object integer NOT NULL, + date_creation datetime NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + objecttype varchar(128) NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; + +ALTER TABLE llx_hrm_skillrank ADD INDEX idx_hrm_skillrank_rowid (rowid); +ALTER TABLE llx_hrm_skillrank ADD INDEX idx_hrm_skillrank_fk_skill (fk_skill); +ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); + +--END GRH/HRM MODULE diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluation.key.sql b/htdocs/install/mysql/tables/llx_hrm_evaluation.key.sql new file mode 100644 index 00000000000..804bc6b4803 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_evaluation.key.sql @@ -0,0 +1,29 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_evaluation ADD INDEX idx_hrm_evaluation_rowid (rowid); +ALTER TABLE llx_hrm_evaluation ADD INDEX idx_hrm_evaluation_ref (ref); +ALTER TABLE llx_hrm_evaluation ADD CONSTRAINT llx_hrm_evaluation_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_hrm_evaluation ADD INDEX idx_hrm_evaluation_status (status); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_hrm_evaluation ADD UNIQUE INDEX uk_hrm_evaluation_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_hrm_evaluation ADD CONSTRAINT llx_hrm_evaluation_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluation.sql b/htdocs/install/mysql/tables/llx_hrm_evaluation.sql new file mode 100644 index 00000000000..bc9b7a1effc --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_evaluation.sql @@ -0,0 +1,37 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +CREATE TABLE llx_hrm_evaluation( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + label varchar(255), + description text, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status smallint NOT NULL, + date_eval date, + fk_user integer NOT NULL, + fk_job integer NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.key.sql new file mode 100644 index 00000000000..ff9ba9d6cb6 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.key.sql @@ -0,0 +1,21 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_evaluation_extrafields ADD INDEX idx_evaluation_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.sql new file mode 100644 index 00000000000..da00cc3c333 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.sql @@ -0,0 +1,25 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +create table llx_hrm_evaluation_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet.key.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet.key.sql new file mode 100644 index 00000000000..05309ce57e2 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_evaluationdet.key.sql @@ -0,0 +1,29 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_evaluationdet ADD INDEX idx_hrm_evaluationdet_rowid (rowid); +ALTER TABLE llx_hrm_evaluationdet ADD CONSTRAINT llx_hrm_evaluationdet_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_hrm_evaluationdet ADD INDEX idx_hrm_evaluationdet_fk_skill (fk_skill); +ALTER TABLE llx_hrm_evaluationdet ADD INDEX idx_hrm_evaluationdet_fk_evaluation (fk_evaluation); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_hrm_evaluationdet ADD UNIQUE INDEX uk_hrm_evaluationdet_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_hrm_evaluationdet ADD CONSTRAINT llx_hrm_evaluationdet_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet.sql new file mode 100644 index 00000000000..0509cc80146 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_evaluationdet.sql @@ -0,0 +1,32 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +CREATE TABLE llx_hrm_evaluationdet( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + fk_skill integer NOT NULL, + fk_evaluation integer NOT NULL, + rank integer NOT NULL, + required_rank integer NOT NULL, + import_key varchar(14) + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.key.sql new file mode 100644 index 00000000000..5072e2eb67b --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.key.sql @@ -0,0 +1,21 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_evaluationdet_extrafields ADD INDEX idx_evaluationdet_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.sql new file mode 100644 index 00000000000..4d4031ba228 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.sql @@ -0,0 +1,24 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +create table llx_hrm_evaluationdet_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_hrm_job.key.sql b/htdocs/install/mysql/tables/llx_hrm_job.key.sql new file mode 100644 index 00000000000..6fe7da6016e --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_job.key.sql @@ -0,0 +1,27 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_job ADD INDEX idx_hrm_job_rowid (rowid); +ALTER TABLE llx_hrm_job ADD INDEX idx_hrm_job_label (label); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_hrm_job ADD UNIQUE INDEX uk_hrm_job_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_hrm_job ADD CONSTRAINT llx_hrm_job_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_hrm_job.sql b/htdocs/install/mysql/tables/llx_hrm_job.sql new file mode 100644 index 00000000000..51f472af377 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_job.sql @@ -0,0 +1,32 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +CREATE TABLE llx_hrm_job( + + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + label varchar(255) NOT NULL, + description text, + date_creation datetime NOT NULL, + tms timestamp, + deplacement varchar(255), + note_public text, + note_private text, + fk_user_creat integer, + fk_user_modif integer + +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_hrm_job_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_job_extrafields.key.sql new file mode 100644 index 00000000000..b5226dc4c38 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_job_extrafields.key.sql @@ -0,0 +1,21 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_job_extrafields ADD INDEX idx_job_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_hrm_job_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_job_extrafields.sql new file mode 100644 index 00000000000..10cccf1c36f --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_job_extrafields.sql @@ -0,0 +1,25 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +create table llx_hrm_job_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_hrm_position.key.sql b/htdocs/install/mysql/tables/llx_hrm_position.key.sql new file mode 100644 index 00000000000..40f0d8db97c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_position.key.sql @@ -0,0 +1,27 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_position ADD INDEX idx_hrm_position_rowid (rowid); +-- ALTER TABLE llx_hrm_position ADD INDEX idx_hrm_position_ref (ref); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_hrm_position ADD UNIQUE INDEX uk_hrm_position_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_hrm_position ADD CONSTRAINT llx_hrm_position_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_hrm_position.sql b/htdocs/install/mysql/tables/llx_hrm_position.sql new file mode 100644 index 00000000000..9a470b516ce --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_position.sql @@ -0,0 +1,36 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +CREATE TABLE llx_hrm_position( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + -- ref varchar(128) NOT NULL, + description text, + date_creation datetime NOT NULL, + tms timestamp, + fk_contrat integer, + fk_user integer NOT NULL, + fk_job integer NOT NULL, + date_start datetime, + date_end datetime, + commentaire_abandon varchar(255), + note_public text, + note_private text, + fk_user_creat integer, + fk_user_modif integer + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_hrm_position_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_position_extrafields.key.sql new file mode 100644 index 00000000000..a5fdca5a068 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_position_extrafields.key.sql @@ -0,0 +1,21 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_position_extrafields ADD INDEX idx_position_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_hrm_position_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_position_extrafields.sql new file mode 100644 index 00000000000..0b93df9083a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_position_extrafields.sql @@ -0,0 +1,25 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +create table llx_hrm_position_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_hrm_skill.key.sql b/htdocs/install/mysql/tables/llx_hrm_skill.key.sql new file mode 100644 index 00000000000..b3196bf8522 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_skill.key.sql @@ -0,0 +1,28 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_skill ADD INDEX idx_hrm_skill_rowid (rowid); +ALTER TABLE llx_hrm_skill ADD CONSTRAINT llx_hrm_skill_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +ALTER TABLE llx_hrm_skill ADD INDEX idx_hrm_skill_skill_type (skill_type); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_hrm_skill ADD UNIQUE INDEX uk_hrm_skill_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_hrm_skill ADD CONSTRAINT llx_hrm_skill_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_hrm_skill.sql b/htdocs/install/mysql/tables/llx_hrm_skill.sql new file mode 100644 index 00000000000..96a31be588a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_skill.sql @@ -0,0 +1,35 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +CREATE TABLE llx_hrm_skill( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + label varchar(255), + description text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + required_level integer NOT NULL, + date_validite integer NOT NULL, + temps_theorique double(24,8) NOT NULL, + skill_type integer NOT NULL, + note_public text, + note_private text + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_hrm_skill_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_skill_extrafields.key.sql new file mode 100644 index 00000000000..a4ae591731e --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_skill_extrafields.key.sql @@ -0,0 +1,21 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_skill_extrafields ADD INDEX idx_skill_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_hrm_skill_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_skill_extrafields.sql new file mode 100644 index 00000000000..d47657e34f8 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_skill_extrafields.sql @@ -0,0 +1,25 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +create table llx_hrm_skill_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet.key.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet.key.sql new file mode 100644 index 00000000000..289276e07b5 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_skilldet.key.sql @@ -0,0 +1,27 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_skilldet ADD INDEX idx_hrm_skilldet_rowid (rowid); +ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_hrm_skilldet ADD UNIQUE INDEX uk_hrm_skilldet_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet.sql new file mode 100644 index 00000000000..fba82645915 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_skilldet.sql @@ -0,0 +1,28 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +CREATE TABLE llx_hrm_skilldet( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + description text, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + fk_skill integer NOT NULL, + rank integer + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.key.sql new file mode 100644 index 00000000000..319eb193a18 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.key.sql @@ -0,0 +1,21 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_skilldet_extrafields ADD INDEX idx_skilldet_fk_object(fk_object); +-- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.sql new file mode 100644 index 00000000000..a6e14f476c0 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.sql @@ -0,0 +1,24 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + +create table llx_hrm_skilldet_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_hrm_skillrank.key.sql b/htdocs/install/mysql/tables/llx_hrm_skillrank.key.sql new file mode 100644 index 00000000000..11d89b0187c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_skillrank.key.sql @@ -0,0 +1,27 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +-- BEGIN MODULEBUILDER INDEXES +ALTER TABLE llx_hrm_skillrank ADD INDEX idx_hrm_skillrank_rowid (rowid); +ALTER TABLE llx_hrm_skillrank ADD INDEX idx_hrm_skillrank_fk_skill (fk_skill); +ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); +-- END MODULEBUILDER INDEXES + +--ALTER TABLE llx_hrm_skillrank ADD UNIQUE INDEX uk_hrm_skillrank_fieldxy(fieldx, fieldy); + +--ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); + diff --git a/htdocs/install/mysql/tables/llx_hrm_skillrank.sql b/htdocs/install/mysql/tables/llx_hrm_skillrank.sql new file mode 100644 index 00000000000..5c4deb95938 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_hrm_skillrank.sql @@ -0,0 +1,30 @@ +-- Copyright (C) 2021 Gauthier VERDOL +-- Copyright (C) 2021 Greg Rastklan +-- Copyright (C) 2021 Jean-Pascal BOUDET +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see https://www.gnu.org/licenses/. + + +CREATE TABLE llx_hrm_skillrank( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + fk_skill integer NOT NULL, + rank integer NOT NULL, + fk_object integer NOT NULL, + date_creation datetime NOT NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + objecttype varchar(128) NOT NULL + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; From 6abe6462e6c1dde1f9e1cba2ba2049e52723e512 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 27 Sep 2021 14:33:57 +0200 Subject: [PATCH 021/113] FIX: products/services card: hidden extrafields were overridden --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index d74cab0ada4..542c66dee25 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -487,7 +487,7 @@ if (empty($reshook)) if ($accountancy_code_buy_export <= 0) { $object->accountancy_code_buy_export = ''; } else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; } // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; if (!$error && $object->check()) From 2472dff67bd84284d36a121c4e5f832b19c51272 Mon Sep 17 00:00:00 2001 From: Indelog Date: Tue, 28 Sep 2021 12:08:45 +0200 Subject: [PATCH 022/113] Fix FormFile::list_of_autoecmfiles object_instance classname after hook FormFile::list_of_autoecmfiles() can instantiate object with parameters resulting of hook `addSectionECMAuto` but for do this, it use `${$hookmanager->resArray['classname']}` which return a `null`. Instead we should do this `$hookmanager->resArray['classname']`. --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 60054ecf5ad..71d8c02b5f2 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1672,7 +1672,7 @@ class FormFile dol_include_once($hookmanager->resArray['classpath']); if (array_key_exists('classname', $hookmanager->resArray) && !empty($hookmanager->resArray['classname'])) { if (class_exists($hookmanager->resArray['classname'])) { - $object_instance = new ${$hookmanager->resArray['classname']}($this->db); + $object_instance = new $hookmanager->resArray['classname']($this->db); } } } From 1199782d61e16da2370c9ce6a57c0f99bcd50c5a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 28 Sep 2021 13:10:46 +0200 Subject: [PATCH 023/113] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index b957feda82c..3ebb0252500 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1298,7 +1298,6 @@ class Setup extends DolibarrApi { $list = array(); - //TODO link with multicurrency module $sql = "SELECT t.id, t.code, t.libelle, t.active, t.module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif as t"; $sql .= " WHERE t.active = ".((int) $active); From d43cf4938a43208d81509702560f0cefea466a97 Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Tue, 28 Sep 2021 13:46:03 +0200 Subject: [PATCH 024/113] it was impossible to update a task after some investigation i saw those errors but they are maybe some more around here --- htdocs/projet/class/api_tasks.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index e3d6af2de53..9366422002d 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -454,7 +454,7 @@ class Tasks extends DolibarrApi throw new RestException(404, 'Task not found'); } - if (!DolibarrApi::_checkAccessToResource('tasks', $this->project->id)) { + if (!DolibarrApi::_checkAccessToResource('task', $this->task->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { @@ -488,7 +488,7 @@ class Tasks extends DolibarrApi throw new RestException(404, 'Task not found'); } - if (!DolibarrApi::_checkAccessToResource('tasks', $this->project->id)) { + if (!DolibarrApi::_checkAccessToResource('task', $this->task->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } From d565f9d3f1005689749e6a3f8bb064a5440f127c Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 28 Sep 2021 15:09:47 +0200 Subject: [PATCH 025/113] reveiw code --- .../class/accountingaccount.class.php | 29 ++++++++++--------- htdocs/accountancy/customer/index.php | 2 +- htdocs/accountancy/customer/list.php | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 7ec07d1f15b..ed3c69c18bc 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -732,7 +732,8 @@ class AccountingAccount extends CommonObject /** * Return Suggest accounting accounts to bind * - * @param Societe $thirdparty Societe Object seller or Buyers + * @param Societe $buyer Societe Object Buyers + * @param $seller Company Object seller * @param Product $product Product object sell or buy * @param Facture $facture Facture * @param FactureLigne $factureDet Facture Det @@ -740,22 +741,22 @@ class AccountingAccount extends CommonObject * * @return array Accounting accounts suggested */ - public function getAccountingCodeToBind(Societe $thirdparty, Product $product, Facture $facture, FactureLigne $factureDet, $accountingAccount = array()) + public function getAccountingCodeToBind(Societe $buyer, $seller, Product $product, Facture $facture, FactureLigne $factureDet, $accountingAccount = array()) { - global $mysoc, $conf; + global $conf; global $hookmanager; // Instantiate hooks for external modules $hookmanager->initHooks(array('accoutancyBindingCalculation')); // Execute hook accoutancyBindingCalculation - $parameters = array('thirdparty' => $thirdparty, 'product' => $product, 'facture' => $facture, 'factureDet' => $factureDet ,'accountingAccount'=>$accountingAccount); + $parameters = array('buyer' => $buyer, 'seller' => $seller, 'product' => $product, 'facture' => $facture, 'factureDet' => $factureDet ,'accountingAccount'=>$accountingAccount); $reshook = $hookmanager->executeHooks('accoutancyBindingCalculation', $parameters); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; - $isBuyerInEEC = isInEEC($thirdparty); - $isSellerInEEC = isInEEC($mysoc); + $isBuyerInEEC = isInEEC($buyer); + $isSellerInEEC = isInEEC($seller); $code_sell_l = ''; $code_sell_p = ''; $code_sell_t = ''; @@ -764,14 +765,14 @@ class AccountingAccount extends CommonObject // Level 1: Search suggested default account for product/service $suggestedaccountingaccountbydefaultfor = ''; if ($factureDet->product_type == 1) { - if ($thirdparty->country_code == $mysoc->country_code || empty($thirdparty->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + if ($buyer->country_code == $seller->country_code || empty($buyer->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) $code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with a VAT $code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($thirdparty->tva_intra)) { // European intravat sale, without VAT intra community number + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { // European intravat sale, without VAT intra community number $code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale @@ -783,14 +784,14 @@ class AccountingAccount extends CommonObject } } } elseif ($factureDet->product_type == 0) { - if ($thirdparty->country_code == $mysoc->country_code || empty($thirdparty->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + if ($buyer->country_code == $seller->country_code || empty($buyer->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) $code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC && $factureDet->tva_tx != 0) { // European intravat sale, but with a VAT $code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($thirdparty->tva_intra)) { // European intravat sale, without VAT intra community number + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra)) { // European intravat sale, without VAT intra community number $code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber'; } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale @@ -808,7 +809,7 @@ class AccountingAccount extends CommonObject // Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding) $suggestedaccountingaccountfor = ''; - if ((($thirdparty->country_code == $mysoc->country_code) || empty($thirdparty->country_code)) && !empty($product->accountancy_code_sell)) { // If buyer in same country than seller (if not defined, we assume it is same country) + if ((($buyer->country_code == $seller->country_code) || empty($buyer->country_code)) && !empty($product->accountancy_code_sell)) { // If buyer in same country than seller (if not defined, we assume it is same country) $code_sell_p = $product->accountancy_code_sell; $suggestedid = $accountingAccount['dom']; $suggestedaccountingaccountfor = 'prodserv'; @@ -817,7 +818,7 @@ class AccountingAccount extends CommonObject $code_sell_p = $product->accountancy_code_sell; $suggestedid = $accountingAccount['dom']; $suggestedaccountingaccountfor = 'eecwithvat'; - } elseif ($isSellerInEEC && $isBuyerInEEC && empty($thirdparty->tva_intra) && !empty($product->accountancy_code_sell)) { // European intravat sale, without VAT intra community number + } elseif ($isSellerInEEC && $isBuyerInEEC && empty($buyer->tva_intra) && !empty($product->accountancy_code_sell)) { // European intravat sale, without VAT intra community number $code_sell_p = $product->accountancy_code_sell; $suggestedid = $accountingAccount['dom']; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ? $suggestedaccountingaccountfor = 'eecwithoutvatnumber'; @@ -834,8 +835,8 @@ class AccountingAccount extends CommonObject // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding) if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) { - if (!empty($thirdparty->code_compta)) { - $code_sell_t = $thirdparty->code_compta; + if (!empty($buyer->code_compta)) { + $code_sell_t = $buyer->code_compta; $suggestedid = $accountingAccount['thirdparty']; $suggestedaccountingaccountfor = 'thridparty'; } diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 4fe6bd8cae9..7c3cc2cf0e2 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -232,7 +232,7 @@ if ($action == 'validatehistory') { $code_sell_p_notset = ''; $code_sell_t_notset = ''; - $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $product_static, $facture_static, $facture_static_det, $accoutinAccountArray); + $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $mysoc, $product_static, $facture_static, $facture_static_det, $accoutinAccountArray); if (!is_array($return) && $return<0) { setEventMessage($accountingAccount->error, 'errors'); } else { diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 0435f6cfafe..a730a8a9af6 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -573,7 +573,7 @@ if ($result) { $code_sell_p_notset = ''; $code_sell_t_notset = ''; - $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $product_static, $facture_static, $facture_static_det, $accoutinAccountArray); + $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $mysoc, $product_static, $facture_static, $facture_static_det, $accoutinAccountArray); if (!is_array($return) && $return<0) { setEventMessage($accountingAccount->error, 'errors'); } else { From 5b8b55cfba0e9459126fcffb6f2923b472cea8ba Mon Sep 17 00:00:00 2001 From: Indelog Date: Tue, 28 Sep 2021 15:26:08 +0200 Subject: [PATCH 026/113] Fix append module suffix on src_object_type when create ecm file Files added to `llx_ecm_files` for externals modules never be removed on object deletion. When `CommonObject::deleteEcmFiles()` is called with `mode=1`, it use this sql filter to find the file related to the object which is removed : ``` $sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".((int) $this->id).")"; ``` We see it append `'@'.$this->module` to `$this->table_element` but when file is add to the `llx_ecm_files` by `CommonObject::commonGenerateDocument()` , it added whiteout the `'@'.$this->module` suffix. So the file is never remove from `llx_ecm_files` when object is deleted. This fix it by appending module suffix on `src_object_type` if object has `module` property when add document to the `llx_ecm_files`. --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d53b8829686..858d21d5e4d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5297,7 +5297,7 @@ abstract class CommonObject $ecmfile->gen_or_uploaded = 'generated'; $ecmfile->description = ''; // indexed content $ecmfile->keywords = ''; // keyword content - $ecmfile->src_object_type = $this->table_element; + $ecmfile->src_object_type = $this->table_element.(empty($this->module) ? '' : '@'.$this->module); $ecmfile->src_object_id = $this->id; $result = $ecmfile->create($user); From fae0337b3e58cc160afdd2bc20343a6563af47c2 Mon Sep 17 00:00:00 2001 From: Indelog Date: Tue, 28 Sep 2021 16:22:28 +0200 Subject: [PATCH 027/113] Fix show for external module in ecm index auto page This set the correct `modulepart` parameter for link generated to `document.php` of ecm auto index page if `src_object_type` for ecm document has a module suffix (`@modulename`). --- htdocs/core/class/html.formfile.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 60054ecf5ad..55460c587d8 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1811,9 +1811,11 @@ class FormFile print ''; // File + // Check if document source has external module part, if it the case use it for module part on document.php + preg_match('/^[^@]*@([^@]*)$/', $modulepart.'@expertisemedical', $modulesuffix); print '
\n"; From 43a47999d7261f60430bcb64a76e3aa8fd575fb6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 28 Sep 2021 16:35:01 +0200 Subject: [PATCH 028/113] FIX avoid warning if $categories is an id --- htdocs/core/class/commonobject.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d53b8829686..ee1d9b51ede 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9135,6 +9135,11 @@ abstract class CommonObject */ public function setCategoriesCommon($categories, $type_categ = '', $remove_existing = true) { + // Handle single category + if (!is_array($categories)) { + $categories = array($categories); + } + dol_syslog(get_class($this)."::setCategoriesCommon Oject Id:".$this->id.' type_categ:'.$type_categ.' nb tag add:'.count($categories), LOG_DEBUG); require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; @@ -9144,11 +9149,6 @@ abstract class CommonObject return -1; } - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } - // Get current categories $c = new Categorie($this->db); $existing = $c->containing($this->id, $type_categ, 'id'); From b6bb27e0f743ac767c27f94d8bf60666d1c61681 Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Tue, 28 Sep 2021 17:21:22 +0200 Subject: [PATCH 029/113] FIX: #18848 --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 9fd88f44d4f..fc447980780 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1503,7 +1503,7 @@ class Account extends CommonObject { $country_code = $this->getCountryCode(); - if (in_array($country_code, array('FR', 'ES', 'GA', 'IT', 'NC'))) { + if (in_array($country_code, array('AD','FR', 'ES', 'GA', 'IT', 'NC'))) { return 1; // France, Spain, Gabon, ... - Not valid for CH } if (in_array($country_code, array('AU', 'BE', 'CA', 'DE', 'DK', 'GR', 'GB', 'ID', 'IE', 'IR', 'KR', 'NL', 'NZ', 'UK', 'US'))) { From f6c8932cfa3890168c02ae7c2c998729bb4a24c6 Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Tue, 28 Sep 2021 17:25:31 +0200 Subject: [PATCH 030/113] Update account.class.php --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index fc447980780..a852e351f22 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1503,7 +1503,7 @@ class Account extends CommonObject { $country_code = $this->getCountryCode(); - if (in_array($country_code, array('AD','FR', 'ES', 'GA', 'IT', 'NC'))) { + if (in_array($country_code, array('AD', 'FR', 'ES', 'GA', 'IT', 'NC'))) { return 1; // France, Spain, Gabon, ... - Not valid for CH } if (in_array($country_code, array('AU', 'BE', 'CA', 'DE', 'DK', 'GR', 'GB', 'ID', 'IE', 'IR', 'KR', 'NL', 'NZ', 'UK', 'US'))) { From 1b714042252e1bde92e8eea1a555e7edc6bc6723 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 28 Sep 2021 20:27:45 +0200 Subject: [PATCH 031/113] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 65 +++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 3ebb0252500..26732863dc7 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2017 Regis Houssin * Copyright (C) 2017 Neil Orley * Copyright (C) 2018-2021 Frédéric France - * Copyright (C) 2018-2020 Thibault FOUCART + * Copyright (C) 2018-2021 Thibault FOUCART * * * This program is free software; you can redistribute it and/or modify @@ -1239,7 +1239,6 @@ class Setup extends DolibarrApi { $list = array(); - //TODO link with multicurrency module $sql = "SELECT t.rowid, t.code, t.label,t.short_label, t.active, t.scale, t.unit_type"; $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; $sql .= " WHERE t.active = ".((int) $active); @@ -1280,6 +1279,68 @@ class Setup extends DolibarrApi } /** + * Get the list of legal form of business. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param string $country To filter on country + * @param int $active Lega form is active or not {@min 0} {@max 1} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return array List of legal form + * + * @url GET dictionary/legal_form + * + * @throws RestException + */ + public function getListOfLegalForm($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $country = '', $active = 1, $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT t.rowid, t.code, t.fk_pays, t.libelle, t.isvatexempted, t.active, t.module, t.position"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as t"; + $sql .= " WHERE t.active = ".((int) $active); + if ($country) { + $sql .= " AND t.fk_pays = '".$this->db->escape($country)."'"; + } + // Add sql filters + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql .= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of legal form: '.$this->db->lasterror()); + } + + return $list; + } + +/** * Get the list of staff. * * @param string $sortfield Sort field From 4d62aff8aa0983a59cd4be0d6f5f1d33795710c2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 28 Sep 2021 18:29:50 +0000 Subject: [PATCH 032/113] Fixing style errors. --- htdocs/api/class/api_setup.class.php | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 26732863dc7..6892092a8a3 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1339,22 +1339,22 @@ class Setup extends DolibarrApi return $list; } - -/** - * Get the list of staff. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number (starting from zero) - * @param int $active Staff is active or not {@min 0} {@max 1} - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return array List of staff - * - * @url GET dictionary/staff - * - * @throws RestException - */ + + /** + * Get the list of staff. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param int $active Staff is active or not {@min 0} {@max 1} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return array List of staff + * + * @url GET dictionary/staff + * + * @throws RestException + */ public function getListOfStaff($sortfield = "id", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); From baadf2dc6c7de60b7ba97ff608eaa1f8a8f82d9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 01:51:34 +0200 Subject: [PATCH 033/113] Fix reposition --- htdocs/core/class/html.formfile.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 60054ecf5ad..61c6ff3b310 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -136,6 +136,7 @@ class FormFile $out .= ''."\n"; $out .= ''."\n"; $out .= ''."\n"; + $out .= ''."\n"; } $out .= '
'.$langs->trans('Rank').''.$langs->trans('ComposedProduct').''.$langs->trans('Label').''.$langs->trans('MinSupplierPrice').''.$langs->trans('Qty').''.$langs->trans('ComposedProductIncDecStock').'
'.$object->sousprods[$parent_label][$value['id']][7].''.($value['incdec'] == 1 ? 'x' : '').''; + print '
'; for ($i = 0; $i < $value['level']; $i++) { print '     '; // Add indentation @@ -437,6 +456,7 @@ if ($id > 0 || !empty($ref)) { } print ''.$value['nb'].'  
'; //print "XX".$file['name']; //$file['name'] must be utf8 - print 'getDocumentsLink($modulepart, $modulesubdir, $filedir, '^'.preg_quote($file['name'],'/').'$'); - print $this->showPreview($file, $modulepart, $file['relativename']); + print $this->showPreview($file, (empty($modulesuffix) ? $modulepart : $modulesuffix[1]), $file['relativename']); print "
'; @@ -215,13 +216,13 @@ class FormFile $langs->load('link'); $out .= ''; } - $out .= 'trans("Upload").'"'; $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); $out .= '>'; if ($addcancel) { $out .= '   '; - $out .= ''; + $out .= ''; } if (!empty($conf->global->MAIN_UPLOAD_DOC)) { @@ -275,6 +276,7 @@ class FormFile $out .= ''."\n"; $out .= ''."\n"; $out .= ''."\n"; + $out .= ''."\n"; } $out .= '
'; @@ -293,7 +295,7 @@ class FormFile $out .= ''; $out .= '
'; $out .= '
'; - $out .= 'trans("ToLink").'"'; $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); $out .= '>'; $out .= '
'; From 6e08ecde0488c3defd398ab0a25f8970792431a1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 29 Sep 2021 08:47:22 +0200 Subject: [PATCH 034/113] FIX indentation --- htdocs/core/class/commonobject.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ee1d9b51ede..1eb661471ae 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9135,10 +9135,10 @@ abstract class CommonObject */ public function setCategoriesCommon($categories, $type_categ = '', $remove_existing = true) { - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } + // Handle single category + if (!is_array($categories)) { + $categories = array($categories); + } dol_syslog(get_class($this)."::setCategoriesCommon Oject Id:".$this->id.' type_categ:'.$type_categ.' nb tag add:'.count($categories), LOG_DEBUG); From 10ea7ddeef9058119a9d149b1ea2b04646f90ce5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 12:31:25 +0200 Subject: [PATCH 035/113] Fix link param --- htdocs/contrat/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 2438505a13c..bdbdb27331e 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -421,16 +421,16 @@ if ($search_dfyear != '') { if ($search_dfmonth != '') { $param .= '&search_dfmonth='.urlencode($search_dfmonth); } -if ($search_sale != '') { +if ($search_sale > 0) { $param .= '&search_sale='.urlencode($search_sale); } -if ($search_user != '') { +if ($search_user > 0) { $param .= '&search_user='.urlencode($search_user); } -if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { +if ($search_type_thirdparty > 0) { $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); } -if ($search_product_category != '') { +if ($search_product_category > 0) { $param .= '&search_product_category='.urlencode($search_product_category); } if ($show_files) { From c5d683a8bc4558c10ef2c9f4903a1ea576561937 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 12:46:30 +0200 Subject: [PATCH 036/113] Fix link param --- htdocs/contrat/list.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 83e5d3fd393..7e19ec13e22 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -431,28 +431,28 @@ if ($search_ref_supplier != '') { if ($search_op2df != '') { $param .= '&search_op2df='.urlencode($search_op2df); } -if ($search_date_startday) { +if ($search_date_startday > 0) { $param .= '&search_date_startday='.urlencode($search_date_startday); } -if ($search_date_startmonth) { +if ($search_date_startmonth > 0) { $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); } -if ($search_date_startyear) { +if ($search_date_startyear > 0) { $param .= '&search_date_startyear='.urlencode($search_date_startyear); } -if ($search_date_endday) { +if ($search_date_endday > 0) { $param .= '&search_date_endday='.urlencode($search_date_endday); } -if ($search_date_endmonth) { +if ($search_date_endmonth > 0) { $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); } -if ($search_date_endyear) { +if ($search_date_endyear > 0) { $param .= '&search_date_endyear='.urlencode($search_date_endyear); } -if ($search_dfyear != '') { +if ($search_dfyear > 0) { $param .= '&search_dfyear='.urlencode($search_dfyear); } -if ($search_dfmonth != '') { +if ($search_dfmonth > 0) { $param .= '&search_dfmonth='.urlencode($search_dfmonth); } if ($search_sale > 0) { From 0f55eea276548a1ae128f758500b10b8facae024 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 14:48:50 +0200 Subject: [PATCH 037/113] css --- htdocs/core/class/html.formticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index c37766b24df..a4b18470be4 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -762,7 +762,7 @@ class FormTicket $arraycodenotparent[] = ""; $stringtoprint = ''.$langs->trans("GroupOfTicket").' '; - $stringtoprint .= ''; $stringtoprint .= ''; $sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, "; From a395ff5ee394dfa445356fd8b3ac1b7536b31fc5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 16:19:47 +0200 Subject: [PATCH 038/113] Css --- htdocs/admin/system/perf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 758a93a765d..bbfa4b85c41 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -63,7 +63,7 @@ print '
'; print ''.$langs->trans("XDebug").': '; $test = !function_exists('xdebug_is_enabled'); if ($test) { - print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotSlowedDownByThis"); + print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' '.$langs->trans("NotSlowedDownByThis").''; } else { print img_picto('', 'warning').' '.$langs->trans("ModuleActivated", $langs->transnoentities("XDebug")); print ' - '.$langs->trans("MoreInformation").' XDebug admin page'; From 670a80c74c5b8c9d469d04ed24a01eb8fe3179ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 16:26:10 +0200 Subject: [PATCH 039/113] Trans --- htdocs/langs/en_US/printing.lang | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang index 16494583550..bd9094f213d 100644 --- a/htdocs/langs/en_US/printing.lang +++ b/htdocs/langs/en_US/printing.lang @@ -1,10 +1,10 @@ # Dolibarr language file - Source file is en_US - printing -Module64000Name=Direct Printing -Module64000Desc=Enable Direct Printing System -PrintingSetup=Setup of Direct Printing System -PrintingDesc=This module adds a Print button to various modules to allow documents to be printed directly to a printer without needing to open the document in another application. -MenuDirectPrinting=Direct Printing jobs -DirectPrint=Direct print +Module64000Name=One click Printing +Module64000Desc=Enable One click Printing System +PrintingSetup=Setup of One click Printing System +PrintingDesc=This module adds a Print button to various modules to allow documents to be printed directly to a printer with no need to open the document into another application. +MenuDirectPrinting=One click Printing jobs +DirectPrint=One click Print PrintingDriverDesc=Configuration variables for printing driver. ListDrivers=List of drivers PrintTestDesc=List of Printers. From 34dacca77c8241e97b6b0f5559a0b87b7fd04005 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 16:31:40 +0200 Subject: [PATCH 040/113] Css --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f26b18152b9..e0dcc51917b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3704,7 +3704,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'action'=>'infobox-action', 'account'=>'infobox-bank_account', 'accountline'=>'infobox-bank_account', 'accountancy'=>'infobox-bank_account', 'asset'=>'infobox-bank_account', 'bank_account'=>'bg-infobox-bank_account', 'bill'=>'infobox-commande', 'billa'=>'infobox-commande', 'billr'=>'infobox-commande', 'billd'=>'infobox-commande', - 'conferenceorbooth'=>'infobox-project', + 'margin'=>'infobox-bank_account', 'conferenceorbooth'=>'infobox-project', 'cash-register'=>'infobox-bank_account', 'contract'=>'infobox-contrat', 'check'=>'font-status4', 'collab'=>'infobox-action', 'conversation'=>'infobox-contrat', 'donation'=>'infobox-commande', 'dolly'=>'infobox-commande', 'dollyrevert'=>'flip infobox-order_supplier', 'ecm'=>'infobox-action', 'eventorganization'=>'infobox-project', From 1d35d8fd2d679c6beccc13fb034de2c4de02fe90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 16:42:52 +0200 Subject: [PATCH 041/113] CSS popup company --- htdocs/societe/class/societe.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e7597b311c2..818d5249a6c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2575,13 +2575,13 @@ class Societe extends CommonObject $label .= ' '.$this->getLibStatut(5); } - if (!empty($this->name)) { - $label .= '
'.$langs->trans('Name').': '.dol_escape_htmltag($this->name); - if (!empty($this->name_alias)) { - $label .= ' ('.dol_escape_htmltag($this->name_alias).')'; - } + $label .= '
'.$langs->trans('Name').': '.dol_escape_htmltag($this->name); + if (!empty($this->name_alias)) { + $label .= ' ('.dol_escape_htmltag($this->name_alias).')'; + } + if ($this->email) { + $label .= '
'.img_picto('', 'email', 'class="pictofixedwidth"').$this->email; } - $label .= '
'.img_picto('', 'email', 'class="pictofixedwidth"').$this->email; if (!empty($this->phone) || !empty($this->fax)) { $phonelist = array(); if ($this->phone) { From 52fb627a64501c9d3f099450403f4bb46f9463c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 16:45:48 +0200 Subject: [PATCH 042/113] Look and feel v14 --- htdocs/adherents/type.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 10560d38648..76099ff7d66 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -318,6 +318,19 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ""; $i++; } + + // If no record found + if ($num == 0) { + /*$colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + }*/ + $colspan = 8; + print '
'; + } + print "
'.$langs->trans("NoRecordFound").'
"; print ''; From 2dd55301deb1e41310893bbb292ea17466b3201e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 17:06:51 +0200 Subject: [PATCH 043/113] Fix duplicate field and look and feel --- htdocs/opensurvey/card.php | 20 ++++++-------------- htdocs/opensurvey/wizard/create_survey.php | 6 +++--- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index fd9fa3e0456..40e9d14adca 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -251,18 +251,6 @@ if ($action == 'edit') { } print ''; -// EMail -//If linked user, then emails are going to be sent to users' email -if (!$object->fk_user_creat) { - print ''.$langs->trans("EMail").''; - if ($action == 'edit') { - print ''; - } else { - print dol_print_email($object->mail_admin, 0, 0, 1); - } - print ''; -} - // Receive an email with each vote print ''.$langs->trans('ToReceiveEMailForEachVote').''; if ($action == 'edit') { @@ -312,10 +300,14 @@ print ''; // Author print ''; print $langs->trans("Author").''; -if ($object->fk_user_creat) { +if ($object->fk_user_creat > 0) { print $userstatic->getLoginUrl(1); } else { - print dol_htmlentities($object->nom_admin); + if ($action == 'edit') { + print ''; + } else { + print dol_print_email($object->mail_admin, 0, 0, 1); + } } print ''; diff --git a/htdocs/opensurvey/wizard/create_survey.php b/htdocs/opensurvey/wizard/create_survey.php index 30e662be7ea..6ed1f2073d2 100644 --- a/htdocs/opensurvey/wizard/create_survey.php +++ b/htdocs/opensurvey/wizard/create_survey.php @@ -170,7 +170,7 @@ if ($_SESSION["mailsonde"]) { $cochemail = "checked"; } -print ' '.$langs->trans("ToReceiveEMailForEachVote").'
'."\n"; +print '
'."\n"; if ($_SESSION['allow_comments']) { $allow_comments = 'checked'; @@ -178,7 +178,7 @@ if ($_SESSION['allow_comments']) { if (GETPOSTISSET('allow_comments')) { $allow_comments = GETPOST('allow_comments') ? 'checked' : ''; } -print ' '.$langs->trans('CanComment').'
'."\n"; +print '
'."\n"; if ($_SESSION['allow_spy']) { $allow_spy = 'checked'; @@ -186,7 +186,7 @@ if ($_SESSION['allow_spy']) { if (GETPOSTISSET('allow_spy')) { $allow_spy = GETPOST('allow_spy') ? 'checked' : ''; } -print ' '.$langs->trans('CanSeeOthersVote').'
'."\n"; +print '
'."\n"; if (GETPOST('choix_sondage')) { if (GETPOST('choix_sondage') == 'date') { From a495d5e9824458b7620551c508fb0da50026723f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 17:14:37 +0200 Subject: [PATCH 044/113] Fix translation --- htdocs/index.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/index.php b/htdocs/index.php index 0f457b0f40b..c4d3e5e4d78 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -336,6 +336,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { ), 'supplier_proposal' => array( + 'lang' => 'supplier_proposal', 'groupName' => 'SupplierProposals', 'globalStatsKey' => 'askprice', 'stats' => @@ -485,6 +486,9 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } if (!empty($boards)) { + if (!empty($groupElement['lang'])) { + $langs->load($groupElement['lang']); + } $groupName = $langs->trans($groupElement['groupName']); $groupKeyLowerCase = strtolower($groupKey); $nbTotalForGroup = 0; From 11c48a53a5cfac791d4be3c03c4d53eddcd979d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 17:20:59 +0200 Subject: [PATCH 045/113] Fix name of file --- ...n_user_group.sql => llx_workstation_workstation_usergroup.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename htdocs/install/mysql/tables/{llx_workstation_workstation_user_group.sql => llx_workstation_workstation_usergroup.sql} (100%) diff --git a/htdocs/install/mysql/tables/llx_workstation_workstation_user_group.sql b/htdocs/install/mysql/tables/llx_workstation_workstation_usergroup.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_workstation_workstation_user_group.sql rename to htdocs/install/mysql/tables/llx_workstation_workstation_usergroup.sql From 3d239e75288bb8ed97e1aca6cb5c7dd958efc74a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 17:28:06 +0200 Subject: [PATCH 046/113] Trans --- htdocs/admin/tools/purge.php | 2 +- htdocs/langs/en_US/admin.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index 09647549c8b..eb274163697 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -110,7 +110,7 @@ if (!empty($conf->syslog->enabled)) { print '

'; +print '>

'; print '%s directory). Using this feature is not normally necessary. It is provided as a workaround for users whose Dolibarr is hosted by a provider that does not offer permissions to delete files generated by the web server. PurgeDeleteLogFile=Delete log files, including %s defined for Syslog module (no risk of losing data) PurgeDeleteTemporaryFiles=Delete all log and temporary files (no risk of losing data). Parameter can be 'tempfilesold', 'logfiles' or both 'tempfilesold+logfiles'. Note: Deletion of temporary files is done only if the temp directory was created more than 24 hours ago. -PurgeDeleteTemporaryFilesShort=Delete log and temporary files +PurgeDeleteTemporaryFilesShort=Delete log and temporary files (no risk of losing data) PurgeDeleteAllFilesInDocumentsDir=Delete all files in directory: %s.
This will delete all generated documents related to elements (third parties, invoices etc...), files uploaded into the ECM module, database backup dumps and temporary files. PurgeRunNow=Purge now PurgeNothingToDelete=No directory or files to delete. From a9805fbfc19802b2ea7b824733b31082d35ec293 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Sep 2021 17:34:31 +0200 Subject: [PATCH 047/113] NEW The protection MAIN_SECURITY_CSRF_WITH_TOKEN=1 is on by default --- htdocs/core/class/conf.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index ec145f89f43..8e43a70c3fe 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -826,9 +826,10 @@ class Conf $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567'; } - // If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined. - if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $this->global->MAIN_FEATURES_LEVEL >= 2) { - $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1; + // Enable by default the CSRF protection by token. + if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) { + $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1; // Value 2 uses also CSRF check for all GET requests + // Note: Set MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL=1 to have a renewal of token at each page call instead of each session (not recommended) } if (defined('MAIN_ANTIVIRUS_COMMAND')) { From 1595b38498c3e382b898555a77c4039dfa7fdafd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 00:28:47 +0200 Subject: [PATCH 048/113] Fix param $morecss on img_mime --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2d3a69fb1ea..ef7f320f049 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4386,7 +4386,7 @@ function img_mime($file, $titlealt = '', $morecss = '') } //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"'); - return ''; + return ''; } From fca39d91792ce0cb443704c84d8af3f9f71c0739 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 01:15:36 +0200 Subject: [PATCH 049/113] css --- htdocs/compta/index.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index ca7cd08a6fe..9cb9bca667b 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -206,6 +206,7 @@ if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { print ''; print ''; + print ''; @@ -222,15 +223,19 @@ if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { print '
'; print $tmpinvoice->getNomUrl(1, ''); print '
'; print ''; - print ''; + + print ''; print $thirdpartystatic->getNomUrl(1, 'customer', 44); print ''; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) { print ''.price($obj->total_ht).''; } print ''.price($obj->total_ttc).''; + print ''.dol_print_date($db->jdate($obj->tms), 'day').''; + print ''.$tmpinvoice->getLibStatut(3, $obj->am).''; + print ''; $total_ttc += $obj->total_ttc; From 04fa5ff70b5d3d7d7526a81479e02acc67406472 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 01:50:11 +0200 Subject: [PATCH 050/113] css --- htdocs/holiday/define_holiday.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index fdcdb5f88e6..621443fb408 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -358,7 +358,7 @@ if (count($typeleaves) == 0) { //var_dump($users['rowid'].' - '.$val['rowid']); print ''; if ($canedit) { - print ''; + print ''; } else { print $nbtoshow; } From 2205073f252571615f2e47ced12273eadacd3b2c Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Thu, 30 Sep 2021 12:09:17 +0200 Subject: [PATCH 051/113] load_stats_reception is not loaded --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fd5d8ecf1db..2702f7989b3 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5306,7 +5306,7 @@ class Product extends CommonObject } $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; } - if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->reception->enabled)) { + if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && !empty($conf->reception->enabled)) { $filterStatus = '4'; if (isset($includedraftpoforvirtual)) { $filterStatus = '0,'.$filterStatus; From 4e86f872ca3b0634433fbe12a5798c880c86dab7 Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Tue, 28 Sep 2021 13:46:03 +0200 Subject: [PATCH 052/113] it was impossible to update a task after some investigation i saw those errors but they are maybe some more around here --- htdocs/projet/class/api_tasks.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index e3d6af2de53..9366422002d 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -454,7 +454,7 @@ class Tasks extends DolibarrApi throw new RestException(404, 'Task not found'); } - if (!DolibarrApi::_checkAccessToResource('tasks', $this->project->id)) { + if (!DolibarrApi::_checkAccessToResource('task', $this->task->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { @@ -488,7 +488,7 @@ class Tasks extends DolibarrApi throw new RestException(404, 'Task not found'); } - if (!DolibarrApi::_checkAccessToResource('tasks', $this->project->id)) { + if (!DolibarrApi::_checkAccessToResource('task', $this->task->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } From ae9643bbeff659ee7424cafba02eee6bfce616e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 13:38:38 +0200 Subject: [PATCH 053/113] Update html.formfile.class.php --- htdocs/core/class/html.formfile.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 71d8c02b5f2..53c00327746 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1672,7 +1672,8 @@ class FormFile dol_include_once($hookmanager->resArray['classpath']); if (array_key_exists('classname', $hookmanager->resArray) && !empty($hookmanager->resArray['classname'])) { if (class_exists($hookmanager->resArray['classname'])) { - $object_instance = new $hookmanager->resArray['classname']($this->db); + $tmpclassname = $hookmanager->resArray['classname']; + $object_instance = new $tmpclassname($this->db); } } } From 332fa77d902b87338c07904718dde58be55b3b07 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 30 Sep 2021 13:49:02 +0200 Subject: [PATCH 054/113] fix: search code on tva dict --- htdocs/admin/dict.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 5542ad43b2a..5e5793cc361 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1048,6 +1048,7 @@ if ($id) elseif ($search_code != '' && $id == 28) $sql .= natural_search("h.code", $search_code); elseif ($search_code != '' && $id == 32) $sql .= natural_search("a.code", $search_code); elseif ($search_code != '' && $id == 3) $sql .= natural_search("r.code_region", $search_code); + elseif ($search_code != '' && $id == 10) $sql .= natural_search("t.code", $search_code); elseif ($search_code != '' && $id != 9) $sql .= natural_search("code", $search_code); if ($sortfield) From 620d7109b5b243237e6a53181edcc31f63cde198 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 14:04:56 +0200 Subject: [PATCH 055/113] Update dict.php --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 5e5793cc361..32db04c455f 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1048,7 +1048,7 @@ if ($id) elseif ($search_code != '' && $id == 28) $sql .= natural_search("h.code", $search_code); elseif ($search_code != '' && $id == 32) $sql .= natural_search("a.code", $search_code); elseif ($search_code != '' && $id == 3) $sql .= natural_search("r.code_region", $search_code); - elseif ($search_code != '' && $id == 10) $sql .= natural_search("t.code", $search_code); + elseif ($search_code != '' && $id == 10) $sql .= natural_search("t.code", $search_code); elseif ($search_code != '' && $id != 9) $sql .= natural_search("code", $search_code); if ($sortfield) From c5ad75c7c12ebbd17ad1c9ba89cda8c482b3260e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 30 Sep 2021 12:27:01 +0000 Subject: [PATCH 056/113] Fixing style errors. --- htdocs/core/ajax/row.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 1f5d20af874..52cc23faf8f 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -101,7 +101,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) $perm = 1; } elseif ($table_element_line == 'product_association' && $fk_element == 'fk_product' && !empty($user->rights->produit->creer)) { $perm = 1; - } elseif ($table_element_line == 'projet_task' && $fk_element == 'fk_projet' && $user->rights->projet->creer) { + } elseif ($table_element_line == 'projet_task' && $fk_element == 'fk_projet' && $user->rights->projet->creer) { $perm = 1; } else { $tmparray = explode('_', $table_element_line); From 63218d5d5c3de75309609015d520f7c6035a144c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 14:30:50 +0200 Subject: [PATCH 057/113] Update product.class.php --- htdocs/product/class/product.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1054d747387..67521ef149b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4021,22 +4021,22 @@ class Product extends CommonObject } // Check not already father of id_pere (to avoid father -> child -> father links) - $sql = 'SELECT fk_product_pere from '.MAIN_DB_PREFIX.'product_association'; - $sql .= ' WHERE fk_product_pere = '.((int) $id_fils).' AND fk_product_fils = '.((int) $id_pere); + $sql = "SELECT fk_product_pere from ".MAIN_DB_PREFIX."product_association"; + $sql .= " WHERE fk_product_pere = ".((int) $id_fils)." AND fk_product_fils = ".((int) $id_pere); if (!$this->db->query($sql)) { dol_print_error($this->db); return -1; } else { //Selection of the highest row - $sql = 'SELECT MAX(rang) as max_rank FROM '.MAIN_DB_PREFIX.'product_association'; - $sql .= ' WHERE fk_product_pere = '.$id_pere; + $sql = "SELECT MAX(rang) as max_rank FROM ".MAIN_DB_PREFIX."product_association"; + $sql .= " WHERE fk_product_pere = ".((int) $id_pere); $resql = $this->db->query($sql); if ($resql > 0) { $obj = $this->db->fetch_object($resql); $rank = $obj->max_rank + 1; //Addition of a product with the highest rank +1 - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)'; - $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$qty.', '.$incdec.', '.$this->db->escape($rank).')'; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)"; + $sql .= " VALUES (".((int) $id_pere).", ".((int) $id_fils).", ".((float) $qty).", ".((float) $incdec).", ".$this->db->escape($rank).")"; if (! $this->db->query($sql)) { dol_print_error($this->db); return -1; From d764080636c11f653eda646100f50a1a46062c96 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 14:43:19 +0200 Subject: [PATCH 058/113] Add tag data-ignoreidfordnd=1 to ignor lines for drage and drop lines --- htdocs/core/tpl/ajaxrow.tpl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index acc5fad8125..61428170f50 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -61,6 +61,7 @@ $(document).ready(function(){ console.log("tableDND onDrop"); console.log(decodeURI($("#").tableDnDSerialize())); $('# tr[data-element=extrafield]').attr('id', ''); // Set extrafields id to empty value in order to ignore them in tableDnDSerialize function + $('# tr[data-ignoreidfordnd=1]').attr('id', ''); // Set id to empty value in order to ignore them in tableDnDSerialize function var roworder = cleanSerialize(decodeURI($("#").tableDnDSerialize())); var table_element_line = ""; var fk_element = ""; From 827639f28deb37803d7d46012df8fec261d5ee19 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 14:45:22 +0200 Subject: [PATCH 059/113] Try to solve pb of unique id --- htdocs/product/composition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index d1e59482d44..5f783d190e9 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -432,7 +432,7 @@ if ($id > 0 || !empty($ref)) { $hide = ' hideobject'; // By default, we do not show this. It makes screen very difficult to understand } - print ''; + print ''; //$productstatic->ref=$value['label']; $productstatic->ref = $value['ref']; From aaf170313f905ce4f9db3328db4419871bc91256 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 14:51:38 +0200 Subject: [PATCH 060/113] Clean code --- htdocs/product/class/product.class.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 67521ef149b..fa853dfec5e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4036,7 +4036,7 @@ class Product extends CommonObject $rank = $obj->max_rank + 1; //Addition of a product with the highest rank +1 $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_association(fk_product_pere,fk_product_fils,qty,incdec,rang)"; - $sql .= " VALUES (".((int) $id_pere).", ".((int) $id_fils).", ".((float) $qty).", ".((float) $incdec).", ".$this->db->escape($rank).")"; + $sql .= " VALUES (".((int) $id_pere).", ".((int) $id_fils).", ".price2num($qty, 'MS').", ".price2num($incdec, 'MS').", ".((int) $rank).")"; if (! $this->db->query($sql)) { dol_print_error($this->db); return -1; @@ -4092,11 +4092,11 @@ class Product extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Retire le lien entre un sousproduit et un produit/service + * Remove a link between a subproduct and a parent product/service * - * @param int $fk_parent Id du produit auquel ne sera plus lie le produit lie - * @param int $fk_child Id du produit a ne plus lie - * @return int < 0 if KO, > 0 if OK + * @param int $fk_parent Id of parent product (child will no more be linked to it) + * @param int $fk_child Id of child product + * @return int < 0 if KO, > 0 if OK */ public function del_sousproduit($fk_parent, $fk_child) { @@ -4118,18 +4118,18 @@ class Product extends CommonObject return -1; } - //Updated ranks so that none are missing - $sqlrank = 'SELECT rowid, rang FROM '.MAIN_DB_PREFIX.'product_association'; - $sqlrank.= ' WHERE fk_product_pere = '.$this->db->escape($fk_parent); - $sqlrank.= ' ORDER BY rang'; + // Updated ranks so that none are missing + $sqlrank = "SELECT rowid, rang FROM ".MAIN_DB_PREFIX."product_association"; + $sqlrank.= " WHERE fk_product_pere = ".((int) $fk_parent); + $sqlrank.= " ORDER BY rang"; $resqlrank = $this->db->query($sqlrank); if ($resqlrank) { $cpt = 0; while ($objrank = $this->db->fetch_object($resqlrank)) { $cpt++; - $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_association'; - $sql.= ' SET rang ='.$cpt; - $sql.= ' WHERE rowid ='.$this->db->escape($objrank->rowid); + $sql = "UPDATE ".MAIN_DB_PREFIX."product_association"; + $sql.= " SET rang = ".((int) $cpt); + $sql.= " WHERE rowid = ".((int) $objrank->rowid); if (! $this->db->query($sql)) { dol_print_error($this->db); return -1; From 608b6f5fa32375eacedf368880a07f91c9c26d5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 15:24:57 +0200 Subject: [PATCH 061/113] Clean code --- htdocs/accountancy/admin/card.php | 6 +-- htdocs/accountancy/journal/bankjournal.php | 4 +- htdocs/admin/multicurrency.php | 2 +- .../compta/paiement/class/paiement.class.php | 4 +- htdocs/core/class/commoninvoice.class.php | 2 +- htdocs/core/class/commonobject.class.php | 10 ++-- .../webservices/server_supplier_invoice.php | 10 ++-- test/phpunit/CodingPhpTest.php | 49 +++++++++++++++++-- 8 files changed, 61 insertions(+), 26 deletions(-) diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index cd48526e62b..4d69eae7db8 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -75,7 +75,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); $action = 'create'; } else { - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid='.((int) $conf->global->CHARTOFACCOUNTS); + $sql = "SELECT pcg_version FROM " . MAIN_DB_PREFIX . "accounting_system WHERE rowid = ".((int) $conf->global->CHARTOFACCOUNTS); dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result = $db->query($sql); @@ -138,7 +138,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) { } else { $result = $object->fetch($id); - $sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.((int) $conf->global->CHARTOFACCOUNTS); + $sql = "SELECT pcg_version FROM ".MAIN_DB_PREFIX."accounting_system WHERE rowid=".((int) $conf->global->CHARTOFACCOUNTS); dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); $result2 = $db->query($sql); @@ -260,7 +260,7 @@ if ($action == 'create') { print ''; // autosuggest from existing account types if found print ''; - $sql = 'SELECT DISTINCT pcg_type FROM ' . MAIN_DB_PREFIX . 'accounting_account'; + $sql = "SELECT DISTINCT pcg_type FROM " . MAIN_DB_PREFIX . "accounting_account"; $sql .= " WHERE fk_pcg_version = '" . $db->escape($accountsystem->ref) . "'"; $sql .= ' AND entity in ('.getEntity('accounting_account', 0).')'; // Always limit to current entity. No sharing in accountancy. $sql .= ' LIMIT 50000'; // just as a sanity check diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index d05135e7a67..4367241dbd7 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -362,7 +362,7 @@ if ($result) { // Retrieve the accounting code of the social contribution of the payment from link of payment. // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id. - $sqlmid = 'SELECT cchgsoc.accountancy_code'; + $sqlmid = "SELECT cchgsoc.accountancy_code"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; @@ -1019,7 +1019,7 @@ if (empty($action) || $action == 'view') { // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) - $sql = 'SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE entity = '.$conf->entity.' AND fk_accountancy_journal IS NULL AND clos=0'; + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."bank_account WHERE entity = ".((int) $conf->entity)." AND fk_accountancy_journal IS NULL AND clos=0"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 95b418a75f0..e8619219471 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -138,7 +138,7 @@ if ($action == 'add_currency') { $TCurrency = array(); -$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity; +$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."multicurrency WHERE entity = ".((int) $conf->entity); $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 3e1dc59a52e..aab54e4ef81 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -304,8 +304,8 @@ class Paiement extends CommonObject $facid = $key; if (is_numeric($amount) && $amount <> 0) { $amount = price2num($amount); - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)'; - $sql .= ' VALUES ('.((int) $facid).', '.((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).')'; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)"; + $sql .= " VALUES (".((int) $facid).", ".((int) $this->id).", ".((float) $amount).", ".((float) $this->multicurrency_amounts[$key]).")"; dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index dfabfd24ebe..9bd17c77ea5 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -734,7 +734,7 @@ abstract class CommonInvoice extends CommonObject $sql .= 'fk_facture, '; } $sql .= ' amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib, sourcetype, entity)'; - $sql .= ' VALUES ('.((int) $this->id); + $sql .= " VALUES (".((int) $this->id); $sql .= ", ".((float) price2num($amount)); $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", ".((int) $fuser->id); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3c95d9c26a0..ca3cc7ad39d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8682,7 +8682,7 @@ abstract class CommonObject // If field is an implicit foreign key field if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) { if (isset($this->fields[$key]['default'])) { - $values[$key] = $this->fields[$key]['default']; + $values[$key] = ((int) $this->fields[$key]['default']); } else { $values[$key] = 'null'; } @@ -8699,9 +8699,9 @@ abstract class CommonObject $this->db->begin(); if (!$error) { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' ('.implode(", ", $keys).')'; - $sql .= ' VALUES ('.implode(", ", $values).')'; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " (".implode(", ", $keys).')'; + $sql .= " VALUES (".implode(", ", $values).")"; // $values can contains 'abc' or 123 $res = $this->db->query($sql); if ($res === false) { @@ -8717,7 +8717,7 @@ abstract class CommonObject // If we have a field ref with a default value of (PROV) if (!$error) { if (key_exists('ref', $this->fields) && $this->fields['ref']['notnull'] > 0 && key_exists('default', $this->fields['ref']) && $this->fields['ref']['default'] == '(PROV)') { - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE (ref = '(PROV)' OR ref = '') AND rowid = ".((int) $this->id); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".((int) $this->id).")' WHERE (ref = '(PROV)' OR ref = '') AND rowid = ".((int) $this->id); $resqlupdate = $this->db->query($sql); if ($resqlupdate === false) { diff --git a/htdocs/webservices/server_supplier_invoice.php b/htdocs/webservices/server_supplier_invoice.php index 6803133d527..926fa8f6418 100644 --- a/htdocs/webservices/server_supplier_invoice.php +++ b/htdocs/webservices/server_supplier_invoice.php @@ -350,13 +350,9 @@ function getSupplierInvoicesForThirdParty($authentication, $idthirdparty) if (!$error) { $linesinvoice = array(); - $sql .= 'SELECT f.rowid as facid'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f'; - //$sql.=', '.MAIN_DB_PREFIX.'societe as s'; - //$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid'; - //$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'"; - //$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'"; - $sql .= " WHERE f.entity = ".$conf->entity; + $sql .= "SELECT f.rowid as facid"; + $sql .= " FROM '.MAIN_DB_PREFIX.'facture_fourn as f"; + $sql .= " WHERE f.entity = ".((int) $conf->entity); if ($idthirdparty != 'all') { $sql .= " AND f.fk_soc = ".((int) $idthirdparty); } diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 21a58f34159..414daa21632 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -250,7 +250,6 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $ok=true; $matches=array(); - // Check string get_class... preg_match_all('/'.preg_quote('get_class($this)."::".__METHOD__', '/').'/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { $ok=false; @@ -260,9 +259,9 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $this->assertTrue($ok, 'Found string get_class($this)."::".__METHOD__ that must be replaced with __METHOD__ only in '.$file['relativename']); //exit; + // Check string $this->db->idate without quotes $ok=true; $matches=array(); - // Check string $this->db->idate without quotes preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if ($val[1] != '\'"' && $val[1] != '\'\'') { @@ -276,11 +275,10 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase //exit; - $ok=true; - $matches=array(); - // Check sql string DELETE|OR|AND|WHERE|INSERT ... yyy = ".$xxx // with xxx that is not 'thi' (for $this->db->sanitize) and 'db-' (for $db->sanitize). It means we forget a ' if string, or an (int) if int, when forging sql request. + $ok=true; + $matches=array(); preg_match_all('/(DELETE|OR|AND|WHERE|INSERT)\s.*([^\s][^\s][^\s])\s*=\s*"\s*\.\s*\$(...)/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if ($val[2] == 'ity' && $val[3] == 'con') { // exclude entity = ".$conf->entity @@ -300,8 +298,39 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $this->assertTrue($ok, 'Found non quoted or not casted var into sql request '.$file['relativename'].' - Bad.'); //exit; + // Check that forged sql string is using " as string PHP quotes + $ok=true; + $matches=array(); + preg_match_all('/\$sql \.= \'\s*VALUES.*\$/', $filecontent, $matches, PREG_SET_ORDER); + foreach ($matches as $key => $val) { + //if ($val[1] != '\'"' && $val[1] != '\'\'') { + var_dump($matches); + $ok=false; + break; + //} + //if ($reg[0] != 'db') $ok=false; + } + //print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n"; + $this->assertTrue($ok, 'Found a forged SQL string that mix on same line the use of \' for PHP string and PHP variables into file '.$file['relativename'].' Use " to forge PHP string like this: $sql = "SELET ".$myvar...'); + //exit; + + // Check that forged sql string is using " as string PHP quotes + /* + $ok=true; + $matches=array(); + preg_match_all('/\$sql \.*= \'SELECT.*\$/', $filecontent, $matches, PREG_SET_ORDER); + foreach ($matches as $key => $val) { + var_dump($matches); + $ok=false; + break; + } + $this->assertTrue($ok, 'Found a forged SQL string that mix on same line the use of \' for PHP string and PHP variables into file '.$file['relativename'].' Use " to forge PHP string like this: $sql = "SELET ".$myvar...'); + */ + // Check sql string VALUES ... , ".$xxx // with xxx that is not 'db-' (for $db->escape). It means we forget a ' if string, or an (int) if int, when forging sql request. + $ok=true; + $matches=array(); preg_match_all('/(VALUES).*,\s*"\s*\.\s*\$(...)/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if ($val[1] == 'VALUES' && $val[2] == 'db-') { // exclude $db->escape( @@ -321,6 +350,8 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase // Check '".$xxx non escaped // Check string ='".$this->xxx with xxx that is not 'escape'. It means we forget a db->escape when forging sql request. + $ok=true; + $matches=array(); preg_match_all('/=\s*\'"\s*\.\s*\$this->(....)/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if ($val[1] != 'db->' && $val[1] != 'esca') { @@ -332,6 +363,8 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $this->assertTrue($ok, 'Found non escaped string in building of a sql request (case 1) in '.$file['relativename'].' - Bad.'); // Check string sql|set...'".$yyy->xxx with xxx that is not 'escape', 'idate', .... It means we forget a db->escape when forging sql request. + $ok=true; + $matches=array(); preg_match_all('/(sql|SET|WHERE|INSERT|VALUES).+\s*\'"\s*\.\s*\$(.........)/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if (! in_array($val[2], array('this->db-', 'this->esc', 'db->escap', 'dbs->esca', 'mydb->esc', 'dbsession', 'db->idate', 'escapedli', 'excludeGr', 'includeGr'))) { @@ -345,6 +378,8 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase //exit; // Check string sql|set...'.$yyy->xxx with xxx that is not 'escape', 'idate', .... It means we forget a db->escape when forging sql request. + $ok=true; + $matches=array(); preg_match_all('/(\$sql|SET\s|WHERE\s|INSERT\s|VALUES\s|VALUES\().+\s*\'\s*\.\s*\$(.........)/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if (! in_array($val[2], array('this->db-', 'db->sanit', 'conf->ent', 'key : \'\')', 'key])."\')', 'excludefi', 'regexstri', ''))) { @@ -361,6 +396,8 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase // Checks with IN // Check string 'IN (".xxx' or 'IN (\'.xxx' with xxx that is not '$this->db->sanitize' and not '$db->sanitize'. It means we forget a db->sanitize when forging sql request. + $ok=true; + $matches=array(); preg_match_all('/ IN \([\'"]\s*\.\s*(.........)/i', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if (!in_array($val[1], array('$db->sani', '$this->db', 'getEntity', 'WON\',\'L', 'self::STA', 'Commande:', 'CommandeF', 'Entrepot:', 'Facture::', 'FactureFo', 'ExpenseRe', 'Societe::', 'Ticket::S'))) { @@ -374,6 +411,8 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase //exit; // Check string 'IN (\'".xxx' with xxx that is not '$this->db->sanitize' and not '$db->sanitize'. It means we forget a db->sanitize when forging sql request. + $ok=true; + $matches=array(); preg_match_all('/ IN \(\'"\s*\.\s*(.........)/i', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if (!in_array($val[1], array('$db->sani', '$this->db', 'getEntity', 'WON\',\'L', 'self::STA', 'Commande:', 'CommandeF', 'Entrepot:', 'Facture::', 'FactureFo', 'ExpenseRe', 'Societe::', 'Ticket::S'))) { From 3d4bb66853f815c40b9b16dde15a21ab6ad75650 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 15:59:47 +0200 Subject: [PATCH 062/113] Clean code --- htdocs/compta/facture/class/facture.class.php | 8 +-- htdocs/core/actions_massactions.inc.php | 2 +- htdocs/core/boxes/box_validated_projects.php | 2 +- htdocs/core/class/commonincoterm.class.php | 8 +-- htdocs/core/class/commoninvoice.class.php | 16 +++--- htdocs/core/class/commonobject.class.php | 36 ++++++------- htdocs/core/class/extrafields.class.php | 10 ++-- htdocs/don/class/don.class.php | 2 +- .../core/actions_massactions_mail.inc.php | 2 +- htdocs/install/lib/repair.lib.php | 10 ++-- htdocs/install/repair.php | 4 +- .../template/class/myobject.class.php | 17 ++++--- .../class/multicurrency.class.php | 50 +++++++++---------- htdocs/product/class/product.class.php | 2 +- htdocs/product/fournisseurs.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 2 +- htdocs/projet/class/project.class.php | 8 +-- htdocs/reception/class/reception.class.php | 10 ++-- htdocs/societe/class/societe.class.php | 2 +- htdocs/website/class/website.class.php | 22 ++++---- htdocs/website/index.php | 2 +- test/phpunit/CodingPhpTest.php | 8 ++- 22 files changed, 113 insertions(+), 112 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 22cd946275c..4b49c88f8ca 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5783,7 +5783,7 @@ class FactureLigne extends CommonInvoiceLine return 0; } - $sql = 'SELECT situation_percent FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid='.((int) $this->fk_prev_id); + $sql = "SELECT situation_percent FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".((int) $this->fk_prev_id); $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { $res = $this->db->fetch_array($resql); @@ -5793,9 +5793,9 @@ class FactureLigne extends CommonInvoiceLine if ($include_credit_note) { $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd'; $sql .= ' JOIN '.MAIN_DB_PREFIX.'facture f ON (f.rowid = fd.fk_facture) '; - $sql .= ' WHERE fd.fk_prev_id = '.((int) $this->fk_prev_id); - $sql .= ' AND f.situation_cycle_ref = '.((int) $invoicecache[$invoiceid]->situation_cycle_ref); // Prevent cycle outed - $sql .= ' AND f.type = '.Facture::TYPE_CREDIT_NOTE; + $sql .= " WHERE fd.fk_prev_id = ".((int) $this->fk_prev_id); + $sql .= " AND f.situation_cycle_ref = ".((int) $invoicecache[$invoiceid]->situation_cycle_ref); // Prevent cycle outed + $sql .= " AND f.type = ".Facture::TYPE_CREDIT_NOTE; $res = $this->db->query($sql); if ($res) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index d10cd2d2f02..00bfe865aaa 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -357,7 +357,7 @@ if (!$error && $massaction == 'confirm_presend') { $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); $from = trim($tmp[($reg[1] - 1)]); } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { - $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; + $sql = "SELECT rowid, label, email FROM ".MAIN_DB_PREFIX."c_email_senderprofile WHERE rowid = ".(int) $reg[1]; $resql = $db->query($sql); $obj = $db->fetch_object($resql); if ($obj) { diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index d756e1461ea..3f2b2cdc221 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -157,7 +157,7 @@ class box_validated_projects extends ModeleBoxes ); if ($objp->fk_soc > 0) { - $sql = 'SELECT rowid, nom as name FROM '.MAIN_DB_PREFIX.'societe WHERE rowid = '.((int) $objp->fk_soc); + $sql = "SELECT rowid, nom as name FROM ".MAIN_DB_PREFIX."societe WHERE rowid = ".((int) $objp->fk_soc); $resql = $this->db->query($sql); //$socstatic = new Societe($this->db); $obj2 = $this->db->fetch_object($resql); diff --git a/htdocs/core/class/commonincoterm.class.php b/htdocs/core/class/commonincoterm.class.php index 11af43c2914..d0485acc5a9 100644 --- a/htdocs/core/class/commonincoterm.class.php +++ b/htdocs/core/class/commonincoterm.class.php @@ -60,7 +60,7 @@ trait CommonIncoterm $this->label_incoterms = ''; if (!empty($this->fk_incoterms)) { - $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; + $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms; $result = $this->db->query($sql); if ($result) { $res = $this->db->fetch_object($result); @@ -80,7 +80,7 @@ trait CommonIncoterm */ public function getIncotermsForPDF() { - $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; + $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -107,7 +107,7 @@ trait CommonIncoterm { if ($this->id && $this->table_element) { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null"); + $sql .= " SET fk_incoterms = ".($id_incoterm > 0 ? ((int) $id_incoterm) : "null"); $sql .= ", location_incoterms = ".($id_incoterm > 0 ? "'".$this->db->escape($location)."'" : "null"); $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this).'::setIncoterms', LOG_DEBUG); @@ -116,7 +116,7 @@ trait CommonIncoterm $this->fk_incoterms = $id_incoterm; $this->location_incoterms = $location; - $sql = 'SELECT libelle as label_incotermsFROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; + $sql = "SELECT libelle as label_incoterms FROM ".MAIN_DB_PREFIX."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms; $res = $this->db->query($sql); if ($res) { $obj = $this->db->fetch_object($res); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 9bd17c77ea5..3b98d3f3356 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -226,8 +226,8 @@ abstract class CommonInvoice extends CommonObject $idarray = array(); $sql = 'SELECT rowid'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' WHERE fk_facture_source = '.((int) $this->id); + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE fk_facture_source = ".((int) $this->id); $sql .= ' AND type = 2'; $resql = $this->db->query($sql); if ($resql) { @@ -253,8 +253,8 @@ abstract class CommonInvoice extends CommonObject public function getIdReplacingInvoice($option = '') { $sql = 'SELECT rowid'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' WHERE fk_facture_source = '.((int) $this->id); + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE fk_facture_source = ".((int) $this->id); $sql .= ' AND type < 2'; if ($option == 'validated') { $sql .= ' AND fk_statut = 1'; @@ -306,8 +306,8 @@ abstract class CommonInvoice extends CommonObject $sharedentity = 'facture_fourn'; } - $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'.$field3; - $sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; + $sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3; + $sql .= " FROM ".MAIN_DB_PREFIX.$table." as pf, ".MAIN_DB_PREFIX.$table2." as p, ".MAIN_DB_PREFIX."c_paiement as t"; $sql .= " WHERE pf.".$field." = ".((int) $this->id); $sql .= " AND pf.".$field2." = p.rowid"; $sql .= ' AND p.fk_paiement = t.id'; @@ -335,12 +335,12 @@ abstract class CommonInvoice extends CommonObject //look for credit notes and discounts and deposits $sql = ''; if ($this->element == 'facture' || $this->element == 'invoice') { - $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; + $sql = "SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type"; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.((int) $this->id); $sql .= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set) } elseif ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { - $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; + $sql = "SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type"; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.((int) $this->id); $sql .= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ca3cc7ad39d..faf2ab18d2c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1671,7 +1671,7 @@ abstract class CommonObject return 0; } - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE '.$this->table_ref_field.' LIKE "'.$this->db->escape($ref).'" LIMIT 1'; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE ".$this->table_ref_field." LIKE '".$this->db->escape($ref)."' LIMIT 1"; $query = $this->db->query($sql); @@ -2900,7 +2900,7 @@ abstract class CommonObject // Count number of lines to reorder (according to choice $renum) $nl = 0; - $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql = "SELECT count(rowid) FROM ".MAIN_DB_PREFIX.$this->table_element_line; $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); if (!$renum) { $sql .= ' AND rang = 0'; @@ -2922,7 +2922,7 @@ abstract class CommonObject $rows = array(); // We first search all lines that are parent lines (for multilevel details lines) - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element_line; $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); if ($fk_parent_line) { $sql .= ' AND fk_parent_line IS NULL'; @@ -2970,7 +2970,7 @@ abstract class CommonObject { $rows = array(); - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element_line; $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); $sql .= ' AND fk_parent_line = '.((int) $id); $sql .= ' ORDER BY rang ASC'; @@ -3148,8 +3148,8 @@ abstract class CommonObject */ public function getRangOfLine($rowid) { - $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE rowid ='.((int) $rowid); + $sql = "SELECT rang FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG); $resql = $this->db->query($sql); @@ -3167,9 +3167,9 @@ abstract class CommonObject */ public function getIdOfLine($rang) { - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element_line; $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); - $sql .= ' AND rang = '.((int) $rang); + $sql .= " AND rang = ".((int) $rang); $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_row($resql); @@ -3196,7 +3196,7 @@ abstract class CommonObject if ($fk_parent_line) { $sql = "SELECT max(".$positionfield.") FROM ".MAIN_DB_PREFIX.$this->table_element_line; $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); - $sql .= ' AND fk_parent_line = '.((int) $fk_parent_line); + $sql .= " AND fk_parent_line = ".((int) $fk_parent_line); dol_syslog(get_class($this)."::line_max", LOG_DEBUG); $resql = $this->db->query($sql); @@ -3412,7 +3412,7 @@ abstract class CommonObject $sql .= ', situation_percent'; } $sql .= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line; $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); if ($exclspec) { $product_field = 'product_type'; @@ -3572,7 +3572,7 @@ abstract class CommonObject } if (empty($nodatabaseupdate)) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element.' SET'; $sql .= " ".$fieldht." = ".((float) price2num($this->total_ht)).","; $sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva)).","; $sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1)).","; @@ -4267,8 +4267,8 @@ abstract class CommonObject */ public function getSpecialCode($lineid) { - $sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line; - $sql .= ' WHERE rowid = '.((int) $lineid); + $sql = "SELECT special_code FROM ".MAIN_DB_PREFIX.$this->table_element_line; + $sql .= " WHERE rowid = ".((int) $lineid); $resql = $this->db->query($sql); if ($resql) { $row = $this->db->fetch_row($resql); @@ -6687,8 +6687,8 @@ abstract class CommonObject } $sqlwhere = ''; - $sql = 'SELECT '.$keyList; - $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; + $sql = "SELECT ".$keyList; + $sql .= " FROM ".MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$') !== false) { @@ -6839,7 +6839,7 @@ abstract class CommonObject } $sqlwhere = ''; - $sql = 'SELECT '.$keyList; + $sql = "SELECT ".$keyList; $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { // can use SELECT request @@ -7200,7 +7200,7 @@ abstract class CommonObject $keyList .= implode(', ', $fields_label); } - $sql = 'SELECT '.$keyList; + $sql = "SELECT ".$keyList; $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (strpos($InfoFieldList[4], 'extra') !== false) { $sql .= ' as main'; @@ -7283,7 +7283,7 @@ abstract class CommonObject $keyList .= implode(', ', $fields_label); } - $sql = 'SELECT '.$keyList; + $sql = "SELECT ".$keyList; $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (strpos($InfoFieldList[4], 'extra') !== false) { $sql .= ' as main'; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5710d47644b..4ec87d75974 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1252,7 +1252,7 @@ class ExtraFields } $sqlwhere = ''; - $sql = 'SELECT '.$keyList; + $sql = "SELECT ".$keyList; $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { // can use curent entity filter @@ -1420,7 +1420,7 @@ class ExtraFields } $sqlwhere = ''; - $sql = 'SELECT '.$keyList; + $sql = "SELECT ".$keyList; $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { // can use SELECT request @@ -1716,7 +1716,7 @@ class ExtraFields } } - $sql = 'SELECT '.$keyList; + $sql = "SELECT ".$keyList; $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4], 'extra') !== false) { $sql .= ' as main'; @@ -1820,8 +1820,8 @@ class ExtraFields } } - $sql = 'SELECT '.$keyList; - $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; + $sql = "SELECT ".$keyList; + $sql .= " FROM ".MAIN_DB_PREFIX.$InfoFieldList[0]; if (strpos($InfoFieldList[4], 'extra') !== false) { $sql .= ' as main'; } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 792edbcc928..7ca70a31aa2 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -1116,7 +1116,7 @@ class Don extends CommonObject return -1; } - $sql = 'SELECT SUM(amount) as sum_amount FROM '.MAIN_DB_PREFIX.'payment_donation WHERE fk_donation = '.((int) $this->id); + $sql = "SELECT SUM(amount) as sum_amount FROM ".MAIN_DB_PREFIX."payment_donation WHERE fk_donation = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { dol_print_error($this->db); diff --git a/htdocs/eventorganization/core/actions_massactions_mail.inc.php b/htdocs/eventorganization/core/actions_massactions_mail.inc.php index 483a1e5bc84..2f8e2959f2b 100644 --- a/htdocs/eventorganization/core/actions_massactions_mail.inc.php +++ b/htdocs/eventorganization/core/actions_massactions_mail.inc.php @@ -173,7 +173,7 @@ if (!$error && $massaction == 'confirm_presend_attendees') { $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); $from = trim($tmp[($reg[1] - 1)]); } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { - $sql = 'SELECT rowid, label, email FROM ' . MAIN_DB_PREFIX . 'c_email_senderprofile WHERE rowid = ' . (int) $reg[1]; + $sql = "SELECT rowid, label, email FROM " . MAIN_DB_PREFIX . "c_email_senderprofile WHERE rowid = " . (int) $reg[1]; $resql = $db->query($sql); $obj = $db->fetch_object($resql); if ($obj) { diff --git a/htdocs/install/lib/repair.lib.php b/htdocs/install/lib/repair.lib.php index aa0866fac69..aea82107d29 100644 --- a/htdocs/install/lib/repair.lib.php +++ b/htdocs/install/lib/repair.lib.php @@ -32,8 +32,8 @@ function checkElementExist($id, $table) { global $db; - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$table; - $sql .= ' WHERE rowid = '.((int) $id); + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table; + $sql .= " WHERE rowid = ".((int) $id); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -87,8 +87,8 @@ function checkLinkedElements($sourcetype, $targettype) $out = $langs->trans('SourceType').': '.$sourcetype.' => '.$langs->trans('TargetType').': '.$targettype.' '; - $sql = 'SELECT rowid, fk_source, fk_target FROM '.MAIN_DB_PREFIX.'element_element'; - $sql .= " WHERE sourcetype='".$db->escape($sourcetype)."' AND targettype='".$db->escape($targettype)."'"; + $sql = "SELECT rowid, fk_source, fk_target FROM ".MAIN_DB_PREFIX."element_element"; + $sql .= " WHERE sourcetype = '".$db->escape($sourcetype)."' AND targettype = '".$db->escape($targettype)."'"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -106,7 +106,7 @@ function checkLinkedElements($sourcetype, $targettype) foreach ($elements as $key => $element) { if (!checkElementExist($element[$sourcetype], $sourcetable) || !checkElementExist($element[$targettype], $targettable)) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'element_element'; - $sql .= ' WHERE rowid = '.((int) $key); + $sql .= " WHERE rowid = ".((int) $key); $resql = $db->query($sql); $deleted++; } diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 8160f6e89b8..3bc37960bf3 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1180,7 +1180,7 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { foreach ($conf->modules as $key => $val) { $listofmods .= ($listofmods ? ',' : '')."'".$val."'"; } - $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module NOT IN ('.$db->sanitize($listofmods).') AND id > 100000'; + $sql = "SELECT id, libelle as label, module from ".MAIN_DB_PREFIX."rights_def WHERE module NOT IN (".$db->sanitize($listofmods).") AND id > 100000"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1191,7 +1191,7 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { if ($obj->id > 0) { print 'Found line with id '.$obj->id.', label "'.$obj->label.'" of module "'.$obj->module.'" to delete'; if (GETPOST('clean_perm_table', 'alpha') == 'confirmed') { - $sqldelete = 'DELETE FROM '.MAIN_DB_PREFIX.'rights_def WHERE id = '.$obj->id; + $sqldelete = "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE id = ".((int) $obj->id); $resqldelete = $db->query($sqldelete); if (!$resqldelete) { dol_print_error($db); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index e7db2a1275a..ad1774b149e 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -430,13 +430,13 @@ class MyObject extends CommonObject $records = array(); - $sql = 'SELECT '; + $sql = "SELECT "; $sql .= $this->getFieldList('t'); - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= " WHERE t.entity IN (".getEntity($this->table_element).")"; } else { - $sql .= ' WHERE 1 = 1'; + $sql .= " WHERE 1 = 1"; } // Manage filter $sqlwhere = array(); @@ -908,10 +908,11 @@ class MyObject extends CommonObject */ public function info($id) { - $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql .= ' fk_user_creat, fk_user_modif'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.rowid = '.((int) $id); + $sql = "SELECT rowid, date_creation as datec, tms as datem,"; + $sql .= " fk_user_creat, fk_user_modif"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " WHERE t.rowid = ".((int) $id); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 5e145dbd8a6..73eab7773bd 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -133,7 +133,7 @@ class MultiCurrency extends CommonObject $now = dol_now(); // Insert request - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; $sql .= ' code,'; $sql .= ' name,'; $sql .= ' entity,'; @@ -194,7 +194,7 @@ class MultiCurrency extends CommonObject global $conf; - $sql = 'SELECT'; + $sql = "SELECT"; $sql .= ' c.rowid, c.name, c.code, c.entity, c.date_create, c.fk_user'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' AS c'; if (!empty($code)) { @@ -243,7 +243,7 @@ class MultiCurrency extends CommonObject */ public function fetchAllCurrencyRate() { - $sql = 'SELECT cr.rowid'; + $sql = "SELECT cr.rowid"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr'; $sql .= ' WHERE cr.fk_multicurrency = '.((int) $this->id); $sql .= ' ORDER BY cr.date_sync DESC'; @@ -298,10 +298,10 @@ class MultiCurrency extends CommonObject } // Update request - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET'; - $sql .= ' name=\''.$this->db->escape($this->name).'\''; - $sql .= ' code=\''.$this->db->escape($this->code).'\''; - $sql .= ' WHERE rowid='.((int) $this->id); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; + $sql .= " name = '".$this->db->escape($this->name)."'"; + $sql .= " code = '".$this->db->escape($this->code)."'"; + $sql .= " WHERE rowid = ".((int) $this->id); $this->db->begin(); @@ -362,8 +362,8 @@ class MultiCurrency extends CommonObject dol_syslog('Currency::delete '.join(',', $this->errors), LOG_ERR); } - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element; - $sql .= ' WHERE rowid='.((int) $this->id); + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -438,7 +438,7 @@ class MultiCurrency extends CommonObject $currency->code = $code; $currency->name = $code; - $sql = 'SELECT label FROM '.MAIN_DB_PREFIX."c_currencies WHERE code_iso = '".$this->db->escape($code)."'"; + $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies WHERE code_iso = '".$this->db->escape($code)."'"; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -477,8 +477,8 @@ class MultiCurrency extends CommonObject */ public function getRate() { - $sql = 'SELECT cr.rowid'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr'; + $sql = "SELECT cr.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line." as cr"; $sql .= " WHERE cr.fk_multicurrency = ".((int) $this->id); $sql .= " AND cr.date_sync = (SELECT MAX(cr2.date_sync) FROM ".MAIN_DB_PREFIX.$this->table_element_line." AS cr2 WHERE cr2.fk_multicurrency = ".((int) $this->id).")"; @@ -502,7 +502,7 @@ class MultiCurrency extends CommonObject { global $conf; - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."multicurrency WHERE code = '".$db->escape($code)."' AND entity = ".$conf->entity; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."multicurrency WHERE code = '".$db->escape($code)."' AND entity = ".$conf->entity; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); @@ -527,7 +527,7 @@ class MultiCurrency extends CommonObject { global $conf; - $sql1 = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; + $sql1 = "SELECT m.rowid, mc.rate FROM ".MAIN_DB_PREFIX."multicurrency m"; $sql1 .= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)'; $sql1 .= " WHERE m.code = '".$db->escape($code)."'"; @@ -537,7 +537,7 @@ class MultiCurrency extends CommonObject $tmparray = dol_getdate($date_document); $sql2 .= " AND mc.date_sync <= '".$db->idate(dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], true))."'"; } - $sql3 = ' ORDER BY mc.date_sync DESC LIMIT 1'; + $sql3 = " ORDER BY mc.date_sync DESC LIMIT 1"; dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql1.$sql2.$sql3); @@ -591,7 +591,7 @@ class MultiCurrency extends CommonObject { global $db; - $sql = 'SELECT multicurrency_tx FROM '.MAIN_DB_PREFIX.$table.' WHERE rowid = '.((int) $fk_facture); + $sql = "SELECT multicurrency_tx FROM ".MAIN_DB_PREFIX.$table." WHERE rowid = ".((int) $fk_facture); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $db->query($sql); @@ -773,7 +773,7 @@ class CurrencyRate extends CommonObjectLine $now = empty($this->date_sync) ? dol_now() : $this->date_sync; // Insert request - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.'('; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."("; $sql .= ' rate,'; $sql .= ' date_sync,'; $sql .= ' fk_multicurrency,'; @@ -829,9 +829,9 @@ class CurrencyRate extends CommonObjectLine { dol_syslog('CurrencyRate::fetch', LOG_DEBUG); - $sql = 'SELECT cr.rowid, cr.rate, cr.date_sync, cr.fk_multicurrency, cr.entity'; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' AS cr'; - $sql .= ' WHERE cr.rowid = '.((int) $id); + $sql = "SELECT cr.rowid, cr.rate, cr.date_sync, cr.fk_multicurrency, cr.entity"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." AS cr"; + $sql .= " WHERE cr.rowid = ".((int) $id); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); @@ -878,15 +878,15 @@ class CurrencyRate extends CommonObjectLine $this->rate = price2num($this->rate); // Update request - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql .= "SET rate =".((float) $this->rate); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= "SET rate = ".((float) $this->rate); if (!empty($this->date_sync)) { - $sql .= ", date_sync='".$this->db->idate($this->date_sync)."'"; + $sql .= ", date_sync = '".$this->db->idate($this->date_sync)."'"; } if (!empty($this->fk_multicurrency)) { - $sql .= ', fk_multicurrency='.((int) $this->fk_multicurrency); + $sql .= ', fk_multicurrency = '.((int) $this->fk_multicurrency); } - $sql .= ' WHERE rowid='.((int) $this->id); + $sql .= " WHERE rowid =".((int) $this->id); $this->db->begin(); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fa853dfec5e..de88ec9f277 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5087,7 +5087,7 @@ class Product extends CommonObject $langs->load('products'); if (isset($this->finished) && $this->finished >= 0) { - $sql = 'SELECT label, code FROM '.MAIN_DB_PREFIX.'c_product_nature where code='.((int) $this->finished).' AND active=1'; + $sql = "SELECT label, code FROM ".MAIN_DB_PREFIX."c_product_nature where code = ".((int) $this->finished)." AND active=1"; $resql = $this->db->query($sql); if ($resql && $this->db->num_rows($resql) > 0) { $res = $this->db->fetch_array($resql); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 72af7b6e886..285331a091a 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -683,7 +683,7 @@ if ($id > 0 || $ref) { print ''; $currencies = array(); - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.((int) $conf->entity); + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."multicurrency WHERE entity = ".((int) $conf->entity); $resql = $db->query($sql); if ($resql) { $currency = new MultiCurrency($db); diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 37f6f76d216..991ec70b6aa 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -819,7 +819,7 @@ class Entrepot extends CommonObject $parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents $i = 0; while ($parentid > 0 && $i < $protection) { - $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.((int) $parentid); + $sql = "SELECT fk_parent FROM ".MAIN_DB_PREFIX."entrepot WHERE rowid = ".((int) $parentid); $resql = $this->db->query($sql); if ($resql) { $objarbo = $this->db->fetch_object($resql); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index af1fb65337b..368fb3c2982 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -706,9 +706,9 @@ class Project extends CommonObject } elseif ($type == 'project_task_time') { // Case we want to duplicate line foreach user $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet IN (".$this->db->sanitize($ids).")"; } elseif ($type == 'stock_mouvement') { - $sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$this->db->sanitize($ids).") AND ms.type_mouvement = 1"; + $sql = "SELECT ms.rowid, ms.fk_user_author as fk_user FROM ".MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$this->db->sanitize($ids).") AND ms.type_mouvement = 1"; } elseif ($type == 'loan') { - $sql = 'SELECT l.rowid, l.fk_user_author as fk_user FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet IN (".$this->db->sanitize($ids).")"; + $sql = "SELECT l.rowid, l.fk_user_author as fk_user FROM ".MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet IN (".$this->db->sanitize($ids).")"; } else { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$this->db->sanitize($ids).") AND entity IN (".getEntity($type).")"; } @@ -952,9 +952,9 @@ class Project extends CommonObject } elseif ($type == 'project_task_time') { // Case we want to duplicate line foreach user $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet = ".((int) $this->id); } elseif ($type == 'stock_mouvement') { - $sql = 'SELECT COUNT(ms.rowid) as nb FROM '.MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin = ".((int) $this->id)." AND ms.type_mouvement = 1"; + $sql = "SELECT COUNT(ms.rowid) as nb FROM ".MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin = ".((int) $this->id)." AND ms.type_mouvement = 1"; } elseif ($type == 'loan') { - $sql = 'SELECT COUNT(l.rowid) as nb FROM '.MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet = ".((int) $this->id); + $sql = "SELECT COUNT(l.rowid) as nb FROM ".MAIN_DB_PREFIX."loan as l WHERE l.entity IN (".getEntity('loan').") AND l.fk_projet = ".((int) $this->id); } else { $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." = ".((int) $this->id)." AND entity IN (".getEntity($type).")"; } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 278263669ea..b88f5519c3f 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -948,9 +948,10 @@ class Reception extends CommonObject } if (!$error) { - $main = MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_reception = ".((int) $this->id).")"; + $main = MAIN_DB_PREFIX.'commande_fournisseur_dispatch'; + $ef = $main."_extrafields"; + + $sqlef = "DELETE FROM ".$ef." WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_reception = ".((int) $this->id).")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch"; $sql .= " WHERE fk_reception = ".((int) $this->id); @@ -1044,7 +1045,8 @@ class Reception extends CommonObject { // phpcs:enable dol_include_once('/fourn/class/fournisseur.commande.dispatch.class.php'); - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch WHERE fk_reception='.((int) $this->id); + + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch WHERE fk_reception = ".((int) $this->id); $resql = $this->db->query($sql); if (!empty($resql)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8f0e2c84805..23c2976d43a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3743,7 +3743,7 @@ class Societe extends CommonObject public function has_projects() { // phpcs:enable - $sql = 'SELECT COUNT(*) as numproj FROM '.MAIN_DB_PREFIX.'projet WHERE fk_soc = '.((int) $this->id); + $sql = "SELECT COUNT(*) as numproj FROM ".MAIN_DB_PREFIX."projet WHERE fk_soc = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index f80a705c3f2..f1a923642e2 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -297,8 +297,8 @@ class Website extends CommonObject { dol_syslog(__METHOD__, LOG_DEBUG); - $sql = 'SELECT'; - $sql .= ' t.rowid,'; + $sql = "SELECT"; + $sql .= " t.rowid,"; $sql .= " t.entity,"; $sql .= " t.ref,"; $sql .= " t.position,"; @@ -313,12 +313,12 @@ class Website extends CommonObject $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification"; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('website').')'; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " WHERE t.entity IN (".getEntity('website').")"; if (!empty($ref)) { $sql .= " AND t.ref = '".$this->db->escape($ref)."'"; } else { - $sql .= ' AND t.rowid = '.(int) $id; + $sql .= " AND t.rowid = ".(int) $id; } $resql = $this->db->query($sql); @@ -395,8 +395,8 @@ class Website extends CommonObject { dol_syslog(__METHOD__, LOG_DEBUG); - $sql = 'SELECT'; - $sql .= ' t.rowid,'; + $sql = "SELECT"; + $sql .= " t.rowid,"; $sql .= " t.entity,"; $sql .= " t.ref,"; $sql .= " t.description,"; @@ -409,8 +409,8 @@ class Website extends CommonObject $sql .= " t.fk_user_modif,"; $sql .= " t.date_creation,"; $sql .= " t.tms as date_modification"; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE t.entity IN ('.getEntity('website').')'; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " WHERE t.entity IN (".getEntity('website').")"; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -1252,7 +1252,7 @@ class Website extends CommonObject // Read record of website that has been updated by the run_sql function previously called so we can get the // value of fk_default_home that is ID of home page - $sql = 'SELECT fk_default_home FROM '.MAIN_DB_PREFIX.'website WHERE rowid = '.((int) $object->id); + $sql = "SELECT fk_default_home FROM ".MAIN_DB_PREFIX."website WHERE rowid = ".((int) $object->id); $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -1297,7 +1297,7 @@ class Website extends CommonObject $objectpagestatic = new WebsitePage($this->db); - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'website_page WHERE fk_website = '.((int) $this->id); + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."website_page WHERE fk_website = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index beca6a3a1a0..4e21887ff04 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3825,7 +3825,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties print ''; if ($action != 'createcontainer') { // Has translation pages - $sql = 'SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.((int) $objectpage->id); + $sql = "SELECT rowid, lang from ".MAIN_DB_PREFIX."website_page where fk_page = ".((int) $objectpage->id); $resql = $db->query($sql); if ($resql) { $num_rows = $db->num_rows($resql); diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 414daa21632..2d3c71e7370 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -298,7 +298,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $this->assertTrue($ok, 'Found non quoted or not casted var into sql request '.$file['relativename'].' - Bad.'); //exit; - // Check that forged sql string is using " as string PHP quotes + // Check that forged sql string is using ' instead of " as string PHP quotes $ok=true; $matches=array(); preg_match_all('/\$sql \.= \'\s*VALUES.*\$/', $filecontent, $matches, PREG_SET_ORDER); @@ -314,18 +314,16 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $this->assertTrue($ok, 'Found a forged SQL string that mix on same line the use of \' for PHP string and PHP variables into file '.$file['relativename'].' Use " to forge PHP string like this: $sql = "SELET ".$myvar...'); //exit; - // Check that forged sql string is using " as string PHP quotes - /* + // Check that forged sql string is using ' instead of " as string PHP quotes $ok=true; $matches=array(); - preg_match_all('/\$sql \.*= \'SELECT.*\$/', $filecontent, $matches, PREG_SET_ORDER); + preg_match_all('/\$sql \.?= \'SELECT.*\$/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { var_dump($matches); $ok=false; break; } $this->assertTrue($ok, 'Found a forged SQL string that mix on same line the use of \' for PHP string and PHP variables into file '.$file['relativename'].' Use " to forge PHP string like this: $sql = "SELET ".$myvar...'); - */ // Check sql string VALUES ... , ".$xxx // with xxx that is not 'db-' (for $db->escape). It means we forget a ' if string, or an (int) if int, when forging sql request. From fc4a16b356a6e720f80ebca24cbc9a74af577e6f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 16:18:07 +0200 Subject: [PATCH 063/113] Fix avoid error when trigger run on downgraded version. --- .../triggers/interface_90_modSociete_ContactRoles.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index e2759eb3926..15c84bc41a1 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -79,7 +79,11 @@ class InterfaceContactRoles extends DolibarrTriggers require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contactdefault = new Contact($this->db); $contactdefault->socid = $socid; - $TContact = $contactdefault->getContactRoles($object->element); + + $TContact = array(); + if (method_exists($contactdefault, 'getContactRoles')) { // For backward compatibility + $TContact = $contactdefault->getContactRoles($object->element); + } if (is_array($TContact) && !empty($TContact)) { $TContactAlreadyLinked = array(); From c2c7d88520cad416d2f7064eaa4ffe896d6d90d1 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 30 Sep 2021 16:40:15 +0200 Subject: [PATCH 064/113] NEW: NEW: expense reports: conf to pre-fill start/end dates with bounds of current month --- htdocs/admin/expensereport.php | 11 ++++++++++- htdocs/expensereport/card.php | 11 +++++++++++ htdocs/langs/en_US/admin.lang | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index f7c9a84c5d1..badbcc784e4 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -145,7 +145,10 @@ if ($action == 'updateMask') { $draft = GETPOST('EXPENSEREPORT_DRAFT_WATERMARK', 'alpha'); $res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (!$res1 > 0 || !$res2 > 0) { + $dates = GETPOST('EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', 'int'); + $res3 = dolibarr_set_const($db, 'EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', intval($dates), 'chaine', 0, '', $conf->entity); + + if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) { $error++; } @@ -458,6 +461,12 @@ print $form->textwithpicto($langs->trans("WatermarkOnDraftExpenseReports"), $htm print ''; print ''."\n"; +print ''; +print $langs->trans('PrefillExpenseReportDatesWithCurrentMonth'); +print ''; +print $form->selectyesno('EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH', empty($conf->global->EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH) ? 0 : 1, 1); +print ''; + print ''; print $form->buttonsSaveCancel("Save", ''); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index f982b046793..1c52265d5e5 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -68,6 +68,17 @@ $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('socid_id', $childids = $user->getAllChildIds(1); +if (! empty($conf->global->EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH)) { + if (empty($date_start)) { + $date_start = dol_mktime(0, 0, 0, (int) dol_print_date(dol_now(), '%m'), 1, (int) dol_print_date(dol_now(), '%Y')); + } + + if (empty($date_end)) { + // date('t') => number of days in the month, so last day of the month too + $date_end = dol_mktime(0, 0, 0, (int) dol_print_date(dol_now(), '%m'), (int) date('t'), (int) dol_print_date(dol_now(), '%Y')); + } +} + // Hack to use expensereport dir $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 48887552e7e..84e670b339a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -517,6 +517,7 @@ Field=Field ProductDocumentTemplates=Document templates to generate product document FreeLegalTextOnExpenseReports=Free legal text on expense reports WatermarkOnDraftExpenseReports=Watermark on draft expense reports +PrefillExpenseReportDatesWithCurrentMonth=Pre-fill dates with start and end dates of the current month AttachMainDocByDefault=Set this to 1 if you want to attach main document to email by default (if applicable) FilesAttachedToEmail=Attach file SendEmailsReminders=Send agenda reminders by emails From 6a66fcbff85bea8058a2609a7a4d13f990afaf71 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 30 Sep 2021 16:51:31 +0200 Subject: [PATCH 065/113] NEW: expense report: show link to already existing overlapping expense report --- htdocs/expensereport/card.php | 12 ++++++++---- htdocs/expensereport/class/expensereport.class.php | 13 ++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index f982b046793..7f41245b4d8 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -266,10 +266,14 @@ if (empty($reshook)) { } } - if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS) && $object->periode_existe($fuser, $object->date_debut, $object->date_fin)) { - $error++; - setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors'); - $action = 'create'; + if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS)) { + $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin, true); + + if ($overlappingExpenseReportID > 0) { + $error++; + setEventMessages($langs->trans("ErrorDoubleDeclaration").' '. $langs->trans('ShowTrip').'', null, 'errors'); + $action = 'create'; + } } if (!$error) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 63303554c51..8df8b356090 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2195,9 +2195,10 @@ class ExpenseReport extends CommonObject * @param User $fuser User * @param integer $date_debut Start date * @param integer $date_fin End date + * @param bool $return_id True to return ID of existing expense report * @return int <0 if KO, >0 if OK */ - public function periode_existe($fuser, $date_debut, $date_fin) + public function periode_existe($fuser, $date_debut, $date_fin, $return_id = false) { // phpcs:enable $sql = "SELECT rowid, date_debut, date_fin"; @@ -2213,8 +2214,6 @@ class ExpenseReport extends CommonObject $date_d_form = $date_debut; $date_f_form = $date_fin; - $existe = false; - while ($i < $num_rows) { $objp = $this->db->fetch_object($result); @@ -2222,17 +2221,13 @@ class ExpenseReport extends CommonObject $date_f_req = $this->db->jdate($objp->date_fin); // 4 if (!($date_f_form < $date_d_req || $date_d_form > $date_f_req)) { - $existe = true; + return $return_id ? $objp->rowid : 1; } $i++; } - if ($existe) { - return 1; - } else { - return 0; - } + return 0; } else { return 0; } From d3e90e8f76dd7ce01d93a513ec0e48ddb751c7ad Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 30 Sep 2021 17:24:57 +0200 Subject: [PATCH 066/113] NEW: expense reports: conf to force amounts to be entered only including taxes --- htdocs/admin/expensereport.php | 10 +++++++++- htdocs/expensereport/card.php | 6 ++++-- htdocs/langs/en_US/admin.lang | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index f7c9a84c5d1..09b7f66473d 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -145,7 +145,10 @@ if ($action == 'updateMask') { $draft = GETPOST('EXPENSEREPORT_DRAFT_WATERMARK', 'alpha'); $res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (!$res1 > 0 || !$res2 > 0) { + $amounts = GETPOST('EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', 'int'); + $res3 = dolibarr_set_const($db, 'EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', intval($amounts), 'chaine', 0, '', $conf->entity); + + if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) { $error++; } @@ -458,6 +461,11 @@ print $form->textwithpicto($langs->trans("WatermarkOnDraftExpenseReports"), $htm print ''; print ''."\n"; +print ''; +print $langs->trans('ForceExpenseReportsLineAmountsIncludingTaxesOnly'); +print ''; +print $form->selectyesno('EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY', empty($conf->global->EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY) ? 0 : 1, 1); +print ''; print ''; print $form->buttonsSaveCancel("Save", ''); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index f982b046793..9bc2197055d 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1565,6 +1565,8 @@ if ($action == 'create') { print ''; } else { + $taxlessUnitPriceDisabled = ! empty($conf->global->EXPENSEREPORT_FORCE_LINE_AMOUNTS_INCLUDING_TAXES_ONLY) ? ' disabled' : ''; + print dol_get_fiche_head($head, 'card', $langs->trans("ExpenseReport"), -1, 'trip'); // Clone confirmation @@ -2281,7 +2283,7 @@ if ($action == 'create') { // Unit price print ''; - print ''; + print ''; print ''; // Unit price with tax @@ -2460,7 +2462,7 @@ if ($action == 'create') { // Unit price net print ''; - print ''; + print ''; print ''; // Unit price with tax diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0e8e39e6600..d33aad11c64 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -517,6 +517,7 @@ Field=Field ProductDocumentTemplates=Document templates to generate product document FreeLegalTextOnExpenseReports=Free legal text on expense reports WatermarkOnDraftExpenseReports=Watermark on draft expense reports +ForceExpenseReportsLineAmountsIncludingTaxesOnly=Force expense report amounts to be input only including taxes AttachMainDocByDefault=Set this to 1 if you want to attach main document to email by default (if applicable) FilesAttachedToEmail=Attach file SendEmailsReminders=Send agenda reminders by emails From 166d3b08d6ec719428ab7566750915e90215995c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 20:00:48 +0200 Subject: [PATCH 067/113] Add LIBXML_NONET to simplexml_load_string --- htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php | 2 +- htdocs/admin/system/dolibarr.php | 2 +- htdocs/admin/system/filecheck.php | 2 +- htdocs/admin/tools/update.php | 2 +- htdocs/api/class/api_setup.class.php | 2 +- htdocs/core/class/rssparser.class.php | 2 +- htdocs/core/tpl/login.tpl.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index adaf82d6964..5a23133923e 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -232,7 +232,7 @@ class PrestaShopWebservice if ($response != '') { libxml_clear_errors(); libxml_use_internal_errors(true); - $xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA); + $xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); if (libxml_get_errors()) { $msg = var_export(libxml_get_errors(), true); libxml_clear_errors(); diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 90e35c8e970..75ca036b92f 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -51,7 +51,7 @@ if ($action == 'getlastversion') { $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); //var_dump($result['content']); if (function_exists('simplexml_load_string')) { - $sfurl = simplexml_load_string($result['content']); + $sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); } else { setEventMessages($langs->trans("ErrorPHPDoesNotSupport", "xml"), null, 'errors'); } diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 272ac8d8f19..5ca87663c7a 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -171,7 +171,7 @@ if (GETPOST('target') == 'remote') { if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; //print "xmlfilestart".$xmlfile."xmlfileend"; - $xml = simplexml_load_string($xmlfile); + $xml = simplexml_load_string($xmlfile, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); } else { $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].(($xmlarray['http_code'] == 400 && $xmlarray['content']) ? ' '.$xmlarray['content'] : '').' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; setEventMessages($errormsg, null, 'errors'); diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index 821bcd9e3f3..8de6e32e8a0 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -61,7 +61,7 @@ $version = '0.0'; if ($action == 'getlastversion') { $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); //var_dump($result['content']); - $sfurl = simplexml_load_string($result['content']); + $sfurl = simplexml_load_string($result['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index f5f301e9c16..9856acfacdc 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1683,7 +1683,7 @@ class Setup extends DolibarrApi if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '400' && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; //print "xmlfilestart".$xmlfile."endxmlfile"; - $xml = simplexml_load_string($xmlfile); + $xml = simplexml_load_string($xmlfile, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); } else { $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].(($xmlarray['http_code'] == 400 && $xmlarray['content']) ? ' '.$xmlarray['content'] : '').' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; throw new RestException(500, $errormsg); diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 6a8a91dbb05..c3c434d1aed 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -240,7 +240,7 @@ class RssParser if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { //print 'xx'.LIBXML_NOCDATA; libxml_use_internal_errors(false); - $rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA); + $rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA|LIBXML_NOCDATA); } else { if (!function_exists('xml_parser_create')) { $this->error = 'Function xml_parser_create are not supported by your PHP'; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 7b20e7209f7..7f460587248 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -346,7 +346,7 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { $resgetcommitstrip = getURLContent("https://www.commitstrip.com/en/feed/"); } if ($resgetcommitstrip && $resgetcommitstrip['http_code'] == '200') { - $xml = simplexml_load_string($resgetcommitstrip['content']); + $xml = simplexml_load_string($resgetcommitstrip['content'], 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET); $little = $xml->channel->item[0]->children('content', true); print preg_replace('/width="650" height="658"/', '', $little->encoded); } From 7f8d5adb6c6a88422c9b539ecbb6b9437d2d05b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Sep 2021 20:32:52 +0200 Subject: [PATCH 068/113] css --- htdocs/product/composition/card.php | 52 ++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 5f783d190e9..2cecfc84bc4 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -24,7 +24,7 @@ /** * \file htdocs/product/composition/card.php * \ingroup product - * \brief Page de la fiche produit + * \brief Page of product file */ require '../../main.inc.php'; @@ -335,19 +335,28 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; - print ''; + print '
'; print ''; + // Rank print ''; + // Product ref print ''; + // Product label print ''; + // Min supplier price print ''; + // Min customer price print ''; + // Stock if (!empty($conf->stock->enabled)) { print ''; } + // Qty in kit print ''; + // Stoc inc/dev print ''; + // Move print ''; print ''."\n"; @@ -359,12 +368,16 @@ if ($id > 0 || !empty($ref)) { if ($value['level'] <= 1) { print ''; + // Rank print ''; $notdefined = 0; $nb_of_subproduct = $value['nb']; + // Product ref print ''; + + // Product label print ''; // Best buying price @@ -423,8 +436,9 @@ if ($id > 0 || !empty($ref)) { print ''; } - print ''; + // Move action + print ''; + print ''."\n"; } else { $hide = ''; @@ -436,12 +450,18 @@ if ($id > 0 || !empty($ref)) { //$productstatic->ref=$value['label']; $productstatic->ref = $value['ref']; + + // Rankd print ''; + + // Product ref print ''; + + // Product label print ''; // Best buying price @@ -451,19 +471,36 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; + // Stock if (!empty($conf->stock->enabled)) { print ''; // Real stock } + + // Qty in kit print ''; + + // Inc/dec print ''; + + // Action move print ''; print ''."\n"; } } + + // Total + print ''; + + // Rank + print ''; + + // Product ref print ''; + + // Product label print ''; // Minimum buying price @@ -495,11 +532,16 @@ if ($id > 0 || !empty($ref)) { print ''; } - print ''; + + print ''; + + print ''; + print ''."\n"; } else { $colspan = 8; From 433132de9a69a735ba2b9f0e3fe25a87726cd30e Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 1 Oct 2021 07:49:31 +0200 Subject: [PATCH 069/113] FIX : llx_hrm_position > llx_hrm_job_user --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 10 +++++----- ...x_hrm_position.key.sql => llx_hrm_job_user.key.sql} | 8 ++++---- .../{llx_hrm_position.sql => llx_hrm_job_user.sql} | 2 +- ...ds.key.sql => llx_hrm_job_user_extrafields.key.sql} | 2 +- ...xtrafields.sql => llx_hrm_job_user_extrafields.sql} | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) rename htdocs/install/mysql/tables/{llx_hrm_position.key.sql => llx_hrm_job_user.key.sql} (80%) rename htdocs/install/mysql/tables/{llx_hrm_position.sql => llx_hrm_job_user.sql} (97%) rename htdocs/install/mysql/tables/{llx_hrm_position_extrafields.key.sql => llx_hrm_job_user_extrafields.key.sql} (93%) rename htdocs/install/mysql/tables/{llx_hrm_position_extrafields.sql => llx_hrm_job_user_extrafields.sql} (96%) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 779d2940b75..75a15f64e3c 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -253,7 +253,7 @@ ALTER TABLE llx_hrm_job_extrafields ADD INDEX idx_job_fk_object(fk_object); -CREATE TABLE llx_hrm_position( +CREATE TABLE llx_hrm_job_user( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, -- ref varchar(128) NOT NULL, @@ -273,11 +273,11 @@ CREATE TABLE llx_hrm_position( -- END MODULEBUILDER FIELDS ) ENGINE=innodb; -ALTER TABLE llx_hrm_position ADD INDEX idx_hrm_position_rowid (rowid); --- ALTER TABLE llx_hrm_position ADD INDEX idx_hrm_position_ref (ref); +ALTER TABLE llx_hrm_job_user ADD INDEX idx_hrm_job_user_rowid (rowid); +-- ALTER TABLE llx_hrm_job_user ADD INDEX idx_hrm_job_user_ref (ref); -create table llx_hrm_position_extrafields +create table llx_hrm_job_user_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, @@ -285,7 +285,7 @@ create table llx_hrm_position_extrafields import_key varchar(14) -- import key ) ENGINE=innodb; -ALTER TABLE llx_hrm_position_extrafields ADD INDEX idx_position_fk_object(fk_object); +ALTER TABLE llx_hrm_job_user_extrafields ADD INDEX idx_position_fk_object(fk_object); diff --git a/htdocs/install/mysql/tables/llx_hrm_position.key.sql b/htdocs/install/mysql/tables/llx_hrm_job_user.key.sql similarity index 80% rename from htdocs/install/mysql/tables/llx_hrm_position.key.sql rename to htdocs/install/mysql/tables/llx_hrm_job_user.key.sql index 40f0d8db97c..ead2f7f3b18 100644 --- a/htdocs/install/mysql/tables/llx_hrm_position.key.sql +++ b/htdocs/install/mysql/tables/llx_hrm_job_user.key.sql @@ -17,11 +17,11 @@ -- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_hrm_position ADD INDEX idx_hrm_position_rowid (rowid); --- ALTER TABLE llx_hrm_position ADD INDEX idx_hrm_position_ref (ref); +ALTER TABLE llx_hrm_job_user ADD INDEX idx_hrm_job_user_rowid (rowid); +-- ALTER TABLE llx_hrm_job_user ADD INDEX idx_hrm_job_user_ref (ref); -- END MODULEBUILDER INDEXES ---ALTER TABLE llx_hrm_position ADD UNIQUE INDEX uk_hrm_position_fieldxy(fieldx, fieldy); +--ALTER TABLE llx_hrm_job_user ADD UNIQUE INDEX uk_hrm_job_user_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_hrm_position ADD CONSTRAINT llx_hrm_position_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); +--ALTER TABLE llx_hrm_job_user ADD CONSTRAINT llx_hrm_job_user_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); diff --git a/htdocs/install/mysql/tables/llx_hrm_position.sql b/htdocs/install/mysql/tables/llx_hrm_job_user.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_hrm_position.sql rename to htdocs/install/mysql/tables/llx_hrm_job_user.sql index 9a470b516ce..ce9620623dd 100644 --- a/htdocs/install/mysql/tables/llx_hrm_position.sql +++ b/htdocs/install/mysql/tables/llx_hrm_job_user.sql @@ -15,7 +15,7 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see https://www.gnu.org/licenses/. -CREATE TABLE llx_hrm_position( +CREATE TABLE llx_hrm_job_user( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, -- ref varchar(128) NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_hrm_position_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.key.sql similarity index 93% rename from htdocs/install/mysql/tables/llx_hrm_position_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.key.sql index a5fdca5a068..99ed1f4c1bc 100644 --- a/htdocs/install/mysql/tables/llx_hrm_position_extrafields.key.sql +++ b/htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.key.sql @@ -17,5 +17,5 @@ -- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_hrm_position_extrafields ADD INDEX idx_position_fk_object(fk_object); +ALTER TABLE llx_hrm_job_user_extrafields ADD INDEX idx_position_fk_object(fk_object); -- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_hrm_position_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.sql similarity index 96% rename from htdocs/install/mysql/tables/llx_hrm_position_extrafields.sql rename to htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.sql index 0b93df9083a..7495563f68d 100644 --- a/htdocs/install/mysql/tables/llx_hrm_position_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.sql @@ -15,7 +15,7 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see https://www.gnu.org/licenses/. -create table llx_hrm_position_extrafields +create table llx_hrm_job_user_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, From 87cbc2b555590ce4c74b8032cdae16ffd64f24cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Oct 2021 08:24:40 +0200 Subject: [PATCH 070/113] Update 14.0.0-15.0.0.sql --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 912eb7fe0eb..31f503cc098 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -128,7 +128,7 @@ ALTER TABLE llx_categorie_knowledgemanagement ADD INDEX idx_categorie_knowledgem ALTER TABLE llx_categorie_knowledgemanagement ADD INDEX idx_categorie_knowledgemanagement_fk_knowledgemanagement (fk_knowledgemanagement); ALTER TABLE llx_categorie_knowledgemanagement ADD CONSTRAINT fk_categorie_knowledgemanagement_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); -ALTER TABLE llx_categorie_knowledgemanagement ADD CONSTRAINT fk_categorie_knowledgemanagement_knowledgemanagement_rowid FOREIGN KEY (fk_knowledgemanagement) REFERENCES llx_knowledgemanagement (rowid); +ALTER TABLE llx_categorie_knowledgemanagement ADD CONSTRAINT fk_categorie_knowledgemanagement_knowledgemanagement_rowid FOREIGN KEY (fk_knowledgemanagement) REFERENCES llx_knowledgemanagement_knowledgerecord (rowid); ALTER TABLE llx_product_lot ADD COLUMN barcode varchar(180) DEFAULT NULL; ALTER TABLE llx_product_lot ADD COLUMN fk_barcode_type integer DEFAULT NULL; From c244d7375c640dca724328beb0c6350d71d20255 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Oct 2021 12:30:24 +0200 Subject: [PATCH 071/113] MAIN_SECURITY_CSRF_WITH_TOKEN now has 3 levels (1, 2, 3) --- htdocs/core/class/conf.class.php | 2 +- htdocs/main.inc.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 8e43a70c3fe..e4abfc1a748 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -828,7 +828,7 @@ class Conf // Enable by default the CSRF protection by token. if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) { - $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1; // Value 2 uses also CSRF check for all GET requests + $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1; // Value 2 uses also CSRF check for sensitive GET requests and 3 uses CSRF check for all POST and GET requests. // Note: Set MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL=1 to have a renewal of token at each page call instead of each session (not recommended) } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6f6d74c0cda..d3f30ae47f7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -465,11 +465,11 @@ if (!defined('NOTOKENRENEWAL') && !defined('NOSESSION')) { if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN')) || defined('CSRFCHECK_WITH_TOKEN')) { // Array of action code where CSRFCHECK with token will be forced (so token must be provided on url request) $sensitiveget = false; - if ((GETPOSTISSET('massaction') || GETPOST('action', 'aZ09')) && getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') == 2) { + if ((GETPOSTISSET('massaction') || GETPOST('action', 'aZ09')) && getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') == 3) { // All GET actions and mass actions are processed as sensitive. $sensitiveget = true; - } else { - // Only GET actions coded with a &token into url are processed as sensitive. + } elseif (getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') == 2) { + // Few GET actions coded with a &token into url are processed as sensitive. $arrayofactiontoforcetokencheck = array( 'activate', 'add', 'addrights', 'addtimespent', 'doprev', 'donext', 'dvprev', 'dvnext', From c664b78800adf997805b250cfc1776cf6a46f020 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Oct 2021 12:37:32 +0200 Subject: [PATCH 072/113] MAIN_SECURITY_CSRF_WITH_TOKEN now has 3 levels (1, 2, 3) --- htdocs/core/class/conf.class.php | 5 ++++- htdocs/main.inc.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index e4abfc1a748..5ec3a4cfbc0 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -828,7 +828,10 @@ class Conf // Enable by default the CSRF protection by token. if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) { - $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1; // Value 2 uses also CSRF check for sensitive GET requests and 3 uses CSRF check for all POST and GET requests. + // Value 1 makes CSRF check for all POST parameters only + // Value 2 makes also CSRF check for GET requests with action = a sensitive requests like action=del, action=remove... + // Value 3 makes also CSRF check for all GET requests with a param action or massaction + $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1; // Note: Set MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL=1 to have a renewal of token at each page call instead of each session (not recommended) } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d3f30ae47f7..a52bb7dcf2b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -465,10 +465,10 @@ if (!defined('NOTOKENRENEWAL') && !defined('NOSESSION')) { if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN')) || defined('CSRFCHECK_WITH_TOKEN')) { // Array of action code where CSRFCHECK with token will be forced (so token must be provided on url request) $sensitiveget = false; - if ((GETPOSTISSET('massaction') || GETPOST('action', 'aZ09')) && getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') == 3) { + if ((GETPOSTISSET('massaction') || GETPOST('action', 'aZ09')) && getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') >= 3) { // All GET actions and mass actions are processed as sensitive. $sensitiveget = true; - } elseif (getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') == 2) { + } elseif (getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') >= 2) { // Few GET actions coded with a &token into url are processed as sensitive. $arrayofactiontoforcetokencheck = array( 'activate', 'add', 'addrights', 'addtimespent', From eada0f468f3338eeded6e3c2f3ff0cf5a0c13880 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Oct 2021 12:39:15 +0200 Subject: [PATCH 073/113] Set MAIN_SECURITY_CSRF_WITH_TOKEN recommended value to 1 --- htdocs/admin/system/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 818f096c99e..0bf568082b2 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -442,7 +442,7 @@ print '
'; print 'MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = '.(empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)' : $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)."
"; print '
'; -print 'MAIN_SECURITY_CSRF_WITH_TOKEN = '.(empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)' : $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)."
"; +print 'MAIN_SECURITY_CSRF_WITH_TOKEN = '.(empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 2)' : $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)."
"; print '
'; print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.(empty($conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)' : $conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL)."
"; From d68719226b7aac5cdb43c173427f2d8635b44ad4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Oct 2021 14:10:50 +0200 Subject: [PATCH 074/113] Fix can install module with name module_abc-x.y.z (w).zip --- htdocs/admin/modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 53cbc1aad69..00142deb9e8 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -133,7 +133,7 @@ if ($action == 'install') { // $original_file should match format module_modulename-x.y[.z].zip $original_file = basename($_FILES["fileinstall"]["name"]); - $original_file = preg_replace('/\(\d+\)\.zip$/i', '.zip', $original_file); + $original_file = preg_replace('/\s*\(\d+\)\.zip$/i', '.zip', $original_file); $newfile = $conf->admin->dir_temp.'/'.$original_file.'/'.$original_file; if (!$original_file) { From 2be2423dee0136679c95641f2db4a0fa9805dbaf Mon Sep 17 00:00:00 2001 From: JR-Polyline <91737050+JR-Polyline@users.noreply.github.com> Date: Fri, 1 Oct 2021 21:30:25 +0800 Subject: [PATCH 075/113] Fix dynamic prices not updating When Dynamic price module active and an a math expression is used to compute buy price on supplier product card, the calculated price does not update on the card when saved. Changing line 849 appears to solve this without any ill effect. --- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 3eaed8d27b8..230c794b038 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -846,7 +846,7 @@ class ProductFournisseur extends Product $this->fourn_qty = $record["quantity"]; $this->fourn_remise_percent = $record["remise_percent"]; $this->fourn_remise = $record["remise"]; - $this->fourn_unitprice = $record["unitprice"]; + $this->fourn_unitprice = $fourn_unitprice; $this->fourn_charges = $record["charges"]; // deprecated $this->fourn_tva_tx = $record["tva_tx"]; $this->fourn_id = $record["fourn_id"]; From fd7d1374c2f54dd17e63774680dbca6baa93b94e Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 1 Oct 2021 16:37:54 +0200 Subject: [PATCH 076/113] FIX Product accountancy affectation with product_perentity activated (PR #18620) --- htdocs/accountancy/admin/productaccount.php | 27 +++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index e29653a3e40..58ffa9bd150 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -186,18 +186,35 @@ if ($action == 'update') { $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$sql.'
'; $ko++; } else { - $db->begin(); - + $sql = ''; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_perentity (fk_product, entity, '".$db->escape($accountancy_field_name)."')"; - $sql .= " VALUES (".((int) $productid).", ".((int) $conf->entity).", '".$db->escape($accounting->account_number)."')"; - $sql .= " ON DUPLICATE KEY UPDATE ".$accountancy_field_name." = '".$db->escape($accounting->account_number)."'"; + $sql_exists = "SELECT rowid FROM " . MAIN_DB_PREFIX . "product_perentity"; + $sql_exists .= " WHERE fk_product = " . ((int) $productid) . " AND entity = " . ((int) $conf->entity); + $resql_exists = $db->query($sql_exists); + if (!$resql_exists) { + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$resql_exists.'
'; + $ko++; + } else { + $nb_exists = $db->num_rows($resql_exists); + if ($nb_exists <= 0) { + // insert + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity (fk_product, entity, '" . $db->escape($accountancy_field_name) . "')"; + $sql .= " VALUES (" . ((int) $productid) . ", " . ((int) $conf->entity) . ", '" . $db->escape($accounting->account_number) . "')"; + } else { + $obj_exists = $db->fetch_object($resql_exists); + // update + $sql = "UPDATE " . MAIN_DB_PREFIX . "product_perentity"; + $sql .= " SET " . $accountancy_field_name . " = '" . $db->escape($accounting->account_number) . "'"; + $sql .= " WHERE rowid = " . ((int) $obj_exists->rowid); + } + } } else { $sql = " UPDATE ".MAIN_DB_PREFIX."product"; $sql .= " SET ".$accountancy_field_name." = '".$db->escape($accounting->account_number)."'"; $sql .= " WHERE rowid = ".((int) $productid); } + $db->begin(); dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); if ($db->query($sql)) { $ok++; From 2671eeb4e58bfe4ddf21a9040429eee70386ed07 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Oct 2021 18:54:14 +0200 Subject: [PATCH 077/113] Responsive --- htdocs/compta/facture/list.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index b2074224412..852589dbd1a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1846,8 +1846,8 @@ if ($resql) { } // Alias if (!empty($arrayfields['s.name_alias']['checked'])) { - print '
'; if (!$i) { $totalarray['nbfield']++; @@ -1855,8 +1855,8 @@ if ($resql) { } // Town if (!empty($arrayfields['s.town']['checked'])) { - print ''; if (!$i) { $totalarray['nbfield']++; @@ -1865,7 +1865,7 @@ if ($resql) { // Zip if (!empty($arrayfields['s.zip']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -1873,7 +1873,7 @@ if ($resql) { } // State if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; + print "\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1936,7 +1936,7 @@ if ($resql) { // Module Source if (!empty($arrayfields['f.module_source']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -1946,7 +1946,7 @@ if ($resql) { // POS Terminal if (!empty($arrayfields['f.pos_source']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; From d064ab2b17f2317077856f6db64285c8cf187e3f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Oct 2021 12:58:15 +0200 Subject: [PATCH 078/113] Add more action to GET action to check --- htdocs/adherents/subscription.php | 2 +- htdocs/admin/menus/edit.php | 2 +- htdocs/admin/paymentbybanktransfer.php | 2 +- htdocs/admin/perms.php | 2 +- htdocs/admin/prelevement.php | 2 +- htdocs/categories/photos.php | 2 +- htdocs/comm/mailing/cibles.php | 2 +- htdocs/compta/bank/bankentries_list.php | 4 +- htdocs/core/class/commonobject.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 2 +- htdocs/imports/import.php | 2 +- htdocs/main.inc.php | 4 +- htdocs/mrp/mo_production.php | 4 +- htdocs/product/fournisseurs.php | 39 ++++++++++--------- htdocs/product/price.php | 2 +- htdocs/public/members/new.php | 2 +- htdocs/public/project/new.php | 2 +- htdocs/societe/price.php | 2 +- htdocs/takepos/floors.php | 4 +- htdocs/takepos/index.php | 2 +- htdocs/takepos/invoice.php | 4 +- htdocs/takepos/phone.php | 4 +- htdocs/user/group/perms.php | 10 ++--- htdocs/user/perms.php | 4 +- htdocs/variants/combinations.php | 4 +- 25 files changed, 56 insertions(+), 55 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 26a45271801..c51fa86cec6 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -670,7 +670,7 @@ if ($rowid > 0) { print '
'; if ($object->statut > 0) { - print '"; + print '"; } else { print ''; } diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index aaadde965a2..65906b83f3c 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -281,7 +281,7 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("NewMenu"), '', 'title_setup'); - print '
'; + print ''; print ''; print dol_get_fiche_head(); diff --git a/htdocs/admin/paymentbybanktransfer.php b/htdocs/admin/paymentbybanktransfer.php index ba7690bb6e3..50a266a2efe 100644 --- a/htdocs/admin/paymentbybanktransfer.php +++ b/htdocs/admin/paymentbybanktransfer.php @@ -429,7 +429,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION)) } - print ''; + print ''; print ''; print '
'.$langs->trans('Rank').''.$langs->trans('ComposedProduct').''.$langs->trans('Label').''.$langs->trans('MinSupplierPrice').''.$langs->trans('MinCustomerPrice').''.$langs->trans('Stock').''.$langs->trans('Qty').''.$langs->trans('ComposedProductIncDecStock').'
'.$object->sousprods[$parent_label][$value['id']][7].''.$productstatic->getNomUrl(1, 'composition').''.$productstatic->label.''.($value['incdec'] == 1 ? 'x' : '').''; - print '
'; for ($i = 0; $i < $value['level']; $i++) { print '     '; // Add indentation } print $productstatic->getNomUrl(1, 'composition').''.$productstatic->label.'  '.$value['nb'].'  
 '; + print ''; if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; } print '
'; - print $obj->name_alias; + print ''; + print dol_escape_htmltag($obj->name_alias); print ''; - print $obj->town; + print ''; + print dol_escape_htmltag($obj->town); print ''; - print $obj->zip; + print dol_escape_htmltag($obj->zip); print '".$obj->state_name."".dol_escape_htmltag($obj->state_name)."'; - print $obj->module_source; + print dol_escape_htmltag($obj->module_source); print ''; - print $obj->pos_source; + print dol_escape_htmltag($obj->pos_source); print '
'; print ''; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 8f4c0c6f763..d2f0d79e4f3 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -236,7 +236,7 @@ if ($result) { print ''; } else { print ''."\n"; } if (!count($boxtoadd) && count($boxactivated)) { - print ''; + print ''; } print '
'; - print ''; + print ''; //print img_edit_add(); print img_picto('', 'switch_off'); print ''; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 90a75626e7c..e09dd13b045 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -443,7 +443,7 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION)) } - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 06c3caae43c..5c014b6206f 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -231,7 +231,7 @@ if ($object->id) { // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) { - print ''.img_picto($langs->trans('GenerateThumb'), 'refresh').'  '; + print ''.img_picto($langs->trans('GenerateThumb'), 'refresh').'  '; } if ($user->rights->categorie->creer) { print ''; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 3283957f8a2..e3d151c6bbb 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -378,7 +378,7 @@ if ($object->fetch($id) >= 0) { $var = !$var; if ($allowaddtarget) { - print ''; + print ''; print ''; } else { print '
'; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index f6a03c1d11d..eabe47e54ca 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -932,10 +932,10 @@ if ($resql) { $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&accountid='.urlencode($search_account).'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.urlencode($search_account)), '', $user->rights->banque->modifier); } else // If direct entries is not done using miscellaneous payments { - $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&page='.$page.$param, '', $user->rights->banque->modifier); + $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&token='.newToken().'&page='.$page.$param, '', $user->rights->banque->modifier); } } else { - $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&page='.$page.$param, '', -1); + $newcardbutton = dolGetButtonTitle($langs->trans('AddBankRecord'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?action=addline&token='.newToken().'&page='.$page.$param, '', -1); } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b1110212293..6020e0b2723 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8220,7 +8220,7 @@ abstract class CommonObject $return .= '
'; // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites if ($photo_vignette && (image_format_supported($photo) > 0) && ($this->imgWidth > $maxWidth || $this->imgHeight > $maxHeight)) { - $return .= '
'.img_picto($langs->trans('GenerateThumb'), 'refresh').'  '; + $return .= ''.img_picto($langs->trans('GenerateThumb'), 'refresh').'  '; } // Special cas for product if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer)) { diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index b08d9237c63..854f043670f 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1183,7 +1183,7 @@ class ProductFournisseur extends Product $label .= $this->displayPriceProductFournisseurLog($logPrices); } - $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; + $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&token='.newToken().'&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; if ($option != 'nolink') { // Add param to save lastsearch_values or not diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 5139e12ab7a..2ab7e3976aa 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1205,7 +1205,7 @@ if ($step == 4 && $datatoimport) { // async: false // });'."\n"; // Now reload page - print 'var newlocation= \''.$_SERVER["PHP_SELF"].'?step=4'.$param.'&action=saveorder&boxorder=\' + boxorder;'."\n"; + print 'var newlocation= \''.$_SERVER["PHP_SELF"].'?step=4'.$param.'&action=saveorder&token='.newToken().'&boxorder=\' + boxorder;'."\n"; //print 'alert(newlocation);'; print 'window.location.href=newlocation;'."\n"; print '}'."\n"; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a52bb7dcf2b..834cffc4f28 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -471,7 +471,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( } elseif (getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN') >= 2) { // Few GET actions coded with a &token into url are processed as sensitive. $arrayofactiontoforcetokencheck = array( - 'activate', 'add', 'addrights', 'addtimespent', + 'activate', 'doprev', 'donext', 'dvprev', 'dvnext', 'install', 'reopen' @@ -479,7 +479,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( if (in_array(GETPOST('action', 'aZ09'), $arrayofactiontoforcetokencheck)) { $sensitiveget = true; } - if (preg_match('/^(classify|close|confirm|del|disable|enable|remove|set|unset|update)/', GETPOST('action', 'aZ09'))) { + if (preg_match('/^(add|classify|close|confirm|copy|del|disable|enable|remove|set|unset|update|save|)/', GETPOST('action', 'aZ09'))) { $sensitiveget = true; } } diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 84dab109b91..784b91f6f4c 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -704,7 +704,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $newlinetext = ''; if ($object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED && $action != 'consumeorproduce' && $action != 'consumeandproduceall') { - $newlinetext = ''.$langs->trans("AddNewConsumeLines").''; + $newlinetext = ''.$langs->trans("AddNewConsumeLines").''; } print load_fiche_titre($langs->trans('Consumption'), '', '', 0, '', '', $newlinetext); @@ -996,7 +996,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $newlinetext = ''; if ($object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED && $action != 'consumeorproduce' && $action != 'consumeandproduceall') { if ($nblinetoproduce == 0 || $object->mrptype == 1) { - $newlinetext = ''.$langs->trans("AddNewProduceLines").''; + $newlinetext = ''.$langs->trans("AddNewProduceLines").''; } } print load_fiche_titre($langs->trans('Production'), '', '', 0, '', '', $newlinetext); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 285331a091a..a3ae38184e9 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -767,11 +767,6 @@ END; // Barcode if (!empty($conf->barcode->enabled)) { - // Option to define a transport cost on supplier price - print '
'; - print ''; - print ''; - print ''; $formbarcode = new FormBarCode($db); // Barcode type @@ -781,6 +776,12 @@ END; print $formbarcode->selectBarcodeType(($rowid ? $object->supplier_fk_barcode_type : $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE), 'fk_barcode_type', 1); print ''; print ''; + + // Barcode value + print ''; + print ''; + print ''; + print ''; } // Option to define a transport cost on supplier price @@ -788,7 +789,7 @@ END; if (!empty($conf->margin->enabled)) { print ''; print ''; - print ''; print ''; } @@ -893,7 +894,7 @@ END; $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if ($usercancreate) { - print ''; + print ''; print $langs->trans("AddSupplierPrice").''; } } @@ -933,8 +934,8 @@ END; 'pfp.multicurrency_unitprice'=>array('label'=>$langs->trans("UnitPriceHTCurrency"), 'enabled' => $conf->multicurrency->enabled, 'checked'=>0, 'position'=>10), 'pfp.delivery_time_days'=>array('label'=>$langs->trans("NbDaysToDelivery"), 'checked'=>1, 'position'=>13), 'pfp.supplier_reputation'=>array('label'=>$langs->trans("ReputationForThisProduct"), 'checked'=>1, 'position'=>14), - 'pfp.barcode'=>array('label'=>$langs->trans("BarcodeValue"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>15), - 'pfp.fk_barcode_type'=>array('label'=>$langs->trans("BarcodeType"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>16), + 'pfp.fk_barcode_type'=>array('label'=>$langs->trans("BarcodeType"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>15), + 'pfp.barcode'=>array('label'=>$langs->trans("BarcodeValue"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>16), 'pfp.packaging'=>array('label'=>$langs->trans("PackagingForThisProduct"), 'enabled' => !empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING), 'checked'=>0, 'position'=>17), 'pfp.tms'=>array('label'=>$langs->trans("DateModification"), 'enabled' => $conf->barcode->enabled, 'checked'=>1, 'position'=>18), ); @@ -1007,12 +1008,12 @@ END; if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) { print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center '); } - if (!empty($arrayfields['pfp.barcode']['checked'])) { - print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center '); - } if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) { print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center '); } + if (!empty($arrayfields['pfp.barcode']['checked'])) { + print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center '); + } if (!empty($arrayfields['pfp.packaging']['checked'])) { print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder); } @@ -1152,13 +1153,6 @@ END; print''; } - // Barcode - if (!empty($arrayfields['pfp.barcode']['checked'])) { - print ''; - } - // Barcode type if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) { print ''; } + // Barcode + if (!empty($arrayfields['pfp.barcode']['checked'])) { + print ''; + } + // Packaging if (!empty($arrayfields['pfp.packaging']['checked'])) { print ''; if ($caneditperms) { print ''; } print ''; @@ -302,9 +302,9 @@ if ($object->id > 0) { print ''; if ($caneditperms) { print ''; } else { print ''; @@ -353,7 +353,7 @@ if ($object->id > 0) { } else { // Do not own permission if ($caneditperms) { - print ''; diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 7c7fe868b2f..d3ba33a5acf 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -420,7 +420,7 @@ if ($result) { } else { // Do not own permission if ($caneditperms) { - print ''; @@ -430,7 +430,7 @@ if ($result) { } else { // Do not own permission if ($caneditperms) { - print ''; diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index a3ad036ca9a..d70419060f5 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -587,7 +587,7 @@ if (!empty($id) || !empty($ref)) { $htmltext = $langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes")); print $form->textwithpicto('', $htmltext); - /*print '     id).'">'; + /*print '     id).'">'; print $langs->trans("Create"); print '';*/ @@ -605,7 +605,7 @@ if (!empty($id) || !empty($ref)) { $htmltext = $langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes")); print $form->textwithpicto('', $htmltext); /* - print '     id).'">'; + print '     id).'">'; print $langs->trans("Create"); print ''; */ From 3102d0725c82c6eb4f40fa60c2f09a6268b372a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Oct 2021 13:04:57 +0200 Subject: [PATCH 079/113] Fix test on action param --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 834cffc4f28..a26954bbed5 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -479,7 +479,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( if (in_array(GETPOST('action', 'aZ09'), $arrayofactiontoforcetokencheck)) { $sensitiveget = true; } - if (preg_match('/^(add|classify|close|confirm|copy|del|disable|enable|remove|set|unset|update|save|)/', GETPOST('action', 'aZ09'))) { + if (preg_match('/^(add|classify|close|confirm|copy|del|disable|enable|remove|set|unset|update|save)/', GETPOST('action', 'aZ09'))) { $sensitiveget = true; } } From 254fbb862b45b04af2c5d54f2ce54a2cf75b8422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:27:25 +0200 Subject: [PATCH 080/113] doxygen --- htdocs/admin/eventorganization_confbooth_extrafields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/eventorganization_confbooth_extrafields.php b/htdocs/admin/eventorganization_confbooth_extrafields.php index 6e19bde8268..991ed3f824a 100644 --- a/htdocs/admin/eventorganization_confbooth_extrafields.php +++ b/htdocs/admin/eventorganization_confbooth_extrafields.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/admin/eventorganization_extrafields.php + * \file htdocs/admin/eventorganization_confbooth_extrafields.php * \ingroup bom * \brief Page to setup extra fields of EventOrganization */ From c5871ac765bc345a1089f30cdbddc571279bc50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:29:33 +0200 Subject: [PATCH 081/113] doxygen /home/dolibarr/htdocs/admin/eventorganization_confboothattendee_extrafields.php:23: warning: the name 'admin/conferenceorboothattendee_extrafields.php' supplied as the argument in the \file statement is not an input file --- .../admin/eventorganization_confboothattendee_extrafields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/eventorganization_confboothattendee_extrafields.php b/htdocs/admin/eventorganization_confboothattendee_extrafields.php index 6b201e6b923..0b50c483d69 100644 --- a/htdocs/admin/eventorganization_confboothattendee_extrafields.php +++ b/htdocs/admin/eventorganization_confboothattendee_extrafields.php @@ -21,7 +21,7 @@ */ /** - * \file admin/conferenceorboothattendee_extrafields.php + * \file htdocs/admin/eventorganization_confboothattendee_extrafields.php * \ingroup eventorganization * \brief Page to setup extra fields of conferenceorboothattendee */ From 5d181810daa91e61ef5d8afcd382b766d1f49c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:31:54 +0200 Subject: [PATCH 082/113] doxygen --- htdocs/admin/knowledgemanagement.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index 10f308b2b2c..8d93c16741a 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -17,7 +17,7 @@ */ /** - * \file knowledgemanagement/admin/setup.php + * \file htdocs/admin/knowledgemanagement.php * \ingroup knowledgemanagement * \brief KnowledgeManagement setup page. */ @@ -65,9 +65,7 @@ if (!$user->admin) { * Actions */ -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { $maskconstorder = GETPOST('maskconstorder', 'alpha'); From 10aa6106d2383ed9db80a7f6c8ee5c21009ce3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:34:08 +0200 Subject: [PATCH 083/113] doxygen --- htdocs/admin/paymentbybanktransfer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/paymentbybanktransfer.php b/htdocs/admin/paymentbybanktransfer.php index 50a266a2efe..997c71bb335 100644 --- a/htdocs/admin/paymentbybanktransfer.php +++ b/htdocs/admin/paymentbybanktransfer.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/admin/credtitransfer.php + * \file htdocs/admin/paymentbybanktransfer.php * \ingroup paymentbybanktransfer * \brief Page to setup payments by credit transfer */ From 5c4b55fe7fbf2ad5b57499f997b7bc6b5a85ba00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:35:17 +0200 Subject: [PATCH 084/113] doxygen https://doxygen.dolibarr.org/develop/doxygen-warnings.log --- htdocs/compta/facture/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/index.php b/htdocs/compta/facture/index.php index d3d3a33acb5..790b9d334c3 100644 --- a/htdocs/compta/facture/index.php +++ b/htdocs/compta/facture/index.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/compat/facture/index.php + * \file htdocs/compta/facture/index.php * \ingroup facture * \brief Home page of customer invoices area */ From 7bf07395c686a3dab8eba28bb886cc2b26700a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:37:41 +0200 Subject: [PATCH 085/113] doxygen https://doxygen.dolibarr.org/develop/doxygen-warnings.log --- htdocs/salaries/paiement_salary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/salaries/paiement_salary.php b/htdocs/salaries/paiement_salary.php index 9f9a1ae7b50..b1e03866d7e 100644 --- a/htdocs/salaries/paiement_salary.php +++ b/htdocs/salaries/paiement_salary.php @@ -18,7 +18,7 @@ */ /** - * \file htdocs/compta/paiement_salary.php + * \file htdocs/salaries/paiement_salary.php * \ingroup salary * \brief Page to add payment of a salary */ From c33d8ac49b3ef28de915aa775912986b7dcd3886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:40:33 +0200 Subject: [PATCH 086/113] doxygen https://doxygen.dolibarr.org/develop/doxygen-warnings.log --- htdocs/core/lib/eventorganization.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/eventorganization.lib.php b/htdocs/core/lib/eventorganization.lib.php index 2f8ea573c1f..51ff1f2a90f 100644 --- a/htdocs/core/lib/eventorganization.lib.php +++ b/htdocs/core/lib/eventorganization.lib.php @@ -16,7 +16,7 @@ */ /** - * \file eventorganization/lib/eventorganization.lib.php + * \file htdocs/core/lib/eventorganization.lib.php * \ingroup eventorganization * \brief Library files with common functions for EventOrganization */ From 365f2ba31ea0afd3795bf9cab809bdf3d4621807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:42:19 +0200 Subject: [PATCH 087/113] doxygen https://doxygen.dolibarr.org/develop/doxygen-warnings.log --- htdocs/mrp/class/api_mos.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 8fbd25090c7..59b4cbfa16b 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -22,7 +22,7 @@ require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; /** - * \file mrp/class/api_mo.class.php + * \file htdocs/mrp/class/api_mos.class.php * \ingroup mrp * \brief File for API management of MO. */ From 1ba0369f01fbd83b5aa63a92ff4d8b291fa0f0a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:47:30 +0200 Subject: [PATCH 088/113] doxygen https://doxygen.dolibarr.org/develop/doxygen-warnings.log --- htdocs/core/modules/product_batch/mod_lot_free.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/product_batch/mod_lot_free.php b/htdocs/core/modules/product_batch/mod_lot_free.php index 0f069143ab1..def14bd37b3 100644 --- a/htdocs/core/modules/product_batch/mod_lot_free.php +++ b/htdocs/core/modules/product_batch/mod_lot_free.php @@ -18,7 +18,7 @@ */ /** - * \file htdocs/core/modules/product/mod_lot_free.php + * \file htdocs/core/modules/product_batch/mod_lot_free.php * \ingroup productbatch * \brief File containing class for numbering model of Lot free */ From 0ebe4de80a7cbc60b95c01f77c488ee1a8cd42c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:48:27 +0200 Subject: [PATCH 089/113] doxygen https://doxygen.dolibarr.org/develop/doxygen-warnings.log --- htdocs/core/modules/product_batch/mod_sn_advanced.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php index 5e8fde199c1..abe094220d2 100644 --- a/htdocs/core/modules/product_batch/mod_sn_advanced.php +++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php @@ -22,7 +22,7 @@ */ /** - * \file htdocs/core/modules/product_batch/mod_batch_advanced.php + * \file htdocs/core/modules/product_batch/mod_sn_advanced.php * \ingroup productbatch * \brief File containing class for numbering model of SN advanced */ From 828c1d41e75fbefa20b47784c5a13969b7a2ab17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Oct 2021 13:49:33 +0200 Subject: [PATCH 090/113] doxygen https://doxygen.dolibarr.org/develop/doxygen-warnings.log --- htdocs/core/modules/product_batch/mod_sn_free.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/product_batch/mod_sn_free.php b/htdocs/core/modules/product_batch/mod_sn_free.php index 95e1bd20359..67d39ec085a 100644 --- a/htdocs/core/modules/product_batch/mod_sn_free.php +++ b/htdocs/core/modules/product_batch/mod_sn_free.php @@ -18,7 +18,7 @@ */ /** - * \file htdocs/core/modules/product/mod_sn_free.php + * \file htdocs/core/modules/product_batch/mod_sn_free.php * \ingroup productbatch * \brief File containing class for numbering model of SN free */ From 04a5dc2794bcd47386839ba0d1d57554a1518bbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Oct 2021 14:53:47 +0200 Subject: [PATCH 091/113] css --- htdocs/theme/md/style.css.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index d68bfa78ee9..e66a3c23d7d 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1859,6 +1859,7 @@ body.sidebar-collapse .side-nav, body.sidebar-collapse .login_block div.login_block { /* border-right: none ! important; */ top: inherit !important; + border-right: 1px solid rgba(0,0,0,0.3); } .side-nav { @@ -2810,9 +2811,9 @@ img.login, img.printer, img.entity { font-weight: bold; } .userimg.atoplogin img.userphoto, .userimgatoplogin img.userphoto { /* size for user photo in login bar */ - border-radius: 8px; - width: 16px; - height: 16px; + /* border-radius: 8px; */ + width: 20px; + height: 20px; background-size: contain; vertical-align: text-bottom; background-color: #FFF; From 227adaf5fccacfe68fa9c2b357929702cb53b201 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Oct 2021 15:26:29 +0200 Subject: [PATCH 092/113] CSS --- htdocs/theme/md/style.css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e66a3c23d7d..bb1fff44289 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1915,7 +1915,7 @@ div.login_block { padding-top: 20px; browser->layout, array('phone', 'tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> - top: 50px ! important; + top: 66px ! important; top: 60px ! important; From 7863642daaae1fecf02a123b02900f7d9173246a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Oct 2021 19:16:42 +0200 Subject: [PATCH 093/113] FIX #18852 --- htdocs/product/class/product.class.php | 4 +- .../stock/class/api_stockmovements.class.php | 5 +- .../stock/class/mouvementstock.class.php | 115 +++++++++--------- 3 files changed, 66 insertions(+), 58 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index de88ec9f277..1109c93fad9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5133,7 +5133,7 @@ class Product extends CommonObject $op[1] = "-".trim($nbpiece); $movementstock = new MouvementStock($this->db); - $movementstock->setOrigin($origin_element, $origin_id); // Set ->origin and ->origin->id + $movementstock->setOrigin($origin_element, $origin_id); // Set ->origin_type and ->origin_id $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', '', '', '', false, 0, $disablestockchangeforsubproduct); if ($result >= 0) { @@ -5180,7 +5180,7 @@ class Product extends CommonObject $op[1] = "-".trim($nbpiece); $movementstock = new MouvementStock($this->db); - $movementstock->setOrigin($origin_element, $origin_id); + $movementstock->setOrigin($origin_element, $origin_id); // Set ->origin_type and ->fk_origin $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot, false, 0, $disablestockchangeforsubproduct); if ($result >= 0) { diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 42a03a1836a..19f23edd4f4 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -165,11 +165,13 @@ class StockMovements extends DolibarrApi * @param string $price To update AWP (Average Weighted Price) when you make a stock increase (qty must be higher then 0). {@from body} * @param string $dlc Eat-by date. {@from body} {@type date} * @param string $dluo Sell-by date. {@from body} {@type date} + * @param string $origin_type Origin type (Element of source object, like 'project', 'inventory', ...) + * @param string $origin_id Origin id (Id of source object) * * @return int ID of stock movement * @throws RestException */ - public function post($product_id, $warehouse_id, $qty, $lot = '', $movementcode = '', $movementlabel = '', $price = '', $dlc = '', $dluo = '') + public function post($product_id, $warehouse_id, $qty, $lot = '', $movementcode = '', $movementlabel = '', $price = '', $dlc = '', $dluo = '', $origin_type = '', $origin_id = 0) { if (!DolibarrApiAccess::$user->rights->stock->creer) { throw new RestException(401); @@ -189,6 +191,7 @@ class StockMovements extends DolibarrApi $eatBy = empty($dluo) ? '' : dol_stringtotime($dluo); $sellBy = empty($dlc) ? '' : dol_stringtotime($dlc); + $this->stockmovement->setOrigin($origin_type, $origin_id); if ($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $eatBy, $sellBy, $lot) <= 0) { $errormessage = $this->stockmovement->error; if (empty($errormessage)) { diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index dd1b2202956..3a43d9ee6bb 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -54,8 +54,10 @@ class MouvementStock extends CommonObject /** * @var int Type of movement - * 0=input (stock increase by a stock transfer), 1=output (stock decrease after by a stock transfer), - * 2=output (stock decrease), 3=input (stock increase) + * 0=input (stock increase by a manual/direct stock transfer, correction or inventory), + * 1=output (stock decrease after by a manual/direct stock transfer, correction or inventory), + * 2=output (stock decrease after a business event like sale, shipment or manufacturing, ...), + * 3=input (stock increase after a business event like purchase, reception or manufacturing, ...) * Note that qty should be > 0 with 0 or 3, < 0 with 1 or 2. */ public $type; @@ -76,18 +78,32 @@ class MouvementStock extends CommonObject /** * @var int ID + * @deprecated + * @see $origin_id */ public $fk_origin; + /** + * @var int Origin id + */ + public $origin_id; + + /** + * @var string origintype + * @deprecated + * see $origin_type + */ public $origintype; + /** + * @var string Origin type ('project', ...) + */ + public $origin_type; + + public $inventorycode; public $batch; - /** - * @var Object Object set as origin before calling livraison() or reception() - */ - public $origin; public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10, 'showoncombobox'=>1), @@ -127,7 +143,7 @@ class MouvementStock extends CommonObject /** * Add a movement of stock (in one direction only). * This is the lowest level method to record a stock change. - * $this->origin can be also be set to save the source object of movement. + * $this->origin_type and $this->origin_id can be also be set to save the source object of movement. * * @param User $user User object * @param int $fk_product Id of product @@ -403,25 +419,20 @@ class MouvementStock extends CommonObject } if ($movestock) { // Change stock for current product, change for subproduct is done after - // Set $origintype, fk_origin, fk_project - $fk_project = 0; - if (!empty($this->origin)) { // This is set by caller for tracking reason - $origintype = empty($this->origin->origin_type) ? $this->origin->element : $this->origin->origin_type; - $fk_origin = $this->origin->id; - if ($origintype == 'project') { - $fk_project = $fk_origin; - } else { - $res = $this->origin->fetch($fk_origin); - if ($res > 0) { - if (!empty($this->origin->fk_project)) { - $fk_project = $this->origin->fk_project; - } - } + // Set $origin_type, origin_id and fk_project + $fk_project = $this->fk_project; + if (!empty($this->origin_type)) { // This is set by caller for tracking reason + $origin_type = $this->origin_type; + $origin_id = $this->origin_id; + if (empty($fk_project) && $origin_type == 'project') { + $fk_project = $origin_id; + $origin_type = ''; + $origin_id = 0; } } else { - $origintype = ''; - $fk_origin = 0; $fk_project = 0; + $origin_type = ''; + $origin_id = 0; } $sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement("; @@ -437,8 +448,8 @@ class MouvementStock extends CommonObject $sql .= " '".$this->db->escape($label)."',"; $sql .= " ".($inventorycode ? "'".$this->db->escape($inventorycode)."'" : "null").","; $sql .= " ".((float) price2num($price)).","; - $sql .= " ".((int) $fk_origin).","; - $sql .= " '".$this->db->escape($origintype)."',"; + $sql .= " ".((int) $origin_id).","; + $sql .= " '".$this->db->escape($origin_type)."',"; $sql .= " ".((int) $fk_project); $sql .= ")"; @@ -626,8 +637,8 @@ class MouvementStock extends CommonObject $sql .= " t.type_mouvement,"; $sql .= " t.fk_user_author,"; $sql .= " t.label,"; - $sql .= " t.fk_origin,"; - $sql .= " t.origintype,"; + $sql .= " t.fk_origin as origin_id,"; + $sql .= " t.origintype as origin_type,"; $sql .= " t.inventorycode,"; $sql .= " t.batch,"; $sql .= " t.eatby,"; @@ -654,8 +665,10 @@ class MouvementStock extends CommonObject $this->price = $obj->price; $this->fk_user_author = $obj->fk_user_author; $this->label = $obj->label; - $this->fk_origin = $obj->fk_origin; - $this->origintype = $obj->origintype; + $this->fk_origin = $obj->origin_id; // For backward compatibility + $this->origintype = $obj->origin_type; // For backward compatibility + $this->origin_id = $obj->origin_id; + $this->origin_type = $obj->origin_type; $this->inventorycode = $obj->inventorycode; $this->batch = $obj->batch; $this->eatby = $this->db->jdate($obj->eatby); @@ -730,6 +743,7 @@ class MouvementStock extends CommonObject foreach ($pids as $key => $value) { if (!$error) { $tmpmove = dol_clone($this, 1); + $result = $tmpmove->_create($user, $pids[$key], $entrepot_id, ($qty * $pqtys[$key]), $type, 0, $label, $inventorycode); // This will also call _createSubProduct making this recursive if ($result < 0) { $this->error = $tmpmove->error; @@ -921,16 +935,16 @@ class MouvementStock extends CommonObject /** * Return Url link of origin object * - * @param int $fk_origin Id origin - * @param int $origintype Type origin + * @param int $origin_id Id origin + * @param int $origin_type Type origin * @return string */ - public function get_origin($fk_origin, $origintype) + public function get_origin($origin_id, $origin_type) { // phpcs:enable $origin = ''; - switch ($origintype) { + switch ($origin_type) { case 'commande': require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $origin = new Commande($this->db); @@ -973,11 +987,11 @@ class MouvementStock extends CommonObject break; default: - if ($origintype) { + if ($origin_type) { // Separate originetype with "@" : left part is class name, right part is module name - $origintype_array = explode('@', $origintype); - $classname = ucfirst($origintype_array[0]); - $modulename = empty($origintype_array[1]) ? $classname : $origintype_array[1]; + $origin_type_array = explode('@', $origin_type); + $classname = ucfirst($origin_type_array[0]); + $modulename = empty($origin_type_array[1]) ? $classname : $origin_type_array[1]; $result = dol_include_once('/'.$modulename.'/class/'.strtolower($classname).'.class.php'); if ($result) { $classname = ucfirst($classname); @@ -991,7 +1005,7 @@ class MouvementStock extends CommonObject return ''; } - if ($origin->fetch($fk_origin) > 0) { + if ($origin->fetch($origin_id) > 0) { return $origin->getNomUrl(1); } @@ -999,29 +1013,20 @@ class MouvementStock extends CommonObject } /** - * Set attribute origin to object + * Set attribute origin_type and fk_origin to object * - * @param string $origin_element type of element - * @param int $origin_id id of element + * @param string $origin_element Type of element + * @param int $origin_id Id of element * * @return void */ public function setOrigin($origin_element, $origin_id) { - if (!empty($origin_element) && $origin_id > 0) { - $origin = ''; - if ($origin_element == 'project') { - if (!class_exists('Project')) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - } - $origin = new Project($this->db); - } - - if (!empty($origin)) { - $this->origin = $origin; - $this->origin->id = $origin_id; - } - } + $this->origin_type = $origin_element; + $this->origin_id = $origin_id; + // For backward compatibility + $this->origintype = $origin_element; + $this->fk_origin = $origin_id; } From 2fe1b548ef9f4f923ddd2f78033c075a12e2b53a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Oct 2021 19:45:58 +0200 Subject: [PATCH 094/113] Show label of permission as tooltip on list of modules/app --- htdocs/admin/system/modules.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 150ca10a359..a56ed8c1da3 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -91,6 +91,7 @@ $modules_files = array(); $modules_fullpath = array(); $modulesdir = dolGetModulesDirs(); $rights_ids = array(); +$arrayofpermissions = array(); foreach ($modulesdir as $dir) { $handle = @opendir(dol_osencode($dir)); @@ -155,7 +156,7 @@ foreach ($modules as $key => $module) { if (empty($rights[0])) { continue; } - + $arrayofpermissions[$rights[0]] = array('label'=> 'user->rights->'.$module->rights_class.'->'.$rights[4].(empty($rights[5]) ? '' : '->'.$rights[5])); $permission[] = $rights[0]; array_push($rights_ids, $rights[0]); @@ -336,8 +337,10 @@ foreach ($moduleList as $module) { $idperms = ''; foreach ($module->permission as $permission) { - $idperms .= ($idperms ? ", " : "").$permission; $translationKey = "Permission".$permission; + $labelpermission = $langs->trans($translationKey); + $labelpermission .= ' : '.$arrayofpermissions[$permission]['label']; + $idperms .= ($idperms ? ", " : "").''.$permission.''; if (!empty($conf->global->MAIN_SHOW_PERMISSION)) { if (empty($langs->tab_translate[$translationKey])) { From d99b3d601a2d020bb17965045909a3d1814acb54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Oct 2021 20:07:09 +0200 Subject: [PATCH 095/113] FIX #18854 --- htdocs/ecm/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 3a8d33343c7..813ee69b6fb 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -42,6 +42,7 @@ if (!$section) { $section = 0; } $section_dir = GETPOST('section_dir', 'alpha'); +$overwritefile = GETPOST('overwritefile', 'int'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -120,7 +121,7 @@ if (GETPOST("sendit", 'alphanohtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) if (!$error) { $generatethumbs = 0; - $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', null, '', $generatethumbs); + $res = dol_add_file_process($upload_dir, $overwritefile, 1, 'userfile', '', null, '', $generatethumbs); if ($res > 0) { $result = $ecmdir->changeNbOfFiles('+'); } From 55e97784bd19bd5decb5f32434c6d7526b3f7274 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Oct 2021 20:42:54 +0200 Subject: [PATCH 096/113] FIX #18880 --- htdocs/install/mysql/data/llx_c_tva.sql | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index cae269783e4..12b0b92a13e 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -330,7 +330,7 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (10 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (105,10, '15','0','VAT 12% Majoré à 25% (15%)',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (106,10, '22.5','0','VAT 18% Majoré à 25% (22.5%)',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (107,10, '6','0','VAT 6%', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (107,10,'18.18','0','VAT 18%+FODEC', 1, 1, '4', 0, 0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active,localtax1,localtax1_type,localtax2,localtax2_type) values (108,10,'18.18','0','VAT 18%+FODEC', 1, 1, '4', 0, 0); -- UKRAINE (id country=226) INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2261,226, '0','0','VAT rate 0',1); @@ -379,10 +379,6 @@ INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 4 INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 462, 46, '15','0','VAT 15%',1); INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 463, 46, '7.5','0','VAT 7.5%',1); --- SOUTH AFRICA (id country=205) -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2051,205, '0','0','No VAT',1); -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2052,205, '14','0','VAT 14%',1); - -- VENEZUELA (id country=232) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2321,232, '0','0','No VAT',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2322,232, '12','0','VAT 12%',1); From a5daf9de9d722cb77209e37d86bdc85e023ff924 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Oct 2021 21:09:03 +0200 Subject: [PATCH 097/113] Update admin.lang --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 84e670b339a..f28b2a085e9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -517,7 +517,7 @@ Field=Field ProductDocumentTemplates=Document templates to generate product document FreeLegalTextOnExpenseReports=Free legal text on expense reports WatermarkOnDraftExpenseReports=Watermark on draft expense reports -PrefillExpenseReportDatesWithCurrentMonth=Pre-fill dates with start and end dates of the current month +PrefillExpenseReportDatesWithCurrentMonth=Pre-fill start and end dates of new expense report with start and end dates of the current month AttachMainDocByDefault=Set this to 1 if you want to attach main document to email by default (if applicable) FilesAttachedToEmail=Attach file SendEmailsReminders=Send agenda reminders by emails From b1eb1c1070307b3454f9bbc76aee6c8734ea537f Mon Sep 17 00:00:00 2001 From: stepanych Date: Sun, 3 Oct 2021 01:08:22 +0200 Subject: [PATCH 098/113] fix issue #18875 added check for $$search_array_options --- htdocs/reception/list.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index b7f3f577ce2..f32e09aa580 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -618,11 +618,13 @@ if ($search_ref_supplier) { $param .= "&search_ref_supplier=".urlencode($search_ref_supplier); } // Add $param from extra fields -foreach ($search_array_options as $key => $val) { - $crit = $val; - $tmpkey = preg_replace('/search_options_/', '', $key); - if ($val != '') { - $param .= '&search_options_'.$tmpkey.'='.urlencode($val); +if ($search_array_options) { + foreach ($search_array_options as $key => $val) { + $crit = $val; + $tmpkey = preg_replace('/search_options_/', '', $key); + if ($val != '') { + $param .= '&search_options_' . $tmpkey . '=' . urlencode($val); + } } } From 042d52006150fe1e7b3ac7fa374d6dc22815fb47 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 3 Oct 2021 05:30:49 +0200 Subject: [PATCH 099/113] Change Url --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 0adcb967991..3271d74a4dd 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -724,7 +724,7 @@ function getFormeJuridiqueLabel($code) function getCountriesInEEC() { // List of all country codes that are in europe for european vat rules - // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 + // List found on https://europa.eu/european-union/about-eu/countries_en global $conf, $db; $country_code_in_EEC = array(); From 94166cdb7e30398ab60093d71d0479a56a825582 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 3 Oct 2021 05:36:53 +0200 Subject: [PATCH 100/113] FIX Remove Isle of Man of ECC's countries --- htdocs/install/mysql/data/llx_00_c_country.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_00_c_country.sql b/htdocs/install/mysql/data/llx_00_c_country.sql index 4465756f00a..7217fda7d09 100644 --- a/htdocs/install/mysql/data/llx_00_c_country.sql +++ b/htdocs/install/mysql/data/llx_00_c_country.sql @@ -279,5 +279,5 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (24 -- Set field eec -UPDATE llx_c_country SET eec = 1 WHERE code IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','NL','HU','IE','IM','IT','LT','LU','LV','MC','MT','PL','PT','RO','SE','SK','SI'); +UPDATE llx_c_country SET eec = 1 WHERE code IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','NL','HU','IE','IT','LT','LU','LV','MC','MT','PL','PT','RO','SE','SK','SI'); From 42bb9ac6d2a8da328560f88219735aed8994fde8 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 3 Oct 2021 05:49:54 +0200 Subject: [PATCH 101/113] Better URL --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 3271d74a4dd..efea4c54b09 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -724,7 +724,7 @@ function getFormeJuridiqueLabel($code) function getCountriesInEEC() { // List of all country codes that are in europe for european vat rules - // List found on https://europa.eu/european-union/about-eu/countries_en + // List found on https://ec.europa.eu/taxation_customs/territorial-status-eu-countries-and-certain-territories_en global $conf, $db; $country_code_in_EEC = array(); From d6e1a6be93f3323b5ffff5478f4936d0443d2296 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Oct 2021 18:20:01 +0200 Subject: [PATCH 102/113] Look and feel v14 --- htdocs/core/class/html.form.class.php | 14 +++++++------- htdocs/core/tpl/contacts.tpl.php | 10 +++++----- .../eventorganization/conferenceorbooth_list.php | 1 + .../conferenceorboothattendee_list.php | 1 + htdocs/projet/tasks/time.php | 1 + 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 221e641ad8d..39d53e9dbc7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1675,11 +1675,6 @@ class Form if ($resql) { $num = $this->db->num_rows($resql); - if ($conf->use_javascript_ajax && !$forcecombo && !$options_only) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); - } - if ($htmlname != 'none' && !$options_only) { $out .= ''; } + if ($conf->use_javascript_ajax && !$forcecombo && !$options_only) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); + } + $this->num = $num; return $out; } else { @@ -8529,8 +8529,8 @@ class Form public function showFilterButtons() { $out = '
'; - $out .= ''; - $out .= ''; + $out .= ''; + $out .= ''; $out .= '
'; return $out; diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 1257d473ced..4ec84283345 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -135,19 +135,19 @@ if ($permission) { + '; } ?> -
+
socid) ? 0 : $object->socid); $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0, '', 'minwidth300imp'); ?>
- -
+
selectcontacts(($selectedCompany > 0 ? $selectedCompany : -1), '', 'contactid', 3, '', '', 1, 'minwidth100imp'); + print img_object('', 'contact', 'class="pictofixedwidth"').$form->selectcontacts(($selectedCompany > 0 ? $selectedCompany : -1), '', 'contactid', 3, '', '', 1, 'minwidth100imp widthcentpercentminusxx maxwidth400'); $nbofcontacts = $form->num; $newcardbutton = ''; @@ -157,7 +157,7 @@ if ($permission) { print $newcardbutton; ?>
-
+
element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 9c086528120..a002aa2844c 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -643,6 +643,7 @@ print ''; print ''; print ''; print ''; +print ''; $title = $langs->trans("ListOfConferencesOrBooths"); diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 801ecb1d69f..849513710f7 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -697,6 +697,7 @@ print ''; print ''; print ''; print ''; +print ''; $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_card.php?action=create'.(!empty($confOrBooth->id)?'&conforboothid='.$confOrBooth->id:'').(!empty($projectstatic->id)?'&fk_project='.$projectstatic->id:'').$withProjectUrl.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.(empty($confOrBooth->id) ? '' : '&conforboothid='.$confOrBooth->id).$withProjectUrl), '', $permissiontoadd); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 8e5877c7d0d..9e27f026c9d 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -992,6 +992,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { print ''; print ''; print ''; + print ''; // Form to convert time spent into invoice if ($massaction == 'generateinvoice') { From 2c32c6c5c9b7d9b454068d37c85653c8bf87c58d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Oct 2021 19:17:23 +0200 Subject: [PATCH 103/113] Fix contextpage for list of tickets --- htdocs/theme/eldy/global.inc.php | 21 ++++++++++++++++++--- htdocs/ticket/list.php | 5 ++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 79977faac6a..9ddaab40e65 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1732,6 +1732,20 @@ td.showDragHandle { display: inline-block; } +/* +.classforhorizontalscrolloftabs .fiche .div-table-responsive +{ + transform:rotateX(180deg); + -ms-transform:rotateX(180deg); + -webkit-transform:rotateX(180deg); +} +.classforhorizontalscrolloftabs .fiche .div-table-responsive-inside +{ + transform:rotateX(180deg); + -ms-transform:rotateX(180deg); + -webkit-transform:rotateX(180deg); +} +*/ global->THEME_DISABLE_STICKY_TOPMENU)) { ?> @@ -1842,10 +1856,11 @@ div.vmenu, td.vmenu { display: none; } - /* if no side-nav, we don't need to have width forced */ + /* if no side-nav, we don't need to have width forced to calc(100% - 210px); */ .classforhorizontalscrolloftabs #id-right { - width: unset; - display: unset; + width: 100%; + /* width: unset; */ + /* display: unset; */ } body.sidebar-collapse .login_block { diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index c79a75e851c..6991516ede8 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -45,7 +45,7 @@ $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'tickep#selectedfieldstlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'ticketlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -698,6 +698,7 @@ print ''; print ''; print ''; print ''; + if ($socid) { print ''; } @@ -759,6 +760,7 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; print '
'.$langs->trans('BarcodeValue').''.img_picto('', 'barcode', 'class="pictofixedwidth"').'
'.$langs->trans('BarcodeValue').''.img_picto('', 'barcode', 'class="pictofixedwidth"').'
'.$langs->trans("Charges").''; + print ''; print '
'; - print $productfourn->supplier_barcode; - print ''; @@ -1168,6 +1162,13 @@ END; print ''; + print $productfourn->supplier_barcode; + print ''; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 49ffd69fd0b..773a097fed8 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1161,7 +1161,7 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''; + print ''; } } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index b6498ca4032..c00c1d70367 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -381,7 +381,7 @@ if (empty($reshook) && $action == 'add') { $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION; // TODO Make replacement of __AMOUNT__, etc... } else { - $urlback = $_SERVER["PHP_SELF"]."?action=added"; + $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); } if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index ca7101a3679..1d673991d3d 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -311,7 +311,7 @@ if (empty($reshook) && $action == 'add') { $urlback = $conf->global->PROJECT_URL_REDIRECT_LEAD; // TODO Make replacement of __AMOUNT__, etc... } else { - $urlback = $_SERVER["PHP_SELF"]."?action=added"; + $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); } if (!empty($entity)) { diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index c29717f002d..21dd3b9643b 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -525,7 +525,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print "\n".'
'."\n"; if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''; + print ''; } print "\n
\n"; diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index b3ba955f4e8..64040a24466 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -212,9 +212,9 @@ $( document ).ready(function() { admin) {?> &place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline, function() { global->TAKEPOS_CUSTOMER_DISPLAY)) echo "CustomerDisplay();";?> }); } diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index ad5d8f9fbd2..8b2e5ca78b7 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1056,12 +1056,12 @@ function DolibarrTakeposPrinting(id) { } function CreditNote() { - $("#poslines").load("invoice.php?action=creditnote&invoiceid="+placeid, function() { + $("#poslines").load("invoice.php?action=creditnote&token=&invoiceid="+placeid, function() { }); } function SetNote() { - $("#poslines").load("invoice.php?action=addnote&invoiceid="+placeid+"&idline="+selectedline+"&addnote="+$("#textinput").val(), function() { + $("#poslines").load("invoice.php?action=addnote&token=&invoiceid="+placeid+"&idline="+selectedline+"&addnote="+$("#textinput").val(), function() { }); } diff --git a/htdocs/takepos/phone.php b/htdocs/takepos/phone.php index 7eaa4d9ec68..b655d9f7789 100644 --- a/htdocs/takepos/phone.php +++ b/htdocs/takepos/phone.php @@ -238,10 +238,10 @@ function AddProductConfirm(placeid, productid){ place=placeid; diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 46506163c1f..478e345f2e3 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -248,9 +248,9 @@ if ($object->id > 0) { print '
'.$langs->trans("Module").''; - print ''.$langs->trans("All").""; + print ''.$langs->trans("All").""; print '/'; - print ''.$langs->trans("None").""; + print ''.$langs->trans("None").""; print ' '; - print 'module.'&token='.newToken().'">'.$langs->trans("All").""; + print 'module.'&token='.newToken().'">'.$langs->trans("All").""; print '/'; - print 'module.'&token='.newToken().'">'.$langs->trans("None").""; + print 'module.'&token='.newToken().'">'.$langs->trans("None").""; print ' id.'&confirm=yes&token='.newToken().'">'; + print 'id.'&confirm=yes&token='.newToken().'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); print 'id.'&confirm=yes&token='.newToken().'">'; + print 'id.'&confirm=yes&token='.newToken().'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); print 'id.'&confirm=yes&token='.newToken().'">'; + print 'id.'&confirm=yes&token='.newToken().'">'; //print img_edit_add($langs->trans("Add")); print img_picto($langs->trans("Add"), 'switch_off'); print '
'."\n"; @@ -1088,6 +1090,7 @@ print $hookmanager->resPrint; print '
'."\n"; print ''."\n"; +print ''."\n"; print ''."\n"; From 6a6678438f5cd719d39bf858d98927bbad1a92bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Oct 2021 19:30:51 +0200 Subject: [PATCH 104/113] Update doc --- SECURITY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 61f4a392db8..427b1cc7ae2 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -54,12 +54,12 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us * $dolibarr_main_prod must be set to 1 into conf.php * $dolibarr_nocsrfcheck must be kept to the value 0 into conf.php (this is the default value) * $dolibarr_main_force_https must be set to something else than 0. -* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 2 into backoffice menu Home - Setup - Other (this protection should be set to 2 soon by default) +* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 3 into backoffice menu Home - Setup - Other (this protection should be set to 3 soon by default) * The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools) * ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities). * The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer). * The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly. -* CSRF attacks are accepted when using a POST URL, but when using GET URL, they are validated only for creating, updating or deleting data resctricted from pages restricted to admin users. +* CSRF attacks are accepted but double check that you have set MAIN_SECURITY_CSRF_WITH_TOKEN to value 3. * Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user. Scope is the web application (back office) and the APIs. From e46d064d5e4f5bb19757b649f4badb980483476f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Oct 2021 20:36:03 +0200 Subject: [PATCH 105/113] Clean text --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7878f6270a7..5116c7b21ce 100644 --- a/README.md +++ b/README.md @@ -154,18 +154,18 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### Other application/modules -- Electronic Document Management (EDM) +- Electronic Document Management (EDM) - Bookmarks management - Reporting - Data export/import -- Barcodes +- Barcodes - Margin calculations - LDAP connectivity - ClickToDial integration - Mass emailing - RSS integration - Skype integration -- Social platforms linking +- Social platforms linking - Payment platforms integration (PayPal, Stripe, Paybox...) - Email-Collector @@ -179,14 +179,11 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Multi-Users and groups with finely grained rights - Multi-Currency - Multi-Company (by adding of an external module) - - Very user friendly and easy to use - customizable Dashboard - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) - - APIs (REST, SOAP) - Code that is easy to understand, maintain and develop (PHP with no heavy framework; trigger and hook architecture) - - Support a lot of country specific features: - Spanish Tax RE and ISPF - French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM) @@ -197,7 +194,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Compatible with European GDPR rules - ... - Flexible PDF & ODT generation for invoices, proposals, orders... -- … +- ... ### System Environment / Requirements From b3cb56f2eff9a97293cca6c21399b96e6efc20a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Oct 2021 04:14:31 +0200 Subject: [PATCH 106/113] Clean css --- htdocs/admin/boxes.php | 2 +- htdocs/comm/mailing/index.php | 2 +- htdocs/compta/paymentbybanktransfer/index.php | 4 +- htdocs/compta/prelevement/index.php | 2 +- htdocs/compta/prelevement/list.php | 2 +- htdocs/compta/prelevement/orders_list.php | 2 +- htdocs/compta/prelevement/rejets.php | 2 +- htdocs/contact/consumption.php | 4 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formother.class.php | 4 +- htdocs/core/lib/usergroups.lib.php | 4 +- .../core/tpl/admin_extrafields_view.tpl.php | 4 +- htdocs/modulebuilder/index.php | 8 +- htdocs/product/admin/dynamic_prices.php | 4 +- htdocs/societe/consumption.php | 4 +- htdocs/societe/paymentmodes.php | 2 +- htdocs/theme/eldy/global.inc.php | 96 ++++++------ htdocs/theme/eldy/style.css.php | 2 + htdocs/theme/md/style.css.php | 139 +++++++++--------- 19 files changed, 149 insertions(+), 140 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 2e4226e89d5..afcba2ef23d 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -360,7 +360,7 @@ foreach ($boxtoadd as $box) { print '
'.$langs->trans("AllWidgetsWereEnabled").'
'.$langs->trans("AllWidgetsWereEnabled").'
'."\n"; print ''; diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 01abc1e5ef1..66860669e2d 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -184,7 +184,7 @@ if ($result) { $i++; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print "
"; $db->free($result); diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index 25763dd8339..8c8c029f8d8 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -166,7 +166,7 @@ if ($resql) { $i++; } } else { - print ''.$langs->trans("NoSupplierInvoiceToWithdraw", $langs->transnoentitiesnoconv("BankTransfer")).''; + print ''.$langs->trans("NoSupplierInvoiceToWithdraw", $langs->transnoentitiesnoconv("BankTransfer")).''; } print "
"; } else { @@ -223,7 +223,7 @@ if ($result) { $i++; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print "
"; diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index c0f89a7e046..d4bfdb10588 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -225,7 +225,7 @@ if ($result) { $i++; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print "
"; diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index feb69bdc7fb..65f4ba7b142 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -274,7 +274,7 @@ if ($result) { $i++; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ""; print ''; diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index 3ca9ce32fbe..011f29f4f5c 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -217,7 +217,7 @@ if ($result) { $i++; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ""; diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index ed8c704bcfa..1abc717dbe0 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -140,7 +140,7 @@ if ($result) { $i++; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ""; diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 974bfb15e77..bb610baa4b0 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -645,7 +645,7 @@ if ($sql_select) { print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); print "\n"; - print ''.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).''; + print ''.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).''; print ""; } else { @@ -653,7 +653,7 @@ if ($sql_select) { print ''."\n"; - print ''; + print ''; print "
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("FeatureNotYetAvailable").'
"; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8deda2ecd09..a98957969cb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -791,7 +791,7 @@ class Form // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button $ret .= ''; // Hidden button BEFORE so it is the one used when we submit with ENTER. - $ret .= 'use_javascript_ajax) ? '' : ' style="display: none"').' class="button'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' '.$name.' '.$name.'confirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">'; + $ret .= 'use_javascript_ajax) ? '' : ' style="display: none"').' class="button small'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' '.$name.' '.$name.'confirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">'; $ret .= ''; if (!empty($conf->use_javascript_ajax)) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 8c30d42075f..99ee1b6af9b 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -863,9 +863,9 @@ class FormOther } }, function(color, context) { console.log("close"); }, - function(color, context) { var hex = color.val(\'hex\'); console.log("new color selected in jpicker "+hex);'; + function(color, context) { var hex = color.val(\'hex\'); console.log("new color selected in jpicker "+hex+" setpropertyonselect='.dol_escape_js($setpropertyonselect).'");'; if ($setpropertyonselect) { - $out .= ' if (hex != null) document.documentElement.style.setProperty(\'--'.$setpropertyonselect.'\', \'#\'+hex);'; + $out .= ' if (hex != null) document.documentElement.style.setProperty(\'--'.dol_escape_js($setpropertyonselect).'\', \'#\'+hex);'; } $out .= '}, function(color, context) { console.log("cancel"); } diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 7a9bb12172b..84b0ada3487 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -339,7 +339,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) $thumbsbyrow = 6; print '
'; - print ''; + print '
'; // Title if ($foruserprofile) { @@ -400,7 +400,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) if (!file_exists($file)) { $url = DOL_URL_ROOT.'/public/theme/common/nophoto.png'; } - print ''; + print ''; if ($subdir == $conf->global->MAIN_THEME) { $title = $langs->trans("ThemeCurrentlyActive"); } else { diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 2f1c113fcf5..6750cc0b1a5 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -141,9 +141,9 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel } print ''; - print ''; + print ''; print ''; } diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 4a3f9fd6e25..ea0af722885 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2309,7 +2309,7 @@ if ($module == 'initmodule') { $i++; } } else { - print ''; + print ''; } print '
'; + print ''; print $langs->trans("None"); - print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; @@ -3106,7 +3106,7 @@ if ($module == 'initmodule') { print ''; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ''; @@ -3199,7 +3199,7 @@ if ($module == 'initmodule') { print ''; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ''; @@ -3696,7 +3696,7 @@ if ($module == 'initmodule') { print ''; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ''; diff --git a/htdocs/product/admin/dynamic_prices.php b/htdocs/product/admin/dynamic_prices.php index 9a354a8dcdb..e1e23feac86 100644 --- a/htdocs/product/admin/dynamic_prices.php +++ b/htdocs/product/admin/dynamic_prices.php @@ -182,9 +182,9 @@ if ($action != 'create_updater' && $action != 'edit_updater') { print ''; } } else { - print ''; + print ''; print $langs->trans("None"); - print ''; + print ''; } print ''; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 5f996e6f37d..b5a7b5cd8ea 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -686,7 +686,7 @@ if ($sql_select) { print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); print "\n"; - print ''.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).''; + print ''.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).''; print ""; } else { @@ -694,7 +694,7 @@ if ($sql_select) { print ''."\n"; - print ''; + print ''; print "
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("FeatureNotYetAvailable").'
"; } diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index f80bebd9bf5..49ec346ec3f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1227,7 +1227,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' if ($nbremote == 0 && $nblocal == 0) { $colspan = (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD) ? 10 : 9); - print ''.$langs->trans("None").''; + print '>'.$langs->trans("None").''; } print ""; print "
"; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 708870eeaa6..bb1f8a6423d 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -13,7 +13,7 @@ --colorbacktitle1: rgb(); --colorbacktabcard1: rgb(); --colorbacktabactive: rgb(); - --colorbacklineimpair1: rgb(); + --colorbacklinepair1: rgb(); --colorbacklineimpair2: rgb(); --colorbacklinepair1: rgb(); --colorbacklinepair2: rgb(); @@ -28,8 +28,9 @@ --colortexttitlelink: rgba(, 0.9); --colortext: rgb(); --colortextlink: rgb(); - --colortextbackhmenu: #; + --colortextbackhmenu: #; --colortextbackvmenu: #; + --colortopbordertitle1: rgb(); --listetotal: #888888; --inputbackgroundcolor: #FFF; --inputbordercolor: rgba(0,0,0,.2); @@ -2222,12 +2223,12 @@ img.photorefnoborder { .underrefbanner { } .underbanner { - border-bottom: px solid rgb(); + border-bottom: px solid var(--colortopbordertitle1); /* border-bottom: 2px solid var(--colorbackhmenu1); */ } .trextrafieldseparator td, .trextrafields_collapse_last td { /* border-bottom: 2px solid var(--colorbackhmenu1) !important; */ - border-bottom: 2px solid rgb() !important; + border-bottom: 2px solid var(--colortopbordertitle1) !important; } .tdhrthin { @@ -3364,10 +3365,10 @@ td.border, div.tagtable div div.border { border-bottom: none !important; } .bordertop { - border-top: 1px solid rgb(); + border-top: 1px solid var(--colortopbordertitle1); } .borderbottom { - border-bottom: 1px solid rgb(); + border-bottom: 1px solid var(--colortopbordertitle1); } @@ -3379,10 +3380,15 @@ table.liste, table.noborder, table.formdoc, div.noborder { border-collapse: separate !important; border-spacing: 0px; border-top-width: px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; margin: 0px 0px 5px 0px; + + border-left: 1px solid var(--colortopbordertitle1); + border-right: 1px solid var(--colortopbordertitle1); + /*width: calc(100% - 7px); border-collapse: separate !important; border-spacing: 0px; @@ -3395,20 +3401,20 @@ table.liste, table.noborder, table.formdoc, div.noborder { } #tablelines { border-bottom-width: 1px; - border-bottom-color: rgb(); + border-bottom-color: var(--colortopbordertitle1); border-bottom-style: solid; } table.liste tr:last-of-type td, table.noborder:not(#tablelines) tr:last-of-type td, table.formdoc tr:last-of-type td, div.noborder tr:last-of-type td { border-bottom-width: 1px; - border-bottom-color: rgb(); + border-bottom-color: var(--colortopbordertitle1); border-bottom-style: solid; } div.tabBar div.fichehalfright table.noborder:not(.margintable):not(.paymenttable):not(.lastrecordtable):last-of-type { - border-bottom: 1px solid rgb(); + border-bottom: 1px solid var(--colortopbordertitle1); } div.tabBar table.border>tbody>tr:last-of-type>td { border-bottom-width: 1px; - border-bottom-color: rgb(); + border-bottom-color: var(--colortopbordertitle1); border-bottom-style: solid; } div.tabBar div.fichehalfright table.noborder { @@ -3442,7 +3448,7 @@ tr.liste_titre_filter td.liste_titre:first-of-type { { border-bottom-width: 0 !important; border-top-width: 1px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; } tr#trlinefordates td { @@ -3451,7 +3457,7 @@ tr#trlinefordates td { .liste_titre_add td, .liste_titre_add th, .liste_titre_add .tagtd { border-top-width: 1px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; } table.liste tr, table.noborder tr, div.noborder form { @@ -3716,14 +3722,14 @@ table.hidepaginationnext .paginationnext { { font-family: ; margin-bottom: 1px; - color: var(--oddevencolor); + color: var(--oddeven); } .impair, .nohover .impair:hover, tr.impair td.nohover { - background: var(--colorbacklineimpair1); + background-color: var(--colorbacklineimpair2); } #GanttChartDIV { - background-color: var(--colorbacklineimpair1); + background-color: var(--colorbacklineimpair2); } .oddeven, .evenodd, .pair, .nohover .pair:hover, tr.pair td.nohover, .tagtr.oddeven { @@ -3732,21 +3738,21 @@ table.hidepaginationnext .paginationnext { color: var(--oddevencolor); } .pair, .nohover .pair:hover, tr.pair td.nohover { - background-color: var(--colorbacklinepair1); + background-color: var(--colorbacklinepair2); } table.dataTable tr.oddeven { - background-color: var(--colorbacklinepair1) !important; + background-color: var(--colorbacklinepair2) !important; } /* For no hover style */ td.oddeven, table.nohover tr.impair, table.nohover tr.pair, table.nohover tr.impair td, table.nohover tr.pair td, tr.nohover td, form.nohover, form.nohover:hover { - background-color: var(--colorbacklineimpair1) !important; - background: var(--colorbacklineimpair1) !important; + background-color: var(--colorbacklineimpair2) !important; + background: var(--colorbacklineimpair2) !important; } td.evenodd, tr.nohoverpair td, #trlinefordates td { - background-color: var(--colorbacklinepair1) !important; - background: var(--colorbacklinepair1) !important; + background-color: var(--colorbacklinepair2) !important; + background: var(--colorbacklinepair2) !important; } .trforbreak td { font-weight: 500; @@ -3781,7 +3787,9 @@ tr.pair td .nobordernopadding tr td, tr.impair td .nobordernopadding tr td { } table.nobottomiftotal tr.liste_total td { background-color: #fff; + border-bottom: 0px !important; + } table.nobottom, td.nobottom { border-bottom: 0px !important; @@ -3797,8 +3805,12 @@ div.liste_titre { } div.liste_titre_bydiv { border-top-width: px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; + + border-left: px solid var(--colortopbordertitle1); + /* border-right: px solid var(--colortopbordertitle1); */ + border-collapse: collapse; display: table; @@ -3829,7 +3841,7 @@ div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_se } tr.liste_titre th, tr.liste_titre td, th.liste_titre { - border-bottom: 1px solid rgb(); + border-bottom: 1px solid var(--colortopbordertitle1); } tr.liste_titre:first-child th, tr:first-child th.liste_titre { /* border-bottom: 1px solid #ddd ! important; */ @@ -3848,7 +3860,7 @@ tr.liste_titre th a, th.liste_titre a, tr.liste_titre td a, td.liste_titre a, fo } tr.liste_titre_topborder td { border-top-width: px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; } .liste_titre td a { @@ -3949,7 +3961,7 @@ div.tabBar .noborder { } #tablelines tr.liste_titre td, .paymenttable tr.liste_titre td, .margintable tr.liste_titre td, .tableforservicepart1 tr.liste_titre td { - border-bottom: 1px solid rgb() !important; + border-bottom: 1px solid var(--colortopbordertitle1) !important; } #tablelines tr td { height: unset; @@ -3961,11 +3973,10 @@ div.tabBar .noborder { div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre), div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(even):not(.liste_titre) { - background: linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); - background: -o-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); - background: -moz-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); - background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); - /* background: -ms-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); */ + background: linear-gradient(bottom, var(----colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair2) 0%, var(--colorbacklineimpair2) 100%); } .noborder > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), .noborder .oddeven.tagtr:nth-child(even):not(:last-child) .tagtd:not(.liste_titre) @@ -3977,11 +3988,10 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre), div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(odd):not(.liste_titre) { - background: linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -o-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -moz-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -webkit-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - /* background: -ms-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); */ + background: linear-gradient(bottom, var(--colorbacklinepair2) 0%, var(--colorbacklinepair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklinepair2) 0%, var(--colorbacklinepair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklinepair2) 0%, var(--colorbacklinepair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklinepair2) 0%, var(--colorbacklinepair2) 100%); } .noborder > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .noborder .oddeven.tagtr:nth-child(odd):not(:last-child) .tagtd:not(.liste_titre) @@ -4196,7 +4206,7 @@ span.dashboardlineko { margin-bottom: 25px !important; border-bottom-width: 1px; background: var(--colorbackbody); - border-top: px solid rgb(); + border-top: px solid var(--colortopbordertitle1); /* border-top: 2px solid var(--colorbackhmenu1) !important; */ } table.noborder.boxtable tr td { @@ -4878,11 +4888,10 @@ table.cal_month td { padding-left: 1px !important; padding-right: 1px !important .cal_past { } .cal_peruser { padding-top: 0 !important; padding-bottom: 0 !important; padding-: 1px !important; padding-: 1px !important; } .cal_impair { - background: linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -o-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -moz-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - background: -webkit-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); - /* background: -ms-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); */ + background: linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklinepair2) 85%, var(--colorbacklinepair2) 100%); } .cal_today_peruser_impair { background: #F8F8F0; } .peruser_busy { } @@ -5654,7 +5663,7 @@ span#select2-taskid-container[title^='--'] { } .select2-container--default .select2-results__option--highlighted[aria-selected] { - background-color: rgb(); + background-color: var(--colorbackhmenu1); color: var(--colortextbackhmenu); } .select2-container--default .select2-results__option--highlighted[aria-selected] span { @@ -6659,7 +6668,6 @@ div.tabsElem a.tab { background-image: -o-linear-gradient(bottom, rgba(0,0,0,0.1) 0%, rgba(230,230,230,0.4) 100%); background-image: -moz-linear-gradient(bottom, rgba(0,0,0,0.1) 0%, rgba(230,230,230,0.4) 100%); background-image: -webkit-linear-gradient(bottom, rgba(0,0,0,0.1) 0%, rgba(230,230,230,0.4) 100%); - background-image: -ms-linear-gradient(bottom, rgba(0,0,0,0.1) 0%, rgba(230,230,230,0.4) 100%); background-image: linear-gradient(bottom, rgba(0,0,0,0.1) 0%, rgba(230,230,230,0.4) 100%); } .cd-timeline-content:after { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 44a0a7d7b20..f16300ba98e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -208,6 +208,8 @@ if ($tmpval <= 460) { $colortextbackvmenu = '000000'; } +$colortopbordertitle1 = join(',', colorStringToArray($colortopbordertitle1)); // Normalize value to 'x,y,z' + $colorbacktitle1 = join(',', colorStringToArray($colorbacktitle1)); // Normalize value to 'x,y,z' $tmppart = explode(',', $colorbacktitle1); if ($colortexttitle == '') { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index bb1fff44289..691ffa8f658 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -118,6 +118,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; // Case of option always editable if (!isset($conf->global->THEME_ELDY_BACKBODY)) { @@ -210,6 +211,8 @@ if ($tmpval <= 460) { $colortextbackvmenu = '000000'; } +$colortopbordertitle1 = join(',', colorStringToArray($colortopbordertitle1)); // Normalize value to 'x,y,z' + $colorbacktitle1 = join(',', colorStringToArray($colorbacktitle1)); // Normalize value to 'x,y,z' $tmppart = explode(',', $colorbacktitle1); if ($colortexttitle == '') { @@ -270,12 +273,13 @@ print 'colorbacklinepair1='.$colorbacklinepair1."\n"; print 'colorbacklinepair2='.$colorbacklinepair2."\n"; print 'colorbacklinepairhover='.$colorbacklinepairhover."\n"; print 'colorbacklinepairchecked='.$colorbacklinepairchecked."\n"; -print '$colortexttitlenotab='.$colortexttitlenotab."\n"; -print '$colortexttitle='.$colortexttitle."\n"; -print '$colortext='.$colortext."\n"; -print '$colortextlink='.$colortextlink."\n"; -print '$colortextbackhmenu='.$colortextbackhmenu."\n"; -print '$colortextbackvmenu='.$colortextbackvmenu."\n"; +print 'colortexttitlenotab='.$colortexttitlenotab."\n"; +print 'colortexttitle='.$colortexttitle."\n"; +print 'colortext='.$colortext."\n"; +print 'colortextlink='.$colortextlink."\n"; +print 'colortexttitlelink='.$colortexttitlelink."\n"; +print 'colortextbackhmenu='.$colortextbackhmenu."\n"; +print 'colortextbackvmenu='.$colortextbackvmenu."\n"; print 'dol_hide_topmenu='.$dol_hide_topmenu."\n"; print 'dol_hide_leftmenu='.$dol_hide_leftmenu."\n"; print 'dol_optimize_smallscreen='.$dol_optimize_smallscreen."\n"; @@ -306,12 +310,15 @@ print '*/'."\n"; --colorbacklinepairchecked: rgb(); --colorbacklinebreak: rgb(); --colorbackbody: rgb(); + --colorbackmobilemenu: #f8f8f8; --colortexttitlenotab: rgb(); --colortexttitle: rgb(); + --colortexttitlelink: rgba(, 0.9); --colortext: rgb(); --colortextlink: rgb(); - --colortextbackhmenu: #; + --colortextbackhmenu: #; --colortextbackvmenu: #; + --colortopbordertitle1: rgb(); --listetotal: #551188; --inputbackgroundcolor: #FFF; --inputbordercolor: rgba(0,0,0,.2); @@ -328,13 +335,16 @@ print '*/'."\n"; --amountremaintopaycolor:#880000; --amountpaymentcomplete:#008800; --amountremaintopaybackcolor:none; + --productlinestockod: #002200; + --productlinestocktoolow: #884400; + --infoboxmoduleenabledbgcolor : linear-gradient(0.4turn, #fff, #fff, #fff, #e4efe8); } body { background-color: #FFFFFF; - background: rgb(); + background: var(--colorbackbody); color: rgb(); font-size: ; @@ -580,7 +590,7 @@ input.pageplusone { } .optionblue { - color: rgb(); + color: var(--colortextlink); } .optiongrey, .opacitymedium { opacity: 0.5; @@ -984,7 +994,7 @@ body[class*="colorblind-"] .text-success{ color: #ccc !important; } .editfielda span.fa-pencil-alt:hover, .editfielda span.fa-trash:hover { - color: rgb() !important; + color: var(--colortexttitle) !important; } .size15x { font-size: 1.5em !important; } @@ -1765,7 +1775,7 @@ td.showDragHandle { display: none; - background: rgb(); + background: var(--colorbackvmenu1); border-right: 1px solid rgba(0,0,0,0.2); box-shadow: 3px 0 6px -2px #eee; bottom: 0; @@ -1910,7 +1920,7 @@ div.login_block { } #id-left { z-index: 91; - background: rgb(); + background: var(--colorbackvmenu1); border-right: 1px solid rgba(0,0,0,0.3); padding-top: 20px; px solid rgb(); + border-bottom: px solid var(--colortopbordertitle1); } .trextrafieldseparator td, .trextrafields_collapse_last td { - border-bottom: 1px solid rgb() !important; + border-bottom: 1px solid var(--colortopbordertitle1) !important; } .tdhrthin { margin: 0; @@ -2240,13 +2250,12 @@ div#tmenu_tooltip { display:none; - background: rgb(); + background: var(--colorbackhmenu1); /* background-image: linear-gradient(to top, rgba(255,255,255,.3) 0%, rgba(128,128,128,.3) 100%); background-image: -o-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(128,128,128,.3) 100%); background-image: -moz-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(128,128,128,.3) 100%); background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(128,128,128,.3) 100%); - background-image: -ms-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(128,128,128,.3) 100%); background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, rgba(255,255,255,.3)), color-stop(1, rgba(128,128,128,.3)) ); */ @@ -2323,13 +2332,12 @@ ul.tmenu { /* t r b l */ padding-left: 5px; } ul.tmenu li { - background: rgb(); + background: var(--colorbackhmenu1); /* background-image: linear-gradient(to top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); background-image: -o-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); background-image: -moz-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); - background-image: -ms-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(0,0,0,.3) 100%); background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, rgba(255,255,255,.3)), color-stop(1, rgba(0,0,0,.3)) ); */ } @@ -2730,7 +2738,7 @@ div.login_block { z-index: 10; text-align: center; vertical-align: middle; - background: rgb(); + background: var(--colorbackvmenu1); width: 228px; height: 70px; @@ -3116,7 +3124,7 @@ div.tabBar { border-left: 1px solid #BBB; border-top: 1px solid #CCC; width: auto; - background: rgb(); + background: var(--colorbacktabcard1); border-bottom: 1px solid #aaa; } @@ -3209,8 +3217,8 @@ a.tab:link, a.tab:visited, a.tab:hover, a.tab#active { } .tabactive, a.tab#active { - color: # !important; - background: rgb() !important; + color: var(--colortextbacktab) !important; + background: var(--colorbacktabcard1) !important; border-right: 1px solid #AAA !important; border-left: 1px solid #AAA !important; @@ -3226,8 +3234,8 @@ a.tab:link, a.tab:visited, a.tab:hover, a.tab#active { a.tab:hover { /* - background: rgba(, 0.5) url() 50% 0 repeat-x; - color: #; + background: var(--colorbacktabcard1) url() 50% 0 repeat-x; + color: var(--colortextbacktab); */ text-decoration: underline; } @@ -3387,10 +3395,10 @@ td.border, div.tagtable div div.border { border-bottom: none !important; } .bordertop { - border-top: 1px solid rgb(); + border-top: 1px solid var(--colortopbordertitle1); } .borderbottom { - border-bottom: 1px solid rgb(); + border-bottom: 1px solid var(--colortopbordertitle1); } .fichehalfright table.noborder { @@ -3398,7 +3406,7 @@ td.border, div.tagtable div div.border { } div.colorback { - background: rgb(); + background: var(--colorbacktitle1); padding: 10px; margin-top: 5px; } @@ -3413,7 +3421,7 @@ table.liste, table.noborder, table.formdoc, div.noborder { border-spacing: 0px; border-top-width: px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; border-bottom-width: 1px; @@ -3446,7 +3454,7 @@ table.paddingtopbottomonly tr td { } .liste_titre_filter { - background: rgb() !important; + background: var(--colorbacktitle1) !important; } tr.liste_titre_filter td.liste_titre { padding-top: 4px; @@ -3455,19 +3463,19 @@ tr.liste_titre_filter td.liste_titre { .liste_titre_create td, .liste_titre_create th, .liste_titre_create .tagtd { border-top-width: 1px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; } .liste_titre_add td, .liste_titre_add th, .liste_titre_add .tagtd { border-top-width: 2px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; } .liste_titre_add td, .liste_titre_add .tagtd { border-top-width: 1px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; } @@ -3535,7 +3543,7 @@ div.refidpadding { } div.refid { font-weight: bold; - color: rgb(); + color: rgb(--colortexttitlenotab); font-size: 160%; } div.refidno { @@ -3628,7 +3636,7 @@ div.pagination li .active span:focus { z-index: 2; color: #fff; cursor: default; - background-color: rgb(); + background-color: var(--colorbackhmenu1); border-color: #337ab7; } div.pagination .disabled span, @@ -3673,11 +3681,10 @@ table.hidepaginationnext .paginationnext { /* Prepare to remove class pair - impair .noborder > tbody > tr:nth-child(even) td { - background: linear-gradient(to bottom, rgb() 85%, rgb() 100%); - background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -webkit-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -ms-linear-gradient(bottom, rgb() 85%, rgb() 100%); + background: linear-gradient(to bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair1) 85%, var(--colorbacklineimpair2) 100%); font-family: ; border: 0px; margin-bottom: 1px; @@ -3686,11 +3693,10 @@ table.hidepaginationnext .paginationnext { } .noborder > tbody > tr:nth-child(odd) td { - background: linear-gradient(to bottom, rgb() 85%, rgb() 100%); - background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -webkit-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -ms-linear-gradient(bottom, rgb() 85%, rgb() 100%); + background: linear-gradient(to bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklinepair1) 85%, var(--colorbacklinepair2) 100%); font-family: ; border: 0px; margin-bottom: 1px; @@ -3699,11 +3705,7 @@ table.hidepaginationnext .paginationnext { */ ul.noborder li:nth-child(odd):not(.liste_titre) { - background-color: rgb() !important; - background-color: rgb() !important; - background-color: rgb() !important; - background-color: rgb() !important; - background-color: rgb() !important; + background-color: var(--colorbacklinepair2) !important; } @@ -3828,7 +3830,7 @@ div.liste_titre { } div.liste_titre_bydiv { border-top-width: px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; box-shadow: none; @@ -3843,11 +3845,11 @@ tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, tabl } div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_sel, .tagtr.liste_titre, .tagtr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable thead tr { - background: rgb(); + background: var(--colorbacktitle1); font-weight: ; /* border-bottom: 1px solid #FDFFFF; */ - color: rgb(); + color: var(--colortexttitle); font-family: ; text-align: ; } @@ -3868,25 +3870,25 @@ tr.liste_titre th, th.liste_titre, tr.liste_titre td, td.liste_titre, form.liste } tr.liste_titre th a, th.liste_titre a, tr.liste_titre td a, td.liste_titre a, form.liste_titre div a, div.liste_titre a { text-shadow: none !important; - color: rgb(); + color: var(--colortexttitlelink); } tr.liste_titre_topborder td { border-top-width: px; - border-top-color: rgb(); + border-top-color: var(--colortopbordertitle1); border-top-style: solid; } .liste_titre td a { text-shadow: none !important; - color: rgb(); + color: var(--colortexttitle); } .liste_titre td a.notasortlink { - color: rgb(); + color: var(--colortextlink); } .liste_titre td a.notasortlink:hover { background: transparent; } tr.liste_titre:last-child th.liste_titre, tr.liste_titre:last-child th.liste_titre_sel, tr.liste_titre td.liste_titre, tr.liste_titre td.liste_titre_sel, form.liste_titre div.tagtd { /* For last line of table headers only */ - border-bottom: 1px solid rgb(); + border-bottom: 1px solid var(--colortopbordertitle1); } div.liste_titre { @@ -3934,7 +3936,7 @@ tr.liste_sub_total, tr.liste_sub_total td { } .paymenttable, .margintable:not(.margintablenotop) { border-top-width: px !important; - border-top-color: rgb() !important; + border-top-color: var(--colortopbordertitle1) !important; border-top-style: solid !important; } .margintable.margintablenotop { @@ -3987,11 +3989,10 @@ div .tdtop { div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(even):not(.liste_titre), .liste > tbody > tr:nth-of-type(even):not(.liste_titre), div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(even):not(.liste_titre) { - background: linear-gradient(to bottom, rgb() 85%, rgb() 100%); - background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -webkit-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -ms-linear-gradient(bottom, rgb() 85%, rgb() 100%); + background: linear-gradient(to bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklineimpair1) 0%, var(--colorbacklineimpair2) 100%); } .noborder > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(even):not(:last-child) td:not(.liste_titre), .noborder .tagtr:nth-child(even):not(:last-child) .oddeven.tagtd:not(.liste_titre) @@ -4003,11 +4004,10 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) > .border > tbody > tr:nth-of-type(odd):not(.liste_titre), .liste > tbody > tr:nth-of-type(odd):not(.liste_titre), div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft) .oddeven.tagtr:nth-of-type(odd):not(.liste_titre) { - background: linear-gradient(to bottom, rgb() 85%, rgb() 100%); - background: -o-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -moz-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -webkit-linear-gradient(bottom, rgb() 85%, rgb() 100%); - background: -ms-linear-gradient(bottom, rgb() 85%, rgb() 100%); + background: linear-gradient(to bottom, var(--colorbacklinepair1) 0%, var(--colorbacklinepair2) 100%); + background: -o-linear-gradient(bottom, var(--colorbacklinepair1) 0%, var(--colorbacklinepair2) 100%); + background: -moz-linear-gradient(bottom, var(--colorbacklinepair1) 0%, var(--colorbacklinepair2) 100%); + background: -webkit-linear-gradient(bottom, var(--colorbacklinepair1) 0%, var(--colorbacklinepair2) 100%); } .noborder > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .liste > tbody > tr:nth-child(odd):not(:last-child) td:not(.liste_titre), .noborder .tagtr:nth-child(odd):not(:last-child) .oddeven.tagtd:not(.liste_titre) @@ -4016,7 +4016,7 @@ div:not(.fichecenter):not(.fichehalfleft):not(.fichehalfright):not(.ficheaddleft } ul.noborder li:nth-child(even):not(.liste_titre) { - background-color: rgb() !important; + background-color: var(--colorbacklinepair2) !important; } @@ -6539,7 +6539,6 @@ border-top-right-radius: 6px; background-image: -o-linear-gradient(bottom, rgba(0,0,0,0.1) 0%, rgba(230,230,230,0.4) 100%); background-image: -moz-linear-gradient(bottom, rgba(0,0,0,0.1) 0%, rgba(230,230,230,0.4) 100%); background-image: -webkit-linear-gradient(bottom, rgba(0,0,0,0.1) 0%, rgba(230,230,230,0.4) 100%); - background-image: -ms-linear-gradient(bottom, rgba(0,0,0,0.1) 0%, rgba(230,230,230,0.4) 100%); background-image: linear-gradient(bottom, rgba(0,0,0,0.1) 0%, rgba(230,230,230,0.4) 100%); } .cd-timeline-content:after { From b6ec7ae77aebf1c1968fc9ac0f1665556e26143c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Oct 2021 04:36:58 +0200 Subject: [PATCH 107/113] Fix permissions on module PaymentByBankTransfer --- htdocs/compta/paymentbybanktransfer/index.php | 2 +- htdocs/compta/prelevement/card.php | 15 +++++-------- htdocs/compta/prelevement/create.php | 22 +++++++++++++------ htdocs/compta/prelevement/demandes.php | 13 +++++++---- htdocs/compta/prelevement/factures.php | 16 +++++++------- htdocs/compta/prelevement/fiche-rejet.php | 11 +++++++--- htdocs/compta/prelevement/fiche-stat.php | 16 +++++++------- htdocs/compta/prelevement/index.php | 4 ++-- htdocs/compta/prelevement/line.php | 12 +++++----- htdocs/compta/prelevement/list.php | 18 +++++++++------ htdocs/compta/prelevement/orders_list.php | 22 +++++++++++-------- htdocs/compta/prelevement/rejets.php | 18 +++++++++------ htdocs/compta/prelevement/stats.php | 10 ++++++--- htdocs/theme/eldy/global.inc.php | 4 ++-- 14 files changed, 107 insertions(+), 76 deletions(-) diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index 8c8c029f8d8..009f99fccf1 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -48,7 +48,7 @@ $result = restrictedArea($user, 'paymentbybanktransfer', '', ''); * Actions */ - +// None /* diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 58cfe5be72d..a2de75123a0 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -33,11 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals')); -// Security check -if ($user->socid > 0) { - accessforbidden(); -} - // Get supervariables $action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); @@ -71,11 +66,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist')); -if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') { - accessforbidden(); -} -if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') { - accessforbidden(); +$type = $object->type; +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index fe074bcb9d0..03dfd0288bd 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -39,12 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); // Get supervariables @@ -63,6 +57,16 @@ $offset = $limit * $page; $hookmanager->initHooks(array('directdebitcreatecard', 'globalcard')); +// Security check +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * Actions @@ -141,7 +145,11 @@ if (empty($reshook)) { } } $objectclass = "BonPrelevement"; - $uploaddir = $conf->prelevement->dir_output; + if ($type == 'bank-transfer') { + $uploaddir = $conf->paymentbybanktransfer->dir_output; + } else { + $uploaddir = $conf->prelevement->dir_output; + } include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 0230e4cb726..cb10e9248f1 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -37,10 +37,6 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); // Security check $socid = GETPOST('socid', 'int'); $status = GETPOST('status', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page @@ -73,6 +69,15 @@ $massactionbutton = ''; $hookmanager->initHooks(array('withdrawalstodolist')); +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * Actions diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index a100cd9156f..067f76ed2c8 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -34,11 +34,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals')); -// Securite acces client -if ($user->socid > 0) { - accessforbidden(); -} - // Get supervariables $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -70,11 +65,16 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist')); -if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') { +// Security check +if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') { - accessforbidden(); + +$type = $object->type; +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); } diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 9ff5970e656..febc4827a94 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -62,11 +62,16 @@ $object = new BonPrelevement($db); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') { +// Security check +if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') { - accessforbidden(); + +$type = $object->type; +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); } diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 5833f417ddd..8255c537442 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -32,11 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills')); -// Security check -if ($user->socid > 0) { - accessforbidden(); -} - // Get supervariables $prev_id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -61,11 +56,16 @@ $object = new BonPrelevement($db); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') { +// Security check +if ($user->socid > 0) { accessforbidden(); } -if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') { - accessforbidden(); + +$type = $object->type; +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); } diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index d4bfdb10588..93f2305c60f 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -41,14 +41,14 @@ $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'prelevement', '', ''); +$result = restrictedArea($user, 'prelevement', '', 'bons'); /* * Actions */ - +// None /* diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index a82da74ab48..38ea2fb1d52 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -35,11 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadlangs(array('banks', 'categories', 'bills', 'withdrawals')); -// Security check -if ($user->socid > 0) { - accessforbidden(); -} - // Get supervariables $action = GETPOST('action', 'aZ09'); $id = GETPOST('id', 'int'); @@ -66,6 +61,13 @@ if ($sortfield == "") { $sortfield = "pl.fk_soc"; } +$type = $object->type; +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * Actions diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 65f4ba7b142..ae92286dfec 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -42,13 +42,6 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'di $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -80,6 +73,17 @@ $company = new Societe($db); $hookmanager->initHooks(array('withdrawalsreceiptslineslist')); +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * Actions diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index 011f29f4f5c..be7c72907fd 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -33,13 +33,6 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals')); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlist'; // To manage different context of search -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -72,6 +65,17 @@ if ($type == 'bank-transfer') { $usercancreate = $user->rights->paymentbybanktransfer->create; } +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * Actions @@ -137,15 +141,15 @@ if ($result) { $newcardbutton = ''; if ($usercancreate) { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php?type='.urlencode($type)); } // Lines of title fields print '
'; + print ''; if ($optioncss != '') { print ''; } - print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index 1abc717dbe0..029d5dd8598 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -33,13 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); // Get supervariables @@ -54,6 +47,17 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * View diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index ae1dd54a13c..9c30db6e08a 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -31,14 +31,18 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); +$type = GETPOST('type', 'aZ09'); + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - -$type = GETPOST('type', 'aZ09'); +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} /* diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index bb1f8a6423d..21d75db9238 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3387,8 +3387,8 @@ table.liste, table.noborder, table.formdoc, div.noborder { border-left: 1px solid var(--colortopbordertitle1); - border-right: 1px solid var(--colortopbordertitle1); - + border-right: 1px solid var(--colortopbordertitle1); + /*width: calc(100% - 7px); border-collapse: separate !important; border-spacing: 0px; From 7b02560c4fa562ad76a109b33fd2d33622e49254 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Oct 2021 05:27:07 +0200 Subject: [PATCH 108/113] Better way to present open invoice graph --- htdocs/core/class/dolgraph.class.php | 6 ++++-- htdocs/core/lib/invoice.lib.php | 19 +++++++++++++------ htdocs/langs/en_US/bills.lang | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index a1725526898..e4a91d903df 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -741,7 +741,7 @@ class DolGraph /** * Build a graph using JFlot library. Input when calling this method should be: * $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); - * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x + * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // when there is n series to show for each x * $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated * $this->legend= array("Val1",...,"Valn"); // list of n series name * $this->type = array('bars',...'lines','linesnopoint'); or array('pie') or array('polar') @@ -1028,7 +1028,7 @@ class DolGraph /** * Build a graph using Chart library. Input when calling this method should be: * $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); - * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x + * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // when there is n series to show for each x * $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated * $this->legend= array("Val1",...,"Valn"); // list of n series name * $this->type = array('bars',...'lines', 'linesnopoint'); or array('pie') or array('polar') or array('piesemicircle'); @@ -1303,6 +1303,8 @@ class DolGraph $this->stringtoshow .= 'var options = { maintainAspectRatio: false, aspectRatio: 2.5, '; if (empty($showlegend)) { $this->stringtoshow .= 'legend: { display: false }, '; + } else { + $this->stringtoshow .= 'legend: { position: \'' . ($showlegend == 2 ? 'right' : 'top') . '\' },'; } $this->stringtoshow .= 'scales: { xAxes: [{ '; if ($this->hideXValues) { diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 28b56efb20d..21e3f2007d0 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -480,7 +480,8 @@ function getNumberInvoicesPieChart($mode) date_add($datenowadd30, $interval30days); date_add($datenowadd15, $interval15days); - $sql = "SELECT sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub30, 'Y-m-d')."'", 1, 0).") as nblate30"; + $sql = "SELECT"; + $sql .= " sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub30, 'Y-m-d')."'", 1, 0).") as nblate30"; $sql .= ", sum(".$db->ifsql("f.date_lim_reglement < '".date_format($datenowsub15, 'Y-m-d')."'", 1, 0).") as nblate15"; $sql .= ", sum(".$db->ifsql("f.date_lim_reglement < '".date_format($now, 'Y-m-d')."'", 1, 0).") as nblatenow"; $sql .= ", sum(".$db->ifsql("f.date_lim_reglement >= '".date_format($now, 'Y-m-d')."'", 1, 0).") as nbnotlatenow"; @@ -508,17 +509,19 @@ function getNumberInvoicesPieChart($mode) while ($i < $num) { $obj = $db->fetch_object($resql); - $dataseries = array(array($langs->trans('InvoiceLate30Days'), $obj->nblate30) + /*$dataseries = array(array($langs->trans('InvoiceLate30Days'), $obj->nblate30) ,array($langs->trans('InvoiceLate15Days'), $obj->nblate15 - $obj->nblate30) ,array($langs->trans('InvoiceLateMinus15Days'), $obj->nblatenow - $obj->nblate15) ,array($langs->trans('InvoiceNotLate'), $obj->nbnotlatenow - $obj->nbnotlate15) ,array($langs->trans('InvoiceNotLate15Days'), $obj->nbnotlate15 - $obj->nbnotlate30) - ,array($langs->trans('InvoiceNotLate30Days'), $obj->nbnotlate30)); + ,array($langs->trans('InvoiceNotLate30Days'), $obj->nbnotlate30));*/ + $dataseries[0]=array($langs->trans('NbOfOpenInvoices'), $obj->nblate30, $obj->nblate15 - $obj->nblate30, $obj->nblatenow - $obj->nblate15, $obj->nbnotlatenow - $obj->nbnotlate15, $obj->nbnotlate15 - $obj->nbnotlate30, $obj->nbnotlate30); $i++; } foreach ($dataseries as $key=>$value) { $total += $value[1]; } + $legend = array($langs->trans('InvoiceLate30Days'), $langs->trans('InvoiceLate15Days'), $langs->trans('InvoiceLateMinus15Days'), $langs->trans('InvoiceNotLate'), $langs->trans('InvoiceNotLate15Days'), $langs->trans('InvoiceNotLate30Days')); $colorseries = array($badgeStatus8, $badgeStatus1, $badgeStatus3, $badgeStatus4, $badgeStatus11, '-'.$badgeStatus11); @@ -537,14 +540,18 @@ function getNumberInvoicesPieChart($mode) $result .= ''; if ($conf->use_javascript_ajax) { + //var_dump($dataseries); $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); + + $dolgraph->setLegend($legend); + $dolgraph->SetDataColor(array_values($colorseries)); $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); - $dolgraph->SetType(['pie']); - $dolgraph->setHeight('150'); - $dolgraph->setWidth('300'); + $dolgraph->SetType(array('bars', 'bars', 'bars', 'bars', 'bars', 'bars')); + $dolgraph->setHeight('180'); + $dolgraph->setWidth('500'); if ($mode == 'customers') { $dolgraph->draw('idgraphcustomerinvoices'); } elseif ($mode == 'fourn' || $mode == 'suppliers') { diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index e475a815ac9..afdff97ded6 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -265,6 +265,7 @@ DateInvoice=Invoice date DatePointOfTax=Point of tax NoInvoice=No invoice NoOpenInvoice=No open invoice +NbOfOpenInvoices=Number of open invoices ClassifyBill=Classify invoice SupplierBillsToPay=Unpaid vendor invoices CustomerBillsUnpaid=Unpaid customer invoices From 66310b14d757f1d192fb5b959ea02e633d7059a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Oct 2021 05:34:14 +0200 Subject: [PATCH 109/113] Better way to present open invoice graph --- htdocs/core/lib/invoice.lib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 21e3f2007d0..164840eceb7 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -528,7 +528,7 @@ function getNumberInvoicesPieChart($mode) $result = '
'; $result .= ''; $result .= ''; - $result .= '
'.$langs->trans("Statistics").' - '; + $result .= ''.$langs->trans("NbOfOpenInvoices").' - '; if ($mode == 'customers') { $result .= $langs->trans("CustomerInvoice"); } elseif ($mode == 'fourn' || $mode == 'suppliers') { @@ -550,8 +550,9 @@ function getNumberInvoicesPieChart($mode) $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('bars', 'bars', 'bars', 'bars', 'bars', 'bars')); - $dolgraph->setHeight('180'); - $dolgraph->setWidth('500'); + $dolgraph->setHeight('160'); + $dolgraph->setWidth('400'); + $dolgraph->setHideXValues(true); if ($mode == 'customers') { $dolgraph->draw('idgraphcustomerinvoices'); } elseif ($mode == 'fourn' || $mode == 'suppliers') { From 704bae46a6672aa7a50260e6a6c0ca4df1ff745a Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 4 Oct 2021 08:51:31 +0200 Subject: [PATCH 110/113] FIX: expense report: show link to already existing overlapping expense report without adding new parameter --- htdocs/expensereport/class/expensereport.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 8df8b356090..64034c10a3f 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2195,10 +2195,9 @@ class ExpenseReport extends CommonObject * @param User $fuser User * @param integer $date_debut Start date * @param integer $date_fin End date - * @param bool $return_id True to return ID of existing expense report * @return int <0 if KO, >0 if OK */ - public function periode_existe($fuser, $date_debut, $date_fin, $return_id = false) + public function periode_existe($fuser, $date_debut, $date_fin) { // phpcs:enable $sql = "SELECT rowid, date_debut, date_fin"; @@ -2221,7 +2220,7 @@ class ExpenseReport extends CommonObject $date_f_req = $this->db->jdate($objp->date_fin); // 4 if (!($date_f_form < $date_d_req || $date_d_form > $date_f_req)) { - return $return_id ? $objp->rowid : 1; + return $objp->rowid; } $i++; From 91ee704dc3a28a32988ec65162aba9a301518429 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Oct 2021 12:16:50 +0200 Subject: [PATCH 111/113] Move trans from admin to main --- htdocs/langs/en_US/admin.lang | 1 - htdocs/langs/en_US/main.lang | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5f71e77eb71..58b21ca3554 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -131,7 +131,6 @@ IdModule=Module ID IdPermissions=Permissions ID LanguageBrowserParameter=Parameter %s LocalisationDolibarrParameters=Localization parameters -ClientTZ=Client Time Zone (user) ClientHour=Client time (user) OSTZ=Server OS Time Zone PHPTZ=PHP server Time Zone diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index ddd60a9b68e..9fba774e7a5 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1138,4 +1138,5 @@ InformationOnLinkToContract=This amount is only the total of all the lines of th ConfirmCancel=Are you sure you want to cancel EmailMsgID=Email MsgID Forthcoming=Forthcoming -Currently=Currently \ No newline at end of file +Currently=Currently +ClientTZ=Client Time Zone (user) From 6d8276c9c8d18c5e1f2a3e6a72ce5daf5d567133 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Oct 2021 12:59:53 +0200 Subject: [PATCH 112/113] Doc --- htdocs/admin/system/security.php | 2 ++ htdocs/langs/en_US/admin.lang | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 0bf568082b2..b0614c7501d 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -258,6 +258,8 @@ print '
'; print '$dolibarr_nocsrfcheck: '.(empty($dolibarr_nocsrfcheck) ? '0' : $dolibarr_nocsrfcheck); if (!empty($dolibarr_nocsrfcheck)) { print '   '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 0); +} else { + print '   ('.$langs->trans("Recommended").': 0)'; } print '
'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d445cf8131a..b5a6c347133 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2158,7 +2158,7 @@ NoWritableFilesFoundIntoRootDir=No writable files or directories of the common p RecommendedValueIs=Recommended: %s Recommended=Recommended NotRecommended=Not recommended -ARestrictedPath=A restricted path +ARestrictedPath=Some restricted path CheckForModuleUpdate=Check for external modules updates CheckForModuleUpdateHelp=This action will connect to editors of external modules to check if a new version is available. ModuleUpdateAvailable=An update is available From bad5d87f57e3b1006f49838ccff021354ee334e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Oct 2021 14:56:30 +0200 Subject: [PATCH 113/113] NEW theme option THEME_ELDY_USEBORDERONTABLE --- htdocs/theme/eldy/style.css.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index f16300ba98e..de089ecba54 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -118,7 +118,8 @@ $dol_no_mouse_hover = $conf->dol_no_mouse_hover; //$user->conf->THEME_ELDY_ENABLE_PERSONALIZED=0; //var_dump($user->conf->THEME_ELDY_RGB); -$useboldtitle = (isset($conf->global->THEME_ELDY_USEBOLDTITLE) ? $conf->global->THEME_ELDY_USEBOLDTITLE : 0); +$useboldtitle = getDolGlobalInt('THEME_ELDY_USEBOLDTITLE'); +$userborderontable = getDolGlobalInt('THEME_ELDY_USEBORDERONTABLE'); $borderwidth = 1; // Case of option always editable