/
commonfields_add.tpl.php
118 lines (111 loc) · 3.74 KB
/
commonfields_add.tpl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Need to have following variables defined:
* $object (invoice, order, ...)
* $action
* $conf
* $langs
* $form
*/
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) {
print "Error, template page can't be called as URL";
exit(1);
}
?>
<!-- BEGIN PHP TEMPLATE commonfields_add.tpl.php -->
<?php
$object->fields = dol_sort_array($object->fields, 'position');
foreach ($object->fields as $key => $val) {
// Discard if field is a hidden field on form
// Ensure $val['visible'] is treated as an integer
$visible = (int) $val['visible'];
if (abs($visible) != 1 && abs($visible) != 3) {
continue;
}
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
continue; // We don't want this field
}
print '<tr class="field_'.$key.'">';
print '<td';
print ' class="titlefieldcreate';
if (isset($val['notnull']) && $val['notnull'] > 0) {
print ' fieldrequired';
}
if ($val['type'] == 'text' || $val['type'] == 'html') {
print ' tdtop';
}
print '"';
print '>';
if (!empty($val['help'])) {
print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
} else {
print $langs->trans($val['label']);
}
print '</td>';
print '<td class="valuefieldcreate">';
if (!empty($val['picto'])) {
print img_picto('', $val['picto'], '', false, 0, 0, '', 'pictofixedwidth');
}
if (in_array($val['type'], array('int', 'integer'))) {
$value = GETPOSTINT($key);
} elseif ($val['type'] == 'double') {
$value = price2num(GETPOST($key, 'alphanohtml'));
} elseif (preg_match('/^text/', $val['type'])) {
$tmparray = explode(':', $val['type']);
if (!empty($tmparray[1])) {
$check = $tmparray[1];
} else {
$check = 'nohtml';
}
$value = GETPOST($key, $check);
} elseif (preg_match('/^html/', $val['type'])) {
$tmparray = explode(':', $val['type']);
if (!empty($tmparray[1])) {
$check = $tmparray[1];
} else {
$check = 'restricthtml';
}
$value = GETPOST($key, $check);
} elseif ($val['type'] == 'date') {
$value = dol_mktime(12, 0, 0, GETPOSTINT($key.'month'), GETPOSTINT($key.'day'), GETPOSTINT($key.'year'));
} elseif ($val['type'] == 'datetime') {
$value = dol_mktime(GETPOSTINT($key.'hour'), GETPOSTINT($key.'min'), 0, GETPOSTINT($key.'month'), GETPOSTINT($key.'day'), GETPOSTINT($key.'year'));
} elseif ($val['type'] == 'boolean') {
$value = (GETPOST($key) == 'on' ? 1 : 0);
} elseif ($val['type'] == 'price') {
$value = price2num(GETPOST($key));
} elseif ($key == 'lang') {
$value = GETPOST($key, 'aZ09');
} else {
$value = GETPOST($key, 'alphanohtml');
}
if (!empty($val['noteditable'])) {
print $object->showOutputField($val, $key, $value, '', '', '', 0);
} else {
if ($key == 'lang') {
print img_picto('', 'language', 'class="pictofixedwidth"');
print $formadmin->select_language($value, $key, 0, null, 1, 0, 0, 'minwidth300', 2);
} else {
print $object->showInputField($val, $key, $value, '', '', '', 0);
}
}
print '</td>';
print '</tr>';
}
?>
<!-- END PHP TEMPLATE commonfields_add.tpl.php -->