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