NEW Hidden conf INVOICE_USE_DEFAULT_DOCUMENT

This commit is contained in:
John BOTELLA 2018-10-02 15:51:17 +02:00
parent f4384fa76d
commit af66a8971a
2 changed files with 74 additions and 67 deletions

View File

@ -610,47 +610,48 @@ foreach ($dirmodels as $reldir)
} }
print '</table>'; print '</table>';
if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
/* {
/*
* Document templates generators * Document templates generators
*/ */
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"),'',''); print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"),'','');
print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >'; print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
print '<table id="default-pdf-modules-by-type-table" class="noborder" width="100%">'; print '<table id="default-pdf-modules-by-type-table" class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Type").'</td>'; print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Name").'</td>'; print '<td>'.$langs->trans("Name").'</td>';
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n"; print "</tr>\n";
$listtype=array( $listtype=array(
Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
); );
if (! empty($conf->global->INVOICE_USE_SITUATION)) if (! empty($conf->global->INVOICE_USE_SITUATION))
{ {
$listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
} }
foreach ($listtype as $type => $trans) foreach ($listtype as $type => $trans)
{ {
$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
$current = !empty($conf->global->{$thisTypeConfName})?$conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; $current = !empty($conf->global->{$thisTypeConfName})?$conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF;
print '<tr >'; print '<tr >';
print '<td>'.$trans.'</td>'; print '<td>'.$trans.'</td>';
print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current,0,0, 0).'</td>'; print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current,0,0, 0).'</td>';
print "</tr>\n"; print "</tr>\n";
}
print '</table>';
print "</form>";
} }
print '</table>';
print "</form>";
/* /*
* Modes de reglement * Modes de reglement
*/ */

View File

@ -2779,7 +2779,8 @@ if ($action == 'create')
print '</div>'; print '</div>';
if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
{
// Add auto select default document model // Add auto select default document model
$listtType=array(Facture::TYPE_STANDARD,Facture::TYPE_REPLACEMENT,Facture::TYPE_CREDIT_NOTE,Facture::TYPE_DEPOSIT,Facture::TYPE_SITUATION); $listtType=array(Facture::TYPE_STANDARD,Facture::TYPE_REPLACEMENT,Facture::TYPE_CREDIT_NOTE,Facture::TYPE_DEPOSIT,Facture::TYPE_SITUATION);
$jsListType=''; $jsListType='';
@ -2808,7 +2809,7 @@ if ($action == 'create')
}); });
}); });
</script>'; </script>';
}
@ -2902,8 +2903,13 @@ if ($action == 'create')
print '<td colspan="2">'; print '<td colspan="2">';
include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php';
$liste = ModelePDFFactures::liste_modeles($db); $liste = ModelePDFFactures::liste_modeles($db);
if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)){ // Hidden conf
$paramkey='FACTURE_ADDON_PDF_'.$object->type; $paramkey='FACTURE_ADDON_PDF_'.$object->type;
$curent = !empty($conf->global->$paramkey)?$conf->global->$paramkey:$conf->global->FACTURE_ADDON_PDF; $curent = !empty($conf->global->$paramkey)?$conf->global->$paramkey:$conf->global->FACTURE_ADDON_PDF;
}
else{
$curent = $conf->global->FACTURE_ADDON_PDF;
}
print $form->selectarray('model', $liste, $curent); print $form->selectarray('model', $liste, $curent);
print "</td></tr>"; print "</td></tr>";