diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 27d03465d98..98843eddc1b 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -277,8 +277,8 @@ class FormFile if (is_array($genallowed)) $modellist=$genallowed; else { - include_once(DOL_DOCUMENT_ROOT.'/fourn/facture/modules/modules_facturefournisseur.php'); - $model=new ModelePDFFacturesSuppliers(); + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_invoice/modules_facturefournisseur.php'); + $model=new ModelePDFSuppliersInvoices(); $modellist=$model->liste_modeles($this->db); } } diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index e33bd3a081d..294d1fdc632 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -31,6 +31,7 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_invoice/modules_facturefournisseur.php'); require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'); require_once(DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php'); @@ -463,7 +464,57 @@ if ($_GET['action'] == 'reopen' && $user->rights->fournisseur->facture->creer) } } +/* + * Build document + */ +if ($_REQUEST['action'] == 'builddoc') +{ + /* + * Generation de la facture + * definit dans /includes/modules/supplier_invoice/modules_facturefournisseur.php + */ + + // Sauvegarde le dernier module choisi pour generer un document + $facture= new FactureFournisseur($db); + $facture->fetch($_REQUEST['facid']); + if ($_REQUEST['model']) + { + $facture->setDocModel($user, $_REQUEST['model']); + } + + $outputlangs = $langs; + if (! empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + $result=supplier_invoice_pdf_create($db, $facture,$facture->modelpdf,$outputlangs); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + else + { + Header ('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facture->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + exit; + } +} + +// Delete file in doc form +if ($action=='remove_file') +{ + $facture = new FactureFournisseur($db); + + if ($facture->fetch($id)) + { + $upload_dir = $conf->fournisseur->facture->dir_output . "/"; + $file = $upload_dir . '/' . $_GET['file']; + dol_delete_file($file); + $mesg = '