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