dolibarr 21.0.0-alpha
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 *
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 accountancy_code_view.tpl.php -->
41<?php
42
43if (!is_array($parameters)) {
44 $parameters = array();
45}
46$parameters['assetaccountancycodes'] = &$assetaccountancycodes;
47$reshook = $hookmanager->executeHooks('formAssetAccountancyCodes', $parameters, $object, $action);
48print $hookmanager->resPrint;
49if ($reshook < 0) {
50 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
51}
52
53if (empty($reshook)) {
54 if (isModEnabled('accounting')) {
55 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
56 }
57
58 foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
59 if (empty($assetdepreciationoptions->deprecation_options[$mode_key]) && $mode_key == "accelerated_depreciation") {
60 continue;
61 }
62 $width = "pull-left";
63 print '<table class="liste centpercent '. $width .'" id="block_' . $mode_key . '">' . "\n";
64 print '<tr class="liste_titre"><td colspan="5">'.$langs->trans($mode_info['label']).'</td></tr>';
65 foreach ($mode_info['fields'] as $field_key => $field_info) {
66 $key = $mode_key . '_' . $field_key;
67 print '<tr class="field_' . $key . '" id="block_' . $mode_key . '"><td class="titlefieldmiddle">' . $langs->trans($field_info['label']) . '</td><td colspan="3">';
68 if (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key])) {
69 $accountancy_code = $assetaccountancycodes->accountancy_codes[$mode_key][$field_key];
70 if (isModEnabled('accounting')) {
71 $accountingaccount = new AccountingAccount($db);
72 $accountingaccount->fetch('', $accountancy_code, 1);
73
74 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
75 } else {
76 print $accountancy_code;
77 }
78 }
79 print '</td></tr>';
80 }
81 print '</table>';
82 print '<div class="clearboth"></div>';
83 print '<br>';
84 }
85 print '<div class="clearboth"></div>';
86}
87?>
88<!-- END PHP TEMPLATE accountancy_code_view.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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)
Set event messages in dol_events session object.