dolibarr 21.0.0-alpha
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 *
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
32{
33 global $db, $langs, $conf;
34
35 $langs->load("agenda");
36
37 $showtabofpagecontact = 0;
38 $showtabofpagenote = 1;
39 $showtabofpagedocument = 0;
40 $showtabofpageagenda = 1;
41
42 $h = 0;
43 $head = array();
44
45 $head[$h][0] = DOL_URL_ROOT . '/bookcal/calendar_card.php?id=' . $object->id;
46 $head[$h][1] = $langs->trans("Calendar");
47 $head[$h][2] = 'card';
48 $h++;
49
50 if ($object->status == Calendar::STATUS_VALIDATED) {
51 $head[$h][0] = DOL_URL_ROOT . '/bookcal/booking_list.php?id=' . $object->id;
52 $head[$h][1] = $langs->trans("Bookings");
53 $head[$h][2] = 'booking';
54 $h++;
55 }
56
57
58 if ($showtabofpagecontact) {
59 $head[$h][0] = DOL_URL_ROOT . '/bookcal/calendar_contact.php?id=' . $object->id;
60 $head[$h][1] = $langs->trans("Contacts");
61 $head[$h][2] = 'contact';
62 $h++;
63 }
64
65 if ($showtabofpagenote) {
66 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
67 $nbNote = 0;
68 if (!empty($object->note_private)) {
69 $nbNote++;
70 }
71 if (!empty($object->note_public)) {
72 $nbNote++;
73 }
74 $head[$h][0] = DOL_URL_ROOT . '/bookcal/calendar_note.php?id=' . $object->id;
75 $head[$h][1] = $langs->trans('Notes');
76 if ($nbNote > 0) {
77 $head[$h][1] .= (!getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">' . $nbNote . '</span>' : '');
78 }
79 $head[$h][2] = 'note';
80 $h++;
81 }
82 }
83
84 if ($showtabofpagedocument) {
85 require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
86 require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
87 $upload_dir = $conf->bookcal->dir_output . "/calendar/" . dol_sanitizeFileName($object->ref);
88 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
89 $nbLinks = Link::count($db, $object->element, $object->id);
90 $head[$h][0] = DOL_URL_ROOT . '/bookcal/calendar_document.php?id=' . $object->id;
91 $head[$h][1] = $langs->trans('Documents');
92 if (($nbFiles + $nbLinks) > 0) {
93 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>';
94 }
95 $head[$h][2] = 'document';
96 $h++;
97 }
98
99 if ($showtabofpageagenda) {
100 $head[$h][0] = DOL_URL_ROOT . '/bookcal/calendar_agenda.php?id=' . $object->id;
101 $head[$h][1] = $langs->trans("Events");
102 $head[$h][2] = 'agenda';
103 $h++;
104 }
105
106 // Show more tabs from modules
107 // Entries must be declared in modules descriptor with line
108 //$this->tabs = array(
109 // 'entity:+tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__'
110 //); // to add new tab
111 //$this->tabs = array(
112 // 'entity:-tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__'
113 //); // to remove a tab
114 complete_head_from_modules($conf, $langs, $object, $head, $h, 'calendar@bookcal');
115
116 complete_head_from_modules($conf, $langs, $object, $head, $h, 'calendar@bookcal', 'remove');
117
118 return $head;
119}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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).