From 6dbb3efc894f0738a351e28627a4b5bb156752f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 16 Jan 2017 20:24:26 +0100 Subject: [PATCH] NEW #6280: Generate PDF after creating an invoice from a customer order Close #6280 --- htdocs/compta/facture.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 91267578197..36dce43f5f3 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1291,6 +1291,25 @@ if (empty($reshook)) if ($id > 0 && ! $error) { $db->commit(); + + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($object->lines)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + } + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); exit(); }