From 14860febd572e99ba1991f54bb4db8b8b66241f7 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 6 May 2021 22:59:06 +0200 Subject: [PATCH 01/11] Update pdf.php --- htdocs/admin/pdf.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 7d7b5e36a40..f465f86f01e 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2012-2107 Juanjo Menent * Copyright (C) 2019 Ferran Marcet + * Copyright (C) 2021 Anthony Berton * * 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 @@ -417,6 +418,15 @@ print ''.$langs->trans("ShowDetailsInPDFPageFoot").'selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS : 0)); print ''; +print ''.$langs->trans("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", $arrval, $conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME); +} +print ''; + print ''; print ''; From e71e0f18cee163227c60fa0b1dcfc2bfea773724 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 6 May 2021 23:01:33 +0200 Subject: [PATCH 02/11] Update pdf.php --- htdocs/admin/pdf.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index f465f86f01e..ad93c28b49b 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -418,6 +418,8 @@ print ''.$langs->trans("ShowDetailsInPDFPageFoot").'selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS : 0)); print ''; +// Show alias in thirdparty name + print ''.$langs->trans("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME'); From 6ea3daf9f35282cba0bcfb31e62397ebcb56b099 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Thu, 9 Sep 2021 08:31:16 +0200 Subject: [PATCH 03/11] Update pdf.php --- htdocs/admin/pdf.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 41ed8e25ff2..80f057af26c 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -166,6 +166,10 @@ if ($action == 'update') { dolibarr_set_const($db, "PDF_SHOW_LINK_TO_ONLINE_PAYMENT", GETPOST('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', 'alpha'), 'chaine', 0, '', $conf->entity); } + if (GETPOSTISSET('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) { + dolibarr_set_const($db, "PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", GETPOST('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME', 'alpha'), 'chaine', 0, '', $conf->entity); + } + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); From becb96f04a89e01c5d28d4871e06082950c00728 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 8 Nov 2021 13:24:10 +0000 Subject: [PATCH 04/11] Fixing style errors. --- htdocs/admin/pdf.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index b32867bd90d..ba7159218ed 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -165,11 +165,11 @@ if ($action == 'update') { if (GETPOSTISSET('PDF_SHOW_LINK_TO_ONLINE_PAYMENT')) { dolibarr_set_const($db, "PDF_SHOW_LINK_TO_ONLINE_PAYMENT", GETPOST('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', 'alpha'), 'chaine', 0, '', $conf->entity); } - + if (GETPOSTISSET('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) { dolibarr_set_const($db, "PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", GETPOST('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME', 'alpha'), 'chaine', 0, '', $conf->entity); - } - + } + if (GETPOSTISSET('PDF_USE_A')) { dolibarr_set_const($db, "PDF_USE_A", GETPOST('PDF_USE_A', 'alpha'), 'chaine', 0, '', $conf->entity); } From b9cd22c60ac7bb55ecf5aee52ce2e394853e246a Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 26 Jan 2022 18:36:04 +0100 Subject: [PATCH 05/11] Add fonction invert and traduc --- htdocs/admin/pdf.php | 15 +++ htdocs/core/lib/pdf.lib.php | 192 +++++++++++++++++++++------------- htdocs/langs/en_US/admin.lang | 2 + 3 files changed, 139 insertions(+), 70 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index ba7159218ed..bf9ac2402be 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -170,6 +170,10 @@ if ($action == 'update') { dolibarr_set_const($db, "PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", GETPOST('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME', 'alpha'), 'chaine', 0, '', $conf->entity); } + if (GETPOSTISSET('PDF_INVERT_ALIAS_NAME_THIRDPARTY')) { + dolibarr_set_const($db, "PDF_INVERT_ALIAS_NAME_THIRDPARTY", GETPOST('PDF_INVERT_ALIAS_NAME_THIRDPARTY', 'alpha'), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('PDF_USE_A')) { dolibarr_set_const($db, "PDF_USE_A", GETPOST('PDF_USE_A', 'alpha'), 'chaine', 0, '', $conf->entity); } @@ -541,6 +545,17 @@ if ($conf->use_javascript_ajax) { } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", $arrval, $conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME); +} + +// Invert alias and name thirdparty + +print ''.$langs->trans("PDF_INVERT_ALIAS_NAME_THIRDPARTY").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PDF_INVERT_ALIAS_NAME_THIRDPARTY'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("PDF_INVERT_ALIAS_NAME_THIRDPARTY", $arrval, $conf->global->PDF_INVERT_ALIAS_NAME_THIRDPARTY); +} // Show online payment link on invoices diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index dda52e653fe..29cddef9b3e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -35,6 +35,8 @@ * \ingroup core */ +include_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; + /** * Return array head with list of tabs to view object informations. @@ -392,6 +394,12 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali $socname .= $thirdparty->name; if (($includealias || !empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { $socname .= " - ".$thirdparty->name_alias; + if ($conf->global->PDF_INVERT_ALIAS_NAME_THIRDPARTY) { + $socname = $thirdparty->name_alias." - ".$socname; + if ($conf->global->PDF_INVERT_ALIAS_NAME_THIRDPARTY) { + $socname = $thirdparty->name_alias." - ".$socname; + } + } } } elseif ($thirdparty instanceof Contact) { $socname = $thirdparty->socname; @@ -707,9 +715,12 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) // Add a background image on document only if good setup of const if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF) && ($conf->global->MAIN_USE_BACKGROUND_ON_PDF != '-1')) { // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image - $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image - $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); - $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak + $filepath = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF; + if (file_exists($filepath)) { + $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image + $pdf->Image($filepath, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); + $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak + } } } @@ -975,7 +986,7 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, */ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0) { - global $conf, $user, $mysoc; + global $conf, $user, $mysoc, $hookmanager; $outputlangs->load("dict"); $line = ''; @@ -1143,50 +1154,82 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } } - $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0); - $posy = $marginwithfooter + 0; + // For customize footer + if (is_object($hookmanager)) { + $parameters = array('line1' => $line1, 'line2' => $line2, 'line3' => $line3, 'line4' => $line4, 'outputlangs'=>$outputlangs); + $action = ''; + $hookmanager->executeHooks('pdf_pagefoot', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if (!empty($hookmanager->resPrint) && $hidefreetext == 0) { + $mycustomfooter = $hookmanager->resPrint; + $mycustomfooterheight = pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0)); - if ($line) { // Free text - $pdf->SetXY($dims['lm'], -$posy); - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { // by default - $pdf->MultiCell(0, 3, $line, 0, $align, 0); + $marginwithfooter = $marge_basse + $freetextheight + $mycustomfooterheight; + $posy = $marginwithfooter + 0; + + if ($line) { // Free text + $pdf->SetXY($dims['lm'], -$posy); + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { // by default + $pdf->MultiCell(0, 3, $line, 0, $align, 0); + } else { + $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); + } + $posy -= $freetextheight; + } + + $pdf->SetY(-$posy); + $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); + $posy--; + + $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $posy, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0)); + + $posy -= $mycustomfooterheight - 3; } else { - $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); + // Else default footer + $marginwithfooter = $marge_basse + $freetextheight + (!empty($line1) ? 3 : 0) + (!empty($line2) ? 3 : 0) + (!empty($line3) ? 3 : 0) + (!empty($line4) ? 3 : 0); + $posy = $marginwithfooter + 0; + + if ($line) { // Free text + $pdf->SetXY($dims['lm'], -$posy); + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { // by default + $pdf->MultiCell(0, 3, $line, 0, $align, 0); + } else { + $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk'] - $marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); + } + $posy -= $freetextheight; + } + + $pdf->SetY(-$posy); + $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); + $posy--; + + if (!empty($line1)) { + $pdf->SetFont('', 'B', 7); + $pdf->SetXY($dims['lm'], -$posy); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line1, 0, 'C', 0); + $posy -= 3; + $pdf->SetFont('', '', 7); + } + + if (!empty($line2)) { + $pdf->SetFont('', 'B', 7); + $pdf->SetXY($dims['lm'], -$posy); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line2, 0, 'C', 0); + $posy -= 3; + $pdf->SetFont('', '', 7); + } + + if (!empty($line3)) { + $pdf->SetXY($dims['lm'], -$posy); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line3, 0, 'C', 0); + } + + if (!empty($line4)) { + $posy -= 3; + $pdf->SetXY($dims['lm'], -$posy); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line4, 0, 'C', 0); + } } - $posy -= $freetextheight; } - - $pdf->SetY(-$posy); - $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); - $posy--; - - if (!empty($line1)) { - $pdf->SetFont('', 'B', 7); - $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line1, 0, 'C', 0); - $posy -= 3; - $pdf->SetFont('', '', 7); - } - - if (!empty($line2)) { - $pdf->SetFont('', 'B', 7); - $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line2, 0, 'C', 0); - $posy -= 3; - $pdf->SetFont('', '', 7); - } - - if (!empty($line3)) { - $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line3, 0, 'C', 0); - } - - if (!empty($line4)) { - $posy -= 3; - $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line4, 0, 'C', 0); - } - // Show page nb only on iso languages (so default Helvetica font) if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { $pdf->SetXY($dims['wk'] - $dims['rm'] - 15, -$posy); @@ -1363,6 +1406,11 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Description short of product line $libelleproduitservice = $label; if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) { + // Adding may convert the original string into a HTML string. Sowe have to first + // convert \n into
we text is not already HTML. + if (!dol_textishtml($libelleproduitservice)) { + $libelleproduitservice = str_replace("\n", '
', $libelleproduitservice); + } $libelleproduitservice = ''.$libelleproduitservice.''; } } @@ -1374,17 +1422,13 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) { $tmparrayofsubproducts = reset($prodser->sousprods); foreach ($tmparrayofsubproducts as $subprodval) { - $libelleproduitservice .= "\n * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3].' ('.$subprodval[1].')'; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, " * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3].' ('.$subprodval[1].')'); } } } // Description long of product line if (!empty($desc) && ($desc != $label)) { - if ($libelleproduitservice && empty($hidedesc)) { - $libelleproduitservice .= '__N__'; - } - if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); @@ -1418,17 +1462,17 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } if (empty($hidedesc)) { if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) { - $libelleproduitservice = $desc."\n".$libelleproduitservice; + $libelleproduitservice = dol_concatdesc($desc, $libelleproduitservice); } else { if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) { $libelleproduitservice = $desc; } else { - $libelleproduitservice .= $desc; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); } } } } else { - $libelleproduitservice .= $desc; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); } } } @@ -1492,7 +1536,11 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { + if (!dol_textishtml($libelleproduitservice)) { + $libelleproduitservice = str_replace("\n", '
', $libelleproduitservice); + } $ref_prodserv = ''.$ref_prodserv.''; + // $prefix_prodserv and $ref_prodser are not HTML var } $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; @@ -1506,7 +1554,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Adding the descriptions if they are filled $desccateg = $cate->description; if ($desccateg) { - $libelleproduitservice .= '__N__'.$desccateg; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desccateg); } } } @@ -1526,9 +1574,12 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } //print '>'.$outputlangs->charset_output.','.$period; if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { - $libelleproduitservice .= ''."__N__ ".$period.''; + if (!dol_textishtml($libelleproduitservice)) { + $libelleproduitservice = str_replace("\n", '
', $libelleproduitservice); + } + $libelleproduitservice .= '
'.$period.''; } else { - $libelleproduitservice .= "__N__".$period; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $period); } //print $libelleproduitservice; } @@ -2090,9 +2141,9 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm return ''; } if (empty($hidedetails) || $hidedetails > 1) { - if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) { + if (!empty($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF)) { $prev_progress = 0; - if (method_exists($object, 'get_prev_progress')) { + if (method_exists($object->lines[$i], 'get_prev_progress')) { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); } $result = round($object->lines[$i]->situation_percent - $prev_progress, 1).'%'; @@ -2247,13 +2298,11 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') { $outputlangs->load('orders'); - if (count($objects) > 1) { - $object->note_public .= dol_concatdesc($object->note_public, '
'.$outputlangs->transnoentities("RefOrder").' :
'); + 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).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : '').' '); - $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->transnoentities("OrderDate").' : '); - $object->note_public .= dol_concatdesc($object->note_public, dol_print_date($elementobject->date, 'day', '', $outputlangs)); - $object->note_public .= dol_concatdesc($object->note_public, '
'); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($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); @@ -2283,8 +2332,11 @@ function pdf_getLinkedObjects(&$object, $outputlangs) if (count($objects) > 1) { $order = null; - if (empty($object->linkedObjects['commande']) && $object->element != 'commande') $object->note_public .= dol_concatdesc($object->note_public, '
'.$outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :
'); - else $object->note_public .= dol_concatdesc($object->note_public, '
'.$outputlangs->transnoentities("RefSending").' :
'); + if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { + $object->note_public = dol_concatdesc($object->note_public, '
'.$outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :
'); + } else { + $object->note_public = dol_concatdesc($object->note_public, '
'.$outputlangs->transnoentities("RefSending").' :
'); + } // We concat this record info into fields xxx_value. title is overwrote. foreach ($objects as $elementobject) { if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { // There is not already a link to order and object is not the order, so we show also info with order @@ -2300,12 +2352,12 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } if (! is_object($order)) { - $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref)); - $object->note_public .= dol_concatdesc($object->note_public, '
'); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref)); + $object->note_public = dol_concatdesc($object->note_public, '
'); } 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)); - $object->note_public .= dol_concatdesc($object->note_public, '
'); + $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)); + $object->note_public = dol_concatdesc($object->note_public, '
'); } } } elseif (count($objects) == 1) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 7ffbe0328c1..af99bdce7db 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2140,6 +2140,8 @@ EmailTemplate=Template for email EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax PDF_SHOW_PROJECT=Show project on document ShowProjectLabel=Project Label +PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME = Include alias in thirdparty name +PDF_INVERT_ALIAS_NAME_THIRDPARTY = Invet name and alias PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF. PDF_USE_A=Gererate PDF documents with format PDF/A instead of defaut format PDF FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book. From fea897f3230da4e176f4880f30a66fa7ed1227e5 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Wed, 26 Jan 2022 18:46:51 +0100 Subject: [PATCH 06/11] Fix lang and erreur --- htdocs/admin/pdf.php | 15 ++++++++------- htdocs/core/lib/pdf.lib.php | 6 ++---- htdocs/langs/en_US/admin.lang | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index bf9ac2402be..93c72643d10 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -548,13 +548,14 @@ if ($conf->use_javascript_ajax) { } // Invert alias and name thirdparty - -print ''.$langs->trans("PDF_INVERT_ALIAS_NAME_THIRDPARTY").''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('PDF_INVERT_ALIAS_NAME_THIRDPARTY'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("PDF_INVERT_ALIAS_NAME_THIRDPARTY", $arrval, $conf->global->PDF_INVERT_ALIAS_NAME_THIRDPARTY); +if (!empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) { + print ''.$langs->trans("PDF_INVERT_ALIAS_NAME_THIRDPARTY").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PDF_INVERT_ALIAS_NAME_THIRDPARTY'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("PDF_INVERT_ALIAS_NAME_THIRDPARTY", $arrval, $conf->global->PDF_INVERT_ALIAS_NAME_THIRDPARTY); + } } // Show online payment link on invoices diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 29cddef9b3e..faf00fe1e75 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -395,10 +395,8 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali if (($includealias || !empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { $socname .= " - ".$thirdparty->name_alias; if ($conf->global->PDF_INVERT_ALIAS_NAME_THIRDPARTY) { - $socname = $thirdparty->name_alias." - ".$socname; - if ($conf->global->PDF_INVERT_ALIAS_NAME_THIRDPARTY) { - $socname = $thirdparty->name_alias." - ".$socname; - } + $socname = ''; + $socname = $thirdparty->name_alias." - ".$thirdparty->name; } } } elseif ($thirdparty instanceof Contact) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index af99bdce7db..b5814a96ab9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2141,7 +2141,7 @@ EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax PDF_SHOW_PROJECT=Show project on document ShowProjectLabel=Project Label PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME = Include alias in thirdparty name -PDF_INVERT_ALIAS_NAME_THIRDPARTY = Invet name and alias +PDF_INVERT_ALIAS_NAME_THIRDPARTY = Invert name and alias PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF. PDF_USE_A=Gererate PDF documents with format PDF/A instead of defaut format PDF FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book. From a85f27248ee6839a58d02f4214bce975188977b9 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Fri, 4 Feb 2022 09:28:01 +0100 Subject: [PATCH 07/11] Update pdf.php --- htdocs/admin/pdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 4883d8ce464..64c93e1101b 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -570,7 +570,7 @@ print ''; print ''.$langs->trans("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME").''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME'); + print ajax_constantonoff('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME', array(), null, 0, 0, 1); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", $arrval, $conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME); From 0e1e65e180dc72b07d64500d1cecf9c62a1dc7c6 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Fri, 4 Feb 2022 17:29:13 +0100 Subject: [PATCH 08/11] only one option --- htdocs/admin/pdf.php | 17 ++--------------- htdocs/core/lib/pdf.lib.php | 4 ++-- htdocs/langs/en_US/admin.lang | 3 +-- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index af20bb042f8..b6bf362d8d7 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -574,25 +574,12 @@ print ''; // Show alias in thirdparty name -print ''.$langs->trans("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME").''; +print ''.$langs->trans("PDF_THIRDPARTY_NAME_TO_SHOW_IS").''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME', array(), null, 0, 0, 1); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + $arrval = array('0' => '', '1' => $langs->trans("THIRDPARTY_ALIAS"), '2' => $langs->trans("ALIAS_THIRDPARTY")); print $form->selectarray("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", $arrval, $conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME); } -// Invert alias and name thirdparty -if (!empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) { - print ''.$langs->trans("PDF_INVERT_ALIAS_NAME_THIRDPARTY").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('PDF_INVERT_ALIAS_NAME_THIRDPARTY'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("PDF_INVERT_ALIAS_NAME_THIRDPARTY", $arrval, $conf->global->PDF_INVERT_ALIAS_NAME_THIRDPARTY); - } -} - // Show online payment link on invoices print ''.$langs->trans("PDF_SHOW_LINK_TO_ONLINE_PAYMENT").''; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d7764bb4a8c..bdc2b7814b1 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -392,9 +392,9 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali if ($thirdparty instanceof Societe) { $socname .= $thirdparty->name; - if (($includealias || !empty($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME)) && !empty($thirdparty->name_alias)) { + if (($includealias || $conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME) == 1 && !empty($thirdparty->name_alias)) { $socname .= " - ".$thirdparty->name_alias; - if ($conf->global->PDF_INVERT_ALIAS_NAME_THIRDPARTY) { + if ($conf->global->PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME == 2) { $socname = ''; $socname = $thirdparty->name_alias." - ".$thirdparty->name; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index cda7727a04c..4478b3fb146 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2144,8 +2144,7 @@ EmailTemplate=Template for email EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax PDF_SHOW_PROJECT=Show project on document ShowProjectLabel=Project Label -PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME = Include alias in thirdparty name -PDF_INVERT_ALIAS_NAME_THIRDPARTY = Invert name and alias +PDF_THIRDPARTY_NAME_TO_SHOW_IS = Include alias in thirdparty name PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF. PDF_USE_A=Gererate PDF documents with format PDF/A instead of defaut format PDF FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book. From dd181edde990ddb0a5d23cdbf837ceff7e5e4599 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Fri, 4 Feb 2022 17:37:24 +0100 Subject: [PATCH 09/11] Lang --- htdocs/langs/en_US/admin.lang | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4478b3fb146..3659bc8a2cb 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2144,7 +2144,9 @@ EmailTemplate=Template for email EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax PDF_SHOW_PROJECT=Show project on document ShowProjectLabel=Project Label -PDF_THIRDPARTY_NAME_TO_SHOW_IS = Include alias in thirdparty name +PDF_THIRDPARTY_NAME_TO_SHOW_IS=Include alias in thirdparty name +THIRDPARTY_ALIAS=Name thirdparty - Alias thirdparty +ALIAS_THIRDPARTY=Alias thirdparty - Name thirdparty PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF. PDF_USE_A=Gererate PDF documents with format PDF/A instead of defaut format PDF FafaIconSocialNetworksDesc=Enter here the code of a FontAwesome icon. If you don't know what is FontAwesome, you can use the generic value fa-address-book. From 8e75b7102bfd1ab35f51f2c8d28e1a1f0946765b Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Tue, 10 May 2022 15:40:45 +0200 Subject: [PATCH 10/11] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index bdc2b7814b1..bcf0ef34c13 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -12,7 +12,7 @@ * Copyright (C) 2015-2016 Marcos GarcĂ­a * Copyright (C) 2019 Lenin Rivas * Copyright (C) 2020 Nicolas ZABOURI - * Copyright (C) 2021 Anthony Berton + * Copyright (C) 2021-2022 Anthony Berton * * 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 From 273f1196310a3f8e434c5d0ac78349b79e769100 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Tue, 10 May 2022 16:14:37 +0200 Subject: [PATCH 11/11] Update pdf.php --- htdocs/admin/pdf.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index b6bf362d8d7..8d1c4b68adb 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2012-2107 Juanjo Menent * Copyright (C) 2019 Ferran Marcet - * Copyright (C) 2021 Anthony Berton + * Copyright (C) 2021-2022 Anthony Berton * * 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 @@ -170,10 +170,6 @@ if ($action == 'update') { dolibarr_set_const($db, "PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", GETPOST('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME', 'alpha'), 'chaine', 0, '', $conf->entity); } - if (GETPOSTISSET('PDF_INVERT_ALIAS_NAME_THIRDPARTY')) { - dolibarr_set_const($db, "PDF_INVERT_ALIAS_NAME_THIRDPARTY", GETPOST('PDF_INVERT_ALIAS_NAME_THIRDPARTY', 'alpha'), 'chaine', 0, '', $conf->entity); - } - if (GETPOSTISSET('PDF_USE_A')) { dolibarr_set_const($db, "PDF_USE_A", GETPOST('PDF_USE_A', 'alpha'), 'chaine', 0, '', $conf->entity); }