diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 9b416fd1457..8455f7f8920 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2398,7 +2398,7 @@ if ($action == 'create') if ($action != 'presend') { print '
'; - + print ''; // ancre /* * Documents generes */ diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 26d4d4822e2..f7917b13839 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1187,54 +1187,10 @@ if (empty($reshook)) } } - if ($action == 'builddoc') // In get or post - { - // Save last template used to generate document - if (GETPOST('model')) - $object->setDocModel($user, GETPOST('model', 'alpha')); - if (GETPOST('fk_bank')) { // this field may come from an external module - $object->fk_bank = GETPOST('fk_bank'); - } else { - $object->fk_bank = $object->fk_account; - } - - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) - $newlang = $_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } - } - - // Remove file in doc form - if ($action == 'remove_file') - { - if ($object->id > 0) - { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - - $langs->load("other"); - $upload_dir = $conf->commande->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); - else - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); - $action = ''; - } - } + // Actions to build doc + $upload_dir = $conf->commande->dir_output; + $permissioncreate = $user->rights->commande->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if ($action == 'update_extras') { @@ -2606,7 +2562,7 @@ if ($action == 'create' && $user->rights->commande->creer) if ($action != 'presend') { print '
'; - + print ''; // ancre // Documents $comref = dol_sanitizeFileName($object->ref); $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 5984283b996..dc91cbd0404 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -91,6 +91,9 @@ if ($action == 'builddoc' && $permissioncreate) else { setEventMessages($langs->trans("FileGenerated"), null); + + header('Location: '.$_SERVER['REQUEST_URI'].'#builddoc'); + die; } } } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 4ed3ecb7cef..39075022422 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -438,49 +438,6 @@ if (empty($reshook)) } } - /* - * Build doc - */ - else if ($action == 'builddoc' && $user->rights->ficheinter->creer) // En get ou en post - { - $object->fetch_lines(); - - // Save last template used to generate document - if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $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); - } - $result=fichinter_create($db, $object, GETPOST('model','alpha'), $outputlangs); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - } - - // Remove file in doc form - else if ($action == 'remove_file') - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $object->fetch_thirdparty(); - - $langs->load("other"); - $upload_dir = $conf->ficheinter->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } - // Set into a project else if ($action == 'classin' && $user->rights->ficheinter->creer) { @@ -797,6 +754,11 @@ if (empty($reshook)) if ($error) $action = 'edit_extras'; } + // Actions to build doc + $upload_dir = $conf->ficheinter->dir_output; + $upload_dir = $conf->ficheinter->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer) { if ($action == 'addcontact')