dolibarr 21.0.0-beta
depreciation_view.tpl.php
1<?php
2/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Show extrafields. It also shows fields from hook formAssetAccountancyCode. Need to have the following variables defined:
20 * $object (asset, assetmodel, ...)
21 * $assetaccountancycodes
22 * $action
23 * $conf
24 * $langs
25 *
26 * $parameters
27 */
28
39// Protection to avoid direct call of template
40if (empty($object) || !is_object($object)) {
41 print "Error, template page can't be called as URL";
42 exit(1);
43}
44
45if (!is_object($form)) {
46 $form = new Form($db);
47}
48
49
50?>
51<!-- BEGIN PHP TEMPLATE depreciation_options_view.tpl.php -->
52<?php
53
54if (!is_array($parameters)) {
55 $parameters = array();
56}
57if (empty($parameters['assetdepreciationoptions'])) {
58 $parameters['assetdepreciationoptions'] = &$assetdepreciationoptions;
59}
60$reshook = $hookmanager->executeHooks('formAssetDeprecationOptions', $parameters, $object, $action);
61print $hookmanager->resPrint;
62if ($reshook < 0) {
63 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
64}
65
66if (empty($reshook)) {
67 $class_type = get_class($object) == 'Asset' ? 0 : 1;
68 foreach ($assetdepreciationoptions->deprecation_options_fields as $mode_key => $mode_info) {
69 if (!empty($mode_info['enabled_field'])) {
70 $info = explode(':', $mode_info['enabled_field']);
71 if ($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
72 continue;
73 }
74 }
75
76 $assetdepreciationoptions->setInfosForMode($mode_key, $class_type, true);
77
78 print load_fiche_titre($langs->trans($mode_info['label']), '', '');
79 print '<div class="fichecenter">';
80 print '<div class="fichehalfleft">';
81 print '<div class="underbanner clearboth"></div>';
82 print '<table class="border centpercent tableforfield">' . "\n";
83 $mode_info['fields'] = dol_sort_array($mode_info['fields'], 'position');
84 foreach ($mode_info['fields'] as $field_key => $field_info) {
85 if (!empty($field_info['enabled_field'])) {
86 $info = explode(':', $field_info['enabled_field']);
87 if ($assetdepreciationoptions->deprecation_options[$info[0]][$info[1]] != $info[2]) {
88 continue;
89 }
90 }
91 // Discard if extrafield is a hidden field on form
92 $isVisibleAbs = array_key_exists('visible', $field_info) ? abs((int) $field_info['visible']) : 0;
93 if (!in_array($isVisibleAbs, array(1, 3, 4, 5))) {
94 continue;
95 }
96 if (array_key_exists('enabled', $field_info) && isset($field_info['enabled']) && !verifCond($field_info['enabled'])) {
97 continue; // We don't want this field
98 }
99 if (!empty($field_info['column_break'])) {
100 print '</table>';
101
102 // We close div and reopen for second column
103 print '</div>';
104 print '<div class="fichehalfright">';
105
106 print '<div class="underbanner clearboth"></div>';
107 print '<table class="border centpercent tableforfield">';
108 }
109
110 $key = $mode_key . '_' . $field_key;
111 $value = $assetdepreciationoptions->deprecation_options[$mode_key][$field_key];
112
113 print '<tr class="field_' . $key . '"><td';
114 print ' class="' . (empty($field_info['tdcss']) ? 'titlefield' : $field_info['tdcss']) . ' fieldname_' . $key;
115 if ($field_info['type'] == 'text' || $field_info['type'] == 'html') {
116 print ' tdtop';
117 }
118 print '">';
119 if (!empty($field_info['help'])) {
120 print $form->textwithpicto($langs->trans($field_info['label']), $langs->trans($field_info['help']));
121 } else {
122 if (isset($field_info['copytoclipboard']) && $field_info['copytoclipboard'] == 1) { // @phan-suppress-current-line PhanTypeInvalidDimOffset
123 print showValueWithClipboardCPButton($value, 0, $langs->transnoentitiesnoconv($field_info['label']));
124 } else {
125 print $langs->trans($field_info['label']);
126 }
127 }
128 print '</td>';
129 print '<td class="valuefield fieldname_' . $key;
130 if ($field_info['type'] == 'text') {
131 print ' wordbreak';
132 }
133 if (!empty($field_info['cssview'])) {
134 print ' ' . $field_info['cssview'];
135 }
136 print '">';
137 if (in_array($field_info['type'], array('text', 'html'))) {
138 print '<div class="longmessagecut">';
139 }
140 if ($field_key == 'lang') {
141 $langs->load("languages");
142 $labellang = ($value ? $langs->trans('Language_' . $value) : '');
143 print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"');
144 print $labellang;
145 } else {
146 if (isset($field_info['copytoclipboard']) && $field_info['copytoclipboard'] == 2) {
147 $out = $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key . '_', 0);
148 print showValueWithClipboardCPButton($out, 0, $out);
149 } else {
150 print $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key . '_', 0);
151 }
152 }
153 if (in_array($field_info['type'], array('text', 'html'))) {
154 print '</div>';
155 }
156 print '</td>';
157 print '</tr>';
158 }
159 print '</table>';
160 print '</div>';
161 print '</div>';
162 print '<div class="clearboth"></div>';
163 }
164}
165
166?>
167<!-- END PHP TEMPLATE depreciation_options_view.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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...