dolibarr 19.0.3
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)
48if (!$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;
53while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
54 $i--;
55 $j--;
56}
57if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
58 $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
59}
60if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
61 $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
62}
63// Try main.inc.php using relative path
64if (!$res && file_exists("../main.inc.php")) {
65 $res = @include "../main.inc.php";
66}
67if (!$res && file_exists("../../main.inc.php")) {
68 $res = @include "../../main.inc.php";
69}
70if (!$res && file_exists("../../../main.inc.php")) {
71 $res = @include "../../../main.inc.php";
72}
73if (!$res) {
74 die("Include of main fails");
75}
76
77require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
78require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
79require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
80dol_include_once('/bookcal/class/calendar.class.php');
81dol_include_once('/bookcal/lib/bookcal_calendar.lib.php');
82
83// Load translation files required by the page
84$langs->loadLangs(array("bookcal@bookcal", "other"));
85
86// Get parameters
87$id = GETPOST('id', 'int');
88$ref = GETPOST('ref', 'alpha');
89$lineid = GETPOST('lineid', 'int');
90
91$action = GETPOST('action', 'aZ09');
92$confirm = GETPOST('confirm', 'alpha');
93$cancel = GETPOST('cancel', 'aZ09');
94$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
95$backtopage = GETPOST('backtopage', 'alpha'); // if not set, a default page will be used
96$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // if not set, $backtopage will be used
97$backtopagejsfields = GETPOST('backtopagejsfields', 'alpha');
98$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
99
100if (!empty($backtopagejsfields)) {
101 $tmpbacktopagejsfields = explode(':', $backtopagejsfields);
102 $dol_openinpopup = $tmpbacktopagejsfields[0];
103}
104
105// Initialize technical objects
106$object = new Calendar($db);
107$extrafields = new ExtraFields($db);
108$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
109$hookmanager->initHooks(array('calendarcard', 'globalcard')); // Note that conf->hooks_modules contains array
110
111// Fetch optionals attributes and labels
112$extrafields->fetch_name_optionals_label($object->table_element);
113
114$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
115
116// Initialize array of search criterias
117$search_all = GETPOST("search_all", 'alpha');
118$search = array();
119foreach ($object->fields as $key => $val) {
120 if (GETPOST('search_'.$key, 'alpha')) {
121 $search[$key] = GETPOST('search_'.$key, 'alpha');
122 }
123}
124
125if (empty($action) && empty($id) && empty($ref)) {
126 $action = 'view';
127}
128
129// Load object
130include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
131
132// There is several ways to check permission.
133// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
134$enablepermissioncheck = 0;
135if ($enablepermissioncheck) {
136 $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read');
137 $permissiontoadd = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
138 $permissiontodelete = $user->hasRight('bookcal', 'calendar', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
139 $permissionnote = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_setnotes.inc.php
140 $permissiondellink = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_dellink.inc.php
141} else {
142 $permissiontoread = 1;
143 $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
144 $permissiontodelete = 1;
145 $permissionnote = 1;
146 $permissiondellink = 1;
147}
148
149$upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->entity : 1].'/calendar';
150
151// Security check (enable the most restrictive one)
152//if ($user->socid > 0) accessforbidden();
153//if ($user->socid > 0) $socid = $user->socid;
154//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
155//restrictedArea($user, $object->module, $object, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
156if (!isModEnabled("bookcal")) {
158}
159if (!$permissiontoread) {
161}
162
163
164/*
165 * Actions
166 */
167
168$parameters = array();
169$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
170if ($reshook < 0) {
171 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
172}
173
174if (empty($reshook)) {
175 $error = 0;
176
177 $backurlforlist = dol_buildpath('/bookcal/calendar_list.php', 1);
178
179 if (empty($backtopage) || ($cancel && empty($id))) {
180 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
181 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
182 $backtopage = $backurlforlist;
183 } else {
184 $backtopage = dol_buildpath('/bookcal/calendar_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
185 }
186 }
187 }
188
189 $triggermodname = 'BOOKCAL_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record
190
191 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
192 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
193
194 // Actions when linking object each other
195 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
196
197 // Actions when printing a doc from card
198 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
199
200 // Action to move up and down lines of object
201 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
202
203 // Action to build doc
204 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
205
206 if ($action == 'set_thirdparty' && $permissiontoadd) {
207 $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
208 }
209 if ($action == 'classin' && $permissiontoadd) {
210 $object->setProject(GETPOST('projectid', 'int'));
211 }
212
213 // Actions to send emails
214 $triggersendname = 'BOOKCAL_MYOBJECT_SENTBYMAIL';
215 $autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
216 $trackid = 'calendar'.$object->id;
217 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
218}
219
220
221
222
223/*
224 * View
225 */
226
227$form = new Form($db);
228$formfile = new FormFile($db);
229$formproject = new FormProjets($db);
230
231$title = $langs->trans("Calendar");
232$help_url = '';
233llxHeader('', $title, $help_url);
234
235// Example : Adding jquery code
236// print '<script type="text/javascript">
237// jQuery(document).ready(function() {
238// function init_myfunc()
239// {
240// jQuery("#myid").removeAttr(\'disabled\');
241// jQuery("#myid").attr(\'disabled\',\'disabled\');
242// }
243// init_myfunc();
244// jQuery("#mybutton").click(function() {
245// init_myfunc();
246// });
247// });
248// </script>';
249
250
251// Part to create
252if ($action == 'create') {
253 if (empty($permissiontoadd)) {
254 accessforbidden('NotEnoughPermissions', 0, 1);
255 }
256
257 print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Calendar")), '', 'object_'.$object->picto);
258
259 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
260 print '<input type="hidden" name="token" value="'.newToken().'">';
261 print '<input type="hidden" name="action" value="add">';
262 if ($backtopage) {
263 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
264 }
265 if ($backtopageforcancel) {
266 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
267 }
268 if ($backtopagejsfields) {
269 print '<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.'">';
270 }
271 if ($dol_openinpopup) {
272 print '<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.'">';
273 }
274
275 print dol_get_fiche_head(array(), '');
276
277 // Set some default values
278 //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
279
280 print '<table class="border centpercent tableforfieldcreate">'."\n";
281
282 // Common attributes
283 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
284
285 // Other attributes
286 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
287
288 print '</table>'."\n";
289
290 print dol_get_fiche_end();
291
292 print $form->buttonsSaveCancel("Create");
293
294 print '</form>';
295
296 //dol_set_focus('input[name="ref"]');
297}
298
299// Part to edit record
300if (($id || $ref) && $action == 'edit') {
301 print load_fiche_titre($langs->trans("Calendar"), '', 'object_'.$object->picto);
302
303 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
304 print '<input type="hidden" name="token" value="'.newToken().'">';
305 print '<input type="hidden" name="action" value="update">';
306 print '<input type="hidden" name="id" value="'.$object->id.'">';
307 if ($backtopage) {
308 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
309 }
310 if ($backtopageforcancel) {
311 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
312 }
313
314 print dol_get_fiche_head();
315
316 print '<table class="border centpercent tableforfieldedit">'."\n";
317
318 // Common attributes
319 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
320
321 // Other attributes
322 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
323
324 print '</table>';
325
326 print dol_get_fiche_end();
327
328 print $form->buttonsSaveCancel();
329
330 print '</form>';
331}
332
333// Part to show record
334if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
335 $head = calendarPrepareHead($object);
336
337 print dol_get_fiche_head($head, 'card', $langs->trans("Calendar"), -1, $object->picto, 0, '', '', 0, '', 1);
338
339 $formconfirm = '';
340
341 // Confirmation to delete
342 if ($action == 'delete') {
343 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteCalendar'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
344 }
345 // Confirmation to delete line
346 if ($action == 'deleteline') {
347 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
348 }
349
350 // Clone confirmation
351 if ($action == 'clone') {
352 // Create an array for form
353 $formquestion = array();
354 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
355 }
356
357 // Call Hook formConfirm
358 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
359 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
360 if (empty($reshook)) {
361 $formconfirm .= $hookmanager->resPrint;
362 } elseif ($reshook > 0) {
363 $formconfirm = $hookmanager->resPrint;
364 }
365
366 // Print form confirm
367 print $formconfirm;
368
369
370 // Object card
371 // ------------------------------------------------------------
372 $linkback = '<a href="'.dol_buildpath('/bookcal/calendar_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
373
374 $morehtmlref = '<div class="refidno">';
375 /*
376 // Ref customer
377 $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
378 $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);
379 // Thirdparty
380 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
381 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
382 $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
383 }
384 // Project
385 if (isModEnabled('project')) {
386 $langs->load("projects");
387 $morehtmlref .= '<br>';
388 if ($permissiontoadd) {
389 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
390 if ($action != 'classify') {
391 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
392 }
393 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
394 } else {
395 if (!empty($object->fk_project)) {
396 $proj = new Project($db);
397 $proj->fetch($object->fk_project);
398 $morehtmlref .= $proj->getNomUrl(1);
399 if ($proj->title) {
400 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
401 }
402 }
403 }
404 }
405 */
406 $morehtmlref .= '</div>';
407
408
409 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
410
411
412 print '<div class="fichecenter">';
413 print '<div class="fichehalfleft">';
414 print '<div class="underbanner clearboth"></div>';
415 print '<table class="border centpercent tableforfield">'."\n";
416
417 // Common attributes
418 //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
419 //unset($object->fields['fk_project']); // Hide field already shown in banner
420 //unset($object->fields['fk_soc']); // Hide field already shown in banner
421 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
422
423 // Other attributes. Fields from hook formObjectOptions and Extrafields.
424 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
425
426 // Link to public page
427 print '<tr><td>Link</td>';
428 print '<td><a href="'. DOL_URL_ROOT.'/public/bookcal/index.php?id='.$object->id.'" target="_blank">Public page</a>';
429 print '</td></tr>';
430
431 print '</table>';
432 print '</div>';
433 print '</div>';
434
435 print '<div class="clearboth"></div>';
436
437 print dol_get_fiche_end();
438
439
440 /*
441 * Lines
442 */
443
444 if (!empty($object->table_element_line)) {
445 // Show object lines
446 $result = $object->getLinesArray();
447
448 print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
449 <input type="hidden" name="token" value="' . newToken().'">
450 <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
451 <input type="hidden" name="mode" value="">
452 <input type="hidden" name="page_y" value="">
453 <input type="hidden" name="id" value="' . $object->id.'">
454 ';
455
456 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
457 include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
458 }
459
460 print '<div class="div-table-responsive-no-min">';
461 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
462 print '<table id="tablelines" class="noborder noshadow" width="100%">';
463 }
464
465 if (!empty($object->lines)) {
466 $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
467 }
468
469 // Form to add new line
470 if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
471 if ($action != 'editline') {
472 // Add products/services form
473
474 $parameters = array();
475 $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
476 if ($reshook < 0) {
477 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
478 }
479 if (empty($reshook)) {
480 $object->formAddObjectLine(1, $mysoc, $soc);
481 }
482 }
483 }
484
485 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
486 print '</table>';
487 }
488 print '</div>';
489
490 print "</form>\n";
491 }
492
493
494 // Buttons for actions
495
496 if ($action != 'presend' && $action != 'editline') {
497 print '<div class="tabsAction">'."\n";
498 $parameters = array();
499 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
500 if ($reshook < 0) {
501 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
502 }
503
504 if (empty($reshook)) {
505 // Send
506 /*if (empty($user->socid)) {
507 print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle');
508 }*/
509
510 // Back to draft
511 if ($object->status == $object::STATUS_VALIDATED) {
512 print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
513 }
514
515 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
516
517 // Validate
518 if ($object->status == $object::STATUS_DRAFT) {
519 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
520 print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
521 } else {
522 $langs->load("errors");
523 print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
524 }
525 }
526
527 // Clone
528 if ($permissiontoadd) {
529 print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : '').'&action=clone&token='.newToken(), '', $permissiontoadd);
530 }
531
532 /*
533 if ($permissiontoadd) {
534 if ($object->status == $object::STATUS_ENABLED) {
535 print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
536 } else {
537 print dolGetButtonAction('', $langs->trans('Enable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
538 }
539 }
540 if ($permissiontoadd) {
541 if ($object->status == $object::STATUS_VALIDATED) {
542 print dolGetButtonAction('', $langs->trans('Cancel'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
543 } else {
544 print dolGetButtonAction('', $langs->trans('Re-Open'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
545 }
546 }
547 */
548
549 // Delete
550 $params = array();
551 print dolGetButtonAction('', $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete, $params);
552 }
553 print '</div>'."\n";
554 }
555
556
557 // Select mail models is same action as presend
558 if (GETPOST('modelselected')) {
559 $action = 'presend';
560 }
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:Calendar', $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('calendar'));
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/calendar_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 = 'calendar';
606 $defaulttopic = 'InformationMessage';
607 $diroutput = $conf->bookcal->dir_output;
608 $trackid = 'calendar'.$object->id;
609
610 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
611 */
612}
613
614// End of page
615llxFooter();
616$db->close();
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
calendarPrepareHead($object)
Prepare array of tabs for Calendar.
Class for Calendar.
Class to manage standard extra fields.
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_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='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.