dolibarr  13.0.2
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)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
30 
31 // Load translation files required by the page
32 $langs->loadLangs(array('admin', 'loan'));
33 
34 // Security check
35 if (!$user->admin)
37 
38 $action = GETPOST('action', 'aZ09');
39 
40 // Other parameters LOAN_*
41 $list = array(
42  'LOAN_ACCOUNTING_ACCOUNT_CAPITAL',
43  'LOAN_ACCOUNTING_ACCOUNT_INTEREST',
44  'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'
45 );
46 
47 /*
48  * Actions
49  */
50 
51 if ($action == 'update')
52 {
53  $error = 0;
54 
55  foreach ($list as $constname) {
56  $constvalue = GETPOST($constname, 'alpha');
57 
58  if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
59  $error++;
60  }
61  }
62 
63  if (!$error)
64  {
65  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
66  } else {
67  setEventMessages($langs->trans("Error"), null, 'errors');
68  }
69 }
70 
71 /*
72  * View
73  */
74 
75 llxHeader();
76 
77 $form = new Form($db);
78 if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
79 
80 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
81 print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup');
82 
83 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
84 print '<input type="hidden" name="token" value="'.newToken().'">';
85 print '<input type="hidden" name="action" value="update">';
86 
87 /*
88  * Params
89  */
90 print '<table class="noborder centpercent">';
91 print '<tr class="liste_titre">';
92 print '<td colspan="3">'.$langs->trans('Options').'</td>';
93 print "</tr>\n";
94 
95 foreach ($list as $key)
96 {
97  print '<tr class="oddeven value">';
98 
99  // Param
100  $label = $langs->trans($key);
101  print '<td><label for="'.$key.'">'.$label.'</label></td>';
102 
103  // Value
104  print '<td>';
105  if (!empty($conf->accounting->enabled))
106  {
107  print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
108  } else {
109  print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
110  }
111  print '</td></tr>';
112 }
113 
114 print '</tr>';
115 
116 print '</form>';
117 print "</table>\n";
118 
119 print '<br><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
120 
121 // End of page
122 llxFooter();
123 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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:575
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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 ...
print
Draft customers invoices.
Definition: index.php:89
Class to manage generation of HTML components for accounting management.
llxFooter()
Empty footer.
Definition: wrapper.php:59