dolibarr 22.0.5
commonfields_edit.tpl.php
1<?php
2/* Copyright (C) 2017-2019 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Need to have the following variables defined:
20 * $object (invoice, order, ...)
21 * $action
22 * $conf
23 * $langs
24 * $form
25 */
26
38// Protection to avoid direct call of template
39if (empty($conf) || !is_object($conf)) {
40 print "Error, template page can't be called as URL";
41 exit(1);
42}
43if (!is_object($form)) {
44 $form = new Form($db);
45}
46
47?>
48<!-- BEGIN PHP TEMPLATE commonfields_edit.tpl.php -->
49<?php
50
51$object->fields = dol_sort_array($object->fields, 'position');
52
53foreach ($object->fields as $key => $val) {
54 // Discard if extrafield is a hidden field on form
55 if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) {
56 continue;
57 }
58
59 if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
60 continue; // We don't want this field
61 }
62
63 print '<tr class="field_'.$key.'"><td';
64 print ' class="titlefieldcreate';
65 if (isset($val['notnull']) && $val['notnull'] > 0) {
66 print ' fieldrequired';
67 }
68 if (preg_match('/^(text|html)/', $val['type'])) {
69 print ' tdtop';
70 }
71 print '">';
72 if (!empty($val['help'])) {
73 print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
74 } else {
75 print $langs->trans($val['label']);
76 }
77 print '</td>';
78 print '<td class="valuefieldcreate">';
79
80 if (!empty($val['picto'])) {
81 print img_picto('', $val['picto'], '', 0, 0, 0, '', 'pictofixedwidth');
82 }
83
84 if (in_array($val['type'], array('int', 'integer'))) {
85 $value = GETPOSTISSET($key) ? GETPOSTINT($key) : $object->$key;
86 } elseif ($val['type'] == 'double') {
87 $value = GETPOSTISSET($key) ? price2num(GETPOST($key, 'alphanohtml')) : $object->$key;
88 } elseif (preg_match('/^text/', $val['type'])) {
89 $tmparray = explode(':', $val['type']);
90 if (!empty($tmparray[1])) {
91 $check = $tmparray[1];
92 } else {
93 $check = 'nohtml';
94 }
95 $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
96 } elseif (preg_match('/^html/', $val['type'])) {
97 $tmparray = explode(':', $val['type']);
98 if (!empty($tmparray[1])) {
99 $check = $tmparray[1];
100 } else {
101 $check = 'restricthtml';
102 }
103 $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
104 } elseif (in_array($val['type'], array('date', 'datetime'))) {
105 $value = GETPOSTISSET($key) ? dol_mktime(GETPOSTINT($key.'hour'), GETPOSTINT($key.'min'), GETPOSTINT($key.'sec'), GETPOSTINT($key.'month'), GETPOSTINT($key.'day'), GETPOSTINT($key.'year')) : $object->$key;
106 } elseif ($val['type'] == 'price') {
107 $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key);
108 } elseif ($key == 'lang') {
109 // @phan-suppress-next-line PhanUndeclaredProperty
110 $value = GETPOSTISSET($key) ? GETPOST($key, 'aZ09') : $object->lang;
111 } else {
112 $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key;
113 }
114 //var_dump($val.' '.$key.' '.$value);
115 if (!empty($val['noteditable'])) {
116 print $object->showOutputField($val, $key, $value, '', '', '', 0);
117 } else {
118 if ($key == 'lang') {
119 print img_picto('', 'language', 'class="pictofixedwidth"');
120 print $formadmin->select_language($value, $key, 0, array(), 1, 0, 0, 'minwidth300', 2);
121 } else {
122 print $object->showInputField($val, $key, $value, '', '', '', 0);
123 }
124 }
125 print '</td>';
126 print '</tr>';
127}
128
129?>
130<!-- END PHP TEMPLATE commonfields_edit.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
Class to manage generation of HTML components Only common components 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...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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_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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79