From 8ce687ecd46b8a9c7861f111de8f8571da616cf8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 2 Jun 2006 16:47:59 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20la=20s=E9lection=20du=20mod=E8le=20pdf?= =?UTF-8?q?=20n'=E9tait=20pas=20enregistr=E9=20dans=20la=20facture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/facture.php | 2 ++ htdocs/facture.class.php | 26 ++++++++++++++++++++++++++ mysql/migration/2.0.0-2.1.0.sql | 5 ++++- mysql/tables/llx_facture.sql | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c4600d54acd..48a9f98dd70 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -622,6 +622,8 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post { $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); $outputlangs->setDefaultLang($_REQUEST['lang_id']); + $facture = new Facture($db, 0, $_GET['facid']); + $facture->set_pdf_model($user, $_POST['model']); $result=facture_pdf_create($db, $_REQUEST['facid'], '', $_REQUEST['model'], $outputlangs); if ($result <= 0) { diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 9ae21d4c22b..87693608a49 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -893,6 +893,32 @@ class Facture } } } + + /* + * + * + * + */ + + function set_pdf_model($user, $modelpdf) + { + if ($user->rights->facture->creer) + { + + $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET model_pdf = '$modelpdf'"; + $sql .= " WHERE rowid = $this->id AND fk_statut < 2 ;"; + + if ($this->db->query($sql) ) + { + return 1; + } + else + { + dolibarr_print_error($this->db); + return 0; + } + } + } /** * \brief Ajoute un produit dans l'objet facture diff --git a/mysql/migration/2.0.0-2.1.0.sql b/mysql/migration/2.0.0-2.1.0.sql index 22817b89b5f..af7d08ac75f 100644 --- a/mysql/migration/2.0.0-2.1.0.sql +++ b/mysql/migration/2.0.0-2.1.0.sql @@ -268,4 +268,7 @@ insert into llx_rights_def (id, libelle, module, type, bydefault, subperms, perm insert into llx_user_rights(fk_user,fk_id) select distinct fk_user, '262' from llx_user_rights where fk_id = 261; alter table llx_commandedet add column rang integer DEFAULT 0; -alter table llx_propaldet add column rang integer DEFAULT 0; \ No newline at end of file +alter table llx_propaldet add column rang integer DEFAULT 0; + +alter table llx_facture drop column model; +alter table llx_facture add column model_pdf varchar(50) after note_public; \ No newline at end of file diff --git a/mysql/tables/llx_facture.sql b/mysql/tables/llx_facture.sql index 01094dbc649..30a3a58262a 100644 --- a/mysql/tables/llx_facture.sql +++ b/mysql/tables/llx_facture.sql @@ -52,5 +52,5 @@ create table llx_facture note text, note_public text, - model varchar(50) + model_pdf varchar(50) )type=innodb;