From fa4464e59d2a36babb65cd2a52df80d009991de8 Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 16 Dec 2010 19:01:16 +0000 Subject: [PATCH] Added rewritten AJAX/Javascript driven real-time report(realtime_report.php), able to support webphones for monitoring git-svn-id: svn://192.168.202.10@1576 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/UPGRADE | 3 + .../TO_BE_TRANSLATED_2.4.txt | 2 + .../trunk/www/vicidial/AST_timeonVDADall.php | 781 ++++++----- .../trunk/www/vicidial/admin_search_lead.php | 2 +- .../trunk/www/vicidial/options-example.php | 32 + .../trunk/www/vicidial/realtime_report.php | 1228 +++++++++++++++++ 6 files changed, 1683 insertions(+), 365 deletions(-) create mode 100644 agc_2-X/trunk/www/vicidial/options-example.php create mode 100644 agc_2-X/trunk/www/vicidial/realtime_report.php diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index c18a8867..3189ec73 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -417,6 +417,9 @@ OTHER CHANGES: the campaign modification screen. Also includes called and not called counts. +96. Added rewritten AJAX/Javascript driven real-time report, able to support + webphones. + diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt index c4c91e5a..c9638753 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt @@ -492,6 +492,8 @@ Phone Extension|| This field is where you put the phones name as it appears to Asterisk not including the protocol or slash at the beginning. For Example: for the SIP phone SIP/test101 the Phone extension would be test101. Also, for IAX2 phones: IAX2/IAXphone1@IAXphone1 would be IAXphone1. For Zap and Dahdi attached channelbank or FXS phones make sure you put the full channel number without the prefix: Zap/25-1 would be 25-1. Another note, make sure you set the Protocol field below correctly for your type of phone|| STATUSES WITHIN THE ACTIVE LISTS FOR THIS CAMPAIGN|| SHOW LEAD STATUSES IN THIS CAMPAIGN|| +RELOAD NOW|| +refresh|| AST_LISTS_campaign_stats.php diff --git a/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php b/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php index de37e469..1f910c93 100644 --- a/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php +++ b/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php @@ -70,10 +70,11 @@ # 100914-1326 - Added lookup for user_level 7 users to set to reports only which will remove other admin links # 101024-0832 - Added Agent time stats option and agents-in-dispo counter # 101109-1448 - Added Auto Hopper Level display (MikeC) +# 101216-1358 - Added functions to work with new realtime_report.php script # -$version = '2.4-61'; -$build = '101109-1448'; +$version = '2.4-62'; +$build = '101216-1358'; header ("Content-type: text/html; charset=utf-8"); @@ -139,6 +140,13 @@ if (isset($_GET["PRESETstats"])) {$PRESETstats=$_GET["PRESETstats"];} elseif (isset($_POST["PRESETstats"])) {$PRESETstats=$_POST["PRESETstats"];} if (isset($_GET["AGENTtimeSTATS"])) {$AGENTtimeSTATS=$_GET["AGENTtimeSTATS"];} elseif (isset($_POST["AGENTtimeSTATS"])) {$AGENTtimeSTATS=$_POST["AGENTtimeSTATS"];} +if (isset($_GET["RTajax"])) {$RTajax=$_GET["RTajax"];} + elseif (isset($_POST["RTajax"])) {$RTajax=$_POST["RTajax"];} +if (isset($_GET["RTuser"])) {$RTuser=$_GET["RTuser"];} + elseif (isset($_POST["RTuser"])) {$RTuser=$_POST["RTuser"];} +if (isset($_GET["RTpass"])) {$RTpass=$_GET["RTpass"];} + elseif (isset($_POST["RTpass"])) {$RTpass=$_POST["RTpass"];} + $report_name = 'Real-Time Main Report'; $db_source = 'M'; @@ -258,7 +266,6 @@ $timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); $epochTWENTYFOURhoursAGO = ($STARTtime - 86400); $timeTWENTYFOURhoursAGO = date("Y-m-d H:i:s",$epochTWENTYFOURhoursAGO); - $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); @@ -559,283 +566,302 @@ $open_list = "< - - -\n"; + // function to display in-groups selected for a specific agent + function ingroup_info(agent_user,count) + { + var cursorheight = (document.REALTIMEform.cursorY.value - 0); + var newheight = (cursorheight + 10); + document.getElementById("agent_ingroup_display").style.top = newheight; + // alert(session_id + "|" + server_ip + "|" + monitor_phone + "|" + stage + "|" + user); + var xmlhttp=false; + /*@cc_on @*/ + /*@if (@_jscript_version >= 5) + // JScript gives us Conditional compilation, we can cope with old IE versions. + // and security blocked creation of the objects. + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttp = false; + } + } + @end @*/ + if (!xmlhttp && typeof XMLHttpRequest!='undefined') + { + xmlhttp = new XMLHttpRequest(); + } + if (xmlhttp) + { + var monitorQuery = "source=realtime&function=agent_ingroup_info&stage=change&user=" + user + "&pass=" + pass + "&agent_user=" + agent_user; + xmlhttp.open('POST', 'non_agent_api.php'); + xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); + xmlhttp.send(monitorQuery); + xmlhttp.onreadystatechange = function() + { + if (xmlhttp.readyState == 4 && xmlhttp.status == 200) + { + // alert(xmlhttp.responseText); + var Xoutput = null; + Xoutput = xmlhttp.responseText; + var regXFerr = new RegExp("ERROR","g"); + if (Xoutput.match(regXFerr)) + {alert(xmlhttp.responseText);} + else + { + document.getElementById("agent_ingroup_display").visibility = "visible"; + document.getElementById("agent_ingroup_display").innerHTML = Xoutput; + } + } + } + delete xmlhttp; + } + } + + // function to display in-groups selected for a specific agent + function hide_ingroup_info() + { + document.getElementById("agent_ingroup_display").visibility = "hidden"; + document.getElementById("agent_ingroup_display").innerHTML = ''; + } + + + + + + \n"; + + echo "\n"; + echo"\n"; + echo "$report_name: $group\n"; + + $short_header=1; + + require("admin_header.php"); + + } $stmt = "select count(*) from vicidial_campaigns where active='Y' and campaign_allow_inbound='Y' $group_SQLand;"; $rslt=mysql_query($stmt, $link); @@ -843,60 +869,55 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $campaign_allow_inbound = $row[0]; -echo "\n"; -echo"\n"; -echo "$report_name: $group\n"; - $short_header=1; - - require("admin_header.php"); - -echo "
"; - -echo "
\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo "Real-Time Report                                                                               \n"; -echo "\n"; -echo "
\n"; -echo "Choose Report Display Options"; -echo "
\n"; -echo "
\n"; -echo "\n"; -echo "   "; -echo "\n"; -echo "STOP | "; -echo "SLOW | "; -echo "GO"; -if (eregi('ALL-ACTIVE',$group_string)) +if ($RTajax < 1) { - echo "       MODIFY | \n"; - } -else - { - echo "       MODIFY | \n"; - } -echo "SUMMARY \n"; -echo "\n\n"; + echo ""; - echo ""; + echo ""; echo ""; echo ""; echo ""; @@ -1682,63 +1707,67 @@ echo ""; echo ""; echo "
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "Real-Time Report                                                                               \n"; + echo "\n"; + echo "
\n"; + echo "Choose Report Display Options"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "   "; + echo "\n"; + echo "STOP | "; + echo "SLOW | "; + echo "GO"; + if (eregi('ALL-ACTIVE',$group_string)) + { + echo "       MODIFY | \n"; + } + else + { + echo "       MODIFY | \n"; + } + echo "SUMMARY \n"; + echo "\n\n"; + } if (!$group) {echo "

please select a campaign from the pulldown above\n"; exit;} @@ -1572,8 +1593,12 @@ else if ($adastats>1) { + $min_link='- min '; + if ($RTajax > 0) + {$min_link='';} + echo "
- min   MAX LEVEL:  $maxDIALlev   $min_link  MAX LEVEL:  $maxDIALlev   DROPPED MAX:  $DROPmax%    TARGET DIFF:  $targetDIFF     INTENSITY:  $ADAintense     "; echo "$ingroup_detail"; -if ($adastats<2) +if ($RTajax < 1) { - echo "+ VIEW MORE"; - } -else - { - echo "+ VIEW LESS"; - } -if ($UGdisplay>0) - { - echo "       HIDE USER GROUP"; - } -else - { - echo "       VIEW USER GROUP"; - } -if ($SERVdisplay>0) - { - echo "       HIDE SERVER INFO"; - } -else - { - echo "       SHOW SERVER INFO"; - } -if ($CALLSdisplay>0) - { - echo "       HIDE WAITING CALLS"; - } -else - { - echo "       SHOW WAITING CALLS"; + if ($adastats<2) + { + echo "+ VIEW MORE"; + } + else + { + echo "+ VIEW LESS"; + } + if ($UGdisplay>0) + { + echo "       HIDE USER GROUP"; + } + else + { + echo "       VIEW USER GROUP"; + } + if ($SERVdisplay>0) + { + echo "       HIDE SERVER INFO"; + } + else + { + echo "       SHOW SERVER INFO"; + } + if ($CALLSdisplay>0) + { + echo "       HIDE WAITING CALLS"; + } + else + { + echo "       SHOW WAITING CALLS"; + } + + if ($ALLINGROUPstats>0) + { + echo "       HIDE IN-GROUP STATS"; + } + else + { + echo "       SHOW IN-GROUP STATS"; + } + if ($PHONEdisplay>0) + { + echo "       HIDE PHONES"; + } + else + { + echo "       SHOW PHONES"; + } + if ($CUSTPHONEdisplay>0) + { + echo "       HIDE CUSTPHONES"; + } + else + { + echo "       SHOW CUSTPHONES"; + } } -if ($ALLINGROUPstats>0) - { - echo "       HIDE IN-GROUP STATS"; - } -else - { - echo "       SHOW IN-GROUP STATS"; - } -if ($PHONEdisplay>0) - { - echo "       HIDE PHONES"; - } -else - { - echo "       SHOW PHONES"; - } -if ($CUSTPHONEdisplay>0) - { - echo "       HIDE CUSTPHONES"; - } -else - { - echo "       SHOW CUSTPHONES"; - } echo "
"; @@ -1997,17 +2026,31 @@ $HDstation = "----------------+"; $HTstation = " STATION |"; $HDphone = "-------------+"; $HTphone = " PHONE |"; +if ($RTajax > 0) + {$HTphone = " PHONE |";} $HDuser = "------------------------+"; $HTuser = " USER "; +if ($RTajax > 0) + {$HTuser = " USER ";} if ($UidORname>0) { - $HTuser .= "SHOW ID "; + if ($RTajax > 0) + {$HTuser .= "SHOW ID ";} + else + { + $HTuser .= "SHOW ID "; + } } else { - $HTuser .= "SHOW NAME"; + if ($RTajax > 0) + {$HTuser .= "SHOW NAME";} + else + { + $HTuser .= "SHOW NAME"; + } } $HTuser .= " INFO |"; @@ -2015,6 +2058,8 @@ $HTuser .= " INFO |"; $HDusergroup = "--------------+"; $HTusergroup = " USER GROUP |"; +if ($RTajax > 0) + {$HTusergroup = " USER GROUP |";} $HDsessionid = "------------------+"; $HTsessionid = " SESSIONID |"; $HDbarge = "-------+"; @@ -2029,8 +2074,12 @@ $HDcall_server_ip = "-----------------+"; $HTcall_server_ip = " CALL SERVER IP |"; $HDtime = "---------+"; $HTtime = " MM:SS |"; +if ($RTajax > 0) + {$HTtime = " MM:SS |";} $HDcampaign = "------------+"; $HTcampaign = " CAMPAIGN |"; +if ($RTajax > 0) + {$HTcampaign = " CAMPAIGN |";} $HDcalls = "-------+"; $HTcalls = " CALLS |"; $HDpause = ''; @@ -2556,8 +2605,12 @@ $calls_to_list = mysql_num_rows($rslt); echo "
$Cecho";
 	}
 
+echo "
"; + +if ($RTajax < 1) + { + echo "
"; + } ?> - - diff --git a/agc_2-X/trunk/www/vicidial/admin_search_lead.php b/agc_2-X/trunk/www/vicidial/admin_search_lead.php index ddd4ad6b..eb213542 100644 --- a/agc_2-X/trunk/www/vicidial/admin_search_lead.php +++ b/agc_2-X/trunk/www/vicidial/admin_search_lead.php @@ -207,7 +207,7 @@ if ( (!$vendor_id) and (!$phone) and (!$lead_id) and (!$log_phone) and (!$log_ echo "Lead Search Options:"; echo ""; - echo "$label_vendor_lead_code(vendor lead code):   "; + echo "$label_vendor_lead_code(vendor lead code):   "; echo "\n"; echo ""; echo "   "; diff --git a/agc_2-X/trunk/www/vicidial/options-example.php b/agc_2-X/trunk/www/vicidial/options-example.php new file mode 100644 index 00000000..939295ed --- /dev/null +++ b/agc_2-X/trunk/www/vicidial/options-example.php @@ -0,0 +1,32 @@ + LICENSE: AGPLv2 +# +# rename this file to options.php for the settings here to go into effect +# +# CHANGELOG +# 101216-1043 - First Build +# + +# used by the realtime_report.php script +$webphone_width = '460'; +$webphone_height = '500'; +$webphone_left = '600'; +$webphone_top = '27'; +$webphone_bufw = '250'; +$webphone_bufh = '1'; +$webphone_pad = '10'; +$webphone_clpos = '
'; + +# example using thin webphone +#$webphone_width = '1135'; +#$webphone_height = '36'; +#$webphone_left = '0'; +#$webphone_top = '50'; +#$webphone_bufw = '1300'; +#$webphone_bufh = '37'; +#$webphone_pad = '0'; +#$webphone_clpos = ' '; + +?> diff --git a/agc_2-X/trunk/www/vicidial/realtime_report.php b/agc_2-X/trunk/www/vicidial/realtime_report.php new file mode 100644 index 00000000..cfc41260 --- /dev/null +++ b/agc_2-X/trunk/www/vicidial/realtime_report.php @@ -0,0 +1,1228 @@ + LICENSE: AGPLv2 +# +# live real-time stats for the VICIDIAL Auto-Dialer all servers +# +# Rewritten from AST_timeonVDADall.php report to be AJAX and javascript instead +# of link-driven +# +# * Requires AST_timeonVDADall.php for AJAX-derived stats information +# +# CHANGELOG: +# 101216-1355 - First Build +# + +$version = '2.4-1'; +$build = '101215-0434'; + +header ("Content-type: text/html; charset=utf-8"); + +require("dbconnect.php"); +require("functions.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} + elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} +if (isset($_GET["RR"])) {$RR=$_GET["RR"];} + elseif (isset($_POST["RR"])) {$RR=$_POST["RR"];} +if (isset($_GET["inbound"])) {$inbound=$_GET["inbound"];} + elseif (isset($_POST["inbound"])) {$inbound=$_POST["inbound"];} +if (isset($_GET["group"])) {$group=$_GET["group"];} + elseif (isset($_POST["group"])) {$group=$_POST["group"];} +if (isset($_GET["groups"])) {$groups=$_GET["groups"];} + elseif (isset($_POST["groups"])) {$groups=$_POST["groups"];} +if (isset($_GET["usergroup"])) {$usergroup=$_GET["usergroup"];} + elseif (isset($_POST["usergroup"])) {$usergroup=$_POST["usergroup"];} +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["adastats"])) {$adastats=$_GET["adastats"];} + elseif (isset($_POST["adastats"])) {$adastats=$_POST["adastats"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} +if (isset($_GET["SIPmonitorLINK"])) {$SIPmonitorLINK=$_GET["SIPmonitorLINK"];} + elseif (isset($_POST["SIPmonitorLINK"])) {$SIPmonitorLINK=$_POST["SIPmonitorLINK"];} +if (isset($_GET["IAXmonitorLINK"])) {$IAXmonitorLINK=$_GET["IAXmonitorLINK"];} + elseif (isset($_POST["IAXmonitorLINK"])) {$IAXmonitorLINK=$_POST["IAXmonitorLINK"];} +if (isset($_GET["UGdisplay"])) {$UGdisplay=$_GET["UGdisplay"];} + elseif (isset($_POST["UGdisplay"])) {$UGdisplay=$_POST["UGdisplay"];} +if (isset($_GET["UidORname"])) {$UidORname=$_GET["UidORname"];} + elseif (isset($_POST["UidORname"])) {$UidORname=$_POST["UidORname"];} +if (isset($_GET["orderby"])) {$orderby=$_GET["orderby"];} + elseif (isset($_POST["orderby"])) {$orderby=$_POST["orderby"];} +if (isset($_GET["SERVdisplay"])) {$SERVdisplay=$_GET["SERVdisplay"];} + elseif (isset($_POST["SERVdisplay"])) {$SERVdisplay=$_POST["SERVdisplay"];} +if (isset($_GET["CALLSdisplay"])) {$CALLSdisplay=$_GET["CALLSdisplay"];} + elseif (isset($_POST["CALLSdisplay"])) {$CALLSdisplay=$_POST["CALLSdisplay"];} +if (isset($_GET["PHONEdisplay"])) {$PHONEdisplay=$_GET["PHONEdisplay"];} + elseif (isset($_POST["PHONEdisplay"])) {$PHONEdisplay=$_POST["PHONEdisplay"];} +if (isset($_GET["CUSTPHONEdisplay"])) {$CUSTPHONEdisplay=$_GET["CUSTPHONEdisplay"];} + elseif (isset($_POST["CUSTPHONEdisplay"])) {$CUSTPHONEdisplay=$_POST["CUSTPHONEdisplay"];} +if (isset($_GET["NOLEADSalert"])) {$NOLEADSalert=$_GET["NOLEADSalert"];} + elseif (isset($_POST["NOLEADSalert"])) {$NOLEADSalert=$_POST["NOLEADSalert"];} +if (isset($_GET["DROPINGROUPstats"])) {$DROPINGROUPstats=$_GET["DROPINGROUPstats"];} + elseif (isset($_POST["DROPINGROUPstats"])) {$DROPINGROUPstats=$_POST["DROPINGROUPstats"];} +if (isset($_GET["ALLINGROUPstats"])) {$ALLINGROUPstats=$_GET["ALLINGROUPstats"];} + elseif (isset($_POST["ALLINGROUPstats"])) {$ALLINGROUPstats=$_POST["ALLINGROUPstats"];} +if (isset($_GET["with_inbound"])) {$with_inbound=$_GET["with_inbound"];} + elseif (isset($_POST["with_inbound"])) {$with_inbound=$_POST["with_inbound"];} +if (isset($_GET["monitor_active"])) {$monitor_active=$_GET["monitor_active"];} + elseif (isset($_POST["monitor_active"])) {$monitor_active=$_POST["monitor_active"];} +if (isset($_GET["monitor_phone"])) {$monitor_phone=$_GET["monitor_phone"];} + elseif (isset($_POST["monitor_phone"])) {$monitor_phone=$_POST["monitor_phone"];} +if (isset($_GET["CARRIERstats"])) {$CARRIERstats=$_GET["CARRIERstats"];} + elseif (isset($_POST["CARRIERstats"])) {$CARRIERstats=$_POST["CARRIERstats"];} +if (isset($_GET["PRESETstats"])) {$PRESETstats=$_GET["PRESETstats"];} + elseif (isset($_POST["PRESETstats"])) {$PRESETstats=$_POST["PRESETstats"];} +if (isset($_GET["AGENTtimeSTATS"])) {$AGENTtimeSTATS=$_GET["AGENTtimeSTATS"];} + elseif (isset($_POST["AGENTtimeSTATS"])) {$AGENTtimeSTATS=$_POST["AGENTtimeSTATS"];} + +$report_name = 'Real-Time Main Report'; +$db_source = 'M'; + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db FROM system_settings;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysql_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysql_fetch_row($rslt); + $non_latin = $row[0]; + $outbound_autodial_active = $row[1]; + $slave_db_server = $row[2]; + $reports_use_slave_db = $row[3]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) + { + mysql_close($link); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect.php"); + echo "\n"; + } + +if (!isset($DB)) {$DB=0;} +if (!isset($RR)) {$RR=40;} +if (!isset($group)) {$group='ALL-ACTIVE';} +if (!isset($usergroup)) {$usergroup='';} +if (!isset($UGdisplay)) {$UGdisplay=0;} # 0=no, 1=yes +if (!isset($UidORname)) {$UidORname=1;} # 0=id, 1=name +if (!isset($orderby)) {$orderby='timeup';} +if (!isset($SERVdisplay)) {$SERVdisplay=0;} # 0=no, 1=yes +if (!isset($CALLSdisplay)) {$CALLSdisplay=1;} # 0=no, 1=yes +if (!isset($PHONEdisplay)) {$PHONEdisplay=0;} # 0=no, 1=yes +if (!isset($CUSTPHONEdisplay)) {$CUSTPHONEdisplay=0;} # 0=no, 1=yes +if (!isset($PAUSEcodes)) {$PAUSEcodes='N';} # 0=no, 1=yes +if (!isset($with_inbound)) + { + if ($outbound_autodial_active > 0) + {$with_inbound='Y';} # N=no, Y=yes, O=only + else + {$with_inbound='O';} # N=no, Y=yes, O=only + } +$ingroup_detail=''; + +if ( (strlen($group)>1) and (strlen($groups[0])<1) ) {$groups[0] = $group; $RR=40;} +else {$group = $groups[0];} + +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochONEminuteAGO = ($STARTtime - 60); +$timeONEminuteAGO = date("Y-m-d H:i:s",$epochONEminuteAGO); +$epochFIVEminutesAGO = ($STARTtime - 300); +$timeFIVEminutesAGO = date("Y-m-d H:i:s",$epochFIVEminutesAGO); +$epochFIFTEENminutesAGO = ($STARTtime - 900); +$timeFIFTEENminutesAGO = date("Y-m-d H:i:s",$epochFIFTEENminutesAGO); +$epochONEhourAGO = ($STARTtime - 3600); +$timeONEhourAGO = date("Y-m-d H:i:s",$epochONEhourAGO); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); +$epochTWENTYFOURhoursAGO = ($STARTtime - 86400); +$timeTWENTYFOURhoursAGO = date("Y-m-d H:i:s",$epochTWENTYFOURhoursAGO); +$webphone_content=''; + +$webphone_width = '460'; +$webphone_height = '500'; +$webphone_left = '600'; +$webphone_top = '27'; +$webphone_bufw = '250'; +$webphone_bufh = '1'; +$webphone_pad = '10'; +$webphone_clpos = '
'; + +if (file_exists('options.php')) + { + require('options.php'); + } + + + +$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; +if ($DB) {echo "|$stmt|\n";} +if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; + +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level='7' and view_reports='1' and active='Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$reports_only_user=$row[0]; + +if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; + } +# and (preg_match("/MONITOR|BARGE|HIJACK/",$monitor_active) ) ) +if ( (!isset($monitor_phone)) or (strlen($monitor_phone)<1) ) + { + $stmt="select phone_login from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active='Y';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $monitor_phone = $row[0]; + } + +$stmt="SELECT realtime_block_user_info,user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$realtime_block_user_info = $row[0]; +$LOGuser_group = $row[1]; + +$stmt="SELECT allowed_campaigns,allowed_reports,webphone_url_override,webphone_dialpad_override,webphone_systemkey_override from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$webphone_url = $row[2]; +$webphone_dialpad_override = $row[3]; +$system_key = $row[4]; +if ( ($webphone_dialpad_override != 'DISABLED') and (strlen($webphone_dialpad_override) > 0) ) + {$webphone_dialpad = $webphone_dialpad_override;} + +if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) + { + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "You are not allowed to view this report: |$PHP_AUTH_USER|$report_name|\n"; + exit; + } + +$LOGallowed_campaignsSQL=''; +$whereLOGallowed_campaignsSQL=''; +if ( (!preg_match("/ALL-/",$LOGallowed_campaigns)) ) + { + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + } +$regexLOGallowed_campaigns = " $LOGallowed_campaigns "; + +$allactivecampaigns=''; +$stmt="select campaign_id,campaign_name from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL order by campaign_id;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$groups_to_print = mysql_num_rows($rslt); +$i=0; +$LISTgroups[$i]='ALL-ACTIVE'; +$i++; +$groups_to_print++; +while ($i < $groups_to_print) + { + $row=mysql_fetch_row($rslt); + $LISTgroups[$i] =$row[0]; + $LISTnames[$i] =$row[1]; + $allactivecampaigns .= "'$LISTgroups[$i]',"; + $i++; + } +$allactivecampaigns .= "''"; + +$i=0; +$group_string='|'; +$group_ct = count($groups); +while($i < $group_ct) + { + if ( (preg_match("/ $groups[$i] /",$regexLOGallowed_campaigns)) or (preg_match("/ALL-/",$LOGallowed_campaigns)) ) + { + $group_string .= "$groups[$i]|"; + $group_SQL .= "'$groups[$i]',"; + $groupQS .= "&groups[]=$groups[$i]"; + } + + $i++; + } +$group_SQL = eregi_replace(",$",'',$group_SQL); + +### if no campaigns selected, display all +if ( ($group_ct < 1) or (strlen($group_string) < 2) ) + { + $groups[0] = 'ALL-ACTIVE'; + $group_string = '|ALL-ACTIVE|'; + $group = 'ALL-ACTIVE'; + $groupQS .= "&groups[]=ALL-ACTIVE"; + } + +if ( (ereg("--NONE--",$group_string) ) or ($group_ct < 1) ) + { + $all_active = 0; + $group_SQL = "''"; + $group_SQLand = "and FALSE"; + $group_SQLwhere = "where FALSE"; + } +elseif ( eregi('ALL-ACTIVE',$group_string) ) + { + $all_active = 1; + $group_SQL = $allactivecampaigns; + $group_SQLand = "and campaign_id IN($allactivecampaigns)"; + $group_SQLwhere = "where campaign_id IN($allactivecampaigns)"; + } +else + { + $all_active = 0; + $group_SQLand = "and campaign_id IN($group_SQL)"; + $group_SQLwhere = "where campaign_id IN($group_SQL)"; + } + + +$stmt="select user_group from vicidial_user_groups;"; +$rslt=mysql_query($stmt, $link); +if (!isset($DB)) {$DB=0;} +if ($DB) {echo "$stmt\n";} +$usergroups_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $usergroups_to_print) + { + $row=mysql_fetch_row($rslt); + $usergroups[$i] =$row[0]; + $i++; + } + +if (!isset($RR)) {$RR=4;} + +$NFB = ''; +$NFE = ''; +$F=''; $FG=''; $B=''; $BG=''; + +$select_list = "
Select Campaigns:
"; +$select_list .= ""; +$select_list .= "
(To select more than 1 campaign, hold down the Ctrl key and click)"; +$select_list .= "
"; +$select_list .= "Close Panel

"; +$select_list .= ""; + +$select_list .= ""; + +$select_list .= ""; +$select_list .= ""; + +if ($UGdisplay > 0) + { + $select_list .= ""; + } + +$select_list .= ""; +$select_list .= ""; +$select_list .= "
"; +$select_list .= "Screen Refresh Rate:
"; +$select_list .= "Inbound:
 
"; + $select_list .= "Select User Group: "; + $select_list .= "
"; +$select_list .= "Dialable Leads Alert:
"; + $select_list .= "Show Presets Stats:
"; +$select_list .= "   "; +$select_list .= ""; +$select_list .= "VERSION: $version   BUILD: $build"; +$select_list .= "
"; + +$open_list = "
Choose Report Display Options
"; + + + + + +if (strlen($monitor_phone)>1) + { + $stmt="SELECT extension,dialplan_number,server_ip,login,pass,protocol,conf_secret,is_webphone,use_external_server_ip,codecs_list,webphone_dialpad,outbound_cid from phones where login='$monitor_phone' and active = 'Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + $Mph_ct = mysql_num_rows($rslt); + if ($Mph_ct > 0) + { + $row=mysql_fetch_row($rslt); + $extension = $row[0]; + $dialplan_number = $row[1]; + $webphone_server_ip = $row[2]; + $login = $row[3]; + $pass = $row[4]; + $protocol = $row[5]; + $conf_secret = $row[6]; + $is_webphone = $row[7]; + $use_external_server_ip = $row[8]; + $codecs_list = $row[9]; + $webphone_dialpad = $row[10]; + $outbound_cid = $row[11]; + + if ($is_webphone == 'Y') + { + ### build Iframe variable content for webphone here + $codecs_list = preg_replace("/ /",'',$codecs_list); + $codecs_list = preg_replace("/-/",'',$codecs_list); + $codecs_list = preg_replace("/&/",'',$codecs_list); + + if ($use_external_server_ip=='Y') + { + ##### find external_server_ip if enabled for this phone account + $stmt="SELECT external_server_ip FROM servers where server_ip='$webphone_server_ip' LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01065',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $exip_ct = mysql_num_rows($rslt); + if ($exip_ct > 0) + { + $row=mysql_fetch_row($rslt); + $webphone_server_ip =$row[0]; + } + } + if (strlen($webphone_url) < 6) + { + ##### find webphone_url in system_settings and generate IFRAME code for it ##### + $stmt="SELECT webphone_url FROM system_settings LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01066',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $wu_ct = mysql_num_rows($rslt); + if ($wu_ct > 0) + { + $row=mysql_fetch_row($rslt); + $webphone_url =$row[0]; + } + } + if (strlen($system_key) < 1) + { + ##### find system_key in system_settings if populated ##### + $stmt="SELECT webphone_systemkey FROM system_settings LIMIT 1;"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01068',$VD_login,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $wsk_ct = mysql_num_rows($rslt); + if ($wsk_ct > 0) + { + $row=mysql_fetch_row($rslt); + $system_key =$row[0]; + } + } + $webphone_options='INITIAL_LOAD'; + if ($webphone_dialpad == 'Y') {$webphone_options .= "--DIALPAD_Y";} + if ($webphone_dialpad == 'TOGGLE') {$webphone_options .= "--DIALPAD_TOGGLE";} + $session_name='RTS01234561234567890'; + + ### base64 encode variables + $b64_phone_login = base64_encode($extension); + $b64_phone_pass = base64_encode($conf_secret); + $b64_session_name = base64_encode($session_name); + $b64_server_ip = base64_encode($webphone_server_ip); + $b64_callerid = base64_encode($outbound_cid); + $b64_protocol = base64_encode($protocol); + $b64_codecs = base64_encode($codecs_list); + $b64_options = base64_encode($webphone_options); + $b64_system_key = base64_encode($system_key); + + $WebPhonEurl = "$webphone_url?phone_login=$b64_phone_login&phone_login=$b64_phone_login&phone_pass=$b64_phone_pass&server_ip=$b64_server_ip&callerid=$b64_callerid&protocol=$b64_protocol&codecs=$b64_codecs&options=$b64_options&system_key=$b64_system_key"; + $webphone_content = ""; + } + } + } + + + +?> + + + + + + +\n"; + +$stmt = "select count(*) from vicidial_campaigns where active='Y' and campaign_allow_inbound='Y' $group_SQLand;"; +$rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $campaign_allow_inbound = $row[0]; + +echo "\n"; +echo "$report_name: $group\n"; + + $short_header=1; + + require("admin_header.php"); + +echo "
"; + +echo "
\n"; +echo "\n"; +echo "\n"; + +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; +#echo "\n"; + +echo "Real-Time Report                                                                               \n"; +echo "\n"; +echo "
\n"; +echo "Choose Report Display Options"; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +echo ""; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +echo "$webphone_content\n$webphone_clpos\n"; +echo "   webphone -"; +echo "
\n"; +echo "
\n"; +echo "\n"; +echo "   "; +echo "\n"; +echo "RELOAD NOW"; +if (eregi('ALL-ACTIVE',$group_string)) + {echo "       MODIFY | \n";} +else + {echo "       MODIFY | \n";} + +echo "SUMMARY \n"; + + +echo "       refresh: \n\n"; + +if ($is_webphone == 'Y') + {echo "       webphone +\n\n";} +else + {echo "       \n\n";} + +if ($webphone_bufh > 10) + {echo "
\n";} +echo "
\n\n"; + + +if ($adastats<2) + {echo "       + VIEW MORE";} +else + {echo "       - VIEW LESS";} +if ($UGdisplay>0) + {echo "       HIDE USER GROUP";} +else + {echo "       VIEW USER GROUP";} +if ($SERVdisplay>0) + {echo "       HIDE SERVER INFO";} +else + {echo "       SHOW SERVER INFO";} +if ($CALLSdisplay>0) + {echo "       HIDE WAITING CALLS";} +else + {echo "       SHOW WAITING CALLS";} +if ($ALLINGROUPstats>0) + {echo "       HIDE IN-GROUP STATS";} +else + {echo "       SHOW IN-GROUP STATS";} +if ($PHONEdisplay>0) + {echo "       HIDE PHONES";} +else + {echo "       SHOW PHONES";} +if ($CUSTPHONEdisplay>0) + {echo "       HIDE CUSTPHONES";} +else + {echo "       SHOW CUSTPHONES";} + +#echo "
"; +##### END header formatting ##### + +#echo "
"; + +echo "\n"; + + + + + + + + +?> +
+ + +