dolibarr  13.0.2
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  */
23 
24 // Protection to avoid direct call of template
25 if (empty($conf) || !is_object($conf))
26 {
27  print "Error, template page can't be called as URL";
28  exit;
29 }
30 if (!is_object($form)) $form = new Form($db);
31 
32 ?>
33 <!-- BEGIN PHP TEMPLATE commonfields_edit.tpl.php -->
34 <?php
35 
36 $object->fields = dol_sort_array($object->fields, 'position');
37 
38 foreach ($object->fields as $key => $val)
39 {
40  // Discard if extrafield is a hidden field on form
41  if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4) continue;
42 
43  if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field
44 
45  print '<tr><td';
46  print ' class="titlefieldcreate';
47  if ($val['notnull'] > 0) print ' fieldrequired';
48  if (preg_match('/^(text|html)/', $val['type'])) print ' tdtop';
49  print '">';
50  if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
51  else print $langs->trans($val['label']);
52  print '</td>';
53  print '<td>';
54  if (!empty($val['picto'])) { print img_picto('', $val['picto']); }
55  if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key) ?GETPOST($key, 'int') : $object->$key;
56  elseif (preg_match('/^(text|html)/', $val['type'])) {
57  $tmparray = explode(':', $val['type']);
58  if (!empty($tmparray[1])) {
59  $check = $tmparray[1];
60  } else {
61  $check = 'restricthtml';
62  }
63  $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key;
64  }
65  else $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key;
66  //var_dump($val.' '.$key.' '.$value);
67  if ($val['noteditable']) print $object->showOutputField($val, $key, $value, '', '', '', 0);
68  else print $object->showInputField($val, $key, $value, '', '', '', 0);
69  print '</td>';
70  print '</tr>';
71 }
72 
73 ?>
74 <!-- END PHP TEMPLATE commonfields_edit.tpl.php -->
verifCond($strRights)
Verify if condition in string is ok or not.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
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...
print
Draft customers invoices.
Definition: index.php:89