diff --git a/ChangeLog b/ChangeLog index 2e8bfc968c7..de1482ea183 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,21 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 15.0.0 compared to 14.0.0 ***** + +For developers: +--------------- + +WARNING: + +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook. +* Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale. +* The method static ActionComm::getActions($db, ...) is no more static. Use $actioncomm->getActions(...) instead (without $db param). + + + ***** ChangeLog for 14.0.2 compared to 14.0.1 ***** FIX: #18353 Invoice list translation issue @@ -86,19 +101,6 @@ FIX: using Tulip, deposit mask was not saved FIX: #yogosha6907 -***** ChangeLog for 15.0.0 compared to 14.0.0 ***** - -For developers: ---------------- - -WARNING: - -Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook. -* Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale. - - - ***** ChangeLog for 14.0.0 compared to 13.0.0 ***** For users: diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index bdaaa5845f3..d32ef64aebc 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -33,10 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php' // Load translation files required by the page $langs->loadLangs(array("admin", "trips", "errors", "other", "dict")); -if (!$user->admin) { - accessforbidden(); -} - $error = 0; $action = GETPOST('action', 'aZ09'); @@ -45,10 +41,20 @@ $ikoffset = GETPOST('ikoffset', 'int'); $coef = GETPOST('coef', 'int'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); -$fk_range = GETPOST('fk_range'); +$fk_range = GETPOST('fk_range', 'int'); + +$expIk = new ExpenseReportIk($db); + +if (!$user->admin) { + accessforbidden(); +} + + +/* + * Actions + */ if ($action == 'updateik') { - $expIk = new ExpenseReportIk($db); if ($id > 0) { $result = $expIk->fetch($id); if ($result < 0) { @@ -61,13 +67,13 @@ if ($action == 'updateik') { if ($result > 0) { setEventMessages('SetupSaved', null, 'mesgs'); + header('Location: '.$_SERVER['PHP_SELF']); exit; } else { setEventMessages($expIk->error, $expIk->errors, 'errors'); } } elseif ($action == 'delete') { // TODO add confirm - $expIk = new ExpenseReportIk($db); if ($id > 0) { $result = $expIk->fetch($id); if ($result < 0) { @@ -77,12 +83,11 @@ if ($action == 'updateik') { $expIk->delete($user); } - header('Location: '.$_SERVER['PHP_SELF']); exit; } -$rangesbycateg = ExpenseReportIk::getAllRanges(); +$rangesbycateg = $expIk->getAllRanges(); /* @@ -102,7 +107,8 @@ print dol_get_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"), echo ''.$langs->trans('ExpenseReportIkDesc').''; print '

'; -echo '
'; +echo ''; +echo ''; if ($action == 'edit') { echo ''; @@ -111,8 +117,6 @@ if ($action == 'edit') { echo ''; } -echo ''; - echo ''; foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) { diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 802cc939caa..67627a94af8 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -54,7 +54,6 @@ $code_expense_rules_type = GETPOST('code_expense_rules_type'); $dates = dol_mktime(12, 0, 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear')); $datee = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); $amount = GETPOST('amount'); -$restrictive = GETPOST('restrictive'); $object = new ExpenseReportRule($db); if (!empty($id)) { @@ -138,7 +137,7 @@ if ($action == 'save') { exit; } -$rules = ExpenseReportRule::getAllRule(); +$rules = $object->getAllRule(); $tab_apply = array( 'A' => $langs->trans('All'), diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 79fb13a8717..a4c06b65d1f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1245,7 +1245,6 @@ class ActionComm extends CommonObject * Load all objects with filters. * @todo WARNING: This make a fetch on all records instead of making one request with a join. * - * @param DoliDb $db Not used * @param int $socid Filter by thirdparty * @param int $fk_element Id of element action is linked to * @param string $elementtype Type of element action is linked to @@ -1255,7 +1254,7 @@ class ActionComm extends CommonObject * @param string $limit Limit number of answers * @return array|string Error string if KO, array with actions if OK */ - public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) + public function getActions($socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) { global $conf, $langs; @@ -1277,33 +1276,33 @@ class ActionComm extends CommonObject $sql .= " (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX."actioncomm_resources WHERE"; $sql .= " element_type = 'socpeople' AND fk_element = ".((int) $fk_element).')'; } else { - $sql .= " AND a.fk_element = ".((int) $fk_element)." AND a.elementtype = '".$db->escape($elementtype)."'"; + $sql .= " AND a.fk_element = ".((int) $fk_element)." AND a.elementtype = '".$this->db->escape($elementtype)."'"; } } if (!empty($filter)) { $sql .= $filter; } if ($sortorder && $sortfield) { - $sql .= $db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); } - $sql .= $db->plimit($limit, 0); + $sql .= $this->db->plimit($limit, 0); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); if ($num) { for ($i = 0; $i < $num; $i++) { - $obj = $db->fetch_object($resql); - $actioncommstatic = new ActionComm($db); + $obj = $this->db->fetch_object($resql); + $actioncommstatic = new ActionComm($this->db); $actioncommstatic->fetch($obj->id); $resarray[$i] = $actioncommstatic; } } - $db->free($resql); + $this->db->free($resql); return $resarray; } else { - return $db->lasterror(); + return $this->db->lasterror(); } } diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 0048031d0e7..0590566582d 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -178,7 +178,8 @@ class FormActions $sortfield = 'a.datep,a.id'; $sortorder = 'DESC,DESC'; - $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); + $actioncomm = new ActionComm($this->db); + $listofactions = $actioncomm->getActions($socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); if (!is_array($listofactions)) { dol_print_error($this->db, 'FailedToGetActions'); } diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 5bf91ec341e..e89a2a4fe3e 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -300,10 +300,11 @@ class modMultiCurrency extends DolibarrModules { global $conf, $user, $langs; - if (!MultiCurrency::checkCodeAlreadyExists($conf->currency)) { + $multicurrency = new MultiCurrency($this->db); + + if (! $multicurrency->checkCodeAlreadyExists($conf->currency)) { $langs->loadCacheCurrencies(''); - $multicurrency = new MultiCurrency($this->db); $multicurrency->code = $conf->currency; $multicurrency->name = $langs->cache_currencies[$conf->currency]['label'].' ('.$langs->getCurrencySymbol($conf->currency).')'; $r = $multicurrency->create($user); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 7b609391ee2..c87d2fcc5ce 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -137,8 +137,15 @@ if ($reshook < 0) { if (empty($reshook)) { if ($cancel) { - $action = ''; - $object->fetch($id); // show shipment also after canceling modification + if ($origin && $origin_id > 0) { + if ($origin == 'commande') { + header("Location: ".DOL_URL_ROOT.'/expedition/shipment.php?id='.((int) $origin_id)); + exit; + } + } else { + $action = ''; + $object->fetch($id); // show shipment also after canceling modification + } } include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once @@ -1049,7 +1056,7 @@ if ($action == 'create') { print ''; print '
'.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip"); if (empty($conf->productbatch->enabled)) { - print '
'.img_picto($langs->trans("Autofill"), 'autofill', 'class="paddingrightonly"').$langs->trans("Fill").''; + print '
'.img_picto($langs->trans("Autofill"), 'autofill', 'class="paddingrightonly"').''; print ' / '; } else { print '
'; @@ -2482,7 +2489,7 @@ if ($action == 'create') { $label = "ClassifyBilled"; $paramaction = 'classifybilled'; } - print ''.$langs->trans($label).''; + print ''.$langs->trans($label).''; } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index a9372564280..bf956d9dc32 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -43,9 +43,7 @@ if (!empty($conf->propal->enabled)) { if (!empty($conf->commande->enabled)) { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; } -if (!empty($conf->productbatch->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; -} +require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionlinebatch.class.php'; /** @@ -1188,7 +1186,6 @@ class Expedition extends CommonObject global $conf, $langs, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; $error = 0; $this->error = ''; @@ -1230,6 +1227,9 @@ class Expedition extends CommonObject $resql = $this->db->query($sql); if ($resql) { $cpt = $this->db->num_rows($resql); + + $shipmentlinebatch = new ExpeditionLineBatch($this->db); + for ($i = 0; $i < $cpt; $i++) { dol_syslog(get_class($this)."::delete movement index ".$i); $obj = $this->db->fetch_object($resql); @@ -1240,7 +1240,7 @@ class Expedition extends CommonObject // get lot/serial $lotArray = null; if ($conf->productbatch->enabled) { - $lotArray = ExpeditionLineBatch::fetchAll($this->db, $obj->expeditiondet_id); + $lotArray = $shipmentlinebatch->fetchAll($this->db, $obj->expeditiondet_id); if (!is_array($lotArray)) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } @@ -1276,7 +1276,8 @@ class Expedition extends CommonObject // delete batch expedition line if (!$error && $conf->productbatch->enabled) { - if (ExpeditionLineBatch::deletefromexp($this->db, $this->id) < 0) { + $shipmentlinebatch = new ExpeditionLineBatch($this->db); + if ($shipmentlinebatch->deleteFromShipment($this->id) < 0) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } @@ -1372,7 +1373,6 @@ class Expedition extends CommonObject global $conf, $langs, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; $error = 0; $this->error = ''; @@ -1460,15 +1460,16 @@ class Expedition extends CommonObject // delete batch expedition line (we try deletion even if module not enabled in case of the module were enabled and disabled previously) if (!$error) { - if (ExpeditionLineBatch::deletefromexp($this->db, $this->id) < 0) { + $shipmentlinebatch = ExpeditionLineBatch($this->db); + if ($shipmentlinebatch->deleteFromShipment($this->id) < 0) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } if (!$error) { - $main = MAIN_DB_PREFIX.'expeditiondet'; - $ef = $main."_extrafields"; - $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_expedition = ".((int) $this->id).")"; + $main = MAIN_DB_PREFIX.'expeditiondet'; + $ef = $main."_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_expedition = ".((int) $this->id).")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet"; $sql .= " WHERE fk_expedition = ".((int) $this->id); @@ -1480,8 +1481,8 @@ class Expedition extends CommonObject $error++; } - // delete extrafields - $res = $this->deleteExtraFields(); + // delete extrafields + $res = $this->deleteExtraFields(); if ($res < 0) { $error++; } @@ -1597,6 +1598,7 @@ class Expedition extends CommonObject $this->total_localtax2 = 0; $line = new ExpeditionLigne($this->db); + $shipmentlinebatch = new ExpeditionLineBatch($this->db); while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -1695,9 +1697,8 @@ class Expedition extends CommonObject // Detail of batch if (!empty($conf->productbatch->enabled) && $obj->line_id > 0 && $obj->product_tobatch > 0) { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; + $newdetailbatch = $shipmentlinebatch->fetchAll($obj->line_id, $obj->fk_product); - $newdetailbatch = ExpeditionLineBatch::fetchAll($this->db, $obj->line_id, $obj->fk_product); if (is_array($newdetailbatch)) { if ($originline != $obj->fk_origin_line) { $line->detail_batch = $newdetailbatch; @@ -2925,8 +2926,9 @@ class ExpeditionLigne extends CommonObjectLine } // fetch remaining lot qty - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; - if (!$error && ($lotArray = ExpeditionLineBatch::fetchAll($this->db, $this->id)) < 0) { + $shipmentlinebatch = new ExpeditionLineBatch($this->db); + + if (!$error && ($lotArray = $shipmentlinebatch->fetchAll($this->id)) < 0) { $this->errors[] = $this->db->lasterror()." - ExpeditionLineBatch::fetchAll"; $error++; } else { diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php similarity index 85% rename from htdocs/expedition/class/expeditionbatch.class.php rename to htdocs/expedition/class/expeditionlinebatch.class.php index 03066869450..b2562734447 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionlinebatch.class.php @@ -17,7 +17,7 @@ */ /** - * \file expedition/class/expeditionbatch.class.php + * \file htdocs/expedition/class/expeditionlinebatch.class.php * \ingroup productbatch * \brief This file implements CRUD method for managing shipment batch lines * with batch record @@ -33,7 +33,10 @@ class ExpeditionLineBatch extends CommonObject */ public $element = 'expeditionlignebatch'; - private static $_table_element = 'expeditiondet_batch'; //!< Name of table without prefix where object is stored + /** + * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. + */ + public $table_element = 'expeditiondet_batch'; public $sellby; public $eatby; @@ -44,6 +47,7 @@ class ExpeditionLineBatch extends CommonObject public $fk_origin_stock; public $fk_expeditiondet; + /** * Constructor * @@ -74,6 +78,7 @@ class ExpeditionLineBatch extends CommonObject $sql .= " WHERE pb.rowid = ".(int) $id_stockdluo; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { @@ -106,7 +111,7 @@ class ExpeditionLineBatch extends CommonObject $id_line_expdet = (int) $id_line_expdet; - $sql = "INSERT INTO ".MAIN_DB_PREFIX.self::$_table_element." ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." ("; $sql .= "fk_expeditiondet"; $sql .= ", sellby"; $sql .= ", eatby"; @@ -129,7 +134,8 @@ class ExpeditionLineBatch extends CommonObject } if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.self::$_table_element); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + $this->fk_expeditiondet = $id_line_expdet; return $this->id; } else { @@ -145,17 +151,16 @@ class ExpeditionLineBatch extends CommonObject /** * Delete batch record attach to a shipment * - * @param DoliDB $db Database object * @param int $id_expedition rowid of shipment * @return int -1 if KO, 1 if OK */ - public static function deletefromexp($db, $id_expedition) + public function deleteFromShipment($id_expedition) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX.self::$_table_element; + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE fk_expeditiondet in (SELECT rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition=".((int) $id_expedition).")"; dol_syslog(__METHOD__, LOG_DEBUG); - if ($db->query($sql)) { + if ($this->db->query($sql)) { return 1; } else { return -1; @@ -165,12 +170,11 @@ class ExpeditionLineBatch extends CommonObject /** * Retrieve all batch number detailed information of a shipment line * - * @param DoliDB $db Database object * @param int $id_line_expdet id of shipment line * @param int $fk_product If provided, load also detailed information of lot * @return int|array -1 if KO, array of ExpeditionLineBatch if OK */ - public static function fetchAll($db, $id_line_expdet, $fk_product = 0) + public function fetchAll($id_line_expdet, $fk_product = 0) { $sql = "SELECT"; $sql .= " eb.rowid,"; @@ -184,25 +188,24 @@ class ExpeditionLineBatch extends CommonObject $sql .= ", pl.sellby"; $sql .= ", pl.eatby"; } - $sql .= " FROM ".MAIN_DB_PREFIX.self::$_table_element." as eb"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as eb"; if ($fk_product > 0) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON pl.batch = eb.batch AND pl.fk_product = ".((int) $fk_product); } $sql .= " WHERE fk_expeditiondet=".(int) $id_line_expdet; dol_syslog(__METHOD__."", LOG_DEBUG); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); $i = 0; $ret = array(); while ($i < $num) { - $tmp = new self($db); + $obj = $this->db->fetch_object($resql); - $obj = $db->fetch_object($resql); - - $tmp->sellby = $db->jdate($obj->sellby ? $obj->sellby : $obj->oldsellby); - $tmp->eatby = $db->jdate($obj->eatby ? $obj->eatby : $obj->oldeatby); + $tmp = new self($this->db); + $tmp->sellby = $this->db->jdate($obj->sellby ? $obj->sellby : $obj->oldsellby); + $tmp->eatby = $this->db->jdate($obj->eatby ? $obj->eatby : $obj->oldeatby); $tmp->batch = $obj->batch; $tmp->id = $obj->rowid; $tmp->fk_origin_stock = $obj->fk_origin_stock; @@ -213,10 +216,12 @@ class ExpeditionLineBatch extends CommonObject $ret[] = $tmp; $i++; } - $db->free($resql); + + $this->db->free($resql); + return $ret; } else { - dol_print_error($db); + dol_print_error($this->db); return -1; } } diff --git a/htdocs/expensereport/ajax/ajaxik.php b/htdocs/expensereport/ajax/ajaxik.php index c2cc8345671..6cd8c05fe5b 100644 --- a/htdocs/expensereport/ajax/ajaxik.php +++ b/htdocs/expensereport/ajax/ajaxik.php @@ -76,7 +76,8 @@ if (empty($fk_expense) || $fk_expense < 0) { if ($userauthor->fetch($expense->fk_user_author) <= 0) { echo json_encode(array('error' => $langs->transnoentitiesnoconv('ErrorRecordNotFound'), 'fk_user_author' => $expense->fk_user_author)); } else { - $range = ExpenseReportIk::getRangeByUser($userauthor, $fk_c_exp_tax_cat); + $expenseik = new ExpenseReportIk($db); + $range = $expenseik->getRangeByUser($userauthor, $fk_c_exp_tax_cat); if (empty($range)) { echo json_encode(array('error' => $langs->transnoentitiesnoconv('ErrorRecordNotFound'), 'range' => $range)); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index df1c79c82dd..63303554c51 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1887,7 +1887,8 @@ class ExpenseReport extends CommonObject } //$buyer = new Societe($this->db); - $rulestocheck = ExpenseReportRule::getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author); + $expensereportrule = new ExpenseReportRule($db); + $rulestocheck = $expensereportrule->getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author); $violation = 0; $rule_warning_message_tab = array(); @@ -1974,7 +1975,8 @@ class ExpenseReport extends CommonObject } //$buyer = new Societe($this->db); - $range = ExpenseReportIk::getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat); + $expenseik = new ExpenseReportIk($db); + $range = $expenseik->getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat); if (empty($range)) { $this->error = 'ErrorNoRangeAvailable'; diff --git a/htdocs/expensereport/class/expensereport_ik.class.php b/htdocs/expensereport/class/expensereport_ik.class.php index 358a2fe06ca..da2312bdcb1 100644 --- a/htdocs/expensereport/class/expensereport_ik.class.php +++ b/htdocs/expensereport/class/expensereport_ik.class.php @@ -87,8 +87,6 @@ class ExpenseReportIk extends CoreObject */ public function __construct(DoliDB &$db) { - global $conf; - parent::__construct($db); parent::init(); @@ -102,29 +100,28 @@ class ExpenseReportIk extends CoreObject * @param int $mode 1=only active; 2=only inactive; other value return all * @return array of category */ - public static function getTaxCategories($mode = 1) + public function getTaxCategories($mode = 1) { - global $db; - $categories = array(); $sql = 'SELECT rowid, label, entity, active'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat'; - $sql .= ' WHERE entity IN ('.getEntity('c_exp_tax_cat').')'; + $sql .= ' WHERE entity IN (0, '.getEntity($this->element).')'; if ($mode == 1) { $sql .= ' AND active = 1'; } elseif ($mode == 2) { $sql .= 'AND active = 0'; } - dol_syslog(get_called_class().'::getTaxCategories sql='.$sql, LOG_DEBUG); - $resql = $db->query($sql); + dol_syslog(get_called_class().'::getTaxCategories', LOG_DEBUG); + + $resql = $this->db->query($sql); if ($resql) { - while ($obj = $db->fetch_object($resql)) { + while ($obj = $this->db->fetch_object($resql)) { $categories[$obj->rowid] = $obj; } } else { - dol_print_error($db); + dol_print_error($this->db); } return $categories; @@ -137,10 +134,10 @@ class ExpenseReportIk extends CoreObject * @param int $fk_c_exp_tax_cat category * @return boolean|array */ - public static function getRangeByUser(User $userauthor, int $fk_c_exp_tax_cat) + public function getRangeByUser(User $userauthor, int $fk_c_exp_tax_cat) { $default_range = (int) $userauthor->default_range; // if not defined, then 0 - $ranges = self::getRangesByCategory($fk_c_exp_tax_cat); + $ranges = $this->getRangesByCategory($fk_c_exp_tax_cat); // substract 1 because array start from 0 if (empty($ranges) || !isset($ranges[$default_range - 1])) { @@ -157,10 +154,8 @@ class ExpenseReportIk extends CoreObject * @param int $active active * @return array */ - public static function getRangesByCategory(int $fk_c_exp_tax_cat, $active = 1) + public function getRangesByCategory(int $fk_c_exp_tax_cat, $active = 1) { - global $db; - $ranges = array(); dol_syslog(get_called_class().'::getRangesByCategory for fk_c_exp_tax_cat='.$fk_c_exp_tax_cat, LOG_DEBUG); @@ -170,24 +165,25 @@ class ExpenseReportIk extends CoreObject $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)'; } $sql .= ' WHERE r.fk_c_exp_tax_cat = '.((int) $fk_c_exp_tax_cat); + $sql .= " AND entity IN(0, ".getEntity($this->element).")"; if ($active) { $sql .= ' AND r.active = 1 AND c.active = 1'; } $sql .= ' ORDER BY r.range_ik'; - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $this->db->num_rows($resql); if ($num > 0) { - while ($obj = $db->fetch_object($resql)) { - $object = new ExpenseReportIk($db); + while ($obj = $this->db->fetch_object($resql)) { + $object = new ExpenseReportIk($this->db); $object->fetch($obj->rowid); $ranges[] = $object; } } } else { - dol_print_error($db); + dol_print_error($this->db); } return $ranges; @@ -198,24 +194,23 @@ class ExpenseReportIk extends CoreObject * * @return array */ - public static function getAllRanges() + public function getAllRanges() { - global $db; - $ranges = array(); $sql = ' SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, c.label, i.rowid as fk_expense_ik, r.active as range_active, c.active as cat_active'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r'; $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport_ik i ON (r.rowid = i.fk_range)'; - $sql .= ' WHERE r.entity IN (0, '.getEntity('').')'; + $sql .= ' WHERE r.entity IN (0, '.getEntity($this->element).')'; $sql .= ' ORDER BY r.fk_c_exp_tax_cat, r.range_ik'; - dol_syslog(get_called_class().'::getAllRanges sql='.$sql, LOG_DEBUG); - $resql = $db->query($sql); + dol_syslog(get_called_class().'::getAllRanges', LOG_DEBUG); + + $resql = $this->db->query($sql); if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $ik = new ExpenseReportIk($db); + while ($obj = $this->db->fetch_object($resql)) { + $ik = new ExpenseReportIk($this->db); if ($obj->fk_expense_ik > 0) { $ik->fetch($obj->fk_expense_ik); } @@ -227,7 +222,7 @@ class ExpenseReportIk extends CoreObject $ranges[$obj->fk_c_exp_tax_cat]['ranges'][] = $obj; } } else { - dol_print_error($db); + dol_print_error($this->db); } return $ranges; @@ -236,30 +231,28 @@ class ExpenseReportIk extends CoreObject /** * Return the max number of range by a category * - * @param int $default_c_exp_tax_cat id - * @return int + * @param int $default_c_exp_tax_cat id Default c_exp_tax_cat + * @return int Max nb */ - public static function getMaxRangeNumber($default_c_exp_tax_cat = 0) + public function getMaxRangeNumber($default_c_exp_tax_cat = 0) { - global $db, $conf; - $sql = 'SELECT MAX(counted) as nbRange FROM ('; $sql .= ' SELECT COUNT(*) as counted'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r'; - $sql .= ' WHERE r.entity IN (0, '.$conf->entity.')'; + $sql .= ' WHERE r.entity IN (0, '.getEntity($this->element).')'; if ($default_c_exp_tax_cat > 0) { $sql .= ' AND r.fk_c_exp_tax_cat = '.((int) $default_c_exp_tax_cat); } $sql .= ' GROUP BY r.fk_c_exp_tax_cat'; $sql .= ') as counts'; - dol_syslog(get_called_class().'::getMaxRangeNumber sql='.$sql, LOG_DEBUG); - $resql = $db->query($sql); + dol_syslog(get_called_class().'::getMaxRangeNumber', LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { - $obj = $db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); return $obj->nbRange; } else { - dol_print_error($db); + dol_print_error($this->db); } return 0; diff --git a/htdocs/expensereport/class/expensereport_rule.class.php b/htdocs/expensereport/class/expensereport_rule.class.php index 6299dd7c5bd..ae89b4b0f51 100644 --- a/htdocs/expensereport/class/expensereport_rule.class.php +++ b/htdocs/expensereport/class/expensereport_rule.class.php @@ -148,20 +148,19 @@ class ExpenseReportRule extends CoreObject * @param int $fk_user user of expense * @return array Array with ExpenseReportRule */ - public static function getAllRule($fk_c_type_fees = '', $date = '', $fk_user = '') + public function getAllRule($fk_c_type_fees = '', $date = '', $fk_user = '') { - global $db; - $rules = array(); + $sql = 'SELECT er.rowid'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_rules er'; - $sql .= ' WHERE er.entity IN (0,'.getEntity('').')'; + $sql .= ' WHERE er.entity IN (0,'.getEntity($this->element).')'; if (!empty($fk_c_type_fees)) { $sql .= ' AND er.fk_c_type_fees IN (-1, '.((int) $fk_c_type_fees).')'; } if (!empty($date)) { - $sql .= " AND er.dates <= '".dol_print_date($date, '%Y-%m-%d')."'"; - $sql .= " AND er.datee >= '".dol_print_date($date, '%Y-%m-%d')."'"; + $sql .= " AND er.dates <= '".$this->db->idate($date)."'"; + $sql .= " AND er.datee >= '".$this->db->idate($date)."'"; } if ($fk_user > 0) { $sql .= ' AND (er.is_for_all = 1'; @@ -172,18 +171,18 @@ class ExpenseReportRule extends CoreObject dol_syslog("ExpenseReportRule::getAllRule"); - $resql = $db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj = $db->fetch_object($resql)) { - $rule = new ExpenseReportRule($db); + while ($obj = $this->db->fetch_object($resql)) { + $rule = new ExpenseReportRule($this->db); if ($rule->fetch($obj->rowid) > 0) { $rules[$rule->id] = $rule; } else { - dol_print_error($db); + dol_print_error($this->db); } } } else { - dol_print_error($db); + dol_print_error($this->db); } return $rules; @@ -201,7 +200,7 @@ class ExpenseReportRule extends CoreObject if ($this->fk_usergroup > 0) { $group = new UserGroup($this->db); if ($group->fetch($this->fk_usergroup) > 0) { - return $group->nom; + return $group->name; } else { $this->error = $group->error; $this->errors[] = $this->error; diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index cbe238ad2a4..bc9c7dab537 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -64,6 +64,7 @@ ShipmentClassifyClosedInDolibarr=Shipment %s classified billed ShipmentUnClassifyCloseddInDolibarr=Shipment %s classified re-open ShipmentBackToDraftInDolibarr=Shipment %s go back to draft status ShipmentDeletedInDolibarr=Shipment %s deleted +ShipmentCanceledInDolibarr=Shipment %s canceled ReceptionValidatedInDolibarr=Reception %s validated OrderCreatedInDolibarr=Order %s created OrderValidatedInDolibarr=Order %s validated diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0a64a4a913e..6f6d74c0cda 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -506,7 +506,11 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( } else { dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (POST method or GET with a sensible value for 'action' parameter) in main.inc.php. Token not provided.", LOG_WARNING); print "Access to this page this way (POST method or GET with a sensible value for 'action' parameter) is refused by CSRF protection in main.inc.php. Token not provided.\n"; - print "If you access your server behind a proxy using url rewriting and the parameter is provided by caller, you might check that all HTTP header are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0 into setup).\n"; + print "If you access your server behind a proxy using url rewriting and the parameter is provided by caller, you might check that all HTTP header are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0"; + if (! empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) { + print " instead of ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN; + } + print " into setup).\n"; } die; } diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index a811a396811..5e145dbd8a6 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -432,7 +432,7 @@ class MultiCurrency extends CommonObject */ public function addRateFromDolibarr($code, $rate) { - global $db, $user; + global $user; $currency = new MultiCurrency($this->db); $currency->code = $code; @@ -441,8 +441,8 @@ class MultiCurrency extends CommonObject $sql = 'SELECT label FROM '.MAIN_DB_PREFIX."c_currencies WHERE code_iso = '".$this->db->escape($code)."'"; dol_syslog(__METHOD__, LOG_DEBUG); - $resql = $db->query($sql); - if ($resql && ($line = $db->fetch_object($resql))) { + $resql = $this->db->query($sql); + if ($resql && ($line = $this->db->fetch_object($resql))) { $currency->name = $line->label; } @@ -521,7 +521,7 @@ class MultiCurrency extends CommonObject * @param integer $date_document Date from document (propal, order, invoice, ...) * * @return array [0] => id currency - * [1] => rate + * [1] => rate */ public static function getIdAndTxFromCode($db, $code, $date_document = '') { @@ -687,12 +687,10 @@ class MultiCurrency extends CommonObject * @param string $code current code to search * @return boolean True if exists, false if not exists */ - public static function checkCodeAlreadyExists($code) + public function checkCodeAlreadyExists($code) { - global $db; - - $currency = new MultiCurrency($db); - if ($currency->fetch('', $code) > 0) { + $currencytmp = new MultiCurrency($this->db); + if ($currencytmp->fetch('', $code) > 0) { return true; } else { return false; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 4b32d924203..27360c6080d 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -2026,7 +2026,7 @@ if ($action == 'create') { $label = "ClassifyBilled"; $paramaction = 'classifybilled'; } - print ''.$langs->trans($label).''; + print ''.$langs->trans($label).''; } } diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 84083113309..1bb88ce3d8c 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -339,7 +339,10 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac $ret .= ''; $ret .= ''; $ret .= ''; - $maxRangeNum = ExpenseReportIk::getMaxRangeNumber($object->default_c_exp_tax_cat); + + $expensereportik = new ExpenseReportIk($db); + $maxRangeNum = $expensereportik->getMaxRangeNumber($object->default_c_exp_tax_cat); + $ret .= $form->selectarray('default_range', range(0, $maxRangeNum), $object->default_range); $ret .= ' '; $ret .= ''; diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 40ca07c441f..fea52610c2b 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -201,7 +201,6 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase || in_array($file['name'], array('modules_boxes.php', 'rapport.pdf.php', 'TraceableDB.php'))) { if (! in_array($file['name'], array( 'api.class.php', - 'actioncomm.class.php', 'commonobject.class.php', 'conf.class.php', 'html.form.class.php', @@ -213,16 +212,13 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase 'modules_product.class.php', 'modules_societe.class.php', 'TraceableDB.php', - 'expeditionbatch.class.php', - 'expensereport_ik.class.php', - 'expensereport_rule.class.php', 'multicurrency.class.php', 'productbatch.class.php', 'reception.class.php', 'societe.class.php' , 'account.class.php' ))) { - // Must must not found $db-> + // Must not found $db-> $ok=true; $matches=array(); // Check string $db-> inside a class.php file (it should be $this->db-> insto such classes)