dolibarr 21.0.0-beta
bookcal_calendar.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023 Alice Adminson <aadminson@example.com>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
33{
34 global $db, $langs, $conf;
35
36 $langs->load("agenda");
37
38 $showtabofpagecontact = 0;
39 $showtabofpagenote = 1;
40 $showtabofpagedocument = 0;
41 $showtabofpageagenda = 1;
42
43 $h = 0;
44 $head = array();
45
46 $head[$h][0] = DOL_URL_ROOT . '/bookcal/calendar_card.php?id=' . $object->id;
47 $head[$h][1] = $langs->trans("Calendar");
48 $head[$h][2] = 'card';
49 $h++;
50
51 if ($object->status == Calendar::STATUS_VALIDATED) {
52 $head[$h][0] = DOL_URL_ROOT . '/bookcal/booking_list.php?id=' . $object->id;
53 $head[$h][1] = $langs->trans("Bookings");
54 $head[$h][2] = 'booking';
55 $h++;
56 }
57
58
59 if ($showtabofpagecontact) {
60 $head[$h][0] = DOL_URL_ROOT . '/bookcal/calendar_contact.php?id=' . $object->id;
61 $head[$h][1] = $langs->trans("Contacts");
62 $head[$h][2] = 'contact';
63 $h++;
64 }
65
66 if ($showtabofpagenote) {
67 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
68 $nbNote = 0;
69 if (!empty($object->note_private)) {
70 $nbNote++;
71 }
72 if (!empty($object->note_public)) {
73 $nbNote++;
74 }
75 $head[$h][0] = DOL_URL_ROOT . '/bookcal/calendar_note.php?id=' . $object->id;
76 $head[$h][1] = $langs->trans('Notes');
77 if ($nbNote > 0) {
78 $head[$h][1] .= (!getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">' . $nbNote . '</span>' : '');
79 }
80 $head[$h][2] = 'note';
81 $h++;
82 }
83 }
84
85 if ($showtabofpagedocument) {
86 require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
87 require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
88 $upload_dir = $conf->bookcal->dir_output . "/calendar/" . dol_sanitizeFileName($object->ref);
89 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
90 $nbLinks = Link::count($db, $object->element, $object->id);
91 $head[$h][0] = DOL_URL_ROOT . '/bookcal/calendar_document.php?id=' . $object->id;
92 $head[$h][1] = $langs->trans('Documents');
93 if (($nbFiles + $nbLinks) > 0) {
94 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>';
95 }
96 $head[$h][2] = 'document';
97 $h++;
98 }
99
100 if ($showtabofpageagenda) {
101 $head[$h][0] = DOL_URL_ROOT . '/bookcal/calendar_agenda.php?id=' . $object->id;
102 $head[$h][1] = $langs->trans("Events");
103 $head[$h][2] = 'agenda';
104 $h++;
105 }
106
107 // Show more tabs from modules
108 // Entries must be declared in modules descriptor with line
109 //$this->tabs = array(
110 // 'entity:+tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__'
111 //); // to add new tab
112 //$this->tabs = array(
113 // 'entity:-tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__'
114 //); // to remove a tab
115 complete_head_from_modules($conf, $langs, $object, $head, $h, 'calendar@bookcal');
116
117 complete_head_from_modules($conf, $langs, $object, $head, $h, 'calendar@bookcal', 'remove');
118
119 return $head;
120}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
calendarPrepareHead($object)
Prepare array of tabs for Calendar.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79