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