dolibarr 21.0.0-beta
accountancy_codes_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
37// Protection to avoid direct call of template
38if (empty($object) || !is_object($object)) {
39 print "Error, template page can't be called as URL";
40 exit(1);
41}
42
43if (!is_object($form)) {
44 $form = new Form($db);
45}
46
47
48?>
49<!-- BEGIN PHP TEMPLATE accountancy_code_view.tpl.php -->
50<?php
51
52if (!is_array($parameters)) {
53 $parameters = array();
54}
55$parameters['assetaccountancycodes'] = &$assetaccountancycodes;
56$reshook = $hookmanager->executeHooks('formAssetAccountancyCodes', $parameters, $object, $action);
57print $hookmanager->resPrint;
58if ($reshook < 0) {
59 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
60}
61
62if (empty($reshook)) {
63 if (isModEnabled('accounting')) {
64 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
65 }
66
67 foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
68 if (empty($assetdepreciationoptions->deprecation_options[$mode_key]) && $mode_key == "accelerated_depreciation") {
69 continue;
70 }
71 $width = "pull-left";
72 print '<table class="liste centpercent '. $width .'" id="block_' . $mode_key . '">' . "\n";
73 print '<tr class="liste_titre"><td colspan="5">'.$langs->trans($mode_info['label']).'</td></tr>';
74 foreach ($mode_info['fields'] as $field_key => $field_info) {
75 $key = $mode_key . '_' . $field_key;
76 print '<tr class="field_' . $key . '" id="block_' . $mode_key . '"><td class="titlefieldmiddle">' . $langs->trans($field_info['label']) . '</td><td colspan="3">';
77 if (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key])) {
78 $accountancy_code = $assetaccountancycodes->accountancy_codes[$mode_key][$field_key];
79 if (isModEnabled('accounting')) {
80 $accountingaccount = new AccountingAccount($db);
81 $accountingaccount->fetch(0, $accountancy_code, 1);
82
83 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
84 } else {
85 print $accountancy_code;
86 }
87 }
88 print '</td></tr>';
89 }
90 print '</table>';
91 print '<div class="clearboth"></div>';
92 print '<br>';
93 }
94 print '<div class="clearboth"></div>';
95}
96?>
97<!-- END PHP TEMPLATE accountancy_code_view.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to manage accounting accounts.
Class to manage generation of HTML components Only common components must be here.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.