dolibarr 22.0.5
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-2025 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
35{
39 public $action = '';
40
44 public $backtopage = '';
45
49 public $backtopageforcancel = '';
50
54 public $cancel = '';
55
59 public $db;
60
64 public $elementEn = '';
65
69 public $form;
70
74 public $id;
75
79 public $object;
80
84 public $permissiontoread = 0;
85
89 public $permissiontoadd = 0;
90
94 public $permissiontodelete = 0;
95
99 public $permissionnote = 0;
100
104 public $permissiondellink = 0;
105
109 public $ref;
110
114 public $titleKey = '';
115
119 public $titleDescKey = '';
120
126 public function __construct($db)
127 {
128 $this->db = $db;
129 $this->form = new FormWebPortal($this->db);
130 }
131
144 public function init($elementEn, $id = 0, $permissiontoread = 0, $permissiontoadd = 0, $permissiontodelete = 0, $permissionnote = 0, $permissiondellink = 0)
145 {
146 global $hookmanager, $langs;
147
148 $elementEnUpper = strtoupper($elementEn);
149 $objectclass = 'WebPortal' . ucfirst($elementEn);
150
151 $elementCardAccess = getDolGlobalString('WEBPORTAL_' . $elementEnUpper . '_CARD_ACCESS', 'hidden');
152 if ($elementCardAccess == 'hidden' || $id <= 0) {
154 }
155
156 // load module libraries
157 dol_include_once('/webportal/class/webportal' . $elementEn . '.class.php');
158
159 // Load translation files required by the page
160 $langs->loadLangs(array('website', 'other'));
161
162 // Get parameters
163 //$id = $id > 0 ? $id : GETPOST('id', 'int');
164 $ref = GETPOST('ref', 'alpha');
165 $action = GETPOST('action', 'aZ09');
166 $confirm = GETPOST('confirm', 'alpha');
167 $cancel = GETPOST('cancel');
168 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'webportal' . $elementEn . 'card'; // To manage different context of search
169 $backtopage = GETPOST('backtopage', 'alpha'); // if not set, a default page will be used
170 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // if not set, $backtopage will be used
171
172 // Initialize a technical objects
173 $object = new $objectclass($this->db);
174 //$extrafields = new ExtraFields($db);
175 $hookmanager->initHooks(array('webportal' . $elementEn . 'card', 'globalcard')); // Note that conf->hooks_modules contains array
176
177 // Fetch optionals attributes and labels
178 //$extrafields->fetch_name_optionals_label($object->table_element);
179 //$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
180
181 if (empty($action) && empty($id) && empty($ref)) {
182 $action = 'view';
183 }
184
185 // Load object
186 include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
187
188 // Security check (enable the most restrictive one)
189 if (!isModEnabled('webportal')) {
191 }
192 if (!$permissiontoread) {
194 }
195
196 // set form card
197 $this->action = $action;
198 $this->backtopage = $backtopage;
199 $this->backtopageforcancel = $backtopageforcancel;
200 $this->cancel = $cancel;
201 $this->elementEn = $elementEn;
202 $this->id = (int) $id;
203 $this->object = $object;
204 $this->permissiontoread = $permissiontoread;
205 $this->permissiontoadd = $permissiontoadd;
206 $this->permissiontodelete = $permissiontodelete;
207 $this->permissionnote = $permissionnote;
208 $this->permissiondellink = $permissiondellink;
209 $this->titleKey = $objectclass . 'CardTitle';
210 $this->ref = $ref;
211 }
212
218 public function doActions()
219 {
220 global $langs;
221
222 // initialize
223 $action = $this->action;
224 $backtopage = $this->backtopage;
225 $backtopageforcancel = $this->backtopageforcancel;
226 $cancel = $this->cancel;
227 $elementEn = $this->elementEn;
228 $id = $this->id;
229 $object = $this->object;
230 //$permissiontoread = $this->permissiontoread;
231 $permissiontoadd = $this->permissiontoadd;
232
233 $error = 0;
234
236
237 $backurlforlist = $context->getControllerUrl('default');
238 $noback = 1;
239
240 if (empty($backtopage) || ($cancel && empty($id))) {
241 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
242 $backtopage = $context->getControllerUrl($elementEn . 'card');
243 }
244 }
245
246 // Action to cancel record
247 if ($cancel) {
248 if (!empty($backtopageforcancel)) {
249 header("Location: " . $backtopageforcancel);
250 exit;
251 } elseif (!empty($backtopage)) {
252 header("Location: " . $backtopage);
253 exit;
254 }
255 $action = '';
256 }
257
258 // Action to update record
259 if ($action == 'update' && !empty($permissiontoadd)) {
260 foreach ($object->fields as $key => $val) {
261 // Check if field was submitted to be edited
262 if ($object->fields[$key]['type'] == 'duration') {
263 if (!GETPOSTISSET($key . 'hour') || !GETPOSTISSET($key . 'min')) {
264 continue; // The field was not submitted to be saved
265 }
266 } elseif ($object->fields[$key]['type'] == 'boolean') {
267 if (!GETPOSTISSET($key)) {
268 $object->$key = 0; // use 0 instead null if the field is defined as not null
269 continue;
270 }
271 } else {
272 if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type']) && $object->fields[$key]['type'] !== 'checkbox') {
273 continue; // The field was not submitted to be saved
274 }
275 }
276 // Ignore special fields
277 if (in_array($key, array('rowid', 'entity', 'import_key'))) {
278 continue;
279 }
280 if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) {
281 if (!in_array(abs($val['visible']), array(1, 3, 4))) {
282 continue; // Only 1 and 3 and 4, that are cases to update
283 }
284 }
285
286 // Set value to update
287 if (preg_match('/^text/', $object->fields[$key]['type'])) {
288 $tmparray = explode(':', $object->fields[$key]['type']);
289 if (!empty($tmparray[1])) {
290 $value = GETPOST($key, $tmparray[1]);
291 } else {
292 $value = GETPOST($key, 'nohtml');
293 }
294 } elseif (preg_match('/^html/', $object->fields[$key]['type'])) {
295 $tmparray = explode(':', $object->fields[$key]['type']);
296 if (!empty($tmparray[1])) {
297 $value = GETPOST($key, $tmparray[1]);
298 } else {
299 $value = GETPOST($key, 'restricthtml');
300 }
301 } elseif (in_array($object->fields[$key]['type'], array('date', 'datetime'))) {
302 $postDate = GETPOST($key, 'alphanohtml');
303 // extract date YYYY-MM-DD for year, month and day
304 $dateArr = explode('-', $postDate);
305 $dateYear = 0;
306 $dateMonth = 0;
307 $dateDay = 0;
308 if (count($dateArr) == 3) {
309 $dateYear = (int) $dateArr[0];
310 $dateMonth = (int) $dateArr[1];
311 $dateDay = (int) $dateArr[2];
312 }
313 // extract time HH:ii:ss for hours, minutes and seconds
314 $postTime = GETPOST($key . '_time', 'alphanohtml');
315 $timeArr = explode(':', $postTime);
316 $timeHours = 12;
317 $timeMinutes = 0;
318 $timeSeconds = 0;
319 if (!empty($timeArr)) {
320 if (isset($timeArr[0])) {
321 $timeHours = (int) $timeArr[0];
322 }
323 if (isset($timeArr[1])) {
324 $timeMinutes = (int) $timeArr[1];
325 }
326 if (isset($timeArr[2])) {
327 $timeSeconds = (int) $timeArr[2];
328 }
329 }
330 $value = dol_mktime($timeHours, $timeMinutes, $timeSeconds, $dateMonth, $dateDay, $dateYear);
331 } elseif ($object->fields[$key]['type'] == 'duration') {
332 if (GETPOSTINT($key . 'hour') != '' || GETPOSTINT($key . 'min') != '') {
333 $value = 60 * 60 * GETPOSTINT($key . 'hour') + 60 * GETPOSTINT($key . 'min');
334 } else {
335 $value = '';
336 }
337 } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
338 $value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup
339 } elseif ($object->fields[$key]['type'] == 'boolean') {
340 $value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0);
341 //}
342 //elseif ($object->fields[$key]['type'] == 'reference') {
343 // $value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2');
344 } elseif (preg_match('/^chkbxlst:/', $object->fields[$key]['type']) || $object->fields[$key]['type'] == 'checkbox') {
345 $value = '';
346 $values_arr = GETPOST($key, 'array');
347 if (!empty($values_arr)) {
348 $value = implode(',', $values_arr);
349 }
350 } else {
351 if ($key == 'lang') {
352 $value = GETPOST($key, 'aZ09');
353 } else {
354 $value = GETPOST($key, 'alphanohtml');
355 }
356 }
357 if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
358 $value = ''; // This is an implicit foreign key field
359 }
360 if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') {
361 $value = ''; // This is an explicit foreign key field
362 }
363
364 $object->$key = $value;
365 if (!empty($val['notnull']) && $val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) {
366 $error++;
367 $context->setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors');
368 }
369
370 // Validation of fields values
371 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 || getDolGlobalString('MAIN_ACTIVATE_VALIDATION_RESULT')) {
372 if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) {
373 if (!$object->validateField($object->fields, $key, $value)) {
374 $error++;
375 }
376 }
377 }
378
379 if (isModEnabled('category')) {
380 $categories = GETPOST('categories', 'array');
381 if (method_exists($object, 'setCategories')) {
382 $object->setCategories($categories);
383 }
384 }
385 }
386
387 // Fill array 'array_options' with data from add form
388 //if (!$error) {
389 // $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
390 // if ($ret < 0) {
391 // $error++;
392 // }
393 //}
394
395 if (!$error) {
396 $result = $object->update($context->logged_user);
397 if ($result >= 0) {
398 $action = 'view';
399 $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
400 $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', (string) $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
401 if ($urltogo && empty($noback)) {
402 header("Location: " . $urltogo);
403 exit;
404 }
405 } else {
406 $error++;
407 // Creation KO
408 $context->setEventMessages($object->error, $object->errors, 'errors');
409 $action = 'edit';
410 }
411 } else {
412 $action = 'edit';
413 }
414 }
415
416 $this->object = $object;
417 $this->action = $action;
418 }
419
426 protected function header($context)
427 {
428 global $langs;
429
430 $html = '';
431
432 // initialize
433 $object = $this->object;
434 $addgendertxt = '';
435 //if (property_exists($object, 'gender') && !empty($object->gender)) {
436 // switch ($object->gender) {
437 // case 'man':
438 // $addgendertxt .= '<i class="fas fa-mars"></i>';
439 // break;
440 // case 'woman':
441 // $addgendertxt .= '<i class="fas fa-venus"></i>';
442 // break;
443 // case 'other':
444 // $addgendertxt .= '<i class="fas fa-transgender"></i>';
445 // break;
446 // }
447 //}
448
449 $html .= '<!-- html.formcardwebportal.class.php -->';
450 $html .= '<header>';
451
452 // Left block - begin
453 $html .= '<div class="header-card-left-block inline-block" style="width: 75%;">';
454 $html .= '<div>';
455
456 // logo or photo
457 $form = new Form($this->db);
458 $html .= '<div class="inline-block floatleft valignmiddle">';
459 $html .= '<div class="floatleft inline-block valignmiddle divphotoref">';
460 $html .= $form->showphoto('memberphoto', $object, 0, 0, 0, 'photowithmargin photoref', 'small', 1, 0, 1);
461 //include DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
462 //$html .= getImagePublicURLOfObject($object, 1, '_small');
463 $html .= '</div>';
464 $html .= '</div>';
465
466 // main information - begin
467 $html .= '<div class="header-card-main-information inline-block valignmiddle">';
468 // ref
469 $html .= '<div><strong>' . $langs->trans("Ref").' : '.dol_escape_htmltag($object->ref) . '</strong></div>';
470 // full name
471 $fullname = '';
472 if (method_exists($object, 'getFullName')) {
473 $fullname = $object->getFullName($langs);
474 }
475 $html .= '<div><strong>';
476 if ($object->element == 'member') {
477 '@phan-var-force Adherent $object';
478 if ($object->morphy == 'mor' && !empty($object->societe)) {
479 $html .= dol_htmlentities((string) $object->societe);
480 $html .= (!empty($fullname) && $object->societe != $fullname) ? ' (' . dol_htmlentities($fullname) . $addgendertxt . ')' : '';
481 } else {
482 $html .= dol_htmlentities($fullname) . $addgendertxt;
483 if (empty($object->fk_soc)) {
484 $html .= (!empty($object->societe) && $object->societe != $fullname) ? ' (' . dol_htmlentities((string) $object->societe) . ')' : '';
485 }
486 }
487 } else {
488 $html .= dol_htmlentities(!empty($object->ref) ? $object->ref : '');
489 }
490 $html .= '</strong></div>';
491 // address
492 if (method_exists($object, 'getBannerAddressForWebPortal')) {
493 $moreaddress = $object->getBannerAddressForWebPortal('refaddress');
494 if ($moreaddress) {
495 $html .= '<div class="refidno refaddress">';
496 $html .= $moreaddress;
497 $html .= '</div>';
498 }
499 }
500 $html .= '</div>';
501 // main information - end
502
503 $html .= '</div>';
504 $html .= '</div>';
505 // Left block - end
506
507 // Right block - begin
508 $html .= '<div class="header-card-right-block inline-block" style="width: 24%;">';
509 // show status
510 $htmlStatus = $object->getLibStatut(6);
511 if (empty($htmlStatus) || $htmlStatus == $object->getLibStatut(3)) {
512 $htmlStatus = $object->getLibStatut(5);
513 }
514 $html .= $htmlStatus;
515 $html .= '</div>';
516 // Right block - end
517
518 $html .= '</header>';
519
520 return $html;
521 }
522
528 protected function bodyView($keyforbreak = '')
529 {
530 global $langs;
531
532 $html = '';
533
534 // initialize
535 $object = $this->object;
536
537 $object->fields = dol_sort_array($object->fields, 'position');
538
539 // separate fields to show on the left and on the right
540 $fieldShowList = array();
541 foreach ($object->fields as $key => $val) {
542 // discard if it's a hidden field on form
543 if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) {
544 continue;
545 }
546
547 if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
548 continue; // we don't want this field
549 }
550
551 if (!empty($val['showonheader'])) {
552 continue; // already on header
553 }
554
555 $fieldShowList[$key] = $val;
556 }
557
558 $nbFieldShow = count($fieldShowList);
559 $lastKeyFieldLeft = $keyforbreak;
560 $lastNumFieldLeft = 0;
561 if ($lastKeyFieldLeft == '') {
562 $lastNumFieldLeft = ceil($nbFieldShow / 2);
563 }
564 $numField = 0;
565 $html .= '<div class="grid">';
566 $html .= '<div class="card-left">';
567 foreach ($object->fields as $key => $val) {
568 if (!array_key_exists($key, $fieldShowList)) {
569 continue; // not to show
570 }
571
572 $value = $object->$key;
573
574 $html .= '<div class="grid field_' . $key . '">';
575
576 $html .= '<div class="' . (empty($val['tdcss']) ? '' : $val['tdcss']) . ' fieldname_' . $key;
577 $html .= '">';
578 $labeltoshow = '';
579 $labeltoshow .= '<strong>' . $langs->trans($val['label']) . '</strong>';
580 $html .= $labeltoshow;
581 $html .= '</div>';
582
583 $html .= '<div class="valuefield fieldname_' . $key;
584 if (!empty($val['cssview'])) {
585 $html .= ' ' . $val['cssview'];
586 }
587 $html .= '">';
588 if ($key == 'lang') {
589 $langs->load('languages');
590 $labellang = ($value ? $langs->trans('Language_' . $value) : '');
591 //$html .= picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"');
592 $html .= $labellang;
593 } else {
594 $html .= $this->form->showOutputFieldForObject($object, $val, $key, $value, '', '', '', 0);
595 }
596 $html .= '</div>';
597
598 $html .= '</div>';
599
600 $numField++;
601
602 // fields on the right
603 $cardRight = false;
604 if ($keyforbreak != '') {
605 if ($key == $keyforbreak) {
606 $cardRight = true;
607 }
608 } else {
609 if ($numField == $lastNumFieldLeft) {
610 $cardRight = true;
611 }
612 }
613 if ($cardRight) {
614 $html .= '</div>';
615 $html .= '<div class="card-right">';
616 }
617 }
618 $html .= '</div>';
619 $html .= '</div>';
620
621 return $html;
622 }
623
629 protected function bodyEdit()
630 {
631 global $langs;
632
633 $html = '';
634
635 // initialize
636 $object = $this->object;
637
638 $object->fields = dol_sort_array($object->fields, 'position');
639
640 foreach ($object->fields as $key => $val) {
641 // Discard if filed is a hidden field on form
642 if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) {
643 continue;
644 }
645
646 if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
647 continue; // We don't want this field
648 }
649
650 $html .= '<div class="grid field_' . $key . '">';
651 $html .= '<div class="titlefieldcreate';
652 if (isset($val['notnull']) && $val['notnull'] > 0) {
653 $html .= ' required';
654 }
655 $html .= '">';
656 $html .= $langs->trans($val['label']);
657 $html .= '</div>';
658
659 $html .= '<div class="valuefieldcreate">';
660 if (in_array($val['type'], array('int', 'integer'))) {
661 $value = GETPOSTISSET($key) ? GETPOSTINT($key) : $object->$key;
662 } elseif ($val['type'] == 'double') {
663 $value = GETPOSTISSET($key) ? price2num(GETPOST($key, 'alphanohtml')) : $object->$key;
664 } elseif (preg_match('/^text/', $val['type'])) {
665 $tmparray = explode(':', $val['type']);
666 if (!empty($tmparray[1])) {
667 $check = $tmparray[1];
668 } else {
669 $check = 'nohtml';
670 }
671 $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
672 } elseif (preg_match('/^html/', $val['type'])) {
673 $tmparray = explode(':', $val['type']);
674 if (!empty($tmparray[1])) {
675 $check = $tmparray[1];
676 } else {
677 $check = 'restricthtml';
678 }
679 $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
680 } elseif (in_array($val['type'], array('date', 'datetime'))) {
681 $isPostDate = GETPOSTISSET($key);
682 $isPostTime = GETPOSTISSET($key . '_time');
683 if ($isPostDate) {
684 $postDate = GETPOST($key, 'alphanohtml');
685 if ($isPostTime) {
686 $postTime = GETPOST($key . '_time', 'alphanohtml') . ':00';
687 } else {
688 $postTime = '00:00:00';
689 }
690 $valueDateTimeStr = $postDate . ' ' . $postTime;
691 } else {
692 // format date timestamp to YYYY-MM-DD HH:ii:ss
693 $valueDateTimeStr = dol_print_date($object->$key, '%Y-%m-%d %H:%M:%S');
694 }
695
696 $value = $valueDateTimeStr;
697 } elseif ($val['type'] == 'price') {
698 $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key);
699 } elseif ($key == 'lang') {
700 $value = GETPOSTISSET($key) ? GETPOST($key, 'aZ09') : $object->lang;
701 } else {
702 $value = GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : $object->$key;
703 }
704
705 if (!empty($val['noteditable'])) {
706 $html .= $this->form->showOutputFieldForObject($object, $val, $key, $value, '', '', '', 0);
707 //$html .= $object->showOutputFieldForObject($object, $val, $key, $value, '', '', '', 0);
708 } else {
709 $html .= $this->form->showInputFieldForObject($object, $val, $key, $value, '', '', '', '');
710 //$html .= $object->showInputField($val, $key, $value, '', '', '', '');
711 }
712 $html .= '</div>';
713 $html .= '</div>';
714 }
715
716 return $html;
717 }
718
724 protected function footer()
725 {
726 $html = '';
727 $html .= '<footer>';
728 $html .= '</footer>';
729
730 return $html;
731 }
732
739 public function elementCard($context)
740 {
741 global $hookmanager, $langs;
742
743 $html = '<!-- elementCard -->';
744
745 // initialize
746 $action = $this->action;
747 $backtopage = $this->backtopage;
748 $backtopageforcancel = $this->backtopageforcancel;
749 //$elementEn = $this->elementEn;
750 $id = $this->id;
751 $object = $this->object;
752 //$permissiontoread = $this->permissiontoread;
753 $permissiontoadd = $this->permissiontoadd;
754 $ref = $this->ref;
755 $titleKey = $this->titleKey;
756 $title = $langs->trans($titleKey);
757
758 // Part to edit record
759 if (($id || $ref) && $action == 'edit') {
760 $html .= '<article>';
761 //$html .= load_fiche_titre($title, '', 'object_'.$object->picto);
762 $html .= '<header>';
763 $html .= '<h2>' . $title . '</h2>';
764 $html .= '</header>';
765
766 $url_file = $context->getControllerUrl($context->controller, '', false);
767 $html .= '<form method="POST" action="' . $url_file . '">';
768 $html .= $context->getFormToken();
769 $html .= '<input type="hidden" name="action" value="update">';
770 $html .= '<input type="hidden" name="id" value="' . $object->id . '">';
771 if ($backtopage) {
772 $html .= '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
773 }
774 if ($backtopageforcancel) {
775 $html .= '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
776 }
777
778 //$html .= '<table>'."\n";
779 // Common attributes
780 //include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
781 $html .= $this->bodyEdit();
782
783 // Other attributes
784 //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
785 //$html .= '</table>';
786
787 // Save and Cancel buttons
788 $html .= '<div class="grid">';
789 $html .= '<div><input type="submit" name="save" role="button" value="' . dol_escape_htmltag($langs->trans('Save')) . '" /></div>';
790 $html .= '<div><input type="submit" name="cancel" role="button" value="' . dol_escape_htmltag($langs->trans('Cancel')) . '" /></div>';
791 $html .= '</div>';
792
793 $html .= '</form>';
794 $html .= '</article>';
795 }
796
797 // Part to show record
798 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
799 $html .= '<article>';
800
801 $formconfirm = '';
802
803 // Call Hook formConfirm
804 $parameters = array('formConfirm' => $formconfirm);
805 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
806 if (empty($reshook)) {
807 $formconfirm .= $hookmanager->resPrint;
808 } elseif ($reshook > 0) {
809 $formconfirm = $hookmanager->resPrint;
810 }
811
812 // Print form confirm
813 $html .= $formconfirm;
814
815 // Object card
816 // ------------------------------------------------------------
817 $html .= $this->header($context);
818
819 // Common attributes
820 $keyforbreak = '';
821 $html .= $this->bodyView($keyforbreak);
822
823 // Other attributes. Fields from hook formObjectOptions and Extrafields.
824 //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
825
826 //$html .= $this->footer();
827 $html .= '</article>';
828
829 // Buttons for actions
830 if ($action != 'presend' && $action != 'editline') {
831 $html .= '<div>' . "\n";
832 $parameters = array();
833 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
834 if ($reshook < 0) {
835 $context->setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
836 }
837
838 if (empty($reshook)) {
839 if ($permissiontoadd) {
840 $url_file = $context->getControllerUrl($context->controller, '', false);
841 $html .= '<a href="' . $url_file . '&id=' . $object->id . '&action=edit" role="button">' . $langs->trans('Modify') . '</a>';
842 }
843 }
844 $html .= '</div>' . "\n";
845 }
846 }
847
848 return $html;
849 }
850}
$object ref
Definition info.php:90
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.