openinghours.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /* Copyright (C) 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. * \file htdocs/admin/openinghours.php
  19. * \ingroup core
  20. * \brief Setup page to configure opening hours
  21. */
  22. // Load Dolibarr environment
  23. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  26. $action = GETPOST('action', 'aZ09');
  27. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'adminaccoutant'; // To manage different context of search
  28. // Load translation files required by the page
  29. $langs->loadLangs(array('admin', 'companies', 'other'));
  30. if (!$user->admin) {
  31. accessforbidden();
  32. }
  33. $error = 0;
  34. /*
  35. * Actions
  36. */
  37. $parameters = array();
  38. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  39. if ($reshook < 0) {
  40. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  41. }
  42. if (($action == 'update' && !GETPOST("cancel", 'alpha'))
  43. || ($action == 'updateedit')) {
  44. dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_MONDAY", GETPOST("monday", 'alpha'), 'chaine', 0, '', $conf->entity);
  45. dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_TUESDAY", GETPOST("tuesday", 'alpha'), 'chaine', 0, '', $conf->entity);
  46. dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_WEDNESDAY", GETPOST("wednesday", 'alpha'), 'chaine', 0, '', $conf->entity);
  47. dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_THURSDAY", GETPOST("thursday", 'alpha'), 'chaine', 0, '', $conf->entity);
  48. dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_FRIDAY", GETPOST("friday", 'alpha'), 'chaine', 0, '', $conf->entity);
  49. dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SATURDAY", GETPOST("saturday", 'alpha'), 'chaine', 0, '', $conf->entity);
  50. dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SUNDAY", GETPOST('sunday', 'alpha'), 'chaine', 0, '', $conf->entity);
  51. if ($action != 'updateedit' && !$error) {
  52. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  53. header("Location: ".$_SERVER["PHP_SELF"]);
  54. exit;
  55. }
  56. }
  57. /*
  58. * View
  59. */
  60. $form = new Form($db);
  61. $help_url = '';
  62. llxHeader('', $langs->trans("CompanyFoundation"), $help_url);
  63. print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
  64. $head = company_admin_prepare_head();
  65. print dol_get_fiche_head($head, 'openinghours', '', -1, '');
  66. print '<span class="opacitymedium">'.$langs->trans("OpeningHoursDesc")."</span><br>\n";
  67. print "<br><br>\n";
  68. if (empty($action) || $action == 'edit' || $action == 'updateedit') {
  69. /**
  70. * Edit parameters
  71. */
  72. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index">';
  73. print '<input type="hidden" name="token" value="'.newToken().'">';
  74. print '<input type="hidden" name="action" value="update">';
  75. print '<table class="noborder centpercent editmode">';
  76. print '<tr class="liste_titre"><th class="titlefieldcreate wordbreak">'.$langs->trans("Day").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
  77. print '<tr class="oddeven"><td>';
  78. print $form->textwithpicto($langs->trans("Monday"), $langs->trans("OpeningHoursFormatDesc"));
  79. print '</td><td>';
  80. print '<input name="monday" id="monday" class="minwidth100" value="'.(getDolGlobalString('MAIN_INFO_OPENINGHOURS_MONDAY') ? $conf->global->MAIN_INFO_OPENINGHOURS_MONDAY : GETPOST("monday", 'alpha')).'"'.(!getDolGlobalString('MAIN_INFO_OPENINGHOURS_MONDAY') ? ' autofocus="autofocus"' : '').'></td></tr>'."\n";
  81. print '<tr class="oddeven"><td>';
  82. print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc"));
  83. print '</td><td>';
  84. print '<input name="tuesday" id="tuesday" class="minwidth100" value="'.(getDolGlobalString('MAIN_INFO_OPENINGHOURS_TUESDAY') ? $conf->global->MAIN_INFO_OPENINGHOURS_TUESDAY : GETPOST("tuesday", 'alpha')).'"></td></tr>'."\n";
  85. print '<tr class="oddeven"><td>';
  86. print $form->textwithpicto($langs->trans("Wednesday"), $langs->trans("OpeningHoursFormatDesc"));
  87. print '</td><td>';
  88. print '<input name="wednesday" id="wednesday" class="minwidth100" value="'.(getDolGlobalString('MAIN_INFO_OPENINGHOURS_WEDNESDAY') ? $conf->global->MAIN_INFO_OPENINGHOURS_WEDNESDAY : GETPOST("wednesday", 'alpha')).'"></td></tr>'."\n";
  89. print '<tr class="oddeven"><td>';
  90. print $form->textwithpicto($langs->trans("Thursday"), $langs->trans("OpeningHoursFormatDesc"));
  91. print '</td><td>';
  92. print '<input name="thursday" id="thursday" class="minwidth100" value="'.(getDolGlobalString('MAIN_INFO_OPENINGHOURS_THURSDAY') ? $conf->global->MAIN_INFO_OPENINGHOURS_THURSDAY : GETPOST("thursday", 'alpha')).'"></td></tr>'."\n";
  93. print '<tr class="oddeven"><td>';
  94. print $form->textwithpicto($langs->trans("Friday"), $langs->trans("OpeningHoursFormatDesc"));
  95. print '</td><td>';
  96. print '<input name="friday" id="friday" class="minwidth100" value="'.(getDolGlobalString('MAIN_INFO_OPENINGHOURS_FRIDAY') ? $conf->global->MAIN_INFO_OPENINGHOURS_FRIDAY : GETPOST("friday", 'alpha')).'"></td></tr>'."\n";
  97. print '<tr class="oddeven"><td>';
  98. print $form->textwithpicto($langs->trans("Saturday"), $langs->trans("OpeningHoursFormatDesc"));
  99. print '</td><td>';
  100. print '<input name="saturday" id="saturday" class="minwidth100" value="'.(getDolGlobalString('MAIN_INFO_OPENINGHOURS_SATURDAY') ? $conf->global->MAIN_INFO_OPENINGHOURS_SATURDAY : GETPOST("saturday", 'alpha')).'"></td></tr>'."\n";
  101. print '<tr class="oddeven"><td>';
  102. print $form->textwithpicto($langs->trans("Sunday"), $langs->trans("OpeningHoursFormatDesc"));
  103. print '</td><td>';
  104. print '<input name="sunday" id="sunday" class="minwidth100" value="'.(getDolGlobalString('MAIN_INFO_OPENINGHOURS_SUNDAY') ? $conf->global->MAIN_INFO_OPENINGHOURS_SUNDAY : GETPOST("sunday", 'alpha')).'"></td></tr>'."\n";
  105. print '</table>';
  106. print $form->buttonsSaveCancel("Save", '');
  107. print '</form>';
  108. }
  109. llxFooter();
  110. $db->close();