dolibarr 19.0.3
accountancy_codes_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;
31}
32
33if (!is_object($form)) {
34 $form = new Form($db);
35}
36
37
38?>
39<!-- BEGIN PHP TEMPLATE accountancy_code_view.tpl.php -->
40<?php
41
42if (!is_array($parameters)) {
43 $parameters = array();
44}
45$parameters['assetaccountancycodes'] = &$assetaccountancycodes;
46$reshook = $hookmanager->executeHooks('formAssetAccountancyCodes', $parameters, $object, $action);
47print $hookmanager->resPrint;
48if ($reshook < 0) {
49 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
50}
51
52if (empty($reshook)) {
53 if (isModEnabled('accounting')) {
54 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
55 }
56
57 foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
58 //if (empty($object->enabled_modes[$mode_key])) continue;
59
60 print load_fiche_titre($langs->trans($mode_info['label']), '', '');
61 print '<div class="fichecenter">';
62 print '<div class="underbanner clearboth"></div>';
63 print '<table class="border centpercent tableforfield">';
64 foreach ($mode_info['fields'] as $field_key => $field_info) {
65 print '<tr><td class="titlefieldcreate">' . $langs->trans($field_info['label']) . '</td><td colspan="3">';
66 if (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key])) {
67 $accountancy_code = $assetaccountancycodes->accountancy_codes[$mode_key][$field_key];
68 if (isModEnabled('accounting')) {
69 $accountingaccount = new AccountingAccount($db);
70 $accountingaccount->fetch('', $accountancy_code, 1);
71
72 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
73 } else {
74 print $accountancy_code;
75 }
76 }
77 print '</td></tr>';
78 }
79 print '</table>';
80 print '</div>';
81 }
82}
83?>
84<!-- END PHP TEMPLATE accountancy_code_view.tpl.php -->
Class to manage accounting accounts.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.