From 7e7638792e71a8be1fd8a396c18ea719b3cd37b7 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 17 Feb 2022 16:20:35 +0100 Subject: [PATCH 001/831] NEW : Added of the field "include_sub_warehouse" in the table "llx_inventory" --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_inventory-stock.sql | 3 ++- htdocs/product/stock/tpl/extrafields_add.tpl.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index b78e53bd287..56d5410a898 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -237,4 +237,6 @@ ALTER TABLE llx_advtargetemailing RENAME TO llx_mailing_advtarget; ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity); +ALTER TABLE llx_inventory ADD COLUMN include_sub_warehouse boolean NOT NULL DEFAULT FALSE; + diff --git a/htdocs/install/mysql/tables/llx_inventory-stock.sql b/htdocs/install/mysql/tables/llx_inventory-stock.sql index c25ccb9767b..4053aa971b1 100644 --- a/htdocs/install/mysql/tables/llx_inventory-stock.sql +++ b/htdocs/install/mysql/tables/llx_inventory-stock.sql @@ -30,7 +30,8 @@ CREATE TABLE llx_inventory fk_warehouse integer DEFAULT NULL, fk_product integer DEFAULT NULL, status integer DEFAULT 0, - title varchar(255) NOT NULL, + title varchar(255) NOT NULL, + include_sub_warehouse boolean NOT NULL DEFAULT FALSE, date_inventory datetime DEFAULT NULL, date_validation datetime DEFAULT NULL, import_key varchar(14) -- import key diff --git a/htdocs/product/stock/tpl/extrafields_add.tpl.php b/htdocs/product/stock/tpl/extrafields_add.tpl.php index 62921f0a6e0..4dcddcad672 100644 --- a/htdocs/product/stock/tpl/extrafields_add.tpl.php +++ b/htdocs/product/stock/tpl/extrafields_add.tpl.php @@ -37,13 +37,13 @@ if (empty($conf) || !is_object($conf)) { // Other attributes if (!isset($parameters)) $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $movement, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { $params = array(); if (isset($tpl_context)) $params['tpl_context'] = $tpl_context; $params['cols'] = $parameters['colspanvalue']; + var_dump($movement); print $movement->showOptionals($extrafields, 'create', $params); } From 16f6aaf1c8f24dcb22dbe90dd81db50d682d61a5 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 17 Feb 2022 17:24:04 +0100 Subject: [PATCH 002/831] NEW : Add new field into $fields array + Creation of the function getChildWarehouse() --- .../inventory/class/inventory.class.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 92061972e60..58ec8e05ca1 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -101,6 +101,7 @@ class Inventory extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), + 'include_sub_warehouse' => array('type'=>'boolean', 'label'=>'IncludeSubWarehouse', 'enabled'=>1, 'visible'=>1, 'notnull'=>0, 'index'=>0, 'position'=>31), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35), // This date is not used so disabled by default. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), @@ -691,6 +692,30 @@ class Inventory extends CommonObject $this->initAsSpecimenCommon(); $this->title = ''; } + + + /** + * Return the child warehouse of the current one + * + * @return int | array <0 if KO, >0 if OK + */ + public function getchildWarehouse() + { + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'entrepot'; + $sql.= ' WHERE fk_parent='.$this->id; + $sql.= ' ORDER BY rowid'; + $resql = $this->db->query($sql); + if($resql && $this->db->num_rows($resql)>0){ + $TChildWarehouse = array(); + while ($obj = $this->db->fetch_object($resql)){ + $TChildWarehouse[] = $obj->rowid; + } + return $TChildWarehouse; + } else { + return -1; + } + } + } /** From c60047b3c8ced7b79a6069fb50d5890181c92502 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Mon, 21 Feb 2022 17:18:05 +0100 Subject: [PATCH 003/831] NEW : Add recurring behaviour --- .../install/mysql/migration/15.0.0-16.0.0.sql | 2 +- .../mysql/tables/llx_inventory-stock.sql | 2 +- htdocs/langs/en_US/stocks.lang | 3 ++- htdocs/langs/fr_FR/stocks.lang | 1 + .../inventory/class/inventory.class.php | 18 +++++++++++++----- .../product/stock/tpl/extrafields_add.tpl.php | 2 +- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 56d5410a898..3aa6353c250 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -237,6 +237,6 @@ ALTER TABLE llx_advtargetemailing RENAME TO llx_mailing_advtarget; ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity); -ALTER TABLE llx_inventory ADD COLUMN include_sub_warehouse boolean NOT NULL DEFAULT FALSE; +ALTER TABLE llx_inventory ADD COLUMN include_sub_warehouse boolean DEFAULT FALSE; diff --git a/htdocs/install/mysql/tables/llx_inventory-stock.sql b/htdocs/install/mysql/tables/llx_inventory-stock.sql index 4053aa971b1..c6ac552de60 100644 --- a/htdocs/install/mysql/tables/llx_inventory-stock.sql +++ b/htdocs/install/mysql/tables/llx_inventory-stock.sql @@ -31,7 +31,7 @@ CREATE TABLE llx_inventory fk_product integer DEFAULT NULL, status integer DEFAULT 0, title varchar(255) NOT NULL, - include_sub_warehouse boolean NOT NULL DEFAULT FALSE, + include_sub_warehouse boolean DEFAULT FALSE, date_inventory datetime DEFAULT NULL, date_validation datetime DEFAULT NULL, import_key varchar(14) -- import key diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index ebd67df79c9..5d6ad811983 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -270,4 +270,5 @@ ErrorOnElementsInventory=Operation canceled for the following reason: ErrorCantFindCodeInInventory=Can't find the following code in inventory QtyWasAddedToTheScannedBarcode=Success !! The quantity was added to all the requested barcode. You can close the Scanner tool. StockChangeDisabled=Change on stock disabled -NoWarehouseDefinedForTerminal=No warehouse defined for terminal \ No newline at end of file +NoWarehouseDefinedForTerminal=No warehouse defined for terminal +IncludeSubWarehouse=Include sub-warehouse ? \ No newline at end of file diff --git a/htdocs/langs/fr_FR/stocks.lang b/htdocs/langs/fr_FR/stocks.lang index a907598ff61..44da826b36b 100644 --- a/htdocs/langs/fr_FR/stocks.lang +++ b/htdocs/langs/fr_FR/stocks.lang @@ -271,3 +271,4 @@ ErrorCantFindCodeInInventory=Impossible de trouver le code suivant dans l'invent QtyWasAddedToTheScannedBarcode=Succès !! La quantité a été ajoutée à tous les codes-barres demandés. Vous pouvez fermer l'outil Scanner. StockChangeDisabled=Changement sur stock désactivé NoWarehouseDefinedForTerminal=Aucun entrepôt défini pour le terminal +IncludeSubWarehouse=Inclure les sous-entrepôts ? \ No newline at end of file diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 58ec8e05ca1..b5f49e01076 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -290,8 +290,15 @@ class Inventory extends CommonObject $sql .= " AND ps.fk_product = ".((int) $this->fk_product); } if ($this->fk_warehouse > 0) { - $sql .= " AND ps.fk_entrepot = ".((int) $this->fk_warehouse); + $sql .= " AND (ps.fk_entrepot = ".((int) $this->fk_warehouse); } + if($this->include_sub_warehouse>0 && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE){ + $this->getchildWarehouse($this->fk_warehouse, $TChildWarehouses); + foreach ($TChildWarehouses as $childWarehouse){ + $sql .= " OR ps.fk_entrepot = ".((int) $childWarehouse); + } + } + $sql .= ')'; $inventoryline = new InventoryLine($this->db); @@ -699,18 +706,19 @@ class Inventory extends CommonObject * * @return int | array <0 if KO, >0 if OK */ - public function getchildWarehouse() + public function getchildWarehouse($id, &$TChildWarehouse) { $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'entrepot'; - $sql.= ' WHERE fk_parent='.$this->id; + $sql.= ' WHERE fk_parent='.$id; $sql.= ' ORDER BY rowid'; $resql = $this->db->query($sql); if($resql && $this->db->num_rows($resql)>0){ - $TChildWarehouse = array(); while ($obj = $this->db->fetch_object($resql)){ + $TChildWarehouse[] = $obj->rowid; + $this->getchildWarehouse($obj->rowid, $TChildWarehouse); } - return $TChildWarehouse; + return 1; } else { return -1; } diff --git a/htdocs/product/stock/tpl/extrafields_add.tpl.php b/htdocs/product/stock/tpl/extrafields_add.tpl.php index 4dcddcad672..d3c5f0e362c 100644 --- a/htdocs/product/stock/tpl/extrafields_add.tpl.php +++ b/htdocs/product/stock/tpl/extrafields_add.tpl.php @@ -43,7 +43,7 @@ if (empty($reshook)) { $params = array(); if (isset($tpl_context)) $params['tpl_context'] = $tpl_context; $params['cols'] = $parameters['colspanvalue']; - var_dump($movement); + print $movement->showOptionals($extrafields, 'create', $params); } From ab8cd6aa062d138187571211ed49a71e5d3385be Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 22 Feb 2022 14:50:25 +0100 Subject: [PATCH 004/831] FIX : Global conf --- htdocs/product/inventory/class/inventory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index b5f49e01076..a15aadd243e 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -101,7 +101,7 @@ class Inventory extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), - 'include_sub_warehouse' => array('type'=>'boolean', 'label'=>'IncludeSubWarehouse', 'enabled'=>1, 'visible'=>1, 'notnull'=>0, 'index'=>0, 'position'=>31), + 'include_sub_warehouse' => array('type'=>'boolean', 'label'=>'IncludeSubWarehouse', 'enabled'=>'$conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE', 'visible'=>1, 'notnull'=>0, 'index'=>0, 'position'=>31), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35), // This date is not used so disabled by default. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), From e74e0ffada816a5843b329068efc85f1baf85106 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 22 Feb 2022 14:38:25 +0000 Subject: [PATCH 005/831] Fixing style errors. --- htdocs/product/inventory/class/inventory.class.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index a15aadd243e..4836f8c810a 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -292,9 +292,9 @@ class Inventory extends CommonObject if ($this->fk_warehouse > 0) { $sql .= " AND (ps.fk_entrepot = ".((int) $this->fk_warehouse); } - if($this->include_sub_warehouse>0 && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE){ + if ($this->include_sub_warehouse>0 && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE) { $this->getchildWarehouse($this->fk_warehouse, $TChildWarehouses); - foreach ($TChildWarehouses as $childWarehouse){ + foreach ($TChildWarehouses as $childWarehouse) { $sql .= " OR ps.fk_entrepot = ".((int) $childWarehouse); } } @@ -712,9 +712,8 @@ class Inventory extends CommonObject $sql.= ' WHERE fk_parent='.$id; $sql.= ' ORDER BY rowid'; $resql = $this->db->query($sql); - if($resql && $this->db->num_rows($resql)>0){ - while ($obj = $this->db->fetch_object($resql)){ - + if ($resql && $this->db->num_rows($resql)>0) { + while ($obj = $this->db->fetch_object($resql)) { $TChildWarehouse[] = $obj->rowid; $this->getchildWarehouse($obj->rowid, $TChildWarehouse); } @@ -723,7 +722,6 @@ class Inventory extends CommonObject return -1; } } - } /** From 62bf1e4273cd82ad21ec3d32992eaf4a5740e870 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 22 Feb 2022 15:54:45 +0100 Subject: [PATCH 006/831] FIX : Stickler errors --- htdocs/product/inventory/class/inventory.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index a15aadd243e..bc095c9c459 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -700,11 +700,11 @@ class Inventory extends CommonObject $this->title = ''; } - /** * Return the child warehouse of the current one - * - * @return int | array <0 if KO, >0 if OK + * @param int $id Id of warehouse + * @param $TChildWarehouse child warehouses + * @return int <0 if KO, >0 if OK */ public function getchildWarehouse($id, &$TChildWarehouse) { From 6807c53a0fe2acdc08444ebc5c7ca592f06aa6ec Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Tue, 22 Feb 2022 15:56:55 +0100 Subject: [PATCH 007/831] FIX : Travis errors --- htdocs/product/inventory/class/inventory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index bc095c9c459..82eabc120fa 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -709,7 +709,7 @@ class Inventory extends CommonObject public function getchildWarehouse($id, &$TChildWarehouse) { $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'entrepot'; - $sql.= ' WHERE fk_parent='.$id; + $sql.= ' WHERE fk_parent='.(int) $id; $sql.= ' ORDER BY rowid'; $resql = $this->db->query($sql); if($resql && $this->db->num_rows($resql)>0){ From 02917f28df57f592c64f8213b2859d3a55cf833c Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 24 Feb 2022 10:41:46 +0100 Subject: [PATCH 008/831] FIX : PR Returns --- htdocs/product/inventory/class/inventory.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 675446dd2b6..97c11a0370d 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -294,9 +294,7 @@ class Inventory extends CommonObject } if ($this->include_sub_warehouse>0 && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE) { $this->getchildWarehouse($this->fk_warehouse, $TChildWarehouses); - foreach ($TChildWarehouses as $childWarehouse) { - $sql .= " OR ps.fk_entrepot = ".((int) $childWarehouse); - } + $sql .= " OR ps.fk_entrepot IN (".implode(',', $TChildWarehouses).")"; } $sql .= ')'; From 50028dadeffc73e07f9ec36168888cbd3ed7e259 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 24 Feb 2022 11:27:14 +0100 Subject: [PATCH 009/831] FIX : Travis returns --- htdocs/product/inventory/class/inventory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 97c11a0370d..0ad970a7d40 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -294,7 +294,7 @@ class Inventory extends CommonObject } if ($this->include_sub_warehouse>0 && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE) { $this->getchildWarehouse($this->fk_warehouse, $TChildWarehouses); - $sql .= " OR ps.fk_entrepot IN (".implode(',', $TChildWarehouses).")"; + $sql .= " OR ps.fk_entrepot IN (".filter_var(implode(',', $TChildWarehouses),FILTER_SANITIZE_STRING).")"; } $sql .= ')'; From abc450e44ce6409d3031e2b9576694f9ae834faa Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 24 Feb 2022 10:30:48 +0000 Subject: [PATCH 010/831] Fixing style errors. --- htdocs/product/inventory/class/inventory.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 0ad970a7d40..fb2041b6b88 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -294,7 +294,7 @@ class Inventory extends CommonObject } if ($this->include_sub_warehouse>0 && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE) { $this->getchildWarehouse($this->fk_warehouse, $TChildWarehouses); - $sql .= " OR ps.fk_entrepot IN (".filter_var(implode(',', $TChildWarehouses),FILTER_SANITIZE_STRING).")"; + $sql .= " OR ps.fk_entrepot IN (".filter_var(implode(',', $TChildWarehouses), FILTER_SANITIZE_STRING).")"; } $sql .= ')'; From f9c5da4ae27ba7e1714d43bb48ad2175ee679b11 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 24 Feb 2022 16:49:13 +0100 Subject: [PATCH 011/831] NEW : Added of a popup on validation instead of a database fielld to know if the user wants to include subwarehouse --- htdocs/langs/en_US/stocks.lang | 4 +++- htdocs/product/inventory/card.php | 18 +++++++++++++++++- .../inventory/class/inventory.class.php | 12 ++++++------ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 5d6ad811983..905bd137350 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -271,4 +271,6 @@ ErrorCantFindCodeInInventory=Can't find the following code in inventory QtyWasAddedToTheScannedBarcode=Success !! The quantity was added to all the requested barcode. You can close the Scanner tool. StockChangeDisabled=Change on stock disabled NoWarehouseDefinedForTerminal=No warehouse defined for terminal -IncludeSubWarehouse=Include sub-warehouse ? \ No newline at end of file +ValidateInventory=Inventory validation +IncludeSubWarehouse=Include sub-warehouse ? +IncludeSubWarehouseExplanation=Check this box if you want to include all sub-warehouses of the associated warehouse in the inventory \ No newline at end of file diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 23473545b11..14a107d3d6a 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -291,6 +291,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } + + if ($action == 'validate'){ + $form = new Form($db); + $formquestion = ''; + if($conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE && !empty($object->fk_warehouse)){ + $formquestion = array( + array('type' => 'checkbox', 'name' => 'include_sub_warehouse', 'label' => $langs->trans("IncludeSubWarehouse"), 'value' => 0, 'size' => '10'), + ); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateInventory'), $langs->trans('IncludeSubWarehouseExplanation'), 'confirm_validate', $formquestion, '', 1); + } + } + // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -414,7 +426,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Validate if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_CANCELED) { if ($permissiontoadd) { - print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'; + if($conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE && !empty($object->fk_warehouse)){ + print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'; + } else { + print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'; + } } } diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index fb2041b6b88..8f79a6d8267 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -101,7 +101,6 @@ class Inventory extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), - 'include_sub_warehouse' => array('type'=>'boolean', 'label'=>'IncludeSubWarehouse', 'enabled'=>'$conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE', 'visible'=>1, 'notnull'=>0, 'index'=>0, 'position'=>31), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35), // This date is not used so disabled by default. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), @@ -265,6 +264,7 @@ class Inventory extends CommonObject $result = 0; + $this->include_sub_warehouse = GETPOST('include_sub_warehouse'); if ($this->status == self::STATUS_DRAFT) { // Delete inventory $sql = 'DELETE FROM '.$this->db->prefix().'inventorydet WHERE fk_inventory = '.((int) $this->id); @@ -291,12 +291,12 @@ class Inventory extends CommonObject } if ($this->fk_warehouse > 0) { $sql .= " AND (ps.fk_entrepot = ".((int) $this->fk_warehouse); + if (!empty($this->include_sub_warehouse) && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE) { + $this->getchildWarehouse($this->fk_warehouse, $TChildWarehouses); + $sql .= " OR ps.fk_entrepot IN (".filter_var(implode(',', $TChildWarehouses), FILTER_SANITIZE_STRING).")"; + } + $sql .= ')'; } - if ($this->include_sub_warehouse>0 && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE) { - $this->getchildWarehouse($this->fk_warehouse, $TChildWarehouses); - $sql .= " OR ps.fk_entrepot IN (".filter_var(implode(',', $TChildWarehouses), FILTER_SANITIZE_STRING).")"; - } - $sql .= ')'; $inventoryline = new InventoryLine($this->db); From 168b1c7578552a9b0d2cd87fbf755af2676db9b1 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 24 Feb 2022 16:51:14 +0100 Subject: [PATCH 012/831] NEW : remove include_subwarehouse form llx_inventory database table --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 2 -- htdocs/install/mysql/tables/llx_inventory-stock.sql | 1 - 2 files changed, 3 deletions(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 2e4c271a691..cbf3c8fadc5 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -237,8 +237,6 @@ ALTER TABLE llx_advtargetemailing RENAME TO llx_mailing_advtarget; ALTER TABLE llx_mailing ADD UNIQUE uk_mailing(titre, entity); -ALTER TABLE llx_inventory ADD COLUMN include_sub_warehouse boolean DEFAULT FALSE; - create table llx_inventory_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, diff --git a/htdocs/install/mysql/tables/llx_inventory-stock.sql b/htdocs/install/mysql/tables/llx_inventory-stock.sql index c6ac552de60..1f38469b300 100644 --- a/htdocs/install/mysql/tables/llx_inventory-stock.sql +++ b/htdocs/install/mysql/tables/llx_inventory-stock.sql @@ -31,7 +31,6 @@ CREATE TABLE llx_inventory fk_product integer DEFAULT NULL, status integer DEFAULT 0, title varchar(255) NOT NULL, - include_sub_warehouse boolean DEFAULT FALSE, date_inventory datetime DEFAULT NULL, date_validation datetime DEFAULT NULL, import_key varchar(14) -- import key From 23cd8bde29fdd0d5e81a01236b296a641476df75 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 24 Feb 2022 15:54:37 +0000 Subject: [PATCH 013/831] Fixing style errors. --- htdocs/product/inventory/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 14a107d3d6a..901a4e2a399 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -292,10 +292,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } - if ($action == 'validate'){ + if ($action == 'validate') { $form = new Form($db); $formquestion = ''; - if($conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE && !empty($object->fk_warehouse)){ + if ($conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE && !empty($object->fk_warehouse)) { $formquestion = array( array('type' => 'checkbox', 'name' => 'include_sub_warehouse', 'label' => $langs->trans("IncludeSubWarehouse"), 'value' => 0, 'size' => '10'), ); @@ -426,7 +426,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Validate if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_CANCELED) { if ($permissiontoadd) { - if($conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE && !empty($object->fk_warehouse)){ + if ($conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE && !empty($object->fk_warehouse)) { print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'; } else { print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'; From 43428f622f789f07aead4cb494505bda2f4a86cd Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 31 Mar 2022 15:28:03 +0200 Subject: [PATCH 014/831] FIX : Add sub warehouse management on inventory.php file --- htdocs/product/inventory/inventory.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 6026e4316e4..ab3c0276051 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -435,6 +435,17 @@ if ($object->id > 0) { $action = 'view'; } + if ($action == 'validate') { + $form = new Form($db); + $formquestion = ''; + if ($conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE && !empty($object->fk_warehouse)) { + $formquestion = array( + array('type' => 'checkbox', 'name' => 'include_sub_warehouse', 'label' => $langs->trans("IncludeSubWarehouse"), 'value' => 0, 'size' => '10'), + ); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateInventory'), $langs->trans('IncludeSubWarehouseExplanation'), 'confirm_validate', $formquestion, '', 1); + } + } + // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -541,7 +552,11 @@ if ($object->id > 0) { if (empty($reshook)) { if ($object->status == Inventory::STATUS_DRAFT) { if ($permissiontoadd) { - print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'."\n"; + if ($conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE && !empty($object->fk_warehouse)) { + print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'; + } else { + print ''.$langs->trans("Validate").' ('.$langs->trans("Start").')'; + } } else { print ''.$langs->trans('Validate').' ('.$langs->trans("Start").')'."\n"; } From 468f4d18cb3634d7ee2b3cf266e86b6b6836bd29 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 7 Apr 2022 17:43:40 +0200 Subject: [PATCH 015/831] FIX : PR returns --- htdocs/core/actions_addupdatedelete.inc.php | 9 ++++++++- htdocs/product/inventory/class/inventory.class.php | 5 ++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index f97d4aa94ee..8b0f07c3274 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -366,7 +366,14 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto // Action validate object if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { - $result = $object->validate($user); + if($object->element == 'inventory'){ + //Case of the conf INVENTORY_INCLUDE_SUB_WAREHOUSE + $include_sub_warehouse = !empty(GETPOST('include_sub_warehouse')) ? GETPOST('include_sub_warehouse') : 0; + $result = $object->validate($user, $include_sub_warehouse); + } else { + $result = $object->validate($user); + } + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 8f79a6d8267..ddb41813eae 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -257,14 +257,13 @@ class Inventory extends CommonObject * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, Id of created object if OK */ - public function validate(User $user, $notrigger = false) + public function validate(User $user, $include_sub_warehouse, $notrigger = false) { global $conf; $this->db->begin(); $result = 0; - $this->include_sub_warehouse = GETPOST('include_sub_warehouse'); if ($this->status == self::STATUS_DRAFT) { // Delete inventory $sql = 'DELETE FROM '.$this->db->prefix().'inventorydet WHERE fk_inventory = '.((int) $this->id); @@ -291,7 +290,7 @@ class Inventory extends CommonObject } if ($this->fk_warehouse > 0) { $sql .= " AND (ps.fk_entrepot = ".((int) $this->fk_warehouse); - if (!empty($this->include_sub_warehouse) && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE) { + if (!empty($include_sub_warehouse) && $conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE) { $this->getchildWarehouse($this->fk_warehouse, $TChildWarehouses); $sql .= " OR ps.fk_entrepot IN (".filter_var(implode(',', $TChildWarehouses), FILTER_SANITIZE_STRING).")"; } From 2150c93f61344ef40585fc909c63336e94c4f7fa Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 7 Apr 2022 15:49:53 +0000 Subject: [PATCH 016/831] Fixing style errors. --- htdocs/core/actions_addupdatedelete.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 8b0f07c3274..45ca6074478 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -366,7 +366,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto // Action validate object if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { - if($object->element == 'inventory'){ + if ($object->element == 'inventory') { //Case of the conf INVENTORY_INCLUDE_SUB_WAREHOUSE $include_sub_warehouse = !empty(GETPOST('include_sub_warehouse')) ? GETPOST('include_sub_warehouse') : 0; $result = $object->validate($user, $include_sub_warehouse); From ac81bacb4ffa46dfe5bdf232b93e1a5a58f1b8d1 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Wed, 20 Apr 2022 13:57:09 +0200 Subject: [PATCH 017/831] ADD : add parent product column on list if show_child products is enabled, add a column who contains the parent product --- htdocs/product/list.php | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index de5e4f278b7..bb64f5a8d3e 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -12,6 +12,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2020-2021 Open-DSI + * Copyright (C) 2022 Charlene Benke * * 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 @@ -209,6 +210,7 @@ $arrayfields = array( 'p.fk_product_type'=>array('label'=>"Type", 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->service->enabled)), 'position'=>11), 'p.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(!empty($conf->barcode->enabled)), 'position'=>12), 'p.duration'=>array('label'=>"Duration", 'checked'=>($contextpage != 'productlist'), 'enabled'=>(!empty($conf->service->enabled) && (string) $type == '1'), 'position'=>13), + 'pac.fk_product_parent' => array('label'=>"ParentProduct", 'checked'=> 1, 'enabled'=>(!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && $show_childproducts)), 'position'=>14), 'p.finished'=>array('label'=>"Nature", 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && $type != '1'), 'position'=>19), 'p.weight'=>array('label'=>'Weight', 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && $type != '1'), 'position'=>20), 'p.weight_units'=>array('label'=>'WeightUnits', 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && $type != '1'), 'position'=>21), @@ -413,8 +415,9 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ' p.fk_unit, cu.label as cu_label,'; } $sql .= ' MIN(pfp.unitprice) as minsellprice'; -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { - $sql .= ', pac.rowid prod_comb_id'; +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) )) { + $sql .= ', pac.rowid as prod_comb_id'; + $sql .= ', pac.fk_product_parent'; } // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -442,7 +445,7 @@ if (!empty($conf->global->MAIN_MULTILANGS)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$db->escape($langs->getDefaultLang())."'"; } -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD))) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } if (!empty($conf->global->PRODUCT_USE_UNITS)) { @@ -574,8 +577,9 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ', p.fk_unit, cu.label'; } -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD))) { $sql .= ', pac.rowid'; + $sql .= ', pac.fk_product_parent'; } // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -901,7 +905,11 @@ if ($resql) { print ''; print ''; } - + // Parent + if (!empty($arrayfields['pac.fk_product_parent']['checked'])) { + print ''; + print ''; + } // Finished if (!empty($arrayfields['p.finished']['checked'])) { print ''; @@ -1143,6 +1151,9 @@ if ($resql) { if (!empty($arrayfields['p.duration']['checked'])) { print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"], "p.duration", "", $param, '', $sortfield, $sortorder, 'center '); } + if (!empty($arrayfields['pac.fk_product_parent']['checked'])) { + print_liste_field_titre($arrayfields['pac.fk_product_parent']['label'], $_SERVER["PHP_SELF"], "pac.fk_product_parent", "", $param, '', $sortfield, $sortorder, 'center '); + } if (!empty($arrayfields['p.finished']['checked'])) { print_liste_field_titre($arrayfields['p.finished']['label'], $_SERVER["PHP_SELF"], "p.finished", "", $param, '', $sortfield, $sortorder, 'center '); } @@ -1450,7 +1461,19 @@ if ($resql) { $totalarray['nbfield']++; } } - + + if (!empty($arrayfields['pac.fk_product_parent']['checked'])) { + print ''; + if ($obj->fk_product_parent > 0) { + $product_parent_static= new Product($db); + $product_parent_static->fetch($obj->fk_product_parent); + print $product_parent_static->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } // Finished if (!empty($arrayfields['p.finished']['checked'])) { print ''; From 9323b366adde5aa602e30043dba83394ad64e0e3 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Fri, 22 Apr 2022 10:18:07 +0200 Subject: [PATCH 018/831] FIX : Retours PR --- htdocs/core/actions_addupdatedelete.inc.php | 5 ++--- htdocs/product/inventory/card.php | 1 + htdocs/product/inventory/class/inventory.class.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 8b0f07c3274..cb66cc97ca6 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -366,10 +366,9 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto // Action validate object if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { - if($object->element == 'inventory'){ + if($object->element == 'inventory' && !empty($include_sub_warehouse)){ //Case of the conf INVENTORY_INCLUDE_SUB_WAREHOUSE - $include_sub_warehouse = !empty(GETPOST('include_sub_warehouse')) ? GETPOST('include_sub_warehouse') : 0; - $result = $object->validate($user, $include_sub_warehouse); + $result = $object->validate($user, false, $include_sub_warehouse); } else { $result = $object->validate($user); } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 390a57ea989..e2320d047fd 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -39,6 +39,7 @@ $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'inventorycard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); +$include_sub_warehouse = !empty(GETPOST('include_sub_warehouse')) ? GETPOST('include_sub_warehouse') : 0; if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $result = restrictedArea($user, 'stock', $id); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index ddb41813eae..e8cd0c87c2c 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -257,7 +257,7 @@ class Inventory extends CommonObject * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, Id of created object if OK */ - public function validate(User $user, $include_sub_warehouse, $notrigger = false) + public function validate(User $user, $notrigger = false, $include_sub_warehouse = 0) { global $conf; $this->db->begin(); From 8f670ce96d832069de5b2df5af907904f500bfe5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 22 Apr 2022 08:25:49 +0000 Subject: [PATCH 019/831] Fixing style errors. --- htdocs/core/actions_addupdatedelete.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index cb66cc97ca6..ec3f5a180b9 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -366,7 +366,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto // Action validate object if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { - if($object->element == 'inventory' && !empty($include_sub_warehouse)){ + if ($object->element == 'inventory' && !empty($include_sub_warehouse)) { //Case of the conf INVENTORY_INCLUDE_SUB_WAREHOUSE $result = $object->validate($user, false, $include_sub_warehouse); } else { From a3be6a0c2cdc26e2902ec2bc7a15afc471bef686 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Thu, 28 Apr 2022 12:11:59 +0200 Subject: [PATCH 020/831] FIX : When conf is active, option "include subwarehouse" must be checked by default --- htdocs/product/inventory/card.php | 2 +- htdocs/product/inventory/inventory.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index e2320d047fd..e3e6cb4c1d3 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -295,7 +295,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formquestion = ''; if ($conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE && !empty($object->fk_warehouse)) { $formquestion = array( - array('type' => 'checkbox', 'name' => 'include_sub_warehouse', 'label' => $langs->trans("IncludeSubWarehouse"), 'value' => 0, 'size' => '10'), + array('type' => 'checkbox', 'name' => 'include_sub_warehouse', 'label' => $langs->trans("IncludeSubWarehouse"), 'value' => 1, 'size' => '10'), ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateInventory'), $langs->trans('IncludeSubWarehouseExplanation'), 'confirm_validate', $formquestion, '', 1); } diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index ab3c0276051..82b3c6bc28e 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -440,7 +440,7 @@ if ($object->id > 0) { $formquestion = ''; if ($conf->global->INVENTORY_INCLUDE_SUB_WAREHOUSE && !empty($object->fk_warehouse)) { $formquestion = array( - array('type' => 'checkbox', 'name' => 'include_sub_warehouse', 'label' => $langs->trans("IncludeSubWarehouse"), 'value' => 0, 'size' => '10'), + array('type' => 'checkbox', 'name' => 'include_sub_warehouse', 'label' => $langs->trans("IncludeSubWarehouse"), 'value' => 1, 'size' => '10'), ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateInventory'), $langs->trans('IncludeSubWarehouseExplanation'), 'confirm_validate', $formquestion, '', 1); } From 32f3a2aff642e39f4334b097ddc73271d79ca211 Mon Sep 17 00:00:00 2001 From: kamel Date: Fri, 13 May 2022 10:45:18 +0200 Subject: [PATCH 021/831] NEW - Add all id prof checker on thirdparty for code compta customer and supplier --- htdocs/comm/card.php | 1 + htdocs/fourn/card.php | 1 + .../fourn/class/fournisseur.facture.class.php | 50 ++++++++++++++++++- htdocs/langs/en_US/errors.lang | 1 + htdocs/societe/admin/societe.php | 21 ++------ htdocs/societe/class/societe.class.php | 44 ++++++++++++++-- 6 files changed, 96 insertions(+), 22 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 411efc5ae93..055432dc76c 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -167,6 +167,7 @@ if (empty($reshook)) { $result = $object->update($object->id, $user, 1, 1, 0); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + $_GET['action'] = 'editcustomeraccountancycode'; } } diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 8ad44d198a8..27493417312 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -103,6 +103,7 @@ if (empty($reshook)) { $result = $object->update($object->id, $user, 1, 0, 1); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + $_GET['action'] = 'editsupplieraccountancycode'; } } // terms of the settlement diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 52d9b19bfaf..e8e10008fae 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1762,7 +1762,7 @@ class FactureFournisseur extends CommonInvoice */ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) { - global $conf, $langs; + global $mysoc, $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1791,6 +1791,54 @@ class FactureFournisseur extends CommonInvoice return -1; } + // Check for mandatory fields in thirdparty (defined into setup) + if (!empty($this->thirdparty) && is_object($this->thirdparty)) { + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'ACCOUNTANCY_CODE_SUPPLIER'); + foreach ($array_to_check as $key) { + $keymin = strtolower($key); + if ($keymin == 'accountancy_code_supplier') $keymin = 'code_compta_fournisseur'; + if (!property_exists($this->thirdparty, $keymin)) { + continue; + } + $vallabel = $this->thirdparty->$keymin; + + $i = (int) preg_replace('/[^0-9]/', '', $key); + if ($i > 0) { + if ($this->thirdparty->isACompany()) { + // Check for mandatory prof id (but only if country is other than ours) + if ($mysoc->country_id > 0 && $this->thirdparty->country_id == $mysoc->country_id) { + $idprof_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; + if (!$vallabel && !empty($conf->global->$idprof_mandatory)) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId'.$i, $this->thirdparty->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").') ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + } + } else { + if ($key == 'EMAIL') { + // Check for mandatory + if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($this->thirdparty->email)) { + $langs->load("errors"); + $this->error = $langs->trans("ErrorBadEMail", $this->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").') ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') { + // Check for mandatory + if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_SUPPLIER_INVOICE_MANDATORY) && empty($this->thirdparty->code_compta_fournisseur)) { + $langs->load("errors"); + $this->error = $langs->trans("ErrorAccountancyCodeSupplierIsMandatory", $this->thirdparty->name).' ('.$langs->trans("ForbiddenBySetupRules").')'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + } + } + } + $this->db->begin(); // Define new ref diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 60b2b424aaa..e12751834eb 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -31,6 +31,7 @@ ErrorBadThirdPartyName=Bad value for third-party name ForbiddenBySetupRules=Forbidden by setup rules ErrorProdIdIsMandatory=The %s is mandatory ErrorAccountancyCodeCustomerIsMandatory=The accountancy code of customer %s is mandatory +ErrorAccountancyCodeSupplierIsMandatory=The accountancy code of supplier %s is mandatory ErrorBadCustomerCodeSyntax=Bad syntax for customer code ErrorBadBarCodeSyntax=Bad syntax for barcode. May be you set a bad barcode type or you defined a barcode mask for numbering that does not match value scanned. ErrorCustomerCodeRequired=Customer code required diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 2fb9285379f..870c8dd96b1 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -672,6 +672,10 @@ $profid['IDPROF6'][0] = $langs->trans("ProfId6"); $profid['IDPROF6'][1] = $langs->transcountry('ProfId6', $mysoc->country_code); $profid['EMAIL'][0] = $langs->trans("EMail"); $profid['EMAIL'][1] = $langs->trans('Email'); +$profid['ACCOUNTANCY_CODE_CUSTOMER'][0] = $langs->trans("CustomerAccountancyCodeShort"); +$profid['ACCOUNTANCY_CODE_CUSTOMER'][1] = $langs->trans('CustomerAccountancyCodeShort'); +$profid['ACCOUNTANCY_CODE_SUPPLIER'][0] = $langs->trans("SupplierAccountancyCodeShort"); +$profid['ACCOUNTANCY_CODE_SUPPLIER'][1] = $langs->trans('SupplierAccountancyCodeShort'); $nbofloop = count($profid); foreach ($profid as $key => $val) { @@ -724,23 +728,6 @@ foreach ($profid as $key => $val) { $i++; } -if ($conf->accounting->enabled) { - print ''; - print ''.$langs->trans('CustomerAccountancyCodeShort')."\n"; - print ''; - - if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_INVOICE_MANDATORY)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print "\n"; -} - print "\n"; print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1d32063c27b..7c35e84a3e2 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1152,9 +1152,11 @@ class Societe extends CommonObject } // Check for duplicate or mandatory fields defined into setup - $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'ACCOUNTANCY_CODE_CUSTOMER', 'ACCOUNTANCY_CODE_SUPPLIER'); foreach ($array_to_check as $key) { $keymin = strtolower($key); + if ($key == 'ACCOUNTANCY_CODE_CUSTOMER') $keymin = 'code_compta'; + elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') $keymin = 'code_compta_fournisseur'; $i = (int) preg_replace('/[^0-9]/', '', $key); $vallabel = $this->$keymin; @@ -1198,6 +1200,40 @@ class Societe extends CommonObject } } } + elseif ($key == 'ACCOUNTANCY_CODE_CUSTOMER' && ! empty($this->client)) { + // Check for unicity + if ($vallabel && !empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_UNIQUE)) { + if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { + $langs->loadLangs(array("errors", 'compta')); + $error++; + $this->errors[] = $langs->trans('CustomerAccountancyCodeShort') . " " . $langs->trans("ErrorProdIdAlreadyExist", $vallabel) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')'; + } + } + + // Check for mandatory + if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_MANDATORY) && (!isset($vallabel) || trim($vallabel) === '')) { + $langs->loadLangs(array("errors", 'compta')); + $error++; + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('CustomerAccountancyCodeShort')) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')'; + } + } + elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER' && ! empty($this->fournisseur)) { + // Check for unicity + if ($vallabel && !empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_SUPPLIER_UNIQUE)) { + if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { + $langs->loadLangs(array("errors", 'compta')); + $error++; + $this->errors[] = $langs->trans('SupplierAccountancyCodeShort') . " " . $langs->trans("ErrorProdIdAlreadyExist", $vallabel) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')'; + } + } + + // Check for mandatory + if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_SUPPLIER_MANDATORY) && (!isset($vallabel) || trim($vallabel) === '')) { + $langs->loadLangs(array("errors", 'compta')); + $error++; + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('SupplierAccountancyCodeShort')) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')'; + } + } } } @@ -3359,18 +3395,18 @@ class Societe extends CommonObject global $conf; if (!empty($conf->global->SOCIETE_CODECOMPTA_ADDON)) { + $module=$conf->global->SOCIETE_CODECOMPTA_ADDON; $res = false; $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { - $res = dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.'.php'); + $res = dol_include_once($dirroot.$module.'.php'); if ($res) { break; } } if ($res) { - $classname = $conf->global->SOCIETE_CODECOMPTA_ADDON; - $mod = new $classname; + $mod = new $module(); // Set code count in $mod->code $result = $mod->get_code($this->db, $this, $type); From 23fe8bef37ab7024611756607c526000ac83db97 Mon Sep 17 00:00:00 2001 From: kamel Date: Fri, 13 May 2022 10:53:00 +0200 Subject: [PATCH 022/831] Correction Stickler CI --- htdocs/fourn/class/fournisseur.facture.class.php | 3 +-- htdocs/societe/class/societe.class.php | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index e8e10008fae..5aea9b9e278 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1825,8 +1825,7 @@ class FactureFournisseur extends CommonInvoice dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); return -1; } - } - elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') { + } elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') { // Check for mandatory if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_SUPPLIER_INVOICE_MANDATORY) && empty($this->thirdparty->code_compta_fournisseur)) { $langs->load("errors"); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7c35e84a3e2..8ec94cd4471 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1199,8 +1199,7 @@ class Societe extends CommonObject $error++; $this->errors[] = $langs->trans('Email')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')'; } } - } - elseif ($key == 'ACCOUNTANCY_CODE_CUSTOMER' && ! empty($this->client)) { + } elseif ($key == 'ACCOUNTANCY_CODE_CUSTOMER' && !empty($this->client)) { // Check for unicity if ($vallabel && !empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_UNIQUE)) { if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { @@ -1216,8 +1215,7 @@ class Societe extends CommonObject $error++; $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('CustomerAccountancyCodeShort')) . ' (' . $langs->trans("ForbiddenBySetupRules") . ')'; } - } - elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER' && ! empty($this->fournisseur)) { + } elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER' && !empty($this->fournisseur)) { // Check for unicity if ($vallabel && !empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_SUPPLIER_UNIQUE)) { if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0))) { From e1eb85ffb0829d4a3bb88e602320eb8c1f704e2d Mon Sep 17 00:00:00 2001 From: kamel Date: Fri, 13 May 2022 11:53:23 +0200 Subject: [PATCH 023/831] relaunch travis From 16bdd0dc491744ecfbff2e7c5b250b4a91ae5ecb Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Sat, 21 May 2022 18:54:38 +0200 Subject: [PATCH 024/831] FIX #20930 --- htdocs/core/ajax/ziptown.php | 3 +++ htdocs/core/class/html.formcompany.class.php | 26 ++++++++++++++++++++ htdocs/user/card.php | 4 +-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index aa9474ce142..3cd50c8b612 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -141,6 +141,9 @@ if (GETPOST('zipcode') || GETPOST('town')) { } echo json_encode($return_arr); +} elseif (isset($_GET['country_codeid'])) { + $formcompany = new FormCompany($db); + print $formcompany->select_state(GETPOST('selected', 'int', 1), GETPOST('country_codeid', 'int', 1), GETPOST('htmlname', 'alpha', 1), GETPOST('morecss', 'alpha', 1)); } $db->close(); diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index f976fac978d..d1c79ab2979 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -366,6 +366,32 @@ class FormCompany extends Form return $out; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. + * In the case of an all-country list, the display breaks on the country. + * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). + * Thus the links with the departments are done on a department independently of its name. + * + * @param string $parent_field_id Parent select name to monitor + * @param integer $selected Code state preselected (mus be state id) + * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show + * @param string $htmlname Id of department. If '', we want only the string with