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