loadCoreJS(); $vbo_app->loadContextMenuAssets(); VBOFactory::getChatMediator()->useAssets(); VikBookingIcons::loadRemoteAssets(); $geo = VikBooking::getGeocodingInstance(); if ($geo->isSupported()) { $geo->loadAssets([ 'callback' => 'vbo_gm_ready', 'libraries' => 'marker', 'loading' => 'async', ]); } JHtml::fetch('vbohtml.tmscripts.changestatus'); // access the CMS application $app = JFactory::getApplication(); // get the current filters $filters = (array) $app->getUserStateFromRequest("vbo.tm.filters", 'filters', [], 'array'); // determine the current calendar type $allowedTypes = [ 'month', 'day', 'taskdetails', ]; $calendarType = $filters['calendar_type'] ?? $allowedTypes[0]; $calendarType = in_array($calendarType, $allowedTypes) ? $calendarType : $allowedTypes[0]; // make sure to set the proper calendar type filter $filters['calendar_type'] = $calendarType; // build operator TM iCal URL $operator_signature = base64_encode($operator['id'] . ':' . md5($operator['code'])); $tm_ical_uri = VBOFactory::getPlatform()->getUri()->route('index.php?option=com_vikbooking&view=operators&task=operatortool.tm_ical&opsid=' . urlencode($operator_signature)); // get the list of area/project IDs to which the current operator belongs $areaIds = VBOTaskModelArea::getInstance()->getAssigneeItems($operator['id']); // get the current operator permissions $accept_tasks = (bool) ($permissions ? $permissions->get('accept_tasks', 0) : 0); // check from the permissions whether tasks can be accepted by the operator, // hence null assigness should be included - use a different filter otherwise $operatorTasksFilterName = $accept_tasks ? 'operator' : 'assignee'; // build filter options for counting all future tasks (from the right areas/projects if fetching also the unassigned tasks) $fetchOptions = array_merge($filters, [ $operatorTasksFilterName => $operator['id'], 'id_areas' => $accept_tasks ? $areaIds : null, 'future' => true, ]); $futureTasksCount = VBOTaskModelTask::getInstance()->filterItems($fetchOptions, 0, 1, $count = true); // count future tasks assigned and unassigned, if permissions enabled $assignedTasksCount = 0; $unassignedTasksCount = 0; if ($accept_tasks) { // build filter options for counting the future tasks assigned $fetchOptions = array_merge($filters, [ 'assignee' => $operator['id'], 'future' => true, ]); $assignedTasksCount = VBOTaskModelTask::getInstance()->filterItems($fetchOptions, 0, 1, $count = true); // build filter options for counting the future tasks unassigned (yet from the right areas/projects) $fetchOptions = array_merge($filters, [ 'assignee' => -1, 'id_areas' => $areaIds, 'future' => true, ]); $unassignedTasksCount = VBOTaskModelTask::getInstance()->filterItems($fetchOptions, 0, 1, $count = true); } ?>
$tool, 'operator' => $operator, 'permissions' => $permissions, 'tool_uri' => $tool_uri, 'data' => [ 'filters' => $filters, ], // inject flag for not loading any tasks and display just an empty calendar 'no_tasks' => 1, ]; echo JLayoutHelper::render('taskmanager.calendar.' . $allowedTypes[0], $layout_data, null, [ 'component' => 'com_vikbooking', 'client' => 'site', ]); ?>