dolibarr 21.0.0-alpha
availabilities_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
26require '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
30require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php';
31require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php';
32
33// Load translation files required by the page
34$langs->loadLangs(array("agenda", "other"));
35
36// Get parameters
37$id = GETPOSTINT('id');
38$ref = GETPOST('ref', 'alpha');
39$lineid = GETPOSTINT('lineid');
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 a technical objects
50$object = new Availabilities($db);
51$extrafields = new ExtraFields($db);
52$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
53$hookmanager->initHooks(array('availabilitiescard', '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 criteria
61$search_all = GETPOST("search_all", 'alpha');
62$search = array();
63foreach ($object->fields as $key => $val) {
64 if (GETPOST('search_'.$key, 'alpha')) {
65 $search[$key] = GETPOST('search_'.$key, 'alpha');
66 }
67}
68
69if (empty($action) && empty($id) && empty($ref)) {
70 $action = 'view';
71}
72
73// Load object
74include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
75
76//avoid warning on missing/undef entity
77$object->entity = (GETPOSTISSET('entity') ? GETPOSTINT('entity') : $conf->entity);
78
79// There is several ways to check permission.
80// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
81$enablepermissioncheck = 0;
82if ($enablepermissioncheck) {
83 $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
84 $permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
85 $permissiontodelete = $user->hasRight('bookcal', 'availabilities', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
86 $permissionnote = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_setnotes.inc.php
87 $permissiondellink = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_dellink.inc.php
88} else {
89 $permissiontoread = 1;
90 $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
91 $permissiontodelete = 1;
92 $permissionnote = 1;
93 $permissiondellink = 1;
94}
95
96$upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->entity : 1].'/availabilities';
97
98// Security check (enable the most restrictive one)
99//if ($user->socid > 0) accessforbidden();
100//if ($user->socid > 0) $socid = $user->socid;
101//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
102//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
103if (!isModEnabled('bookcal')) {
105}
106if (!$permissiontoread) {
108}
109
110
111
112
113
114
115/*
116 * Actions
117 */
118
119$parameters = array();
120$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
121if ($reshook < 0) {
122 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
123}
124
125if (empty($reshook)) {
126 $error = 0;
127
128 $backurlforlist = dol_buildpath('/bookcal/availabilities_list.php', 1);
129
130 if (empty($backtopage) || ($cancel && empty($id))) {
131 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
132 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
133 $backtopage = $backurlforlist;
134 } else {
135 $backtopage = dol_buildpath('/bookcal/availabilities_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
136 }
137 }
138 }
139
140 $triggermodname = 'BOOKCAL_AVAILABILITIES_MODIFY'; // Name of trigger action code to execute when we modify record
141
142
143 $startday = GETPOST('startday', 'int');
144 $startmonth = GETPOST('startmonth', 'int');
145 $startyear = GETPOST('startyear', 'int');
146 $starthour = GETPOST('startHour', 'int');
147
148 if ($starthour == "0") {
149 $error++;
150 setEventMessages($langs->trans("ErrorStartHourIsNull"), $hookmanager->errors, 'errors');
151 }
152
153 $dateStartTimestamp = dol_mktime($starthour, 0, 0, $startmonth, $startday, $startyear);
154
155 $endday = GETPOST('endday', 'int');
156 $endmonth = GETPOST('endmonth', 'int');
157 $endyear = GETPOST('endyear', 'int');
158 $endhour = GETPOST('endHour', 'int');
159
160 if ($endhour == "0") {
161 $error++;
162 setEventMessages($langs->trans("ErrorEndHourIsNull"), $hookmanager->errors, 'errors');
163 }
164
165 $dateEndTimestamp = dol_mktime($endhour, 0, 0, $endmonth, $endday, $endyear);
166
167 // check hours
168 if ($starthour > $endhour) {
169 if ($dateStartTimestamp === $dateEndTimestamp) {
170 $error++;
171 setEventMessages($langs->trans("ErrorEndTimeMustBeGreaterThanStartTime"), $hookmanager->errors, 'errors');
172 }
173 }
174
175 // check date
176 if (($dateStartTimestamp != "") && ($dateStartTimestamp >= $dateEndTimestamp)) {
177 $error++;
178 setEventMessages($langs->trans("ErrorIncoherentDates"), $hookmanager->errors, 'errors');
179 }
180
181
182 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
183 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
184
185 // Actions when linking object each other
186 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
187
188 // Actions when printing a doc from card
189 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
190
191 // Action to move up and down lines of object
192 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
193
194 // Action to build doc
195 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
196
197 if ($action == 'set_thirdparty' && $permissiontoadd) {
198 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', '', 'date', '', $user, $triggermodname);
199 }
200 if ($action == 'classin' && $permissiontoadd) {
201 $object->setProject(GETPOSTINT('projectid'));
202 }
203
204 // Actions to send emails
205 $triggersendname = 'BOOKCAL_AVAILABILITIES_SENTBYMAIL';
206 $autocopy = 'MAIN_MAIL_AUTOCOPY_AVAILABILITIES_TO';
207 $trackid = 'availabilities'.$object->id;
208 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
209}
210
211
212
213
214/*
215 * View
216 *
217 * Put here all code to build page
218 */
219
220$form = new Form($db);
221$formfile = new FormFile($db);
222$formproject = new FormProjets($db);
223
224$title = $langs->trans("Availabilities");
225$help_url = '';
226llxHeader('', $title, $help_url);
227
228// Example : Adding jquery code
229// print '<script type="text/javascript">
230// jQuery(document).ready(function() {
231// function init_myfunc()
232// {
233// jQuery("#myid").removeAttr(\'disabled\');
234// jQuery("#myid").attr(\'disabled\',\'disabled\');
235// }
236// init_myfunc();
237// jQuery("#mybutton").click(function() {
238// init_myfunc();
239// });
240// });
241// </script>';
242
243
244// Part to create
245if ($action == 'create') {
246 if (empty($permissiontoadd)) {
247 accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1);
248 exit;
249 }
250
251 print load_fiche_titre($langs->trans("NewAvailabilities"), '', '', 'object_'.$object->picto);
252 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
253 print '<input type="hidden" name="token" value="'.newToken().'">';
254 if ($error != 0) {
255 print '<input type="hidden" name="action" value="create">';
256 } else {
257 print '<input type="hidden" name="action" value="add">';
258 }
259 if ($backtopage) {
260 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
261 }
262 if ($backtopageforcancel) {
263 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
264 }
265
266 print dol_get_fiche_head(array(), '');
267
268 print '<table class="border centpercent tableforfieldcreate">'."\n";
269
270 // Common attributes
271 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
272
273 // Other attributes
274 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
275
276 print '</table>'."\n";
277
278 print dol_get_fiche_end();
279
280 print $form->buttonsSaveCancel("Create");
281
282 print '</form>';
283
284 //dol_set_focus('input[name="ref"]');
285}
286
287// Part to edit record
288if (($id || $ref) && $action == 'edit') {
289 print load_fiche_titre($langs->trans("Availabilities"), '', 'object_'.$object->picto);
290
291 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
292 print '<input type="hidden" name="token" value="'.newToken().'">';
293 print '<input type="hidden" name="action" value="update">';
294 print '<input type="hidden" name="id" value="'.$object->id.'">';
295 if ($backtopage) {
296 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
297 }
298 if ($backtopageforcancel) {
299 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
300 }
301
302 print dol_get_fiche_head();
303
304 print '<table class="border centpercent tableforfieldedit">'."\n";
305
306 // Common attributes
307 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
308
309 // Other attributes
310 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
311
312 print '</table>';
313
314 print dol_get_fiche_end();
315
316 print $form->buttonsSaveCancel();
317
318 print '</form>';
319}
320
321// Part to show record
322if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
323 $res = $object->fetch_optionals();
324
325 $head = availabilitiesPrepareHead($object);
326 print dol_get_fiche_head($head, 'card', $langs->trans("Availabilities"), -1, $object->picto);
327
328 $formconfirm = '';
329
330 // Confirmation to delete
331 if ($action == 'delete') {
332 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteAvailabilities'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
333 }
334 // Confirmation to delete line
335 if ($action == 'deleteline') {
336 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
337 }
338
339 // Clone confirmation
340 if ($action == 'clone') {
341 // Create an array for form
342 $formquestion = array();
343 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
344 }
345
346
347 // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
348 if ($action == 'xxx') {
349 $text = $langs->trans('ConfirmActionAvailabilities', $object->ref);
350 /*if (! empty($conf->notification->enabled))
351 {
352 require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
353 $notify = new Notify($db);
354 $text .= '<br>';
355 $text .= $notify->confirmMessage('AVAILABILITIES_CLOSE', $object->socid, $object);
356 }*/
357
358 $formquestion = array();
359 /*
360 $forcecombo=0;
361 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
362 $formquestion = array(
363 // 'text' => $langs->trans("ConfirmClone"),
364 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
365 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
366 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
367 );
368 */
369 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
370 }
371
372 // Call Hook formConfirm
373 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
374 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
375 if (empty($reshook)) {
376 $formconfirm .= $hookmanager->resPrint;
377 } elseif ($reshook > 0) {
378 $formconfirm = $hookmanager->resPrint;
379 }
380
381 // Print form confirm
382 print $formconfirm;
383
384
385 // Object card
386 // ------------------------------------------------------------
387 $linkback = '<a href="'.dol_buildpath('/bookcal/availabilities_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
388
389 $morehtmlref = '<div class="refidno">';
390 /*
391 // Ref customer
392 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
393 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
394 // Thirdparty
395 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
396 // Project
397 if (isModEnabled('project')) {
398 $langs->load("projects");
399 $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
400 if ($permissiontoadd) {
401 //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
402 $morehtmlref .= ' : ';
403 if ($action == 'classify') {
404 //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300');
405 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
406 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
407 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
408 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
409 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
410 $morehtmlref .= '</form>';
411 } else {
412 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
413 }
414 } else {
415 if (! empty($object->fk_project)) {
416 $proj = new Project($db);
417 $proj->fetch($object->fk_project);
418 $morehtmlref .= ': '.$proj->getNomUrl();
419 } else {
420 $morehtmlref .= '';
421 }
422 }
423 }*/
424 $morehtmlref .= '</div>';
425
426
427 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
428
429
430 print '<div class="fichecenter">';
431 print '<div class="fichehalfleft">';
432 print '<div class="underbanner clearboth"></div>';
433 print '<table class="border centpercent tableforfield">'."\n";
434
435 // Common attributes
436 //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
437 //unset($object->fields['fk_project']); // Hide field already shown in banner
438 //unset($object->fields['fk_soc']); // Hide field already shown in banner
439 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
440
441 // Other attributes. Fields from hook formObjectOptions and Extrafields.
442 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
443
444 print '</table>';
445 print '</div>';
446 print '</div>';
447
448 print '<div class="clearboth"></div>';
449
450 print dol_get_fiche_end();
451
452
453 /*
454 * Lines
455 */
456
457 if (!empty($object->table_element_line)) {
458 // Show object lines
459 $result = $object->getLinesArray();
460
461 print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOSTINT('lineid')).'" method="POST">
462 <input type="hidden" name="token" value="' . newToken().'">
463 <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
464 <input type="hidden" name="mode" value="">
465 <input type="hidden" name="page_y" value="">
466 <input type="hidden" name="id" value="' . $object->id.'">
467 ';
468
469 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
470 include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
471 }
472
473 print '<div class="div-table-responsive-no-min">';
474 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
475 print '<table id="tablelines" class="noborder noshadow" width="100%">';
476 }
477
478 if (!empty($object->lines)) {
479 $object->printObjectLines($action, $mysoc, null, GETPOSTINT('lineid'), 1);
480 }
481
482 // Form to add new line
483 if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
484 if ($action != 'editline') {
485 // Add products/services form
486
487 $parameters = array();
488 $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
489 if ($reshook < 0) {
490 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
491 }
492 if (empty($reshook)) {
493 $object->formAddObjectLine(1, $mysoc, $soc);
494 }
495 }
496 }
497
498 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
499 print '</table>';
500 }
501 print '</div>';
502
503 print "</form>\n";
504 }
505
506
507 // Buttons for actions
508
509 if ($action != 'presend' && $action != 'editline') {
510 print '<div class="tabsAction">'."\n";
511 $parameters = array();
512 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
513 if ($reshook < 0) {
514 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
515 }
516
517 if (empty($reshook)) {
518 // Send
519 if (empty($user->socid)) {
520 print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle');
521 }
522
523 // Back to draft
524 if ($object->status == $object::STATUS_VALIDATED) {
525 print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
526 }
527
528 print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
529
530 // Validate
531 if ($object->status == $object::STATUS_DRAFT) {
532 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
533 print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
534 } else {
535 $langs->load("errors");
536 print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
537 }
538 }
539
540 // Clone
541 print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : '').'&action=clone&token='.newToken(), '', $permissiontoadd);
542
543 /*
544 if ($permissiontoadd) {
545 if ($object->status == $object::STATUS_ENABLED) {
546 print dolGetButtonAction($langs->trans('Disable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
547 } else {
548 print dolGetButtonAction($langs->trans('Enable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
549 }
550 }
551 if ($permissiontoadd) {
552 if ($object->status == $object::STATUS_VALIDATED) {
553 print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
554 } else {
555 print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
556 }
557 }
558 */
559
560 // Delete (need delete permission, or if draft, just need create/modify permission)
561 print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
562 }
563 print '</div>'."\n";
564 }
565
566
567 // Select mail models is same action as presend
568 if (GETPOST('modelselected')) {
569 $action = 'presend';
570 }
571
572 if ($action != 'presend') {
573 print '<div class="fichecenter"><div class="fichehalfleft">';
574 print '<a name="builddoc"></a>'; // ancre
575
576 $includedocgeneration = 0;
577
578 // Documents
579 if ($includedocgeneration) {
580 $objref = dol_sanitizeFileName($object->ref);
581 $relativepath = $objref.'/'.$objref.'.pdf';
582 $filedir = $conf->bookcal->dir_output.'/'.$object->element.'/'.$objref;
583 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
584 $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content
585 $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card
586 print $formfile->showdocuments('bookcal:Availabilities', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
587 }
588
589 // Show links to link elements
590 $linktoelem = $form->showLinkToObjectBlock($object, null, array('availabilities'));
591 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
592
593
594 print '</div><div class="fichehalfright">';
595
596 $MAXEVENT = 10;
597
598 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/bookcal/availabilities_agenda.php', 1).'?id='.$object->id);
599
600 // List of actions on element
601 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
602 $formactions = new FormActions($db);
603 $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
604
605 print '</div></div>';
606 }
607
608 //Select mail models is same action as presend
609 if (GETPOST('modelselected')) {
610 $action = 'presend';
611 }
612
613 // Presend form
614 $modelmail = 'availabilities';
615 $defaulttopic = 'InformationMessage';
616 $diroutput = $conf->bookcal->dir_output;
617 $trackid = 'availabilities'.$object->id;
618
619 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
620}
621
622// End of page
623llxFooter();
624$db->close();
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
availabilitiesPrepareHead($object)
Prepare array of tabs for Availabilities.
Class for Availabilities.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
llxFooter()
Footer empty.
Definition document.php:107
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.