NEW #2763 Go to document block after clicking in Generate document button

Close #2763
This commit is contained in:
Marcos García de La Fuente
2017-02-03 20:11:06 +01:00
parent 10353d1e1a
commit 2dfced366e
4 changed files with 14 additions and 93 deletions

View File

@@ -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 '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
// Documents
$comref = dol_sanitizeFileName($object->ref);
$file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf';