diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index f489c5ec992..6497c93b734 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -231,8 +231,8 @@ class Commande { $this->projetid = 0; } - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande (fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client) '; - $sql .= ' VALUES ('.$this->soc_id.', now(), '.$user->id.', '.$this->projetid.', '.$this->db->idate($this->date_commande).', '.$this->source.', \''.$this->note.'\', \''.$this->ref_client.'\')'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande (fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client, model_pdf) '; + $sql .= ' VALUES ('.$this->soc_id.', now(), '.$user->id.', '.$this->projetid.', '.$this->db->idate($this->date_commande).', '.$this->source.', \''.$this->note.'\', \''.$this->ref_client.'\', \''.$this->modelpdf.'\')'; if ( $this->db->query($sql) ) { @@ -446,7 +446,7 @@ class Commande function fetch($id) { $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva'; - $sql .= ', '.$this->db->pdate('c.date_commande').' as date_commande, c.fk_projet, c.remise_percent, c.source, c.facture, c.note, c.ref_client'; + $sql .= ', '.$this->db->pdate('c.date_commande').' as date_commande, c.fk_projet, c.remise_percent, c.source, c.facture, c.note, c.ref_client, c.model_pdf'; $sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c'; $sql .= ' WHERE c.rowid = '.$id; @@ -469,6 +469,7 @@ class Commande $this->facturee = $obj->facture; $this->note = $obj->note; $this->projet_id = $obj->fk_projet; + $this->modelpdf = $obj->model_pdf; $this->db->free(); if ($this->statut == 0) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 6ef273d06c4..047add991f6 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -86,6 +86,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer) $commande->projetid = $_POST['projetid']; $commande->remise_percent = $_POST['remise_percent']; $commande->ref_client = $_POST['ref_client']; + $commande->modelpdf = $_POST['model']; $commande->add_product($_POST['idprod1'],$_POST['qty1'],$_POST['remise_percent1']); $commande->add_product($_POST['idprod2'],$_POST['qty2'],$_POST['remise_percent2']); @@ -222,13 +223,20 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes') } } -if ($_GET['action'] == 'builddoc' || $_POST['action'] == 'builddoc') +if ($_POST['action'] == 'builddoc') { /* * Generation de la commande * définit dans /includes/modules/commande/modules_commande.php */ commande_pdf_create($db, $_GET['id'],$_POST['model']); + +} +if($_GET['action'] == 'builddoc') +{ + $commande = new Commande($db); + $commande->fetch($_GET['id']); + commande_pdf_create($db, $_GET['id'],$commande->modelpdf); } @@ -312,7 +320,16 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) print ''.$langs->trans('Source').''; $html->select_array('source_id',$new_commande->sources,2); print ''; - + print 'Modèle'; + print ''; + // pdf + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/commande/modules_commande.php'); + $form=new Form($db); + $model=new ModelePDFCommandes(); + $liste=$model->liste_modeles($db); + $form->select_array("model",$liste,$conf->global->COMMANDE_ADDON_PDF); + print ""; + if ($propalid > 0) { $amount = ($obj->price); @@ -579,8 +596,10 @@ else { print nl2br($commande->note); } + print ''; print ''; + // Société print ''.$langs->trans('Customer').''; @@ -939,7 +958,8 @@ else print '
'; } */ - $html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed); + //$html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf); + $html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); /* * Liste des factures */