dolibarr  16.0.5
loan.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2014-2017 Alexandre Spangaro <aspangaro@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  */
18 
25 require '../main.inc.php';
26 
27 // Class
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 if (!empty($conf->accounting->enabled)) {
30  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
31 }
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array('admin', 'loan'));
35 
36 // Security check
37 if (!$user->admin) {
39 }
40 
41 $action = GETPOST('action', 'aZ09');
42 
43 // Other parameters LOAN_*
44 $list = array(
45  'LOAN_ACCOUNTING_ACCOUNT_CAPITAL',
46  'LOAN_ACCOUNTING_ACCOUNT_INTEREST',
47  'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'
48 );
49 
50 /*
51  * Actions
52  */
53 
54 if ($action == 'update') {
55  $error = 0;
56 
57  foreach ($list as $constname) {
58  $constvalue = GETPOST($constname, 'alpha');
59 
60  if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
61  $error++;
62  }
63  }
64 
65  if (!$error) {
66  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
67  } else {
68  setEventMessages($langs->trans("Error"), null, 'errors');
69  }
70 }
71 
72 /*
73  * View
74  */
75 
76 llxHeader();
77 
78 $form = new Form($db);
79 if (!empty($conf->accounting->enabled)) {
80  $formaccounting = new FormAccounting($db);
81 }
82 
83 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
84 print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup');
85 
86 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
87 print '<input type="hidden" name="token" value="'.newToken().'">';
88 print '<input type="hidden" name="action" value="update">';
89 
90 /*
91  * Params
92  */
93 print '<table class="noborder centpercent">';
94 print '<tr class="liste_titre">';
95 print '<td colspan="3">'.$langs->trans('Options').'</td>';
96 print "</tr>\n";
97 
98 foreach ($list as $key) {
99  print '<tr class="oddeven value">';
100 
101  // Param
102  $label = $langs->trans($key);
103  print '<td><label for="'.$key.'">'.$label.'</label></td>';
104 
105  // Value
106  print '<td>';
107  if (!empty($conf->accounting->enabled)) {
108  print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1);
109  } else {
110  print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
111  }
112  print '</td></tr>';
113 }
114 
115 print '</tr>';
116 
117 print '</form>';
118 print "</table>\n";
119 
120 print '<br><div style="text-align:center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
121 
122 // End of page
123 llxFooter();
124 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormAccounting
Class to manage generation of HTML components for accounting management.
Definition: html.formaccounting.class.php:33
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
dolibarr_set_const
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).
Definition: admin.lib.php:627
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59