/asterisk-stats/trunk/telbook.php |
---|
File deleted |
/asterisk-stats/trunk/telbook_categories.php |
---|
File deleted |
/asterisk-stats/trunk/telbook_details.php |
---|
0,0 → 1,81 |
<?php |
include_once('includes/common.php'); |
Prolog(); |
$id = $_GET['id']; |
# person and entries |
$person = array(); |
$table = new Table(array('Type', 'Number', 'Comment')); |
$table->set_table_class('telbook list'); |
$entry_count = 0; |
function add_entry_inputs($table, $entry_count, $entry_title, $entry_value, $entry_comment) |
{ |
++$entry_count; |
$table->newrow(); |
$table->addcell(array('html' => display_input( |
'text', 'entry_title-' . $entry_count, $entry_title))); |
$table->addcell(array('html' => display_input( |
'text', 'entry_value-' . $entry_count, $entry_value))); |
$table->addcell(array('html' => display_input( |
'text', 'entry_comment-' . $entry_count, $entry_comment))); |
return $entry_count; |
} |
if($id) { |
$db->query_params("select person_id, person_name, person_comment, person_category," |
. " entry_title, entry_value, entry_comment" |
. " from telbook_persons p" |
. " left join telbook_entries e on p.person_id=e.entry_person" |
. " where person_id=$1", array($id)); |
$first_line = true; |
while($line = $db->fetch_row()) { |
if($first_line) { |
$person['PERSON_ID'] = $line['person_id']; |
$person['PERSON_NAME'] = $line['person_name']; |
$person['PERSON_COMMENT'] = $line['person_comment']; |
$person['PERSON_CATEGORY'] = $line['person_category']; |
$first_line = false; |
} |
if($line['entry_value']) { |
$entry_count = add_entry_inputs($table, $entry_count, |
$line['entry_title'], $line['entry_value'], $line['entry_comment']); |
} |
} |
} |
else { |
$person['PERSON_ID'] = ''; |
$person['PERSON_NAME'] = ''; |
$person['PERSON_COMMENT'] = ''; |
$person['PERSON_CATEGORY'] = ''; |
} |
$g_display->add_variables($person); |
for($i = 0; $i < 5; ++$i) { |
$entry_count = add_entry_inputs($table, $entry_count, '', '', ''); |
} |
# categories select box |
$db->query("select category_id, category_name from telbook_categories order by category_name"); |
$categories_list = "\n\t\t\t\t<option value=''>(none)</option>"; |
while($line = $db->fetch_row()) { |
$categories_list .= "\n\t\t\t\t<option value='" |
. htmlspecialchars($line['category_id']) . "'" |
. ($line['category_id'] == $person['PERSON_CATEGORY'] ? " selected" : "") |
. ">" . htmlspecialchars($line['category_name']) . "</option>"; |
} |
$g_display->add_html_variables(array('CATEGORIES' => $categories_list)); |
# show |
$g_display->add_template('telbook_details_begin'); |
$g_display->add_html_text($table->build()); |
$g_display->add_template('telbook_details_end'); |
Epilog(); |
?> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/telbook_categories_update.php |
---|
0,0 → 1,37 |
<?php |
include_once('includes/common.php'); |
Prolog(); |
if(array_key_exists('delete', $_POST)) { |
$id = $_POST['id']; |
$db->query_params("delete from telbook_categories where category_id=$1", array($id)); |
header("Location: telbook_categories_list.php"); |
$g_display->add_text('Information deleted successfully'); |
} |
else if(array_key_exists('update', $_POST)) { |
$id = $_POST['id']; |
$category_name = $_POST['category_name']; |
$category_comment = $_POST['category_comment']; |
$category_export_key = ($_POST['category_export_key'] ? $_POST['category_export_key'] : NULL); |
if($id) { |
$db->query_params("update telbook_categories set" |
. " category_name=$2, category_comment=$3, category_export_key=$4" |
. " where category_id=$1", |
array($id, $category_name, $category_comment, $category_export_key)); |
} |
else { |
$db->query_params("insert into telbook_categories" |
. " (category_name, category_comment, category_export_key) values ($1, $2, $3)", |
array($category_name, $category_comment, $category_export_key)); |
} |
header("Location: telbook_categories_list.php"); |
$g_display->add_text('Information saved successfully'); |
} |
Epilog(); |
?> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/index.php |
---|
1,32 → 1,38 |
<?php |
#################################################### |
# AstWeb - Asterisk PBX Dynamic config environment # |
# # |
# Written by: Jamie Carl # |
# jazz@funkynerd.com # |
# # |
# Copyright (C) 2006 Achieve Corp # |
# # |
# Licence: This software is licenced under the # |
# GNU/GPL. Please see licence.txt for # |
# more information. # |
#################################################### |
include_once('includes/common.php'); |
Prolog(); |
$display = new template_handler('template'); |
$display->add_template('header'); |
include('includes/menu.php'); |
function add_summary($count_name, $dur_name, $interval, $diff = NULL) |
{ |
global $db, $g_display; |
switch($_GET['m']) { |
case 'cdr': |
include('includes/cdr.php'); |
break; |
default: |
include('includes/summary.php'); |
$query = "select count(acctid), sum(billsec) from cdr where" . BaseQuery() |
. ($interval ? " and date_trunc('" . $interval . "', calldate)" |
. ($diff ? " + interval '$diff $interval'" : "") . " = date_trunc('" |
. $interval . "', current_date)" : ""); |
$db->query($query); |
$db->fetch_row_idx(); |
$g_display->add_variables(array($count_name => $db->get_field(0), |
$dur_name => FormatDuration($db->get_field(1)))); |
} |
$display->add_template('footer'); |
echo $display; |
# active calls |
$db->query("select count(acctid), sum(extract(epoch from date_trunc('second',current_timestamp-linkdate)))" |
. " from activecalls where" . BaseQuery() . " and duration is null"); |
$db->fetch_row_idx(); |
$g_display->add_variables(array('CS_ACTIVE' => $db->get_field(0), |
'CS_ACTIVE_DUR' => FormatDuration($db->get_field(1)))); |
add_summary('CS_TODAY', 'CS_TODAY_DUR', 'day'); |
add_summary('CS_WEEK', 'CS_WEEK_DUR', 'week'); |
add_summary('CS_LAST_WEEK', 'CS_LAST_WEEK_DUR', 'week', 1); |
add_summary('CS_MONTH', 'CS_MONTH_DUR', 'month'); |
add_summary('CS_YEAR', 'CS_YEAR_DUR', 'year'); |
add_summary('CS_TOTAL', 'CS_TOTAL_DUR', null); |
$g_display->add_template('summary'); |
Epilog(); |
?> |
/asterisk-stats/trunk/telbook_categories_details.php |
---|
0,0 → 1,33 |
<?php |
include_once('includes/common.php'); |
Prolog(); |
$id = $_GET['id']; |
$category = array(); |
if($id) { |
$db->query_params("select category_id, category_name, category_comment, category_export_key" |
. " from telbook_categories" |
. " where category_id=$1", array($id)); |
if($line = $db->fetch_row()) { |
$category['CATEGORY_ID'] = $line['category_id']; |
$category['CATEGORY_NAME'] = $line['category_name']; |
$category['CATEGORY_COMMENT'] = $line['category_comment']; |
$category['CATEGORY_EXPORT_KEY'] = $line['category_export_key']; |
} |
} |
else { |
$category['CATEGORY_ID'] = ''; |
$category['CATEGORY_NAME'] = ''; |
$category['CATEGORY_COMMENT'] = ''; |
$category['CATEGORY_EXPORT_KEY'] = ''; |
} |
$g_display->add_variables($category); |
$g_display->add_template('telbook_category_edit'); |
Epilog(); |
?> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/cdr_details.php |
---|
0,0 → 1,60 |
<?php |
include_once('includes/common.php'); |
Prolog(); |
if(array_key_exists('active', $_GET)) { |
$db->query_params("select acctid, calldate, linkdate, clid, src, dst, dcontext," |
. " channel, dstchannel, lastapp, lastdata," |
. " extract(epoch from date_trunc('second',current_timestamp-calldate)) as duration," |
. " extract(epoch from date_trunc('second',current_timestamp-linkdate)) as billsec," |
. " disposition, amaflags, accountcode, uniqueid, userfield," |
. " p1.person_name as src_name, e1.entry_title as src_title," |
. " p2.person_name as dst_name, e2.entry_title as dst_title" |
. " from activecalls r" |
. " left join telbook_entries e1 on r.src=e1.entry_value" |
. " left join telbook_persons p1 on p1.person_id=e1.entry_person" |
. " left join telbook_entries e2 on r.dst=e2.entry_value" |
. " left join telbook_persons p2 on p2.person_id=e2.entry_person" |
. " where acctid=$1 and duration is null", array($_GET['active'])); |
} |
elseif(array_key_exists('detail', $_GET)) { |
$cdr_detail = array(); |
$db->query_params("select r.*," |
. " p1.person_name as src_name, e1.entry_title as src_title," |
. " p2.person_name as dst_name, e2.entry_title as dst_title" |
. " from cdr r" |
. " left join telbook_entries e1 on r.src=e1.entry_value" |
. " left join telbook_persons p1 on p1.person_id=e1.entry_person" |
. " left join telbook_entries e2 on r.dst=e2.entry_value" |
. " left join telbook_persons p2 on p2.person_id=e2.entry_person" |
. " where acctid=$1", array($_GET['detail'])); |
} |
else { |
die("No ID to search"); |
} |
$cdr_detail = array(); |
$detail = $db->fetch_row(); |
for($i = 0; $i < $db->num_fields(); ++$i) { |
$col = $db->get_field_name($i); |
$cdr_detail['CDR_'.strtoupper($col)] = $detail[$col]; |
} |
$cdr_detail['CDR_STATUS'] = ($detail ? (array_key_exists('active', $_GET) |
? 'ACTIVE' : 'DONE') : 'NOT FOUND'); |
$cdr_detail['CDR_CALLDATE_F'] = FormatDateTime($detail['calldate']); |
$cdr_detail['CDR_DURATION_F'] = FormatDuration($detail['duration']); |
$cdr_detail['CDR_BILLSEC_F'] = FormatDuration($detail['billsec']); |
$cdr_detail['CDR_SRC_PERSON'] = $detail['src_name'] . ($detail['src_title'] ? '/' |
. $detail['src_title'] : ''); |
$cdr_detail['CDR_DST_PERSON'] = $detail['dst_name'] . ($detail['dst_title'] ? '/' |
. $detail['dst_title'] : ''); |
$g_display->add_variables($cdr_detail); |
$g_display->add_template('cdr_detail'); |
Epilog(); |
?> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/includes/cdr.php |
---|
File deleted |
Property changes: |
Deleted: svn:mergeinfo |
/asterisk-stats/trunk/includes/menu.php |
---|
File deleted |
/asterisk-stats/trunk/includes/summary.php |
---|
File deleted |
Property changes: |
Deleted: svn:mergeinfo |
/asterisk-stats/trunk/includes/defaults.php |
---|
1,11 → 1,8 |
<?php |
$tpl_dir = 'templates'; |
$img_dir = 'images'; |
$g_site_title = 'Asterisk Web Interface'; |
$g_site_style = 'style.css'; |
$site_title = 'Asterisk Web Interface'; |
$site_style = 'style.css'; |
$db_type = 'PGSQL'; |
$db_host = 'localhost'; |
$db_user = 'astweb'; |
/asterisk-stats/trunk/includes/common.php |
---|
6,4 → 6,36 |
include_once('includes/functions.php'); |
include_once('includes/db.php'); |
$g_display = NULL; |
function Prolog() |
{ |
global $g_display; |
$g_display = new template_handler('template'); |
$g_display->add_template('header'); |
ShowMenu($g_display); |
} |
function ShowMenu($display) |
{ |
global $g_site_style, $g_site_title; |
$display->add_template('menu'); |
$display->add_variables(array( |
'AST_STYLESHEET' => $g_site_style, |
'AST_SITETITLE' => $g_site_title, |
'AST_DATETIME' => date('Y-m-d H:i:s'), |
)); |
} |
function Epilog() |
{ |
global $g_display; |
$g_display->add_template('footer'); |
echo $g_display; |
} |
?> |
/asterisk-stats/trunk/includes/functions.php |
---|
1,7 → 1,5 |
<?php |
$PHP_SELF = $_SERVER['PHP_SELF']; |
function FormatDuration($seconds) { |
$minutes = $seconds / 60; |
$seconds = $seconds % 60; |
/asterisk-stats/trunk/template/telbook_edit_end.tpl |
---|
File deleted |
/asterisk-stats/trunk/template/telbook_edit_begin.tpl |
---|
File deleted |
/asterisk-stats/trunk/template/cdr.tpl |
---|
File deleted |
/asterisk-stats/trunk/template/telbook_details_begin.tpl |
---|
0,0 → 1,18 |
<form method="POST" action="telbook_update.php"> |
<input type=hidden name=id value="${PERSON_ID}"> |
<table class="telbook edit"> |
<tr> |
<th>Name</th> |
<td><input type=text name=person_name value="${PERSON_NAME}"></td> |
</tr> |
<tr> |
<th>Comment</th> |
<td><textarea name=person_comment>${PERSON_COMMENT}</textarea></td> |
</tr> |
<tr> |
<th>Category</th> |
<td> |
<select name=person_category>${CATEGORIES} |
</select> |
</td> |
</tr> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/template/telbook_details_end.tpl |
---|
0,0 → 1,10 |
<tr class="buttons"> |
<td colspan=2> |
<input type=reset name="reset" value="Reset"> |
<input type=submit name=update value="Update"> |
<input type=submit name=delete value="Delete"> |
</td> |
</tr> |
</table> |
</form> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/template/summary.tpl |
---|
5,39 → 5,39 |
<th>Duration</th> |
</tr> |
<tr> |
<td class="t"><a href=${HREF_CDR_LIST}=active>Active</a></td> |
<td class="d"><a href=${HREF_CDR_LIST}=active>${CS_ACTIVE}</a></td> |
<td class="di"><a href=${HREF_CDR_LIST}=active>${CS_ACTIVE_DUR}</a></td> |
<td class="t"><a href=cdr_list?list=active>Active</a></td> |
<td class="d"><a href=cdr_list?list=active>${CS_ACTIVE}</a></td> |
<td class="di"><a href=cdr_list?list=active>${CS_ACTIVE_DUR}</a></td> |
</tr> |
<tr> |
<td class="t"><a href=${HREF_CDR_LIST}=today>Today</a></td> |
<td class="d"><a href=${HREF_CDR_LIST}=today>${CS_TODAY}</a></td> |
<td class="di"><a href=${HREF_CDR_LIST}=today>${CS_TODAY_DUR}</a></td> |
<td class="t"><a href=cdr_list?list=today>Today</a></td> |
<td class="d"><a href=cdr_list?list=today>${CS_TODAY}</a></td> |
<td class="di"><a href=cdr_list?list=today>${CS_TODAY_DUR}</a></td> |
</tr> |
<tr> |
<td class="t"><a href=${HREF_CDR_LIST}=week>This Week</a></td> |
<td class="d"><a href=${HREF_CDR_LIST}=week>${CS_WEEK}</a></td> |
<td class="di"><a href=${HREF_CDR_LIST}=week>${CS_WEEK_DUR}</a></td> |
<td class="t"><a href=cdr_list?list=week>This Week</a></td> |
<td class="d"><a href=cdr_list?list=week>${CS_WEEK}</a></td> |
<td class="di"><a href=cdr_list?list=week>${CS_WEEK_DUR}</a></td> |
</tr> |
<tr> |
<td class="t"><a href=${HREF_CDR_LIST}=lastweek>Last Week</a></td> |
<td class="d"><a href=${HREF_CDR_LIST}=lastweek>${CS_LAST_WEEK}</a></td> |
<td class="di"><a href=${HREF_CDR_LIST}=lastweek>${CS_LAST_WEEK_DUR}</a></td> |
<td class="t"><a href=cdr_list?list=lastweek>Last Week</a></td> |
<td class="d"><a href=cdr_list?list=lastweek>${CS_LAST_WEEK}</a></td> |
<td class="di"><a href=cdr_list?list=lastweek>${CS_LAST_WEEK_DUR}</a></td> |
</tr> |
<tr> |
<td class="t"><a href=${HREF_CDR_LIST}=month>This Month</a></td> |
<td class="d"><a href=${HREF_CDR_LIST}=month>${CS_MONTH}</a></td> |
<td class="di"><a href=${HREF_CDR_LIST}=month>${CS_MONTH_DUR}</a></td> |
<td class="t"><a href=cdr_list?list=month>This Month</a></td> |
<td class="d"><a href=cdr_list?list=month>${CS_MONTH}</a></td> |
<td class="di"><a href=cdr_list?list=month>${CS_MONTH_DUR}</a></td> |
</tr> |
<tr> |
<td class="t"><a href=${HREF_CDR_LIST}=year>This Year</a></td> |
<td class="d"><a href=${HREF_CDR_LIST}=year>${CS_YEAR}</a></td> |
<td class="di"><a href=${HREF_CDR_LIST}=year>${CS_YEAR_DUR}</a></td> |
<td class="t"><a href=cdr_list?list=year>This Year</a></td> |
<td class="d"><a href=cdr_list?list=year>${CS_YEAR}</a></td> |
<td class="di"><a href=cdr_list?list=year>${CS_YEAR_DUR}</a></td> |
</tr> |
<tr class="total"> |
<td class="t"><a href=${HREF_CDR_LIST}>Total</a></td> |
<td class="d"><a href=${HREF_CDR_LIST}>${CS_TOTAL}</a></td> |
<td class="di"><a href=${HREF_CDR_LIST}>${CS_TOTAL_DUR}</a></td> |
<td class="t"><a href=cdr_list?list>Total</a></td> |
<td class="d"><a href=cdr_list?list>${CS_TOTAL}</a></td> |
<td class="di"><a href=cdr_list?list>${CS_TOTAL_DUR}</a></td> |
</tr> |
</table> |
/asterisk-stats/trunk/template/telbook_category_list_end.tpl |
---|
1,3 → 1,3 |
<p><a href="telbook_categories.php?edit=">New category</a></p> |
<p><a href="telbook.php">Back to tel. book</a></p> |
<p><a href="telbook_categories_details.php?edit=">New category</a></p> |
<p><a href="telbook_list.php">Back to tel. book</a></p> |
/asterisk-stats/trunk/template/cdr_search.tpl |
---|
0,0 → 1,49 |
<form method="GET" action="cdr_list.php"> |
<table class="stat cdr search"> |
<tr> |
<th>After</th> |
<td><input type=text name="after" value="${AST_DATETIME}"></td> |
<td colspan="4" class="desc">Format: YYYY-MM-DD hh:mm:ss</td> |
</tr> |
<tr> |
<th>Before</th> |
<td><input type=text name="before" value=""></td> |
<td colspan="4" class="desc">Format: YYYY-MM-DD hh:mm:ss</td> |
</tr> |
<tr> |
<th>CLI</th> |
<td><input type=text name="clid" value=""></td> |
<td class="radio"><input type=radio name="clidtype" value="1">Exact</td> |
<td class="radio"><input type=radio name="clidtype" value="2">Begins with</td> |
<td class="radio"><input type=radio name="clidtype" value="3">Contains</td> |
<td class="radio"><input type=radio name="clidtype" value="4">Ends with</td> |
</tr> |
<tr> |
<th>Source</th> |
<td><input type=text name="src" value=""></td> |
<td class="radio"><input type=radio name="srctype" value="1">Exact</td> |
<td class="radio"><input type=radio name="srctype" value="2">Begins with</td> |
<td class="radio"><input type=radio name="srctype" value="3">Contains</td> |
<td class="radio"><input type=radio name="srctype" value="4">Ends with</td> |
</tr> |
<tr> |
<th>Desination</th> |
<td><input type=text name="dst" value=""></td> |
<td class="radio"><input type=radio name="dsttype" value="1">Exact</td> |
<td class="radio"><input type=radio name="dsttype" value="2">Begins with</td> |
<td class="radio"><input type=radio name="dsttype" value="3">Contains</td> |
<td class="radio"><input type=radio name="dsttype" value="4">Ends with</td> |
</tr> |
<tr> |
<th>Channel</th> |
<td><input type=text name="channel" value=""></td> |
<td colspan="4" class="desc"> </td> |
</tr> |
<tr class="buttons"> |
<td colspan=5><input type=reset name="reset" value="Reset"></td> |
<td><input type=submit name=s value="Show CDR"></td> |
</tr> |
</table> |
</form> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/template/telbook_list_end.tpl |
---|
1,5 → 1,5 |
<p><a href="telbook.php?edit=">New person</a></p> |
<p><a href="telbook_categories.php">Categories</a></p> |
<p><a href="telbook_details.php">New person</a></p> |
<p><a href="telbook_categories_list.php">Categories</a></p> |
<p>Export into format: |
<ul> |
/asterisk-stats/trunk/template/telbook_category_edit.tpl |
---|
1,4 → 1,4 |
<form method="POST" action="telbook_categories.php"> |
<form method="POST" action="telbook_categories_update.php"> |
<input type=hidden name=id value="${CATEGORY_ID}"> |
<table class="telbook edit"> |
<tr> |
/asterisk-stats/trunk/template/menu.tpl |
---|
1,8 → 1,8 |
<table class="menu"> |
<tr> |
<td><a href=..>Up</a></td> |
<td><a href=${HREF_HOME}>Summary</a></td> |
<td><a href=${HREF_CDR}>Search</a></td> |
<td><a href=${HREF_TELBOOK}>Tel. Book</a></td> |
<td><a href="index.php">Summary</a></td> |
<td><a href="cdr_search.php">Search</a></td> |
<td><a href="telbook_list.php">Tel. Book</a></td> |
</tr> |
</table> |
/asterisk-stats/trunk/telbook_list.php |
---|
0,0 → 1,37 |
<?php |
include_once('includes/common.php'); |
Prolog(); |
$db->query("select person_id, person_name, person_comment, category_name," |
. " category_comment, entry_title, entry_value, entry_comment" |
. " from telbook_persons p" |
. " left join telbook_categories c on p.person_category=c.category_id" |
. " left join telbook_entries e on p.person_id=e.entry_person" |
. " order by person_name, entry_title, entry_value"); |
$table = new Table(array('Name', 'Category', 'Type', 'Number', '')); |
$table->set_table_class('telbook list'); |
$last_person_id = NULL; |
while($line = $db->fetch_row()) { |
$table->newrow(); |
//$same_person = ($line['person_id'] == $last_person_id); |
$table->addcell($same_person ? '' : array('text' => $line['person_name'], |
'comment' => $line['person_comment'])); |
$table->addcell($same_person ? '' : array('text' => $line['category_name'], |
'comment' => $line['category_comment'])); |
$table->addcell(array('text' => $line['entry_title'], |
'comment' => $line['entry_comment'])); |
$table->addcell(array('text' => $line['entry_value'], |
'comment' => $line['entry_comment'])); |
$table->addcell($same_person ? '' : array('class' => 'link', 'html' => |
display_link('telbook_details.php?id=' . $line['person_id'], 'Edit'))); |
$last_person_id = $line['person_id']; |
} |
$g_display->add_html_text($table->build()); |
$g_display->add_template('telbook_list_end'); |
Epilog(); |
?> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/cdr_search.php |
---|
0,0 → 1,10 |
<?php |
include_once('includes/common.php'); |
Prolog(); |
$g_display->add_template('cdr_search'); |
Epilog(); |
?> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/telbook_categories_list.php |
---|
0,0 → 1,25 |
<?php |
include_once('includes/common.php'); |
Prolog(); |
$db->query("select category_id, category_name, category_comment, category_export_key" |
. " from telbook_categories order by category_name"); |
$table = new Table(array('Name', 'Comment', 'Export Key', '')); |
$table->set_table_class('telbook list category_list'); |
while($line = $db->fetch_row()) { |
$table->newrow(); |
$table->addcell($line['category_name']); |
$table->addcell($line['category_comment']); |
$table->addcell($line['category_export_key']); |
$table->addcell(array('class' => 'link', 'html' => |
display_link('telbook_categories_details.php?id=' . $line['category_id'], 'Edit'))); |
} |
$g_display->add_html_text($table->build()); |
$g_display->add_template('telbook_category_list_end'); |
Epilog(); |
?> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/telbook_update.php |
---|
0,0 → 1,61 |
<?php |
include_once('includes/common.php'); |
Prolog(); |
if(array_key_exists('delete', $_POST)) { |
$id = $_POST['id']; |
$db->query_params("delete from telbook_entries where entry_person=$1", array($id)); |
$db->query_params("delete from telbook_persons where person_id=$1", array($id)); |
header("Location: telbook_list.php"); |
$g_display->add_text('Information deleted successfully'); |
} |
else if(array_key_exists('update', $_POST)) { |
$id = $_POST['id']; |
$person_name = $_POST['person_name']; |
$person_comment = $_POST['person_comment']; |
$person_category = ($_POST['person_category'] == '' ? NULL : $_POST['person_category']); |
if($id) { |
$db->query_params("update telbook_persons set" |
. " person_name=$2, person_comment=$3, person_category=$4" |
. " where person_id=$1", |
array($id, $person_name, $person_comment, $person_category)); |
} |
else { |
$db->query_params("insert into telbook_persons" |
. " (person_name, person_comment, person_category) values ($1, $2, $3)", |
array($person_name, $person_comment, $person_category)); |
$db->query("select currval('telbook_persons_person_id_seq')"); |
if($line = $db->fetch_row_idx()) { |
$id = $line[0]; |
} |
} |
$db->query_params("delete from telbook_entries where entry_person=$1", array($id)); |
foreach($_POST as $key => $value) { |
if(substr($key, 0, strlen('entry_title-')) == 'entry_title-') { |
$entry_count = substr($key, strlen('entry_title-')); |
$entry_title = $_POST['entry_title-' . $entry_count]; |
$entry_value = $_POST['entry_value-' . $entry_count]; |
$entry_comment = $_POST['entry_comment-' . $entry_count]; |
if($entry_value) { |
$db->query_params("insert into telbook_entries" |
. " (entry_value, entry_title, entry_person, entry_comment)" |
. " values ($1, $2, $3, $4)", |
array($entry_value, $entry_title, $id, $entry_comment)); |
} |
} |
} |
header("Location: telbook_list.php"); |
$g_display->add_text('Information saved successfully'); |
} |
Epilog(); |
?> |
Property changes: |
Added: svn:mergeinfo |
/asterisk-stats/trunk/cdr_list.php |
---|
0,0 → 1,157 |
<?php |
include_once('includes/common.php'); |
Prolog(); |
function do_field($sql, &$params, $fld) { |
if($fld && $_GET[$fld]) { |
$sql .= " and $fld"; |
if(array_key_exists($fld.'type', $_GET)) { |
$dType = $_GET[$fld.'type']; |
switch($dType) { |
case 1: |
array_push($params, $_GET[$fld]); |
$sql .= "=$" . count($params); |
break; |
case 2: |
array_push($params, "$_GET[$fld]%"); |
$sql .= " LIKE $" . count($params); |
break; |
case 3: |
array_push($params, "%$_GET[$fld]%"); |
$sql .= " LIKE $" . count($params); |
break; |
case 4; |
array_push($params, "%$_GET[$fld]"); |
$sql .= " LIKE $" . count($params); |
} |
} |
else { |
array_push($params, "%$_GET[$fld]%"); |
$sql .= " LIKE $" . count($params); |
} |
} |
return $sql; |
} |
function do_date_compare($period, $diff = NULL) |
{ |
return " and date_trunc('" . $period . "', calldate)" |
. ($diff ? " + interval '$diff $period'" : "") . " = date_trunc('" |
. $period . "', current_date)"; |
} |
# Construct Query Here |
$query = BaseQuery(); |
$params = array(); |
$active = false; |
if ($_GET['before']) { |
array_push($params, $_GET['before']); |
$query .= " AND calldate < $" . count($params); |
} |
if ($_GET['after']) { |
array_push($params, $_GET['after']); |
$query .= " AND calldate > $" . count($params); |
} |
$query = do_field($query, $params, 'clid'); |
$query = do_field($query, $params, 'src'); |
$query = do_field($query, $params, 'dst'); |
$query = do_field($query, $params, 'channel'); |
$query_limit = ''; |
if(array_key_exists('list',$_GET)) { |
switch($_GET['list']) { |
case 'year': $query .= do_date_compare('year'); break; |
case 'month': $query .= do_date_compare('month'); break; |
case 'week': $query .= do_date_compare('week'); break; |
case 'lastweek': $query .= do_date_compare('week', 1); break; |
case 'today': $query .= do_date_compare('day'); break; |
case 'active': |
$active = true; |
$query .= " and duration is null"; |
break; |
default: $query_limit .= " limit 1000"; |
} |
} |
if($active) { |
$list_query = "select acctid,calldate,src,dst," |
. " extract(epoch from date_trunc('second'," |
. " current_timestamp-linkdate)) as billsec,disposition," |
. " p1.person_name as src_name, e1.entry_title as src_title," |
. " p2.person_name as dst_name, e2.entry_title as dst_title" |
. " from activecalls r" |
. " left join telbook_entries e1 on r.src=e1.entry_value" |
. " left join telbook_persons p1 on p1.person_id=e1.entry_person" |
. " left join telbook_entries e2 on r.dst=e2.entry_value" |
. " left join telbook_persons p2 on p2.person_id=e2.entry_person" |
. " where" |
. $query . " order by calldate desc" . $query_limit; |
} |
else { |
$list_query = "select acctid,calldate,src,dst,billsec,disposition," |
. " p1.person_name as src_name, e1.entry_title as src_title," |
. " p2.person_name as dst_name, e2.entry_title as dst_title" |
. " from cdr r" |
. " left join telbook_entries e1 on r.src=e1.entry_value" |
. " left join telbook_persons p1 on p1.person_id=e1.entry_person" |
. " left join telbook_entries e2 on r.dst=e2.entry_value" |
. " left join telbook_persons p2 on p2.person_id=e2.entry_person" |
. " where" |
. $query . " order by calldate desc" . $query_limit; |
} |
$result = $db->query_params($list_query, $params); |
$calls_number = $db->num_rows(); |
$cdr = new Table(array('ID', 'Call Date', array('text' => 'Source', 'colspan' => 2), |
array('text' => 'Destination', 'colspan' => 2), 'Duration', 'Disposition')); |
$cdr->set_table_class('stat cdr list'); |
while($line = $db->fetch_row()) { |
$cdr->newrow(); |
$cdr->addcell($line['acctid']); |
$cdr->addcell(FormatDateTime($line['calldate'])); |
$cdr->addcell(array('text' => $line['src'], 'class' => 'num')); |
$cdr->addcell($line['src_name'] . ($line['src_title'] ? '/' . $line['src_title'] : '')); |
$cdr->addcell(array('text' => $line['dst'], 'class' => 'num')); |
$cdr->addcell($line['dst_name'] . ($line['dst_title'] ? '/' . $line['dst_title'] : '')); |
$cdr->addcell(array('text' => ($line['disposition'] == 'ANSWERED' |
? FormatDuration($line['billsec']) : ''), 'class' => 'duration')); |
$cdr->addcell(strtolower($line['disposition'])); |
$cdr->addcell(array('class' => 'link', 'html' => |
display_link('cdr_details?' . ($active ? 'active' : 'detail') |
. '=' . $line['acctid'], 'Details'))); |
} |
$g_display->add_html_text($cdr->build()); |
// summary |
if($active) { |
$sum_query = "select" |
. " sum(extract(epoch from date_trunc('second',current_timestamp-calldate))) as dur," |
. " sum(extract(epoch from date_trunc('second',current_timestamp-linkdate))) as bill" |
. " from activecalls where" . $query; |
} |
else { |
$sum_query = "select sum(duration) as dur, sum(billsec) as bill from cdr where" . $query; |
} |
$result = $db->query_params($sum_query, $params); |
$line = $db->fetch_row(); |
$cdr = new Table(); |
$cdr->set_table_class('stat cdr sum'); |
$cdr->addcell(array('tag' => 'th', 'text' => 'Calls')); |
$cdr->addcell($calls_number); |
$cdr->newrow(); |
$cdr->addcell(array('tag' => 'th', 'text' => 'Call Seconds')); |
$cdr->addcell(FormatDuration($line['dur'])); |
$cdr->newrow(); |
$cdr->addcell(array('tag' => 'th', 'text' => 'Bill Seconds')); |
$cdr->addcell(FormatDuration($line['bill'])); |
$g_display->add_html_text($cdr->build()); |
Epilog(); |
?> |
Property changes: |
Added: svn:mergeinfo |