loan.php 3.2 KB

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