dolibarr 21.0.0-beta
accountancy_codes_edit.tpl.php
1<?php
2/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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
36// Protection to avoid direct call of template
37if (empty($object) || !is_object($object)) {
38 print "Error, template page can't be called as URL";
39 exit(1);
40}
41
42if (!is_object($form)) {
43 $form = new Form($db);
44}
45
46global $formaccounting;
47if (isModEnabled('accounting') && !is_object($formaccounting)) {
48 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
49 $formaccounting = new FormAccounting($db);
50}
51
52
53?>
54<!-- BEGIN PHP TEMPLATE accountancy_code_edit.tpl.php -->
55<?php
56
57if (!is_array($parameters)) {
58 $parameters = array();
59}
60$parameters['assetaccountancycodes'] = &$assetaccountancycodes;
61$reshook = $hookmanager->executeHooks('formAssetAccountancyCodes', $parameters, $object, $action);
62print $hookmanager->resPrint;
63if ($reshook < 0) {
64 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
65}
66
67if (empty($reshook)) {
68 foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
69 //if (empty($object->enabled_modes[$mode_key])) continue;
70 $width = ($mode_key == "economic")? "width50p pull-left" : "width50p";
71 print '<table class="border '. $width .'" id="block_' . $mode_key . '">';
72 print '<tr><td class="info-box-title">'.$langs->trans($mode_info['label']).'</td></tr>';
73 foreach ($mode_info['fields'] as $field_key => $field_info) {
74 $html_name = $mode_key . '_' . $field_key;
75 print '<tr><td class="width40p">' . $langs->trans($field_info['label']) . '</td><td>';
76 $accountancy_code = GETPOSTISSET($html_name) ? GETPOST($html_name, 'aZ09') : (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key]) ? $assetaccountancycodes->accountancy_codes[$mode_key][$field_key] : '');
77 if (isModEnabled('accounting')) {
78 print $formaccounting->select_account($accountancy_code, $html_name, 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1);
79 } else {
80 print '<input name="' . $html_name . '" class="maxwidth200 " value="' . dol_escape_htmltag($accountancy_code) . '">';
81 }
82 print '</td></tr>';
83 }
84 print '</table>';
85 }
86
87 print '<div class="clearboth"></div>';
88}
89?>
90<!-- END PHP TEMPLATE accountancy_code_edit.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to manage generation of HTML components for accounting management.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...