dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
29
30// Class
31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32if (isModEnabled('accounting')) {
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
34}
35
44// Load translation files required by the page
45$langs->loadLangs(array('admin', 'loan'));
46
47// Security check
48if (!$user->admin) {
50}
51
52$action = GETPOST('action', 'aZ09');
53
54// Other parameters LOAN_*
55$list = array(
56 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL',
57 'LOAN_ACCOUNTING_ACCOUNT_INTEREST',
58 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'
59);
60
61/*
62 * Actions
63 */
64
65if ($action == 'update') {
66 $error = 0;
67
68 foreach ($list as $constname) {
69 $constvalue = GETPOST($constname, 'alpha');
70
71 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
72 $error++;
73 }
74 }
75
76 if (!$error) {
77 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
78 } else {
79 setEventMessages($langs->trans("Error"), null, 'errors');
80 }
81}
82
83/*
84 * View
85 */
86
87llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-loan');
88
89$form = new Form($db);
90if (isModEnabled('accounting')) {
91 $formaccounting = new FormAccounting($db);
92} else {
93 $formaccounting = null;
94}
95
96$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
97print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup');
98
99print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
100print '<input type="hidden" name="token" value="'.newToken().'">';
101print '<input type="hidden" name="action" value="update">';
102
103/*
104 * Params
105 */
106print '<table class="noborder centpercent">';
107print '<tr class="liste_titre">';
108print '<td colspan="3">'.$langs->trans('Options').'</td>';
109print "</tr>\n";
110
111foreach ($list as $key) {
112 print '<tr class="oddeven value">';
113
114 // Param
115 $label = $langs->trans($key);
116 print '<td><label for="' . $key . '">' . $label . '</label></td>';
117
118 // Value
119 print '<td>';
120 if ($formaccounting instanceof FormAccounting) {
121 print $formaccounting->select_account(getDolGlobalString($key), $key, 1, array(), 1, 1);
122 } else {
123 print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . getDolGlobalString($key) . '">';
124 }
125 print '</td></tr>';
126}
127
128print '</tr>';
129
130print '</form>';
131print "</table>\n";
132
133print '<br><div style="text-align:center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
134
135// End of page
136llxFooter();
137$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:71
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.