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