dolibarr  7.0.0-beta
loan.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2014-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
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 <http://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 $langs->load("admin");
32 $langs->load("loan");
33 
34 // Security check
35 if (!$user->admin)
37 
38 $action = GETPOST('action', 'alpha');
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  }
67  else
68  {
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 (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
81 
82 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
83 print load_fiche_titre($langs->trans('ConfigLoan'),$linkback,'title_setup');
84 
85 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
86 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
87 print '<input type="hidden" name="action" value="update">';
88 
89 /*
90  * Params
91  */
92 print '<table class="noborder" width="100%">';
93 print '<tr class="liste_titre">';
94 print '<td colspan="3">' . $langs->trans('Options') . '</td>';
95 print "</tr>\n";
96 
97 foreach ($list as $key)
98 {
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  {
109  print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
110  }
111  else
112  {
113  print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
114  }
115  print '</td></tr>';
116 }
117 
118 print '</tr>';
119 
120 print '</form>';
121 print "</table>\n";
122 
123 print '<br><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
124 
125 llxFooter();
126 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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:485
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91
Class to manage generation of HTML components for accounting management.