salaries.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /* Copyright (C) 2014-2019 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/salaries/admin/salaries.php
  20. * \ingroup Salaries
  21. * \brief Setup page to configure salaries 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. require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
  28. if (isModEnabled('accounting')) {
  29. 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', 'salaries'));
  33. // Security check
  34. if (!$user->admin) {
  35. accessforbidden();
  36. }
  37. $action = GETPOST('action', 'aZ09');
  38. // Other parameters SALARIES_*
  39. $list = array(
  40. 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
  41. );
  42. /*
  43. * Actions
  44. */
  45. if ($action == 'update') {
  46. $error = 0;
  47. foreach ($list as $constname) {
  48. $constvalue = GETPOST($constname, 'alpha');
  49. if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  50. $error++;
  51. }
  52. }
  53. if (!$error) {
  54. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  55. } else {
  56. setEventMessages($langs->trans("Error"), null, 'errors');
  57. }
  58. }
  59. $reg = array();
  60. if (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
  61. // Set boolean (on/off) constants
  62. if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
  63. dol_print_error($db);
  64. }
  65. }
  66. /*
  67. * View
  68. */
  69. llxHeader('', $langs->trans('SalariesSetup'));
  70. $form = new Form($db);
  71. if (isModEnabled('accounting')) {
  72. $formaccounting = new FormAccounting($db);
  73. }
  74. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  75. print load_fiche_titre($langs->trans('SalariesSetup'), $linkback, 'title_setup');
  76. $head = salaries_admin_prepare_head();
  77. print dol_get_fiche_head($head, 'general', $langs->trans("Salaries"), -1, 'payment');
  78. // Document templates
  79. print load_fiche_titre($langs->trans("Options"), '', '');
  80. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  81. print '<input type="hidden" name="token" value="'.newToken().'">';
  82. print '<input type="hidden" name="action" value="update">';
  83. /*
  84. * Params
  85. */
  86. print '<table class="noborder centpercent">';
  87. print '<tr class="liste_titre">';
  88. print '<td>'.$langs->trans("Parameters").'</td>';
  89. print '<td width="60">'.$langs->trans("Value")."</td>\n";
  90. print "</tr>\n";
  91. foreach ($list as $key) {
  92. print '<tr class="oddeven value">';
  93. // Param
  94. $label = $langs->trans($key);
  95. print '<td class="fieldrequired" width="50%"><label for="'.$key.'">'.$label.'</label></td>';
  96. // Value
  97. print '<td>';
  98. if (isModEnabled('accounting')) {
  99. print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1);
  100. } else {
  101. print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
  102. }
  103. print '</td></tr>';
  104. }
  105. print '</tr>';
  106. print "</table>\n";
  107. //print dol_get_fiche_end();
  108. print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
  109. print '</form><br>';
  110. echo '<div>';
  111. echo '<table class="noborder centpercent">';
  112. echo '<thead>';
  113. echo '<tr class="liste_titre"><th>' . $langs->trans('Parameter') . '</th><th>' . $langs->trans('Value') . '</th></tr>';
  114. echo '</thead>';
  115. echo '<tbody>';
  116. $key = 'CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT';
  117. echo '<tr><td>', $langs->trans($key), '</td><td>', ajax_constantonoff($key), '</td></tr>';
  118. echo '</tbody>';
  119. echo '</table>';
  120. echo '</div>';
  121. // End of page
  122. llxFooter();
  123. $db->close();