dolibarr  7.0.0-beta
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 
33 ?>
34 <!-- BEGIN PHP TEMPLATE commonfields_view.tpl.php -->
35 <?php
36 
37 $object->fields = dol_sort_array($object->fields, 'position');
38 
39 foreach($object->fields as $key => $val)
40 {
41  // Discard if extrafield is a hidden field on form
42  if (abs($val['visible']) != 1) continue;
43 
44  if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
45  if ($key == 'status') continue; // Status is already in dol_banner
46 
47  $value=$object->$key;
48 
49  print '<tr><td';
50  print ' class="titlefield';
51  if ($val['notnull'] > 0) print ' fieldrequired';
52  if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop';
53  print '"';
54  print '>'.$langs->trans($val['label']).'</td>';
55  print '<td>';
56  print $object->showOutputField($val, $key, $value, '', '', '', 0);
57  //print dol_escape_htmltag($object->$key, 1, 1);
58  print '</td>';
59  print '</tr>';
60 
61  if (! empty($keyforbreak) && $key == $keyforbreak) break; // key used for break on second column
62 }
63 
64 print '</table>';
65 print '</div>';
66 print '<div class="fichehalfright">';
67 print '<div class="ficheaddleft">';
68 print '<div class="underbanner clearboth"></div>';
69 print '<table class="border centpercent">';
70 
71 $alreadyoutput = 1;
72 foreach($object->fields as $key => $val)
73 {
74  if ($alreadyoutput)
75  {
76  if (! empty($keyforbreak) && $key == $keyforbreak) $alreadyoutput = 0; // key used for break on second column
77  continue;
78  }
79 
80  if (abs($val['visible']) != 1) continue; // Discard such field from form
81  if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
82  if ($key == 'status') continue; // Status is alreadt in dol_banner
83 
84  $value=$object->$key;
85 
86  print '<tr><td';
87  print ' class="titlefield';
88  if ($val['notnull'] > 0) print ' fieldrequired';
89  if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop';
90  print '"';
91  print '>'.$langs->trans($val['label']).'</td>';
92  print '<td>';
93  print $object->showOutputField($val, $key, $value, '', '', '', 0);
94  //print dol_escape_htmltag($object->$key, 1, 1);
95  print '</td>';
96  print '</tr>';
97 }
98 
99 ?>
100 <!-- END PHP TEMPLATE commonfields_view.tpl.php -->
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:91