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 19/** 20 * \file htdocs/admin/loan.php 21 * \ingroup loan 22 * \brief Setup page to configure loan module 23 */ 24 25require '../main.inc.php'; 26 27// Class 28require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; 29if (!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 35if (!$user->admin) 36 accessforbidden(); 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 51if ($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 75llxHeader(); 76 77$form = new Form($db); 78if (!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>'; 81print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup'); 82 83print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; 84print '<input type="hidden" name="token" value="'.newToken().'">'; 85print '<input type="hidden" name="action" value="update">'; 86 87/* 88 * Params 89 */ 90print '<table class="noborder centpercent">'; 91print '<tr class="liste_titre">'; 92print '<td colspan="3">'.$langs->trans('Options').'</td>'; 93print "</tr>\n"; 94 95foreach ($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 114print '</tr>'; 115 116print '</form>'; 117print "</table>\n"; 118 119print '<br><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>'; 120 121// End of page 122llxFooter(); 123$db->close(); 124