diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 1e015d69f9c..c8567af3c9e 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 @@ -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); + } + if (GETPOSTISSET('PDF_USE_A')) { dolibarr_set_const($db, "PDF_USE_A", GETPOST('PDF_USE_A', 'alpha'), 'chaine', 0, '', $conf->entity); } @@ -564,6 +568,14 @@ 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_THIRDPARTY_NAME_TO_SHOW_IS").''; +if ($conf->use_javascript_ajax) { + $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); +} + // 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 4583ca6b7d0..36f04836a64 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -392,8 +392,12 @@ 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_INCLUDE_ALIAS_IN_THIRDPARTY_NAME == 2) { + $socname = ''; + $socname = $thirdparty->name_alias." - ".$thirdparty->name; + } } } elseif ($thirdparty instanceof Contact) { $socname = $thirdparty->socname; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 8382914bd8c..c4cdb5d6d04 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2168,6 +2168,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 +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.