mirror of
https://github.com/Mibew/java.git
synced 2025-01-22 17:40:35 +03:00
Added tabs at statistics page
This commit is contained in:
parent
0fc5beb17a
commit
5016eceae8
46
src/messenger/webim/libs/statistics.php
Normal file
46
src/messenger/webim/libs/statistics.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Mibew Messenger project.
|
||||
*
|
||||
* Copyright (c) 2005-2011 Mibew Messenger Community
|
||||
* All rights reserved. The contents of this file are subject to the terms of
|
||||
* the Eclipse Public License v1.0 which accompanies this distribution, and
|
||||
* is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU General Public License Version 2 or later (the "GPL"), in which case
|
||||
* the provisions of the GPL are applicable instead of those above. If you wish
|
||||
* to allow use of your version of this file only under the terms of the GPL, and
|
||||
* not to allow others to use your version of this file under the terms of the
|
||||
* EPL, indicate your decision by deleting the provisions above and replace them
|
||||
* with the notice and other provisions required by the GPL.
|
||||
*
|
||||
* Contributors:
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
function get_statistics_query($type)
|
||||
{
|
||||
$query = $_SERVER['QUERY_STRING'];
|
||||
if (! empty($query)) {
|
||||
$query = '?'.$query;
|
||||
$query = preg_replace("/\?type=\w+\&/", "?", $query);
|
||||
$query = preg_replace("/(\?|\&)type=\w+/", "", $query);
|
||||
}
|
||||
$query .= strstr($query, "?") ? "&type=$type" : "?type=$type";
|
||||
return $query;
|
||||
}
|
||||
|
||||
function setup_statistics_tabs($active)
|
||||
{
|
||||
global $settings, $page, $webimroot;
|
||||
$page['tabs'] = array(
|
||||
getlocal("report.bydate.title") => $active != 0 ? "$webimroot/operator/statistics.php".get_statistics_query('bydate') : "",
|
||||
getlocal("report.byoperator.title") => $active != 1 ? "$webimroot/operator/statistics.php".get_statistics_query('byagent') : ""
|
||||
);
|
||||
if ($settings['enabletracking']) {
|
||||
$page['tabs'][getlocal("report.bypage.title")] = ($active != 2 ? "$webimroot/operator/statistics.php".get_statistics_query('bypage') : "");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -22,6 +22,7 @@
|
||||
require_once('../libs/common.php');
|
||||
require_once('../libs/chat.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/statistics.php');
|
||||
|
||||
$operator = check_login();
|
||||
force_password($operator);
|
||||
@ -33,6 +34,11 @@ $page['operator'] = topage(get_operator_name($operator));
|
||||
$page['availableDays'] = range(1, 31);
|
||||
$page['availableMonth'] = get_month_selection(time() - 400 * 24 * 60 * 60, time() + 50 * 24 * 60 * 60);
|
||||
$page['showresults'] = false;
|
||||
$statisticstype = verifyparam("type", "/^(bydate|byagent|bypage)$/", "bydate");
|
||||
$page['type'] = $statisticstype;
|
||||
$page['showbydate'] = ($statisticstype == 'bydate');
|
||||
$page['showbyagent'] = ($statisticstype == 'byagent');
|
||||
$page['showbypage'] = ($statisticstype == 'bypage');
|
||||
$errors = array();
|
||||
|
||||
if (isset($_GET['startday'])) {
|
||||
@ -68,29 +74,34 @@ if ($start > $end) {
|
||||
$errors[] = getlocal("statistics.wrong.dates");
|
||||
}
|
||||
|
||||
$activetab = 0;
|
||||
$link = connect();
|
||||
if ($statisticstype == 'bydate') {
|
||||
$page['reportByDate'] = select_multi_assoc("select DATE(t.dtmcreated) as date, COUNT(distinct t.threadid) as threads, SUM(m.ikind = $kind_agent) as agents, SUM(m.ikind = $kind_user) as users, ROUND(AVG(unix_timestamp(t.dtmchatstarted)-unix_timestamp(t.dtmcreated)),1) as avgwaitingtime, ROUND(AVG(tmp.lastmsgtime - unix_timestamp(t.dtmchatstarted)),1) as avgchattime " .
|
||||
"from ${mysqlprefix}chatmessage m, ${mysqlprefix}chatthread t, (SELECT i.threadid, unix_timestamp(MAX(i.dtmcreated)) AS lastmsgtime FROM ${mysqlprefix}chatmessage i WHERE (ikind = $kind_user OR ikind = $kind_agent) GROUP BY i.threadid) tmp " .
|
||||
"where m.threadid = t.threadid AND tmp.threadid = t.threadid AND unix_timestamp(t.dtmchatstarted) <> 0 AND unix_timestamp(m.dtmcreated) >= $start AND unix_timestamp(m.dtmcreated) < $end group by DATE(m.dtmcreated) order by m.dtmcreated desc", $link);
|
||||
|
||||
$page['reportByDate'] = select_multi_assoc("select DATE(t.dtmcreated) as date, COUNT(distinct t.threadid) as threads, SUM(m.ikind = $kind_agent) as agents, SUM(m.ikind = $kind_user) as users, ROUND(AVG(unix_timestamp(t.dtmchatstarted)-unix_timestamp(t.dtmcreated)),1) as avgwaitingtime, ROUND(AVG(tmp.lastmsgtime - unix_timestamp(t.dtmchatstarted)),1) as avgchattime " .
|
||||
"from ${mysqlprefix}chatmessage m, ${mysqlprefix}chatthread t, (SELECT i.threadid, unix_timestamp(MAX(i.dtmcreated)) AS lastmsgtime FROM ${mysqlprefix}chatmessage i WHERE (ikind = $kind_user OR ikind = $kind_agent) GROUP BY i.threadid) tmp " .
|
||||
"where m.threadid = t.threadid AND tmp.threadid = t.threadid AND unix_timestamp(t.dtmchatstarted) <> 0 AND unix_timestamp(m.dtmcreated) >= $start AND unix_timestamp(m.dtmcreated) < $end group by DATE(m.dtmcreated) order by m.dtmcreated desc", $link);
|
||||
|
||||
$page['reportByDateTotal'] = select_one_row("select DATE(t.dtmcreated) as date, COUNT(distinct t.threadid) as threads, SUM(m.ikind = $kind_agent) as agents, SUM(m.ikind = $kind_user) as users, ROUND(AVG(unix_timestamp(t.dtmchatstarted)-unix_timestamp(t.dtmcreated)),1) as avgwaitingtime, ROUND(AVG(tmp.lastmsgtime - unix_timestamp(t.dtmchatstarted)),1) as avgchattime " .
|
||||
"from ${mysqlprefix}chatmessage m, ${mysqlprefix}chatthread t, (SELECT i.threadid, unix_timestamp(MAX(i.dtmcreated)) AS lastmsgtime FROM ${mysqlprefix}chatmessage i WHERE (ikind = $kind_user OR ikind = $kind_agent) GROUP BY i.threadid) tmp " .
|
||||
"where m.threadid = t.threadid AND tmp.threadid = t.threadid AND unix_timestamp(t.dtmchatstarted) <> 0 AND unix_timestamp(m.dtmcreated) >= $start AND unix_timestamp(m.dtmcreated) < $end", $link);
|
||||
|
||||
$page['reportByAgent'] = select_multi_assoc("select vclocalename as name, COUNT(distinct threadid) as threads, SUM(ikind = $kind_agent) as msgs, AVG(CHAR_LENGTH(tmessage)) as avglen " .
|
||||
"from ${mysqlprefix}chatmessage, ${mysqlprefix}chatoperator " .
|
||||
"where agentId = operatorid AND unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by operatorid", $link);
|
||||
|
||||
$page['reportByPage'] = select_multi_assoc("SELECT COUNT(DISTINCT p.pageid) as visittimes, p.address, COUNT(DISTINCT t.threadid) as chattimes " .
|
||||
"FROM ${mysqlprefix}visitedpagestatistics p LEFT OUTER JOIN ${mysqlprefix}chatthread t ON (p.address = t.referer AND DATE(p.visittime) = DATE(t.dtmcreated)) " .
|
||||
"WHERE unix_timestamp(p.visittime) >= $start AND unix_timestamp(p.visittime) < $end GROUP BY p.address", $link);
|
||||
|
||||
$page['reportByDateTotal'] = select_one_row("select DATE(t.dtmcreated) as date, COUNT(distinct t.threadid) as threads, SUM(m.ikind = $kind_agent) as agents, SUM(m.ikind = $kind_user) as users, ROUND(AVG(unix_timestamp(t.dtmchatstarted)-unix_timestamp(t.dtmcreated)),1) as avgwaitingtime, ROUND(AVG(tmp.lastmsgtime - unix_timestamp(t.dtmchatstarted)),1) as avgchattime " .
|
||||
"from ${mysqlprefix}chatmessage m, ${mysqlprefix}chatthread t, (SELECT i.threadid, unix_timestamp(MAX(i.dtmcreated)) AS lastmsgtime FROM ${mysqlprefix}chatmessage i WHERE (ikind = $kind_user OR ikind = $kind_agent) GROUP BY i.threadid) tmp " .
|
||||
"where m.threadid = t.threadid AND tmp.threadid = t.threadid AND unix_timestamp(t.dtmchatstarted) <> 0 AND unix_timestamp(m.dtmcreated) >= $start AND unix_timestamp(m.dtmcreated) < $end", $link);
|
||||
$activetab = 0;
|
||||
} elseif($statisticstype == 'byagent') {
|
||||
$page['reportByAgent'] = select_multi_assoc("select vclocalename as name, COUNT(distinct threadid) as threads, SUM(ikind = $kind_agent) as msgs, AVG(CHAR_LENGTH(tmessage)) as avglen " .
|
||||
"from ${mysqlprefix}chatmessage, ${mysqlprefix}chatoperator " .
|
||||
"where agentId = operatorid AND unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by operatorid", $link);
|
||||
$activetab = 1;
|
||||
} elseif($statisticstype == 'bypage') {
|
||||
$page['reportByPage'] = select_multi_assoc("SELECT COUNT(DISTINCT p.pageid) as visittimes, p.address, COUNT(DISTINCT t.threadid) as chattimes " .
|
||||
"FROM ${mysqlprefix}visitedpagestatistics p LEFT OUTER JOIN ${mysqlprefix}chatthread t ON (p.address = t.referer AND DATE(p.visittime) = DATE(t.dtmcreated)) " .
|
||||
"WHERE unix_timestamp(p.visittime) >= $start AND unix_timestamp(p.visittime) < $end GROUP BY p.address", $link);
|
||||
$activetab = 2;
|
||||
}
|
||||
$page['showresults'] = count($errors) == 0;
|
||||
|
||||
close_connection($link);
|
||||
|
||||
prepare_menu($operator);
|
||||
setup_statistics_tabs($activetab);
|
||||
start_html_output();
|
||||
require('../view/statistics.php');
|
||||
?>
|
||||
|
@ -19,7 +19,9 @@
|
||||
* Evgeny Gryaznov - initial API and implementation
|
||||
*/
|
||||
|
||||
require_once("inc_tabbar.php");
|
||||
require_once("inc_menu.php");
|
||||
|
||||
$page['title'] = getlocal("statistics.title");
|
||||
$page['menuid'] = "statistics";
|
||||
|
||||
@ -34,8 +36,11 @@ require_once('inc_errors.php');
|
||||
?>
|
||||
|
||||
<form name="statisticsForm" method="get" action="<?php echo $webimroot ?>/operator/statistics.php">
|
||||
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
||||
<input type="hidden" name="type" value="<?php echo $page['type'] ?>" />
|
||||
|
||||
<?php print_tabbar(); ?>
|
||||
|
||||
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
||||
|
||||
<div class="fieldForm">
|
||||
<div class="field">
|
||||
@ -66,6 +71,7 @@ require_once('inc_errors.php');
|
||||
|
||||
<?php if( $page['showresults'] ) { ?>
|
||||
|
||||
<?php if($page['showbydate']) { ?>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
@ -117,7 +123,9 @@ require_once('inc_errors.php');
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
<?php if($page['showbyagent']) { ?>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
@ -153,7 +161,9 @@ require_once('inc_errors.php');
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
<?php if($page['showbypage']) { ?>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
@ -186,6 +196,7 @@ require_once('inc_errors.php');
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user