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