admin_hrm.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /* Copyright (C) 2015 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. * \file htdocs/hrm/admin/admin_hrm.php
  19. * \ingroup HRM
  20. * \brief HRM module setup page
  21. */
  22. // Load Dolibarr environment
  23. require '../../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  26. // Load translation files required by the page
  27. $langs->loadLangs(array('admin', 'hrm'));
  28. // Get Parameters
  29. $action = GETPOST('action', 'aZ09');
  30. // Other parameters HRM_*
  31. $list = array(
  32. // 'HRM_EMAIL_EXTERNAL_SERVICE' // To prevent your public accountant for example
  33. );
  34. // Permissions
  35. $permissiontoread = $user->admin;
  36. $permissiontoadd = $user->admin;
  37. // Security check - Protection if external user
  38. //if ($user->socid > 0) accessforbidden();
  39. //if ($user->socid > 0) $socid = $user->socid;
  40. //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  41. //restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', 0);
  42. if (!isModEnabled('hrm')) accessforbidden();
  43. if (empty($permissiontoread)) accessforbidden();
  44. /*
  45. * Actions
  46. */
  47. if ($action == 'update') {
  48. $error = 0;
  49. foreach ($list as $constname) {
  50. $constvalue = GETPOST($constname, 'alpha');
  51. if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  52. $error++;
  53. }
  54. }
  55. if (!$error) {
  56. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  57. } else {
  58. setEventMessages($langs->trans("Error"), null, 'errors');
  59. }
  60. }
  61. /*
  62. * View
  63. */
  64. $title = $langs->trans('Parameters');
  65. llxHeader('', $title, '');
  66. $form = new Form($db);
  67. dol_htmloutput_mesg($mesg);
  68. // Subheader
  69. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  70. print load_fiche_titre($langs->trans("HRMSetup"), $linkback);
  71. // Configuration header
  72. $head = hrm_admin_prepare_head();
  73. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  74. print '<input type="hidden" name="token" value="'.newToken().'">';
  75. print '<input type="hidden" name="action" value="update">';
  76. print dol_get_fiche_head($head, 'parameters', $langs->trans("HRM"), -1, "user");
  77. print '<table class="noborder centpercent">';
  78. print '<tr class="liste_titre">';
  79. print '<td colspan="3">'.$langs->trans('Parameters').'</td>';
  80. print "</tr>\n";
  81. foreach ($list as $key) {
  82. print '<tr class="oddeven value">';
  83. // Param
  84. $label = $langs->trans($key);
  85. print '<td width="50%"><label for="'.$key.'">'.$label.'</label></td>';
  86. // Value
  87. print '<td>';
  88. print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
  89. print '</td></tr>';
  90. }
  91. print "</table>\n";
  92. print dol_get_fiche_end();
  93. print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
  94. print '</form>';
  95. // End of page
  96. llxFooter();
  97. $db->close();