dolibarr  16.0.5
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 
31 function 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 (!empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->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 
122  global $db, $langs, $conf;
123 
124  $langs->load("eventorganization");
125 
126  $h = 0;
127  $head = array();
128 
129  $head[$h][0] = dol_buildpath("/eventorganization/conferenceorbooth_list.php", 1).'?projectid='.$object->id;
130  $head[$h][1] = $langs->trans("ConferenceOrBooth");
131  $head[$h][2] = 'conferenceorbooth';
132  // Enable caching of conf or booth count attendees
133  $nbAttendees = 0;
134  $nbConferenceOrBooth= 0;
135  require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
136  $cachekey = 'count_conferenceorbooth_project_'.$object->id;
137  $dataretrieved = dol_getcache($cachekey);
138  if (!is_null($dataretrieved)) {
139  $nbAttendees = $dataretrieved;
140  } else {
141  require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php';
142  $conforbooth=new ConferenceOrBooth($db);
143  $result = $conforbooth->fetchAll('', '', 0, 0, array('t.fk_project'=>$object->id));
144  if (!is_array($result) && $result<0) {
145  setEventMessages($conforbooth->error, $conforbooth->errors, 'errors');
146  } else {
147  $nbConferenceOrBooth = count($result);
148  }
149  dol_setcache($cachekey, $nbConferenceOrBooth, 120); // If setting cache fails, this is not a problem, so we do not test result.
150  }
151  if ($nbConferenceOrBooth > 0) {
152  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbConferenceOrBooth.'</span>';
153  }
154  $h++;
155 
156  $head[$h][0] = dol_buildpath("/eventorganization/conferenceorboothattendee_list.php", 1).'?fk_project='.$object->id.'&withproject=1';
157  $head[$h][1] = $langs->trans("Attendees");
158  $head[$h][2] = 'attendees';
159  // Enable caching of conf or booth count attendees
160  $nbAttendees = 0;
161  require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
162  $cachekey = 'count_attendees_conferenceorbooth_project_'.$object->id;
163  $dataretrieved = dol_getcache($cachekey);
164  if (!is_null($dataretrieved)) {
165  $nbAttendees = $dataretrieved;
166  } else {
167  require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
168  $attendees=new ConferenceOrBoothAttendee($db);
169  $result = $attendees->fetchAll('', '', 0, 0, array('t.fk_project'=>$object->id));
170  if (!is_array($result) && $result<0) {
171  setEventMessages($attendees->error, $attendees->errors, 'errors');
172  } else {
173  $nbAttendees = count($result);
174  }
175  dol_setcache($cachekey, $nbAttendees, 120); // If setting cache fails, this is not a problem, so we do not test result.
176  }
177  if ($nbAttendees > 0) {
178  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbAttendees.'</span>';
179  }
180 
181  complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothproject@eventorganization');
182 
183  complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothproject@eventorganization', 'remove');
184 
185  return $head;
186 }
187 
188 
196 {
197  global $db, $langs, $conf;
198 
199  $langs->load("eventorganization");
200 
201  $h = 0;
202  $head = array();
203 
204  $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) : '');
205  $head[$h][1] = $langs->trans("Card");
206  $head[$h][2] = 'card';
207  $h++;
208 
209  //TODO : Note and docuement
210 
211  complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization');
212 
213  complete_head_from_modules($conf, $langs, $object, $head, $h, 'conferenceorboothattendee@eventorganization', 'remove');
214 
215  return $head;
216 }
dol_setcache
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
Definition: memory.lib.php:68
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
dol_getcache
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.
Definition: memory.lib.php:135
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
conferenceorboothPrepareHead
conferenceorboothPrepareHead($object, $with_project=0)
Prepare array of tabs for ConferenceOrBooth.
Definition: eventorganization_conferenceorbooth.lib.php:31
dol_dir_list
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
complete_head_from_modules
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
Definition: functions.lib.php:9038
conferenceorboothAttendeePrepareHead
conferenceorboothAttendeePrepareHead($object)
Prepare array of tabs for ConferenceOrBoothAttendees.
Definition: eventorganization_conferenceorbooth.lib.php:195
ConferenceOrBooth
Class for ConferenceOrBooth.
Definition: conferenceorbooth.class.php:33
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
conferenceorboothProjectPrepareHead
conferenceorboothProjectPrepareHead($object)
Prepare array of tabs for ConferenceOrBooth Project tab.
Definition: eventorganization_conferenceorbooth.lib.php:119
ConferenceOrBoothAttendee
Class for ConferenceOrBoothAttendee.
Definition: conferenceorboothattendee.class.php:33