dolibarr 21.0.0-alpha
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 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';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
34require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
35require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_calendar.lib.php';
39
40// load module libraries
41require_once __DIR__.'/class/calendar.class.php';
42
43// Load translation files required by the page
44$langs->loadLangs(array("agenda", "other"));
45
46$id = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility
47$ref = GETPOST('ref', 'alpha');
48$socid = GETPOSTINT('socid');
49$action = GETPOST('action', 'aZ09');
50$type = GETPOST('type', 'aZ09');
51
52$fieldid = (!empty($ref) ? 'ref' : 'rowid');
53if ($user->socid) {
54 $socid = $user->socid;
55}
56
57$moreparam = '';
58
59$object = new Calendar($db);
60
61// Load object
62if ($id > 0 || !empty($ref)) {
63 $ret = $object->fetch($id, $ref);
64 $isdraft = (($object->status == Calendar::STATUS_DRAFT) ? 1 : 0);
65 if ($ret > 0) {
66 $object->fetch_thirdparty();
67 }
68}
69
70// There is several ways to check permission.
71// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
72$enablepermissioncheck = 0;
73if ($enablepermissioncheck) {
74 $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read');
75 $permissiontoadd = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
76 $permissiontodelete = $user->hasRight('bookcal', 'calendar', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
77 $permissionnote = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_setnotes.inc.php
78 $permissiondellink = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_dellink.inc.php
79} else {
80 $permissiontoread = 1;
81 $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
82 $permissiontodelete = 1;
83 $permissionnote = 1;
84 $permissiondellink = 1;
85}
86
87if (!isModEnabled("bookcal")) {
89}
90if (!$permissiontoread) {
92}
93
94/*
95 * Actions
96 */
97
98$parameters = array();
99$helpurl = '';
100$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
101if ($reshook < 0) {
102 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
103}
104
105
106/*
107 * View
108 */
109
110$form = new Form($db);
111
112$now = dol_now();
113$title = $langs->trans('Calendar')." - ".$langs->trans('Bookings');
114
115llxHeader('', $title, $helpurl, '', 0, 0, '', '', '', 'mod-bookcal page-list');
116
117
118if ($object->id > 0) {
119 $head = calendarPrepareHead($object);
120
121 print dol_get_fiche_head($head, 'booking', $langs->trans("Calendar"), -1, $object->picto, 0, '', '', 0, '', 1);
122
123 $formconfirm = '';
124
125 // Call Hook formConfirm
126 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
127 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
128 if (empty($reshook)) {
129 $formconfirm .= $hookmanager->resPrint;
130 } elseif ($reshook > 0) {
131 $formconfirm = $hookmanager->resPrint;
132 }
133
134 // Print form confirm
135 print $formconfirm;
136
137
138 // Object card
139 // ------------------------------------------------------------
140 $linkback = '<a href="'.dol_buildpath('/bookcal/calendar_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
141
142 $morehtmlref = '<div class="refidno">';
143 $morehtmlref .= '</div>';
144
145
146 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
147
148
149 print '<div class="fichecenter">';
150 print '<div class="fichehalfleft">';
151 print '<div class="underbanner clearboth"></div>';
152 print '<table class="border centpercent tableforfield">'."\n";
153
154 // Common attributes
155 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
156
157 // Other attributes. Fields from hook formObjectOptions and Extrafields.
158 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
159
160 // Link to public page
161 print '<tr><td>Link</td>';
162 print '<td><a href="'. DOL_URL_ROOT.'/public/bookcal/index.php?id='.$object->id.'" target="_blank">Public page</a>';
163 print '</td></tr>';
164
165 print '</table>';
166 print '</div>';
167 print '</div>';
168
169 print '<div class="clearboth"></div>';
170
171 print dol_get_fiche_end();
172
173
174 /*
175 * Bookings
176 */
177
178 print '<div class="div-table-responsive-no-min">';
179 print '<table class="noborder centpercent">';
180
181 print '<tr class="liste_titre">';
182
183 print '<td class="left">'.$langs->trans("Ref").'</td>';
184 print '<td>'.$langs->trans("Title").'</td>';
185 print '<td class="center">'.$langs->trans("DateStart").'</td>';
186 print '<td class="center">'.$langs->trans("DateEnd").'</td>';
187 print '<td class="left">'.$langs->trans("Contact").'</td>';
188 print '</tr>';
189
190
191 $sql = "SELECT ac.id, ac.ref, ac.datep as date_start, ac.datep2 as date_end, ac.label, acr.fk_element as elementid";
192 $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as ac";
193 $sql .= " JOIN ".MAIN_DB_PREFIX."actioncomm_resources as acr on acr.fk_actioncomm = ac.id";
194 $sql .= " WHERE ac.fk_bookcal_calendar = ".((int) $object->id);
195 $sql .= " AND ac.code = 'AC_RDV'";
196 $sql .= " AND acr.element_type = 'socpeople'";
197
198 $resql = $db->query($sql);
199
200 $num = 0;
201 if ($resql) {
202 $i = 0;
203
204 $tmpcontact = new Contact($db);
205 $tmpactioncomm = new ActionComm($db);
206
207 $num = $db->num_rows($resql);
208 while ($i < $num) {
209 $obj = $db->fetch_object($resql);
210 $tmpcontact->fetch($obj->elementid);
211 $tmpactioncomm->fetch($obj->id);
212
213 print '<tr class="oddeven">';
214
215 // Ref
216 print '<td class="nowraponall">'.$tmpactioncomm->getNomUrl(1, -1)."</td>\n";
217
218 // Title
219 print '<td class="tdoverflowmax125">';
220 print $obj->label;
221 print '</td>';
222
223 // Amount
224 print '<td class="center">'.dol_print_date($db->jdate($obj->date_start), "dayhour").'</td>';
225
226 // Date process
227 print '<td class="center">'.dol_print_date($db->jdate($obj->date_end), "dayhour").'</td>';
228
229 // Link to make payment now
230 print '<td class="minwidth75">';
231 print $tmpcontact->getNomUrl(1, -1);
232 print '</td>';
233
234 print "</tr>\n";
235 $i++;
236 }
237
238 $db->free($resql);
239 } else {
240 dol_print_error($db);
241 }
242
243 print "</table>";
244 print '</div>';
245}
246
247// End of page
248llxFooter();
249$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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:70
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.
llxFooter()
Footer empty.
Definition document.php:107
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)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.