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