dolibarr/htdocs/core/tpl/commonfields_view.tpl.php

183 lines
5.5 KiB
PHP
Raw Normal View History

<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Need to have following variables defined:
* $object (invoice, order, ...)
* $action
* $conf
* $langs
2017-12-09 20:40:11 +01:00
*
* $keyforbreak may be defined to key to switch on second column
*/
// Protection to avoid direct call of template
2021-02-23 22:03:23 +01:00
if (empty($conf) || !is_object($conf)) {
print "Error, template page can't be called as URL";
exit;
}
2021-02-23 22:03:23 +01:00
if (!is_object($form)) {
$form = new Form($db);
}
?>
<!-- BEGIN PHP TEMPLATE commonfields_view.tpl.php -->
<?php
2018-01-15 18:05:15 +01:00
$object->fields = dol_sort_array($object->fields, 'position');
2021-02-23 22:03:23 +01:00
foreach ($object->fields as $key => $val) {
if (!empty($keyforbreak) && $key == $keyforbreak) {
break; // key used for break on second column
}
2020-01-09 11:04:58 +01:00
2017-11-03 15:56:16 +01:00
// Discard if extrafield is a hidden field on form
2021-02-23 22:03:23 +01:00
if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) {
continue;
}
2017-11-03 15:56:16 +01:00
2021-02-23 22:03:23 +01:00
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
continue; // We don't want this field
}
if (in_array($key, array('ref', 'status'))) {
continue; // Ref and status are already in dol_banner
}
$value = $object->$key;
2021-02-27 12:45:07 +01:00
print '<tr class="field_'.$key.'"><td';
print ' class="'.(empty($val['tdcss']) ? 'titlefield' : $val['tdcss']).' fieldname_'.$key;
2019-04-25 17:37:54 +02:00
//if ($val['notnull'] > 0) print ' fieldrequired'; // No fieldrequired on the view output
2021-02-23 22:03:23 +01:00
if ($val['type'] == 'text' || $val['type'] == 'html') {
print ' tdtop';
}
print '">';
2021-02-23 22:03:23 +01:00
if (!empty($val['help'])) {
print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
} else {
if (isset($val['copytoclipboard']) && $val['copytoclipboard'] == 1) {
print showValueWithClipboardCPButton($value, 0, $langs->transnoentitiesnoconv($val['label']));
} else {
print $langs->trans($val['label']);
}
2021-02-23 22:03:23 +01:00
}
print '</td>';
print '<td class="valuefield fieldname_'.$key;
2021-02-23 22:03:23 +01:00
if ($val['type'] == 'text') {
print ' wordbreak';
}
2021-06-03 15:14:31 +02:00
if (!empty($val['cssview'])) {
2021-02-23 22:03:23 +01:00
print ' '.$val['cssview'];
}
2019-11-09 18:13:59 +01:00
print '">';
2021-02-23 22:03:23 +01:00
if (in_array($val['type'], array('text', 'html'))) {
print '<div class="longmessagecut">';
}
2021-08-04 11:25:23 +02:00
if ($key == 'lang') {
$langs->load("languages");
$labellang = ($value ? $langs->trans('Language_'.$value) : '');
print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"');
print $labellang;
} else {
if (isset($val['copytoclipboard']) && $val['copytoclipboard'] == 2) {
$out = $object->showOutputField($val, $key, $value, '', '', '', 0);
print showValueWithClipboardCPButton($out, 0, $out);
} else {
print $object->showOutputField($val, $key, $value, '', '', '', 0);
}
2021-08-04 11:25:23 +02:00
}
//print dol_escape_htmltag($object->$key, 1, 1);
2021-02-23 22:03:23 +01:00
if (in_array($val['type'], array('text', 'html'))) {
print '</div>';
}
print '</td>';
print '</tr>';
}
print '</table>';
2019-05-19 13:01:11 +02:00
// We close div and reopen for second column
print '</div>';
2019-05-19 13:01:11 +02:00
2022-01-24 16:38:25 +01:00
$rightpart = '';
$alreadyoutput = 1;
2021-02-23 22:03:23 +01:00
foreach ($object->fields as $key => $val) {
if ($alreadyoutput) {
2020-01-09 11:04:58 +01:00
if (!empty($keyforbreak) && $key == $keyforbreak) {
$alreadyoutput = 0; // key used for break on second column
2020-05-21 15:05:19 +02:00
} else {
2020-01-09 11:04:58 +01:00
continue;
}
}
// Discard if extrafield is a hidden field on form
2021-02-23 22:03:23 +01:00
if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) {
continue;
}
2021-02-23 22:03:23 +01:00
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) {
continue; // We don't want this field
}
if (in_array($key, array('ref', 'status'))) {
continue; // Ref and status are already in dol_banner
}
$value = $object->$key;
2022-01-24 16:38:25 +01:00
$rightpart .= '<tr><td';
$rightpart .= ' class="'.(empty($val['tdcss']) ? 'titlefield' : $val['tdcss']).' fieldname_'.$key;
//if ($val['notnull'] > 0) $rightpart .= ' fieldrequired'; // No fieldrequired inthe view output
2021-02-23 22:03:23 +01:00
if ($val['type'] == 'text' || $val['type'] == 'html') {
2022-01-24 16:38:25 +01:00
$rightpart .= ' tdtop';
2021-02-23 22:03:23 +01:00
}
2022-01-24 16:38:25 +01:00
$rightpart.= '">';
2021-02-23 22:03:23 +01:00
if (!empty($val['help'])) {
2022-01-24 16:38:25 +01:00
$rightpart .= $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
2021-02-23 22:03:23 +01:00
} else {
2022-01-24 16:38:25 +01:00
$rightpart .= $langs->trans($val['label']);
2021-02-23 22:03:23 +01:00
}
2022-01-24 16:38:25 +01:00
$rightpart .= '</td>';
$rightpart .= '<td class="valuefield fieldname_'.$key;
2021-02-23 22:03:23 +01:00
if ($val['type'] == 'text') {
2022-01-24 16:38:25 +01:00
$rightpart .= ' wordbreak';
2021-02-23 22:03:23 +01:00
}
2021-10-24 19:19:32 +02:00
if (!empty($val['cssview'])) {
2022-01-24 16:38:25 +01:00
$rightpart .= ' '.$val['cssview'];
2021-02-23 22:03:23 +01:00
}
2022-01-24 16:38:25 +01:00
$rightpart .= '">';
2021-02-23 22:03:23 +01:00
if (in_array($val['type'], array('text', 'html'))) {
2022-01-24 16:38:25 +01:00
$rightpart .= '<div class="longmessagecut">';
2021-02-23 22:03:23 +01:00
}
2022-01-24 16:38:25 +01:00
$rightpart .= $object->showOutputField($val, $key, $value, '', '', '', 0);
//$rightpart .= dol_escape_htmltag($object->$key, 1, 1);
2021-02-23 22:03:23 +01:00
if (in_array($val['type'], array('text', 'html'))) {
2022-01-24 16:38:25 +01:00
$rightpart .= '</div>';
2021-02-23 22:03:23 +01:00
}
2022-01-24 16:38:25 +01:00
$rightpart .= '</td>';
$rightpart .= '</tr>';
}
2022-01-24 16:38:25 +01:00
print '<div class="fichehalfright">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';
print $rightpart;
?>
2019-09-23 21:55:30 +02:00
<!-- END PHP TEMPLATE commonfields_view.tpl.php -->