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