dolibarr 20.0.2
depreciation_view.tpl.php
1<?php
2/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
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 * Show extrafields. It also show fields from hook formAssetAccountancyCode. Need to have following variables defined:
18 * $object (asset, assetmodel, ...)
19 * $assetaccountancycodes
20 * $action
21 * $conf
22 * $langs
23 *
24 * $parameters
25 */
26
27// Protection to avoid direct call of template
28if (empty($object) || !is_object($object)) {
29 print "Error, template page can't be called as URL";
30 exit(1);
31}
32
33if (!is_object($form)) {
34 $form = new Form($db);
35}
36
37
38?>
39<!-- BEGIN PHP TEMPLATE depreciation_options_view.tpl.php -->
40<?php
41
42if (!is_array($parameters)) {
43 $parameters = array();
44}
45if (empty($parameters['assetdepreciationoptions'])) {
46 $parameters['assetdepreciationoptions'] = &$assetdepreciationoptions;
47}
48$reshook = $hookmanager->executeHooks('formAssetDeprecationOptions', $parameters, $object, $action);
49print $hookmanager->resPrint;
50if ($reshook < 0) {
51 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
52}
53
54if (empty($reshook)) {
55 $class_type = get_class($object) == 'Asset' ? 0 : 1;
56 foreach ($assetdepreciationoptions->deprecation_options_fields as $mode_key => $mode_info) {
57 if (!empty($mode_info['enabled_field'])) {
58 $info = explode(':', $mode_info['enabled_field']);
59 if ($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
60 continue;
61 }
62 }
63
64 $assetdepreciationoptions->setInfosForMode($mode_key, $class_type, true);
65
66 print load_fiche_titre($langs->trans($mode_info['label']), '', '');
67 print '<div class="fichecenter">';
68 print '<div class="fichehalfleft">';
69 print '<div class="underbanner clearboth"></div>';
70 print '<table class="border centpercent tableforfield">' . "\n";
71 $mode_info['fields'] = dol_sort_array($mode_info['fields'], 'position');
72 foreach ($mode_info['fields'] as $field_key => $field_info) {
73 if (!empty($field_info['enabled_field'])) {
74 $info = explode(':', $field_info['enabled_field']);
75 if ($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
76 continue;
77 }
78 }
79 // Discard if extrafield is a hidden field on form
80 if (abs($field_info['visible']) != 1 && abs($field_info['visible']) != 3 && abs($field_info['visible']) != 4 && abs($field_info['visible']) != 5) {
81 continue;
82 }
83 if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) {
84 continue; // We don't want this field
85 }
86 if (!empty($field_info['column_break'])) {
87 print '</table>';
88
89 // We close div and reopen for second column
90 print '</div>';
91 print '<div class="fichehalfright">';
92
93 print '<div class="underbanner clearboth"></div>';
94 print '<table class="border centpercent tableforfield">';
95 }
96
97 $key = $mode_key . '_' . $field_key;
98 $value = $assetdepreciationoptions->deprecation_options[$mode_key][$field_key];
99
100 print '<tr class="field_' . $key . '"><td';
101 print ' class="' . (empty($field_info['tdcss']) ? 'titlefield' : $field_info['tdcss']) . ' fieldname_' . $key;
102 if ($field_info['type'] == 'text' || $field_info['type'] == 'html') {
103 print ' tdtop';
104 }
105 print '">';
106 if (!empty($field_info['help'])) {
107 print $form->textwithpicto($langs->trans($field_info['label']), $langs->trans($field_info['help']));
108 } else {
109 if (isset($field_info['copytoclipboard']) && $field_info['copytoclipboard'] == 1) {
110 print showValueWithClipboardCPButton($value, 0, $langs->transnoentitiesnoconv($field_info['label']));
111 } else {
112 print $langs->trans($field_info['label']);
113 }
114 }
115 print '</td>';
116 print '<td class="valuefield fieldname_' . $key;
117 if ($field_info['type'] == 'text') {
118 print ' wordbreak';
119 }
120 if (!empty($field_info['cssview'])) {
121 print ' ' . $field_info['cssview'];
122 }
123 print '">';
124 if (in_array($field_info['type'], array('text', 'html'))) {
125 print '<div class="longmessagecut">';
126 }
127 if ($field_key == 'lang') {
128 $langs->load("languages");
129 $labellang = ($value ? $langs->trans('Language_' . $value) : '');
130 print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"');
131 print $labellang;
132 } else {
133 if (isset($field_info['copytoclipboard']) && $field_info['copytoclipboard'] == 2) {
134 $out = $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key . '_', 0);
135 print showValueWithClipboardCPButton($out, 0, $out);
136 } else {
137 print $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key . '_', 0);
138 }
139 }
140 if (in_array($field_info['type'], array('text', 'html'))) {
141 print '</div>';
142 }
143 print '</td>';
144 print '</tr>';
145 }
146 print '</table>';
147 print '</div>';
148 print '</div>';
149 print '<div class="clearboth"></div>';
150 }
151}
152
153?>
154<!-- END PHP TEMPLATE depreciation_options_view.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage generation of HTML components Only common components must be here.
verifCond($strToEvaluate, $onlysimplestring='1')
Verify if condition in string is ok or not.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.