32 if (!empty($permissioncreate) && empty($permissiontoadd)) {
33 $permissiontoadd = $permissioncreate;
37 if ($action ==
'builddoc' && $permissiontoadd) {
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;
69 if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
70 $newlang =
GETPOST(
'lang_id',
'aZ09');
72 if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && isset($object->thirdparty->default_lang)) {
73 $newlang = $object->thirdparty->default_lang;
75 if (!empty($conf->global->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)) {
117 if ($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);