53@phan-var-force int $id
54@phan-var-force int $permissiontoadd
55@phan-var-force ?int $hidedetails
56@phan-var-force ?int $hidedesc
57@phan-var-force ?int $hideref
58@phan-var-force ?array<string,mixed> $moreparams
59@phan-var-force CommonObject|Societe $object
60@phan-var-force int $id
63if (!empty($permissioncreate) && empty($permissiontoadd)) {
64 $permissiontoadd = $permissioncreate;
68if ($action ==
'builddoc' && ($permissiontoadd || !empty($usercangeneratedoc))) {
69 if (is_numeric(
GETPOST(
'model',
'alpha'))) {
70 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Model")),
null,
'errors');
74 $ret =
$object->fetch_thirdparty();
77 if (
GETPOST(
'model',
'alpha')) {
86 } elseif (!empty(
$object->fk_account)) {
90 $outputlangs = $langs;
93 $newlang =
GETPOST(
'lang_id',
'aZ09');
96 $newlang =
$object->thirdparty->default_lang;
99 $newlang =
$object->default_lang;
101 if (!empty($newlang)) {
103 $outputlangs->setDefaultLang($newlang);
107 $hidedetails = isset($hidedetails) ? $hidedetails : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
108 $hidedesc = isset($hidedesc) ? $hidedesc : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
109 $hideref = isset($hideref) ? $hideref : (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
110 $moreparams = isset($moreparams) ? $moreparams :
null;
113 if (!is_array($moreparams)) {
114 $moreparams = array();
116 $moreparams[
'addtermsofsale'] = (
GETPOSTINT(
'addtermsofsale') ? 1 : 0);
119 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
123 setEventMessages(
$object->warning,
$object->warnings,
'warnings');
126 if (empty($donotredirect)) {
127 setEventMessages($langs->trans(
"FileGenerated"),
null);
141if ($action ==
'remove_file' && $permissiontoadd) {
142 if (!empty($upload_dir)) {
143 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
148 $ret =
$object->fetch_thirdparty();
151 $langs->load(
"other");
152 $filetodelete =
GETPOST(
'file',
'alpha');
153 $file = $upload_dir.
'/'.$filetodelete;
154 $dirthumb = dirname($file).
'/thumbs/';
159 if (preg_match(
'/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff|\.webp|\.xpm|\.xbm|\.avif)$/i', $file, $regs)) {
160 $photo_vignette = basename(preg_replace(
'/'.$regs[0].
'/i',
'', $file).
'_small'.$regs[0]);
161 if (file_exists(
dol_osencode($dirthumb.$photo_vignette))) {
165 $photo_vignette = basename(preg_replace(
'/'.$regs[0].
'/i',
'', $file).
'_mini'.$regs[0]);
166 if (file_exists(
dol_osencode($dirthumb.$photo_vignette))) {
171 setEventMessages($langs->trans(
"FileWasRemoved", $filetodelete),
null,
'mesgs');
173 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", $filetodelete),
null,
'errors');
177 $urltoredirect = $_SERVER[
'REQUEST_URI'];
178 $urltoredirect = preg_replace(
'/#builddoc$/',
'', $urltoredirect);
179 $urltoredirect = preg_replace(
'/action=remove_file&?/',
'', $urltoredirect);
181 header(
'Location: '.$urltoredirect);
184 setEventMessages(
'BugFoundVarUploaddirnotDefined',
null,
'errors');
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.