dolibarr  17.0.3
booking_card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2022 Alice Adminson <aadminson@example.com>
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
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
30 dol_include_once('/bookcal/class/booking.class.php');
31 dol_include_once('/bookcal/lib/bookcal_booking.lib.php');
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array("bookcal@bookcal", "other"));
35 
36 // Get parameters
37 $id = GETPOST('id', 'int');
38 $ref = GETPOST('ref', 'alpha');
39 $lineid = GETPOST('lineid', 'int');
40 
41 $action = GETPOST('action', 'aZ09');
42 $confirm = GETPOST('confirm', 'alpha');
43 $cancel = GETPOST('cancel', 'aZ09');
44 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
45 $backtopage = GETPOST('backtopage', 'alpha');
46 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
47 $dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
48 
49 // Initialize technical objects
50 $object = new Booking($db);
51 $extrafields = new ExtraFields($db);
52 $diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
53 $hookmanager->initHooks(array('bookingcard', 'globalcard')); // Note that conf->hooks_modules contains array
54 
55 // Fetch optionals attributes and labels
56 $extrafields->fetch_name_optionals_label($object->table_element);
57 
58 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
59 
60 // Initialize array of search criterias
61 $search_all = GETPOST("search_all", 'alpha');
62 $search = array();
63 foreach ($object->fields as $key => $val) {
64  if (GETPOST('search_'.$key, 'alpha')) {
65  $search[$key] = GETPOST('search_'.$key, 'alpha');
66  }
67 }
68 
69 if (empty($action) && empty($id) && empty($ref)) {
70  $action = 'view';
71 }
72 
73 // Load object
74 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
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;
79 if ($enablepermissioncheck) {
80  $permissiontoread = $user->rights->bookcal->booking->read;
81  $permissiontoadd = $user->rights->bookcal->booking->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
82  $permissiontodelete = $user->rights->bookcal->booking->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
83  $permissionnote = $user->rights->bookcal->booking->write; // Used by the include of actions_setnotes.inc.php
84  $permissiondellink = $user->rights->bookcal->booking->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 
93 $upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->entity : 1].'/booking';
94 
95 // Security check (enable the most restrictive one)
96 //if ($user->socid > 0) accessforbidden();
97 //if ($user->socid > 0) $socid = $user->socid;
98 //$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
99 //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
100 if (empty($conf->bookcal->enabled)) accessforbidden();
101 if (!$permissiontoread) accessforbidden();
102 
103 
104 /*
105  * Actions
106  */
107 
108 $parameters = array();
109 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
110 if ($reshook < 0) {
111  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
112 }
113 
114 if (empty($reshook)) {
115  $error = 0;
116 
117  $backurlforlist = dol_buildpath('/bookcal/booking_list.php', 1);
118 
119  if (empty($backtopage) || ($cancel && empty($id))) {
120  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
121  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
122  $backtopage = $backurlforlist;
123  } else {
124  $backtopage = dol_buildpath('/bookcal/booking_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
125  }
126  }
127  }
128 
129  $triggermodname = 'BOOKCAL_BOOKING_MODIFY'; // Name of trigger action code to execute when we modify record
130 
131  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
132  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
133 
134  // Actions when linking object each other
135  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
136 
137  // Actions when printing a doc from card
138  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
139 
140  // Action to move up and down lines of object
141  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
142 
143  // Action to build doc
144  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
145 
146  if ($action == 'set_thirdparty' && $permissiontoadd) {
147  $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
148  }
149  if ($action == 'classin' && $permissiontoadd) {
150  $object->setProject(GETPOST('projectid', 'int'));
151  }
152 
153  // Actions to send emails
154  $triggersendname = 'BOOKCAL_BOOKING_SENTBYMAIL';
155  $autocopy = 'MAIN_MAIL_AUTOCOPY_BOOKING_TO';
156  $trackid = 'booking'.$object->id;
157  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
158 }
159 
160 
161 
162 
163 /*
164  * View
165  *
166  * Put here all code to build page
167  */
168 
169 $form = new Form($db);
170 $formfile = new FormFile($db);
171 $formproject = new FormProjets($db);
172 
173 $title = $langs->trans("Booking");
174 $help_url = '';
175 llxHeader('', $title, $help_url);
176 
177 // Example : Adding jquery code
178 // print '<script type="text/javascript">
179 // jQuery(document).ready(function() {
180 // function init_myfunc()
181 // {
182 // jQuery("#myid").removeAttr(\'disabled\');
183 // jQuery("#myid").attr(\'disabled\',\'disabled\');
184 // }
185 // init_myfunc();
186 // jQuery("#mybutton").click(function() {
187 // init_myfunc();
188 // });
189 // });
190 // </script>';
191 
192 
193 // Part to create
194 if ($action == 'create') {
195  if (empty($permissiontoadd)) {
196  accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1);
197  exit;
198  }
199 
200  print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Booking")), '', 'object_'.$object->picto);
201 
202  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
203  print '<input type="hidden" name="token" value="'.newToken().'">';
204  print '<input type="hidden" name="action" value="add">';
205  if ($backtopage) {
206  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
207  }
208  if ($backtopageforcancel) {
209  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
210  }
211 
212  print dol_get_fiche_head(array(), '');
213 
214  // Set some default values
215  //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
216 
217  print '<table class="border centpercent tableforfieldcreate">'."\n";
218 
219  // Common attributes
220  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
221 
222  // Other attributes
223  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
224 
225  print '</table>'."\n";
226 
227  print dol_get_fiche_end();
228 
229  print $form->buttonsSaveCancel("Create");
230 
231  print '</form>';
232 
233  //dol_set_focus('input[name="ref"]');
234 }
235 
236 // Part to edit record
237 if (($id || $ref) && $action == 'edit') {
238  print load_fiche_titre($langs->trans("Booking"), '', 'object_'.$object->picto);
239 
240  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
241  print '<input type="hidden" name="token" value="'.newToken().'">';
242  print '<input type="hidden" name="action" value="update">';
243  print '<input type="hidden" name="id" value="'.$object->id.'">';
244  if ($backtopage) {
245  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
246  }
247  if ($backtopageforcancel) {
248  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
249  }
250 
251  print dol_get_fiche_head();
252 
253  print '<table class="border centpercent tableforfieldedit">'."\n";
254 
255  // Common attributes
256  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
257 
258  // Other attributes
259  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
260 
261  print '</table>';
262 
263  print dol_get_fiche_end();
264 
265  print $form->buttonsSaveCancel();
266 
267  print '</form>';
268 }
269 
270 // Part to show record
271 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
272  $res = $object->fetch_optionals();
273 
274  $head = bookingPrepareHead($object);
275  print dol_get_fiche_head($head, 'card', $langs->trans("Booking"), -1, $object->picto);
276 
277  $formconfirm = '';
278 
279  // Confirmation to delete
280  if ($action == 'delete') {
281  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBooking'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
282  }
283  // Confirmation to delete line
284  if ($action == 'deleteline') {
285  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
286  }
287 
288  // Clone confirmation
289  if ($action == 'clone') {
290  // Create an array for form
291  $formquestion = array();
292  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
293  }
294 
295  // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
296  if ($action == 'xxx') {
297  $text = $langs->trans('ConfirmActionBooking', $object->ref);
298  /*if (! empty($conf->notification->enabled))
299  {
300  require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
301  $notify = new Notify($db);
302  $text .= '<br>';
303  $text .= $notify->confirmMessage('BOOKING_CLOSE', $object->socid, $object);
304  }*/
305 
306  $formquestion = array();
307  /*
308  $forcecombo=0;
309  if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
310  $formquestion = array(
311  // 'text' => $langs->trans("ConfirmClone"),
312  // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
313  // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
314  // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
315  );
316  */
317  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
318  }
319 
320  // Call Hook formConfirm
321  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
322  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
323  if (empty($reshook)) {
324  $formconfirm .= $hookmanager->resPrint;
325  } elseif ($reshook > 0) {
326  $formconfirm = $hookmanager->resPrint;
327  }
328 
329  // Print form confirm
330  print $formconfirm;
331 
332 
333  // Object card
334  // ------------------------------------------------------------
335  $linkback = '<a href="'.dol_buildpath('/bookcal/booking_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
336 
337  $morehtmlref = '<div class="refidno">';
338  /*
339  // Ref customer
340  $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
341  $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
342  // Thirdparty
343  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
344  // Project
345  if (! empty($conf->project->enabled)) {
346  $langs->load("projects");
347  $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
348  if ($permissiontoadd) {
349  //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
350  $morehtmlref .= ' : ';
351  if ($action == 'classify') {
352  //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300');
353  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
354  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
355  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
356  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
357  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
358  $morehtmlref .= '</form>';
359  } else {
360  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
361  }
362  } else {
363  if (! empty($object->fk_project)) {
364  $proj = new Project($db);
365  $proj->fetch($object->fk_project);
366  $morehtmlref .= ': '.$proj->getNomUrl();
367  } else {
368  $morehtmlref .= '';
369  }
370  }
371  }*/
372  $morehtmlref .= '</div>';
373 
374 
375  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
376 
377 
378  print '<div class="fichecenter">';
379  print '<div class="fichehalfleft">';
380  print '<div class="underbanner clearboth"></div>';
381  print '<table class="border centpercent tableforfield">'."\n";
382 
383  // Common attributes
384  //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
385  //unset($object->fields['fk_project']); // Hide field already shown in banner
386  //unset($object->fields['fk_soc']); // Hide field already shown in banner
387  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
388 
389  // Other attributes. Fields from hook formObjectOptions and Extrafields.
390  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
391 
392  print '</table>';
393  print '</div>';
394  print '</div>';
395 
396  print '<div class="clearboth"></div>';
397 
398  print dol_get_fiche_end();
399 
400 
401  /*
402  * Lines
403  */
404 
405  if (!empty($object->table_element_line)) {
406  // Show object lines
407  $result = $object->getLinesArray();
408 
409  print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
410  <input type="hidden" name="token" value="' . newToken().'">
411  <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
412  <input type="hidden" name="mode" value="">
413  <input type="hidden" name="page_y" value="">
414  <input type="hidden" name="id" value="' . $object->id.'">
415  ';
416 
417  if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
418  include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
419  }
420 
421  print '<div class="div-table-responsive-no-min">';
422  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
423  print '<table id="tablelines" class="noborder noshadow" width="100%">';
424  }
425 
426  if (!empty($object->lines)) {
427  $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
428  }
429 
430  // Form to add new line
431  if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
432  if ($action != 'editline') {
433  // Add products/services form
434 
435  $parameters = array();
436  $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
437  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
438  if (empty($reshook))
439  $object->formAddObjectLine(1, $mysoc, $soc);
440  }
441  }
442 
443  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
444  print '</table>';
445  }
446  print '</div>';
447 
448  print "</form>\n";
449  }
450 
451 
452  // Buttons for actions
453 
454  if ($action != 'presend' && $action != 'editline') {
455  print '<div class="tabsAction">'."\n";
456  $parameters = array();
457  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
458  if ($reshook < 0) {
459  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
460  }
461 
462  if (empty($reshook)) {
463  // Send
464  if (empty($user->socid)) {
465  print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle');
466  }
467 
468  // Back to draft
469  if ($object->status == $object::STATUS_VALIDATED) {
470  print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
471  }
472 
473  print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
474 
475  // Validate
476  if ($object->status == $object::STATUS_DRAFT) {
477  if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
478  print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
479  } else {
480  $langs->load("errors");
481  print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
482  }
483  }
484 
485  // Clone
486  print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd);
487 
488  /*
489  if ($permissiontoadd) {
490  if ($object->status == $object::STATUS_ENABLED) {
491  print dolGetButtonAction($langs->trans('Disable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
492  } else {
493  print dolGetButtonAction($langs->trans('Enable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
494  }
495  }
496  if ($permissiontoadd) {
497  if ($object->status == $object::STATUS_VALIDATED) {
498  print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
499  } else {
500  print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
501  }
502  }
503  */
504 
505  // Delete (need delete permission, or if draft, just need create/modify permission)
506  print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
507  }
508  print '</div>'."\n";
509  }
510 
511 
512  // Select mail models is same action as presend
513  if (GETPOST('modelselected')) {
514  $action = 'presend';
515  }
516 
517  if ($action != 'presend') {
518  print '<div class="fichecenter"><div class="fichehalfleft">';
519  print '<a name="builddoc"></a>'; // ancre
520 
521  $includedocgeneration = 0;
522 
523  // Documents
524  if ($includedocgeneration) {
525  $objref = dol_sanitizeFileName($object->ref);
526  $relativepath = $objref.'/'.$objref.'.pdf';
527  $filedir = $conf->bookcal->dir_output.'/'.$object->element.'/'.$objref;
528  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
529  $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content
530  $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card
531  print $formfile->showdocuments('bookcal:Booking', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
532  }
533 
534  // Show links to link elements
535  $linktoelem = $form->showLinkToObjectBlock($object, null, array('booking'));
536  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
537 
538 
539  print '</div><div class="fichehalfright">';
540 
541  $MAXEVENT = 10;
542 
543  $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/bookcal/booking_agenda.php', 1).'?id='.$object->id);
544 
545  // List of actions on element
546  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
547  $formactions = new FormActions($db);
548  $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
549 
550  print '</div></div>';
551  }
552 
553  //Select mail models is same action as presend
554  if (GETPOST('modelselected')) {
555  $action = 'presend';
556  }
557 
558  // Presend form
559  $modelmail = 'booking';
560  $defaulttopic = 'InformationMessage';
561  $diroutput = $conf->bookcal->dir_output;
562  $trackid = 'booking'.$object->id;
563 
564  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
565 }
566 
567 // End of page
568 llxFooter();
569 $db->close();
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1225
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5360
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:520
FormActions
Class to manage building of HTML components.
Definition: html.formactions.class.php:30
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1032
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1061
FormProjets
Class to manage building of HTML components.
Definition: html.formprojet.class.php:30
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_banner_tab
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.
Definition: functions.lib.php:2082
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
Booking
Class for Booking.
Definition: booking.class.php:33
$formactions
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
Definition: agenda_other.php:179
$formconfirm
$formconfirm
if ($action == 'delbookkeepingyear') {
Definition: listbyaccount.php:614
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:11021
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1858
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11294
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2054
dolGetButtonAction
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
Definition: functions.lib.php:10857
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
bookingPrepareHead
bookingPrepareHead($object)
Prepare array of tabs for Booking.
Definition: bookcal_booking.lib.php:30
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8465
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1125