statistics

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@428 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2009-03-22 02:22:34 +00:00
parent 22e616e79b
commit 76affc9b4b
9 changed files with 302 additions and 5 deletions

View File

@ -388,7 +388,17 @@ input.formauth {
padding-left: 4px; padding-left: 4px;
} }
table.list, table.translate { .tabletitle {
background: url(images/graydot.gif) repeat-x left bottom;
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 1.4em;
margin: 10px 0px 20px;
padding-bottom: 10px;
color: #1D485E;
font-weight: bold;
}
table.list, table.translate, table.statistics {
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
background: #fff; background: #fff;
width: 100%; width: 100%;
@ -396,15 +406,17 @@ table.list, table.translate {
text-align: left; text-align: left;
} }
table.list th, table.translate th { table.list th, table.translate th, table.statistics th {
font-size: 1.2em; font-size: 1.2em;
font-weight: normal; font-weight: normal;
color: #1D485E;
padding: 10px 8px; padding: 10px 8px;
border-bottom: 2px solid #2F7598; border-bottom: 2px solid #2F7598;
} }
table.list td { table.list th, table.translate th { color: #1D485E; }
table.statistics th { color: #2F7598; }
table.list td, table.statistics td {
color: #2f7599; color: #2f7599;
padding: 10px 8px; padding: 10px 8px;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
@ -423,7 +435,7 @@ table.list td a.man {
padding-left: 15px; padding-left: 15px;
} }
table.list tbody tr:hover td, table.list tbody tr:hover td a { table.list tbody tr:hover td, table.list tbody tr:hover td a, table.statistics tbody tr:hover td {
color: #1D485E; color: #1D485E;
} }
@ -508,6 +520,13 @@ table.awaiting td.visitor {
padding-right:5px; padding-right:5px;
} }
.searchctrl {
float: left;
margin:7px 20px 5px 0px;
padding-right:5px;
display: inline;
}
#searchtext input { #searchtext input {
width: 100%; width: 100%;
margin: 0px; margin: 0px;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -221,6 +221,7 @@ function prepare_menu($operator,$hasright=true) {
loadsettings(); loadsettings();
$page['showban'] = $settings['enableban'] == "1"; $page['showban'] = $settings['enableban'] == "1";
$page['showdep'] = $settings['enabledepartments'] == "1"; $page['showdep'] = $settings['enabledepartments'] == "1";
$page['showstat'] = true; //$settings['enablestatistics'] == "1";
$page['showadmin'] = is_capable($can_administrate, $operator); $page['showadmin'] = is_capable($can_administrate, $operator);
} }
} }

View File

@ -295,6 +295,18 @@ permission.takeover=Take over chat thread
permission.viewthreads=View another operator's chat thread permission.viewthreads=View another operator's chat thread
permissions.intro=Here you can control operator's permissions permissions.intro=Here you can control operator's permissions
permissions.title=Permissions permissions.title=Permissions
report.bydate.1=Date
report.bydate.2=Chat threads
report.bydate.3=Messages from operators
report.bydate.4=Messages from visitors
report.bydate.title=Usage statistics for each date
report.byoperator.1=Operator
report.byoperator.2=Chat Threads
report.byoperator.3=Messages
report.byoperator.4=Average message length (in chars)
report.byoperator.title=Threads by operator
report.no_items=Not enough data
report.total=Total:
right.administration=Administration right.administration=Administration
right.main=Main right.main=Main
right.other=Other right.other=Other
@ -330,6 +342,12 @@ settings.usernamepattern=Visitor's identifier
settings.wrong.email=Enter proper email address settings.wrong.email=Enter proper email address
site.title=openwebim.org site.title=openwebim.org
site.url=http://openwebim.org site.url=http://openwebim.org
statistics.dates=Select dates
statistics.description=Daily usage reports
statistics.from=From:
statistics.till=Till:
statistics.title=Statistics
statistics.wrong.dates=You have selected From date after Till date
tag.pagination.info=Page {0} of {1}, {2}-{3} from {4} tag.pagination.info=Page {0} of {1}, {2}-{3} from {4}
tag.pagination.next=next tag.pagination.next=next
tag.pagination.no_items.elements=No elements tag.pagination.no_items.elements=No elements

View File

@ -277,6 +277,18 @@ permissions.title=
right.administration=Управление right.administration=Управление
right.main=Посетители right.main=Посетители
right.other=Остальное right.other=Остальное
report.bydate.1=Дата
report.bydate.2=Диалогов
report.bydate.3=Сообщений операторов
report.bydate.4=Сообщений посетителей
report.bydate.title=Использование мессенджера по дням
report.byoperator.1=Оператор
report.byoperator.2=Диалогов
report.byoperator.3=Сообщений
report.byoperator.4=Средняя длина сообщения (в символах)
report.byoperator.title=Статистика по операторам
report.no_items=Мало данных
report.total=Итого:
settings.chat.title.description=Например, название отдела вашей компании settings.chat.title.description=Например, название отдела вашей компании
settings.chat.title=Заголовок в чат окне settings.chat.title=Заголовок в чат окне
settings.chatstyle.description=Предпросмотр всех страниц каждого стиля доступен <a href="preview.php">здесь</a> settings.chatstyle.description=Предпросмотр всех страниц каждого стиля доступен <a href="preview.php">здесь</a>
@ -307,6 +319,12 @@ settings.usernamepattern=
settings.wrong.email=Введите правильный адрес электронной почты settings.wrong.email=Введите правильный адрес электронной почты
site.title=openwebim.org site.title=openwebim.org
site.url=http://openwebim.org site.url=http://openwebim.org
statistics.dates=Выберите даты
statistics.description=Различные отчеты по посетителям и использованию мессенджера
statistics.from=С:
statistics.till=По:
statistics.title=Статистика
statistics.wrong.dates=Вы выбрали дату для начала отчета после даты конца
tag.pagination.info=Страница {0} из {1}, показаны {2}-{3} из {4} tag.pagination.info=Страница {0} из {1}, показаны {2}-{3} из {4}
tag.pagination.next=следующая tag.pagination.next=следующая
tag.pagination.no_items.elements=Нет элементов для отображения. tag.pagination.no_items.elements=Нет элементов для отображения.

View File

@ -0,0 +1,80 @@
<?php
/*
* This file is part of Web Instant Messenger project.
*
* Copyright (c) 2005-2009 Web Messenger Community
* All rights reserved. This program and the accompanying materials
* are made available under 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
*
* Contributors:
* Evgeny Gryaznov - initial API and implementation
*/
require_once('../libs/common.php');
require_once('../libs/chat.php');
require_once('../libs/operator.php');
$operator = check_login();
$page = array();
$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;
$errors = array();
if(isset($_GET['startday'])) {
$startday = verifyparam("startday","/^\d+$/");
$startmonth = verifyparam("startmonth","/^\d{2}.\d{2}$/");
$endday = verifyparam("endday","/^\d+$/");
$endmonth = verifyparam("endmonth","/^\d{2}.\d{2}$/");
$start = get_form_date($startday,$startmonth);
$end = get_form_date($endday, $endmonth)+24*60*60;
} else {
$curr = getdate(time());
if( $curr['mday'] < 7 ) {
// previous month
if($curr['mon'] == 1) {
$month = 12;
$year = $curr['year']-1;
} else {
$month = $curr['mon']-1;
$year = $curr['year'];
}
$start = mktime(0,0,0,$month,1,$year);
$end = mktime(0,0,0,$month, date("t",$start),$year)+24*60*60;
} else {
$start = mktime(0,0,0,$curr['mon'],1,$curr['year']);
$end = time()+24*60*60;
}
}
set_form_date($start, "start");
set_form_date($end-24*60*60, "end");
if( $start > $end ) {
$errors[] = getlocal("statistics.wrong.dates");
}
$link = connect();
$page['reportByDate'] = select_multi_assoc("select DATE(dtmcreated) as date, COUNT(distinct threadid) as threads, SUM(chatmessage.ikind = $kind_agent) as agents, SUM(chatmessage.ikind = $kind_user) as users ".
"from chatmessage where unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by DATE(dtmcreated) order by dtmcreated desc", $link);
$page['reportByDateTotal'] = select_one_row("select COUNT(distinct threadid) as threads, SUM(chatmessage.ikind = $kind_agent) as agents, SUM(chatmessage.ikind = $kind_user) as users ".
"from chatmessage where unix_timestamp(dtmcreated) >= $start AND unix_timestamp(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 chatmessage, chatoperator ".
"where agentId = operatorid AND unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by operatorid", $link);
$page['showresults'] = count($errors) == 0;
mysql_close($link);
prepare_menu($operator);
start_html_output();
require('../view/statistics.php');
?>

View File

@ -15,6 +15,9 @@ function tpl_menu() { global $page, $webimroot, $errors;
<li<?php menuli("main")?>><a href='<?php echo $webimroot ?>/operator/index.php'><?php echo getlocal('topMenu.main') ?></a></li> <li<?php menuli("main")?>><a href='<?php echo $webimroot ?>/operator/index.php'><?php echo getlocal('topMenu.main') ?></a></li>
<li<?php menuli("users")?>><a href='<?php echo $webimroot ?>/operator/users.php'><?php echo getlocal('topMenu.users') ?></a></li> <li<?php menuli("users")?>><a href='<?php echo $webimroot ?>/operator/users.php'><?php echo getlocal('topMenu.users') ?></a></li>
<li<?php menuli("history")?>><a href='<?php echo $webimroot ?>/operator/history.php'><?php echo getlocal('page_analysis.search.title') ?></a></li> <li<?php menuli("history")?>><a href='<?php echo $webimroot ?>/operator/history.php'><?php echo getlocal('page_analysis.search.title') ?></a></li>
<?php if(isset($page['showstat']) && $page['showstat']) { ?>
<li<?php menuli("statistics")?>><a href='<?php echo $webimroot ?>/operator/statistics.php'><?php echo getlocal('statistics.title') ?></a></li>
<?php } ?>
<?php if(isset($page['showban']) && $page['showban']) { ?> <?php if(isset($page['showban']) && $page['showban']) { ?>
<li<?php menuli("blocked")?>><a href='<?php echo $webimroot ?>/operator/blocked.php'><?php echo getlocal('menu.blocked') ?></a></li> <li<?php menuli("blocked")?>><a href='<?php echo $webimroot ?>/operator/blocked.php'><?php echo getlocal('menu.blocked') ?></a></li>
<?php } ?> <?php } ?>

View File

@ -59,6 +59,16 @@ function tpl_content() { global $page, $webimroot, $current_locale, $menuItemsCo
$menuItemsCount = 2; $menuItemsCount = 2;
if( $page['showban'] ) { if( $page['showban'] ) {
?> ?>
<?php if($page['showstat']) { ?>
<td class="dashitem">
<img src="/webim/images/dash/stat.gif" alt=""/>
<a href='<?php echo $webimroot ?>/operator/statistics.php'>
<?php echo getlocal('statistics.title') ?></a>
<?php echo getlocal('statistics.description') ?>
</td>
<?php menuseparator(); ?>
<?php } ?>
<td class="dashitem"> <td class="dashitem">
<img src="/webim/images/dash/blocked.gif" alt=""/> <img src="/webim/images/dash/blocked.gif" alt=""/>

View File

@ -0,0 +1,148 @@
<?php
/*
* This file is part of Web Instant Messenger project.
*
* Copyright (c) 2005-2009 Web Messenger Community
* All rights reserved. This program and the accompanying materials
* are made available under 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
*
* Contributors:
* Evgeny Gryaznov - initial API and implementation
*/
require_once("inc_menu.php");
$page['title'] = getlocal("statistics.title");
$page['menuid'] = "statistics";
function tpl_content() { global $page, $webimroot, $errors;
?>
<?php echo getlocal("statistics.description") ?>
<br />
<br />
<?php
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">
<div class="fieldForm">
<div class="field">
<div class="flabel"><?php echo getlocal("statistics.dates") ?></div>
<div class="fvaluenodesc">
<div class="searchctrl">
<?php echo getlocal("statistics.from") ?>
<select name="startday"><?php foreach($page['availableDays'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("startday") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
<select name="startmonth"><?php foreach($page['availableMonth'] as $k => $v) { echo "<option value=\"".$k."\"".($k == form_value("startmonth") ? " selected=\"selected\"" : "").">".$v."</option>"; } ?></select>
</div>
<div class="searchctrl">
<?php echo getlocal("statistics.till") ?>
<select name="endday"><?php foreach($page['availableDays'] as $k) { echo "<option value=\"".$k."\"".($k == form_value("endday") ? " selected=\"selected\"" : "").">".$k."</option>"; } ?></select>
<select name="endmonth"><?php foreach($page['availableMonth'] as $k => $v) { echo "<option value=\"".$k."\"".($k == form_value("endmonth") ? " selected=\"selected\"" : "").">".$v."</option>"; } ?></select>
</div>
<div id="searchbutton">
<input type="image" name="search" src='<?php echo $webimroot.getlocal("image.button.search") ?>' alt='<?php echo getlocal("button.search") ?>'/>
</div>
</div>
<br clear="all"/>
</div>
</div>
</div><div class="formbottom"><div class="formbottomi"></div></div></div>
</form>
<?php if( $page['showresults'] ) { ?>
<br/>
<br/>
<div class="tabletitle">
<?php echo getlocal("report.bydate.title") ?>
</div>
<table class="statistics">
<thead>
<tr><th>
<?php echo getlocal("report.bydate.1") ?>
</th><th>
<?php echo getlocal("report.bydate.2") ?>
</th><th>
<?php echo getlocal("report.bydate.3") ?>
</th><th>
<?php echo getlocal("report.bydate.4") ?>
</th></tr>
</thead>
<tbody>
<?php if( $page['reportByDate'] ) { ?>
<?php foreach( $page['reportByDate'] as $row ) { ?>
<tr>
<td><?php echo $row['date'] ?></td>
<td><?php echo $row['threads'] ?></td>
<td><?php echo $row['agents'] ?></td>
<td><?php echo $row['users'] ?></td>
</tr>
<?php } ?>
<tr>
<td><b><?php echo getlocal("report.total") ?></b></td>
<td><?php echo $page['reportByDateTotal']['threads'] ?></td>
<td><?php echo $page['reportByDateTotal']['agents'] ?></td>
<td><?php echo $page['reportByDateTotal']['users'] ?></td>
</tr>
<?php } else { ?>
<tr>
<td colspan="4">
<?php echo getlocal("report.no_items") ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br/>
<br/>
<div class="tabletitle"><?php echo getlocal("report.byoperator.title") ?></div>
<table class="statistics">
<thead>
<tr><th>
<?php echo getlocal("report.byoperator.1") ?>
</th><th>
<?php echo getlocal("report.byoperator.2") ?>
</th><th>
<?php echo getlocal("report.byoperator.3") ?>
</th><th>
<?php echo getlocal("report.byoperator.4") ?>
</th></tr>
</thead>
<tbody>
<?php if( $page['reportByAgent'] ) { ?>
<?php foreach( $page['reportByAgent'] as $row ) { ?>
<tr>
<td><?php echo topage(htmlspecialchars($row['name'])) ?></td>
<td><?php echo $row['threads'] ?></td>
<td><?php echo $row['msgs'] ?></td>
<td><?php echo $row['avglen'] ?></td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td colspan="4">
<?php echo getlocal("report.no_items") ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
<?php
} /* content */
require_once('inc_main.php');
?>