dolibarr  16.0.5
commonfields_edit.tpl.php
1 <?php
2 /* Copyright (C) 2017-2019 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
26 if (empty($conf) || !is_object($conf)) {
27  print "Error, template page can't be called as URL";
28  exit;
29 }
30 if (!is_object($form)) {
31  $form = new Form($db);
32 }
33 
34 ?>
35 <!-- BEGIN PHP TEMPLATE commonfields_edit.tpl.php -->
36 <?php
37 
38 $object->fields = dol_sort_array($object->fields, 'position');
39 
40 foreach ($object->fields as $key => $val) {
41  // Discard if extrafield is a hidden field on form
42  if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) {
43  continue;
44  }
45 
46  if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
47  continue; // We don't want this field
48  }
49 
50  print '<tr class="field_'.$key.'"><td';
51  print ' class="titlefieldcreate';
52  if (isset($val['notnull']) && $val['notnull'] > 0) {
53  print ' fieldrequired';
54  }
55  if (preg_match('/^(text|html)/', $val['type'])) {
56  print ' tdtop';
57  }
58  print '">';
59  if (!empty($val['help'])) {
60  print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
61  } else {
62  print $langs->trans($val['label']);
63  }
64  print '</td>';
65  print '<td class="valuefieldcreate">';
66 
67  if (!empty($val['picto'])) {
68  print img_picto('', $val['picto'], '', false, 0, 0, '', 'pictofixedwidth');
69  }
70 
71  if (in_array($val['type'], array('int', 'integer'))) {
72  $value = GETPOSTISSET($key) ?GETPOST($key, 'int') : $object->$key;
73  } elseif ($val['type'] == 'double') {
74  $value = GETPOSTISSET($key) ? price2num(GETPOST($key, 'alphanohtml')) : $object->$key;
75  } elseif (preg_match('/^(text|html)/', $val['type'])) {
76  $tmparray = explode(':', $val['type']);
77  if (!empty($tmparray[1])) {
78  $check = $tmparray[1];
79  } else {
80  $check = 'restricthtml';
81  }
82  $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
83  } elseif (in_array($val['type'], array('date', 'datetime'))) {
84  $value = GETPOSTISSET($key) ? dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')) : $object->$key;
85  } elseif ($val['type'] == 'price') {
86  $value = GETPOSTISSET($key) ? price2num(GETPOST($key)) : price2num($object->$key);
87  } elseif ($key == 'lang') {
88  $value = GETPOSTISSET($key) ? GETPOST($key, 'aZ09') : $object->lang;
89  } else {
90  $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key;
91  }
92  //var_dump($val.' '.$key.' '.$value);
93  if (!empty($val['noteditable'])) {
94  print $object->showOutputField($val, $key, $value, '', '', '', 0);
95  } else {
96  if ($key == 'lang') {
97  print img_picto('', 'language', 'class="pictofixedwidth"');
98  print $formadmin->select_language($value, $key, 0, null, 1, 0, 0, 'minwidth300', 2);
99  } else {
100  print $object->showInputField($val, $key, $value, '', '', '', 0);
101  }
102  }
103  print '</td>';
104  print '</tr>';
105 }
106 
107 ?>
108 <!-- END PHP TEMPLATE commonfields_edit.tpl.php -->
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_sort_array
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
Definition: functions.lib.php:8385
verifCond
verifCond($strToEvaluate)
Verify if condition in string is ok or not.
Definition: functions.lib.php:8582
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757