dolibarr 24.0.0-beta
openinghours.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
3 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
29
30$action = GETPOST('action', 'aZ09');
31$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'adminaccoutant'; // To manage different context of search
32
41// Load translation files required by the page
42$langs->loadLangs(array('admin', 'companies', 'other'));
43
44if (!$user->admin) {
46}
47
48$error = 0;
49
50
51/*
52 * Actions
53 */
54
55$parameters = array();
56$object = null;
57$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
58if ($reshook < 0) {
59 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
60}
61
62if (($action == 'update' && !GETPOST("cancel", 'alpha'))
63|| ($action == 'updateedit')) {
64 if (!dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_MONDAY", GETPOST("monday", 'alpha'), 'chaine', 0, '', $conf->entity)) {
65 $error++;
66 }
67 if (!dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_TUESDAY", GETPOST("tuesday", 'alpha'), 'chaine', 0, '', $conf->entity)) {
68 $error++;
69 }
70 if (!dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_WEDNESDAY", GETPOST("wednesday", 'alpha'), 'chaine', 0, '', $conf->entity)) {
71 $error++;
72 }
73 if (!dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_THURSDAY", GETPOST("thursday", 'alpha'), 'chaine', 0, '', $conf->entity)) {
74 $error++;
75 }
76 if (!dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_FRIDAY", GETPOST("friday", 'alpha'), 'chaine', 0, '', $conf->entity)) {
77 $error++;
78 }
79 if (!dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SATURDAY", GETPOST("saturday", 'alpha'), 'chaine', 0, '', $conf->entity)) {
80 $error++;
81 }
82 if (!dolibarr_set_const($db, "MAIN_INFO_OPENINGHOURS_SUNDAY", GETPOST('sunday', 'alpha'), 'chaine', 0, '', $conf->entity)) {
83 $error++;
84 }
85
86 if ($action != 'updateedit' && !$error) {
87 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
88 header("Location: ".$_SERVER["PHP_SELF"]);
89 exit;
90 }
91}
92
93/*
94 * View
95 */
96
97$form = new Form($db);
98
99$help_url = '';
100llxHeader('', $langs->trans("CompanyFoundation"), $help_url, '', 0, 0, '', '', '', 'mod-admin page-openinghours');
101
102print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
103
105
106print dol_get_fiche_head($head, 'openinghours', '', -1, '');
107
108print '<span class="opacitymedium">'.$langs->trans("OpeningHoursDesc")."</span><br>\n";
109print "<br><br>\n";
110
111if (empty($action) || $action == 'edit' || $action == 'updateedit') {
115 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index">';
116 print '<input type="hidden" name="token" value="'.newToken().'">';
117 print '<input type="hidden" name="action" value="update">';
118
119 print '<table class="noborder centpercent editmode">';
120 print '<tr class="liste_titre"><th class="titlefieldcreate wordbreak">'.$langs->trans("Day").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
121
122 print '<tr class="oddeven"><td>';
123 print $form->textwithpicto($langs->trans("Monday"), $langs->trans("OpeningHoursFormatDesc"));
124 print '</td><td>';
125 print '<input name="monday" id="monday" class="minwidth100" value="'.getDolGlobalString('MAIN_INFO_OPENINGHOURS_MONDAY', GETPOST("monday", 'alpha')).'"'.(getDolGlobalString('MAIN_INFO_OPENINGHOURS_MONDAY') ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
126
127 print '<tr class="oddeven"><td>';
128 print $form->textwithpicto($langs->trans("Tuesday"), $langs->trans("OpeningHoursFormatDesc"));
129 print '</td><td>';
130 print '<input name="tuesday" id="tuesday" class="minwidth100" value="'.getDolGlobalString('MAIN_INFO_OPENINGHOURS_TUESDAY', GETPOST("tuesday", 'alpha')).'"></td></tr>'."\n";
131
132 print '<tr class="oddeven"><td>';
133 print $form->textwithpicto($langs->trans("Wednesday"), $langs->trans("OpeningHoursFormatDesc"));
134 print '</td><td>';
135 print '<input name="wednesday" id="wednesday" class="minwidth100" value="'.getDolGlobalString('MAIN_INFO_OPENINGHOURS_WEDNESDAY', GETPOST("wednesday", 'alpha')).'"></td></tr>'."\n";
136
137 print '<tr class="oddeven"><td>';
138 print $form->textwithpicto($langs->trans("Thursday"), $langs->trans("OpeningHoursFormatDesc"));
139 print '</td><td>';
140 print '<input name="thursday" id="thursday" class="minwidth100" value="'.getDolGlobalString('MAIN_INFO_OPENINGHOURS_THURSDAY', GETPOST("thursday", 'alpha')).'"></td></tr>'."\n";
141
142 print '<tr class="oddeven"><td>';
143 print $form->textwithpicto($langs->trans("Friday"), $langs->trans("OpeningHoursFormatDesc"));
144 print '</td><td>';
145 print '<input name="friday" id="friday" class="minwidth100" value="'.getDolGlobalString('MAIN_INFO_OPENINGHOURS_FRIDAY', GETPOST("friday", 'alpha')).'"></td></tr>'."\n";
146
147 print '<tr class="oddeven"><td>';
148 print $form->textwithpicto($langs->trans("Saturday"), $langs->trans("OpeningHoursFormatDesc"));
149 print '</td><td>';
150 print '<input name="saturday" id="saturday" class="minwidth100" value="'.getDolGlobalString('MAIN_INFO_OPENINGHOURS_SATURDAY', GETPOST("saturday", 'alpha')).'"></td></tr>'."\n";
151
152 print '<tr class="oddeven"><td>';
153 print $form->textwithpicto($langs->trans("Sunday"), $langs->trans("OpeningHoursFormatDesc"));
154 print '</td><td>';
155 print '<input name="sunday" id="sunday" class="minwidth100" value="'.getDolGlobalString('MAIN_INFO_OPENINGHOURS_SUNDAY', GETPOST("sunday", 'alpha')).'"></td></tr>'."\n";
156
157 print '</table>';
158
159 print $form->buttonsSaveCancel("Save", '');
160
161 print '</form>';
162}
163
164llxFooter();
165
166$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
company_admin_prepare_head()
Return array head with list of tabs to view object information.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.