28@phan-var-force CommonObject $this
29@phan-var-force ?string $action
30@phan-var-force ?string $cancel
31@phan-var-force CommonObject $object
32@phan-var-force string $permissiontoadd
33@phan-var-force ?string $permissionedit
34@phan-var-force string $permissiontodelete
35@phan-var-force string $backurlforlist
36@phan-var-force ?string $backtopage
37@phan-var-force ?string $noback
38@phan-var-force ?string $triggermodname
39@phan-var-force string $hidedetails
40@phan-var-force string $hidedesc
41@phan-var-force string $hideref
42@phan-var-force ?string $confirm
43@phan-var-force ?int $lineid
44@phan-var-force ?int $id
80$hidedetails = isset($hidedetails) ? $hidedetails :
'';
81$hidedesc = isset($hidedesc) ? $hidedesc :
'';
82$hideref = isset($hideref) ? $hideref :
'';
85if (!empty($permissionedit) && empty($permissiontoadd)) {
86 $permissiontoadd = $permissionedit;
91 if (!empty($backtopageforcancel)) {
92 header(
"Location: ".$backtopageforcancel);
94 } elseif (!empty($backtopage)) {
95 header(
"Location: ".$backtopage);
103if ($action ==
'add' && !empty($permissiontoadd)) {
104 foreach (
$object->fields as $key => $val) {
106 if (
$object->fields[$key][
'type'] ==
'duration') {
117 if (in_array($key, array(
'rowid',
'entity',
'import_key'))) {
120 if (in_array($key, array(
'date_creation',
'tms',
'fk_user_creat',
'fk_user_modif'))) {
121 if (!in_array(abs($val[
'visible']), array(1, 3))) {
127 if (preg_match(
'/^text/',
$object->fields[$key][
'type'])) {
128 $tmparray = explode(
':',
$object->fields[$key][
'type']);
129 if (!empty($tmparray[1])) {
130 $check = $tmparray[1];
135 $security_check =
'alphanohtml';
137 $security_check = $check;
139 if (!empty($tmparray[1])) {
140 $value =
GETPOST($key, $security_check);
142 $value =
GETPOST($key, $security_check);
143 if (!empty(
$object->fields[$key][
'arrayofkeyval']) && !empty(
$object->fields[$key][
'multiinput'])) {
144 $tmparraymultiselect =
GETPOST($key.
'_multiselect',
'array');
145 foreach ($tmparraymultiselect as $tmpvalue) {
146 $value .= (!empty($value) ?
"," :
"").$tmpvalue;
150 } elseif (preg_match(
'/^html/',
$object->fields[$key][
'type'])) {
151 $tmparray = explode(
':',
$object->fields[$key][
'type']);
152 if (!empty($tmparray[1])) {
153 $value =
GETPOST($key, $tmparray[1]);
155 $value =
GETPOST($key,
'restricthtml');
157 } elseif (
$object->fields[$key][
'type'] ==
'date') {
159 } elseif (
$object->fields[$key][
'type'] ==
'datetime') {
161 } elseif (
$object->fields[$key][
'type'] ==
'duration') {
163 } elseif (preg_match(
'/^(integer|price|real|double)/',
$object->fields[$key][
'type'])) {
165 } elseif (
$object->fields[$key][
'type'] ==
'boolean') {
166 $value = ((
GETPOST($key) ==
'1' ||
GETPOST($key) ==
'on') ? 1 : 0);
167 } elseif (
$object->fields[$key][
'type'] ==
'reference') {
168 $tmparraykey = array_keys(
$object->param_list);
170 } elseif (preg_match(
'/^chkbxlst:(.*)/',
$object->fields[$key][
'type']) ||
$object->fields[$key][
'type'] ==
'checkbox') {
172 $values_arr =
GETPOST($key,
'array');
173 if (!empty($values_arr)) {
174 $value = implode(
',', $values_arr);
177 if ($key ==
'lang') {
180 $value =
GETPOST($key,
'alphanohtml');
183 if (preg_match(
'/^integer:/i',
$object->fields[$key][
'type']) && $value ==
'-1') {
186 if (!empty(
$object->fields[$key][
'foreignkey']) && $value ==
'-1') {
189 if ((preg_match(
'/^sellist/i',
$object->fields[$key][
'type']) ||
$object->fields[$key][
'type'] ==
'select') && $value ===
'0') {
196 if (!empty($val[
'notnull']) && $val[
'notnull'] > 0 &&
$object->$key ==
'' && isset($val[
'default']) && $val[
'default'] ===
'(PROV)') {
199 if ($key ==
'pass_crypted') {
203 if (!empty($val[
'notnull']) && $val[
'notnull'] > 0 &&
$object->$key ==
'' && !isset($val[
'default'])) {
205 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv($val[
'label'])),
null,
'errors');
211 if (!$error && !empty($val[
'validate']) && is_callable(array(
$object,
'validateField'))) {
222 if (!empty($model_pdf) && property_exists(
$object,
'model_pdf')) {
223 $object->model_pdf = $model_pdf;
228 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'', 1);
237 $result =
$object->create($user);
241 $categories =
GETPOST(
'categories',
'array:int');
242 $object->setCategories($categories);
245 $urltogo = $backtopage ? str_replace(
'__ID__', $result, $backtopage) : $backurlforlist;
246 $urltogo = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $urltogo);
250 if (empty($noback)) {
251 header(
"Location: " . $urltogo);
271if ($action ==
'update' && !empty($permissiontoadd)) {
272 foreach (
$object->fields as $key => $val) {
274 if (
$object->fields[$key][
'type'] ==
'duration') {
278 } elseif (
$object->fields[$key][
'type'] ==
'boolean') {
284 if (!
GETPOSTISSET($key) && !preg_match(
'/^chkbxlst:/',
$object->fields[$key][
'type']) &&
$object->fields[$key][
'type'] !==
'checkbox') {
289 if (in_array($key, array(
'rowid',
'entity',
'import_key'))) {
292 if (in_array($key, array(
'date_creation',
'tms',
'fk_user_creat',
'fk_user_modif'))) {
293 if (!in_array(abs($val[
'visible']), array(1, 3, 4))) {
299 if (preg_match(
'/^text/',
$object->fields[$key][
'type'])) {
300 $tmparray = explode(
':',
$object->fields[$key][
'type']);
301 if (!empty($tmparray[1])) {
302 $check = $tmparray[1];
307 $security_check =
'alphanohtml';
309 $security_check = $check;
311 if (!empty($tmparray[1])) {
312 $value =
GETPOST($key, $security_check);
314 $value =
GETPOST($key, $security_check);
315 if (!empty(
$object->fields[$key][
'arrayofkeyval']) && !empty(
$object->fields[$key][
'multiinput'])) {
316 $tmparraymultiselect =
GETPOST($key.
'_multiselect',
'array');
317 foreach ($tmparraymultiselect as $keytmp => $tmpvalue) {
318 $value .= (!empty($value) ?
"," :
"").$tmpvalue;
322 } elseif (preg_match(
'/^html/',
$object->fields[$key][
'type'])) {
323 $tmparray = explode(
':',
$object->fields[$key][
'type']);
324 if (!empty($tmparray[1])) {
325 $value =
GETPOST($key, $tmparray[1]);
327 $value =
GETPOST($key,
'restricthtml');
329 } elseif (
$object->fields[$key][
'type'] ==
'date') {
331 } elseif (
$object->fields[$key][
'type'] ==
'datetime') {
333 } elseif (
$object->fields[$key][
'type'] ==
'duration') {
339 } elseif (preg_match(
'/^(integer|price|real|double)/',
$object->fields[$key][
'type'])) {
341 } elseif (
$object->fields[$key][
'type'] ==
'boolean') {
342 $value = ((
GETPOST($key,
'aZ09') ==
'on' ||
GETPOST($key,
'aZ09') ==
'1') ? 1 : 0);
343 } elseif (
$object->fields[$key][
'type'] ==
'reference') {
345 } elseif (preg_match(
'/^chkbxlst:/',
$object->fields[$key][
'type']) ||
$object->fields[$key][
'type'] ==
'checkbox') {
347 $values_arr =
GETPOST($key,
'array');
348 if (!empty($values_arr)) {
349 $value = implode(
',', $values_arr);
352 if ($key ==
'lang') {
353 $value =
GETPOST($key,
'aZ09');
355 $value =
GETPOST($key,
'alphanohtml');
358 if (preg_match(
'/^integer:/i',
$object->fields[$key][
'type']) && $value ==
'-1') {
361 if (!empty(
$object->fields[$key][
'foreignkey']) && $value ==
'-1') {
364 if ((preg_match(
'/^sellist/i',
$object->fields[$key][
'type']) ||
$object->fields[$key][
'type'] ==
'select') && $value ===
'0') {
370 if ($key ==
'pass_crypted' && property_exists(
$object,
'pass')) {
371 if (
GETPOST(
"pass",
"password")) {
376 if (!empty($val[
'notnull']) && $val[
'notnull'] > 0 &&
$object->$key ==
'' && (!isset($val[
'default']) || is_null($val[
'default']))) {
378 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv($val[
'label'])),
null,
'errors');
384 if (!$error && !empty($val[
'validate']) && is_callable(array(
$object,
'validateField'))) {
392 $categories =
GETPOST(
'categories',
'array');
393 if (method_exists(
$object,
'setCategories')) {
394 $object->setCategories($categories);
402 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
409 $result =
$object->update($user);
412 $urltogo = $backtopage ? str_replace(
'__ID__', (
string) $result, $backtopage) : $backurlforlist;
413 $urltogo = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $urltogo);
414 if ($urltogo && empty($noback)) {
415 header(
"Location: " . $urltogo);
431if (preg_match(
'/^set(\w+)$/', $action, $reg) &&
GETPOSTINT(
'id') > 0 && !empty($permissiontoadd)) {
434 $keyforfield = $reg[1];
435 if (property_exists(
$object, $keyforfield)) {
436 if (!empty(
$object->fields[$keyforfield]) && in_array(
$object->fields[$keyforfield][
'type'], array(
'date',
'datetime',
'timestamp'))) {
442 $result =
$object->update($user);
450 $action =
'edit'.$reg[1];
456$permissiontoeditextra = $permissiontoadd;
457if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
459 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
462if ($action ==
"update_extras" &&
GETPOSTINT(
'id') > 0 && !empty($permissiontoeditextra)) {
467 $attribute =
GETPOST(
'attribute',
'aZ09');
472 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute);
476 $action =
'edit_extras';
478 $result =
$object->updateExtraField($attribute, empty($triggermodname) ?
'' : $triggermodname, $user);
485 $action =
'edit_extras';
491if ($action ==
'confirm_delete' && $confirm ==
'yes' && !empty($permissiontodelete)) {
493 dol_print_error(
null,
'Error, object must be fetched before being deleted');
499 $result =
$object->delete($user);
507 if (empty($noback)) {
508 if (empty($backurlforlist)) {
509 print
'Error backurlforlist is not defined';
512 header(
"Location: " . $backurlforlist);
530if ($action ==
'confirm_deleteline' && $confirm ==
'yes' && !empty($permissiontoadd)) {
533 $result =
$object->deleteLine($user, $lineid, 0, $fk_movement);
535 $result =
$object->deleteLine($user, $lineid);
540 $outputlangs = $langs;
543 $newlang =
GETPOST(
'lang_id',
'aZ09');
546 $newlang =
$object->thirdparty->default_lang;
548 if (!empty($newlang)) {
550 $outputlangs->setDefaultLang($newlang);
553 if (method_exists(
$object,
'generateDocument')) {
555 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
561 if (empty($noback)) {
562 header(
'Location: '.((empty($backtopage)) ? $_SERVER[
"PHP_SELF"].
'?id='.
$object->id : $backtopage));
573if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
574 if (
$object->element ==
'inventory' && !empty($include_sub_warehouse)) {
576 $result =
$object->validate($user,
false, $include_sub_warehouse);
578 $result =
$object->validate($user);
584 if (method_exists(
$object,
'generateDocument')) {
585 $outputlangs = $langs;
588 $newlang =
GETPOST(
'lang_id',
'aZ09');
591 $newlang = !empty(
$object->thirdparty->default_lang) ?
$object->thirdparty->default_lang :
"";
593 if (!empty($newlang)) {
595 $outputlangs->setDefaultLang($newlang);
602 $retgen =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
616if ($action ==
'confirm_close' && $confirm ==
'yes' && $permissiontoadd) {
617 $result =
$object->cancel($user);
621 if (method_exists(
$object,
'generateDocument')) {
622 $outputlangs = $langs;
625 $newlang =
GETPOST(
'lang_id',
'aZ09');
628 $newlang =
$object->thirdparty->default_lang;
630 if (!empty($newlang)) {
632 $outputlangs->setDefaultLang($newlang);
637 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
648if ($action ==
'confirm_setdraft' && $confirm ==
'yes' && $permissiontoadd) {
649 $result =
$object->setDraft($user);
660if ($action ==
'confirm_reopen' && $confirm ==
'yes' && $permissiontoadd) {
661 $result =
$object->reopen($user);
665 if (method_exists(
$object,
'generateDocument')) {
666 $outputlangs = $langs;
669 $newlang =
GETPOST(
'lang_id',
'aZ09');
672 $newlang =
$object->thirdparty->default_lang;
674 if (!empty($newlang)) {
676 $outputlangs->setDefaultLang($newlang);
681 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
692if ($action ==
'confirm_clone' && $confirm ==
'yes' && !empty($permissiontoadd)) {
694 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
702 $result = $objectutil->createFromClone($user, ((
$object->id > 0) ?
$object->id :
$id));
703 if (is_object($result) || $result > 0) {
705 if (is_object($result)) {
706 $newid = $result->id;
711 if (empty($noback)) {
712 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' . $newid);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
Class to manage translations.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
isModEnabled($module)
Is Dolibarr module enabled.