Commit 2f07ae7b authored by tbrehm's avatar tbrehm
Browse files

Added mailbox traffic statistics to the interface.

parent ace9ddcd
......@@ -38,8 +38,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class listform_actions {
private $id;
private $idx_key;
private $DataRowColor;
public $idx_key;
public $DataRowColor;
public $SQLExtWhere = '';
public $SQLOrderBy = '';
......@@ -82,7 +82,7 @@ class listform_actions {
}
private function prepareDataRow($rec)
public function prepareDataRow($rec)
{
global $app;
......
<?php
$wb["list_head_txt"] = 'Mail traffic statistic';
$wb["email_txt"] = 'Email';
$wb["this_month_txt"] = 'This month';
$wb["last_month_txt"] = 'Last month';
$wb["this_year_txt"] = 'This year';
$wb["last_year_txt"] = 'Last year';
$wb["page_txt"] = 'Page';
$wb["page_of_txt"] = 'of';
$wb["page_next_txt"] = 'Next';
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
?>
\ No newline at end of file
......@@ -80,7 +80,19 @@ $module['nav'][] = array( 'title' => 'Fetchmail',
'open' => 1,
'items' => $items);
//**** Statistics menu
$items = array();
$items[] = array( 'title' => 'Mailboxes',
'target' => 'content',
'link' => 'mail/mail_user_stats.php');
$module['nav'][] = array( 'title' => 'Statistics',
'open' => 1,
'items' => $items);
//**** Global filters menu
$items = array();
if($_SESSION['s']['user']['typ'] == 'admin') {
......
<?php
/*
Datatypes:
- INTEGER
- DOUBLE
- CURRENCY
- VARCHAR
- TEXT
- DATE
*/
// Name of the list
$liste["name"] = "mail_user_stats";
// Database table
$liste["table"] = "mail_user";
// Index index field of the database table
$liste["table_idx"] = "mailuser_id";
// Search Field Prefix
$liste["search_prefix"] = "search_";
// Records per page
$liste["records_per_page"] = 15;
// Script File of the list
$liste["file"] = "mail_user_stats.php";
// Script file of the edit form
$liste["edit_file"] = "mail_user_edit.php";
// Script File of the delete script
$liste["delete_file"] = "mail_user_del.php";
// Paging Template
$liste["paging_tpl"] = "templates/paging.tpl.htm";
// Enable auth
$liste["auth"] = "yes";
/*****************************************************
* Suchfelder
*****************************************************/
$liste["item"][] = array( 'field' => "email",
'datatype' => "VARCHAR",
'formtype' => "TEXT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'width' => "",
'value' => "");
?>
\ No newline at end of file
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/mail_user_stats.list.php";
/******************************************
* End Form configuration
******************************************/
// Checking module permissions
if(!stristr($_SESSION["s"]["user"]["modules"],'mail')) {
header("Location: ../index.php");
exit;
}
$app->load('listform_actions');
class list_action extends listform_actions {
function prepareDataRow($rec)
{
global $app;
$rec = $app->listform->decode($rec);
//* Alternating datarow colors
$this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
$rec['bgcolor'] = $this->DataRowColor;
//* Set the statistics colums
//** Traffic of the current month
$tmp_date = date('Y-m');
$tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month = '$tmp_date'");
$rec['this_month'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
//** Traffic of the current year
$tmp_date = date('Y');
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month like '$tmp_date%'");
$rec['this_year'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
//** Traffic of the last month
$tmp_date = date('Y-m',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
$tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month = '$tmp_date'");
$rec['last_month'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
//** Traffic of the last year
$tmp_date = date('Y',mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month like '$tmp_date%'");
$rec['last_year'] = number_format(intval($tmp_rec['t'])/1024, 0, '.', ' ');
//* The variable "id" contains always the index variable
$rec['id'] = $rec[$this->idx_key];
return $rec;
}
}
$list = new list_action;
$list->onLoad();
?>
\ No newline at end of file
<div class="frmTextHead"><tmpl_var name="list_head_txt"></div><br />
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="listTable">
<tr>
<td class="tblHead"><tmpl_var name="email_txt"></td>
<td class="tblHead"><tmpl_var name="this_month_txt"></td>
<td class="tblHead"><tmpl_var name="last_month_txt"></td>
<td class="tblHead"><tmpl_var name="this_year_txt"></td>
<td class="tblHead"><tmpl_var name="last_year_txt"></td>
<td class="tblHead">&nbsp;</td>
</tr>
<tr>
<td class="frmText11"><input type="text" name="search_email" value="{tmpl_var name='search_email'}" class="text" /></td>
<td class="frmText11">&nbsp;</td>
<td class="frmText11">&nbsp;</td>
<td class="frmText11">&nbsp;</td>
<td class="frmText11">&nbsp;</td>
<td class="frmText11" align="right"><input name="Filter" type="button" id="Filter" value="{tmpl_var name="filter_txt"}" class="button" onClick="submitForm('pageForm','mail/mail_user_stats.php');"><div class="buttonEnding"></div></td>
</tr>
<tmpl_loop name="records">
<tr bgcolor="{tmpl_var name="bgcolor"}">
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="email"}</a></td>
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="this_month"} KB</a></td>
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="last_month"} KB</a></td>
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="this_year"} KB</a></td>
<td class="frmText11"><a href="#" onClick="loadContent('mail/mail_user_edit.php?id={tmpl_var name='id'}');" class="frmText11">{tmpl_var name="last_year"} KB</a></td>
<td class="frmText11" align="right">&nbsp;</td>
</tr>
</tmpl_loop>
<tr>
<td colspan="6" height="40" align="center" class="tblFooter"><tmpl_var name="paging"></td>
</tr>
</table>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment