dolibarr 21.0.0-alpha
loan.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2014-2017 Alexandre Spangaro <aspangaro@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 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
28
29// Class
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31if (isModEnabled('accounting')) {
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
33}
34
35// Load translation files required by the page
36$langs->loadLangs(array('admin', 'loan'));
37
38// Security check
39if (!$user->admin) {
41}
42
43$action = GETPOST('action', 'aZ09');
44
45// Other parameters LOAN_*
46$list = array(
47 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL',
48 'LOAN_ACCOUNTING_ACCOUNT_INTEREST',
49 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'
50);
51
52/*
53 * Actions
54 */
55
56if ($action == 'update') {
57 $error = 0;
58
59 foreach ($list as $constname) {
60 $constvalue = GETPOST($constname, 'alpha');
61
62 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
63 $error++;
64 }
65 }
66
67 if (!$error) {
68 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
69 } else {
70 setEventMessages($langs->trans("Error"), null, 'errors');
71 }
72}
73
74/*
75 * View
76 */
77
78llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-loan');
79
80$form = new Form($db);
81if (isModEnabled('accounting')) {
82 $formaccounting = new FormAccounting($db);
83} else {
84 $formaccounting = null;
85}
86
87$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
88print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup');
89
90print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
91print '<input type="hidden" name="token" value="'.newToken().'">';
92print '<input type="hidden" name="action" value="update">';
93
94/*
95 * Params
96 */
97print '<table class="noborder centpercent">';
98print '<tr class="liste_titre">';
99print '<td colspan="3">'.$langs->trans('Options').'</td>';
100print "</tr>\n";
101
102foreach ($list as $key) {
103 print '<tr class="oddeven value">';
104
105 // Param
106 $label = $langs->trans($key);
107 print '<td><label for="' . $key . '">' . $label . '</label></td>';
108
109 // Value
110 print '<td>';
111 if ($formaccounting instanceof FormAccounting) {
112 print $formaccounting->select_account(getDolGlobalString($key), $key, 1, array(), 1, 1);
113 } else {
114 print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . getDolGlobalString($key) . '">';
115 }
116 print '</td></tr>';
117}
118
119print '</tr>';
120
121print '</form>';
122print "</table>\n";
123
124print '<br><div style="text-align:center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
125
126// End of page
127llxFooter();
128$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.