From f073b7023a52e6acec529466567ae593bbed7272 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 19 May 2020 09:45:02 +0200 Subject: [PATCH 1/7] FIX missing GetNomURL Hook in warehouse class --- htdocs/product/stock/class/entrepot.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 03ba46a4068..47606388b52 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -692,7 +692,7 @@ class Entrepot extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $showfullpath = 0, $notooltip = 0) { - global $conf, $langs; + global $conf, $langs, $hookmanager; $langs->load("stocks"); if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips @@ -731,6 +731,16 @@ class Entrepot extends CommonObject if ($withpicto != 2) $result.= ($showfullpath ? $this->get_full_arbo() : (empty($this->label)?$this->libelle:$this->label)); $result .= $linkend; + global $action; + $hookmanager->initHooks(array('warehousedao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } + return $result; } From e39774a508433ff096e33b83607e0e20de6d68ba Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 19 May 2020 10:04:41 +0200 Subject: [PATCH 2/7] add more hook param --- htdocs/product/stock/class/entrepot.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 47606388b52..0b259018cfc 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -733,7 +733,7 @@ class Entrepot extends CommonObject global $action; $hookmanager->initHooks(array('warehousedao')); - $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result, 'withpicto' => $withpicto, 'option' => $option, 'showfullpath' => $showfullpath, 'notooltip'=> $notooltip); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; From f3582d891ae8d57d905a2ac253b21e5ad01064c7 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 19 May 2020 15:35:37 +0200 Subject: [PATCH 3/7] FIX : We must only rename current bank receipt --- htdocs/compta/bank/releve.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index a16927bda0b..5ef3fbf0953 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -179,7 +179,7 @@ $sqlrequestforbankline = $sql; if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) { // TODO Add a test to check newbankreceipt does not exists yet - $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'"'; + $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.$id; $result = $db->query($sqlupdate); if ($result < 0) dol_print_error($db); From bf9756b8c4dab60d712efaf59bfb2e0694bc77e8 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 19 May 2020 16:05:13 +0200 Subject: [PATCH 4/7] Add Hook "Massstockmove" --- htdocs/product/stock/massstockmove.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 8d98f028d23..7a0472e226d 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -34,6 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'orders', 'productbatch')); +//init Hook +$hookmanager->initHooks(array('massstockmove')); + // Security check if ($user->socid) { $socid = $user->socid; From 55def0248ce74e462536cdc7ad2b798e2fb1853b Mon Sep 17 00:00:00 2001 From: altairis Date: Wed, 20 May 2020 14:37:35 +0200 Subject: [PATCH 5/7] fix missing rollbacks --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 538af54fe23..092c3df8dc2 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1815,7 +1815,6 @@ class CommandeFournisseur extends CommonOrder if ($result < 0) { $error++; - return -1; } // End call triggers } @@ -1923,6 +1922,7 @@ class CommandeFournisseur extends CommonOrder { $this->errors[]='ErrorWhenRunningTrigger'; dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + $this->db->rollback(); return -1; } // End call triggers From 6434f255c32d444c744bb5fba96f547d85e73f0c Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 22 May 2020 00:32:55 +0200 Subject: [PATCH 6/7] Fix load_state_board doesn't take parameters --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 5eee02efa1e..944701fe0d1 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -324,7 +324,7 @@ if (empty($user->societe_id)) include_once $includes[$key]; // Loading a class cost around 1Mb $board=new $classe($db); - $board->load_state_board($user); + $board->load_state_board(); $boardloaded[$classe]=$board; } else From fb0f31c142cad7df1da3fc85190aab10c274e14d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 22 May 2020 00:33:30 +0200 Subject: [PATCH 7/7] Fix board filters for expense report and holiday --- .../class/expensereport.class.php | 20 +++++++++++++------ htdocs/holiday/class/holiday.class.php | 18 +++++++++++++---- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 2dddac4dbab..bb543642733 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -970,7 +970,7 @@ class ExpenseReport extends CommonObject { // phpcs:enable global $conf; - + $this->lines=array(); $sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date, de.rang,'; @@ -2274,7 +2274,7 @@ class ExpenseReport extends CommonObject public function load_state_board() { // phpcs:enable - global $conf; + global $conf, $user; $this->nb=array(); @@ -2282,6 +2282,12 @@ class ExpenseReport extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; $sql.= " WHERE ex.fk_statut > 0"; $sql.= " AND ex.entity IN (".getEntity('expensereport').")"; + if(!$user->rights->expensereport->readall) + { + $userchildids = $user->getAllChildIds(1); + $sql.= " AND (ex.fk_user_author IN (".join(',', $userchildids).")"; + $sql.= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))"; + } $resql=$this->db->query($sql); if ($resql) { @@ -2316,15 +2322,17 @@ class ExpenseReport extends CommonObject $now=dol_now(); - $userchildids = $user->getAllChildIds(1); - $sql = "SELECT ex.rowid, ex.date_valid"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; if ($option == 'toapprove') $sql.= " WHERE ex.fk_statut = 2"; else $sql.= " WHERE ex.fk_statut = 5"; $sql.= " AND ex.entity IN (".getEntity('expensereport').")"; - $sql.= " AND (ex.fk_user_author IN (".join(',', $userchildids).")"; - $sql.= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))"; + if(!$user->rights->expensereport->readall) + { + $userchildids = $user->getAllChildIds(1); + $sql.= " AND (ex.fk_user_author IN (".join(',', $userchildids).")"; + $sql.= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))"; + } $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 25f1d9675bb..1d818d33c1f 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2182,12 +2182,20 @@ class Holiday extends CommonObject public function load_state_board() { // phpcs:enable + global $user; + $this->nb=array(); $sql = "SELECT count(h.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday as h"; $sql.= " WHERE h.statut > 1"; $sql.= " AND h.entity IN (".getEntity('holiday').")"; + if(!$user->rights->expensereport->read_all) + { + $userchildids = $user->getAllChildIds(1); + $sql.= " AND (h.fk_user IN (".join(',', $userchildids).")"; + $sql.= " OR h.fk_validator IN (".join(',', $userchildids)."))"; + } $resql=$this->db->query($sql); if ($resql) { @@ -2221,14 +2229,16 @@ class Holiday extends CommonObject $now=dol_now(); - $userchildids = $user->getAllChildIds(1); - $sql = "SELECT h.rowid, h.date_debut"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday as h"; $sql.= " WHERE h.statut = 2"; $sql.= " AND h.entity IN (".getEntity('holiday').")"; - $sql.= " AND (h.fk_user IN (".join(',', $userchildids).")"; - $sql.= " OR h.fk_validator IN (".join(',', $userchildids)."))"; + if(!$user->rights->expensereport->read_all) + { + $userchildids = $user->getAllChildIds(1); + $sql.= " AND (h.fk_user IN (".join(',', $userchildids).")"; + $sql.= " OR h.fk_validator IN (".join(',', $userchildids)."))"; + } $resql=$this->db->query($sql); if ($resql)