From 7baba2ba43c69a886843ad0b0e738dad88bad770 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 14:55:02 +0100 Subject: [PATCH 01/11] Add line number substitution --- htdocs/core/class/commondocgenerator.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 1bd051d4b55..54dfb294975 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -536,14 +536,16 @@ abstract class CommonDocGenerator * * @param Object $line Object line * @param Translate $outputlangs Lang object to use for output + * @param int $linenumber The number of the line for the substitution of "object_line_pos" * @return array Return a substitution array */ - public function get_substitutionarray_lines($line, $outputlangs) + public function get_substitutionarray_lines($line, $outputlangs, $linenumber = 0) { // phpcs:enable global $conf; $resarray = array( + 'line_pos' => $linenumber, 'line_fulldesc'=>doc_getlinedesc($line, $outputlangs), 'line_product_ref'=>$line->product_ref, 'line_product_ref_fourn'=>$line->ref_fourn, // for supplier doc lines From 4a5593e2136eae62faaa94c9a367aa3f5eb05c9e Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 14:56:26 +0100 Subject: [PATCH 02/11] Add position to ODT for bom --- htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 6e23160baf6..9755369793e 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -411,9 +411,11 @@ class doc_generic_bom_odt extends ModelePDFBom } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); From b29d8e53ed1be6162681524ae356124601e49555 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 14:58:01 +0100 Subject: [PATCH 03/11] Add position to ODT order template --- .../modules/commande/doc/doc_generic_order_odt.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 4694cdaf6ee..75c5103c4ab 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -427,9 +427,11 @@ class doc_generic_order_odt extends ModelePDFCommandes } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); From cdbe6c1e8102af8bdc94ed7c37fd1acef0ad1af2 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 14:59:20 +0100 Subject: [PATCH 04/11] Add position to ODT contract template --- .../modules/contract/doc/doc_generic_contract_odt.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 190abd86126..c938f40cfb2 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -408,9 +408,11 @@ class doc_generic_contract_odt extends ModelePDFContract } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); From 7469aa1f355141acf681c20f81ae8d546655f053 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 15:00:37 +0100 Subject: [PATCH 05/11] Add position to ODT invoice template --- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 01070a6a6c7..acbebd54da8 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -435,9 +435,11 @@ class doc_generic_invoice_odt extends ModelePDFFactures } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); From 933b46790ac8a76dcea062d6de3aa31c197e8515 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 15:02:11 +0100 Subject: [PATCH 06/11] Add position to ODT mo template --- htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 398c8670a47..e276fe1f5f7 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -418,9 +418,11 @@ class doc_generic_mo_odt extends ModelePDFMo } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); From 1f2203f0d6655f17f5d9245b84e5dc244866e01b Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 15:04:02 +0100 Subject: [PATCH 07/11] Add position to ODT propale template --- .../modules/propale/doc/doc_generic_proposal_odt.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index fde5f08d318..33850c5d882 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -456,9 +456,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); From fc76586e2fc7f41b9e56a71c05c5a6231923c7b7 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 15:05:04 +0100 Subject: [PATCH 08/11] Add position to ODT supplier order template --- .../doc/doc_generic_supplier_order_odt.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index c71fe8f59ec..d7f48915308 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -421,9 +421,11 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); From 2d9300cedbd623786dfb5c7d2dafa11d01c47a2a Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 15:06:21 +0100 Subject: [PATCH 09/11] Add position to ODT supplier_proposal template --- .../doc/doc_generic_supplier_proposal_odt.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index 77503c4b61b..3b4a39288ea 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -445,9 +445,11 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal } if ($foundtagforlines) { + $linenumber = 0; foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); From 899ae0f52de9ce36ed6d299934099602b2875bf0 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 15:07:13 +0100 Subject: [PATCH 10/11] Add position to modulebuilder template --- .../mymodule/doc/doc_generic_myobject_odt.modules.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index df2c61ab7f5..940be47a780 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -422,9 +422,11 @@ class doc_generic_myobject_odt extends ModelePDFMyObject } if ($foundtagforlines) { - foreach ($object->lines as $line) + $linenumber = 0; + foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + $linenumber++; + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); From 94a47794293d446c8d22f877b12d37c4c4e9a24c Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 24 Feb 2020 15:10:36 +0100 Subject: [PATCH 11/11] fix indent --- .../modules/mymodule/doc/doc_generic_myobject_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index 940be47a780..22be3dee4ed 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -423,7 +423,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject if ($foundtagforlines) { $linenumber = 0; - foreach ($object->lines as $line) + foreach ($object->lines as $line) { $linenumber++; $tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber);