dolibarr  13.0.2
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 <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  * $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  if (!empty($keyforbreak) && $key == $keyforbreak) break; // key used for break on second column
43 
44  // Discard if extrafield is a hidden field on form
45  if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) continue;
46 
47  if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field
48  if (in_array($key, array('ref', 'status'))) continue; // Ref and status are already in dol_banner
49 
50  $value = $object->$key;
51 
52  print '<tr><td';
53  print ' class="titlefield fieldname_'.$key;
54  //if ($val['notnull'] > 0) print ' fieldrequired'; // No fieldrequired on the view output
55  if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop';
56  print '">';
57  if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
58  else print $langs->trans($val['label']);
59  print '</td>';
60  print '<td class="valuefield fieldname_'.$key;
61  if ($val['type'] == 'text') print ' wordbreak';
62  if ($val['cssview']) print ' '.$val['cssview'];
63  print '">';
64  if (in_array($val['type'], array('text', 'html'))) print '<div class="longmessagecut">';
65  print $object->showOutputField($val, $key, $value, '', '', '', 0);
66  //print dol_escape_htmltag($object->$key, 1, 1);
67  if (in_array($val['type'], array('text', 'html'))) print '</div>';
68  print '</td>';
69  print '</tr>';
70 }
71 
72 print '</table>';
73 
74 // We close div and reopen for second column
75 print '</div>';
76 print '<div class="fichehalfright">';
77 
78 print '<div class="underbanner clearboth"></div>';
79 print '<table class="border centpercent tableforfield">';
80 
81 $alreadyoutput = 1;
82 foreach ($object->fields as $key => $val)
83 {
84  if ($alreadyoutput)
85  {
86  if (!empty($keyforbreak) && $key == $keyforbreak) {
87  $alreadyoutput = 0; // key used for break on second column
88  } else {
89  continue;
90  }
91  }
92 
93  // Discard if extrafield is a hidden field on form
94  if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) continue;
95 
96  if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) continue; // We don't want this field
97  if (in_array($key, array('ref', 'status'))) continue; // Ref and status are already in dol_banner
98 
99  $value = $object->$key;
100 
101  print '<tr><td';
102  print ' class="titlefield fieldname_'.$key;
103  //if ($val['notnull'] > 0) print ' fieldrequired'; // No fieldrequired inthe view output
104  if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop';
105  print '">';
106  if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
107  else print $langs->trans($val['label']);
108  print '</td>';
109  print '<td class="valuefield fieldname_'.$key;
110  if ($val['type'] == 'text') print ' wordbreak';
111  if ($val['cssview']) print ' '.$val['cssview'];
112  print '">';
113  if (in_array($val['type'], array('text', 'html'))) print '<div class="longmessagecut">';
114  print $object->showOutputField($val, $key, $value, '', '', '', 0);
115  //print dol_escape_htmltag($object->$key, 1, 1);
116  if (in_array($val['type'], array('text', 'html'))) print '</div>';
117  print '</td>';
118  print '</tr>';
119 }
120 
121 ?>
122 <!-- END PHP TEMPLATE commonfields_view.tpl.php -->
verifCond($strRights)
Verify if condition in string is ok or not.
Class to manage generation of HTML components Only common components must be here.
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