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