dolibarr 19.0.3
actions_addupdatedelete.inc.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017-2019 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
25// $action or $cancel must be defined
26// $object must be defined
27// $permissiontoadd must be defined
28// $permissiontodelete must be defined
29// $backurlforlist must be defined
30// $backtopage may be defined
31// $noback may be defined
32// $triggermodname may be defined
33
34$hidedetails = isset($hidedetails) ? $hidedetails : '';
35$hidedesc = isset($hidedesc) ? $hidedesc : '';
36$hideref = isset($hideref) ? $hideref : '';
37
38
39if (!empty($permissionedit) && empty($permissiontoadd)) {
40 $permissiontoadd = $permissionedit; // For backward compatibility
41}
42
43if ($cancel) {
44 /*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/
45 if (!empty($backtopageforcancel)) {
46 header("Location: ".$backtopageforcancel);
47 exit;
48 } elseif (!empty($backtopage)) {
49 header("Location: ".$backtopage);
50 exit;
51 }
52 $action = '';
53}
54
55
56// Action to add record
57if ($action == 'add' && !empty($permissiontoadd)) {
58 foreach ($object->fields as $key => $val) {
59 if ($object->fields[$key]['type'] == 'duration') {
60 if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') {
61 continue; // The field was not submited to be saved
62 }
63 } else {
64 if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type'])) {
65 continue; // The field was not submited to be saved
66 }
67 }
68 // Ignore special fields
69 if (in_array($key, array('rowid', 'entity', 'import_key'))) {
70 continue;
71 }
72 if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) {
73 if (!in_array(abs($val['visible']), array(1, 3))) {
74 continue; // Only 1 and 3 that are case to create
75 }
76 }
77
78 // Set value to insert
79 if (preg_match('/^text/', $object->fields[$key]['type'])) {
80 $tmparray = explode(':', $object->fields[$key]['type']);
81 if (!empty($tmparray[1])) {
82 $value = GETPOST($key, $tmparray[1]);
83 } else {
84 $value = GETPOST($key, 'nohtml');
85 }
86 } elseif (preg_match('/^html/', $object->fields[$key]['type'])) {
87 $tmparray = explode(':', $object->fields[$key]['type']);
88 if (!empty($tmparray[1])) {
89 $value = GETPOST($key, $tmparray[1]);
90 } else {
91 $value = GETPOST($key, 'restricthtml');
92 }
93 } elseif ($object->fields[$key]['type'] == 'date') {
94 $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt
95 } elseif ($object->fields[$key]['type'] == 'datetime') {
96 $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'), 'tzuserrel');
97 } elseif ($object->fields[$key]['type'] == 'duration') {
98 $value = 60 * 60 * GETPOSTINT($key.'hour') + 60 * GETPOSTINT($key.'min');
99 } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
100 $value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup
101 } elseif ($object->fields[$key]['type'] == 'boolean') {
102 $value = ((GETPOST($key) == '1' || GETPOST($key) == 'on') ? 1 : 0);
103 } elseif ($object->fields[$key]['type'] == 'reference') {
104 $tmparraykey = array_keys($object->param_list);
105 $value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2');
106 } elseif (preg_match('/^chkbxlst:(.*)/', $object->fields[$key]['type']) || $object->fields[$key]['type'] == 'checkbox') {
107 $value = '';
108 $values_arr = GETPOST($key, 'array');
109 if (!empty($values_arr)) {
110 $value = implode(',', $values_arr);
111 }
112 } else {
113 if ($key == 'lang') {
114 $value = GETPOST($key, 'aZ09') ? GETPOST($key, 'aZ09') : "";
115 } else {
116 $value = GETPOST($key, 'alphanohtml');
117 }
118 }
119 if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
120 $value = ''; // This is an implicit foreign key field
121 }
122 if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') {
123 $value = ''; // This is an explicit foreign key field
124 }
125
126 //var_dump($key.' '.$value.' '.$object->fields[$key]['type'].' '.$object->fields[$key]['notnull']);
127
128 $object->$key = $value;
129 if (!empty($val['notnull']) && $val['notnull'] > 0 && $object->$key == '' && isset($val['default']) && $val['default'] == '(PROV)') {
130 $object->$key = '(PROV)';
131 }
132 if ($key == 'pass_crypted') {
133 $object->pass = GETPOST("pass", "none");
134 // TODO Manadatory for password not yet managed
135 } else {
136 if (!empty($val['notnull']) && $val['notnull'] > 0 && $object->$key == '' && !isset($val['default'])) {
137 $error++;
138 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors');
139 }
140 }
141
142 // Validation of fields values
143 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 || getDolGlobalString('MAIN_ACTIVATE_VALIDATION_RESULT')) {
144 if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) {
145 if (!$object->validateField($object->fields, $key, $value)) {
146 $error++;
147 }
148 }
149 }
150 }
151
152 // Fill array 'array_options' with data from add form
153 if (!$error) {
154 $ret = $extrafields->setOptionalsFromPost(null, $object, '', 1);
155 if ($ret < 0) {
156 $error++;
157 }
158 }
159
160 if (!$error) {
161 $db->begin();
162
163 $result = $object->create($user);
164 if ($result > 0) {
165 // Creation OK
166 if (isModEnabled('categorie') && method_exists($object, 'setCategories')) {
167 $categories = GETPOST('categories', 'array:int');
168 $object->setCategories($categories);
169 }
170
171 $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
172 $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
173
174 $db->commit();
175
176 if (empty($noback)) {
177 header("Location: " . $urltogo);
178 exit;
179 }
180 } else {
181 $db->rollback();
182
183 $error++;
184 // Creation KO
185 if (!empty($object->errors)) {
186 setEventMessages(null, $object->errors, 'errors');
187 } else {
188 setEventMessages($object->error, null, 'errors');
189 }
190 $action = 'create';
191 }
192 } else {
193 $action = 'create';
194 }
195}
196
197// Action to update record
198if ($action == 'update' && !empty($permissiontoadd)) {
199 foreach ($object->fields as $key => $val) {
200 // Check if field was submited to be edited
201 if ($object->fields[$key]['type'] == 'duration') {
202 if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) {
203 continue; // The field was not submited to be saved
204 }
205 } elseif ($object->fields[$key]['type'] == 'boolean') {
206 if (!GETPOSTISSET($key)) {
207 $object->$key = 0; // use 0 instead null if the field is defined as not null
208 continue;
209 }
210 } else {
211 if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type']) && $object->fields[$key]['type']!=='checkbox') {
212 continue; // The field was not submited to be saved
213 }
214 }
215 // Ignore special fields
216 if (in_array($key, array('rowid', 'entity', 'import_key'))) {
217 continue;
218 }
219 if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) {
220 if (!in_array(abs($val['visible']), array(1, 3, 4))) {
221 continue; // Only 1 and 3 and 4, that are cases to update
222 }
223 }
224
225 // Set value to update
226 if (preg_match('/^text/', $object->fields[$key]['type'])) {
227 $tmparray = explode(':', $object->fields[$key]['type']);
228 if (!empty($tmparray[1])) {
229 $value = GETPOST($key, $tmparray[1]);
230 } else {
231 $value = GETPOST($key, 'nohtml');
232 }
233 } elseif (preg_match('/^html/', $object->fields[$key]['type'])) {
234 $tmparray = explode(':', $object->fields[$key]['type']);
235 if (!empty($tmparray[1])) {
236 $value = GETPOST($key, $tmparray[1]);
237 } else {
238 $value = GETPOST($key, 'restricthtml');
239 }
240 } elseif ($object->fields[$key]['type'] == 'date') {
241 $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt
242 } elseif ($object->fields[$key]['type'] == 'datetime') {
243 $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'), 'tzuserrel');
244 } elseif ($object->fields[$key]['type'] == 'duration') {
245 if (GETPOST($key.'hour', 'int') != '' || GETPOST($key.'min', 'int') != '') {
246 $value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int');
247 } else {
248 $value = '';
249 }
250 } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
251 $value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup
252 } elseif ($object->fields[$key]['type'] == 'boolean') {
253 $value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0);
254 } elseif ($object->fields[$key]['type'] == 'reference') {
255 $value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2');
256 } elseif (preg_match('/^chkbxlst:/', $object->fields[$key]['type']) || $object->fields[$key]['type'] == 'checkbox') {
257 $value = '';
258 $values_arr = GETPOST($key, 'array');
259 if (!empty($values_arr)) {
260 $value = implode(',', $values_arr);
261 }
262 } else {
263 if ($key == 'lang') {
264 $value = GETPOST($key, 'aZ09');
265 } else {
266 $value = GETPOST($key, 'alphanohtml');
267 }
268 }
269 if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
270 $value = ''; // This is an implicit foreign key field
271 }
272 if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') {
273 $value = ''; // This is an explicit foreign key field
274 }
275
276 $object->$key = $value;
277 if ($val['notnull'] > 0 && $object->$key == '' && (!isset($val['default']) || is_null($val['default']))) {
278 $error++;
279 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors');
280 }
281
282 // Validation of fields values
283 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 || getDolGlobalString('MAIN_ACTIVATE_VALIDATION_RESULT')) {
284 if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) {
285 if (!$object->validateField($object->fields, $key, $value)) {
286 $error++;
287 }
288 }
289 }
290
291 if (isModEnabled('categorie')) {
292 $categories = GETPOST('categories', 'array');
293 if (method_exists($object, 'setCategories')) {
294 $object->setCategories($categories);
295 }
296 }
297 }
298
299
300 // Fill array 'array_options' with data from add form
301 if (!$error) {
302 $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
303 if ($ret < 0) {
304 $error++;
305 }
306 }
307
308 if (!$error) {
309 $result = $object->update($user);
310 if ($result > 0) {
311 $action = 'view';
312 $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
313 $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
314 if ($urltogo && empty($noback)) {
315 header("Location: " . $urltogo);
316 exit;
317 }
318 } else {
319 $error++;
320 // Creation KO
321 setEventMessages($object->error, $object->errors, 'errors');
322 $action = 'edit';
323 }
324 } else {
325 $action = 'edit';
326 }
327}
328
329// Action to update one modulebuilder field
330$reg = array();
331if (preg_match('/^set(\w+)$/', $action, $reg) && GETPOST('id', 'int') > 0 && !empty($permissiontoadd)) {
332 $object->fetch(GETPOST('id', 'int'));
333
334 $keyforfield = $reg[1];
335 if (property_exists($object, $keyforfield)) {
336 if (!empty($object->fields[$keyforfield]) && in_array($object->fields[$keyforfield]['type'], array('date', 'datetime', 'timestamp'))) {
337 $object->$keyforfield = dol_mktime(GETPOST($keyforfield.'hour'), GETPOST($keyforfield.'min'), GETPOST($keyforfield.'sec'), GETPOST($keyforfield.'month'), GETPOST($keyforfield.'day'), GETPOST($keyforfield.'year'));
338 } else {
339 $object->$keyforfield = GETPOST($keyforfield);
340 }
341
342 $result = $object->update($user);
343
344 if ($result > 0) {
345 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
346 $action = 'view';
347 } else {
348 $error++;
349 setEventMessages($object->error, $object->errors, 'errors');
350 $action = 'edit'.$reg[1];
351 }
352 }
353}
354
355// Action to update one extrafield
356if ($action == "update_extras" && GETPOST('id', 'int') > 0 && !empty($permissiontoadd)) {
357 $object->fetch(GETPOST('id', 'int'));
358
359 $object->oldcopy = dol_clone($object, 2);
360
361 $attribute = GETPOST('attribute', 'alphanohtml');
362
363 $error = 0;
364
365 // Fill array 'array_options' with data from update form
366 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute);
367 if ($ret < 0) {
368 $error++;
369 setEventMessages($extrafields->error, $object->errors, 'errors');
370 $action = 'edit_extras';
371 } else {
372 $result = $object->updateExtraField($attribute, empty($triggermodname) ? '' : $triggermodname, $user);
373 if ($result > 0) {
374 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
375 $action = 'view';
376 } else {
377 $error++;
378 setEventMessages($object->error, $object->errors, 'errors');
379 $action = 'edit_extras';
380 }
381 }
382}
383
384// Action to delete
385if ($action == 'confirm_delete' && !empty($permissiontodelete)) {
386 if (!($object->id > 0)) {
387 dol_print_error('', 'Error, object must be fetched before being deleted');
388 exit;
389 }
390
391 $db->begin();
392
393 $result = $object->delete($user);
394
395 if ($result > 0) {
396 $db->commit();
397
398 // Delete OK
399 setEventMessages("RecordDeleted", null, 'mesgs');
400
401 if (empty($noback)) {
402 if (empty($backurlforlist)) {
403 print 'Error backurlforlist is not defined';
404 exit;
405 }
406 header("Location: " . $backurlforlist);
407 exit;
408 }
409 } else {
410 $db->rollback();
411
412 $error++;
413 if (!empty($object->errors)) {
414 setEventMessages(null, $object->errors, 'errors');
415 } else {
416 setEventMessages($object->error, null, 'errors');
417 }
418 }
419
420 $action = '';
421}
422
423// Remove a line
424if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) {
425 if (method_exists($object, 'deleteline')) {
426 $result = $object->deleteline($user, $lineid); // For backward compatibility
427 } else {
428 $result = $object->deleteLine($user, $lineid);
429 }
430 if ($result > 0) {
431 // Define output language
432 $outputlangs = $langs;
433 $newlang = '';
434 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
435 $newlang = GETPOST('lang_id', 'aZ09');
436 }
437 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && is_object($object->thirdparty)) {
438 $newlang = $object->thirdparty->default_lang;
439 }
440 if (!empty($newlang)) {
441 $outputlangs = new Translate("", $conf);
442 $outputlangs->setDefaultLang($newlang);
443 }
444 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
445 if (method_exists($object, 'generateDocument')) {
446 $ret = $object->fetch($object->id); // Reload to get new records
447 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
448 }
449 }
450
451 setEventMessages($langs->trans('RecordDeleted'), null, 'mesgs');
452
453 if (empty($noback)) {
454 header('Location: '.((empty($backtopage)) ? $_SERVER["PHP_SELF"].'?id='.$object->id : $backtopage));
455 exit;
456 }
457 } else {
458 $error++;
459 setEventMessages($object->error, $object->errors, 'errors');
460 }
461 $action = '';
462}
463
464// Action validate object
465if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) {
466 if ($object->element == 'inventory' && !empty($include_sub_warehouse)) {
467 // Can happen when the conf INVENTORY_INCLUDE_SUB_WAREHOUSE is set
468 $result = $object->validate($user, false, $include_sub_warehouse);
469 } else {
470 $result = $object->validate($user);
471 }
472
473 if ($result >= 0) {
474 // Define output language
475 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
476 if (method_exists($object, 'generateDocument')) {
477 $outputlangs = $langs;
478 $newlang = '';
479 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
480 $newlang = GETPOST('lang_id', 'aZ09');
481 }
482 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
483 $newlang = !empty($object->thirdparty->default_lang) ? $object->thirdparty->default_lang : "";
484 }
485 if (!empty($newlang)) {
486 $outputlangs = new Translate("", $conf);
487 $outputlangs->setDefaultLang($newlang);
488 }
489
490 $ret = $object->fetch($id); // Reload to get new records
491
492 $model = $object->model_pdf;
493
494 $retgen = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
495 if ($retgen < 0) {
496 setEventMessages($object->error, $object->errors, 'warnings');
497 }
498 }
499 }
500 } else {
501 $error++;
502 setEventMessages($object->error, $object->errors, 'errors');
503 }
504 $action = '';
505}
506
507// Action close object
508if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) {
509 $result = $object->cancel($user);
510 if ($result >= 0) {
511 // Define output language
512 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
513 if (method_exists($object, 'generateDocument')) {
514 $outputlangs = $langs;
515 $newlang = '';
516 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
517 $newlang = GETPOST('lang_id', 'aZ09');
518 }
519 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
520 $newlang = $object->thirdparty->default_lang;
521 }
522 if (!empty($newlang)) {
523 $outputlangs = new Translate("", $conf);
524 $outputlangs->setDefaultLang($newlang);
525 }
526 $model = $object->model_pdf;
527 $ret = $object->fetch($id); // Reload to get new records
528
529 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
530 }
531 }
532 } else {
533 $error++;
534 setEventMessages($object->error, $object->errors, 'errors');
535 }
536 $action = '';
537}
538
539// Action setdraft object
540if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) {
541 $result = $object->setDraft($user);
542 if ($result >= 0) {
543 // Nothing else done
544 } else {
545 $error++;
546 setEventMessages($object->error, $object->errors, 'errors');
547 }
548 $action = '';
549}
550
551// Action reopen object
552if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
553 $result = $object->reopen($user);
554 if ($result >= 0) {
555 // Define output language
556 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
557 if (method_exists($object, 'generateDocument')) {
558 $outputlangs = $langs;
559 $newlang = '';
560 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
561 $newlang = GETPOST('lang_id', 'aZ09');
562 }
563 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
564 $newlang = $object->thirdparty->default_lang;
565 }
566 if (!empty($newlang)) {
567 $outputlangs = new Translate("", $conf);
568 $outputlangs->setDefaultLang($newlang);
569 }
570 $model = $object->model_pdf;
571 $ret = $object->fetch($id); // Reload to get new records
572
573 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
574 }
575 }
576 } else {
577 $error++;
578 setEventMessages($object->error, $object->errors, 'errors');
579 }
580 $action = '';
581}
582
583// Action clone object
584if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) {
585 if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) {
586 setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
587 } else {
588 // We clone object to avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object.
589 $objectutil = dol_clone($object, 1);
590 // We used native clone to keep this->db valid and allow to use later all the methods of object.
591 //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
592 // ...
593 $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
594 if (is_object($result) || $result > 0) {
595 $newid = 0;
596 if (is_object($result)) {
597 $newid = $result->id;
598 } else {
599 $newid = $result;
600 }
601
602 if (empty($noback)) {
603 header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $newid); // Open record of new object
604 exit;
605 }
606 } else {
607 $error++;
608 setEventMessages($objectutil->error, $objectutil->errors, 'errors');
609 $action = '';
610 }
611 }
612}
Class to manage translations.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.