From 84dff519b6cad5dec487211af92c57da23853cc9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 31 Jul 2024 15:29:02 +0200 Subject: [PATCH 1/5] FIX possibility to add an internal contact (#30498) * FIX possibility to add an internal contact * FIX doc --- .../comm/propal/class/api_proposals.class.php | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 2749800b0dd..6d033f78eeb 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -579,16 +579,17 @@ class Proposals extends DolibarrApi * Add a contact type of given commercial proposal * * @param int $id Id of commercial proposal to update - * @param int $contactid Id of contact to add - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @param int $contactid Id of external or internal contact to add + * @param string $type Type of the external contact (BILLING, SHIPPING, CUSTOMER), internal contact (SALESREPFOLL) + * @param string $source Source of the contact (internal, external) * @return array * - * @url POST {id}/contact/{contactid}/{type} + * @url POST {id}/contact/{contactid}/{type}/{source} * * @throws RestException 401 * @throws RestException 404 */ - public function postContact($id, $contactid, $type) + public function postContact($id, $contactid, $type, $source = 'external') { if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); @@ -600,15 +601,23 @@ class Proposals extends DolibarrApi throw new RestException(404, 'Proposal not found'); } - if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { - throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); + if (!in_array($source, array('internal', 'external'), true)) { + throw new RestException(500, 'Availables sources: internal OR external'); + } + + if ($source == 'external' && !in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { + throw new RestException(500, 'Availables external types: BILLING, SHIPPING OR CUSTOMER'); + } + + if ($source == 'internal' && !in_array($type, array('SALESREPFOLL'), true)) { + throw new RestException(500, 'Availables internal types: SALESREPFOLL'); } if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->propal->add_contact($contactid, $type, 'external'); + $result = $this->propal->add_contact($contactid, $type, $source); if (!$result) { throw new RestException(500, 'Error when added the contact'); From 3fda1ce4c0a1a06e2920e329a1896ac57113242b Mon Sep 17 00:00:00 2001 From: IC-Ilies <86972374+IC-Ilies@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:36:07 +0200 Subject: [PATCH 2/5] FIX#30491 token not set to launch cron task manually (#30492) --- htdocs/cron/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 215bfb4e40d..8a9f80e677d 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -731,7 +731,7 @@ if ($num > 0) { } if ($user->hasRight('cron', 'execute')) { if (!empty($obj->status)) { - print ' Date: Wed, 31 Jul 2024 15:43:13 +0200 Subject: [PATCH 3/5] NEW API Document implementation for MRP (MO) (#30488) * Get /documents * PUT /documents/builddoc * POST /documents/upload --- htdocs/api/class/api_documents.class.php | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index fabb73c110b..a79d2232ff5 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -258,6 +258,22 @@ class Documents extends DolibarrApi $templateused = $doctemplate ? $doctemplate : $tmpobject->model_pdf; $result = $tmpobject->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { + throw new RestException(500, 'Error generating document missing doctemplate parameter'); + } + } elseif ($modulepart == 'mrp') { + require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php'; + + $tmpobject = new Mo($this->db); + $result = $tmpobject->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); + + if (!$result) { + throw new RestException(404, 'MO not found'); + } + + $templateused = $doctemplate ? $doctemplate : $tmpobject->model_pdf; + $result = $tmpobject->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { throw new RestException(500, 'Error generating document missing doctemplate parameter'); } @@ -567,6 +583,17 @@ class Documents extends DolibarrApi } $upload_dir = $conf->projet->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'project'); + } elseif ($modulepart == 'mrp') { + $modulepart = 'mrp'; + require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php'; + + $object = new Mo($this->db); + $result = $object->fetch($id, $ref); + if (!$result) { + throw new RestException(404, 'MO not found'); + } + + $upload_dir = $conf->mrp->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'mrp'); } else { throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } @@ -749,6 +776,10 @@ class Documents extends DolibarrApi $modulepart = 'contrat'; require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; $object = new Contrat($this->db); + } elseif ($modulepart == 'mrp') { + $modulepart = 'mrp'; + require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php'; + $object = new Mo($this->db); } else { // TODO Implement additional moduleparts throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); From f82eabbab7601de8de17c37f7f3c2ead9617c92d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2024 10:48:17 +0200 Subject: [PATCH 4/5] FIX #30513 FIX #30515 --- .../install/mysql/migration/19.0.0-20.0.0.sql | 22 +++++++++---------- htdocs/install/mysql/tables/llx_menu.key.sql | 6 ++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index ff150c92c7c..f0696fba61d 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -370,15 +370,15 @@ UPDATE llx_mrp_production SET disable_stock_change = 0 WHERE disable_stock_chang ALTER TABLE llx_socpeople ADD COLUMN url varchar(255); --- knowledgemanagement module -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_CREATE','Knowledgerecord created','Executed when a knowledgerecord is created','knowledgemanagement',57001); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_MODIFY','Knowledgerecord modified','Executed when a knowledgerecord is modified','knowledgemanagement',57002); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_VALIDATE','Knowledgerecord Evaluation validated','Executed when an evaluation is validated','knowledgemanagement',57004); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_REOPEN','Knowledgerecord reopen','Executed when an evaluation is back to draft','knowledgemanagement',57004); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_UNVALIDATE','Knowledgerecord unvalidated','Executed when an evaluation is back to draft','knowledgemanagement',57004); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_CANCEL','Knowledgerecord cancel','Executed when an evaluation to cancel','knowledgemanagement',57004); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_SENTBYMAIL','Mails sent from knowledgerecord file','knowledgerecord when you send email from knowledgerecord file','knowledgemanagement',57004); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_DELETE','Knowledgerecord deleted','Executed when a knowledgerecord is deleted','knowledgemanagement',57006); +-- knowledge management module +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_CREATE','Knowledge article created','Executed when a article is created','knowledgemanagement',57001); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_MODIFY','Knowledge article modified','Executed when a article is modified','knowledgemanagement',57002); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_VALIDATE','Knowledge article Evaluation validated','Executed when an evaluation is validated','knowledgemanagement',57004); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_REOPEN','Knowledge article reopen','Executed when an evaluation is back to draft','knowledgemanagement',57004); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_UNVALIDATE','Knowledge article invalidated','Executed when an evaluation is back to draft','knowledgemanagement',57004); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_CANCEL','Knowledge article cancel','Executed when an evaluation to cancel','knowledgemanagement',57004); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_SENTBYMAIL','Mails sent from article file','article when you send email from article file','knowledgemanagement',57004); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_DELETE','Knowledge article deleted','Executed when a article is deleted','knowledgemanagement',57006); -- table chargesociales indexes ALTER TABLE llx_chargesociales ADD INDEX idx_chargesociales_fk_type (fk_type); @@ -404,10 +404,10 @@ INSERT INTO llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active) ALTER TABLE llx_hrm_evaluation ADD COLUMN entity INTEGER DEFAULT 1 NOT NULL; --- Erreur SQL DB_ERROR_1170 BLOB/TEXT column 'url' used in key specification without a key length +-- Error SQL DB_ERROR_1170 BLOB/TEXT column 'url' used in key specification without a key length, so we remove completely the unique key ALTER TABLE llx_menu DROP INDEX idx_menu_uk_menu; ALTER TABLE llx_menu MODIFY COLUMN url TEXT NOT NULL; -ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, entity); +--ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, entity, url); UPDATE llx_c_units SET short_label = 'mn' WHERE short_label = 'i' AND code = 'MI'; diff --git a/htdocs/install/mysql/tables/llx_menu.key.sql b/htdocs/install/mysql/tables/llx_menu.key.sql index 6380a947737..4de7b3217e7 100644 --- a/htdocs/install/mysql/tables/llx_menu.key.sql +++ b/htdocs/install/mysql/tables/llx_menu.key.sql @@ -21,7 +21,5 @@ ALTER TABLE llx_menu ADD INDEX idx_menu_menuhandler_type (menu_handler, type); --- Erreur SQL DB_ERROR_1170 BLOB/TEXT column 'url' used in key specification without a key length - --- ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, url, entity); -ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, entity); +-- Error SQL DB_ERROR_1170 BLOB/TEXT column 'url' used in key specification without a key length, so we removed completely the unique key +-- ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, entity, url); From 6210c2429a229e8a314a8d022940e0c80d061087 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Aug 2024 10:50:52 +0200 Subject: [PATCH 5/5] Fix phan --- htdocs/variants/class/ProductAttribute.class.php | 2 +- .../variants/class/ProductCombination2ValuePair.class.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index eebf1255699..821b3e2da3e 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -371,7 +371,7 @@ class ProductAttribute extends CommonObject * * @param User $user User who updates the attribute * @param int $notrigger 1 = Do not execute trigger (0 by default) - * @return int <0 if KO, 1 if OK + * @return int Return <0 if KO, 1 if OK */ public function update(User $user, $notrigger = 0) { diff --git a/htdocs/variants/class/ProductCombination2ValuePair.class.php b/htdocs/variants/class/ProductCombination2ValuePair.class.php index 2d7b7c67314..c140dfc3a93 100644 --- a/htdocs/variants/class/ProductCombination2ValuePair.class.php +++ b/htdocs/variants/class/ProductCombination2ValuePair.class.php @@ -118,7 +118,7 @@ class ProductCombination2ValuePair * Create a ProductCombination2ValuePair * * @param User $user User that creates //not used - * @return int<-1,1> 1 if OK, -1 if KO + * @return int Return 1 if OK, -1 if KO */ public function create($user) { @@ -141,7 +141,7 @@ class ProductCombination2ValuePair * Retrieve all ProductCombination2ValuePair linked to a given ProductCombination ID. * * @param int $fk_combination ID of the ProductCombination - * @return -1|ProductCombination2ValuePair[] -1 if KO, array of ProductCombination2ValuePair if OK + * @return -1|ProductCombination2ValuePair[] Return <0 if KO, array of ProductCombination2ValuePair if OK */ public function fetchByFkCombination($fk_combination) { @@ -180,7 +180,7 @@ class ProductCombination2ValuePair * Delete all ProductCombination2ValuePair linked to a given ProductCombination ID. * * @param int $fk_combination ID of the ProductCombination - * @return int<-1|1> -1 if KO, 1 if OK + * @return int Return <0 if KO, 1 if OK */ public function deleteByFkCombination($fk_combination) {