32if (!empty($permissioncreate) && empty($permissiontoadd)) {
33 $permissiontoadd = $permissioncreate;
37if ($action ==
'builddoc' && ($permissiontoadd || !empty($usercangeneretedoc))) {
38 if (is_numeric(
GETPOST(
'model',
'alpha'))) {
39 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Model")),
null,
'errors');
43 $ret =
$object->fetch_thirdparty();
51 if (
GETPOST(
'model',
'alpha')) {
61 } elseif (!empty(
$object->fk_account)) {
66 $outputlangs = $langs;
70 $newlang =
GETPOST(
'lang_id',
'aZ09');
73 $newlang =
$object->thirdparty->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';
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);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.