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') {
111 if (!GETPOSTISSET($key) && !preg_match(
'/^chkbxlst:/',
$object->fields[$key][
'type'])) {
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 $value =
GETPOST($key, $tmparray[1]);
132 $value =
GETPOST($key,
'nohtml');
133 if (!empty(
$object->fields[$key][
'arrayofkeyval']) && !empty(
$object->fields[$key][
'multiinput'])) {
134 $tmparraymultiselect =
GETPOST($key.
'_multiselect',
'array');
135 foreach ($tmparraymultiselect as $tmpvalue) {
136 $value .= (!empty($value) ?
"," :
"").$tmpvalue;
140 } elseif (preg_match(
'/^html/',
$object->fields[$key][
'type'])) {
141 $tmparray = explode(
':',
$object->fields[$key][
'type']);
142 if (!empty($tmparray[1])) {
143 $value =
GETPOST($key, $tmparray[1]);
145 $value =
GETPOST($key,
'restricthtml');
147 } elseif (
$object->fields[$key][
'type'] ==
'date') {
149 } elseif (
$object->fields[$key][
'type'] ==
'datetime') {
151 } elseif (
$object->fields[$key][
'type'] ==
'duration') {
153 } elseif (preg_match(
'/^(integer|price|real|double)/',
$object->fields[$key][
'type'])) {
155 } elseif (
$object->fields[$key][
'type'] ==
'boolean') {
156 $value = ((
GETPOST($key) ==
'1' ||
GETPOST($key) ==
'on') ? 1 : 0);
157 } elseif (
$object->fields[$key][
'type'] ==
'reference') {
158 $tmparraykey = array_keys(
$object->param_list);
160 } elseif (preg_match(
'/^chkbxlst:(.*)/',
$object->fields[$key][
'type']) ||
$object->fields[$key][
'type'] ==
'checkbox') {
162 $values_arr =
GETPOST($key,
'array');
163 if (!empty($values_arr)) {
164 $value = implode(
',', $values_arr);
167 if ($key ==
'lang') {
170 $value =
GETPOST($key,
'alphanohtml');
173 if (preg_match(
'/^integer:/i',
$object->fields[$key][
'type']) && $value ==
'-1') {
176 if (!empty(
$object->fields[$key][
'foreignkey']) && $value ==
'-1') {
179 if ((preg_match(
'/^sellist/i',
$object->fields[$key][
'type']) ||
$object->fields[$key][
'type'] ==
'select') && $value ===
'0') {
186 if (!empty($val[
'notnull']) && $val[
'notnull'] > 0 &&
$object->$key ==
'' && isset($val[
'default']) && $val[
'default'] ===
'(PROV)') {
189 if ($key ==
'pass_crypted') {
193 if (!empty($val[
'notnull']) && $val[
'notnull'] > 0 &&
$object->$key ==
'' && !isset($val[
'default'])) {
195 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv($val[
'label'])),
null,
'errors');
201 if (!$error && !empty($val[
'validate']) && is_callable(array(
$object,
'validateField'))) {
212 if (!empty($model_pdf) && property_exists(
$object,
'model_pdf')) {
213 $object->model_pdf = $model_pdf;
218 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'', 1);
227 $result =
$object->create($user);
231 $categories =
GETPOST(
'categories',
'array:int');
232 $object->setCategories($categories);
235 $urltogo = $backtopage ? str_replace(
'__ID__', $result, $backtopage) : $backurlforlist;
236 $urltogo = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $urltogo);
240 if (empty($noback)) {
241 header(
"Location: " . $urltogo);
261if ($action ==
'update' && !empty($permissiontoadd)) {
262 foreach (
$object->fields as $key => $val) {
264 if (
$object->fields[$key][
'type'] ==
'duration') {
265 if (!GETPOSTISSET($key.
'hour') || !GETPOSTISSET($key.
'min')) {
268 } elseif (
$object->fields[$key][
'type'] ==
'boolean') {
269 if (!GETPOSTISSET($key)) {
274 if (!GETPOSTISSET($key) && !preg_match(
'/^chkbxlst:/',
$object->fields[$key][
'type']) &&
$object->fields[$key][
'type'] !==
'checkbox') {
279 if (in_array($key, array(
'rowid',
'entity',
'import_key'))) {
282 if (in_array($key, array(
'date_creation',
'tms',
'fk_user_creat',
'fk_user_modif'))) {
283 if (!in_array(abs($val[
'visible']), array(1, 3, 4))) {
289 if (preg_match(
'/^text/',
$object->fields[$key][
'type'])) {
290 $tmparray = explode(
':',
$object->fields[$key][
'type']);
291 if (!empty($tmparray[1])) {
292 $value =
GETPOST($key, $tmparray[1]);
294 $value =
GETPOST($key,
'nohtml');
295 if (!empty(
$object->fields[$key][
'arrayofkeyval']) && !empty(
$object->fields[$key][
'multiinput'])) {
296 $tmparraymultiselect =
GETPOST($key.
'_multiselect',
'array');
297 foreach ($tmparraymultiselect as $keytmp => $tmpvalue) {
298 $value .= (!empty($value) ?
"," :
"").$tmpvalue;
302 } elseif (preg_match(
'/^html/',
$object->fields[$key][
'type'])) {
303 $tmparray = explode(
':',
$object->fields[$key][
'type']);
304 if (!empty($tmparray[1])) {
305 $value =
GETPOST($key, $tmparray[1]);
307 $value =
GETPOST($key,
'restricthtml');
309 } elseif (
$object->fields[$key][
'type'] ==
'date') {
311 } elseif (
$object->fields[$key][
'type'] ==
'datetime') {
313 } elseif (
$object->fields[$key][
'type'] ==
'duration') {
319 } elseif (preg_match(
'/^(integer|price|real|double)/',
$object->fields[$key][
'type'])) {
321 } elseif (
$object->fields[$key][
'type'] ==
'boolean') {
322 $value = ((
GETPOST($key,
'aZ09') ==
'on' ||
GETPOST($key,
'aZ09') ==
'1') ? 1 : 0);
323 } elseif (
$object->fields[$key][
'type'] ==
'reference') {
325 } elseif (preg_match(
'/^chkbxlst:/',
$object->fields[$key][
'type']) ||
$object->fields[$key][
'type'] ==
'checkbox') {
327 $values_arr =
GETPOST($key,
'array');
328 if (!empty($values_arr)) {
329 $value = implode(
',', $values_arr);
332 if ($key ==
'lang') {
333 $value =
GETPOST($key,
'aZ09');
335 $value =
GETPOST($key,
'alphanohtml');
338 if (preg_match(
'/^integer:/i',
$object->fields[$key][
'type']) && $value ==
'-1') {
341 if (!empty(
$object->fields[$key][
'foreignkey']) && $value ==
'-1') {
344 if ((preg_match(
'/^sellist/i',
$object->fields[$key][
'type']) ||
$object->fields[$key][
'type'] ==
'select') && $value ===
'0') {
350 if ($key ==
'pass_crypted' && property_exists(
$object,
'pass')) {
351 if (
GETPOST(
"pass",
"password")) {
356 if (!empty($val[
'notnull']) && $val[
'notnull'] > 0 &&
$object->$key ==
'' && (!isset($val[
'default']) || is_null($val[
'default']))) {
358 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv($val[
'label'])),
null,
'errors');
364 if (!$error && !empty($val[
'validate']) && is_callable(array(
$object,
'validateField'))) {
372 $categories =
GETPOST(
'categories',
'array');
373 if (method_exists(
$object,
'setCategories')) {
374 $object->setCategories($categories);
382 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
389 $result =
$object->update($user);
392 $urltogo = $backtopage ? str_replace(
'__ID__', (
string) $result, $backtopage) : $backurlforlist;
393 $urltogo = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $urltogo);
394 if ($urltogo && empty($noback)) {
395 header(
"Location: " . $urltogo);
411if (preg_match(
'/^set(\w+)$/', $action, $reg) &&
GETPOSTINT(
'id') > 0 && !empty($permissiontoadd)) {
414 $keyforfield = $reg[1];
415 if (property_exists(
$object, $keyforfield)) {
416 if (!empty(
$object->fields[$keyforfield]) && in_array(
$object->fields[$keyforfield][
'type'], array(
'date',
'datetime',
'timestamp'))) {
422 $result =
$object->update($user);
430 $action =
'edit'.$reg[1];
436$permissiontoeditextra = $permissiontoadd;
437if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
439 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
442if ($action ==
"update_extras" &&
GETPOSTINT(
'id') > 0 && !empty($permissiontoeditextra)) {
447 $attribute =
GETPOST(
'attribute',
'aZ09');
452 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute);
456 $action =
'edit_extras';
458 $result =
$object->updateExtraField($attribute, empty($triggermodname) ?
'' : $triggermodname, $user);
465 $action =
'edit_extras';
471if ($action ==
'confirm_delete' && $confirm ==
'yes' && !empty($permissiontodelete)) {
473 dol_print_error(
null,
'Error, object must be fetched before being deleted');
479 $result =
$object->delete($user);
487 if (empty($noback)) {
488 if (empty($backurlforlist)) {
489 print
'Error backurlforlist is not defined';
492 header(
"Location: " . $backurlforlist);
510if ($action ==
'confirm_deleteline' && $confirm ==
'yes' && !empty($permissiontoadd)) {
513 $result =
$object->deleteLine($user, $lineid, 0, $fk_movement);
515 $result =
$object->deleteLine($user, $lineid);
520 $outputlangs = $langs;
523 $newlang =
GETPOST(
'lang_id',
'aZ09');
526 $newlang =
$object->thirdparty->default_lang;
528 if (!empty($newlang)) {
530 $outputlangs->setDefaultLang($newlang);
533 if (method_exists(
$object,
'generateDocument')) {
535 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
541 if (empty($noback)) {
542 header(
'Location: '.((empty($backtopage)) ? $_SERVER[
"PHP_SELF"].
'?id='.
$object->id : $backtopage));
553if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
554 if (
$object->element ==
'inventory' && !empty($include_sub_warehouse)) {
556 $result =
$object->validate($user,
false, $include_sub_warehouse);
558 $result =
$object->validate($user);
564 if (method_exists(
$object,
'generateDocument')) {
565 $outputlangs = $langs;
568 $newlang =
GETPOST(
'lang_id',
'aZ09');
571 $newlang = !empty(
$object->thirdparty->default_lang) ?
$object->thirdparty->default_lang :
"";
573 if (!empty($newlang)) {
575 $outputlangs->setDefaultLang($newlang);
582 $retgen =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
596if ($action ==
'confirm_close' && $confirm ==
'yes' && $permissiontoadd) {
597 $result =
$object->cancel($user);
601 if (method_exists(
$object,
'generateDocument')) {
602 $outputlangs = $langs;
605 $newlang =
GETPOST(
'lang_id',
'aZ09');
608 $newlang =
$object->thirdparty->default_lang;
610 if (!empty($newlang)) {
612 $outputlangs->setDefaultLang($newlang);
617 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
628if ($action ==
'confirm_setdraft' && $confirm ==
'yes' && $permissiontoadd) {
629 $result =
$object->setDraft($user);
640if ($action ==
'confirm_reopen' && $confirm ==
'yes' && $permissiontoadd) {
641 $result =
$object->reopen($user);
645 if (method_exists(
$object,
'generateDocument')) {
646 $outputlangs = $langs;
649 $newlang =
GETPOST(
'lang_id',
'aZ09');
652 $newlang =
$object->thirdparty->default_lang;
654 if (!empty($newlang)) {
656 $outputlangs->setDefaultLang($newlang);
661 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
672if ($action ==
'confirm_clone' && $confirm ==
'yes' && !empty($permissiontoadd)) {
674 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
682 $result = $objectutil->createFromClone($user, ((
$object->id > 0) ?
$object->id :
$id));
683 if (is_object($result) || $result > 0) {
685 if (is_object($result)) {
686 $newid = $result->id;
691 if (empty($noback)) {
692 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.