diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 6c28081e6fc..cd84dbf65a5 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -238,6 +238,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'); + } + } + + +} /* @@ -465,6 +491,8 @@ print "\n"; clearstatcache(); +$activatedModels = array(); + foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -580,6 +608,47 @@ foreach ($dirmodels as $reldir) } print ''; +if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf +{ + /* + * Document templates generators + */ + print '
'; + print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"),'',''); + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $listtype=array( + Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), + Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), + Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), + Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + ); + if (! empty($conf->global->INVOICE_USE_SITUATION)) + { + $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); + } + + foreach ($listtype as $type => $trans) + { + $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; + $current = !empty($conf->global->{$thisTypeConfName})?$conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; + print ''; + print ''; + print ''; + print "\n"; + } + + print '
'.$langs->trans("Type").''.$langs->trans("Name").'
'.$trans.''.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current,0,0, 0).'
'; + print "
"; +} /* * Modes de reglement @@ -662,6 +731,7 @@ if ($resql) $i = 0; while ($i < $num) { + $row = $db->fetch_row($resql); print '