$end) { $errors[] = getlocal("statistics.wrong.dates"); } $activetab = 0; $db = Database::getInstance(); if ($statisticstype == 'bydate') { $page['reportByDate'] = $db->query( "SELECT DATE(FROM_UNIXTIME(date)) AS date, " . "threads, " . "missedthreads, " . "sentinvitations, " . "acceptedinvitations, " . "rejectedinvitations, " . "ignoredinvitations, " . "operatormessages AS agents, " . "usermessages AS users, " . "averagewaitingtime AS avgwaitingtime, " . "averagechattime AS avgchattime " . "FROM {chatthreadstatistics} s " . "WHERE s.date >= :start " . "AND s.date < :end " . "ORDER BY s.date DESC", array( ':start' => $start, ':end' => $end ), array('return_rows' => Database::RETURN_ALL_ROWS) ); $page['reportByDateTotal'] = $db->query( "SELECT DATE(FROM_UNIXTIME(date)) AS date, " . "SUM(threads) AS threads, " . "SUM(missedthreads) AS missedthreads, " . "SUM(sentinvitations) AS sentinvitations, " . "SUM(acceptedinvitations) AS acceptedinvitations, " . "SUM(rejectedinvitations) AS rejectedinvitations, " . "SUM(ignoredinvitations) AS ignoredinvitations, " . "SUM(operatormessages) AS agents, " . "SUM(usermessages) AS users, " . "ROUND(SUM(averagewaitingtime * s.threads) / SUM(s.threads),1) AS avgwaitingtime, " . "ROUND(SUM(averagechattime * s.threads) / SUM(s.threads),1) AS avgchattime " . "FROM {chatthreadstatistics} s " . "WHERE s.date >= :start " . "AND s.date < :end", array( ':start' => $start, ':end' => $end ), array('return_rows' => Database::RETURN_ONE_ROW) ); $activetab = 0; } elseif($statisticstype == 'byagent') { $page['reportByAgent'] = $db->query( "SELECT o.vclocalename AS name, " . "s.threads AS threads, " . "s.messages AS msgs, " . "s.averagelength AS avglen " . "FROM {chatoperatorstatistics} s, {chatoperator} o " . "WHERE s.operatorid = o.operatorid " . "AND s.date >= :start " . "AND s.date < :end " . "GROUP BY s.operatorid", array( ':start' => $start, ':end' => $end ), array('return_rows' => Database::RETURN_ALL_ROWS) ); $activetab = 1; } elseif($statisticstype == 'bypage') { $page['reportByPage'] = $db->query( "SELECT SUM(visits) as visittimes, " . "address, " . "SUM(chats) as chattimes " . "FROM {visitedpagestatistics} " . "WHERE date >= :start " . "AND date < :end " . "GROUP BY address", array(':start' => $start, ':end' => $end), array('return_rows' => Database::RETURN_ALL_ROWS) ); $activetab = 2; } $page['showresults'] = count($errors) == 0; prepare_menu($operator); setup_statistics_tabs($activetab); start_html_output(); require('../view/statistics.php'); ?>