Merge pull request #22689 from bb2a/NEW---Compléte-function-pdfBuildThirdpartyName-to-use-company-name-of-contact

NEW Make option PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME visible
This commit is contained in:
Laurent Destailleur 2022-11-25 16:49:35 +01:00 committed by GitHub
commit b04d4dd867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 15 deletions

View File

@ -174,7 +174,6 @@ if ($action == 'update') {
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);
}
@ -400,6 +399,13 @@ if ($conf->use_javascript_ajax) {
}
print '</td></tr>';
// Show alias in thirdparty name
print '<tr class="oddeven"><td>'.$langs->trans("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME").'</td><td>';
if ($conf->use_javascript_ajax) {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("THIRDPARTY_ALIAS"), '2' => $langs->trans("ALIAS_THIRDPARTY"));
print $form->selectarray("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", $arrval, getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME'));
}
print '</table>';
print '</div>';
@ -584,16 +590,6 @@ if ($conf->use_javascript_ajax) {
print $form->selectarray("DOC_SHOW_FIRST_SALES_REP", $arrval, $conf->global->DOC_SHOW_FIRST_SALES_REP);
}
// Show alias in thirdparty name
/* Disabled because not yet completely implemented (does not work when we force a contact on object)
print '<tr class="oddeven"><td>'.$langs->trans("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME").'</td><td>';
if ($conf->use_javascript_ajax) {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("THIRDPARTY_ALIAS"), '2' => $langs->trans("ALIAS_THIRDPARTY"));
print $form->selectarray("PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", $arrval, getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME'));
}
*/
// Show online payment link on invoices
print '<tr class="oddeven"><td>'.$langs->trans("PDF_SHOW_LINK_TO_ONLINE_PAYMENT").'</td><td>';

View File

@ -12,7 +12,7 @@
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2019 Lenin Rivas <lenin.rivas@servcom-it.com>
* Copyright (C) 2020 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2021-2022 Anthony Berton <bertonanthony@gmail.com>
* Copyright (C) 2021-2022 Anthony Berton <anthony.berton@bb2a.fr>
*
* 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
@ -400,9 +400,16 @@ function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includeali
}
}
} elseif ($thirdparty instanceof Contact) {
$socname = $thirdparty->socname;
if (($includealias || getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->name_alias)) {
// TODO PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME not completely implemented
if ($thirdparty->socid > 0) {
$thirdparty->fetch_thirdparty();
$socname = $thirdparty->thirdparty->name;
if (($includealias || getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) && !empty($thirdparty->thirdparty->name_alias)) {
if (getDolGlobalInt('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME') == 2) {
$socname = $thirdparty->thirdparty->name_alias." - ".$thirdparty->thirdparty->name;
} else {
$socname = $thirdparty->thirdparty->name." - ".$thirdparty->thirdparty->name_alias;
}
}
}
} else {
throw new InvalidArgumentException('Parameter 1 $thirdparty is not a Societe nor Contact');

View File

@ -2189,6 +2189,7 @@ ShowProjectLabel=Libellé du projet
PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME=Inclure un alias dans le nom du tiers
THIRDPARTY_ALIAS=Nom du tiers - Alias du tiers
ALIAS_THIRDPARTY=Alias du tiers - Nom du tiers
MAIN_USE_COMPANY_NAME_OF_CONTACT=Use company name of contact
PDF_USE_ALSO_LANGUAGE_CODE=Si vous souhaitez que certains textes de votre PDF soient dupliqués dans 2 langues différentes dans le même PDF généré, vous devez définir ici cette deuxième langue pour que le PDF généré contienne 2 langues différentes dans la même page, celle choisie lors de la génération du PDF et celle-ci (seuls quelques modèles PDF prennent en charge cette fonction). Gardez vide pour 1 langue par PDF.
PDF_USE_A=Générer document PDF avec le format PDF/A à la place du format PDF standard
FafaIconSocialNetworksDesc=Entrez ici le code d'une icône FontAwesome. Si vous ne savez pas ce qu'est FontAwesome, vous pouvez utiliser la valeur générique fa-address-book.