From 70c9788a8bf97fb3850dcebe7fe6938238851a26 Mon Sep 17 00:00:00 2001 From: werewolf7160 <31860486+werewolf7160@users.noreply.github.com> Date: Fri, 5 Feb 2021 12:44:55 +0100 Subject: [PATCH 01/15] call to createCommon() return int and not bool with generated Object, the post request call to createCommon() in it and taht function return a int (id or -1 if error). but the test on the returned value is a '!', that don't return false on "-1". a post request with an sql error for example(foreign key error for my test), will always return 200 instead of 500 with the error --- htdocs/modulebuilder/template/class/api_mymodule.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 05ca7f27d16..2e04e34dcac 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -203,7 +203,7 @@ class MyModuleApi extends DolibarrApi foreach ($request_data as $field => $value) { $this->myobject->$field = $value; } - if (!$this->myobject->create(DolibarrApiAccess::$user)) { + if ($this->myobject->create(DolibarrApiAccess::$user)<0) { throw new RestException(500, "Error creating MyObject", array_merge(array($this->myobject->error), $this->myobject->errors)); } return $this->myobject->id; From 858e9d1c03b0aafa825c7c7191046feadebe526b Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 17:27:56 +0100 Subject: [PATCH 02/15] update minimum version --- .../doc/pdf_standard_recruitmentjobposition.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 5f257f594cf..9b59eeca09d 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -70,9 +70,9 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio /** * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.5 = array(5, 5) + * e.g.: PHP ≥ 5.6 = array(5, 6) */ - public $phpmin = array(5, 5); + public $phpmin = array(5, 6); /** * Dolibarr version of the loaded document From 03a5f06d50f2bbc055bd8074c187204bd89df218 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 5 Feb 2021 17:37:51 +0100 Subject: [PATCH 03/15] Update libelle as label in shipment method API --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 84d4ddc3679..85a45e9ff45 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -643,7 +643,7 @@ class Setup extends DolibarrApi public function getListOfShipmentMethods($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); - $sql = "SELECT t.rowid, t.code, t.libelle, t.description, t.tracking"; + $sql = "SELECT t.rowid, t.code, t.libelle as label, t.description, t.tracking"; $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters From c96d36cad3b8dd927c13e44207037523ca214989 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 17:39:22 +0100 Subject: [PATCH 04/15] Save the name of generated file as the main doc when generating a doc with this template --- htdocs/core/modules/contract/doc/pdf_strato.modules.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 2b9fb62b1d4..619dcdf84d3 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -55,6 +55,11 @@ class pdf_strato extends ModelePDFContract */ public $description; + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + /** * @var string document type */ @@ -131,6 +136,7 @@ class pdf_strato extends ModelePDFContract $this->db = $db; $this->name = 'strato'; $this->description = $langs->trans("StandardContractsTemplate"); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format $this->type = 'pdf'; From 998c5b2ec3a3d15c8d662c847124a9226720c5a9 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 17:42:33 +0100 Subject: [PATCH 05/15] Save the name of generated file as the main doc when generating a doc with this template --- .../core/modules/delivery/doc/pdf_storm.modules.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index d6376e6cd17..f6275386cff 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2008 Chiptronik - * Copyright (C) 2011-2019 Philippe Grand + * Copyright (C) 2011-2021 Philippe Grand * Copyright (C) 2015 Marcos García * Copyright (C) 2020 John BOTELLA @@ -54,6 +54,11 @@ class pdf_storm extends ModelePDFDeliveryOrder */ public $description; + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + /** * @var string document type */ @@ -61,9 +66,9 @@ class pdf_storm extends ModelePDFDeliveryOrder /** * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.5 = array(5, 5) + * e.g.: PHP ≥ 5.6 = array(5, 6) */ - public $phpmin = array(5, 5); + public $phpmin = array(5, 6); /** * Dolibarr version of the loaded document @@ -127,6 +132,7 @@ class pdf_storm extends ModelePDFDeliveryOrder $this->db = $db; $this->name = "Storm"; $this->description = $langs->trans("DocumentModelStorm"); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format $this->type = 'pdf'; From d85c8c44fc673fddef4b75ce3906782546dfe2f9 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 17:49:43 +0100 Subject: [PATCH 06/15] Save the name of generated file as the main doc when generating a doc with this template --- htdocs/core/modules/delivery/doc/pdf_typhon.modules.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 3b8baa107ad..41ed6b22554 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2008 Chiptronik - * Copyright (C) 2011-2020 Philippe Grand + * Copyright (C) 2011-2021 Philippe Grand * Copyright (C) 2015 Marcos García * This program is free software; you can redistribute it and/or modify @@ -53,6 +53,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ public $description; + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + /** * @var string document type */ @@ -126,6 +131,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->db = $db; $this->name = "Typhon"; $this->description = $langs->trans("DocumentModelTyphon"); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format $this->type = 'pdf'; From c03da95acb10bae0374a582a444b1c73569ff49d Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 17:52:12 +0100 Subject: [PATCH 07/15] Save the name of generated file as the main doc when generating a doc with this template --- htdocs/core/modules/expedition/doc/pdf_espadon.modules.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 165e83a8e87..8441597a967 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -51,6 +51,11 @@ class pdf_espadon extends ModelePdfExpedition */ public $description; + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + /** * @var string document type */ @@ -122,6 +127,7 @@ class pdf_espadon extends ModelePdfExpedition $this->db = $db; $this->name = "espadon"; $this->description = $langs->trans("DocumentModelStandardPDF"); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template $this->type = 'pdf'; $formatarray = pdf_getFormat(); From 7c1342845609ac4aa56854853b2014ff64d30b8f Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 17:53:34 +0100 Subject: [PATCH 08/15] Save the name of generated file as the main doc when generating a doc with this template --- htdocs/core/modules/expedition/doc/pdf_merou.modules.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index bad252bf799..144167e8912 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -52,6 +52,11 @@ class pdf_merou extends ModelePdfExpedition */ public $description; + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + /** * @var string document type */ @@ -123,6 +128,7 @@ class pdf_merou extends ModelePdfExpedition $this->db = $db; $this->name = "merou"; $this->description = $langs->trans("DocumentModelMerou"); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template $this->type = 'pdf'; $formatarray = pdf_getFormat(); From e638c238c6ce65a366885cd9de4e9a1c8827cdd0 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 17:54:51 +0100 Subject: [PATCH 09/15] Save the name of generated file as the main doc when generating a doc with this template --- htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index f3cffecdd9c..62213127951 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -52,6 +52,11 @@ class pdf_rouget extends ModelePdfExpedition */ public $description; + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + /** * @var string document type */ @@ -123,6 +128,7 @@ class pdf_rouget extends ModelePdfExpedition $this->db = $db; $this->name = "rouget"; $this->description = $langs->trans("DocumentModelStandardPDF"); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template $this->type = 'pdf'; $formatarray = pdf_getFormat(); From 0f196d7f19b9807b06c5609e3088e46637605d5a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 17:56:57 +0100 Subject: [PATCH 10/15] Save the name of generated file as the main doc when generating a doc with this template --- .../core/modules/expensereport/doc/pdf_standard.modules.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 176b09264d4..8495aba945d 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -59,6 +59,11 @@ class pdf_standard extends ModeleExpenseReport */ public $description; + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + /** * @var string document type */ @@ -133,6 +138,7 @@ class pdf_standard extends ModeleExpenseReport $this->db = $db; $this->name = ""; $this->description = $langs->trans('PDFStandardExpenseReports'); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format $this->type = 'pdf'; From 4170332aeeed7d08811cdc84cbf4bc204a7705b6 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 17:58:54 +0100 Subject: [PATCH 11/15] Save the name of generated file as the main doc when generating a doc with this template --- htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 622cd0b2250..844e468a69d 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -54,6 +54,11 @@ class pdf_soleil extends ModelePDFFicheinter */ public $description; + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + /** * @var string document type */ @@ -124,6 +129,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->db = $db; $this->name = 'soleil'; $this->description = $langs->trans("DocumentModelStandardPDF"); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format $this->type = 'pdf'; From 5856f9e5cb6a1d4b0a2aba27c6a1867a288fbad7 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 18:04:46 +0100 Subject: [PATCH 12/15] Save the name of generated file as the main doc when generating a doc with this template and missing declarations --- .../project/doc/pdf_baleine.modules.php | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 6baf416ed64..431e7b6e85c 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -38,6 +38,31 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; class pdf_baleine extends ModelePDFProjects { + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + + /** + * @var string document type + */ + public $type; + /** * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.6 = array(5, 6) @@ -50,6 +75,41 @@ class pdf_baleine extends ModelePDFProjects */ public $version = 'dolibarr'; + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + /** * Issuer * @var Societe Object that emits @@ -71,6 +131,7 @@ class pdf_baleine extends ModelePDFProjects $this->db = $db; $this->name = "baleine"; $this->description = $langs->trans("DocumentModelBaleine"); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format $this->type = 'pdf'; From 5b5ea075e787abb34f2c8245ee7423bc9ce5eaa6 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 18:07:02 +0100 Subject: [PATCH 13/15] Save the name of generated file as the main doc when generating a doc with this template and missing declarations --- .../project/doc/pdf_beluga.modules.php | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 0f877428052..80862ba32d8 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -54,6 +54,78 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; class pdf_beluga extends ModelePDFProjects { + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + + /** + * @var string document type + */ + public $type; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.6 = array(5, 6) + */ + public $phpmin = array(5, 6); + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + /** * Page orientation * @var string 'P' or 'Portait' (default), 'L' or 'Landscape' @@ -81,6 +153,7 @@ class pdf_beluga extends ModelePDFProjects $this->db = $db; $this->name = "beluga"; $this->description = $langs->trans("DocumentModelBeluga"); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format $this->type = 'pdf'; From 47ca631193ca561d53b1738dbda89b6514a5a1ee Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 18:09:36 +0100 Subject: [PATCH 14/15] Save the name of generated file as the main doc when generating a doc with this template and missing declarations --- .../project/doc/pdf_timespent.modules.php | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 5426e076d33..e6fe76cba16 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -37,6 +37,31 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; class pdf_timespent extends ModelePDFProjects { + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var int Save the name of generated file as the main doc when generating a doc with this template + */ + public $update_main_doc_field; + + /** + * @var string document type + */ + public $type; + /** * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.6 = array(5, 6) @@ -49,6 +74,41 @@ class pdf_timespent extends ModelePDFProjects */ public $version = 'dolibarr'; + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + /** * Issuer * @var Societe Object that emits @@ -70,6 +130,7 @@ class pdf_timespent extends ModelePDFProjects $this->db = $db; $this->name = "timespent"; $this->description = $langs->trans("DocumentModelTimeSpent"); + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format $this->type = 'pdf'; From b2e61aa4994b9ed0069e0d640647ceddb5007daa Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 5 Feb 2021 18:23:17 +0100 Subject: [PATCH 15/15] fix typo --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 159898f7256..b9f98adfe04 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4914,7 +4914,7 @@ abstract class CommonObject $this->result['filename']=$ecmfile->filename;*/ //var_dump($obj->update_main_doc_field);exit; - // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) + // Update the last_main_doc field into main object (if document generator has property ->update_main_doc_field set) $update_main_doc_field = 0; if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1; if ($update_main_doc_field && !empty($this->table_element))