Add CDR limit

This commit is contained in:
Mark Crane 2014-07-11 01:34:47 +00:00
parent c42890d4f1
commit d9f26f8cd7
3 changed files with 24 additions and 7 deletions

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
Portions created by the Initial Developer are Copyright (C) 2008-2014
the Initial Developer. All Rights Reserved.
Contributor(s):

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
Portions created by the Initial Developer are Copyright (C) 2008-2014
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -45,7 +45,7 @@ else {
//set the csv headers
$z = 0;
foreach($result[0] as $key => $val) {
if ($key != "xml_cdr") {
if ($key != "xml" && $key != "json") {
if ($z == 0) {
echo '"'.$key.'"';
}
@ -62,7 +62,7 @@ else {
while(true) {
$z = 0;
foreach($result[0] as $key => $val) {
if ($key != "xml_cdr") {
if ($key != "xml" && $key != "json") {
if ($z == 0) {
echo '"'.$result[$x][$key].'"';
}
@ -80,4 +80,5 @@ else {
//$row++;
}
?>

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
Portions created by the Initial Developer are Copyright (C) 2008-2014
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -191,9 +191,14 @@ else {
if (strlen($order_by) == 0) { $order_by = "start_epoch"; }
if (strlen($order) == 0) { $order = "desc"; }
//set the default
//set a default number of rows to show
$num_rows = '0';
//set a default CDR limit
if (!isset($_SESSION['cdr']['limit']['numeric'])) {
$_SESSION['cdr']['limit']['numeric'] = 800;
}
//page results if rows_per_page is greater than zero
if ($rows_per_page > 0) {
//get the number of rows in the v_xml_cdr
@ -210,6 +215,14 @@ else {
}
}
unset($prep_statement, $result);
//limit the number of results
if ($num_rows > $_SESSION['cdr']['limit']['numeric']) {
$num_rows = $_SESSION['cdr']['limit']['numeric'];
}
if ($rows_per_page > $_SESSION['cdr']['limit']['numeric']) {
$rows_per_page = $_SESSION['cdr']['limit']['numeric'];
}
//prepare to page the results
//$rows_per_page = 150; //set on the page that includes this page
@ -222,7 +235,10 @@ else {
//get the results from the db
$sql = "select * from v_xml_cdr where domain_uuid = '".$domain_uuid."' ".$sql_where;
if (strlen($order_by)> 0) { $sql .= " order by ".$order_by." ".$order." "; }
if ($rows_per_page > 0) {
if ($rows_per_page == 0) {
$sql .= " limit ".$_SESSION['cdr']['limit']['numeric']." offset 0 ";
}
else {
$sql .= " limit ".$rows_per_page." offset ".$offset." ";
}
$prep_statement = $db->prepare(check_sql($sql));