NEW #2763 Go to document block after clicking in Generate document button
Close #2763
This commit is contained in:
parent
10353d1e1a
commit
2dfced366e
@ -2398,7 +2398,7 @@ if ($action == 'create')
|
|||||||
if ($action != 'presend')
|
if ($action != 'presend')
|
||||||
{
|
{
|
||||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||||
|
print '<a name="builddoc"></a>'; // ancre
|
||||||
/*
|
/*
|
||||||
* Documents generes
|
* Documents generes
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1187,54 +1187,10 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'builddoc') // In get or post
|
// Actions to build doc
|
||||||
{
|
$upload_dir = $conf->commande->dir_output;
|
||||||
// Save last template used to generate document
|
$permissioncreate = $user->rights->commande->creer;
|
||||||
if (GETPOST('model'))
|
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||||
$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 = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'update_extras')
|
if ($action == 'update_extras')
|
||||||
{
|
{
|
||||||
@ -2606,7 +2562,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
if ($action != 'presend')
|
if ($action != 'presend')
|
||||||
{
|
{
|
||||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||||
|
print '<a name="builddoc"></a>'; // ancre
|
||||||
// Documents
|
// Documents
|
||||||
$comref = dol_sanitizeFileName($object->ref);
|
$comref = dol_sanitizeFileName($object->ref);
|
||||||
$file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf';
|
$file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf';
|
||||||
|
|||||||
@ -91,6 +91,9 @@ if ($action == 'builddoc' && $permissioncreate)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("FileGenerated"), null);
|
setEventMessages($langs->trans("FileGenerated"), null);
|
||||||
|
|
||||||
|
header('Location: '.$_SERVER['REQUEST_URI'].'#builddoc');
|
||||||
|
die;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
// Set into a project
|
||||||
else if ($action == 'classin' && $user->rights->ficheinter->creer)
|
else if ($action == 'classin' && $user->rights->ficheinter->creer)
|
||||||
{
|
{
|
||||||
@ -797,6 +754,11 @@ if (empty($reshook))
|
|||||||
if ($error) $action = 'edit_extras';
|
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 (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer)
|
||||||
{
|
{
|
||||||
if ($action == 'addcontact')
|
if ($action == 'addcontact')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user