* Copyright (C) 2021 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file conferenceorbooth_document.php * \ingroup eventorganization * \brief Tab for documents linked to ConferenceOrBooth */ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array("eventorganization", "projects", "companies", "other", "mails")); // Get Parameters $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) { $sortorder = "ASC"; } if (!$sortfield) { $sortfield = "name"; } //if (! $sortfield) $sortfield="position_name"; // Initialize technical objects $object = new ConferenceOrBooth($db); $extrafields = new ExtraFields($db); $projectstatic = new Project($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('conferenceorboothdocument', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. if ($id > 0 || !empty($ref)) { $upload_dir = $conf->eventorganization->multidir_output[$object->entity ? $object->entity : $conf->entity]."/conferenceorbooth/".get_exdir(0, 0, 0, 1, $object); } // Permissions $permissiontoread = $user->rights->eventorganization->read; $permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $permissionnote = $user->rights->eventorganization->write; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->eventorganization->write; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check if ($user->socid > 0) { accessforbidden(); } $isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); if (!$permissiontoread) { accessforbidden(); } /* * Actions */ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* * View */ $form = new Form($db); $title = $langs->trans("ConferenceOrBooth").' - '.$langs->trans("Files"); $help_url = ''; llxHeader('', $title, $help_url); $result = $projectstatic->fetch($object->fk_project); if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { $projectstatic->fetchComments(); } if (!empty($projectstatic->socid)) { $projectstatic->fetch_thirdparty(); } $withProjectUrl=''; $object->project = clone $projectstatic; if (!empty($withproject)) { // Tabs for project $tab = 'eventorganisation'; $withProjectUrl = "&withproject=1"; $head = project_prepare_head($projectstatic); print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); // Project card $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; // Title $morehtmlref .= $projectstatic->title; // Thirdparty if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) { $morehtmlref .= '
'.$projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref .= '
'; // Define a complementary filter for search of next/prev ref. if (empty($user->rights->project->all->lire)) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); $projectstatic->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); print '
'; print '
'; print '
'; print ''; // Usage if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) { print ''; print ''; } // Visibility print ''; // Date start - end print ''; // Budget print ''; // Other attributes $cols = 2; $objectconf = $object; $object = $projectstatic; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; $object = $objectconf; print '
'; print $langs->trans("Usage"); print ''; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
'; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
'; } if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
'; } if (isModEnabled('eventorganization')) { print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("EventOrganizationDescriptionLong"); print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); } print '
'.$langs->trans("Visibility").''; if ($projectstatic->public) { print $langs->trans('SharedProject'); } else { print $langs->trans('PrivateProject'); } print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($projectstatic->date_start, 'day'); print ($start ? $start : '?'); $end = dol_print_date($projectstatic->date_end, 'day'); print ' - '; print ($end ? $end : '?'); if ($projectstatic->hasDelay()) { print img_warning("Late"); } print '
'.$langs->trans("Budget").''; if (strcmp($projectstatic->budget_amount, '')) { print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); } print '
'; print '
'; print '
'; print '
'; print ''; // Description print ''; // Categories if (isModEnabled('categorie')) { print '"; } print '"; print '"; print '"; print '"; print '"; // Link to the submit vote/register page print ''; // Link to the subscribe print ''; print '
'.$langs->trans("Description").''; print nl2br($projectstatic->description); print '
'.$langs->trans("Categories").''; print $form->showCategories($projectstatic->id, Categorie::TYPE_PROJECT, 1); print "
'; $typeofdata = 'checkbox:'.($projectstatic->accept_conference_suggestions ? ' checked="checked"' : ''); $htmltext = $langs->trans("AllowUnknownPeopleSuggestConfHelp"); print $form->editfieldkey('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); print ''; print $form->editfieldval('AllowUnknownPeopleSuggestConf', 'accept_conference_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); print "
'; $typeofdata = 'checkbox:'.($projectstatic->accept_booth_suggestions ? ' checked="checked"' : ''); $htmltext = $langs->trans("AllowUnknownPeopleSuggestBoothHelp"); print $form->editfieldkey('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '', $projectstatic, 0, $typeofdata, '', 0, 0, 'projectid', $htmltext); print ''; print $form->editfieldval('AllowUnknownPeopleSuggestBooth', 'accept_booth_suggestions', '1', $projectstatic, 0, $typeofdata, '', 0, 0, '', 0, '', 'projectid'); print "
'; print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); print ''; print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfBooth'), $langs->trans("PriceOfBoothHelp")), 'price_booth', $projectstatic->price_booth, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'; print $form->editfieldkey($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', '', $projectstatic, 0, 'amount', '', 0, 0, 'projectid'); print ''; print $form->editfieldval($form->textwithpicto($langs->trans('PriceOfRegistration'), $langs->trans("PriceOfRegistrationHelp")), 'price_registration', $projectstatic->price_registration, $projectstatic, 0, 'amount', '', 0, 0, '', 0, '', 'projectid'); print "
'.$langs->trans("EventOrganizationICSLink").''; // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // Show message $message = 'id.'&module='.urlencode('@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').''; print $message; print "
'; //print ''; print $form->textwithpicto($langs->trans("SuggestOrVoteForConfOrBooth"), $langs->trans("EvntOrgRegistrationHelpMessage")); //print ''; print ''; $linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.((int) $projectstatic->id); $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $projectstatic->id), 'md5'); $linksuggest .= '&securekey='.urlencode($encodedsecurekey); //print ''; //print ajax_autoselect("linkregister"); print '
'; //print ''; print $langs->trans("PublicAttendeeSubscriptionGlobalPage"); //print ''; print ''; $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.((int) $projectstatic->id).'&type=global'; $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $projectstatic->id), 'md5'); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); //print ''; //print ajax_autoselect("linkregister"); print '
'; print '
'; print '
'; print '
'; print dol_get_fiche_end(); print '
'; } if ($object->id) { /* * Show tabs */ $head = conferenceorboothPrepareHead($object, $withproject); print dol_get_fiche_head($head, 'document', $langs->trans("ConferenceOrBooth"), -1, $object->picto); // Build file list $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $totalsize = 0; foreach ($filearray as $key => $file) { $totalsize += $file['size']; } // Object card //----------------------------------------------- $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); print '
'; print '
'; print ''; // Number of files print ''; // Total size print ''; print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; print '
'; print dol_get_fiche_end(); $modulepart = 'eventorganization'; //$permission = $user->rights->eventorganization->conferenceorbooth->write; $permission = 1; //$permtoedit = $user->rights->eventorganization->conferenceorbooth->write; $permtoedit = 1; $param = '&id='.$object->id; //$param = ''; if ($withproject) { $param .= '&withproject=1'; } //$relativepathwithnofile='conferenceorbooth/' . dol_sanitizeFileName($object->id).'/'; $relativepathwithnofile = 'conferenceorbooth/'.dol_sanitizeFileName($object->ref).'/'; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { accessforbidden('', 0, 1); } // End of page llxFooter(); $db->close();