<?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: dialer_reports.php 939 2017-09-07 20:10:45Z reddawg $ * * *************************************************************************************** */ /* Main include info */ ini_set ( 'include_path', $_SERVER ['DOCUMENT_ROOT'] . "/include/" ); include ("config.php"); /* Assign the page title */ $ubF->tpl->assign ( "PAGE_TITLE", "Dialer - Reportrs" ); /* Main defines */ $ubF->tpl->define ( array ( "index" => "user/wrapper/default.html" ) ); $ubF->tpl->define ( array ( "menu" => "user/dialer/menu.html" ) ); $ubF->tpl->define ( array ( "body" => "user/dialer/dialer_reports.html" ) ); $ubF->session->Validate ( 'U_D_', 1 ); /* Dialer Report */ if ( !isset ( $form_data ['start_date'] ) ) $form_data ['start_date'] = date ( "Y-m-d", time () - 10000 ); if ( !isset ( $form_data ['end_date'] ) ) $form_data ['end_date'] = date ( "Y-m-d", time () - 10000 ); $query = "SELECT campaign_id,campaign_name,user_group FROM vicidial_campaigns WHERE user_group = '" . $ubF->session->dialer_group . "'"; $result = $data ['dialer_db']->query ( $query ); $campaigns = "<option value=\"0\">Select Campaign</option>"; while ( $qData = $result->fetch_assoc () ) { if ( in_array ( $qData ['campaign_id'], $form_data ['dialer_cid'] ) ) $campaigns .= "<option value=\"" . $qData ['campaign_id'] . "\" selected>" . $qData ['campaign_name'] . "</option>\n"; else $campaigns .= "<option value=\"" . $qData ['campaign_id'] . "\">" . $qData ['campaign_name'] . "</option>\n"; } $result->free (); $rows = ""; $total_calls = 0; $total_time = 0; $total_drop = 0; $total_hac = 0; $total_hat = 0; if ( isset ( $form_data ['dialer_cid'] ) && $form_data ['dialer_cid'] != 0 ) { $query = "SELECT status,status_name FROM vicidial_statuses"; $result = $data ['dialer_db']->query ( $query ); while ( $qData = $result->fetch_assoc () ) { $status [$qData ['status']] = $qData ['status_name']; } foreach ( $form_data ['dialer_cid'] as $key ) { if ( $key != 0 ) if ( !isset ( $cid_where ) ) $cid_where = "campaign_id = '" . $key . "'"; else $cid_where .= " OR campaign_id = '" . $key . "'"; } $query = "SELECT status,SUM(length_in_sec) AS total_time,COUNT(*) AS total_calls FROM vicidial_log WHERE call_date >= '" . $form_data ['start_date'] . " 00:00:00' AND call_date <= '" . $form_data ['end_date'] . " 23:59:59' AND " . $cid_where . " GROUP BY status ORDER BY status DESC"; $result = $data ['dialer_db']->query ( $query ); while ( $qData = $result->fetch_assoc () ) { $total_calls += $qData ['total_calls']; $total_time += $qData ['total_time']; if ( $qData ['status'] == "DROP" ) $total_drop = $qData ['total_calls']; else if ( $qData ['status'] != "NA" && $qData ['status'] != "N" && $qData ['status'] != "DC" && $qData ['status'] != "AB" && $qData ['status'] != "A" ) { $total_hac += $qData ['total_calls']; $total_hat += $qData ['total_time']; } $rows .= "<tr><td>" . $qData ['status'] . "</td><td>" . $status [$qData ['status']] . "</td><td>" . $qData ['total_calls'] . "</td><td>" . secondsToTime ( $qData ['total_time'] ) . "</td><td>" . gmdate ( "i:s", $qData ['total_time'] / $qData ['total_calls'] ) . "</td>"; $rows .= "<td>$" . $ubF->session->dialer_cpm . "</td><td>$" . number_format ( ($qData ['total_time'] / 60) * $ubF->session->dialer_cpm, 2 ) . "</tr>\n"; } $result->free (); } $ubF->tpl->assign ( "DIALER_ROWS", $rows ); $ubF->tpl->assign ( "DIALER_CAMPAIGNS", $campaigns ); $ubF->tpl->assign ( "START_DATE", $form_data ['start_date'] ); $ubF->tpl->assign ( "END_DATE", $form_data ['end_date'] ); $ubF->tpl->assign ( "TOTAL_CALLS", $total_calls ); $ubF->tpl->assign ( "TOTAL_DROP", $total_drop ); $ubF->tpl->assign ( "HUMAN_TOTAL", $total_hac ); $ubF->tpl->assign ( "AVERAGE_HUMAN_CALL", secondsToTime ( $total_hat / $total_hac ) ); $ubF->tpl->assign ( "AVERAGE_CALL", secondsToTime ( $total_time / $total_calls ) ); $ubF->tpl->assign ( "TOTAL_TIME", secondsToTime ( $total_time ) ); $ubF->tpl->assign ( "TOTAL_COST", number_format ( ($total_time / 60) * $ubF->session->dialer_cpm, 2 ) ); /* 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" ); function secondsToTime ( $t, $f = ':' ) { return sprintf ( "%02d%s%02d%s%02d", floor ( $t / 3600 ), $f, ($t / 60) % 60, $f, $t % 60 ); } ?>