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
77$hidedetails = isset($hidedetails) ? $hidedetails :
'';
78$hidedesc = isset($hidedesc) ? $hidedesc :
'';
79$hideref = isset($hideref) ? $hideref :
'';
82if (!empty($permissionedit) && empty($permissiontoadd)) {
83 $permissiontoadd = $permissionedit;
88 if (!empty($backtopageforcancel)) {
89 header(
"Location: ".$backtopageforcancel);
91 } elseif (!empty($backtopage)) {
92 header(
"Location: ".$backtopage);
100if ($action ==
'add' && !empty($permissiontoadd)) {
101 foreach (
$object->fields as $key => $val) {
103 if (
$object->fields[$key][
'type'] ==
'duration') {
108 if (!GETPOSTISSET($key) && !preg_match(
'/^chkbxlst:/',
$object->fields[$key][
'type'])) {
114 if (in_array($key, array(
'rowid',
'entity',
'import_key'))) {
117 if (in_array($key, array(
'date_creation',
'tms',
'fk_user_creat',
'fk_user_modif'))) {
118 if (!in_array(abs($val[
'visible']), array(1, 3))) {
124 if (preg_match(
'/^text/',
$object->fields[$key][
'type'])) {
125 $tmparray = explode(
':',
$object->fields[$key][
'type']);
126 if (!empty($tmparray[1])) {
127 $value =
GETPOST($key, $tmparray[1]);
129 $value =
GETPOST($key,
'nohtml');
130 if (!empty(
$object->fields[$key][
'arrayofkeyval']) && !empty(
$object->fields[$key][
'multiinput'])) {
131 $tmparraymultiselect =
GETPOST($key.
'_multiselect',
'array');
132 foreach ($tmparraymultiselect as $tmpvalue) {
133 $value .= (!empty($value) ?
"," :
"").$tmpvalue;
137 } elseif (preg_match(
'/^html/',
$object->fields[$key][
'type'])) {
138 $tmparray = explode(
':',
$object->fields[$key][
'type']);
139 if (!empty($tmparray[1])) {
140 $value =
GETPOST($key, $tmparray[1]);
142 $value =
GETPOST($key,
'restricthtml');
144 } elseif (
$object->fields[$key][
'type'] ==
'date') {
146 } elseif (
$object->fields[$key][
'type'] ==
'datetime') {
148 } elseif (
$object->fields[$key][
'type'] ==
'duration') {
150 } elseif (preg_match(
'/^(integer|price|real|double)/',
$object->fields[$key][
'type'])) {
152 } elseif (
$object->fields[$key][
'type'] ==
'boolean') {
153 $value = ((
GETPOST($key) ==
'1' ||
GETPOST($key) ==
'on') ? 1 : 0);
154 } elseif (
$object->fields[$key][
'type'] ==
'reference') {
155 $tmparraykey = array_keys(
$object->param_list);
157 } elseif (preg_match(
'/^chkbxlst:(.*)/',
$object->fields[$key][
'type']) ||
$object->fields[$key][
'type'] ==
'checkbox') {
159 $values_arr =
GETPOST($key,
'array');
160 if (!empty($values_arr)) {
161 $value = implode(
',', $values_arr);
164 if ($key ==
'lang') {
167 $value =
GETPOST($key,
'alphanohtml');
170 if (preg_match(
'/^integer:/i',
$object->fields[$key][
'type']) && $value ==
'-1') {
173 if (!empty(
$object->fields[$key][
'foreignkey']) && $value ==
'-1') {
176 if (preg_match(
'/^sellist:/i',
$object->fields[$key][
'type']) && $value ==
'0') {
183 if (!empty($val[
'notnull']) && $val[
'notnull'] > 0 &&
$object->$key ==
'' && isset($val[
'default']) && $val[
'default'] ===
'(PROV)') {
186 if ($key ==
'pass_crypted') {
190 if (!empty($val[
'notnull']) && $val[
'notnull'] > 0 &&
$object->$key ==
'' && !isset($val[
'default'])) {
192 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv($val[
'label'])),
null,
'errors');
198 if (!$error && !empty($val[
'validate']) && is_callable(array(
$object,
'validateField'))) {
209 if (!empty($model_pdf) && property_exists(
$object,
'model_pdf')) {
210 $object->model_pdf = $model_pdf;
215 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'', 1);
224 $result =
$object->create($user);
228 $categories =
GETPOST(
'categories',
'array:int');
229 $object->setCategories($categories);
232 $urltogo = $backtopage ? str_replace(
'__ID__', $result, $backtopage) : $backurlforlist;
233 $urltogo = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $urltogo);
237 if (empty($noback)) {
238 header(
"Location: " . $urltogo);
258if ($action ==
'update' && !empty($permissiontoadd)) {
259 foreach (
$object->fields as $key => $val) {
261 if (
$object->fields[$key][
'type'] ==
'duration') {
262 if (!GETPOSTISSET($key.
'hour') || !GETPOSTISSET($key.
'min')) {
265 } elseif (
$object->fields[$key][
'type'] ==
'boolean') {
266 if (!GETPOSTISSET($key)) {
271 if (!GETPOSTISSET($key) && !preg_match(
'/^chkbxlst:/',
$object->fields[$key][
'type']) &&
$object->fields[$key][
'type'] !==
'checkbox') {
276 if (in_array($key, array(
'rowid',
'entity',
'import_key'))) {
279 if (in_array($key, array(
'date_creation',
'tms',
'fk_user_creat',
'fk_user_modif'))) {
280 if (!in_array(abs($val[
'visible']), array(1, 3, 4))) {
286 if (preg_match(
'/^text/',
$object->fields[$key][
'type'])) {
287 $tmparray = explode(
':',
$object->fields[$key][
'type']);
288 if (!empty($tmparray[1])) {
289 $value =
GETPOST($key, $tmparray[1]);
291 $value =
GETPOST($key,
'nohtml');
292 if (!empty(
$object->fields[$key][
'arrayofkeyval']) && !empty(
$object->fields[$key][
'multiinput'])) {
293 $tmparraymultiselect =
GETPOST($key.
'_multiselect',
'array');
294 foreach ($tmparraymultiselect as $keytmp => $tmpvalue) {
295 $value .= (!empty($value) ?
"," :
"").$tmpvalue;
299 } elseif (preg_match(
'/^html/',
$object->fields[$key][
'type'])) {
300 $tmparray = explode(
':',
$object->fields[$key][
'type']);
301 if (!empty($tmparray[1])) {
302 $value =
GETPOST($key, $tmparray[1]);
304 $value =
GETPOST($key,
'restricthtml');
306 } elseif (
$object->fields[$key][
'type'] ==
'date') {
308 } elseif (
$object->fields[$key][
'type'] ==
'datetime') {
310 } elseif (
$object->fields[$key][
'type'] ==
'duration') {
316 } elseif (preg_match(
'/^(integer|price|real|double)/',
$object->fields[$key][
'type'])) {
318 } elseif (
$object->fields[$key][
'type'] ==
'boolean') {
319 $value = ((
GETPOST($key,
'aZ09') ==
'on' ||
GETPOST($key,
'aZ09') ==
'1') ? 1 : 0);
320 } elseif (
$object->fields[$key][
'type'] ==
'reference') {
322 } elseif (preg_match(
'/^chkbxlst:/',
$object->fields[$key][
'type']) ||
$object->fields[$key][
'type'] ==
'checkbox') {
324 $values_arr =
GETPOST($key,
'array');
325 if (!empty($values_arr)) {
326 $value = implode(
',', $values_arr);
329 if ($key ==
'lang') {
330 $value =
GETPOST($key,
'aZ09');
332 $value =
GETPOST($key,
'alphanohtml');
335 if (preg_match(
'/^integer:/i',
$object->fields[$key][
'type']) && $value ==
'-1') {
338 if (!empty(
$object->fields[$key][
'foreignkey']) && $value ==
'-1') {
341 if (preg_match(
'/^sellist:/i',
$object->fields[$key][
'type']) && $value ==
'0') {
347 if ($key ==
'pass_crypted' && property_exists(
$object,
'pass')) {
348 if (
GETPOST(
"pass",
"password")) {
353 if (!empty($val[
'notnull']) && $val[
'notnull'] > 0 &&
$object->$key ==
'' && (!isset($val[
'default']) || is_null($val[
'default']))) {
355 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv($val[
'label'])),
null,
'errors');
361 if (!$error && !empty($val[
'validate']) && is_callable(array(
$object,
'validateField'))) {
369 $categories =
GETPOST(
'categories',
'array');
370 if (method_exists(
$object,
'setCategories')) {
371 $object->setCategories($categories);
379 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
386 $result =
$object->update($user);
389 $urltogo = $backtopage ? str_replace(
'__ID__', (
string) $result, $backtopage) : $backurlforlist;
390 $urltogo = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $urltogo);
391 if ($urltogo && empty($noback)) {
392 header(
"Location: " . $urltogo);
408if (preg_match(
'/^set(\w+)$/', $action, $reg) &&
GETPOSTINT(
'id') > 0 && !empty($permissiontoadd)) {
411 $keyforfield = $reg[1];
412 if (property_exists(
$object, $keyforfield)) {
413 if (!empty(
$object->fields[$keyforfield]) && in_array(
$object->fields[$keyforfield][
'type'], array(
'date',
'datetime',
'timestamp'))) {
419 $result =
$object->update($user);
427 $action =
'edit'.$reg[1];
433$permissiontoeditextra = $permissiontoadd;
434if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
436 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
439if ($action ==
"update_extras" &&
GETPOSTINT(
'id') > 0 && !empty($permissiontoeditextra)) {
444 $attribute =
GETPOST(
'attribute',
'aZ09');
449 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute);
453 $action =
'edit_extras';
455 $result =
$object->updateExtraField($attribute, empty($triggermodname) ?
'' : $triggermodname, $user);
462 $action =
'edit_extras';
468if ($action ==
'confirm_delete' && $confirm ==
'yes' && !empty($permissiontodelete)) {
470 dol_print_error(
null,
'Error, object must be fetched before being deleted');
476 $result =
$object->delete($user);
484 if (empty($noback)) {
485 if (empty($backurlforlist)) {
486 print
'Error backurlforlist is not defined';
489 header(
"Location: " . $backurlforlist);
507if ($action ==
'confirm_deleteline' && $confirm ==
'yes' && !empty($permissiontoadd)) {
510 $result =
$object->deleteLine($user, $lineid, 0, $fk_movement);
512 $result =
$object->deleteLine($user, $lineid);
517 $outputlangs = $langs;
520 $newlang =
GETPOST(
'lang_id',
'aZ09');
523 $newlang =
$object->thirdparty->default_lang;
525 if (!empty($newlang)) {
527 $outputlangs->setDefaultLang($newlang);
530 if (method_exists(
$object,
'generateDocument')) {
532 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
538 if (empty($noback)) {
539 header(
'Location: '.((empty($backtopage)) ? $_SERVER[
"PHP_SELF"].
'?id='.
$object->id : $backtopage));
550if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
551 if (
$object->element ==
'inventory' && !empty($include_sub_warehouse)) {
553 $result =
$object->validate($user,
false, $include_sub_warehouse);
555 $result =
$object->validate($user);
561 if (method_exists(
$object,
'generateDocument')) {
562 $outputlangs = $langs;
565 $newlang =
GETPOST(
'lang_id',
'aZ09');
568 $newlang = !empty(
$object->thirdparty->default_lang) ?
$object->thirdparty->default_lang :
"";
570 if (!empty($newlang)) {
572 $outputlangs->setDefaultLang($newlang);
579 $retgen =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
593if ($action ==
'confirm_close' && $confirm ==
'yes' && $permissiontoadd) {
594 $result =
$object->cancel($user);
598 if (method_exists(
$object,
'generateDocument')) {
599 $outputlangs = $langs;
602 $newlang =
GETPOST(
'lang_id',
'aZ09');
605 $newlang =
$object->thirdparty->default_lang;
607 if (!empty($newlang)) {
609 $outputlangs->setDefaultLang($newlang);
614 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
625if ($action ==
'confirm_setdraft' && $confirm ==
'yes' && $permissiontoadd) {
626 $result =
$object->setDraft($user);
637if ($action ==
'confirm_reopen' && $confirm ==
'yes' && $permissiontoadd) {
638 $result =
$object->reopen($user);
642 if (method_exists(
$object,
'generateDocument')) {
643 $outputlangs = $langs;
646 $newlang =
GETPOST(
'lang_id',
'aZ09');
649 $newlang =
$object->thirdparty->default_lang;
651 if (!empty($newlang)) {
653 $outputlangs->setDefaultLang($newlang);
658 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
669if ($action ==
'confirm_clone' && $confirm ==
'yes' && !empty($permissiontoadd)) {
671 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
679 $result = $objectutil->createFromClone($user, ((
$object->id > 0) ?
$object->id :
$id));
680 if (is_object($result) || $result > 0) {
682 if (is_object($result)) {
683 $newid = $result->id;
688 if (empty($noback)) {
689 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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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)
Return value of a param into GET or POST supervariable.
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.