resource.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /* Copyright (C) 2016 Florian HENRY <florian.henry@atm-consulting.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/resource.php
  20. * \ingroup resource
  21. * \brief Setup page to configure resource 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/ajax.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
  30. // Load translation files required by the page
  31. $langs->loadLangs(array("admin", "resource"));
  32. // Security check
  33. if (!$user->admin) {
  34. accessforbidden();
  35. }
  36. $action = GETPOST('action', 'aZ09');
  37. /*
  38. * Actions
  39. */
  40. if ($action == 'updateoptions') {
  41. if (GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT') != '') {
  42. if (dolibarr_set_const($db, "RESOURCE_USE_SEARCH_TO_SELECT", GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT'), 'chaine', 0, '', $conf->entity)) {
  43. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  44. } else {
  45. setEventMessages($langs->trans("Error"), null, 'errors');
  46. }
  47. }
  48. }
  49. /*
  50. * View
  51. */
  52. llxHeader('', $langs->trans('ResourceSetup'));
  53. $form = new Form($db);
  54. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  55. print load_fiche_titre($langs->trans('ResourceSetup'), $linkback, 'title_setup');
  56. $head = resource_admin_prepare_head();
  57. print dol_get_fiche_head($head, 'general', $langs->trans("ResourceSingular"), -1, 'action');
  58. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
  59. print '<input type="hidden" name="token" value="'.newToken().'">';
  60. print '<input type="hidden" name="action" value="updateoptions">';
  61. print '<div class="div-table-responsive-no-min">';
  62. print '<table class="noborder centpercent">';
  63. print '<tr class="liste_titre">';
  64. print '<td>'.$langs->trans("Parameters").'</td>'."\n";
  65. print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
  66. print '<td></td>';
  67. // Utilisation formulaire Ajax sur choix produit
  68. print '<tr class="oddeven">';
  69. print '<td width="80%">'.$langs->trans("UseSearchToSelectResource").'</td>';
  70. if (empty($conf->use_javascript_ajax)) {
  71. print '<td class="nowrap right" colspan="2">';
  72. print $langs->trans("NotAvailableWhenAjaxDisabled");
  73. print '</td>';
  74. } else {
  75. print '<td width="60" class="right">';
  76. $arrval = array(
  77. '0'=>$langs->trans("No"),
  78. '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
  79. '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
  80. '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
  81. );
  82. print $form->selectarray("activate_RESOURCE_USE_SEARCH_TO_SELECT", $arrval, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
  83. print '</td>';
  84. print '<td class="right">';
  85. print '<input type="submit" class="button small" name="RESOURCE_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
  86. print '</td>';
  87. }
  88. print '</tr>';
  89. print '<tr class="oddeven">';
  90. print '<td>'.$langs->trans('EnableResourceUsedInEventCheck').'</td>';
  91. print '<td class="right">';
  92. echo ajax_constantonoff('RESOURCE_USED_IN_EVENT_CHECK');
  93. print '</td>';
  94. print '<td></td>';
  95. print '</tr>';
  96. /*
  97. print '<tr class="oddeven">';
  98. print '<td>'.$langs->trans('DisabledResourceLinkUser').'</td>';
  99. print '<td class="right">';
  100. echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_USER');
  101. print '</td>';
  102. print '<td></td>';
  103. print '</tr>';
  104. print '<tr class="oddeven">';
  105. print '<td>'.$langs->trans('DisabledResourceLinkContact').'</td>';
  106. print '<td class="right">';
  107. echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_THIPARTY');
  108. print '</td>';
  109. print '<td></td>';
  110. print '</tr>';
  111. */
  112. print '</table>';
  113. print '</div>';
  114. print '</form>';
  115. //RESOURCE_HIDE_ADD_CONTACT_USER
  116. //RESOURCE_HIDE_ADD_CONTACT_THIPARTY
  117. print dol_get_fiche_end();
  118. // End of page
  119. llxFooter();
  120. $db->close();