loan.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. * \file htdocs/admin/loan.php
  20. * \ingroup loan
  21. * \brief Setup page to configure loan module
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. // Class
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. if (isModEnabled('accounting')) {
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
  29. }
  30. // Load translation files required by the page
  31. $langs->loadLangs(array('admin', 'loan'));
  32. // Security check
  33. if (!$user->admin) {
  34. accessforbidden();
  35. }
  36. $action = GETPOST('action', 'aZ09');
  37. // Other parameters LOAN_*
  38. $list = array(
  39. 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL',
  40. 'LOAN_ACCOUNTING_ACCOUNT_INTEREST',
  41. 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'
  42. );
  43. /*
  44. * Actions
  45. */
  46. if ($action == 'update') {
  47. $error = 0;
  48. foreach ($list as $constname) {
  49. $constvalue = GETPOST($constname, 'alpha');
  50. if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  51. $error++;
  52. }
  53. }
  54. if (!$error) {
  55. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  56. } else {
  57. setEventMessages($langs->trans("Error"), null, 'errors');
  58. }
  59. }
  60. /*
  61. * View
  62. */
  63. llxHeader();
  64. $form = new Form($db);
  65. if (isModEnabled('accounting')) {
  66. $formaccounting = new FormAccounting($db);
  67. }
  68. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  69. print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup');
  70. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  71. print '<input type="hidden" name="token" value="'.newToken().'">';
  72. print '<input type="hidden" name="action" value="update">';
  73. /*
  74. * Params
  75. */
  76. print '<table class="noborder centpercent">';
  77. print '<tr class="liste_titre">';
  78. print '<td colspan="3">'.$langs->trans('Options').'</td>';
  79. print "</tr>\n";
  80. foreach ($list as $key) {
  81. print '<tr class="oddeven value">';
  82. // Param
  83. $label = $langs->trans($key);
  84. print '<td><label for="' . $key . '">' . $label . '</label></td>';
  85. // Value
  86. print '<td>';
  87. if (isModEnabled('accounting')) {
  88. print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1);
  89. } else {
  90. print '<input type="text" size="20" id="' . $key . '" name="' . $key . '" value="' . getDolGlobalString($key) . '">';
  91. }
  92. print '</td></tr>';
  93. }
  94. print '</tr>';
  95. print '</form>';
  96. print "</table>\n";
  97. print '<br><div style="text-align:center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
  98. // End of page
  99. llxFooter();
  100. $db->close();