From eaf2194bd2c21ec2d53423ad93ef17e8e16c09b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 24 Mar 2025 16:37:26 +0100 Subject: [PATCH 1/5] fix directory url (#33592) Co-authored-by: Laurent Destailleur --- htdocs/core/modules/mailings/partnership.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index cbfe9ec60a1..b0cddaf5cf1 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -298,7 +298,7 @@ class mailing_partnership extends MailingTargets return ''.img_object('', "societe").''; } if ($sourcetype == 'member') { - return ''.img_object('', "member").''; + return ''.img_object('', "member").''; } return ''; From 125b61dfd753808ba79c1186f0490d73f1e6dea1 Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Mon, 24 Mar 2025 16:38:28 +0100 Subject: [PATCH 2/5] FIX #33595 - Click on add component for virtual product (#33596) --- htdocs/product/composition/card.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 71d311ad3ef..2005090f333 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -376,8 +376,13 @@ if ($id > 0 || !empty($ref)) { $atleastonenotdefined = 0; // at least on buying price not defined - $tmpurlforbutton = 'javascript:console.log("click to add a product in kit");jQuery(".formtoaddinkit").toggle();'; - $morehtmlright = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $tmpurlforbutton, '', $usercancreate ? 1 : 0); + $tmpurlforbutton = 'javascript:void(0);'; + $newButtonParams = [ + 'attr' => [ + 'onclick' => 'console.log("click to add a product in kit");jQuery(".formtoaddinkit").toggle();return false;', + ] + ]; + $morehtmlright = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $tmpurlforbutton, '', $usercancreate ? 1 : 0, $newButtonParams); print load_fiche_titre($langs->trans("ProductAssociationList"), $morehtmlright, ''); From 73e54ae77e3212ffc1ef17199c3f864e766f5f06 Mon Sep 17 00:00:00 2001 From: kkhelifa-opendsi Date: Mon, 24 Mar 2025 16:39:13 +0100 Subject: [PATCH 3/5] FIX: rename and add class for column total_ttc in line template (view and title) (#33590) --- htdocs/core/tpl/objectline_title.tpl.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index 9f2e98b349d..b482edb8391 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -204,7 +204,7 @@ if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currenc } if ($outputalsopricetotalwithtax) { - print ''.$langs->trans('TotalTTCShort').''; + print ''.$langs->trans('TotalTTCShort').''; } if (isModEnabled('asset') && $object->element == 'invoice_supplier') { diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 804daad3f83..280844e006c 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -517,7 +517,7 @@ if ($line->special_code == 3) { // Price inc tax if ($outputalsopricetotalwithtax) { - print ''.price($sign * $line->total_ttc).''; + print ''.price($sign * $line->total_ttc).''; $coldisplay++; } From b9946cef4a5be03588a3d19e382a5242692bf1d7 Mon Sep 17 00:00:00 2001 From: Mathieu Schiffmann <909816+Movix@users.noreply.github.com> Date: Mon, 24 Mar 2025 16:41:00 +0100 Subject: [PATCH 4/5] NEW #33506 Add a constant to apply a ratio to resize images in ODT templates (#33543) * CLOSE #33506 add a constant holding the ratio to resize images in ODT templates A new Dolibarr constant MAIN_DOC_ODT_IMAGE_RATIO is taken in consideration for ODT templates. This constant holds a number that is multiplied when computing the size of images in ODT templates. All doc_generic_*_odt_modules.php files have been updated to call the setImage Method with a new parameter $ratio The method setImage in the file odt.php has been modified to have a new parameter $ratio and use it to compute the image size * FIX #33506 wrong branch some other files needed to be changed in the develop branch * FIX #33506 PR errors fixed * FIX #33506 codesniffer errors fixed * QUAL #33506 completed method comment --- .../asset/doc/doc_generic_asset_odt.modules.php | 9 ++++++++- .../bom/doc/doc_generic_bom_odt.modules.php | 9 ++++++++- .../doc/doc_generic_order_odt.modules.php | 9 ++++++++- .../doc/doc_generic_contract_odt.modules.php | 8 +++++++- .../doc/doc_generic_shipment_odt.modules.php | 17 ++++++++++++----- .../doc/doc_generic_invoice_odt.modules.php | 10 +++++++++- .../member/doc/doc_generic_member_odt.class.php | 10 +++++++++- .../mrp/doc/doc_generic_mo_odt.modules.php | 9 ++++++++- .../doc/doc_generic_product_odt.modules.php | 9 ++++++++- .../doc/doc_generic_project_odt.modules.php | 9 ++++++++- .../task/doc/doc_generic_task_odt.modules.php | 9 ++++++++- .../doc/doc_generic_proposal_odt.modules.php | 9 ++++++++- .../doc/doc_generic_reception_odt.modules.php | 10 +++++++++- .../societe/doc/doc_generic_odt.modules.php | 9 ++++++++- .../stock/doc/doc_generic_stock_odt.modules.php | 9 ++++++++- ...doc_generic_supplier_invoice_odt.modules.php | 9 ++++++++- .../doc_generic_supplier_order_odt.modules.php | 9 ++++++++- ...oc_generic_supplier_proposal_odt.modules.php | 9 ++++++++- .../doc/doc_generic_ticket_odt.modules.php | 10 +++++++++- .../user/doc/doc_generic_user_odt.modules.php | 10 +++++++++- .../doc/doc_generic_usergroup_odt.modules.php | 10 +++++++++- htdocs/includes/odtphp/Segment.php | 7 ++++--- htdocs/includes/odtphp/odf.php | 7 ++++--- .../doc/doc_generic_myobject_odt.modules.php | 9 ++++++++- ...neric_recruitmentjobposition_odt.modules.php | 9 ++++++++- 25 files changed, 201 insertions(+), 33 deletions(-) diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index 0ff119f587c..83edf0192f8 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -380,12 +380,19 @@ class doc_generic_asset_odt extends ModelePDFAsset $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } 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 006d797f5b6..4117b0d23ff 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 @@ -378,11 +378,18 @@ class doc_generic_bom_odt extends ModelePDFBom $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } 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 3495cc57265..ccfbe10eb1c 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 @@ -399,11 +399,18 @@ class doc_generic_order_odt extends ModelePDFCommandes $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } 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 6c68888cebc..bfdf38b6778 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 @@ -389,13 +389,19 @@ class doc_generic_contract_odt extends ModelePDFContract // Call the ODTSubstitution hook $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 5cbba7e69f0..f6f950cdf16 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -372,6 +372,13 @@ class doc_generic_shipment_odt extends ModelePdfExpedition dol_syslog($e->getMessage(), LOG_INFO); } + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + // Make substitutions into odt of user info $tmparray = $this->get_substitutionarray_user($user, $outputlangs); foreach ($tmparray as $key => $value) { @@ -379,7 +386,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition if (preg_match('/logo$/', $key)) { // Image //var_dump($value);exit; if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } @@ -397,7 +404,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition if (preg_match('/logo$/', $key)) { // Image //var_dump($value);exit; if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } @@ -419,7 +426,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } @@ -437,7 +444,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } @@ -464,7 +471,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } 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 7b081f4d4bd..6fcf43dd223 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 @@ -453,12 +453,20 @@ class doc_generic_invoice_odt extends ModelePDFFactures $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + + //var_dump($tmparray); exit; foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image //var_dump($value);exit; if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index 6834dcfd7e7..8565ec752fa 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -351,12 +351,20 @@ class doc_generic_member_odt extends ModelePDFMember 'substitutionarray' => &$tmparray ); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } 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 93ce87f2be5..40b1a539046 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 @@ -378,12 +378,19 @@ class doc_generic_mo_odt extends ModelePDFMo $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index e6f0d524747..63fb48978d2 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -390,11 +390,18 @@ class doc_generic_product_odt extends ModelePDFProduct $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index ff383d66c81..fa732d749d1 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -651,11 +651,18 @@ class doc_generic_project_odt extends ModelePDFProjects $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index e45ce84f946..00bc01f449f 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -590,11 +590,18 @@ class doc_generic_task_odt extends ModelePDFTask $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other); complete_substitutions_array($tmparray, $outputlangs, $object); + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } 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 4e3f9adb01b..6cd04bf9963 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 @@ -436,11 +436,18 @@ class doc_generic_proposal_odt extends ModelePDFPropales $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 68b20c45977..4b11553590b 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -385,11 +385,19 @@ class doc_generic_reception_odt extends ModelePdfReception // Call the ODTSubstitution hook $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 23626a6bb8f..12bdc8eb8bc 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -384,12 +384,19 @@ class doc_generic_odt extends ModeleThirdPartyDoc $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + // Replace variables into document foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index fbb1bc64280..e382674d094 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -388,11 +388,18 @@ class doc_generic_stock_odt extends ModelePDFStock $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php index 6ec79297018..e201a80f60d 100644 --- a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php @@ -390,11 +390,18 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } 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 2c26e3fb876..9be7d008e50 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 @@ -385,11 +385,18 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } 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 b207a616be8..8e3e94014d2 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 @@ -414,11 +414,18 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index 9dd7398e304..4240a55f1af 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -346,11 +346,19 @@ class doc_generic_ticket_odt extends ModelePDFTicket // Call the ODTSubstitution hook $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 07c40904605..5cc119fe0c2 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -377,11 +377,19 @@ class doc_generic_user_odt extends ModelePDFUser // Call the ODTSubstitution hook $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 55015b96550..7309f688d2e 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -412,11 +412,19 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup // Call the ODTSubstitution hook $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php index 95b1c75d35c..e4ca91457d3 100644 --- a/htdocs/includes/odtphp/Segment.php +++ b/htdocs/includes/odtphp/Segment.php @@ -257,10 +257,11 @@ class Segment implements IteratorAggregate, Countable * * @param string $key name of the variable within the template * @param string $value path to the picture + * @param float $ratio Ratio for image * @throws OdfException * @return Segment */ - public function setImage($key, $value) + public function setImage($key, $value, float $ratio=1) { $filename = strtok(strrchr($value, '/'), '/.'); $file = substr(strrchr($value, '/'), 1); @@ -270,8 +271,8 @@ class Segment implements IteratorAggregate, Countable } // Set the width and height of the page list ($width, $height) = $size; - $width *= Odf::PIXEL_TO_CM; - $height *= Odf::PIXEL_TO_CM; + $width *= Odf::PIXEL_TO_CM * $ratio; + $height *= Odf::PIXEL_TO_CM * $ratio; // Fix local-aware issues (eg: 12,10 -> 12.10) $width = sprintf("%F", $width); $height = sprintf("%F", $height); diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 70ff59da7bc..b5210d21611 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -529,10 +529,11 @@ class Odf * * @param string $key name of the variable within the template * @param string $value path to the picture + * @param float $ratio Ratio for image * @throws OdfException * @return odf */ - public function setImage($key, $value) + public function setImage($key, $value, float $ratio=1) { $filename = strtok(strrchr($value, '/'), '/.'); $file = substr(strrchr($value, '/'), 1); @@ -541,8 +542,8 @@ class Odf throw new OdfException("Invalid image"); } list ($width, $height) = $size; - $width *= self::PIXEL_TO_CM; - $height *= self::PIXEL_TO_CM; + $width *= self::PIXEL_TO_CM * $ratio; + $height *= self::PIXEL_TO_CM * $ratio; $xml = << IMG; 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 59ae7b1ec71..e5cecd437e9 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 @@ -415,12 +415,19 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index 637ba4f0cba..57c238c2cc3 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -408,12 +408,19 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } From 936d0eeae1b7937b831cb9ffcd4936c5d6c1eb56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Mon, 24 Mar 2025 16:43:32 +0100 Subject: [PATCH 5/5] Add sold amount on api call (V2) (#33589) * Add sold amount on api call (V2) other way to implement it * Update api_bankaccounts.class.php Use the non deprecated property name. --------- Co-authored-by: Laurent Destailleur --- htdocs/compta/bank/class/api_bankaccounts.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 125150dd63c..84600351279 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -1,8 +1,9 @@ - * Copyright (C) 2024-2025 MDW - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2016 Xebax Christy + * Copyright (C) 2024-2025 MDW + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -113,6 +114,7 @@ class BankAccounts extends DolibarrApi $obj = $this->db->fetch_object($result); $account = new Account($this->db); if ($account->fetch($obj->rowid) > 0) { + $account->balance = $account->solde(1); // 1=Exclude future operation date $list[] = $this->_filterObjectProperties($this->_cleanObjectDatas($account), $properties); } }