dolibarr 19.0.4
bookcal_calendar.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023 Alice Adminson <aadminson@example.com>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
30function calendarPrepareHead($object)
31{
32 global $db, $langs, $conf;
33
34 $langs->load("agenda");
35
36 $showtabofpagecontact = 0;
37 $showtabofpagenote = 1;
38 $showtabofpagedocument = 0;
39 $showtabofpageagenda = 1;
40
41 $h = 0;
42 $head = array();
43
44 $head[$h][0] = dol_buildpath("/bookcal/calendar_card.php", 1).'?id='.$object->id;
45 $head[$h][1] = $langs->trans("Calendar");
46 $head[$h][2] = 'card';
47 $h++;
48
49 if ($object->status == Calendar::STATUS_VALIDATED) {
50 $head[$h][0] = dol_buildpath("/bookcal/booking_list.php", 1).'?id='.$object->id;
51 $head[$h][1] = $langs->trans("Bookings");
52 $head[$h][2] = 'booking';
53 $h++;
54 }
55
56
57 if ($showtabofpagecontact) {
58 $head[$h][0] = dol_buildpath("/bookcal/calendar_contact.php", 1).'?id='.$object->id;
59 $head[$h][1] = $langs->trans("Contacts");
60 $head[$h][2] = 'contact';
61 $h++;
62 }
63
64 if ($showtabofpagenote) {
65 if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
66 $nbNote = 0;
67 if (!empty($object->note_private)) {
68 $nbNote++;
69 }
70 if (!empty($object->note_public)) {
71 $nbNote++;
72 }
73 $head[$h][0] = dol_buildpath('/bookcal/calendar_note.php', 1).'?id='.$object->id;
74 $head[$h][1] = $langs->trans('Notes');
75 if ($nbNote > 0) {
76 $head[$h][1] .= (!getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
77 }
78 $head[$h][2] = 'note';
79 $h++;
80 }
81 }
82
83 if ($showtabofpagedocument) {
84 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
85 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
86 $upload_dir = $conf->bookcal->dir_output."/calendar/".dol_sanitizeFileName($object->ref);
87 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
88 $nbLinks = Link::count($db, $object->element, $object->id);
89 $head[$h][0] = dol_buildpath("/bookcal/calendar_document.php", 1).'?id='.$object->id;
90 $head[$h][1] = $langs->trans('Documents');
91 if (($nbFiles + $nbLinks) > 0) {
92 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
93 }
94 $head[$h][2] = 'document';
95 $h++;
96 }
97
98 if ($showtabofpageagenda) {
99 $head[$h][0] = dol_buildpath("/bookcal/calendar_agenda.php", 1).'?id='.$object->id;
100 $head[$h][1] = $langs->trans("Events");
101 $head[$h][2] = 'agenda';
102 $h++;
103 }
104
105 // Show more tabs from modules
106 // Entries must be declared in modules descriptor with line
107 //$this->tabs = array(
108 // 'entity:+tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__'
109 //); // to add new tab
110 //$this->tabs = array(
111 // 'entity:-tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__'
112 //); // to remove a tab
113 complete_head_from_modules($conf, $langs, $object, $head, $h, 'calendar@bookcal');
114
115 complete_head_from_modules($conf, $langs, $object, $head, $h, 'calendar@bookcal', 'remove');
116
117 return $head;
118}
calendarPrepareHead($object)
Prepare array of tabs for Calendar.
dol_dir_list($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:62
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
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).