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