diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 4d3380d1b1f..c50df1c51ec 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -147,7 +147,7 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs");
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
- facture_pdf_create($db, $fac->id, '', $_REQUEST['model'], $outputlangs);
+ facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs);
}
}
@@ -185,6 +185,7 @@ if ($_POST['action'] == 'add')
$facture->note_public = $_POST['note_public'];
$facture->note = $_POST['note'];
$facture->ref_client = $_POST['ref_client'];
+ $facture->modelpdf = $_POST['modelpdf'];
if ($_POST['fac_rec'] > 0)
{
@@ -896,6 +897,15 @@ if ($_GET['action'] == 'create')
$html->select_projects($societe_id, $projetid, 'projetid');
print '';
}
+
+ print '
| '.$langs->trans("Model").' | ';
+ print '';
+ // pdf
+ include_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php');
+ $model=new ModelePDFFactures();
+ $liste=$model->liste_modeles($db);
+ $html->select_array("modelpdf",$liste,$conf->global->FACTURE_ADDON_PDF);
+ print " |
";
// Note publique
print '';
@@ -2135,8 +2145,8 @@ else
$filename=sanitize_string($fac->ref);
$filedir=$conf->facture->dir_output . '/' . sanitize_string($fac->ref);
$urlsource=$_SERVER['PHP_SELF'].'?facid='.$fac->id;
- $genallowed=($fac->statut == 1 && $user->rights->facture->creer);
- $delallowed=$user->rights->facture->supprimer;
+ $genallowed=($fac->statut == 1 && $user->rights->facture->creer);
+ $delallowed=$user->rights->facture->supprimer;
$var=true;
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 19d2776f607..7814b3e4293 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -70,6 +70,7 @@ class Facture extends CommonObject
var $cond_reglement_code;
var $mode_reglement_id;
var $mode_reglement_code;
+ var $modelpdf;
// Pour board
var $nbtodo;
@@ -165,7 +166,7 @@ class Facture extends CommonObject
$sql.= ' note_public,';
$sql.= ' ref_client,';
$sql.= ' fk_user_author, fk_projet,';
- $sql.= ' fk_cond_reglement, fk_mode_reglement, date_lim_reglement) ';
+ $sql.= ' fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf) ';
$sql.= " VALUES (";
$sql.= "'$number','$socid', now(), '$totalht', '".$this->remise_absolue."'";
$sql.= ",'".$this->remise_percent."', ".$this->db->idate($this->date);
@@ -176,7 +177,7 @@ class Facture extends CommonObject
$sql.= ",".($this->projetid?$this->projetid:"null");
$sql.= ','.$this->cond_reglement_id;
$sql.= ",".$this->mode_reglement_id;
- $sql.= ','.$this->db->idate($datelim).")";
+ $sql.= ",".$this->db->idate($datelim).", '".$this->modelpdf."')";
$resql=$this->db->query($sql);
if ($resql)