diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index 1f574175898..ae3b0a66ed5 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -240,6 +240,32 @@ if ($action == 'setforcedate')
}
}
+if ($action == 'setDefaultPDFModulesByType')
+{
+ $invoicetypemodels = GETPOST('invoicetypemodels');
+
+ if(!empty($invoicetypemodels) && is_array($invoicetypemodels))
+ {
+ $error = 0;
+
+ foreach ($invoicetypemodels as $type => $value)
+ {
+ $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type) ,$value,'chaine',0,'',$conf->entity);
+ if (! $res > 0) $error++;
+ }
+
+ if (! $error)
+ {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ }
+ else
+ {
+ setEventMessages($langs->trans("Error"), null, 'errors');
+ }
+ }
+
+
+}
/*
@@ -469,7 +495,7 @@ print '
'.$langs->trans("Preview").' | ';
print "\n";
clearstatcache();
-
+$activatedModels = array();
$var=true;
foreach ($dirmodels as $reldir)
{
@@ -588,6 +614,48 @@ foreach ($dirmodels as $reldir)
print '';
+
+
+/*
+ * Document templates generators
+ */
+print '
';
+print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"),'','');
+print '";
+
+
/*
* Modes de reglement
*/
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 19612349214..277a3bc9697 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -2505,7 +2505,8 @@ if ($action == 'create')
// Standard invoice
print '';
$tmp=' ';
- $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3);
+ $tmp = $tmp.'';
+ $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3);
print $desc;
print '
';
@@ -2524,7 +2525,8 @@ if ($action == 'create')
});
';
- $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3);
+ $tmp = $tmp.'';
+ $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3);
print '| ';
print $desc;
print ' | ';
@@ -2548,8 +2550,9 @@ if ($action == 'create')
{
// First situation invoice
print '';
- $tmp=' ';
- $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceFirstSituationAsk"), $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3);
+ $tmp=' ';
+ $tmp = $tmp.'';
+ $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3);
print $desc;
print '
';
@@ -2559,7 +2562,7 @@ if ($action == 'create')
$tmp='' . $langs->trans('NoSituations') . '') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande')) $tmp.=' disabled';
$tmp.= '> ';
- $text = $tmp.$langs->trans("InvoiceSituationAsk") . ' ';
+ $text = ' ';
$text .= '';
@@ -2583,7 +2586,7 @@ if ($action == 'create')
});
});
';
- $text = $tmp.$langs->trans("InvoiceReplacementAsk") . ' ';
+ $text = '';
$text .= '
';
if ($socid > 0)
@@ -2782,7 +2820,8 @@ if ($action == 'create')
print '';
include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php';
$liste = ModelePDFFactures::liste_modeles($db);
- print $form->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF);
+ $curent = !empty($conf->global->{'FACTURE_ADDON_PDF_'.$object->type})?$conf->global->{'FACTURE_ADDON_PDF_'.$object->type}:$conf->global->FACTURE_ADDON_PDF;
+ print $form->selectarray('model', $liste, $curent);
print " | ";
// Multicurrency
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 7edc3b65b41..91e05827032 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -4023,13 +4023,16 @@ class Facture extends CommonInvoice
if (! dol_strlen($modele)) {
- $modele = 'crabe';
-
- if ($this->modelpdf) {
- $modele = $this->modelpdf;
- } elseif (! empty($conf->global->FACTURE_ADDON_PDF)) {
- $modele = $conf->global->FACTURE_ADDON_PDF;
- }
+ $modele = 'crabe';
+ $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
+
+ if ($this->modelpdf) {
+ $modele = $this->modelpdf;
+ }elseif (! empty($conf->global->{'FACTURE_ADDON_PDF_'.$this->type})){
+ $modele = $conf->global->{'FACTURE_ADDON_PDF_'.$this->type} ;
+ }elseif (! empty($conf->global->FACTURE_ADDON_PDF)) {
+ $modele = $conf->global->FACTURE_ADDON_PDF;
+ }
}
$modelpath = "core/modules/facture/doc/";
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 91a503ba6a6..005b77bd5c2 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1204,6 +1204,7 @@ WebCalUrlForVCalExport=An export link to %s format is available at follow
BillsSetup=Invoices module setup
BillsNumberingModule=Invoices and credit notes numbering model
BillsPDFModules=Invoice documents models
+BillsPDFModulesAccordindToInvoiceType=Invoice documents models according to invoice type
PaymentsPDFModules=Payment documents models
CreditNote=Credit note
CreditNotes=Credit notes