dolibarr 21.0.0-alpha
commonfields_add.tpl.php
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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
27'@phan-var-force FormAdmin $formAdmin';
28
29// Protection to avoid direct call of template
30if (empty($conf) || !is_object($conf)) {
31 print "Error, template page can't be called as URL";
32 exit(1);
33}
34
35?>
36<!-- BEGIN PHP TEMPLATE commonfields_add.tpl.php -->
37<?php
38
39$object->fields = dol_sort_array($object->fields, 'position');
40
41foreach ($object->fields as $key => $val) {
42 // Discard if field is a hidden field on form
43 // Ensure $val['visible'] is treated as an integer
44 $visible = (int) $val['visible'];
45 if (abs($visible) != 1 && abs($visible) != 3) {
46 continue;
47 }
48
49 if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
50 continue; // We don't want this field
51 }
52
53 print '<tr class="field_'.$key.'">';
54 print '<td';
55 print ' class="titlefieldcreate';
56 if (isset($val['notnull']) && $val['notnull'] > 0) {
57 print ' fieldrequired';
58 }
59 if ($val['type'] == 'text' || $val['type'] == 'html') {
60 print ' tdtop';
61 }
62 print '"';
63 print '>';
64 if (!empty($val['help'])) {
65 print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
66 } else {
67 print $langs->trans($val['label']);
68 }
69 print '</td>';
70 print '<td class="valuefieldcreate">';
71 if (!empty($val['picto'])) {
72 print img_picto('', $val['picto'], '', 0, 0, 0, '', 'pictofixedwidth');
73 }
74 if (in_array($val['type'], array('int', 'integer'))) {
75 $value = GETPOSTINT($key);
76 } elseif ($val['type'] == 'double') {
77 $value = price2num(GETPOST($key, 'alphanohtml'));
78 } elseif (preg_match('/^text/', $val['type'])) {
79 $tmparray = explode(':', $val['type']);
80 if (!empty($tmparray[1])) {
81 $check = $tmparray[1];
82 } else {
83 $check = 'nohtml';
84 }
85 $value = GETPOST($key, $check);
86 } elseif (preg_match('/^html/', $val['type'])) {
87 $tmparray = explode(':', $val['type']);
88 if (!empty($tmparray[1])) {
89 $check = $tmparray[1];
90 } else {
91 $check = 'restricthtml';
92 }
93 $value = GETPOST($key, $check);
94 } elseif ($val['type'] == 'date') {
95 $value = dol_mktime(12, 0, 0, GETPOSTINT($key.'month'), GETPOSTINT($key.'day'), GETPOSTINT($key.'year'));
96 } elseif ($val['type'] == 'datetime') {
97 $value = dol_mktime(GETPOSTINT($key.'hour'), GETPOSTINT($key.'min'), 0, GETPOSTINT($key.'month'), GETPOSTINT($key.'day'), GETPOSTINT($key.'year'));
98 } elseif ($val['type'] == 'boolean') {
99 $value = (GETPOST($key) == 'on' ? 1 : 0);
100 } elseif ($val['type'] == 'price') {
101 $value = price2num(GETPOST($key));
102 } elseif ($key == 'lang') {
103 $value = GETPOST($key, 'aZ09');
104 } else {
105 $value = GETPOST($key, 'alphanohtml');
106 }
107 if (!empty($val['noteditable'])) {
108 print $object->showOutputField($val, $key, $value, '', '', '', 0);
109 } else {
110 if ($key == 'lang') {
111 print img_picto('', 'language', 'class="pictofixedwidth"');
112 print $formadmin->select_language($value, $key, 0, array(), 1, 0, 0, 'minwidth300', 2);
113 } else {
114 print $object->showInputField($val, $key, $value, '', '', '', 0);
115 }
116 }
117 print '</td>';
118 print '</tr>';
119}
120
121?>
122<!-- END PHP TEMPLATE commonfields_add.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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)
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.