Start to mutualize the builddoc and remove_file action.

This commit is contained in:
Laurent Destailleur 2015-09-06 14:21:42 +02:00
parent 77ef046af4
commit 0d811dce6a

View File

@ -1053,49 +1053,6 @@ if (empty($reshook))
exit();
}
// Generation doc (depuis lien ou depuis cartouche doc)
else if ($action == 'builddoc' && $user->rights->propal->creer) {
if (GETPOST('model')) {
$object->setDocModel($user, GETPOST('model'));
}
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;
if (! empty($conf->global->MAIN_MULTILANGS)) {
$outputlangs = new Translate("", $conf);
$newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang);
$outputlangs->setDefaultLang($newlang);
}
$ret = $object->fetch($id); // Reload to get new records
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$action='';
}
}
// Remove file in doc form
else if ($action == 'remove_file' && $user->rights->propal->creer) {
if ($object->id > 0) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$langs->load("other");
$upload_dir = $conf->propal->dir_output;
$file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret)
setEventMessage($langs->trans("FileWasRemoved", GETPOST('file')));
else
setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors');
}
}
// Set project
else if ($action == 'classin' && $user->rights->propal->creer) {
$object->setProject($_POST['projectid']);
@ -1211,6 +1168,12 @@ if (empty($reshook))
}
}
}
// Actions to build doc
$upload_dir = $conf->propal->dir_output;
$permissioncreate=$user->rights->propal->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
}