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 if (empty($hidedetails)) {
87 if (empty($hidedesc)) {
90 if (empty($hideref)) {
93 if (empty($moreparams)) {
97 $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
102 if (empty($donotredirect)) {
117if ($action ==
'remove_file' && $permissiontoadd) {
118 if (!empty($upload_dir)) {
119 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
121 if (empty($object->id) || !$object->id > 0) {
123 $ret = $object->fetch($id);
124 $ret = $object->fetch_thirdparty();
127 $langs->load(
"other");
128 $filetodelete =
GETPOST(
'file',
'alpha');
129 $file = $upload_dir.
'/'.$filetodelete;
130 $dirthumb = dirname($file).
'/thumbs/';
135 if (preg_match(
'/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) {
136 $photo_vignette = basename(preg_replace(
'/'.$regs[0].
'/i',
'', $file).
'_small'.$regs[0]);
137 if (file_exists(
dol_osencode($dirthumb.$photo_vignette))) {
141 $photo_vignette = basename(preg_replace(
'/'.$regs[0].
'/i',
'', $file).
'_mini'.$regs[0]);
142 if (file_exists(
dol_osencode($dirthumb.$photo_vignette))) {
147 setEventMessages($langs->trans(
"FileWasRemoved", $filetodelete),
null,
'mesgs');
149 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", $filetodelete),
null,
'errors');
153 $urltoredirect = $_SERVER[
'REQUEST_URI'];
154 $urltoredirect = preg_replace(
'/#builddoc$/',
'', $urltoredirect);
155 $urltoredirect = preg_replace(
'/action=remove_file&?/',
'', $urltoredirect);
157 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 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.