From e2f06c16e8826d7936dac1478f3ba1237862f557 Mon Sep 17 00:00:00 2001 From: John BOTELLA <68917336+thersane-john@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:14:42 +0200 Subject: [PATCH 1/2] FIX : space used by linked elements in PDF notes --- htdocs/core/lib/pdf.lib.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index ca1d72e1cd36e..a3d2a9ebdedfb 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2534,10 +2534,12 @@ function pdf_getLinkedObjects(&$object, $outputlangs) if (count($objects) > 1) { $order = null; + + $refListsTxt = ''; if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :'); + $refListsTxt.= $outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :'; } else { - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("RefSending").' :'); + $refListsTxt.=$outputlangs->transnoentities("RefSending").' :'; } // We concat this record info into fields xxx_value. title is overwrote. foreach ($objects as $elementobject) { @@ -2552,14 +2554,16 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } } } - + $refListsTxt.= (!empty($refListsTxt)?' ':''); if (! is_object($order)) { - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref)); + $refListsTxt.= $outputlangs->transnoentities($elementobject->ref); } else { - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '')); - $object->note_public = dol_concatdesc($object->note_public, ' / '.$outputlangs->transnoentities($elementobject->ref)); + $refListsTxt.= $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : ''); + $refListsTxt.= ' / '.$outputlangs->transnoentities($elementobject->ref); } } + + $object->note_public = dol_concatdesc($object->note_public, $refListsTxt); } elseif (count($objects) == 1) { $elementobject = array_shift($objects); $order = null; From 5c21c62fec0977dcb102835e1e67df112d6bc003 Mon Sep 17 00:00:00 2001 From: John BOTELLA <68917336+thersane-john@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:35:00 +0200 Subject: [PATCH 2/2] fix data repeated on object public note --- htdocs/core/lib/pdf.lib.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a3d2a9ebdedfb..e5f6695c92908 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2501,10 +2501,12 @@ function pdf_getLinkedObjects(&$object, $outputlangs) $outputlangs->load('orders'); if (count($objects) > 1 && count($objects) <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 10)) { - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("RefOrder").' :'); - foreach ($objects as $elementobject) { - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).(empty($elementobject->ref_client) ? '' : ' ('.$elementobject->ref_client.')').(empty($elementobject->ref_supplier) ? '' : ' ('.$elementobject->ref_supplier.')').' '); - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("OrderDate").' : '.dol_print_date($elementobject->date, 'day', '', $outputlangs)); + if (empty($object->context['DolPublicNoteAppendedGetLinkedObjects'])) { // Check if already appended before add to avoid repeat data + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("RefOrder").' :'); + foreach ($objects as $elementobject) { + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).(empty($elementobject->ref_client) ? '' : ' ('.$elementobject->ref_client.')').(empty($elementobject->ref_supplier) ? '' : ' ('.$elementobject->ref_supplier.')').' '); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("OrderDate").' : '.dol_print_date($elementobject->date, 'day', '', $outputlangs)); + } } } elseif (count($objects) == 1) { $elementobject = array_shift($objects); @@ -2563,7 +2565,9 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } } - $object->note_public = dol_concatdesc($object->note_public, $refListsTxt); + if (empty($object->context['DolPublicNoteAppendedGetLinkedObjects'])) { // Check if already appended before add to avoid repeat data + $object->note_public = dol_concatdesc($object->note_public, $refListsTxt); + } } elseif (count($objects) == 1) { $elementobject = array_shift($objects); $order = null; @@ -2601,6 +2605,8 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } } + $object->context['DolPublicNoteAppendedGetLinkedObjects'] = 1; + // For add external linked objects if (is_object($hookmanager)) { $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs' => $outputlangs);