1<?php 2/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net> 3 * Copyright (C) 2021 Florian Henry <florian.henry@scopen.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 19/** 20 * \file conferenceorbooth_document.php 21 * \ingroup eventorganization 22 * \brief Tab for documents linked to ConferenceOrBooth 23 */ 24 25require '../main.inc.php'; 26 27require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; 28require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 29require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; 30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; 31require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; 32require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; 33require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; 34require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; 35 36// Load translation files required by the page 37$langs->loadLangs(array("eventorganization", "companies", "other", "mails")); 38 39$action = GETPOST('action', 'aZ09'); 40$confirm = GETPOST('confirm'); 41$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); 42$ref = GETPOST('ref', 'alpha'); 43$withproject = GETPOST('withproject', 'int'); 44$project_ref = GETPOST('project_ref', 'alpha'); 45 46 47// Get parameters 48$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; 49$sortfield = GETPOST("sortfield", 'alpha'); 50$sortorder = GETPOST("sortorder", 'alpha'); 51$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); 52if (empty($page) || $page == -1) { 53 $page = 0; 54} // If $page is not defined, or '' or -1 55$offset = $liste_limit * $page; 56$pageprev = $page - 1; 57$pagenext = $page + 1; 58if (!$sortorder) { 59 $sortorder = "ASC"; 60} 61if (!$sortfield) { 62 $sortfield = "name"; 63} 64//if (! $sortfield) $sortfield="position_name"; 65 66// Initialize technical objects 67$object = new ConferenceOrBooth($db); 68$extrafields = new ExtraFields($db); 69$projectstatic = new Project($db); 70$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; 71$hookmanager->initHooks(array('conferenceorboothdocument', 'globalcard')); // Note that conf->hooks_modules contains array 72// Fetch optionals attributes and labels 73$extrafields->fetch_name_optionals_label($object->table_element); 74 75// Load object 76include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals 77 78if ($id > 0 || !empty($ref)) { 79 $upload_dir = $conf->eventorganization->multidir_output[$object->entity ? $object->entity : $conf->entity]."/conferenceorbooth/".get_exdir(0, 0, 0, 1, $object); 80} 81 82$permissiontoadd = $user->rights->eventorganization->conferenceorbooth->write; // Used by the include of actions_addupdatedelete.inc.php 83 84// Security check 85if ($user->socid > 0) { 86 accessforbidden(); 87} 88$isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); 89$result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); 90 91 92/* 93 * Actions 94 */ 95 96include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; 97 98 99/* 100 * View 101 */ 102 103$form = new Form($db); 104 105$title = $langs->trans("ConferenceOrBooth").' - '.$langs->trans("Files"); 106$help_url = ''; 107//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; 108llxHeader('', $title, $help_url); 109 110$result = $projectstatic->fetch($object->fk_project); 111if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { 112 $projectstatic->fetchComments(); 113} 114if (!empty($projectstatic->socid)) { 115 $projectstatic->fetch_thirdparty(); 116} 117 118$withProjectUrl=''; 119$object->project = clone $projectstatic; 120 121if (!empty($withproject)) { 122 // Tabs for project 123 $tab = 'eventorganisation'; 124 $head = project_prepare_head($projectstatic); 125 print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); 126 127 // Project card 128 129 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; 130 131 $morehtmlref = '<div class="refidno">'; 132 // Title 133 $morehtmlref .= $projectstatic->title; 134 // Thirdparty 135 if ($projectstatic->thirdparty->id > 0) { 136 $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); 137 } 138 $morehtmlref .= '</div>'; 139 140 // Define a complementary filter for search of next/prev ref. 141 if (!$user->rights->projet->all->lire) { 142 $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); 143 $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; 144 } 145 146 dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); 147 148 print '<div class="fichecenter">'; 149 print '<div class="fichehalfleft">'; 150 print '<div class="underbanner clearboth"></div>'; 151 152 print '<table class="border tableforfield centpercent">'; 153 154 // Usage 155 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { 156 print '<tr><td class="tdtop">'; 157 print $langs->trans("Usage"); 158 print '</td>'; 159 print '<td>'; 160 if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { 161 print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_opportunity ? ' checked="checked"' : '')).'"> '; 162 $htmltext = $langs->trans("ProjectFollowOpportunity"); 163 print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); 164 print '<br>'; 165 } 166 if (empty($conf->global->PROJECT_HIDE_TASKS)) { 167 print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_task ? ' checked="checked"' : '')).'"> '; 168 $htmltext = $langs->trans("ProjectFollowTasks"); 169 print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); 170 print '<br>'; 171 } 172 if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { 173 print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_bill_time ? ' checked="checked"' : '')).'"> '; 174 $htmltext = $langs->trans("ProjectBillTimeDescription"); 175 print $form->textwithpicto($langs->trans("BillTime"), $htmltext); 176 print '<br>'; 177 } 178 if (!empty($conf->eventorganization->enabled)) { 179 print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($projectstatic->usage_organize_event ? ' checked="checked"' : '')).'"> '; 180 $htmltext = $langs->trans("EventOrganizationDescriptionLong"); 181 print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); 182 } 183 print '</td></tr>'; 184 } 185 186 // Visibility 187 print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; 188 if ($projectstatic->public) { 189 print $langs->trans('SharedProject'); 190 } else { 191 print $langs->trans('PrivateProject'); 192 } 193 print '</td></tr>'; 194 195 // Date start - end 196 print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>'; 197 $start = dol_print_date($projectstatic->date_start, 'day'); 198 print ($start ? $start : '?'); 199 $end = dol_print_date($projectstatic->date_end, 'day'); 200 print ' - '; 201 print ($end ? $end : '?'); 202 if ($projectstatic->hasDelay()) { 203 print img_warning("Late"); 204 } 205 print '</td></tr>'; 206 207 // Budget 208 print '<tr><td>'.$langs->trans("Budget").'</td><td>'; 209 if (strcmp($projectstatic->budget_amount, '')) { 210 print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); 211 } 212 print '</td></tr>'; 213 214 // Other attributes 215 $cols = 2; 216 //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; 217 218 print '</table>'; 219 220 print '</div>'; 221 222 print '<div class="fichehalfright">'; 223 print '<div class="ficheaddleft">'; 224 print '<div class="underbanner clearboth"></div>'; 225 226 print '<table class="border centpercent">'; 227 228 // Description 229 print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; 230 print nl2br($projectstatic->description); 231 print '</td></tr>'; 232 233 // Categories 234 if ($conf->categorie->enabled) { 235 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>'; 236 print $form->showCategories($projectstatic->id, 'project', 1); 237 print "</td></tr>"; 238 } 239 240 print '<tr><td>'; 241 $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); 242 $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); 243 print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); 244 print '</td><td>'; 245 print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); 246 print "</td></tr>"; 247 248 print '<tr><td>'; 249 $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); 250 $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); 251 print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); 252 print '</td><td>'; 253 print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); 254 print "</td></tr>"; 255 256 print '<tr><td>'; 257 print $form->editfieldkey('PriceOfRegistration', 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); 258 print '</td><td>'; 259 print $form->editfieldval('PriceOfRegistration', 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); 260 print "</td></tr>"; 261 262 print '<tr><td>'; 263 print $form->editfieldkey('PriceOfBooth', 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); 264 print '</td><td>'; 265 print $form->editfieldval('PriceOfBooth', 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); 266 print "</td></tr>"; 267 268 print '<tr><td valign="middle">'.$langs->trans("EventOrganizationICSLink").'</td><td>'; 269 // Define $urlwithroot 270 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); 271 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; 272 273 // Show message 274 $message = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical'.($conf->entity > 1 ? "&entity=".$conf->entity : ""); 275 $message .= '&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...'); 276 $message .= "&project=".$projectstatic->id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').'</a>'; 277 print $message; 278 print "</td></tr>"; 279 280 print '</table>'; 281 282 print '</div>'; 283 print '</div>'; 284 print '</div>'; 285 286 print '<div class="clearboth"></div>'; 287 288 print dol_get_fiche_end(); 289 290 print '<br>'; 291} 292 293if ($object->id) { 294 /* 295 * Show tabs 296 */ 297 $head = conferenceorboothPrepareHead($object, $withproject); 298 299 print dol_get_fiche_head($head, 'document', $langs->trans("ConferenceOrBooth"), -1, $object->picto); 300 301 302 // Build file list 303 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); 304 $totalsize = 0; 305 foreach ($filearray as $key => $file) { 306 $totalsize += $file['size']; 307 } 308 309 // Object card 310 // ------------- 311 //----------------------------------------------- 312 $linkback = '<a href="'.dol_buildpath('/eventorganization/conferenceorbooth_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; 313 314 $morehtmlref = '<div class="refidno">'; 315 $morehtmlref .= '</div>'; 316 317 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); 318 319 print '<div class="fichecenter">'; 320 321 print '<div class="underbanner clearboth"></div>'; 322 print '<table class="border centpercent tableforfield">'; 323 324 // Number of files 325 print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; 326 327 // Total size 328 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; 329 330 print '</table>'; 331 332 print '</div>'; 333 334 print dol_get_fiche_end(); 335 336 $modulepart = 'eventorganization'; 337 //$permission = $user->rights->eventorganization->conferenceorbooth->write; 338 $permission = 1; 339 //$permtoedit = $user->rights->eventorganization->conferenceorbooth->write; 340 $permtoedit = 1; 341 $param = '&id='.$object->id; 342 //$param = ''; 343 if ($withproject) { 344 $param .= '&withproject=1'; 345 } 346 //$relativepathwithnofile='conferenceorbooth/' . dol_sanitizeFileName($object->id).'/'; 347 $relativepathwithnofile = 'conferenceorbooth/'.dol_sanitizeFileName($object->ref).'/'; 348 349 include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; 350} else { 351 accessforbidden('', 0, 1); 352} 353 354// End of page 355llxFooter(); 356$db->close(); 357