Skip to content

Commit

Permalink
NEW #2763 Go to document block after clicking in Generate document bu…
Browse files Browse the repository at this point in the history
…tton

Close #2763
  • Loading branch information
marcosgdf committed Feb 3, 2017
1 parent 10353d1 commit 2dfced3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 93 deletions.
2 changes: 1 addition & 1 deletion htdocs/comm/propal/card.php
Expand Up @@ -2398,7 +2398,7 @@
if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft">';

print '<a name="builddoc"></a>'; // ancre
/*
* Documents generes
*/
Expand Down
54 changes: 5 additions & 49 deletions htdocs/commande/card.php
Expand Up @@ -1187,54 +1187,10 @@
}
}

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')
{
Expand Down Expand Up @@ -2606,7 +2562,7 @@
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';
Expand Down
3 changes: 3 additions & 0 deletions htdocs/core/actions_builddoc.inc.php
Expand Up @@ -91,6 +91,9 @@
else
{
setEventMessages($langs->trans("FileGenerated"), null);

header('Location: '.$_SERVER['REQUEST_URI'].'#builddoc');
die;
}
}
}
Expand Down
48 changes: 5 additions & 43 deletions htdocs/fichinter/card.php
Expand Up @@ -438,49 +438,6 @@
}
}

/*
* 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)
{
Expand Down Expand Up @@ -797,6 +754,11 @@
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')
Expand Down

0 comments on commit 2dfced3

Please sign in to comment.