dolibarr 20.0.2
accountancy_codes_edit.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(1);
31}
32
33if (!is_object($form)) {
34 $form = new Form($db);
35}
36
37global $formaccounting;
38if (isModEnabled('accounting') && !is_object($formaccounting)) {
39 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
40 $formaccounting = new FormAccounting($db);
41}
42
43
44?>
45<!-- BEGIN PHP TEMPLATE accountancy_code_edit.tpl.php -->
46<?php
47
48if (!is_array($parameters)) {
49 $parameters = array();
50}
51$parameters['assetaccountancycodes'] = &$assetaccountancycodes;
52$reshook = $hookmanager->executeHooks('formAssetAccountancyCodes', $parameters, $object, $action);
53print $hookmanager->resPrint;
54if ($reshook < 0) {
55 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
56}
57
58if (empty($reshook)) {
59 foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
60 //if (empty($object->enabled_modes[$mode_key])) continue;
61 $width = ($mode_key == "economic")? "width50p pull-left" : "width50p";
62 print '<table class="border '. $width .'" id="block_' . $mode_key . '">';
63 print '<tr><td class="info-box-title">'.$langs->trans($mode_info['label']).'</td></tr>';
64 foreach ($mode_info['fields'] as $field_key => $field_info) {
65 $html_name = $mode_key . '_' . $field_key;
66 print '<tr><td class="width40p">' . $langs->trans($field_info['label']) . '</td><td>';
67 $accountancy_code = GETPOSTISSET($html_name) ? GETPOST($html_name, 'aZ09') : (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key]) ? $assetaccountancycodes->accountancy_codes[$mode_key][$field_key] : '');
68 if (isModEnabled('accounting')) {
69 print $formaccounting->select_account($accountancy_code, $html_name, 1, null, 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1);
70 } else {
71 print '<input name="' . $html_name . '" class="maxwidth200 " value="' . dol_escape_htmltag($accountancy_code) . '">';
72 }
73 print '</td></tr>';
74 }
75 print '</table>';
76 }
77
78 print '<div class="clearboth"></div>';
79}
80?>
81<!-- END PHP TEMPLATE accountancy_code_edit.tpl.php -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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...