dolibarr 23.0.3
booking_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
4 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
8 * Copyright (C) 2023-2024 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
41require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
42require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_calendar.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php';
47
48
49// Load translation files required by the page
50$langs->loadLangs(array("agenda", "other"));
51
52$id = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility
53$ref = GETPOST('ref', 'alpha');
54$socid = GETPOSTINT('socid');
55$action = GETPOST('action', 'aZ09');
56$type = GETPOST('type', 'aZ09');
57
58$fieldid = (!empty($ref) ? 'ref' : 'rowid');
59if ($user->socid) {
60 $socid = $user->socid;
61}
62
63$moreparam = '';
64
65$object = new Calendar($db);
66
67// Load object
68if ($id > 0 || !empty($ref)) {
69 $ret = $object->fetch($id, $ref);
70 $isdraft = (($object->status == Calendar::STATUS_DRAFT) ? 1 : 0);
71 if ($ret > 0) {
72 $object->fetch_thirdparty();
73 }
74}
75
76// There is several ways to check permission.
77// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
78$enablepermissioncheck = 0;
79if ($enablepermissioncheck) {
80 $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read');
81 $permissiontoadd = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
82 $permissiontodelete = $user->hasRight('bookcal', 'calendar', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
83 $permissionnote = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_setnotes.inc.php
84 $permissiondellink = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_dellink.inc.php
85} else {
86 $permissiontoread = 1;
87 $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
88 $permissiontodelete = 1;
89 $permissionnote = 1;
90 $permissiondellink = 1;
91}
92
93if (!isModEnabled("bookcal")) {
95}
96if (!$permissiontoread) {
98}
99
100/*
101 * Actions
102 */
103
104$parameters = array();
105$helpurl = '';
106$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
107if ($reshook < 0) {
108 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
109}
110
111
112/*
113 * View
114 */
115
116$form = new Form($db);
117
118$now = dol_now();
119$title = $langs->trans('Calendar')." - ".$langs->trans('Bookings');
120
121llxHeader('', $title, $helpurl, '', 0, 0, '', '', '', 'mod-bookcal page-list');
122
123
124if ($object->id > 0) {
125 $head = calendarPrepareHead($object);
126
127 print dol_get_fiche_head($head, 'booking', $langs->trans("Calendar"), -1, $object->picto, 0, '', '', 0, '', 1);
128
129 $formconfirm = '';
130
131 // Call Hook formConfirm
132 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
133 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
134 if (empty($reshook)) {
135 $formconfirm .= $hookmanager->resPrint;
136 } elseif ($reshook > 0) {
137 $formconfirm = $hookmanager->resPrint;
138 }
139
140 // Print form confirm
141 print $formconfirm;
142
143
144 // Object card
145 // ------------------------------------------------------------
146 $linkback = '<a href="'.dol_buildpath('/bookcal/calendar_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
147
148 $morehtmlref = '<div class="refidno">';
149 $morehtmlref .= '</div>';
150
151
152 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
153
154
155 print '<div class="fichecenter">';
156 print '<div class="fichehalfleft">';
157 print '<div class="underbanner clearboth"></div>';
158 print '<table class="border centpercent tableforfield">'."\n";
159
160 // Common attributes
161 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
162
163 // Other attributes. Fields from hook formObjectOptions and Extrafields.
164 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
165
166 // Link to public page
167 print '<tr><td>Link</td>';
168 print '<td><a href="'. DOL_URL_ROOT.'/public/bookcal/index.php?id='.$object->id.'" target="_blank">Public page</a>';
169 print '</td></tr>';
170
171 print '</table>';
172 print '</div>';
173 print '</div>';
174
175 print '<div class="clearboth"></div>';
176
177 print dol_get_fiche_end();
178
179
180 /*
181 * Bookings
182 */
183
184 print '<div class="div-table-responsive-no-min">';
185 print '<table class="noborder centpercent">';
186
187 print '<tr class="liste_titre">';
188
189 print '<td class="left">'.$langs->trans("Ref").'</td>';
190 print '<td>'.$langs->trans("Title").'</td>';
191 print '<td class="center">'.$langs->trans("DateStart").'</td>';
192 print '<td class="center">'.$langs->trans("DateEnd").'</td>';
193 print '<td class="left">'.$langs->trans("Contact").'</td>';
194 print '</tr>';
195
196
197 $sql = "SELECT ac.id, ac.ref, ac.datep as date_start, ac.datep2 as date_end, ac.label, acr.fk_element as elementid";
198 $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as ac";
199 $sql .= " JOIN ".MAIN_DB_PREFIX."actioncomm_resources as acr on acr.fk_actioncomm = ac.id";
200 $sql .= " WHERE ac.fk_bookcal_calendar = ".((int) $object->id);
201 $sql .= " AND ac.code = 'AC_RDV'";
202 $sql .= " AND acr.element_type = 'socpeople'";
203
204 $resql = $db->query($sql);
205
206 $num = 0;
207 if ($resql) {
208 $i = 0;
209
210 $tmpcontact = new Contact($db);
211 $tmpactioncomm = new ActionComm($db);
212
213 $num = $db->num_rows($resql);
214 while ($i < $num) {
215 $obj = $db->fetch_object($resql);
216 $tmpcontact->fetch($obj->elementid);
217 $tmpactioncomm->fetch($obj->id);
218
219 print '<tr class="oddeven">';
220
221 // Ref
222 print '<td class="nowraponall">'.$tmpactioncomm->getNomUrl(1, -1)."</td>\n";
223
224 // Title
225 print '<td class="tdoverflowmax125">';
226 print $obj->label;
227 print '</td>';
228
229 // Amount
230 print '<td class="center">'.dol_print_date($db->jdate($obj->date_start), "dayhour").'</td>';
231
232 // Date process
233 print '<td class="center">'.dol_print_date($db->jdate($obj->date_end), "dayhour").'</td>';
234
235 // Link to make payment now
236 print '<td class="minwidth75">';
237 print $tmpcontact->getNomUrl(1, '-1');
238 print '</td>';
239
240 print "</tr>\n";
241 $i++;
242 }
243
244 $db->free($resql);
245 } else {
246 dol_print_error($db);
247 }
248
249 print "</table>";
250 print '</div>';
251}
252
253// End of page
254llxFooter();
255$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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
calendarPrepareHead($object)
Prepare array of tabs for Calendar.
Class to manage agenda events (actions)
Class for Calendar.
Class to manage contact/addresses.
Class to manage generation of HTML components Only common components must be here.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.