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