<?php
/*
* ****************************************************************************************
* Copyright (c) 2013 Christopher W. Olsen <cwolsen@ubixtechnologies.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions, the following disclaimer and the list of authors. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions, the following
* disclaimer and the list of authors in the documentation and/or other materials provided
* with the distribution. Neither the name of the uBix Cube Project nor the names of its
* contributors may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: index.php 58 2015-11-12 02:58:24Z reddawg $
*
* ***************************************************************************************
*/
/* Main include info */
ini_set ( 'include_path', $_SERVER ['DOCUMENT_ROOT'] . "/include/" );
include ("config.php");
/* Assign the page title */
$ubF->tpl->assign ( "PAGE_TITLE", "VoIP - Overview" );
/* Main defines */
$ubF->tpl->define ( array (
"index" => "user/wrapper/default.html"
) );
$ubF->tpl->define ( array (
"menu" => "user/voip/menu.html"
) );
$ubF->tpl->define ( array (
"body" => "user/voip/index.html"
) );
$ubF->session->Validate ( 'U_V_', 1 );
if ($ubF->session->voip_code == "")
$message = "<h2>You're account is not setup to use our VoIP services.</h2><h3>Call today to sign up for our VoIP services.</h3>";
else
$message = "";
$days_30_back = strtotime ( "-30 days", time () - 86399 );
$days_28_back = strtotime ( "-28 days", time () - 86399 );
$days_21_back = strtotime ( "-21 days", time () - 86399 );
$days_14_back = strtotime ( "-14 days", time () - 86399 );
$days_07_back = strtotime ( "-7 days", time () - 86399 );
$voip_rows = "";
$ac_calls_total = 0;
$att_calls_total = 0;
$act_calls_total = 0;
$aac_calls_total = 0;
$auc_calls_total = 0;
$abc_calls_total = 0;
$query = "SELECT * FROM voip_stats WHERE voip_code = '" . $ubF->session->voip_code . "' AND date >= $days_30_back ORDER BY date DESC";
$result = $ubF->DB ['main']->query ( $query );
while ( $qData = $result->fetch_assoc () ) {
$ac_calls_total += $qData ['total_calls'];
$att_calls_total += $qData ['total_talk'];
$act_calls_total += $qData ['average_talk'];
$aac_calls_total += $qData ['answered'];
$auc_calls_total += $qData ['unanswered'];
$abc_calls_total += $qData ['busy'];
if ($qData ['date'] >= $days_07_back) {
$voip_date = date ( "m/d/Y", $qData ['date'] );
$voip_calls = number_format ( $qData ['total_calls'] );
$voip_total = gmdate ( "H:i:s", $qData ['total_talk'] );
$voip_average = gmdate ( "H:i:s", $qData ['average_talk'] );
$voip_answered = $qData ['answered'];
$voip_unanswered = $qData ['unanswered'];
$voip_busy = $qData ['busy'];
$voip_rows .= "<tr><td>" . $voip_date . "</td><td>" . $voip_calls . "</td><td>" . $voip_total . "</td><td>" . $voip_average . "</td><td>" . $voip_answered . "</td><td>" . $voip_unanswered . "</td><td>" . $voip_busy . "</td></tr>";
}
}
if (strlen ( $voip_rows ) == 0)
$voip_rows = "<tr><td colspan=\"7\">No Data Available</td></tr>";
$ubF->tpl->assign ( "VOIP_ROWS", $voip_rows );
$ubF->tpl->assign ( "AC_DAILY", number_format ( $ac_calls_total / 30, 2 ) );
$ubF->tpl->assign ( "AC_WEEKLY", number_format ( $ac_calls_total / 4.28, 2 ) );
$ubF->tpl->assign ( "AC_MONTHLY", number_format ( $ac_calls_total, 2 ) );
$ubF->tpl->assign ( "ATT_DAILY", gmdate ( "H:i:s", ceil ( $att_calls_total / 30 ) ) );
$ubF->tpl->assign ( "ATT_WEEKLY", gmdate ( "H:i:s", ceil ( $att_calls_total / 4.28 ) ) );
$ubF->tpl->assign ( "ATT_MONTHLY", gmdate ( "H:i:s", ceil ( $att_calls_total ) ) );
$ubF->tpl->assign ( "ACT_DAILY", gmdate ( "H:i:s", ceil ( $act_calls_total / 30 ) ) );
$ubF->tpl->assign ( "ACT_WEEKLY", gmdate ( "H:i:s", ceil ( $act_calls_total / 4.28 ) ) );
$ubF->tpl->assign ( "ACT_MONTHLY", gmdate ( "H:i:s", ceil ( $act_calls_total ) ) );
$ubF->tpl->assign ( "AAC_DAILY", number_format ( $aac_calls_total / 30, 2 ) );
$ubF->tpl->assign ( "AAC_WEEKLY", number_format ( $aac_calls_total / 4.28, 2 ) );
$ubF->tpl->assign ( "AAC_MONTHLY", number_format ( $aac_calls_total, 2 ) );
$ubF->tpl->assign ( "AUC_DAILY", number_format ( $auc_calls_total / 30, 2 ) );
$ubF->tpl->assign ( "AUC_WEEKLY", number_format ( $auc_calls_total / 4.28, 2 ) );
$ubF->tpl->assign ( "AUC_MONTHLY", number_format ( $auc_calls_total, 2 ) );
$ubF->tpl->assign ( "ABC_DAILY", number_format ( $abc_calls_total / 30, 2 ) );
$ubF->tpl->assign ( "ABC_WEEKLY", number_format ( $abc_calls_total / 4.28, 2 ) );
$ubF->tpl->assign ( "ABC_MONTHLY", number_format ( $abc_calls_total, 2 ) );
$ubF->tpl->assign ( "MESSAGE", $message );
/* Parse and print */
$ubF->tpl->parse ( "MENU", array (
"menu"
) );
$ubF->tpl->parse ( "BODY", array (
"body"
) );
$ubF->tpl->parse ( "INDEX", array (
"index"
) );
$ubF->tpl->FastPrint ( "INDEX" );
?>