dolibarr 19.0.3
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 *
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
31function conferenceorboothPrepareHead($object, $with_project = 0)
32{
33 global $db, $langs, $conf;
34
35 $langs->load("eventorganization");
36
37 $h = 0;
38 $head = array();
39
40 $withProjectUrl='';
41 if ($with_project>0) {
42 $withProjectUrl = "&withproject=1";
43 }
44
45 $head[$h][0] = DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.php?id='.$object->id.$withProjectUrl;
46 $head[$h][1] = $langs->trans("Card");
47 $head[$h][2] = 'card';
48 $h++;
49
50 if (getDolGlobalString('MAIN_FEATURES_LEVEL') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
51 $head[$h][0] = DOL_URL_ROOT.'/eventorganization/conferenceorbooth_contact.php?id='.$object->id.$withProjectUrl;
52 $head[$h][1] = $langs->trans("ContactsAddresses");
53 $head[$h][2] = 'contact';
54 $h++;
55 }
56
57 /*
58 $head[$h][0] = DOL_URL_ROOT.'/eventorganization/conferenceorboothattendee_list.php?conforboothid='.$object->id.$withProjectUrl;
59 $head[$h][1] = $langs->trans("Attendees");
60 $head[$h][2] = 'attendees';
61 // Enable caching of conf or booth count attendees
62 $nbAttendees = 0;
63 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
64 $cachekey = 'count_attendees_conferenceorbooth_'.$object->id;
65 $dataretrieved = dol_getcache($cachekey);
66 if (!is_null($dataretrieved)) {
67 $nbAttendees = $dataretrieved;
68 } else {
69 require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
70 $attendees=new ConferenceOrBoothAttendee($db);
71 $result = $attendees->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$object->id));
72 if (!is_array($result) && $result<0) {
73 setEventMessages($attendees->error, $attendees->errors, 'errors');
74 } else {
75 $nbAttendees = count($result);
76 }
77 dol_setcache($cachekey, $nbAttendees, 120); // If setting cache fails, this is not a problem, so we do not test result.
78 }
79 if ($nbAttendees > 0) {
80 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbAttendees.'</span>';
81 }
82 $h++;
83 */
84
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->eventorganization->dir_output."/conferenceorbooth/".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_buildpath("/eventorganization/conferenceorbooth_document.php", 1).'?id='.$object->id.$withProjectUrl;
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 // Show more tabs from modules
99 // Entries must be declared in modules descriptor with line
100 //$this->tabs = array(
101 // 'entity:+tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__'
102 //); // to add new tab
103 //$this->tabs = array(
104 // 'entity:-tabname:Title:@eventorganization:/eventorganization/mypage.php?id=__ID__'
105 //); // to remove a tab
106 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorbooth@eventorganization');
107
108 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorbooth@eventorganization', 'remove');
109
110 return $head;
111}
112
120{
121 global $db, $langs, $conf;
122
123 $langs->load("eventorganization");
124
125 $h = 0;
126 $head = array();
127
128 $head[$h][0] = DOL_URL_ROOT . '/eventorganization/conferenceorbooth_list.php?projectid=' . $object->id;
129 $head[$h][1] = $langs->trans("ConferenceOrBooth");
130 $head[$h][2] = 'conferenceorbooth';
131 // Enable caching of conf or booth count attendees
132 $nbAttendees = 0;
133 $nbConferenceOrBooth= 0;
134 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
135 $cachekey = 'count_conferenceorbooth_project_'.$object->id;
136 $dataretrieved = dol_getcache($cachekey);
137 if (!is_null($dataretrieved)) {
138 $nbAttendees = $dataretrieved;
139 } else {
140 require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
141 $conforbooth=new ConferenceOrBooth($db);
142 $result = $conforbooth->fetchAll('', '', 0, 0, array('t.fk_project'=>$object->id));
143 if (!is_array($result) && $result<0) {
144 setEventMessages($conforbooth->error, $conforbooth->errors, 'errors');
145 } else {
146 $nbConferenceOrBooth = count($result);
147 }
148 dol_setcache($cachekey, $nbConferenceOrBooth, 120); // If setting cache fails, this is not a problem, so we do not test result.
149 }
150 if ($nbConferenceOrBooth > 0) {
151 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbConferenceOrBooth.'</span>';
152 }
153 $h++;
154
155 $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?fk_project='.$object->id.'&withproject=1';
156 $head[$h][1] = $langs->trans("Attendees");
157 $head[$h][2] = 'attendees';
158 // Enable caching of conf or booth count attendees
159 $nbAttendees = 0;
160 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
161 $cachekey = 'count_attendees_conferenceorbooth_project_'.$object->id;
162 $dataretrieved = dol_getcache($cachekey);
163 if (!is_null($dataretrieved)) {
164 $nbAttendees = $dataretrieved;
165 } else {
166 require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
167 $attendees=new ConferenceOrBoothAttendee($db);
168 $result = $attendees->fetchAll('', '', 0, 0, array('t.fk_project'=>$object->id));
169 if (!is_array($result) && $result<0) {
170 setEventMessages($attendees->error, $attendees->errors, 'errors');
171 } else {
172 $nbAttendees = count($result);
173 }
174 dol_setcache($cachekey, $nbAttendees, 120); // If setting cache fails, this is not a problem, so we do not test result.
175 }
176 if ($nbAttendees > 0) {
177 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbAttendees.'</span>';
178 }
179
180 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothproject@eventorganization');
181
182 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothproject@eventorganization', 'remove');
183
184 return $head;
185}
186
187
195{
196 global $db, $langs, $conf;
197
198 $langs->load("eventorganization");
199
200 $h = 0;
201 $head = array();
202
203 $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) : '');
204 $head[$h][1] = $langs->trans("Card");
205 $head[$h][2] = 'card';
206 $h++;
207
208 //TODO : Note and docuement
209
210 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization');
211
212 complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization', 'remove');
213
214 return $head;
215}
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($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.
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.
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 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.