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