dolibarr 21.0.0-alpha
html.formcardwebportal.class.php
1<?php
2/* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21
28require_once DOL_DOCUMENT_ROOT . '/webportal/class/html.formwebportal.class.php';
29
36{
40 public $action = '';
41
45 public $backtopage = '';
46
50 public $backtopageforcancel = '';
51
55 public $backtopagejsfields = '';
56
60 public $cancel = '';
61
65 public $db;
66
70 public $elementEn = '';
71
75 public $form;
76
80 public $id;
81
85 public $object;
86
90 public $permissiontoread = 0;
91
95 public $permissiontoadd = 0;
96
100 public $permissiontodelete = 0;
101
105 public $permissionnote = 0;
106
110 public $permissiondellink = 0;
111
115 public $ref;
116
120 public $titleKey = '';
121
125 public $titleDescKey = '';
126
132 public function __construct($db)
133 {
134 $this->db = $db;
135 $this->form = new FormWebPortal($this->db);
136 }
137
150 public function init($elementEn, $id = 0, $permissiontoread = 0, $permissiontoadd = 0, $permissiontodelete = 0, $permissionnote = 0, $permissiondellink = 0)
151 {
152 global $hookmanager, $langs;
153
154 $elementEnUpper = strtoupper($elementEn);
155 $objectclass = 'WebPortal' . ucfirst($elementEn);
156
157 $elementCardAccess = getDolGlobalString('WEBPORTAL_' . $elementEnUpper . '_CARD_ACCESS', 'hidden');
158 if ($elementCardAccess == 'hidden' || $id <= 0) {
160 }
161
162 // load module libraries
163 dol_include_once('/webportal/class/webportal' . $elementEn . '.class.php');
164
165 // Load translation files required by the page
166 $langs->loadLangs(array('website', 'other'));
167
168 // Get parameters
169 //$id = $id > 0 ? $id : GETPOST('id', 'int');
170 $ref = GETPOST('ref', 'alpha');
171 $action = GETPOST('action', 'aZ09');
172 $confirm = GETPOST('confirm', 'alpha');
173 $cancel = GETPOST('cancel', 'aZ09');
174 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'webportal' . $elementEn . 'card'; // To manage different context of search
175 $backtopage = GETPOST('backtopage', 'alpha'); // if not set, a default page will be used
176 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // if not set, $backtopage will be used
177 $backtopagejsfields = GETPOST('backtopagejsfields', 'alpha');
178
179 // Initialize a technical objects
180 $object = new $objectclass($this->db);
181 //$extrafields = new ExtraFields($db);
182 $hookmanager->initHooks(array('webportal' . $elementEn . 'card', 'globalcard')); // Note that conf->hooks_modules contains array
183
184 // Fetch optionals attributes and labels
185 //$extrafields->fetch_name_optionals_label($object->table_element);
186 //$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
187
188 if (empty($action) && empty($id) && empty($ref)) {
189 $action = 'view';
190 }
191
192 // Load object
193 include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
194
195 // Security check (enable the most restrictive one)
196 if (!isModEnabled('webportal')) {
198 }
199 if (!$permissiontoread) {
201 }
202
203 // set form card
204 $this->action = $action;
205 $this->backtopage = $backtopage;
206 $this->backtopageforcancel = $backtopageforcancel;
207 $this->backtopagejsfields = $backtopagejsfields;
208 $this->cancel = $cancel;
209 $this->elementEn = $elementEn;
210 $this->id = $id;
211 $this->object = $object;
212 $this->permissiontoread = $permissiontoread;
213 $this->permissiontoadd = $permissiontoadd;
214 $this->permissiontodelete = $permissiontodelete;
215 $this->permissionnote = $permissionnote;
216 $this->permissiondellink = $permissiondellink;
217 $this->titleKey = $objectclass . 'CardTitle';
218 $this->ref = $ref;
219 }
220
226 public function doActions()
227 {
228 global $langs;
229
230 // initialize
231 $action = $this->action;
232 $backtopage = $this->backtopage;
233 $backtopageforcancel = $this->backtopageforcancel;
234 $cancel = $this->cancel;
235 $elementEn = $this->elementEn;
236 $id = $this->id;
237 $object = $this->object;
238 //$permissiontoread = $this->permissiontoread;
239 $permissiontoadd = $this->permissiontoadd;
240
241 $error = 0;
242
244
245 $backurlforlist = $context->getControllerUrl('default');
246 $noback = 1;
247
248 if (empty($backtopage) || ($cancel && empty($id))) {
249 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
250 $backtopage = $context->getControllerUrl($elementEn . 'card');
251 }
252 }
253
254 // Action to cancel record
255 if ($cancel) {
256 if (!empty($backtopageforcancel)) {
257 header("Location: " . $backtopageforcancel);
258 exit;
259 } elseif (!empty($backtopage)) {
260 header("Location: " . $backtopage);
261 exit;
262 }
263 $action = '';
264 }
265
266 // Action to update record
267 if ($action == 'update' && !empty($permissiontoadd)) {
268 foreach ($object->fields as $key => $val) {
269 // Check if field was submitted to be edited
270 if ($object->fields[$key]['type'] == 'duration') {
271 if (!GETPOSTISSET($key . 'hour') || !GETPOSTISSET($key . 'min')) {
272 continue; // The field was not submitted to be saved
273 }
274 } elseif ($object->fields[$key]['type'] == 'boolean') {
275 if (!GETPOSTISSET($key)) {
276 $object->$key = 0; // use 0 instead null if the field is defined as not null
277 continue;
278 }
279 } else {
280 if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type']) && $object->fields[$key]['type'] !== 'checkbox') {
281 continue; // The field was not submitted to be saved
282 }
283 }
284 // Ignore special fields
285 if (in_array($key, array('rowid', 'entity', 'import_key'))) {
286 continue;
287 }
288 if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) {
289 if (!in_array(abs($val['visible']), array(1, 3, 4))) {
290 continue; // Only 1 and 3 and 4, that are cases to update
291 }
292 }
293
294 // Set value to update
295 if (preg_match('/^text/', $object->fields[$key]['type'])) {
296 $tmparray = explode(':', $object->fields[$key]['type']);
297 if (!empty($tmparray[1])) {
298 $value = GETPOST($key, $tmparray[1]);
299 } else {
300 $value = GETPOST($key, 'nohtml');
301 }
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]);
306 } else {
307 $value = GETPOST($key, 'restricthtml');
308 }
309 } elseif (in_array($object->fields[$key]['type'], array('date', 'datetime'))) {
310 $postDate = GETPOST($key, 'alphanohtml');
311 // extract date YYYY-MM-DD for year, month and day
312 $dateArr = explode('-', $postDate);
313 $dateYear = 0;
314 $dateMonth = 0;
315 $dateDay = 0;
316 if (count($dateArr) == 3) {
317 $dateYear = (int) $dateArr[0];
318 $dateMonth = (int) $dateArr[1];
319 $dateDay = (int) $dateArr[2];
320 }
321 // extract time HH:ii:ss for hours, minutes and seconds
322 $postTime = GETPOST($key . '_time', 'alphanohtml');
323 $timeArr = explode(':', $postTime);
324 $timeHours = 12;
325 $timeMinutes = 0;
326 $timeSeconds = 0;
327 if (!empty($timeArr)) {
328 if (isset($timeArr[0])) {
329 $timeHours = (int) $timeArr[0];
330 }
331 if (isset($timeArr[1])) {
332 $timeMinutes = (int) $timeArr[1];
333 }
334 if (isset($timeArr[2])) {
335 $timeSeconds = (int) $timeArr[2];
336 }
337 }
338 $value = dol_mktime($timeHours, $timeMinutes, $timeSeconds, $dateMonth, $dateDay, $dateYear);
339 } elseif ($object->fields[$key]['type'] == 'duration') {
340 if (GETPOSTINT($key . 'hour') != '' || GETPOSTINT($key . 'min') != '') {
341 $value = 60 * 60 * GETPOSTINT($key . 'hour') + 60 * GETPOSTINT($key . 'min');
342 } else {
343 $value = '';
344 }
345 } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
346 $value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup
347 } elseif ($object->fields[$key]['type'] == 'boolean') {
348 $value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0);
349 //}
350 //elseif ($object->fields[$key]['type'] == 'reference') {
351 // $value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2');
352 } elseif (preg_match('/^chkbxlst:/', $object->fields[$key]['type']) || $object->fields[$key]['type'] == 'checkbox') {
353 $value = '';
354 $values_arr = GETPOST($key, 'array');
355 if (!empty($values_arr)) {
356 $value = implode(',', $values_arr);
357 }
358 } else {
359 if ($key == 'lang') {
360 $value = GETPOST($key, 'aZ09');
361 } else {
362 $value = GETPOST($key, 'alphanohtml');
363 }
364 }
365 if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
366 $value = ''; // This is an implicit foreign key field
367 }
368 if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') {
369 $value = ''; // This is an explicit foreign key field
370 }
371
372 $object->$key = $value;
373 if (!empty($val['notnull']) && $val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) {
374 $error++;
375 $context->setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors');
376 }
377
378 // Validation of fields values
379 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 || getDolGlobalString('MAIN_ACTIVATE_VALIDATION_RESULT')) {
380 if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) {
381 if (!$object->validateField($object->fields, $key, $value)) {
382 $error++;
383 }
384 }
385 }
386
387 if (isModEnabled('category')) {
388 $categories = GETPOST('categories', 'array');
389 if (method_exists($object, 'setCategories')) {
390 $object->setCategories($categories);
391 }
392 }
393 }
394
395 // Fill array 'array_options' with data from add form
396 //if (!$error) {
397 // $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
398 // if ($ret < 0) {
399 // $error++;
400 // }
401 //}
402
403 if (!$error) {
404 $result = $object->update($context->logged_user);
405 if ($result >= 0) {
406 $action = 'view';
407 $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
408 $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', (string) $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
409 if ($urltogo && empty($noback)) {
410 header("Location: " . $urltogo);
411 exit;
412 }
413 } else {
414 $error++;
415 // Creation KO
416 $context->setEventMessages($object->error, $object->errors, 'errors');
417 $action = 'edit';
418 }
419 } else {
420 $action = 'edit';
421 }
422 }
423
424 $this->object = $object;
425 $this->action = $action;
426 }
427
434 protected function header($context)
435 {
436 global $langs;
437
438 $html = '';
439
440 // initialize
441 $object = $this->object;
442 $addgendertxt = '';
443 //if (property_exists($object, 'gender') && !empty($object->gender)) {
444 // switch ($object->gender) {
445 // case 'man':
446 // $addgendertxt .= '<i class="fas fa-mars"></i>';
447 // break;
448 // case 'woman':
449 // $addgendertxt .= '<i class="fas fa-venus"></i>';
450 // break;
451 // case 'other':
452 // $addgendertxt .= '<i class="fas fa-transgender"></i>';
453 // break;
454 // }
455 //}
456
457 $html .= '<!-- html.formcardwebportal.class.php -->';
458 $html .= '<header>';
459
460 // Left block - begin
461 $html .= '<div class="header-card-left-block inline-block" style="width: 75%;">';
462 $html .= '<div>';
463
464 // logo or photo
465 $form = new Form($this->db);
466 $html .= '<div class="inline-block floatleft valignmiddle">';
467 $html .= '<div class="floatleft inline-block valignmiddle divphotoref">';
468 $html .= $form->showphoto('memberphoto', $object, 0, 0, 0, 'photowithmargin photoref', 'small', 1, 0, 1);
469 //include DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
470 //$html .= getImagePublicURLOfObject($object, 1, '_small');
471 $html .= '</div>';
472 $html .= '</div>';
473
474 // main information - begin
475 $html .= '<div class="header-card-main-information inline-block valignmiddle">';
476 // ref
477 $html .= '<div><strong>' . $langs->trans("Ref").' : '.dol_escape_htmltag($object->ref) . '</strong></div>';
478 // full name
479 $fullname = '';
480 if (method_exists($object, 'getFullName')) {
481 $fullname = $object->getFullName($langs);
482 }
483 $html .= '<div><strong>';
484 if ($object->element == 'member') {
485 '@phan-var-force Adherent $object';
486 if ($object->morphy == 'mor' && !empty($object->societe)) {
487 $html .= dol_htmlentities($object->societe);
488 $html .= (!empty($fullname) && $object->societe != $fullname) ? ' (' . dol_htmlentities($fullname) . $addgendertxt . ')' : '';
489 } else {
490 $html .= dol_htmlentities($fullname) . $addgendertxt;
491 if (empty($object->fk_soc)) {
492 $html .= (!empty($object->societe) && $object->societe != $fullname) ? ' (' . dol_htmlentities($object->societe) . ')' : '';
493 }
494 }
495 } else {
496 $html .= dol_htmlentities(!empty($object->ref) ? $object->ref : '');
497 }
498 $html .= '</strong></div>';
499 // address
500 if (method_exists($object, 'getBannerAddressForWebPortal')) {
501 $moreaddress = $object->getBannerAddressForWebPortal('refaddress');
502 if ($moreaddress) {
503 $html .= '<div class="refidno refaddress">';
504 $html .= $moreaddress;
505 $html .= '</div>';
506 }
507 }
508 $html .= '</div>';
509 // main information - end
510
511 $html .= '</div>';
512 $html .= '</div>';
513 // Left block - end
514
515 // Right block - begin
516 $html .= '<div class="header-card-right-block inline-block" style="width: 24%;">';
517 // show status
518 $htmlStatus = $object->getLibStatut(6);
519 if (empty($htmlStatus) || $htmlStatus == $object->getLibStatut(3)) {
520 $htmlStatus = $object->getLibStatut(5);
521 }
522 $html .= $htmlStatus;
523 $html .= '</div>';
524 // Right block - end
525
526 $html .= '</header>';
527
528 return $html;
529 }
530
536 protected function bodyView($keyforbreak = '')
537 {
538 global $langs;
539
540 $html = '';
541
542 // initialize
543 $object = $this->object;
544
545 $object->fields = dol_sort_array($object->fields, 'position');
546
547 // separate fields to show on the left and on the right
548 $fieldShowList = array();
549 foreach ($object->fields as $key => $val) {
550 // discard if it's a hidden field on form
551 if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) {
552 continue;
553 }
554
555 if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
556 continue; // we don't want this field
557 }
558
559 if (!empty($val['showonheader'])) {
560 continue; // already on header
561 }
562
563 $fieldShowList[$key] = $val;
564 }
565
566 $nbFieldShow = count($fieldShowList);
567 $lastKeyFieldLeft = $keyforbreak;
568 $lastNumFieldLeft = 0;
569 if ($lastKeyFieldLeft == '') {
570 $lastNumFieldLeft = ceil($nbFieldShow / 2);
571 }
572 $numField = 0;
573 $html .= '<div class="grid">';
574 $html .= '<div class="card-left">';
575 foreach ($object->fields as $key => $val) {
576 if (!array_key_exists($key, $fieldShowList)) {
577 continue; // not to show
578 }
579
580 $value = $object->$key;
581
582 $html .= '<div class="grid field_' . $key . '">';
583
584 $html .= '<div class="' . (empty($val['tdcss']) ? '' : $val['tdcss']) . ' fieldname_' . $key;
585 $html .= '">';
586 $labeltoshow = '';
587 $labeltoshow .= '<strong>' . $langs->trans($val['label']) . '</strong>';
588 $html .= $labeltoshow;
589 $html .= '</div>';
590
591 $html .= '<div class="valuefield fieldname_' . $key;
592 if (!empty($val['cssview'])) {
593 $html .= ' ' . $val['cssview'];
594 }
595 $html .= '">';
596 if ($key == 'lang') {
597 $langs->load('languages');
598 $labellang = ($value ? $langs->trans('Language_' . $value) : '');
599 //$html .= picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"');
600 $html .= $labellang;
601 } else {
602 $html .= $this->form->showOutputFieldForObject($object, $val, $key, $value, '', '', '', 0);
603 }
604 $html .= '</div>';
605
606 $html .= '</div>';
607
608 $numField++;
609
610 // fields on the right
611 $cardRight = false;
612 if ($keyforbreak != '') {
613 if ($key == $keyforbreak) {
614 $cardRight = true;
615 }
616 } else {
617 if ($numField == $lastNumFieldLeft) {
618 $cardRight = true;
619 }
620 }
621 if ($cardRight) {
622 $html .= '</div>';
623 $html .= '<div class="card-right">';
624 }
625 }
626 $html .= '</div>';
627 $html .= '</div>';
628
629 return $html;
630 }
631
637 protected function bodyEdit()
638 {
639 global $langs;
640
641 $html = '';
642
643 // initialize
644 $object = $this->object;
645
646 $object->fields = dol_sort_array($object->fields, 'position');
647
648 foreach ($object->fields as $key => $val) {
649 // Discard if filed is a hidden field on form
650 if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) {
651 continue;
652 }
653
654 if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
655 continue; // We don't want this field
656 }
657
658 $html .= '<div class="grid field_' . $key . '">';
659 $html .= '<div class="titlefieldcreate';
660 if (isset($val['notnull']) && $val['notnull'] > 0) {
661 $html .= ' required';
662 }
663 $html .= '">';
664 $html .= $langs->trans($val['label']);
665 $html .= '</div>';
666
667 $html .= '<div class="valuefieldcreate">';
668 if (in_array($val['type'], array('int', 'integer'))) {
669 $value = GETPOSTISSET($key) ? GETPOSTINT($key) : $object->$key;
670 } elseif ($val['type'] == 'double') {
671 $value = GETPOSTISSET($key) ? price2num(GETPOST($key, 'alphanohtml')) : $object->$key;
672 } elseif (preg_match('/^text/', $val['type'])) {
673 $tmparray = explode(':', $val['type']);
674 if (!empty($tmparray[1])) {
675 $check = $tmparray[1];
676 } else {
677 $check = 'nohtml';
678 }
679 $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
680 } elseif (preg_match('/^html/', $val['type'])) {
681 $tmparray = explode(':', $val['type']);
682 if (!empty($tmparray[1])) {
683 $check = $tmparray[1];
684 } else {
685 $check = 'restricthtml';
686 }
687 $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
688 } elseif (in_array($val['type'], array('date', 'datetime'))) {
689 $isPostDate = GETPOSTISSET($key);
690 $isPostTime = GETPOSTISSET($key . '_time');
691 if ($isPostDate) {
692 $postDate = GETPOST($key, 'alphanohtml');
693 if ($isPostTime) {
694 $postTime = GETPOST($key . '_time', 'alphanohtml') . ':00';
695 } else {
696 $postTime = '00:00:00';
697 }
698 $valueDateTimeStr = $postDate . ' ' . $postTime;
699 } else {
700 // format date timestamp to YYYY-MM-DD HH:ii:ss
701 $valueDateTimeStr = dol_print_date($object->$key, '%Y-%m-%d %H:%M:%S');
702 }
703
704 $value = $valueDateTimeStr;
705 } elseif ($val['type'] == 'price') {
706 $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key);
707 } elseif ($key == 'lang') {
708 $value = GETPOSTISSET($key) ? GETPOST($key, 'aZ09') : $object->lang;
709 } else {
710 $value = GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : $object->$key;
711 }
712
713 if (!empty($val['noteditable'])) {
714 $html .= $this->form->showOutputFieldForObject($object, $val, $key, $value, '', '', '', 0);
715 } else {
716 $html .= $this->form->showInputField($val, $key, $value, '', '', '', '');
717 }
718 $html .= '</div>';
719 $html .= '</div>';
720 }
721
722 return $html;
723 }
724
730 protected function footer()
731 {
732 $html = '';
733 $html .= '<footer>';
734 $html .= '</footer>';
735
736 return $html;
737 }
738
745 public function elementCard($context)
746 {
747 global $hookmanager, $langs;
748
749 $html = '<!-- elementCard -->';
750
751 // initialize
752 $action = $this->action;
753 $backtopage = $this->backtopage;
754 $backtopageforcancel = $this->backtopageforcancel;
755 //$backtopagejsfields = $this->backtopagejsfields;
756 //$elementEn = $this->elementEn;
757 $id = $this->id;
758 $object = $this->object;
759 //$permissiontoread = $this->permissiontoread;
760 $permissiontoadd = $this->permissiontoadd;
761 $ref = $this->ref;
762 $titleKey = $this->titleKey;
763 $title = $langs->trans($titleKey);
764
765 // Part to edit record
766 if (($id || $ref) && $action == 'edit') {
767 $html .= '<article>';
768 //$html .= load_fiche_titre($title, '', 'object_'.$object->picto);
769 $html .= '<header>';
770 $html .= '<h2>' . $title . '</h2>';
771 $html .= '</header>';
772
773 $url_file = $context->getControllerUrl($context->controller, '', false);
774 $html .= '<form method="POST" action="' . $url_file . '">';
775 $html .= $context->getFormToken();
776 $html .= '<input type="hidden" name="action" value="update">';
777 $html .= '<input type="hidden" name="id" value="' . $object->id . '">';
778 if ($backtopage) {
779 $html .= '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
780 }
781 if ($backtopageforcancel) {
782 $html .= '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
783 }
784
785 //$html .= '<table>'."\n";
786 // Common attributes
787 //include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
788 $html .= $this->bodyEdit();
789
790 // Other attributes
791 //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
792 //$html .= '</table>';
793
794 // Save and Cancel buttons
795 $html .= '<div class="grid">';
796 $html .= '<div><input type="submit" name="save" role="button" value="' . dol_escape_htmltag($langs->trans('Save')) . '" /></div>';
797 $html .= '<div><input type="submit" name="cancel" role="button" value="' . dol_escape_htmltag($langs->trans('Cancel')) . '" /></div>';
798 $html .= '</div>';
799
800 $html .= '</form>';
801 $html .= '</article>';
802 }
803
804 // Part to show record
805 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
806 $html .= '<article>';
807
808 $formconfirm = '';
809
810 // Call Hook formConfirm
811 $parameters = array('formConfirm' => $formconfirm);
812 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
813 if (empty($reshook)) {
814 $formconfirm .= $hookmanager->resPrint;
815 } elseif ($reshook > 0) {
816 $formconfirm = $hookmanager->resPrint;
817 }
818
819 // Print form confirm
820 $html .= $formconfirm;
821
822 // Object card
823 // ------------------------------------------------------------
824 $html .= $this->header($context);
825
826 // Common attributes
827 $keyforbreak = '';
828 $html .= $this->bodyView($keyforbreak);
829
830 // Other attributes. Fields from hook formObjectOptions and Extrafields.
831 //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
832
833 //$html .= $this->footer();
834 $html .= '</article>';
835
836 // Buttons for actions
837 if ($action != 'presend' && $action != 'editline') {
838 $html .= '<div>' . "\n";
839 $parameters = array();
840 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
841 if ($reshook < 0) {
842 $context->setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
843 }
844
845 if (empty($reshook)) {
846 if ($permissiontoadd) {
847 $url_file = $context->getControllerUrl($context->controller, '', false);
848 $html .= '<a href="' . $url_file . '&id=' . $object->id . '&action=edit" role="button">' . $langs->trans('Modify') . '</a>';
849 }
850 }
851 $html .= '</div>' . "\n";
852 }
853 }
854
855 return $html;
856 }
857}
$object ref
Definition info.php:79
static getInstance()
Singleton method to create one instance of this object.
Class to manage generation of HTML components Only common components for WebPortal must be here.
header($context)
Html for header.
elementCard($context)
Card for an element in the page context.
bodyEdit()
Html for body (edit mode)
init($elementEn, $id=0, $permissiontoread=0, $permissiontoadd=0, $permissiontodelete=0, $permissionnote=0, $permissiondellink=0)
Init.
bodyView($keyforbreak='')
Html for body (view mode)
Class to manage generation of HTML components Only common components must be here.
Class to manage generation of HTML components Only common components for WebPortal must be here.
verifCond($strToEvaluate, $onlysimplestring='1')
Verify if condition in string is ok or not.
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...
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 '.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
$context
@method int call_trigger(string $triggerName, User $user)
Definition logout.php:42
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.