dolibarr 21.0.0-alpha
eventorganization_conferenceorbooth.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) ---Put here your own copyright and developer email---
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
33function conferenceorboothPrepareHead($object, $with_project = 0)
34{
35 global $db, $langs, $conf;
36
37 $langs->load("eventorganization");
38
39 $h = 0;
40 $head = array();
41
42 $withProjectUrl = '';
43 if ($with_project > 0) {
44 $withProjectUrl = "&withproject=1";
45 }
46
47 $head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorbooth_card.php?id=' . $object->id . $withProjectUrl;
48 $head[$h][1] = $langs->trans("Card");
49 $head[$h][2] = 'card';
50 $h++;
51
52 if (getDolGlobalString('MAIN_FEATURES_LEVEL') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
53 $head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorbooth_contact.php?id=' . $object->id . $withProjectUrl;
54 $head[$h][1] = $langs->trans("ContactsAddresses");
55 $head[$h][2] = 'contact';
56 $h++;
57 }
58
59 /*
60 $head[$h][0] = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_list.php?conforboothid='.$object->id.$withProjectUrl;
61 $head[$h][1] = $langs->trans("Attendees");
62 $head[$h][2] = 'attendees';
63 // Enable caching of conf or booth count attendees
64 $nbAttendees = 0;
65 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
66 $cachekey = 'count_attendees_conferenceorbooth_'.$object->id;
67 $dataretrieved = dol_getcache($cachekey);
68 if (!is_null($dataretrieved)) {
69 $nbAttendees = $dataretrieved;
70 } else {
71 require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
72 $attendees=new ConferenceOrBoothAttendee($db);
73 $result = $attendees->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$object->id));
74 if (!is_array($result) && $result<0) {
75 setEventMessages($attendees->error, $attendees->errors, 'errors');
76 } else {
77 $nbAttendees = count($result);
78 }
79 dol_setcache($cachekey, $nbAttendees, 120); // If setting cache fails, this is not a problem, so we do not test result.
80 }
81 if ($nbAttendees > 0) {
82 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbAttendees.'</span>';
83 }
84 $h++;
85 */
86
87 require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
88 require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
89 $upload_dir = $conf->eventorganization->dir_output . "/conferenceorbooth/" . dol_sanitizeFileName($object->ref);
90 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
91 $nbLinks = Link::count($db, $object->element, $object->id);
92 $head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorbooth_document.php?id=' . $object->id . $withProjectUrl;
93 $head[$h][1] = $langs->trans('Documents');
94 if (($nbFiles + $nbLinks) > 0) {
95 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>';
96 }
97 $head[$h][2] = 'document';
98 $h++;
99
100 // Show more tabs from modules
101 // Entries must be declared in modules descriptor with line
102 //$this->tabs = array(
103 // 'entity:+tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__'
104 //); // to add new tab
105 //$this->tabs = array(
106 // 'entity:-tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__'
107 //); // to remove a tab
108 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorbooth@eventorganization');
109
110 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorbooth@eventorganization', 'remove');
111
112 return $head;
113}
114
122{
123 global $db, $langs, $conf;
124
125 $langs->load("eventorganization");
126
127 $h = 0;
128 $head = array();
129
130 $head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorbooth_list.php?projectid=' . $object->id;
131 $head[$h][1] = $langs->trans("ConferenceOrBooth");
132 $head[$h][2] = 'conferenceorbooth';
133 // Enable caching of conf or booth count attendees
134 $nbAttendees = 0;
135 $nbConferenceOrBooth = 0;
136 require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php';
137 $cachekey = 'count_conferenceorbooth_project_' . $object->id;
138 $dataretrieved = dol_getcache($cachekey);
139 if (!is_null($dataretrieved)) {
140 $nbAttendees = $dataretrieved;
141 } else {
142 require_once DOL_DOCUMENT_ROOT . '/eventorganization/class/conferenceorbooth.class.php';
143 $conforbooth = new ConferenceOrBooth($db);
144 $result = $conforbooth->fetchAll('', '', 0, 0, '(t.fk_project:=:' . ((int) $object->id) . ')');
145 if (!is_array($result) && $result < 0) {
146 setEventMessages($conforbooth->error, $conforbooth->errors, 'errors');
147 } else {
148 $nbConferenceOrBooth = count($result);
149 }
150 dol_setcache($cachekey, $nbConferenceOrBooth, 120); // If setting cache fails, this is not a problem, so we do not test result.
151 }
152 if ($nbConferenceOrBooth > 0) {
153 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbConferenceOrBooth . '</span>';
154 }
155 $h++;
156
157 $head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorboothattendee_list.php?fk_project=' . $object->id . '&withproject=1';
158 $head[$h][1] = $langs->trans("Attendees");
159 $head[$h][2] = 'attendees';
160 // Enable caching of conf or booth count attendees
161 $nbAttendees = 0;
162 require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php';
163 $cachekey = 'count_attendees_conferenceorbooth_project_' . $object->id;
164 $dataretrieved = dol_getcache($cachekey);
165 if (!is_null($dataretrieved)) {
166 $nbAttendees = $dataretrieved;
167 } else {
168 require_once DOL_DOCUMENT_ROOT . '/eventorganization/class/conferenceorboothattendee.class.php';
169 $attendees = new ConferenceOrBoothAttendee($db);
170 $result = $attendees->fetchAll('', '', 0, 0, '(t.fk_project:=:' . ((int) $object->id) . ')');
171 if (!is_array($result) && $result < 0) {
172 setEventMessages($attendees->error, $attendees->errors, 'errors');
173 } else {
174 $nbAttendees = count($result);
175 }
176 dol_setcache($cachekey, $nbAttendees, 120); // If setting cache fails, this is not a problem, so we do not test result.
177 }
178 if ($nbAttendees > 0) {
179 $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbAttendees . '</span>';
180 }
181
182 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothproject@eventorganization');
183
184 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothproject@eventorganization', 'remove');
185
186 return $head;
187}
188
189
197{
198 global $db, $langs, $conf;
199
200 $langs->load("eventorganization");
201
202 $h = 0;
203 $head = array();
204
205 $head[$h][0] = DOL_URL_ROOT . "/eventorganization/conferenceorboothattendee_card.php?id=" . ((int) $object->id) . ($object->fk_actioncomm > 0 ? '&conforboothid=' . ((int) $object->fk_actioncomm) : '') . ($object->fk_project > 0 ? '&withproject=1&fk_project=' . ((int) $object->fk_project) : '');
206 $head[$h][1] = $langs->trans("Card");
207 $head[$h][2] = 'card';
208 $h++;
209
210 //TODO : Note and document
211
212 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization');
213
214 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization', 'remove');
215
216 return $head;
217}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class for ConferenceOrBoothAttendee.
Class for ConferenceOrBooth.
conferenceorboothPrepareHead($object, $with_project=0)
Prepare array of tabs for ConferenceOrBooth.
conferenceorboothProjectPrepareHead($object)
Prepare array of tabs for ConferenceOrBooth Project tab.
conferenceorboothAttendeePrepareHead($object)
Prepare array of tabs for ConferenceOrBoothAttendees.
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
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.