$page_title = $TITLE[$c['dir']]; } $c['r'] = $CNF["rows_in_page"]; //Rows (per page) $c['page'] = checkRequest('page', 0); // № текущей страницы $c['ob'] = checkRequest('ob'); // order_by $c['od'] = checkRequest('od', false); // order_desc // Сортировка по умолчанию if ($c['ob'] == "") { $c['ob'] = $default_order; $c['od'] = false; } $c['row_count'] = getListRowCount($c['filter'], 'filter'); $c['pages'] = ceil($c['row_count'] / $c['r']); $c['tickets'] = getTicketList($c['filter'], $c['ob'], $c['od'], $c['page'], $c['r'], 'filter'); if ($c['ob'] == $default_order) { $c['ob'] = ''; } } elseif (isset($_REQUEST['ticket'])) { $section = 'ticket_view'; $id = checkRequest('ticket'); $rating = checkRequest('r'); if ($rating > 0) { $message = rateTicket($uid, $id, $rating); $c['msg_type'] = $message['success'] ? 'success' : 'error'; $c['msg'] = $message['msg']; } $c['ticket'] = getTicket($id);
break; case 'updateFilters': $c["admins"] = getAdmins(); require_once "../vendor/autoload.php"; // Twig инициализация Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem("../templates/helpdesk"); // Twig папка с шаблонами $twig = new Twig_Environment($loader, array("cache" => "")); // Twig no cache $query_filters = $db->query("SELECT `id`,`user`,`name`,`filter` FROM helpdesk_filter WHERE (`user`=0) OR (`user`=" . $admin_login['uid'] . ") ORDER BY `name`"); while ($filters_res = $db->fetch_assoc($query_filters)) { $c['filters'][$filters_res['id']] = $filters_res; } foreach ($c['filters'] as $id => $filter) { $c['filters'][$id]['count'] = getListRowCount($filter['filter']); } $result['filters_block'] = $twig->render('filters_block.twig', $c); $result['success'] = true; unset($result['msg']); break; case 'getTicketInfo': require_once "../vendor/autoload.php"; // Twig инициализация Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem("../templates/helpdesk"); // Twig папка с шаблонами $twig = new Twig_Environment($loader, array("cache" => "")); // Twig no cache $id = $_POST['ticket_id']; $AREAS = getAreas();
$p[$uid]['rating'] = getAverageRating($p[$uid]['filter_opened']); // print_r($p[$uid]['rating']); $p[$uid]['rating']['rating_r'] = round($p[$uid]['rating']['rating'] / 100, 2) * 100; if ($p[$uid]['opened'] == 0) { unset($p[$uid]); } } $p['all']['firstname'] = 'Всего'; $p['all']['filter_opened'] = '{"dates": "' . $dates . '"}'; $p['all']['filter_done'] = '{"status": "4", "dates": "' . $dates . '"}'; $p['all']['filter_waited'] = '{"status": "5", "dates":"' . $dates . '"}'; $p['all']['filter_paused'] = '{"status": "7", "dates":"' . $dates . '"}'; $p['all']['filter_closed'] = '{"status": "6", "dates": "' . $dates . '"}'; $p['all']['filter_cancelled'] = '{"status": "8", "dates": "' . $dates . '"}'; $p['all']['opened'] = getListRowCount($p['all']['filter_opened']); $p['all']['done'] = getListRowCount($p['all']['filter_done']); $p['all']['waited'] = getListRowCount($p['all']['filter_waited']); $p['all']['paused'] = getListRowCount($p['all']['filter_paused']); $p['all']['closed'] = getListRowCount($p['all']['filter_closed']); $p['all']['cancelled'] = getListRowCount($p['all']['filter_cancelled']); $p['all']['result'] = $p['all']['opened'] - $p['all']['waited'] - $p['all']['paused'] - $p['all']['cancelled'] > 0 ? ($p['all']['done'] + $p['all']['closed']) / ($p['all']['opened'] - $p['all']['waited'] - $p['all']['paused'] - $p['all']['cancelled']) : 0; $p['all']['percentage_r1'] = round($p['all']['result'], 2) * 100; $p['all']['percentage_r2'] = round($p['all']['result'], 2) * 100; $p['all']['rating'] = getAverageRating($p['all']['filter_closed']); $p['all']['rating']['rating_r'] = round($p['all']['rating']['rating']); $c['admins'] = $admins; $c['performers'] = $p; echo $twig->render("helpdesk/reports.twig", $c); } else { echo "Access denied"; }