dolibarr  9.0.0
commonfields_view.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 <http://www.gnu.org/licenses/>.
16  *
17  * Need to have following variables defined:
18  * $object (invoice, order, ...)
19  * $action
20  * $conf
21  * $langs
22  *
23  * $keyforbreak may be defined to key to switch on second column
24  */
25 
26 // Protection to avoid direct call of template
27 if (empty($conf) || ! is_object($conf))
28 {
29  print "Error, template page can't be called as URL";
30  exit;
31 }
32 if (! is_object($form)) $form=new Form($db);
33 
34 ?>
35 <!-- BEGIN PHP TEMPLATE commonfields_view.tpl.php -->
36 <?php
37 
38 $object->fields = dol_sort_array($object->fields, 'position');
39 
40 foreach($object->fields as $key => $val)
41 {
42  // Discard if extrafield is a hidden field on form
43  if (abs($val['visible']) != 1) continue;
44 
45  if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) continue; // We don't want this field
46  if (in_array($key, array('ref','status'))) continue; // Ref and status are already in dol_banner
47 
48  $value=$object->$key;
49 
50  print '<tr><td';
51  print ' class="titlefield';
52  if ($val['notnull'] > 0) print ' fieldrequired';
53  if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop';
54  print '">';
55  if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $val['help']);
56  else print $langs->trans($val['label']);
57  print '</td>';
58  print '<td>';
59  print $object->showOutputField($val, $key, $value, '', '', '', 0);
60  //print dol_escape_htmltag($object->$key, 1, 1);
61  print '</td>';
62  print '</tr>';
63 
64  if (! empty($keyforbreak) && $key == $keyforbreak) break; // key used for break on second column
65 }
66 
67 print '</table>';
68 print '</div>';
69 print '<div class="fichehalfright">';
70 print '<div class="ficheaddleft">';
71 print '<div class="underbanner clearboth"></div>';
72 print '<table class="border centpercent">';
73 
74 $alreadyoutput = 1;
75 foreach($object->fields as $key => $val)
76 {
77  if ($alreadyoutput)
78  {
79  if (! empty($keyforbreak) && $key == $keyforbreak) $alreadyoutput = 0; // key used for break on second column
80  continue;
81  }
82 
83  if (abs($val['visible']) != 1) continue; // Discard such field from form
84  if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
85  if (in_array($key, array('ref','status'))) continue; // Ref and status are already in dol_banner
86 
87  $value=$object->$key;
88 
89  print '<tr><td';
90  print ' class="titlefield';
91  if ($val['notnull'] > 0) print ' fieldrequired';
92  if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop';
93  print '">';
94  if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $val['help']);
95  else print $langs->trans($val['label']);
96  print '</td>';
97  print '<td>';
98  print $object->showOutputField($val, $key, $value, '', '', '', 0);
99  //print dol_escape_htmltag($object->$key, 1, 1);
100  print '</td>';
101  print '</tr>';
102 }
103 
104 ?>
105 <!-- END PHP TEMPLATE commonfields_view.tpl.php -->
verifCond($strRights)
Verify if condition in string is ok or not.
print
Draft customers invoices.
Definition: index.php:91
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...
Class to manage generation of HTML components Only common components must be here.