Clean code

This commit is contained in:
Laurent Destailleur 2026-04-26 15:02:11 +02:00
parent dbf41437c0
commit 45a7ade38d
7 changed files with 61 additions and 48 deletions

View file

@ -2560,14 +2560,17 @@ if ($action == 'create') {
print "</td></tr>";
}
// Template to use by default
print '<tr class="field_model">';
print '<td class="titlefieldcreate">' . $langs->trans("DefaultModel") . '</td>';
print '<td class="valuefieldcreate">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
$liste = ModelePDFPropales::liste_modeles($db);
$preselected = getDolGlobalString('PROPALE_ADDON_PDF_ODT_DEFAULT', getDolGlobalString("PROPALE_ADDON_PDF"));
print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print "</td></tr>";
include_once DOL_DOCUMENT_ROOT . '/core/modules/propale/modules_propale.php';
$list = ModelePDFPropales::liste_modeles($db);
if (is_array($list) && count($list) > 0) {
print '<tr class="field_model">';
print '<td class="titlefieldcreate">' . $langs->trans("DefaultModel") . '</td>';
print '<td class="valuefieldcreate">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
$preselected = getDolGlobalString('PROPALE_ADDON_PDF_ODT_DEFAULT', getDolGlobalString("PROPALE_ADDON_PDF"));
print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print "</td></tr>";
}
// Multicurrency
if (isModEnabled("multicurrency")) {

View file

@ -2494,14 +2494,16 @@ if ($action == 'create' && $usercancreate) {
}
// Template to use by default
print '<tr><td>' . $langs->trans('DefaultModel') . '</td>';
print '<td>';
include_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php';
$liste = ModelePDFCommandes::liste_modeles($db);
$preselected = getDolGlobalString('COMMANDE_ADDON_PDF');
print img_picto('', 'pdf', 'class="pictofixedwidth"');
print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print "</td></tr>";
$list = ModelePDFCommandes::liste_modeles($db);
if (is_array($list) && count($list) > 0) {
print '<tr><td>' . $langs->trans('DefaultModel') . '</td>';
print '<td>';
$preselected = getDolGlobalString('COMMANDE_ADDON_PDF');
print img_picto('', 'pdf', 'class="pictofixedwidth"');
print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print "</td></tr>";
}
// Multicurrency
if (isModEnabled("multicurrency")) {

View file

@ -4643,21 +4643,23 @@ if ($action == 'create') {
}
// Template to use by default
print '<tr><td>'.$langs->trans('Model').'</td>';
print '<td colspan="2">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
$liste = ModelePDFFactures::liste_modeles($db);
if (getDolGlobalString('INVOICE_USE_DEFAULT_DOCUMENT')) {
$type = GETPOSTISSET('type') ? GETPOSTINT('type') : $object->type;
// Hidden conf
$paramkey = 'FACTURE_ADDON_PDF_'.$type;
$preselected = getDolGlobalString($paramkey, getDolGlobalString('FACTURE_ADDON_PDF'));
} else {
$preselected = getDolGlobalString('FACTURE_ADDON_PDF');
$list = ModelePDFFactures::liste_modeles($db);
if (is_array($list) && count($list) > 0) {
print '<tr><td>'.$langs->trans('Model').'</td>';
print '<td colspan="2">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
if (getDolGlobalString('INVOICE_USE_DEFAULT_DOCUMENT')) {
$type = GETPOSTISSET('type') ? GETPOSTINT('type') : $object->type;
// Hidden conf
$paramkey = 'FACTURE_ADDON_PDF_'.$type;
$preselected = getDolGlobalString($paramkey, getDolGlobalString('FACTURE_ADDON_PDF'));
} else {
$preselected = getDolGlobalString('FACTURE_ADDON_PDF');
}
print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print "</td></tr>";
}
print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print "</td></tr>";
// Multicurrency
if (isModEnabled('multicurrency')) {

View file

@ -1620,7 +1620,7 @@ if ($action == 'create' && $usercancreate) {
// Document model
include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
$list = ModelePdfExpedition::liste_modeles($db);
if (is_countable($list) && count($list) > 1) {
if (is_array($list) && count($list) > 1) {
print "<tr><td>".$langs->trans("DefaultModel")."</td>";
print '<td colspan="3">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
@ -1831,7 +1831,7 @@ if ($action == 'create' && $usercancreate) {
// Document model
include_once DOL_DOCUMENT_ROOT . '/core/modules/expedition/modules_expedition.php';
$list = ModelePdfExpedition::liste_modeles($db);
if (is_countable($list) && count($list) > 1) {
if (is_array($list) && count($list) > 1) {
print "<tr><td>" . $langs->trans("DefaultModel") . "</td>";
print '<td colspan="3">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');

View file

@ -1096,12 +1096,14 @@ if ($action == 'create') {
}
// Model
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td>';
$liste = ModelePDFFicheinter::liste_modeles($db);
print $form->selectarray('model', $liste, $conf->global->FICHEINTER_ADDON_PDF);
print "</td></tr>";
if (count($liste) > 0) {
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td>';
print $form->selectarray('model', $liste, getDolGlobalString('FICHEINTER_ADDON_PDF'));
print "</td></tr>";
}
// Public note
print '<tr>';

View file

@ -1296,13 +1296,15 @@ if ($action == 'create' && $permissiontoadd) {
}
// Template to use by default
print '<tr><td>'.$langs->trans('Model').'</td>';
print '<td colspan="2">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php';
$list = ModelePdfReception::liste_modeles($db);
print $form->selectarray('model', $list, getDolGlobalString('RECEPTION_ADDON_PDF'), 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print "</td></tr>";
if (is_countable($list) && count($list) > 0) {
print '<tr><td>'.$langs->trans('Model').'</td>';
print '<td colspan="2">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php';
print $form->selectarray('model', $list, getDolGlobalString('RECEPTION_ADDON_PDF'), 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
print "</td></tr>";
}
// Note Public
$htmltext ='';

View file

@ -1641,14 +1641,16 @@ if ($action == 'create') {
// Model
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td colspan="2">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
$list = ModelePDFSupplierProposal::liste_modeles($db);
$preselected = getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT', getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF'));
print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1);
print "</td></tr>";
if (count($list) > 0) {
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td colspan="2">';
print img_picto('', 'pdf', 'class="pictofixedwidth"');
$preselected = getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT', getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF'));
print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1);
print "</td></tr>";
}
// Project
if (isModEnabled('project')) {