openinghours.php 6.5 KB

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