32if (!empty($permissioncreate) && empty($permissiontoadd)) {
33 $permissiontoadd = $permissioncreate;
37if ($action ==
'builddoc' && ($permissiontoadd || !empty($usercangeneretedoc))) {
38 if (is_numeric(
GETPOST(
'model',
'alpha'))) {
39 $error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Model"));
42 $ret = $object->fetch($id);
43 $ret = $object->fetch_thirdparty();
51 if (
GETPOST(
'model',
'alpha')) {
52 $object->setDocModel($user,
GETPOST(
'model',
'alpha'));
58 if (
GETPOST(
'fk_bank',
'int')) {
60 $object->fk_bank =
GETPOST(
'fk_bank',
'int');
61 } elseif (!empty($object->fk_account)) {
62 $object->fk_bank = $object->fk_account;
66 $outputlangs = $langs;
70 $newlang =
GETPOST(
'lang_id',
'aZ09');
72 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($object->thirdparty->default_lang)) {
73 $newlang = $object->thirdparty->default_lang;
75 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($object->default_lang)) {
76 $newlang = $object->default_lang;
78 if (!empty($newlang)) {
80 $outputlangs->setDefaultLang($newlang);
84 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
85 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
86 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
87 $moreparams = isset($moreparams) ? $moreparams :
null;
89 $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
94 if (empty($donotredirect)) {
109if ($action ==
'remove_file' && $permissiontoadd) {
110 if (!empty($upload_dir)) {
111 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
113 if (empty($object->id) || !$object->id > 0) {
115 $ret = $object->fetch($id);
116 $ret = $object->fetch_thirdparty();
119 $langs->load(
"other");
120 $filetodelete =
GETPOST(
'file',
'alpha');
121 $file = $upload_dir.
'/'.$filetodelete;
122 $dirthumb = dirname($file).
'/thumbs/';
127 if (preg_match(
'/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) {
128 $photo_vignette = basename(preg_replace(
'/'.$regs[0].
'/i',
'', $file).
'_small'.$regs[0]);
129 if (file_exists(
dol_osencode($dirthumb.$photo_vignette))) {
133 $photo_vignette = basename(preg_replace(
'/'.$regs[0].
'/i',
'', $file).
'_mini'.$regs[0]);
134 if (file_exists(
dol_osencode($dirthumb.$photo_vignette))) {
139 setEventMessages($langs->trans(
"FileWasRemoved", $filetodelete),
null,
'mesgs');
141 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", $filetodelete),
null,
'errors');
145 $urltoredirect = $_SERVER[
'REQUEST_URI'];
146 $urltoredirect = preg_replace(
'/#builddoc$/',
'', $urltoredirect);
147 $urltoredirect = preg_replace(
'/action=remove_file&?/',
'', $urltoredirect);
149 header(
'Location: '.$urltoredirect);
Class to manage translations.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.