dolibarr  19.0.0-dev
calendar_card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2023 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 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
26 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
27 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
28 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
29 //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
30 //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
31 //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
32 //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
33 //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
34 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
35 //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
36 //if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
37 //if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
38 //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
39 //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
40 //if (! defined("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies
41 //if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
42 //if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
43 //if (! defined('NOSESSION')) define('NOSESSION', '1'); // Disable session
44 
45 // Load Dolibarr environment
46 $res = 0;
47 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
48 if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
49  $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
50 }
51 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
52 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
53 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
54  $i--; $j--;
55 }
56 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
57  $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
58 }
59 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
60  $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
61 }
62 // Try main.inc.php using relative path
63 if (!$res && file_exists("../main.inc.php")) {
64  $res = @include "../main.inc.php";
65 }
66 if (!$res && file_exists("../../main.inc.php")) {
67  $res = @include "../../main.inc.php";
68 }
69 if (!$res && file_exists("../../../main.inc.php")) {
70  $res = @include "../../../main.inc.php";
71 }
72 if (!$res) {
73  die("Include of main fails");
74 }
75 
76 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
77 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
78 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
79 dol_include_once('/bookcal/class/calendar.class.php');
80 dol_include_once('/bookcal/lib/bookcal_calendar.lib.php');
81 
82 // Load translation files required by the page
83 $langs->loadLangs(array("bookcal@bookcal", "other"));
84 
85 // Get parameters
86 $id = GETPOST('id', 'int');
87 $ref = GETPOST('ref', 'alpha');
88 $lineid = GETPOST('lineid', 'int');
89 
90 $action = GETPOST('action', 'aZ09');
91 $confirm = GETPOST('confirm', 'alpha');
92 $cancel = GETPOST('cancel', 'aZ09');
93 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
94 $backtopage = GETPOST('backtopage', 'alpha'); // if not set, a default page will be used
95 $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // if not set, $backtopage will be used
96 $backtopagejsfields = GETPOST('backtopagejsfields', 'alpha');
97 $dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
98 
99 if (!empty($backtopagejsfields)) {
100  $tmpbacktopagejsfields = explode(':', $backtopagejsfields);
101  $dol_openinpopup = $tmpbacktopagejsfields[0];
102 }
103 
104 // Initialize technical objects
105 $object = new Calendar($db);
106 $extrafields = new ExtraFields($db);
107 $diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
108 $hookmanager->initHooks(array('calendarcard', 'globalcard')); // Note that conf->hooks_modules contains array
109 
110 // Fetch optionals attributes and labels
111 $extrafields->fetch_name_optionals_label($object->table_element);
112 
113 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
114 
115 // Initialize array of search criterias
116 $search_all = GETPOST("search_all", 'alpha');
117 $search = array();
118 foreach ($object->fields as $key => $val) {
119  if (GETPOST('search_'.$key, 'alpha')) {
120  $search[$key] = GETPOST('search_'.$key, 'alpha');
121  }
122 }
123 
124 if (empty($action) && empty($id) && empty($ref)) {
125  $action = 'view';
126 }
127 
128 // Load object
129 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
130 
131 // There is several ways to check permission.
132 // Set $enablepermissioncheck to 1 to enable a minimum low level of checks
133 $enablepermissioncheck = 0;
134 if ($enablepermissioncheck) {
135  $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read');
136  $permissiontoadd = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
137  $permissiontodelete = $user->hasRight('bookcal', 'calendar', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
138  $permissionnote = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_setnotes.inc.php
139  $permissiondellink = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_dellink.inc.php
140 } else {
141  $permissiontoread = 1;
142  $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
143  $permissiontodelete = 1;
144  $permissionnote = 1;
145  $permissiondellink = 1;
146 }
147 
148 $upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->entity : 1].'/calendar';
149 
150 // Security check (enable the most restrictive one)
151 //if ($user->socid > 0) accessforbidden();
152 //if ($user->socid > 0) $socid = $user->socid;
153 //$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
154 //restrictedArea($user, $object->module, $object, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
155 if (!isModEnabled("bookcal")) {
156  accessforbidden();
157 }
158 if (!$permissiontoread) {
159  accessforbidden();
160 }
161 
162 
163 /*
164  * Actions
165  */
166 
167 $parameters = array();
168 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
169 if ($reshook < 0) {
170  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
171 }
172 
173 if (empty($reshook)) {
174  $error = 0;
175 
176  $backurlforlist = dol_buildpath('/bookcal/calendar_list.php', 1);
177 
178  if (empty($backtopage) || ($cancel && empty($id))) {
179  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
180  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
181  $backtopage = $backurlforlist;
182  } else {
183  $backtopage = dol_buildpath('/bookcal/calendar_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
184  }
185  }
186  }
187 
188  $triggermodname = 'BOOKCAL_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record
189 
190  // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
191  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
192 
193  // Actions when linking object each other
194  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
195 
196  // Actions when printing a doc from card
197  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
198 
199  // Action to move up and down lines of object
200  //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
201 
202  // Action to build doc
203  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
204 
205  if ($action == 'set_thirdparty' && $permissiontoadd) {
206  $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
207  }
208  if ($action == 'classin' && $permissiontoadd) {
209  $object->setProject(GETPOST('projectid', 'int'));
210  }
211 
212  // Actions to send emails
213  $triggersendname = 'BOOKCAL_MYOBJECT_SENTBYMAIL';
214  $autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
215  $trackid = 'calendar'.$object->id;
216  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
217 }
218 
219 
220 
221 
222 /*
223  * View
224  */
225 
226 $form = new Form($db);
227 $formfile = new FormFile($db);
228 $formproject = new FormProjets($db);
229 
230 $title = $langs->trans("Calendar");
231 $help_url = '';
232 llxHeader('', $title, $help_url);
233 
234 // Example : Adding jquery code
235 // print '<script type="text/javascript">
236 // jQuery(document).ready(function() {
237 // function init_myfunc()
238 // {
239 // jQuery("#myid").removeAttr(\'disabled\');
240 // jQuery("#myid").attr(\'disabled\',\'disabled\');
241 // }
242 // init_myfunc();
243 // jQuery("#mybutton").click(function() {
244 // init_myfunc();
245 // });
246 // });
247 // </script>';
248 
249 
250 // Part to create
251 if ($action == 'create') {
252  if (empty($permissiontoadd)) {
253  accessforbidden('NotEnoughPermissions', 0, 1);
254  }
255 
256  print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Calendar")), '', 'object_'.$object->picto);
257 
258  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
259  print '<input type="hidden" name="token" value="'.newToken().'">';
260  print '<input type="hidden" name="action" value="add">';
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  if ($backtopagejsfields) {
268  print '<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.'">';
269  }
270  if ($dol_openinpopup) {
271  print '<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.'">';
272  }
273 
274  print dol_get_fiche_head(array(), '');
275 
276  // Set some default values
277  //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
278 
279  print '<table class="border centpercent tableforfieldcreate">'."\n";
280 
281  // Common attributes
282  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
283 
284  // Other attributes
285  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
286 
287  print '</table>'."\n";
288 
289  print dol_get_fiche_end();
290 
291  print $form->buttonsSaveCancel("Create");
292 
293  print '</form>';
294 
295  //dol_set_focus('input[name="ref"]');
296 }
297 
298 // Part to edit record
299 if (($id || $ref) && $action == 'edit') {
300  print load_fiche_titre($langs->trans("Calendar"), '', 'object_'.$object->picto);
301 
302  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
303  print '<input type="hidden" name="token" value="'.newToken().'">';
304  print '<input type="hidden" name="action" value="update">';
305  print '<input type="hidden" name="id" value="'.$object->id.'">';
306  if ($backtopage) {
307  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
308  }
309  if ($backtopageforcancel) {
310  print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
311  }
312 
313  print dol_get_fiche_head();
314 
315  print '<table class="border centpercent tableforfieldedit">'."\n";
316 
317  // Common attributes
318  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
319 
320  // Other attributes
321  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
322 
323  print '</table>';
324 
325  print dol_get_fiche_end();
326 
327  print $form->buttonsSaveCancel();
328 
329  print '</form>';
330 }
331 
332 // Part to show record
333 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
334  $head = calendarPrepareHead($object);
335 
336  print dol_get_fiche_head($head, 'card', $langs->trans("Calendar"), -1, $object->picto, 0, '', '', 0, '', 1);
337 
338  $formconfirm = '';
339 
340  // Confirmation to delete
341  if ($action == 'delete') {
342  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteCalendar'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
343  }
344  // Confirmation to delete line
345  if ($action == 'deleteline') {
346  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
347  }
348 
349  // Clone confirmation
350  if ($action == 'clone') {
351  // Create an array for form
352  $formquestion = array();
353  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
354  }
355 
356  // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
357  if ($action == 'xxx') {
358  $text = $langs->trans('ConfirmActionCalendar', $object->ref);
359  /*if (isModEnabled('notification'))
360  {
361  require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
362  $notify = new Notify($db);
363  $text .= '<br>';
364  $text .= $notify->confirmMessage('MYOBJECT_CLOSE', $object->socid, $object);
365  }*/
366 
367  $formquestion = array();
368 
369  /*
370  $forcecombo=0;
371  if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
372  $formquestion = array(
373  // 'text' => $langs->trans("ConfirmClone"),
374  // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
375  // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
376  // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
377  );
378  */
379  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
380  }
381 
382  // Call Hook formConfirm
383  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
384  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
385  if (empty($reshook)) {
386  $formconfirm .= $hookmanager->resPrint;
387  } elseif ($reshook > 0) {
388  $formconfirm = $hookmanager->resPrint;
389  }
390 
391  // Print form confirm
392  print $formconfirm;
393 
394 
395  // Object card
396  // ------------------------------------------------------------
397  $linkback = '<a href="'.dol_buildpath('/bookcal/calendar_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
398 
399  $morehtmlref = '<div class="refidno">';
400  /*
401  // Ref customer
402  $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
403  $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1);
404  // Thirdparty
405  $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
406  if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
407  $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
408  }
409  // Project
410  if (isModEnabled('project')) {
411  $langs->load("projects");
412  $morehtmlref .= '<br>';
413  if ($permissiontoadd) {
414  $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
415  if ($action != 'classify') {
416  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
417  }
418  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
419  } else {
420  if (!empty($object->fk_project)) {
421  $proj = new Project($db);
422  $proj->fetch($object->fk_project);
423  $morehtmlref .= $proj->getNomUrl(1);
424  if ($proj->title) {
425  $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
426  }
427  }
428  }
429  }
430  */
431  $morehtmlref .= '</div>';
432 
433 
434  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
435 
436 
437  print '<div class="fichecenter">';
438  print '<div class="fichehalfleft">';
439  print '<div class="underbanner clearboth"></div>';
440  print '<table class="border centpercent tableforfield">'."\n";
441 
442  // Common attributes
443  //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
444  //unset($object->fields['fk_project']); // Hide field already shown in banner
445  //unset($object->fields['fk_soc']); // Hide field already shown in banner
446  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
447 
448  // Other attributes. Fields from hook formObjectOptions and Extrafields.
449  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
450 
451  print '</table>';
452  print '</div>';
453  print '</div>';
454 
455  print '<div class="clearboth"></div>';
456 
457  print dol_get_fiche_end();
458 
459 
460  /*
461  * Lines
462  */
463 
464  if (!empty($object->table_element_line)) {
465  // Show object lines
466  $result = $object->getLinesArray();
467 
468  print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
469  <input type="hidden" name="token" value="' . newToken().'">
470  <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
471  <input type="hidden" name="mode" value="">
472  <input type="hidden" name="page_y" value="">
473  <input type="hidden" name="id" value="' . $object->id.'">
474  ';
475 
476  if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
477  include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
478  }
479 
480  print '<div class="div-table-responsive-no-min">';
481  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
482  print '<table id="tablelines" class="noborder noshadow" width="100%">';
483  }
484 
485  if (!empty($object->lines)) {
486  $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
487  }
488 
489  // Form to add new line
490  if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
491  if ($action != 'editline') {
492  // Add products/services form
493 
494  $parameters = array();
495  $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
496  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
497  if (empty($reshook))
498  $object->formAddObjectLine(1, $mysoc, $soc);
499  }
500  }
501 
502  if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
503  print '</table>';
504  }
505  print '</div>';
506 
507  print "</form>\n";
508  }
509 
510 
511  // Buttons for actions
512 
513  if ($action != 'presend' && $action != 'editline') {
514  print '<div class="tabsAction">'."\n";
515  $parameters = array();
516  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
517  if ($reshook < 0) {
518  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
519  }
520 
521  if (empty($reshook)) {
522  // Send
523  if (empty($user->socid)) {
524  print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle');
525  }
526 
527  // Back to draft
528  if ($object->status == $object::STATUS_VALIDATED) {
529  print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
530  }
531 
532  print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
533 
534  // Validate
535  if ($object->status == $object::STATUS_DRAFT) {
536  if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
537  print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
538  } else {
539  $langs->load("errors");
540  print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
541  }
542  }
543 
544  // Clone
545  if ($permissiontoadd) {
546  print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd);
547  }
548 
549  /*
550  if ($permissiontoadd) {
551  if ($object->status == $object::STATUS_ENABLED) {
552  print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
553  } else {
554  print dolGetButtonAction('', $langs->trans('Enable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
555  }
556  }
557  if ($permissiontoadd) {
558  if ($object->status == $object::STATUS_VALIDATED) {
559  print dolGetButtonAction('', $langs->trans('Cancel'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
560  } else {
561  print dolGetButtonAction('', $langs->trans('Re-Open'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
562  }
563  }
564  */
565 
566  // Delete
567  $params = array();
568  print dolGetButtonAction('', $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete, $params);
569  }
570  print '</div>'."\n";
571  }
572 
573 
574  // Select mail models is same action as presend
575  if (GETPOST('modelselected')) {
576  $action = 'presend';
577  }
578 
579  if ($action != 'presend') {
580  print '<div class="fichecenter"><div class="fichehalfleft">';
581  print '<a name="builddoc"></a>'; // ancre
582 
583  $includedocgeneration = 0;
584 
585  // Documents
586  if ($includedocgeneration) {
587  $objref = dol_sanitizeFileName($object->ref);
588  $relativepath = $objref.'/'.$objref.'.pdf';
589  $filedir = $conf->bookcal->dir_output.'/'.$object->element.'/'.$objref;
590  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
591  $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content
592  $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card
593  print $formfile->showdocuments('bookcal:Calendar', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
594  }
595 
596  // Show links to link elements
597  $linktoelem = $form->showLinkToObjectBlock($object, null, array('calendar'));
598  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
599 
600 
601  print '</div><div class="fichehalfright">';
602 
603  $MAXEVENT = 10;
604 
605  $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/bookcal/calendar_agenda.php', 1).'?id='.$object->id);
606 
607  // List of actions on element
608  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
609  $formactions = new FormActions($db);
610  $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
611 
612  print '</div></div>';
613  }
614 
615  //Select mail models is same action as presend
616  if (GETPOST('modelselected')) {
617  $action = 'presend';
618  }
619 
620  // Presend form
621  $modelmail = 'calendar';
622  $defaulttopic = 'InformationMessage';
623  $diroutput = $conf->bookcal->dir_output;
624  $trackid = 'calendar'.$object->id;
625 
626  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
627 }
628 
629 // End of page
630 llxFooter();
631 $db->close();
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1323
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5477
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:609
FormActions
Class to manage building of HTML components.
Definition: html.formactions.class.php:30
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1129
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1158
Calendar
Class for Calendar.
Definition: calendar.class.php:34
FormProjets
Class to manage building of HTML components.
Definition: html.formprojet.class.php:30
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_banner_tab
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.
Definition: functions.lib.php:2205
$help_url
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
llxHeader
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
$formactions
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.
Definition: agenda_other.php:182
$formconfirm
$formconfirm
if ($action == 'delbookkeepingyear') {
Definition: listbyaccount.php:634
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
dolGetButtonTitle
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.
Definition: functions.lib.php:11263
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11654
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2177
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
dol_get_fiche_head
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.
Definition: functions.lib.php:1979
dolGetButtonAction
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
Definition: functions.lib.php:11080
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
calendarPrepareHead
calendarPrepareHead($object)
Prepare array of tabs for Calendar.
Definition: bookcal_calendar.lib.php:30
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1169