From 04bfbb572343d09329a4e7006154865e773827da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 18 Apr 2023 21:11:48 +0200 Subject: [PATCH 1/7] property and doc --- htdocs/bom/class/bom.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index e10139f3711..07acb99189f 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -216,6 +216,11 @@ class BOM extends CommonObject */ public $lines = array(); + /** + * @var BOMLine Bom line + */ + public $line; + /** * @var int Calculated cost for the BOM */ From 697d36c7d199ac9f8abe2c02d9c44c27616a45eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 25 Apr 2023 20:31:49 +0200 Subject: [PATCH 2/7] fix warning --- 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 7f051a1672e..20a4ffdafc1 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1040,7 +1040,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl 'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>1000 + $extrafields->attributes[$contactstatic->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); + 'enabled'=>(abs((int) $extrafields->attributes[$contactstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); } } } From 7126ff7b1f2b1f37d149753721f02e0b1da0190e Mon Sep 17 00:00:00 2001 From: VMR Global Solutions Date: Thu, 27 Apr 2023 09:16:17 +0200 Subject: [PATCH 3/7] Update api_receptions.class.php Change made in _private function validate in reception/class/api_receptions.class.php:709 replaced line 712 foreach (Shipments::$FIELDS as $field) { => foreach (Receptions::$FIELDS as $field) { --- htdocs/reception/class/api_receptions.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index c9f4cba44cc..b24a8dbef11 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -709,7 +709,7 @@ class Receptions extends DolibarrApi private function _validate($data) { $reception = array(); - foreach (Shipments::$FIELDS as $field) { + foreach (Receptions::$FIELDS as $field) { if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); } From 244a986baf74e7be662055ac8c0d822c9786987f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 27 Apr 2023 09:21:56 +0200 Subject: [PATCH 4/7] fix eval --- htdocs/core/lib/company.lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 20a4ffdafc1..0a10d195e06 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1038,9 +1038,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key] < 0) ? 0 : 1), + 'checked'=>((dol_eval($extrafields->attributes[$contactstatic->table_element]['list'][$key], 1, 1, '1') < 0) ? 0 : 1), 'position'=>1000 + $extrafields->attributes[$contactstatic->table_element]['pos'][$key], - 'enabled'=>(abs((int) $extrafields->attributes[$contactstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); + 'enabled' => (abs((int) dol_eval($extrafields->attributes[$contactstatic->table_element]['list'][$key], 1)) != 3 && dol_eval($extrafields->attributes[$contactstatic->table_element]['perms'][$key], 1, 1, '1')) + ); } } } From 0d3fdbe408074e397d62a01b0dd5aedad55dc603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 27 Apr 2023 09:42:54 +0200 Subject: [PATCH 5/7] clean code --- htdocs/bom/class/bom.class.php | 68 +++++++++++++++------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 07acb99189f..a1a7ced7caf 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -216,11 +216,6 @@ class BOM extends CommonObject */ public $lines = array(); - /** - * @var BOMLine Bom line - */ - public $line; - /** * @var int Calculated cost for the BOM */ @@ -232,7 +227,6 @@ class BOM extends CommonObject public $unit_cost = 0; - /** * Constructor * @@ -632,33 +626,33 @@ class BOM extends CommonObject } // Insert line - $this->line = new BOMLine($this->db); + $line = new BOMLine($this->db); - $this->line->context = $this->context; + $line->context = $this->context; - $this->line->fk_bom = $this->id; - $this->line->fk_product = $fk_product; - $this->line->qty = $qty; - $this->line->qty_frozen = $qty_frozen; - $this->line->disable_stock_change = $disable_stock_change; - $this->line->efficiency = $efficiency; - $this->line->fk_bom_child = $fk_bom_child; - $this->line->import_key = $import_key; - $this->line->position = $rankToUse; - $this->line->fk_unit = $fk_unit; + $line->fk_bom = $this->id; + $line->fk_product = $fk_product; + $line->qty = $qty; + $line->qty_frozen = $qty_frozen; + $line->disable_stock_change = $disable_stock_change; + $line->efficiency = $efficiency; + $line->fk_bom_child = $fk_bom_child; + $line->import_key = $import_key; + $line->position = $rankToUse; + $line->fk_unit = $fk_unit; if (is_array($array_options) && count($array_options) > 0) { - $this->line->array_options = $array_options; + $line->array_options = $array_options; } - $result = $this->line->create($user); + $result = $line->create($user); if ($result > 0) { $this->calculateCosts(); $this->db->commit(); return $result; } else { - $this->error = $this->line->error; + $this->error = $line->error; dol_syslog(get_class($this)."::addLine error=".$this->error, LOG_ERR); $this->db->rollback(); return -2; @@ -727,8 +721,7 @@ class BOM extends CommonObject $staticLine = clone $line; $line->oldcopy = $staticLine; - $this->line = $line; - $this->line->context = $this->context; + $line->context = $this->context; // Rank to use $rankToUse = (int) $position; @@ -746,32 +739,32 @@ class BOM extends CommonObject } - $this->line->fk_bom = $this->id; - $this->line->qty = $qty; - $this->line->qty_frozen = $qty_frozen; - $this->line->disable_stock_change = $disable_stock_change; - $this->line->efficiency = $efficiency; - $this->line->import_key = $import_key; - $this->line->position = $rankToUse; + $line->fk_bom = $this->id; + $line->qty = $qty; + $line->qty_frozen = $qty_frozen; + $line->disable_stock_change = $disable_stock_change; + $line->efficiency = $efficiency; + $line->import_key = $import_key; + $line->position = $rankToUse; if (!empty($fk_unit)) { - $this->line->fk_unit = $fk_unit; + $line->fk_unit = $fk_unit; } if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options foreach ($array_options as $key => $value) { - $this->line->array_options[$key] = $array_options[$key]; + $line->array_options[$key] = $array_options[$key]; } } - $result = $this->line->update($user); + $result = $line->update($user); if ($result > 0) { $this->calculateCosts(); $this->db->commit(); return $result; } else { - $this->error = $this->line->error; + $this->error = $line->error; dol_syslog(get_class($this)."::addLine error=".$this->error, LOG_ERR); $this->db->rollback(); return -2; @@ -806,10 +799,9 @@ class BOM extends CommonObject $staticLine = clone $line; $line->oldcopy = $staticLine; - $this->line = $line; - $this->line->context = $this->context; + $line->context = $this->context; - $result = $this->line->delete($user, $notrigger); + $result = $line->delete($user, $notrigger); //Positions (rank) reordering foreach ($this->lines as $bl) { @@ -824,7 +816,7 @@ class BOM extends CommonObject $this->db->commit(); return $result; } else { - $this->error = $this->line->error; + $this->error = $line->error; dol_syslog(get_class($this)."::addLine error=".$this->error, LOG_ERR); $this->db->rollback(); return -2; From 1d8c7f934f7d011711da4eb3aac8033f7a74458f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 27 Apr 2023 09:47:00 +0200 Subject: [PATCH 6/7] clean code --- htdocs/bom/class/bom.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index a1a7ced7caf..b9d485820a5 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -652,7 +652,7 @@ class BOM extends CommonObject $this->db->commit(); return $result; } else { - $this->error = $line->error; + $this->setErrorsFromObject($line); dol_syslog(get_class($this)."::addLine error=".$this->error, LOG_ERR); $this->db->rollback(); return -2; @@ -764,7 +764,7 @@ class BOM extends CommonObject $this->db->commit(); return $result; } else { - $this->error = $line->error; + $this->setErrorsFromObject($line); dol_syslog(get_class($this)."::addLine error=".$this->error, LOG_ERR); $this->db->rollback(); return -2; @@ -816,7 +816,7 @@ class BOM extends CommonObject $this->db->commit(); return $result; } else { - $this->error = $line->error; + $this->setErrorsFromObject($line); dol_syslog(get_class($this)."::addLine error=".$this->error, LOG_ERR); $this->db->rollback(); return -2; From 5e24ef51085db3c3633b41ea97b674f671baaa81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 27 Apr 2023 15:29:42 +0200 Subject: [PATCH 7/7] fix init_menu_auguria.sql --- htdocs/core/menus/init_menu_auguria.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index dc02a2c4b5f..1b65074a82e 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -18,7 +18,7 @@ insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, left insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 16__+MAX_llx_menu__, 'bom|mrp', 'isModEnabled("bom") || isModEnabled("mrp")', __HANDLER__, 'top', 'mrp', '', 0, '/mrp/index.php?mainmenu=mrp&leftmenu=', 'MRP', -1, 'mrp', '$user->hasRight("bom","read")||$user->hasRight("mrp","read")', '', 0, 31, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 7__+MAX_llx_menu__, 'projet', 'isModEnabled("project")', __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->hasRight("projet","lire")', '', 2, 32, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 5__+MAX_llx_menu__, 'propal|commande|fournisseur|supplier_order|supplier_invoice|contrat|ficheinter', 'isModEnabled("propal") || isModEnabled("commande") || isModEnabled("supplier_order") || isModEnabled("contrat") || isModEnabled("ficheinter")', __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->hasRight("societe","lire") || $user->hasRight("societe","contact","lire")', '', 2, 40, __ENTITY__); -insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 6__+MAX_llx_menu__, 'facture|don|tax|salaries|loan|banque', 'isModEnabled("comptabilite") || isModEnabled("accounting") || isModEnabled("facture") || isModEnabled("don") || isModEnabled("tax") || isModEnabled("salaries") || isModEnabled("supplier_invoice") || isModEnabled("loan") || isModEnabled("banque")', __HANDLER__, 'top', 'billing', '', 0, '/compta/index.php?mainmenu=billing&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->rights->facture->lire|| $user->rights->don->lire || $user->rights->tax->charges->lire || $user->rights->salaries->read || $user->rights->loan->read || $user->hasRight("banque","lire") || ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire', '', 2, 50, __ENTITY__); +insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 6__+MAX_llx_menu__, 'facture|don|tax|salaries|loan|banque', 'isModEnabled("comptabilite") || isModEnabled("accounting") || isModEnabled("facture") || isModEnabled("don") || isModEnabled("tax") || isModEnabled("salaries") || isModEnabled("supplier_invoice") || isModEnabled("loan") || isModEnabled("banque")', __HANDLER__, 'top', 'billing', '', 0, '/compta/index.php?mainmenu=billing&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->rights->facture->lire || $user->rights->don->lire || $user->rights->tax->charges->lire || $user->rights->salaries->read || $user->rights->loan->read || $user->hasRight("banque","lire") || $user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire', '', 2, 50, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 14__+MAX_llx_menu__, 'banque|prelevement', 'isModEnabled("banque") || isModEnabled("prelevement")', __HANDLER__, 'top', 'bank', '', 0, '/compta/bank/list.php?mainmenu=bank&leftmenu=bank', 'MenuBankCash', -1, 'banks', '$user->hasRight("banque","lire") || $user->hasRight("prelevement","bons","lire")', '', 0, 52, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 9__+MAX_llx_menu__, 'comptabilite|accounting|asset', 'isModEnabled("comptabilite") || isModEnabled("accounting") || isModEnabled("asset")', __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=accountancy', 'MenuAccountancy', -1, 'main', '$user->hasRight("compta","resultat","lire") || $user->hasRight("accounting","mouvements","lire") || $user->hasRight("asset","read")', '', 2, 54, __ENTITY__); insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 8__+MAX_llx_menu__, '', '', __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '', '', 2, 90, __ENTITY__);