From 9edbb26b6f83f7720f347fd0a4a8681b39623f26 Mon Sep 17 00:00:00 2001 From: mattf Date: Sat, 16 Jan 2010 14:32:00 +0000 Subject: [PATCH] DID related fixes added presets to webforms and script as allowed variables git-svn-id: svn://192.168.202.10@1307 3d104415-ff17-0410-8863-d5cf3c621b8a --- agi/agi-DID_route.agi | 47 +- docs/conf_examples/extensions.conf.sample | 43 +- docs/conf_examples/extensions.conf.sample-1.4 | 36 +- www/agc/vdc_script_display.php | 40 +- www/agc/vicidial.php | 164 ++- www/vicidial/AST_DIDstats.php | 1066 ++++++++--------- www/vicidial/admin.php | 57 +- 7 files changed, 829 insertions(+), 624 deletions(-) diff --git a/agi/agi-DID_route.agi b/agi/agi-DID_route.agi index 911176af..9b432a33 100644 --- a/agi/agi-DID_route.agi +++ b/agi/agi-DID_route.agi @@ -6,11 +6,12 @@ # send the calls to various places depending on the settings for each DID. # # -# You need to put a line similar to this below in your extensions.conf file: +# You need to put a line similar to this below in your extensions.conf file in +# the context for where incoming calls go from your trunks: # ;inbound DID catch-all: #exten => _X.,1,AGI(agi-DID_route.agi) # -# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 # # changes: # 81007-0324 - First Build @@ -20,6 +21,7 @@ # 90507-1145 - Added CALLMENU option # 90825-2252 - Changed PHONE to route using dialplan number # 91122-0743 - Added QueueMetrics logging as DID INFO entries +# 100116-0631 - Logging bug fixes # $script = 'agi-DID_route.agi'; @@ -44,10 +46,10 @@ $now_date_epoch = time(); $now_date = "$year-$mon-$mday $hour:$min:$sec"; $CLInow_date = "$year-$mon-$mday\\ $hour:$min:$sec"; $start_time=$now_date; - $CIDdate = "$mon$mday$hour$min$sec"; - $tsSQLdate = "$year$mon$mday$hour$min$sec"; - $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; - $SQLdateBEGIN = $SQLdate; +$CIDdate = "$mon$mday$hour$min$sec"; +$tsSQLdate = "$year$mon$mday$hour$min$sec"; +$SQLdate = "$year-$mon-$mday $hour:$min:$sec"; +$SQLdateBEGIN = $SQLdate; # default path to astguiclient configuration file: $PATHconf = '/etc/astguiclient.conf'; @@ -174,6 +176,7 @@ if ( (!$callerid) or ($callerid =~ /unknown/) ) ### Grab DID values from the database +$DIDs_in_system=0; $stmtA = "SELECT did_id,did_pattern,did_description,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup,menu_id FROM vicidial_inbound_dids where did_pattern = '$extension' and did_active='Y';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -195,24 +198,19 @@ if ($sthArows > 0) $user_unavailable_action = $aryA[11]; $user_route_settings_ingroup = $aryA[12]; $menu_id = $aryA[13]; + + $DIDs_in_system++; } $sthA->finish(); -$stmtA = "INSERT INTO vicidial_did_log SET uniqueid='$uniqueid',channel='$channel',server_ip='$VARserver_ip',caller_id_number='$callerid',caller_id_name='$calleridname',extension='$extension',call_date='$SQLdate',did_id='$did_id',did_route='$did_route';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} -$affected_rowsL = $dbhA->do($stmtA); -if ($AGILOG) {$agi_string = "-- DID LOG : |$affected_rowsL|$stmtA|"; &agi_output;} - -if ($AGILOG) {$did_string = "$SQLdate|$uniqueid|$channel|$extension|$callerid|$calleridname|$did_id|$did_route|"; &did_output;} - if ($sthArows < 1) { ### Grab DID values from the database for a default DID pattern if there is one $stmtA = "SELECT did_id,did_pattern,did_description,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup,menu_id FROM vicidial_inbound_dids where did_pattern = 'default' and did_active='Y';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows > 0) + $DIDs_in_system=$sthA->rows; + if ($DIDs_in_system > 0) { @aryA = $sthA->fetchrow_array; $did_id = $aryA[0]; @@ -231,12 +229,21 @@ if ($sthArows < 1) $menu_id = $aryA[13]; } $sthA->finish(); + } - if ($sthArows < 1) - { - ### if nothing found, exit script - exit; - } +### Log the call +$stmtA = "INSERT INTO vicidial_did_log SET uniqueid='$uniqueid',channel='$channel',server_ip='$VARserver_ip',caller_id_number='$callerid',caller_id_name='$calleridname',extension='$extension',call_date='$SQLdate',did_id='$did_id',did_route='$did_route';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} +$affected_rowsL = $dbhA->do($stmtA); +if ($AGILOG) {$agi_string = "-- DID LOG : |$affected_rowsL|$stmtA|"; &agi_output;} + +if ($AGILOG) {$did_string = "$SQLdate|$uniqueid|$channel|$extension|$callerid|$calleridname|$did_id|$did_route|"; &did_output;} + +if ($DIDs_in_system < 1) + { + ### if nothing found, exit script + if ($AGILOG) {$did_string = "NO default DID DEFINED! EXITING... $SQLdate|$uniqueid|$channel|$extension|$callerid|$calleridname|"; &did_output;} + exit; } ### Grab Server values from the database diff --git a/docs/conf_examples/extensions.conf.sample b/docs/conf_examples/extensions.conf.sample index 2cb46e3d..69d048eb 100644 --- a/docs/conf_examples/extensions.conf.sample +++ b/docs/conf_examples/extensions.conf.sample @@ -176,26 +176,37 @@ exten => _9119XXXXXXXX,1,Dial(${TRUNKblind}/9998819112,55,to) ; exten => _91NXXNXXXXXX,3,Hangup ; special extensions for North America to catch invalid phone numbers ; exten => _91XXX[0-1]XXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXX[0-1]XXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXX[0-1]XXXXXX,3,Hangup +; exten => _91XXX[0-1]XXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXX[0-1]XXXXXX,n,Hangup ; exten => _91[0-1]XXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91[0-1]XXXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91[0-1]XXXXXXXXX,3,Hangup -; exten => _91XXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXXXXXXXX,3,Hangup +; exten => _91[0-1]XXXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91[0-1]XXXXXXXXX,n,Hangup +; exten => _91XXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) +; exten => _91XXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXX,n,Hangup +; exten => _91XXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) +; exten => _91XXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXX,n,Hangup ; exten => _91XXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXXXXXXX,3,Hangup +; exten => _91XXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXXX,n,Hangup +; exten => _91XXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) +; exten => _91XXXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXXXX,n,Hangup ; exten => _91XXXXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXXXXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXXXXXXXXXX,3,Hangup +; exten => _91XXXXXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXXXXXX,n,Hangup ; exten => _91XXXXXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXXXXXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXXXXXXXXXXX,3,Hangup +; exten => _91XXXXXXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXXXXXXX,n,Hangup ; exten => _91XXXXXXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXXXXXXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXXXXXXXXXXXX,3,Hangup +; exten => _91XXXXXXXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXXXXXXXX,n,Hangup +; dial a USA long distance outbound number through the loopback-no-log context +; exten => _91NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) +; exten => _91NXXNXXXXXX,2,Dial(${TRUNKloop}/888${EXTEN:2},55,o) +; exten => _91NXXNXXXXXX,3,Hangup +;exten => 888NXXNXXXXXX,1,Goto(loopback-no-log,91${EXTEN:3},1) exten => 8889990011112,1,Goto(loopback-no-log,9990011112,1) @@ -284,7 +295,7 @@ exten => 8889990011112,1,Goto(loopback-no-log,9990011112,1) exten => _90009.,1,Answer ; Answer the line exten => _90009.,2,Dial(${TRUNKloop}/9${EXTEN},,to) exten => _90009.,3,Hangup -exten => _990009.,1,Answer ; Answer the line +exten => _990009.,1,Answer ; Answer the line, Sometimes needs to be removed exten => _990009.,2,AGI(agi-VDAD_ALL_inbound.agi,CLOSER-----LB-----CL_TESTCAMP-----7275551212-----Closer-----park----------999-----1) exten => _990009.,3,Hangup ; DID forwarded calls diff --git a/docs/conf_examples/extensions.conf.sample-1.4 b/docs/conf_examples/extensions.conf.sample-1.4 index 27b1d803..649df169 100644 --- a/docs/conf_examples/extensions.conf.sample-1.4 +++ b/docs/conf_examples/extensions.conf.sample-1.4 @@ -180,26 +180,32 @@ exten => _9119XXXXXXXX,1,Dial(${TRUNKblind}/9998819112,55,to) ; exten => _91NXXNXXXXXX,3,Hangup ; special extensions for North America to catch invalid phone numbers ; exten => _91XXX[0-1]XXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXX[0-1]XXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXX[0-1]XXXXXX,3,Hangup +; exten => _91XXX[0-1]XXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXX[0-1]XXXXXX,n,Hangup ; exten => _91[0-1]XXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91[0-1]XXXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91[0-1]XXXXXXXXX,3,Hangup -; exten => _91XXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXXXXXXXX,3,Hangup +; exten => _91[0-1]XXXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91[0-1]XXXXXXXXX,n,Hangup +; exten => _91XXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) +; exten => _91XXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXX,n,Hangup +; exten => _91XXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) +; exten => _91XXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXX,n,Hangup ; exten => _91XXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXXXXXXX,3,Hangup +; exten => _91XXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXXX,n,Hangup +; exten => _91XXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) +; exten => _91XXXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXXXX,n,Hangup ; exten => _91XXXXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXXXXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXXXXXXXXXX,3,Hangup +; exten => _91XXXXXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXXXXXX,n,Hangup ; exten => _91XXXXXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXXXXXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXXXXXXXXXXX,3,Hangup +; exten => _91XXXXXXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXXXXXXX,n,Hangup ; exten => _91XXXXXXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) -; exten => _91XXXXXXXXXXXXX,2,Dial(${TRUNKloop}/8889990011112,,to) -; exten => _91XXXXXXXXXXXXX,3,Hangup +; exten => _91XXXXXXXXXXXXX,n,Dial(${TRUNKloop}/8889990011112,,to) +; exten => _91XXXXXXXXXXXXX,n,Hangup ; dial a USA long distance outbound number through the loopback-no-log context ; exten => _91NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log) ; exten => _91NXXNXXXXXX,2,Dial(${TRUNKloop}/888${EXTEN:2},55,o) diff --git a/www/agc/vdc_script_display.php b/www/agc/vdc_script_display.php index 13775bab..7814428e 100644 --- a/www/agc/vdc_script_display.php +++ b/www/agc/vdc_script_display.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 # # This script is designed display the contents of the SCRIPT tab in the agent interface # @@ -10,10 +10,11 @@ # 90827-1548 - Added list override script option # 91204-1913 - Added recording_filename and recording_id variables # 91211-1103 - Added user_custom_... variables +# 100116-0702 - Added preset variables # -$version = '2.2.0-4'; -$build = '91211-1103'; +$version = '2.2.0-5'; +$build = '100116-0702'; require("dbconnect.php"); @@ -143,7 +144,22 @@ if (isset($_GET["user_custom_four"])) {$user_custom_four=$_GET["user_custom_four elseif (isset($_POST["user_custom_four"])) {$user_custom_four=$_POST["user_custom_four"];} if (isset($_GET["user_custom_five"])) {$user_custom_five=$_GET["user_custom_five"];} elseif (isset($_POST["user_custom_five"])) {$user_custom_five=$_POST["user_custom_five"];} - +if (isset($_GET["preset_number_a"])) {$preset_number_a=$_GET["preset_number_a"];} + elseif (isset($_POST["preset_number_a"])) {$preset_number_a=$_POST["preset_number_a"];} +if (isset($_GET["preset_number_b"])) {$preset_number_b=$_GET["preset_number_b"];} + elseif (isset($_POST["preset_number_b"])) {$preset_number_b=$_POST["preset_number_b"];} +if (isset($_GET["preset_number_c"])) {$preset_number_c=$_GET["preset_number_c"];} + elseif (isset($_POST["preset_number_c"])) {$preset_number_c=$_POST["preset_number_c"];} +if (isset($_GET["preset_number_d"])) {$preset_number_d=$_GET["preset_number_d"];} + elseif (isset($_POST["preset_number_d"])) {$preset_number_d=$_POST["preset_number_d"];} +if (isset($_GET["preset_number_e"])) {$preset_number_e=$_GET["preset_number_e"];} + elseif (isset($_POST["preset_number_e"])) {$preset_number_e=$_POST["preset_number_e"];} +if (isset($_GET["preset_number_f"])) {$preset_number_f=$_GET["preset_number_f"];} + elseif (isset($_POST["preset_number_f"])) {$preset_number_f=$_POST["preset_number_f"];} +if (isset($_GET["preset_dtmf_a"])) {$preset_dtmf_a=$_GET["preset_dtmf_a"];} + elseif (isset($_POST["preset_dtmf_a"])) {$preset_dtmf_a=$_POST["preset_dtmf_a"];} +if (isset($_GET["preset_dtmf_b"])) {$preset_dtmf_b=$_GET["preset_dtmf_b"];} + elseif (isset($_POST["preset_dtmf_b"])) {$preset_dtmf_b=$_POST["preset_dtmf_b"];} if (isset($_GET["ScrollDIV"])) {$ScrollDIV=$_GET["ScrollDIV"];} elseif (isset($_POST["ScrollDIV"])) {$ScrollDIV=$_POST["ScrollDIV"];} if (isset($_GET["ignore_list_script"])) {$ignore_list_script=$_GET["ignore_list_script"];} @@ -316,6 +332,14 @@ if (eregi("iframe src",$script_text)) $user_custom_three = eregi_replace(' ','+',$user_custom_three); $user_custom_four = eregi_replace(' ','+',$user_custom_four); $user_custom_five = eregi_replace(' ','+',$user_custom_five); + $preset_number_a = eregi_replace(' ','+',$preset_number_a); + $preset_number_b = eregi_replace(' ','+',$preset_number_b); + $preset_number_c = eregi_replace(' ','+',$preset_number_c); + $preset_number_d = eregi_replace(' ','+',$preset_number_d); + $preset_number_e = eregi_replace(' ','+',$preset_number_e); + $preset_number_f = eregi_replace(' ','+',$preset_number_f); + $preset_dtmf_a = eregi_replace(' ','+',$preset_dtmf_a); + $preset_dtmf_b = eregi_replace(' ','+',$preset_dtmf_b); } $script_text = eregi_replace('--A--lead_id--B--',"$lead_id",$script_text); @@ -381,6 +405,14 @@ $script_text = eregi_replace('--A--user_custom_two--B--',"$user_custom_two",$scr $script_text = eregi_replace('--A--user_custom_three--B--',"$user_custom_three",$script_text); $script_text = eregi_replace('--A--user_custom_four--B--',"$user_custom_four",$script_text); $script_text = eregi_replace('--A--user_custom_five--B--',"$user_custom_five",$script_text); +$script_text = eregi_replace('--A--preset_number_a--B--',"$preset_number_a",$script_text); +$script_text = eregi_replace('--A--preset_number_b--B--',"$preset_number_b",$script_text); +$script_text = eregi_replace('--A--preset_number_c--B--',"$preset_number_c",$script_text); +$script_text = eregi_replace('--A--preset_number_d--B--',"$preset_number_d",$script_text); +$script_text = eregi_replace('--A--preset_number_e--B--',"$preset_number_e",$script_text); +$script_text = eregi_replace('--A--preset_number_f--B--',"$preset_number_f",$script_text); +$script_text = eregi_replace('--A--preset_dtmf_a--B--',"$preset_dtmf_a",$script_text); +$script_text = eregi_replace('--A--preset_dtmf_b--B--',"$preset_dtmf_b",$script_text); $script_text = eregi_replace("\n","
",$script_text); $script_text = stripslashes($script_text); diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index 8dd5bd2e..43179bdd 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -271,10 +271,11 @@ # 100107-0108 - Added dynamic screen size based on login screen browser dimensions # 100109-0801 - Added ALTNUM alt number status, fixed alt number dialing from setting # 100109-1338 - Fixed Manual dial live call detection +# 100116-0709 - Added presets to script and web form variables # -$version = '2.2.0-249'; -$build = '100109-1338'; +$version = '2.2.0-250'; +$build = '100116-0709'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=64; $one_mysql_log=0; @@ -4982,6 +4983,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -5070,6 +5078,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -5379,6 +5394,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -5467,6 +5489,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -5577,6 +5606,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -5956,6 +5992,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -6681,6 +6724,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -6769,6 +6819,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -6862,6 +6919,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -7036,6 +7100,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -7154,6 +7225,13 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} "&user_custom_three=" + VU_custom_three + '' + "&user_custom_four=" + VU_custom_four + '' + "&user_custom_five=" + VU_custom_five + '' + + "&preset_number_a=" + CalL_XC_a_NuMber + '' + + "&preset_number_b=" + CalL_XC_b_NuMber + '' + + "&preset_number_c=" + CalL_XC_c_NuMber + '' + + "&preset_number_d=" + CalL_XC_d_NuMber + '' + + "&preset_number_e=" + CalL_XC_e_NuMber + '' + + "&preset_dtmf_a=" + CalL_XC_a_Dtmf + '' + + "&preset_dtmf_b=" + CalL_XC_b_Dtmf + '' + webform_session; var regWFspace = new RegExp(" ","ig"); @@ -8735,11 +8813,11 @@ else var RGplus = new RegExp(" ","g"); var RGiframe = new RegExp("iframe","gi"); -var xtest; -xtest=unescape(encoded); -encoded=utf8_decode(xtest); + var xtest; + xtest=unescape(encoded); + encoded=utf8_decode(xtest); - if (scriptformat == 'YES') + if (scriptformat == 'YES') { var SCvendor_lead_code = document.vicidial_form.vendor_lead_code.value; var SCsource_id = source_id; @@ -8799,6 +8877,13 @@ encoded=utf8_decode(xtest); var SCuser_custom_three = VU_custom_three; var SCuser_custom_four = VU_custom_four; var SCuser_custom_five = VU_custom_five; + var SCpreset_number_a = CalL_XC_a_NuMber; + var SCpreset_number_b = CalL_XC_b_NuMber; + var SCpreset_number_c = CalL_XC_c_NuMber; + var SCpreset_number_d = CalL_XC_d_NuMber; + var SCpreset_number_e = CalL_XC_e_NuMber; + var SCpreset_dtmf_a = CalL_XC_a_Dtmf; + var SCpreset_dtmf_b = CalL_XC_b_Dtmf; var SCweb_vars = LIVE_web_vars; if (encoded.match(RGiframe)) @@ -8859,6 +8944,13 @@ encoded=utf8_decode(xtest); SCuser_custom_three = SCuser_custom_three.replace(RGplus,'+'); SCuser_custom_four = SCuser_custom_four.replace(RGplus,'+'); SCuser_custom_five = SCuser_custom_five.replace(RGplus,'+'); + SCpreset_number_a = SCpreset_number_a.replace(RGplus,'+'); + SCpreset_number_b = SCpreset_number_b.replace(RGplus,'+'); + SCpreset_number_c = SCpreset_number_c.replace(RGplus,'+'); + SCpreset_number_d = SCpreset_number_d.replace(RGplus,'+'); + SCpreset_number_e = SCpreset_number_e.replace(RGplus,'+'); + SCpreset_dtmf_a = SCpreset_dtmf_a.replace(RGplus,'+'); + SCpreset_dtmf_b = SCpreset_dtmf_b.replace(RGplus,'+'); SCweb_vars = SCweb_vars.replace(RGplus,'+'); } @@ -8920,6 +9012,13 @@ encoded=utf8_decode(xtest); var RGuser_custom_three = new RegExp("--A--user_custom_three--B--","g"); var RGuser_custom_four = new RegExp("--A--user_custom_four--B--","g"); var RGuser_custom_five = new RegExp("--A--user_custom_five--B--","g"); + var RGpreset_number_a = new RegExp("--A--preset_number_a--B--","g"); + var RGpreset_number_b = new RegExp("--A--preset_number_b--B--","g"); + var RGpreset_number_c = new RegExp("--A--preset_number_c--B--","g"); + var RGpreset_number_d = new RegExp("--A--preset_number_d--B--","g"); + var RGpreset_number_e = new RegExp("--A--preset_number_e--B--","g"); + var RGpreset_dtmf_a = new RegExp("--A--preset_dtmf_a--B--","g"); + var RGpreset_dtmf_b = new RegExp("--A--preset_dtmf_b--B--","g"); var RGweb_vars = new RegExp("--A--web_vars--B--","g"); encoded = encoded.replace(RGvendor_lead_code, SCvendor_lead_code); @@ -8980,31 +9079,38 @@ encoded=utf8_decode(xtest); encoded = encoded.replace(RGuser_custom_three, SCuser_custom_three); encoded = encoded.replace(RGuser_custom_four, SCuser_custom_four); encoded = encoded.replace(RGuser_custom_five, SCuser_custom_five); + encoded = encoded.replace(RGpreset_number_a, SCpreset_number_a); + encoded = encoded.replace(RGpreset_number_b, SCpreset_number_b); + encoded = encoded.replace(RGpreset_number_c, SCpreset_number_c); + encoded = encoded.replace(RGpreset_number_d, SCpreset_number_d); + encoded = encoded.replace(RGpreset_number_e, SCpreset_number_e); + encoded = encoded.replace(RGpreset_dtmf_a, SCpreset_dtmf_a); + encoded = encoded.replace(RGpreset_dtmf_b, SCpreset_dtmf_b); encoded = encoded.replace(RGweb_vars, SCweb_vars); } -decoded=encoded; // simple no ? -decoded = decoded.replace(RGnl, "
"); -// while (i < encoded.length) { -// var ch = encoded.charAt(i); -// if (ch == "%") { -// if (i < (encoded.length-2) -// && HEXCHAR.indexOf(encoded.charAt(i+1)) != -1 -// && HEXCHAR.indexOf(encoded.charAt(i+2)) != -1 ) { -// decoded += unescape( encoded.substr(i,3) ); -// i += 3; -// } else { -// alert( 'Bad escape combo near ...' + encoded.substr(i) ); -// decoded += "%[ERR]"; -// i++; -// } -// } else { -// decoded += ch; -// i++; -// } -// } // while -// decoded = decoded.replace(RGnl, "
"); -// - return false; + decoded=encoded; // simple no ? + decoded = decoded.replace(RGnl, "
"); + // while (i < encoded.length) { + // var ch = encoded.charAt(i); + // if (ch == "%") { + // if (i < (encoded.length-2) + // && HEXCHAR.indexOf(encoded.charAt(i+1)) != -1 + // && HEXCHAR.indexOf(encoded.charAt(i+2)) != -1 ) { + // decoded += unescape( encoded.substr(i,3) ); + // i += 3; + // } else { + // alert( 'Bad escape combo near ...' + encoded.substr(i) ); + // decoded += "%[ERR]"; + // i++; + // } + // } else { + // decoded += ch; + // i++; + // } + // } // while + // decoded = decoded.replace(RGnl, "
"); + // + return false; }; diff --git a/www/vicidial/AST_DIDstats.php b/www/vicidial/AST_DIDstats.php index 788e38d0..c7cde028 100644 --- a/www/vicidial/AST_DIDstats.php +++ b/www/vicidial/AST_DIDstats.php @@ -1,11 +1,12 @@ LICENSE: AGPLv2 +# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 # # CHANGES # # 90601-1443 - First build +# 100116-0620 - Bug fixes # require("dbconnect.php"); @@ -29,8 +30,8 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} -$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); -$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); +$PHP_AUTH_USER = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_USER); +$PHP_AUTH_PW = ereg_replace("[^-_0-9a-zA-Z]","",$PHP_AUTH_PW); if (strlen($shift)<2) {$shift='ALL';} @@ -40,12 +41,10 @@ $stmt = "SELECT use_non_latin FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); -$i=0; -while ($i < $qm_conf_ct) +if ($qm_conf_ct > 0) { $row=mysql_fetch_row($rslt); - $non_latin = $row[0]; - $i++; + $non_latin = $row[0]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -58,7 +57,7 @@ $row=mysql_fetch_row($rslt); $auth=$row[0]; - if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) +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"); @@ -124,9 +123,9 @@ else echo "\n"; echo "Inbound DIDs Report\n"; - $short_header=1; +$short_header=1; - require("admin_header.php"); +require("admin_header.php"); if ($DB > 0) { @@ -145,21 +144,14 @@ echo " to
\n"; echo "\n"; echo "\n"; echo "\n"; @@ -186,85 +178,85 @@ echo "
";
 
 
 if (!$group)
-{
-echo "\n\n";
-echo "PLEASE SELECT A DID AND DATE RANGE ABOVE AND CLICK SUBMIT\n";
-}
+	{
+	echo "\n\n";
+	echo "PLEASE SELECT A DID AND DATE RANGE ABOVE AND CLICK SUBMIT\n";
+	}
 
 else
-{
-### FOR SHIFTS IT IS BEST TO STICK TO 15-MINUTE INCREMENTS FOR START TIMES ###
+	{
+	### FOR SHIFTS IT IS BEST TO STICK TO 15-MINUTE INCREMENTS FOR START TIMES ###
 
-if ($shift == 'AM') 
-	{
-#	$time_BEGIN=$AM_shift_BEGIN;
-#	$time_END=$AM_shift_END;
-#	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
-#	if (strlen($time_END) < 6) {$time_END = "15:15:00";}
-	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}   
-	if (strlen($time_END) < 6) {$time_END = "11:59:59";}
-#	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "12:00:00";}   
-#	if (strlen($time_END) < 6) {$time_END = "11:59:59";}
-	}
-if ($shift == 'PM') 
-	{
-#	$time_BEGIN=$PM_shift_BEGIN;
-#	$time_END=$PM_shift_END;
-#	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
-#	if (strlen($time_END) < 6) {$time_END = "23:15:00";}
-	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "12:00:00";}
-	if (strlen($time_END) < 6) {$time_END = "23:59:59";}
-	}
-if ($shift == 'ALL') 
-	{
-	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
-	if (strlen($time_END) < 6) {$time_END = "23:59:59";}
-	}
-if ($shift == 'DAYTIME') 
-	{
-	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "08:45:00";}
-	if (strlen($time_END) < 6) {$time_END = "00:59:59";}
-	}
-if ($shift == '10AM-6PM') 
-	{
-	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "10:00:00";}
-	if (strlen($time_END) < 6) {$time_END = "17:59:59";}
-	}
-if ($shift == '9AM-1AM') 
-	{
-	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "09:00:00";}
-	if (strlen($time_END) < 6) {$time_END = "00:59:59";}
-	}
-if ($shift == '845-1745') 
-	{
-	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "08:45:00";}
-	if (strlen($time_END) < 6) {$time_END = "17:44:59";}
-	}
-if ($shift == '1745-100') 
-	{
-	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "17:45:00";}
-	if (strlen($time_END) < 6) {$time_END = "00:59:59";}
-	}
+	if ($shift == 'AM') 
+		{
+	#	$time_BEGIN=$AM_shift_BEGIN;
+	#	$time_END=$AM_shift_END;
+	#	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";}   
+	#	if (strlen($time_END) < 6) {$time_END = "15:15:00";}
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}   
+		if (strlen($time_END) < 6) {$time_END = "11:59:59";}
+	#	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "12:00:00";}   
+	#	if (strlen($time_END) < 6) {$time_END = "11:59:59";}
+		}
+	if ($shift == 'PM') 
+		{
+	#	$time_BEGIN=$PM_shift_BEGIN;
+	#	$time_END=$PM_shift_END;
+	#	if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";}
+	#	if (strlen($time_END) < 6) {$time_END = "23:15:00";}
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "12:00:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+		}
+	if ($shift == 'ALL') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";}
+		if (strlen($time_END) < 6) {$time_END = "23:59:59";}
+		}
+	if ($shift == 'DAYTIME') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "08:45:00";}
+		if (strlen($time_END) < 6) {$time_END = "00:59:59";}
+		}
+	if ($shift == '10AM-6PM') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "10:00:00";}
+		if (strlen($time_END) < 6) {$time_END = "17:59:59";}
+		}
+	if ($shift == '9AM-1AM') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "09:00:00";}
+		if (strlen($time_END) < 6) {$time_END = "00:59:59";}
+		}
+	if ($shift == '845-1745') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "08:45:00";}
+		if (strlen($time_END) < 6) {$time_END = "17:44:59";}
+		}
+	if ($shift == '1745-100') 
+		{
+		if (strlen($time_BEGIN) < 6) {$time_BEGIN = "17:45:00";}
+		if (strlen($time_END) < 6) {$time_END = "00:59:59";}
+		}
 
-$query_date_BEGIN = "$query_date $time_BEGIN";   
-$query_date_END = "$end_date $time_END";
+	$query_date_BEGIN = "$query_date $time_BEGIN";   
+	$query_date_END = "$end_date $time_END";
 
-$SQdate_ARY =	explode(' ',$query_date_BEGIN);
-$SQday_ARY =	explode('-',$SQdate_ARY[0]);
-$SQtime_ARY =	explode(':',$SQdate_ARY[1]);
-$EQdate_ARY =	explode(' ',$query_date_END);
-$EQday_ARY =	explode('-',$EQdate_ARY[0]);
-$EQtime_ARY =	explode(':',$EQdate_ARY[1]);
+	$SQdate_ARY =	explode(' ',$query_date_BEGIN);
+	$SQday_ARY =	explode('-',$SQdate_ARY[0]);
+	$SQtime_ARY =	explode(':',$SQdate_ARY[1]);
+	$EQdate_ARY =	explode(' ',$query_date_END);
+	$EQday_ARY =	explode('-',$EQdate_ARY[0]);
+	$EQtime_ARY =	explode(':',$EQdate_ARY[1]);
 
-$SQepochDAY = mktime(0, 0, 0, $SQday_ARY[1], $SQday_ARY[2], $SQday_ARY[0]);
-$SQepoch = mktime($SQtime_ARY[0], $SQtime_ARY[1], $SQtime_ARY[2], $SQday_ARY[1], $SQday_ARY[2], $SQday_ARY[0]);
-$EQepoch = mktime($EQtime_ARY[0], $EQtime_ARY[1], $EQtime_ARY[2], $EQday_ARY[1], $EQday_ARY[2], $EQday_ARY[0]);
+	$SQepochDAY = mktime(0, 0, 0, $SQday_ARY[1], $SQday_ARY[2], $SQday_ARY[0]);
+	$SQepoch = mktime($SQtime_ARY[0], $SQtime_ARY[1], $SQtime_ARY[2], $SQday_ARY[1], $SQday_ARY[2], $SQday_ARY[0]);
+	$EQepoch = mktime($EQtime_ARY[0], $EQtime_ARY[1], $EQtime_ARY[2], $EQday_ARY[1], $EQday_ARY[2], $EQday_ARY[0]);
 
-$SQsec = ( ($SQtime_ARY[0] * 3600) + ($SQtime_ARY[1] * 60) + ($SQtime_ARY[2] * 1) );
-$EQsec = ( ($EQtime_ARY[0] * 3600) + ($EQtime_ARY[1] * 60) + ($EQtime_ARY[2] * 1) );
+	$SQsec = ( ($SQtime_ARY[0] * 3600) + ($SQtime_ARY[1] * 60) + ($SQtime_ARY[2] * 1) );
+	$EQsec = ( ($EQtime_ARY[0] * 3600) + ($EQtime_ARY[1] * 60) + ($EQtime_ARY[2] * 1) );
 
-$DURATIONsec = ($EQepoch - $SQepoch);
-$DURATIONday = intval( ($DURATIONsec / 86400) + 1 );
+	$DURATIONsec = ($EQepoch - $SQepoch);
+	$DURATIONday = intval( ($DURATIONsec / 86400) + 1 );
 
 	if ( ($EQsec < $SQsec) and ($DURATIONday < 1) )
 		{
@@ -273,281 +265,281 @@ $DURATIONday = intval( ($DURATIONsec / 86400) + 1 );
 		$DURATIONday++;
 		}
 
-echo "Inbound DID Report                      $NOW_TIME\n";
-echo "\n";
-echo "Time range $DURATIONday days: $query_date_BEGIN to $query_date_END\n\n";
-#echo "Time range day sec: $SQsec - $EQsec   Day range in epoch: $SQepoch - $EQepoch   Start: $SQepochDAY\n";
+	echo "Inbound DID Report                      $NOW_TIME\n";
+	echo "\n";
+	echo "Time range $DURATIONday days: $query_date_BEGIN to $query_date_END\n\n";
+	#echo "Time range day sec: $SQsec - $EQsec   Day range in epoch: $SQepoch - $EQepoch   Start: $SQepochDAY\n";
 
-$d=0;
-while ($d < $DURATIONday)
-	{
-	$dSQepoch = ($SQepoch + ($d * 86400) );
-	$dEQepoch = ($SQepochDAY + ($EQsec + ($d * 86400) ) );
-
-	if ($EQsec < $SQsec)
+	$d=0;
+	while ($d < $DURATIONday)
 		{
-		$dEQepoch = ($dEQepoch + 86400);
-		}
+		$dSQepoch = ($SQepoch + ($d * 86400) );
+		$dEQepoch = ($SQepochDAY + ($EQsec + ($d * 86400) ) );
 
-	$daySTART[$d] = date("Y-m-d H:i:s", $dSQepoch);
-	$dayEND[$d] = date("Y-m-d H:i:s", $dEQepoch);
-
-	$d++;
-	}
-
-##########################################################################
-#########  CALCULATE ALL OF THE 15-MINUTE PERIODS NEEDED FOR ALL DAYS ####
-
-### BUILD HOUR:MIN DISPLAY ARRAY ###
-$i=0;
-$h=4;
-$j=0;
-$Zhour=1;
-$active_time=0;
-$hour =		($SQtime_ARY[0] - 1);
-$startSEC = ($SQsec - 900);
-$endSEC =	($SQsec - 1);
-if ($SQtime_ARY[1] > 14) 
-	{
-	$h=1;
-	$hour++;
-	if ($hour < 10) {$hour = "0$hour";}
-	}
-if ($SQtime_ARY[1] > 29) {$h=2;}
-if ($SQtime_ARY[1] > 44) {$h=3;}
-while ($i < 96)
-	{
-	$startSEC = ($startSEC + 900);
-	$endSEC = ($endSEC + 900);
-	$time = '      ';
-	if ($h >= 4)
-		{
-		$hour++;
-		if ($Zhour == '00') 
+		if ($EQsec < $SQsec)
 			{
-			$startSEC=0;
-			$endSEC=899;
+			$dEQepoch = ($dEQepoch + 86400);
 			}
-		$h=0;
-		if ($hour < 10) {$hour = "0$hour";}
-		$Stime="$hour:00";
-		$Etime="$hour:15";
-		$time = "+$Stime-$Etime+";
-		}
-	if ($h == 1)
-		{
-		$Stime="$hour:15";
-		$Etime="$hour:30";
-		$time = " $Stime-$Etime ";
-		}
-	if ($h == 2)
-		{
-		$Stime="$hour:30";
-		$Etime="$hour:45";
-		$time = " $Stime-$Etime ";
-		}
-	if ($h == 3)
-		{
-		$Zhour=$hour;
-		$Zhour++;
-		if ($Zhour < 10) {$Zhour = "0$Zhour";}
-		if ($Zhour == 24) {$Zhour = "00";}
-		$Stime="$hour:45";
-		$Etime="$Zhour:00";
-		$time = " $Stime-$Etime ";
-		if ($Zhour == '00') 
-			{$hour = ($Zhour - 1);}
+
+		$daySTART[$d] = date("Y-m-d H:i:s", $dSQepoch);
+		$dayEND[$d] = date("Y-m-d H:i:s", $dEQepoch);
+
+		$d++;
 		}
 
-	if ( ( ($startSEC >= $SQsec) and ($endSEC <= $EQsec) and ($EQsec > $SQsec) ) or 
-		( ($startSEC >= $SQsec) and ($EQsec < $SQsec) ) or 
-		( ($endSEC <= $EQsec) and ($EQsec < $SQsec) ) )
+	##########################################################################
+	#########  CALCULATE ALL OF THE 15-MINUTE PERIODS NEEDED FOR ALL DAYS ####
+
+	### BUILD HOUR:MIN DISPLAY ARRAY ###
+	$i=0;
+	$h=4;
+	$j=0;
+	$Zhour=1;
+	$active_time=0;
+	$hour =		($SQtime_ARY[0] - 1);
+	$startSEC = ($SQsec - 900);
+	$endSEC =	($SQsec - 1);
+	if ($SQtime_ARY[1] > 14) 
 		{
-		$HMdisplay[$j] =	$time;
-		$HMstart[$j] =		$Stime;
-		$HMend[$j] =		$Etime;
-		$HMSepoch[$j] =		$startSEC;
-		$HMEepoch[$j] =		$endSEC;
+		$h=1;
+		$hour++;
+		if ($hour < 10) {$hour = "0$hour";}
+		}
+	if ($SQtime_ARY[1] > 29) {$h=2;}
+	if ($SQtime_ARY[1] > 44) {$h=3;}
+	while ($i < 96)
+		{
+		$startSEC = ($startSEC + 900);
+		$endSEC = ($endSEC + 900);
+		$time = '      ';
+		if ($h >= 4)
+			{
+			$hour++;
+			if ($Zhour == '00') 
+				{
+				$startSEC=0;
+				$endSEC=899;
+				}
+			$h=0;
+			if ($hour < 10) {$hour = "0$hour";}
+			$Stime="$hour:00";
+			$Etime="$hour:15";
+			$time = "+$Stime-$Etime+";
+			}
+		if ($h == 1)
+			{
+			$Stime="$hour:15";
+			$Etime="$hour:30";
+			$time = " $Stime-$Etime ";
+			}
+		if ($h == 2)
+			{
+			$Stime="$hour:30";
+			$Etime="$hour:45";
+			$time = " $Stime-$Etime ";
+			}
+		if ($h == 3)
+			{
+			$Zhour=$hour;
+			$Zhour++;
+			if ($Zhour < 10) {$Zhour = "0$Zhour";}
+			if ($Zhour == 24) {$Zhour = "00";}
+			$Stime="$hour:45";
+			$Etime="$Zhour:00";
+			$time = " $Stime-$Etime ";
+			if ($Zhour == '00') 
+				{$hour = ($Zhour - 1);}
+			}
+
+		if ( ( ($startSEC >= $SQsec) and ($endSEC <= $EQsec) and ($EQsec > $SQsec) ) or 
+			( ($startSEC >= $SQsec) and ($EQsec < $SQsec) ) or 
+			( ($endSEC <= $EQsec) and ($EQsec < $SQsec) ) )
+			{
+			$HMdisplay[$j] =	$time;
+			$HMstart[$j] =		$Stime;
+			$HMend[$j] =		$Etime;
+			$HMSepoch[$j] =		$startSEC;
+			$HMEepoch[$j] =		$endSEC;
+
+			$j++;
+			}
+
+		$h++;
+		$i++;
+		}
+
+	$TOTintervals = $j;
+
+
+	### GRAB ALL RECORDS WITHIN RANGE FROM THE DATABASE ###
+	$stmt="select UNIX_TIMESTAMP(call_date),extension from vicidial_did_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  did_id IN($group_SQL);";
+	$rslt=mysql_query($stmt, $link);
+	if ($DB) {echo "$stmt\n";}
+	$records_to_grab = mysql_num_rows($rslt);
+	$i=0;
+	$extension[0]='';
+	while ($i < $records_to_grab)
+		{
+		$row=mysql_fetch_row($rslt);
+		$dt[$i] =			0;
+		$ut[$i] =			($row[0] - $SQepochDAY);
+		$extension[$i] =	$row[1];
+		while($ut[$i] >= 86400) 
+			{
+			$ut[$i] = ($ut[$i] - 86400);
+			$dt[$i]++;
+			}
+		if ( ($ut[$i] <= $EQsec) and ($EQsec < $SQsec) )
+			{
+			$dt[$i] = ($dt[$i] - 1);
+			}
+
+		$i++;
+		}
+
+	###################################################
+	### TOTALS DID SUMMARY SECTION ###
+	if (strlen($extension[0]) > 0)
+		{
+		echo "DID Summary:\n";
+		echo "+--------------------+--------------------------------+------------+------------+\n";
+		echo "| DID                | DESCRIPTION                    | ROUTE      | CALLS      |\n";
+		echo "+--------------------+--------------------------------+------------+------------+\n";
+
+
+		$stats_array = array_group_count($extension, 'desc');
+		$stats_array_ct = count($stats_array);
+
+		$d=0;
+		while ($d < $stats_array_ct)
+			{
+			$stat_record_array = explode(' ',$stats_array[$d]);
+			$stat_count = ($stat_record_array[0] + 0);
+			$stat_pattern = $stat_record_array[1];
+
+			$stmt="select did_description,did_route from vicidial_inbound_dids where did_pattern='$stat_pattern';";
+			$rslt=mysql_query($stmt, $link);
+			$details_to_grab = mysql_num_rows($rslt);
+			if ($details_to_grab > 0)
+				{
+				$row=mysql_fetch_row($rslt);
+				$stat_description =		$row[0];
+				$stat_route =			$row[1];
+				}
+
+			$totCALLS =			($totCALLS + $stat_count);
+			$stat_pattern =		sprintf("%-18s", $stat_pattern);
+			$stat_description =	sprintf("%-30s", $stat_description);
+			while (strlen($stat_description) > 30) {$stat_description = eregi_replace(".$",'',$stat_description);}
+			$stat_route =		sprintf("%-10s", $stat_route);
+			$stat_count =		sprintf("%10s", $stat_count);
+
+			$stat_pattern = "$stat_pattern";
+
+			echo "| $stat_pattern | $stat_description | $stat_route | $stat_count |\n";
+			$d++;
+			}
+
+			$FtotCALLS =	sprintf("%10s", $totCALLS);
+
+		echo "+--------------------+--------------------------------+------------+------------+\n";
+		echo "|                                                           TOTALS | $FtotCALLS |\n";
+		echo "+------------------------------------------------------------------+------------+\n";
+		}
+
+
+
+	### PARSE THROUGH ALL RECORDS AND GENERATE STATS ###
+	$MT[0]='0';
+	$totCALLS=0;
+	$totCALLSmax=0;
+	$totCALLSdate=$MT;
+	$qrtCALLS=$MT;
+	$qrtCALLSavg=$MT;
+	$qrtCALLSmax=$MT;
+	$j=0;
+	while ($j < $TOTintervals)
+		{
+		$jd__0[$j]=0; $jd_20[$j]=0; $jd_40[$j]=0; $jd_60[$j]=0; $jd_80[$j]=0; $jd100[$j]=0; $jd120[$j]=0; $jd121[$j]=0;
+		$Phd__0[$j]=0; $Phd_20[$j]=0; $Phd_40[$j]=0; $Phd_60[$j]=0; $Phd_80[$j]=0; $Phd100[$j]=0; $Phd120[$j]=0; $Phd121[$j]=0;
+		$qrtCALLS[$j]=0; $qrtCALLSmax[$j]=0;
+		$i=0;
+		while ($i < $records_to_grab)
+			{
+			if ( ($ut[$i] >= $HMSepoch[$j]) and ($ut[$i] <= $HMEepoch[$j]) )
+				{
+				$totCALLS++;
+				$qrtCALLS[$j]++;
+				$dtt = $dt[$i];
+				$totCALLSdate[$dtt]++;
+				if ($totCALLSmax < $ls[$i]) {$totCALLSmax = $ls[$i];}
+				if ($qrtCALLSmax[$j] < $ls[$i]) {$qrtCALLSmax[$j] = $ls[$i];}
+
+				if ($qs[$i] == 0) {$hd__0[$j]++;}
+				if ( ($qs[$i] > 0) and ($qs[$i] <= 20) ) {$hd_20[$j]++;}
+				if ( ($qs[$i] > 20) and ($qs[$i] <= 40) ) {$hd_40[$j]++;}
+				if ( ($qs[$i] > 40) and ($qs[$i] <= 60) ) {$hd_60[$j]++;}
+				if ( ($qs[$i] > 60) and ($qs[$i] <= 80) ) {$hd_80[$j]++;}
+				if ( ($qs[$i] > 80) and ($qs[$i] <= 100) ) {$hd100[$j]++;}
+				if ( ($qs[$i] > 100) and ($qs[$i] <= 120) ) {$hd120[$j]++;}
+				if ($qs[$i] > 120) {$hd121[$j]++;}
+				}
+			
+			$i++;
+			}
 
 		$j++;
 		}
 
-	$h++;
-	$i++;
-	}
-
-$TOTintervals = $j;
 
 
-### GRAB ALL RECORDS WITHIN RANGE FROM THE DATABASE ###
-$stmt="select UNIX_TIMESTAMP(call_date),extension from vicidial_did_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and  did_id IN($group_SQL);";
-$rslt=mysql_query($stmt, $link);
-if ($DB) {echo "$stmt\n";}
-$records_to_grab = mysql_num_rows($rslt);
-$i=0;
-$extension[0]='';
-while ($i < $records_to_grab)
-	{
-	$row=mysql_fetch_row($rslt);
-	$dt[$i] =			0;
-	$ut[$i] =			($row[0] - $SQepochDAY);
-	$extension[$i] =	$row[1];
-	while($ut[$i] >= 86400) 
-		{
-		$ut[$i] = ($ut[$i] - 86400);
-		$dt[$i]++;
-		}
-	if ( ($ut[$i] <= $EQsec) and ($EQsec < $SQsec) )
-		{
-		$dt[$i] = ($dt[$i] - 1);
-		}
 
-	$i++;
-	}
-
-###################################################
-### TOTALS DID SUMMARY SECTION ###
-if (strlen($extension[0]) > 0)
-	{
-	echo "DID Summary:\n";
-	echo "+--------------------+--------------------------------+------------+------------+\n";
-	echo "| DID                | DESCRIPTION                    | ROUTE      | CALLS      |\n";
-	echo "+--------------------+--------------------------------+------------+------------+\n";
-
-
-	$stats_array = array_group_count($extension, 'desc');
-	$stats_array_ct = count($stats_array);
+	###################################################
+	### TOTALS DATE SUMMARY SECTION ###
+	echo "\nDate Summary:\n";
+	echo "+-------------------------------------------+--------+\n";
+	echo "| SHIFT                                     |        |\n";
+	echo "| DATE-TIME RANGE                           | CALLS  |\n";
+	echo "+-------------------------------------------+--------+\n";
 
 	$d=0;
-	while ($d < $stats_array_ct)
+	while ($d < $DURATIONday)
 		{
-		$stat_record_array = explode(' ',$stats_array[$d]);
-		$stat_count = ($stat_record_array[0] + 0);
-		$stat_pattern = $stat_record_array[1];
+		if ($totCALLSdate[$d] < 1) {$totCALLSdate[$d]=0;}
 
-		$stmt="select did_description,did_route from vicidial_inbound_dids where did_pattern='$stat_pattern';";
-		$rslt=mysql_query($stmt, $link);
-		$details_to_grab = mysql_num_rows($rslt);
-		if ($details_to_grab > 0)
+		if ($totCALLSsecDATE[$d] > 0)
 			{
-			$row=mysql_fetch_row($rslt);
-			$stat_description =		$row[0];
-			$stat_route =			$row[1];
+			$totCALLSavgDATE[$d] = ($totCALLSsecDATE[$d] / $totCALLSdate[$d]);
+
+			$totTIME_M = ($totCALLSsecDATE[$d] / 60);
+			$totTIME_M_int = round($totTIME_M, 2);
+			$totTIME_M_int = intval("$totTIME_M");
+			$totTIME_S = ($totTIME_M - $totTIME_M_int);
+			$totTIME_S = ($totTIME_S * 60);
+			$totTIME_S = round($totTIME_S, 0);
+			if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";}
+			$totTIME_MS = "$totTIME_M_int:$totTIME_S";
+			$totTIME_MS =		sprintf("%8s", $totTIME_MS);
+			}
+		else 
+			{
+			$totCALLSavgDATE[$d] = 0;
+			$totTIME_MS='        ';
 			}
 
-		$totCALLS =			($totCALLS + $stat_count);
-		$stat_pattern =		sprintf("%-18s", $stat_pattern);
-		$stat_description =	sprintf("%-30s", $stat_description);
-		while (strlen($stat_description) > 30) {$stat_description = eregi_replace(".$",'',$stat_description);}
-		$stat_route =		sprintf("%-10s", $stat_route);
-		$stat_count =		sprintf("%10s", $stat_count);
+		if ($totCALLSdate[$d] < 1) 
+			{$totCALLSdate[$d]='';}
+		$totCALLSdate[$d] =	sprintf("%6s", $totCALLSdate[$d]);
 
-		$stat_pattern = "$stat_pattern";
-
-		echo "| $stat_pattern | $stat_description | $stat_route | $stat_count |\n";
+		echo "| $daySTART[$d] - $dayEND[$d] | $totCALLSdate[$d] |\n";
 		$d++;
 		}
 
-		$FtotCALLS =	sprintf("%10s", $totCALLS);
-
-	echo "+--------------------+--------------------------------+------------+------------+\n";
-	echo "|                                                           TOTALS | $FtotCALLS |\n";
-	echo "+------------------------------------------------------------------+------------+\n";
-	}
-
-
-
-### PARSE THROUGH ALL RECORDS AND GENERATE STATS ###
-$MT[0]='0';
-$totCALLS=0;
-$totCALLSmax=0;
-$totCALLSdate=$MT;
-$qrtCALLS=$MT;
-$qrtCALLSavg=$MT;
-$qrtCALLSmax=$MT;
-$j=0;
-while ($j < $TOTintervals)
-	{
-	$jd__0[$j]=0; $jd_20[$j]=0; $jd_40[$j]=0; $jd_60[$j]=0; $jd_80[$j]=0; $jd100[$j]=0; $jd120[$j]=0; $jd121[$j]=0;
-	$Phd__0[$j]=0; $Phd_20[$j]=0; $Phd_40[$j]=0; $Phd_60[$j]=0; $Phd_80[$j]=0; $Phd100[$j]=0; $Phd120[$j]=0; $Phd121[$j]=0;
-	$qrtCALLS[$j]=0; $qrtCALLSmax[$j]=0;
-	$i=0;
-	while ($i < $records_to_grab)
-		{
-		if ( ($ut[$i] >= $HMSepoch[$j]) and ($ut[$i] <= $HMEepoch[$j]) )
-			{
-			$totCALLS++;
-			$qrtCALLS[$j]++;
-			$dtt = $dt[$i];
-			$totCALLSdate[$dtt]++;
-			if ($totCALLSmax < $ls[$i]) {$totCALLSmax = $ls[$i];}
-			if ($qrtCALLSmax[$j] < $ls[$i]) {$qrtCALLSmax[$j] = $ls[$i];}
-
-			if ($qs[$i] == 0) {$hd__0[$j]++;}
-			if ( ($qs[$i] > 0) and ($qs[$i] <= 20) ) {$hd_20[$j]++;}
-			if ( ($qs[$i] > 20) and ($qs[$i] <= 40) ) {$hd_40[$j]++;}
-			if ( ($qs[$i] > 40) and ($qs[$i] <= 60) ) {$hd_60[$j]++;}
-			if ( ($qs[$i] > 60) and ($qs[$i] <= 80) ) {$hd_80[$j]++;}
-			if ( ($qs[$i] > 80) and ($qs[$i] <= 100) ) {$hd100[$j]++;}
-			if ( ($qs[$i] > 100) and ($qs[$i] <= 120) ) {$hd120[$j]++;}
-			if ($qs[$i] > 120) {$hd121[$j]++;}
-
-			}
-		
-		$i++;
-		}
-
-	$j++;
-	}
-
-
-
-
-###################################################
-### TOTALS DATE SUMMARY SECTION ###
-echo "\nDate Summary:\n";
-echo "+-------------------------------------------+--------+\n";
-echo "| SHIFT                                     |        |\n";
-echo "| DATE-TIME RANGE                           | CALLS  |\n";
-echo "+-------------------------------------------+--------+\n";
-
-$d=0;
-while ($d < $DURATIONday)
-	{
-	if ($totCALLSdate[$d] < 1) {$totCALLSdate[$d]=0;}
-
-	if ($totCALLSsecDATE[$d] > 0)
-		{
-		$totCALLSavgDATE[$d] = ($totCALLSsecDATE[$d] / $totCALLSdate[$d]);
-
-		$totTIME_M = ($totCALLSsecDATE[$d] / 60);
-		$totTIME_M_int = round($totTIME_M, 2);
-		$totTIME_M_int = intval("$totTIME_M");
-		$totTIME_S = ($totTIME_M - $totTIME_M_int);
-		$totTIME_S = ($totTIME_S * 60);
-		$totTIME_S = round($totTIME_S, 0);
-		if ($totTIME_S < 10) {$totTIME_S = "0$totTIME_S";}
-		$totTIME_MS = "$totTIME_M_int:$totTIME_S";
-		$totTIME_MS =		sprintf("%8s", $totTIME_MS);
-		}
-	else 
-		{
-		$totCALLSavgDATE[$d] = 0;
-		$totTIME_MS='        ';
-		}
-
-	if ($totCALLSdate[$d] < 1) {$totCALLSdate[$d]='';}
-	$totCALLSdate[$d] =	sprintf("%6s", $totCALLSdate[$d]);
-
-	echo "| $daySTART[$d] - $dayEND[$d] | $totCALLSdate[$d] |\n";
-	$d++;
-	}
-
 	$FtotCALLS =	sprintf("%6s", $totCALLS);
 
-echo "+-------------------------------------------+--------+\n";
-echo "|                                    TOTALS | $FtotCALLS |\n";
-echo "+-------------------------------------------+--------+\n";
+	echo "+-------------------------------------------+--------+\n";
+	echo "|                                    TOTALS | $FtotCALLS |\n";
+	echo "+-------------------------------------------+--------+\n";
 
 
 	## FORMAT OUTPUT ##
@@ -560,236 +552,236 @@ echo "+-------------------------------------------+--------+\n";
 		if ($qrtCALLS[$i] > 0)
 			{$qrtCALLSavg[$i] = ($qrtCALLSsec[$i] / $qrtCALLS[$i]);}
 
-		if ($qrtCALLS[$i] > $hi_hour_count) {$hi_hour_count = $qrtCALLS[$i];}
+		if ($qrtCALLS[$i] > $hi_hour_count) 
+			{$hi_hour_count = $qrtCALLS[$i];}
 
 		$i++;
 		}
 
-if ($hi_hour_count < 1)
-	{$hour_multiplier = 0;}
-else
-	{$hour_multiplier = (70 / $hi_hour_count);}
-if ($hi_hold_count < 1)
-	{$hold_multiplier = 0;}
-else
-	{$hold_multiplier = (70 / $hi_hold_count);}
-
-
-
-
-###################################################################
-#########  HOLD TIME, CALL AND DROP STATS 15-MINUTE INCREMENTS ####
-
-echo "\n";
-echo "---------- HOLD TIME, CALL AND DROP STATS\n";
-
-echo "";
-
-echo "";
-echo "\n";
-echo "GRAPH IN 15 MINUTE INCREMENTS OF AVERAGE HOLD TIME FOR CALLS TAKEN INTO THIS IN-GROUP\n";
-
-
-$k=1;
-$Mk=0;
-$call_scale = '0';
-while ($k <= 72) 
-	{
-	if ( ($k < 1) or ($hour_multiplier <= 0) )
-		{$scale_num = 70;}
+	if ($hi_hour_count < 1)
+		{$hour_multiplier = 0;}
 	else
-		{
-		$TMPscale_num=(73 / $hour_multiplier);
-		$TMPscale_num = round($TMPscale_num, 0);
-		$scale_num=($k / $hour_multiplier);
-		$scale_num = round($scale_num, 0);
-		}
-	$tmpscl = "$call_scale$TMPscale_num";
-
-	if ( ($Mk >= 4) or (strlen($tmpscl)==73) )
-		{
-		$Mk=0;
-		$LENscale_num = (strlen($scale_num));
-		$k = ($k + $LENscale_num);
-		$call_scale .= "$scale_num";
-		}
+		{$hour_multiplier = (70 / $hi_hour_count);}
+	if ($hi_hold_count < 1)
+		{$hold_multiplier = 0;}
 	else
-		{
-		$call_scale .= " ";
-		$k++;   $Mk++;
-		}
-	}
-$k=1;
-$Mk=0;
-$hold_scale = '0';
-while ($k <= 72) 
-	{
-	if ( ($k < 1) or ($hold_multiplier <= 0) )
-		{$scale_num = 70;}
-	else
-		{
-		$TMPscale_num=(73 / $hold_multiplier);
-		$TMPscale_num = round($TMPscale_num, 0);
-		$scale_num=($k / $hold_multiplier);
-		$scale_num = round($scale_num, 0);
-		}
-	$tmpscl = "$hold_scale$TMPscale_num";
-
-	if ( ($Mk >= 4) or (strlen($tmpscl)==73) )
-		{
-		$Mk=0;
-		$LENscale_num = (strlen($scale_num));
-		$k = ($k + $LENscale_num);
-		$hold_scale .= "$scale_num";
-		}
-	else
-		{
-		$hold_scale .= " ";
-		$k++;   $Mk++;
-		}
-	}
+		{$hold_multiplier = (70 / $hi_hold_count);}
 
 
-echo "+-------------+-------------------------------------------------------------------------+-------+\n";
-echo "|    TIME     |    CALLS HANDLED                                                        |       |\n";
-echo "| 15 MIN INT  |$call_scale| TOTAL |\n";
-echo "+-------------+-------------------------------------------------------------------------+-------+\n";
 
-$i=0;
-while ($i < $TOTintervals)
-	{
-	$char_counter=0;
-	### BEGIN HOLD TIME TOTALS GRAPH ###
-		$Ghour_count = $qrtCALLS[$i];
-	if ($Ghour_count > 0) {$no_lines_yet=0;}
 
-	$Gavg_hold = $qrtQUEUEavg[$i];
-	if ($Gavg_hold < 1) 
+	###################################################################
+	#########  HOLD TIME, CALL AND DROP STATS 15-MINUTE INCREMENTS ####
+
+	echo "\n";
+	echo "---------- HOLD TIME, CALL AND DROP STATS\n";
+
+	echo "";
+
+	echo "";
+	echo "\n";
+	echo "GRAPH IN 15 MINUTE INCREMENTS OF AVERAGE HOLD TIME FOR CALLS TAKEN INTO THIS IN-GROUP\n";
+
+
+	$k=1;
+	$Mk=0;
+	$call_scale = '0';
+	while ($k <= 72) 
 		{
-		if ($i < 0)
+		if ( ($k < 1) or ($hour_multiplier <= 0) )
+			{$scale_num = 70;}
+		else
 			{
-			$do_nothing=1;
+			$TMPscale_num=(73 / $hour_multiplier);
+			$TMPscale_num = round($TMPscale_num, 0);
+			$scale_num=($k / $hour_multiplier);
+			$scale_num = round($scale_num, 0);
+			}
+		$tmpscl = "$call_scale$TMPscale_num";
+
+		if ( ($Mk >= 4) or (strlen($tmpscl)==73) )
+			{
+			$Mk=0;
+			$LENscale_num = (strlen($scale_num));
+			$k = ($k + $LENscale_num);
+			$call_scale .= "$scale_num";
+			}
+		else
+			{
+			$call_scale .= " ";
+			$k++;   $Mk++;
+			}
+		}
+	$k=1;
+	$Mk=0;
+	$hold_scale = '0';
+	while ($k <= 72) 
+		{
+		if ( ($k < 1) or ($hold_multiplier <= 0) )
+			{$scale_num = 70;}
+		else
+			{
+			$TMPscale_num=(73 / $hold_multiplier);
+			$TMPscale_num = round($TMPscale_num, 0);
+			$scale_num=($k / $hold_multiplier);
+			$scale_num = round($scale_num, 0);
+			}
+		$tmpscl = "$hold_scale$TMPscale_num";
+
+		if ( ($Mk >= 4) or (strlen($tmpscl)==73) )
+			{
+			$Mk=0;
+			$LENscale_num = (strlen($scale_num));
+			$k = ($k + $LENscale_num);
+			$hold_scale .= "$scale_num";
+			}
+		else
+			{
+			$hold_scale .= " ";
+			$k++;   $Mk++;
+			}
+		}
+
+
+	echo "+-------------+-------------------------------------------------------------------------+-------+\n";
+	echo "|    TIME     |    CALLS HANDLED                                                        |       |\n";
+	echo "| 15 MIN INT  |$call_scale| TOTAL |\n";
+	echo "+-------------+-------------------------------------------------------------------------+-------+\n";
+
+	$i=0;
+	while ($i < $TOTintervals)
+		{
+		$char_counter=0;
+		### BEGIN HOLD TIME TOTALS GRAPH ###
+			$Ghour_count = $qrtCALLS[$i];
+		if ($Ghour_count > 0) {$no_lines_yet=0;}
+
+		$Gavg_hold = $qrtQUEUEavg[$i];
+		if ($Gavg_hold < 1) 
+			{
+			if ($i < 0)
+				{
+				$do_nothing=1;
+				}
+			else
+				{
+				$TOT_lines++;
+				$qrtQUEUEavg[$i] =	sprintf("%5s", $qrtQUEUEavg[$i]);
+				$qrtQUEUEmax[$i] =	sprintf("%5s", $qrtQUEUEmax[$i]);
+				echo "|$HMdisplay[$i]|";
+			#	$k=0;   while ($k <= 22) {echo " ";   $k++;}
+			#	echo "| $qrtQUEUEavg[$i] | $qrtQUEUEmax[$i] |";
+				}
 			}
 		else
 			{
 			$TOT_lines++;
+			$no_lines_yet=0;
+			$Xavg_hold = ($Gavg_hold * $hold_multiplier);
+			$Yavg_hold = (19 - $Xavg_hold);
+
 			$qrtQUEUEavg[$i] =	sprintf("%5s", $qrtQUEUEavg[$i]);
 			$qrtQUEUEmax[$i] =	sprintf("%5s", $qrtQUEUEmax[$i]);
+
+		#	echo "|$HMdisplay[$i]|";
 			echo "|$HMdisplay[$i]|";
-		#	$k=0;   while ($k <= 22) {echo " ";   $k++;}
+		#	$k=0;   while ($k <= $Xavg_hold) {echo "*";   $k++;   $char_counter++;}
+		#	if ($char_counter >= 22) {echo "H";   $char_counter++;}
+		#	else {echo "*H";   $char_counter++;   $char_counter++;}
+		#	$k=0;   while ($k <= $Yavg_hold) {echo " ";   $k++;   $char_counter++;}
+		#		while ($char_counter <= 22) {echo " ";   $char_counter++;}
 		#	echo "| $qrtQUEUEavg[$i] | $qrtQUEUEmax[$i] |";
 			}
-		}
-	else
-		{
-		$TOT_lines++;
-		$no_lines_yet=0;
-		$Xavg_hold = ($Gavg_hold * $hold_multiplier);
-		$Yavg_hold = (19 - $Xavg_hold);
+		### END HOLD TIME TOTALS GRAPH ###
 
-		$qrtQUEUEavg[$i] =	sprintf("%5s", $qrtQUEUEavg[$i]);
-		$qrtQUEUEmax[$i] =	sprintf("%5s", $qrtQUEUEmax[$i]);
-
-	#	echo "|$HMdisplay[$i]|";
-		echo "|$HMdisplay[$i]|";
-	#	$k=0;   while ($k <= $Xavg_hold) {echo "*";   $k++;   $char_counter++;}
-	#	if ($char_counter >= 22) {echo "H";   $char_counter++;}
-	#	else {echo "*H";   $char_counter++;   $char_counter++;}
-	#	$k=0;   while ($k <= $Yavg_hold) {echo " ";   $k++;   $char_counter++;}
-	#		while ($char_counter <= 22) {echo " ";   $char_counter++;}
-	#	echo "| $qrtQUEUEavg[$i] | $qrtQUEUEmax[$i] |";
-		}
-	### END HOLD TIME TOTALS GRAPH ###
-
-	$char_counter=0;
- 	### BEGIN CALLS TOTALS GRAPH ###
-	$Ghour_count = $qrtCALLS[$i];
-	if ($Ghour_count < 1) 
-		{
-		if ($i < 0)
+		$char_counter=0;
+		### BEGIN CALLS TOTALS GRAPH ###
+		$Ghour_count = $qrtCALLS[$i];
+		if ($Ghour_count < 1) 
 			{
-			$do_nothing=1;
+			if ($i < 0)
+				{
+				$do_nothing=1;
+				}
+			else
+				{
+				if ($qrtCALLS[$i] < 1) {$qrtCALLS[$i]='';}
+				$qrtCALLS[$i] =	sprintf("%5s", $qrtCALLS[$i]);
+			#	echo "  |";
+				$k=0;   while ($k <= 72) {echo " ";   $k++;}
+				echo "| $qrtCALLS[$i] |\n";
+				}
 			}
 		else
 			{
-			if ($qrtCALLS[$i] < 1) {$qrtCALLS[$i]='';}
-			$qrtCALLS[$i] =	sprintf("%5s", $qrtCALLS[$i]);
-		#	echo "  |";
-			$k=0;   while ($k <= 72) {echo " ";   $k++;}
-			echo "| $qrtCALLS[$i] |\n";
+			$no_lines_yet=0;
+			$Xhour_count = ($Ghour_count * $hour_multiplier);
+			$Yhour_count = (69 - $Xhour_count);
+
+			$Gdrop_count = $qrtDROPS[$i];
+			if ($Gdrop_count < 1) 
+				{
+				if ($qrtCALLS[$i] < 1) {$qrtCALLS[$i]='';}
+				$qrtCALLS[$i] =	sprintf("%5s", $qrtCALLS[$i]);
+
+				echo "";
+				$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
+				if ($char_counter > 71) {echo "C";   $char_counter++;}
+				else {echo "*C";   $char_counter++;   $char_counter++;}
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+					while ($char_counter <= 72) {echo " ";   $char_counter++;}
+				echo "| $qrtCALLS[$i] |\n";
+				}
+			else
+				{
+				$Xdrop_count = ($Gdrop_count * $hour_multiplier);
+
+			#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
+
+				$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
+
+				if ($qrtCALLS[$i] < 1) {$qrtCALLS[$i]='';}
+				$qrtCALLS[$i] =	sprintf("%5s", $qrtCALLS[$i]);
+				$qrtDROPS[$i] =	sprintf("%5s", $qrtDROPS[$i]);
+
+				echo "";
+				$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
+				echo "D";   $char_counter++;
+				$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
+				echo "C";   $char_counter++;
+				$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
+				while ($char_counter <= 72) {echo " ";   $char_counter++;}
+
+				echo "| $qrtCALLS[$i] |\n";
+				}
 			}
+		### END CALLS TOTALS GRAPH ###
+
+		$i++;
 		}
+
+
+	if ($totQUEUEsec > 0)
+		{$totQUEUEavgRAW = ($totCALLS / $totQUEUEsec);}
 	else
-		{
-		$no_lines_yet=0;
-		$Xhour_count = ($Ghour_count * $hour_multiplier);
-		$Yhour_count = (69 - $Xhour_count);
-
-		$Gdrop_count = $qrtDROPS[$i];
-		if ($Gdrop_count < 1) 
-			{
-			if ($qrtCALLS[$i] < 1) {$qrtCALLS[$i]='';}
-			$qrtCALLS[$i] =	sprintf("%5s", $qrtCALLS[$i]);
-
-			echo "";
-			$k=0;   while ($k <= $Xhour_count) {echo "*";   $k++;   $char_counter++;}
-			if ($char_counter > 71) {echo "C";   $char_counter++;}
-			else {echo "*C";   $char_counter++;   $char_counter++;}
-			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
-				while ($char_counter <= 72) {echo " ";   $char_counter++;}
-			echo "| $qrtCALLS[$i] |\n";
-			}
-		else
-			{
-			$Xdrop_count = ($Gdrop_count * $hour_multiplier);
-
-		#	if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);}
-
-			$XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 );
-
-			if ($qrtCALLS[$i] < 1) {$qrtCALLS[$i]='';}
-			$qrtCALLS[$i] =	sprintf("%5s", $qrtCALLS[$i]);
-			$qrtDROPS[$i] =	sprintf("%5s", $qrtDROPS[$i]);
-
-			echo "";
-			$k=0;   while ($k <= $Xdrop_count) {echo ">";   $k++;   $char_counter++;}
-			echo "D";   $char_counter++;
-			$k=0;   while ($k <= $XXhour_count) {echo "*";   $k++;   $char_counter++;}
-			echo "C";   $char_counter++;
-			$k=0;   while ($k <= $Yhour_count) {echo " ";   $k++;   $char_counter++;}
-				while ($char_counter <= 72) {echo " ";   $char_counter++;}
-
-			echo "| $qrtCALLS[$i] |\n";
-			}
-		}
-	### END CALLS TOTALS GRAPH ###
-
-	$i++;
-	}
-
-
-if ($totQUEUEsec > 0)
-	{$totQUEUEavgRAW = ($totCALLS / $totQUEUEsec);}
-else
-	{$totQUEUEavgRAW = 0;}
-$totQUEUEavg =	sprintf("%5s", $totQUEUEavg); 
+		{$totQUEUEavgRAW = 0;}
+	$totQUEUEavg =	sprintf("%5s", $totQUEUEavg); 
 	while (strlen($totQUEUEavg)>5) {$totQUEUEavg = ereg_replace(".$",'',$totQUEUEavg);}
-$totQUEUEmax =	sprintf("%5s", $totQUEUEmax);
+	$totQUEUEmax =	sprintf("%5s", $totQUEUEmax);
 	while (strlen($totQUEUEmax)>5) {$totQUEUEmax = ereg_replace(".$",'',$totQUEUEmax);}
-$totDROPS =	sprintf("%5s", $totDROPS);
-$totCALLS =	sprintf("%5s", $totCALLS);
+	$totDROPS =	sprintf("%5s", $totDROPS);
+	$totCALLS =	sprintf("%5s", $totCALLS);
 
 
-echo "+-------------+-------------------------------------------------------------------------+-------+\n";
-echo "| TOTAL       |                                                                         | $totCALLS |\n";
-echo "+-------------+-------------------------------------------------------------------------+-------+\n";
+	echo "+-------------+-------------------------------------------------------------------------+-------+\n";
+	echo "| TOTAL       |                                                                         | $totCALLS |\n";
+	echo "+-------------+-------------------------------------------------------------------------+-------+\n";
 
 
-
-$ENDtime = date("U");
-$RUNtime = ($ENDtime - $STARTtime);
-echo "\nRun Time: $RUNtime seconds\n";
-}
+	$ENDtime = date("U");
+	$RUNtime = ($ENDtime - $STARTtime);
+	echo "\nRun Time: $RUNtime seconds\n";
+	}
 
 
 
diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php
index 31b5ed07..2cd8e624 100644
--- a/www/vicidial/admin.php
+++ b/www/vicidial/admin.php
@@ -1,7 +1,7 @@
     LICENSE: AGPLv2
+# Copyright (C) 2010  Matt Florell     LICENSE: AGPLv2
 # 
 
 require("dbconnect.php");
@@ -2043,11 +2043,12 @@ else
 # 91228-1837 - Added timer action settings to in-groups and campaigns
 # 100103-0727 - Added Start/Dispo call url, 3/4/5 conf number presets, Lists conf-number overrides
 # 100104-1454 - Fixed in-group/campaign copy duplication issue
+# 100116-0718 - Added presets to script select list
 #
 # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time
 
-$admin_version = '2.2.0-233';
-$build = '100104-1454';
+$admin_version = '2.2.0-234';
+$build = '100116-0718';
 
 $STARTtime = date("U");
 $SQLdate = date("Y-m-d H:i:s");
@@ -6187,6 +6188,14 @@ if ($ADD==7111111)
 	$user_custom_three = 'custom three';
 	$user_custom_four = 'custom four';
 	$user_custom_five = 'custom five';
+	$preset_number_a = 'preset_a';
+	$preset_number_b = 'preset_b';
+	$preset_number_c = 'preset_c';
+	$preset_number_d = 'preset_d';
+	$preset_number_e = 'preset_e';
+	$preset_number_f = 'preset_f';
+	$preset_dtmf_a = 'preset_dtmf_a';
+	$preset_dtmf_b = 'preset_dtmf_b';
 
 	echo "\n";
 	echo "\n";
@@ -6253,6 +6262,14 @@ if ($ADD==7111111)
 		$user_custom_three = eregi_replace(' ','+',$user_custom_three);
 		$user_custom_four = eregi_replace(' ','+',$user_custom_four);
 		$user_custom_five = eregi_replace(' ','+',$user_custom_five);
+		$preset_number_a = eregi_replace(' ','+',$preset_number_a);
+		$preset_number_b = eregi_replace(' ','+',$preset_number_b);
+		$preset_number_c = eregi_replace(' ','+',$preset_number_c);
+		$preset_number_d = eregi_replace(' ','+',$preset_number_d);
+		$preset_number_e = eregi_replace(' ','+',$preset_number_e);
+		$preset_number_f = eregi_replace(' ','+',$preset_number_f);
+		$preset_dtmf_a = eregi_replace(' ','+',$preset_dtmf_a);
+		$preset_dtmf_b = eregi_replace(' ','+',$preset_dtmf_b);
 		}
 
 	$script_text = eregi_replace('--A--vendor_lead_code--B--',"$vendor_lead_code",$script_text);
@@ -6308,6 +6325,14 @@ if ($ADD==7111111)
 	$script_text = eregi_replace('--A--user_custom_three--B--',"$user_custom_three",$script_text);
 	$script_text = eregi_replace('--A--user_custom_four--B--',"$user_custom_four",$script_text);
 	$script_text = eregi_replace('--A--user_custom_five--B--',"$user_custom_five",$script_text);
+	$script_text = eregi_replace('--A--preset_number_a--B--',"$preset_number_a",$script_text);
+	$script_text = eregi_replace('--A--preset_number_b--B--',"$preset_number_b",$script_text);
+	$script_text = eregi_replace('--A--preset_number_c--B--',"$preset_number_c",$script_text);
+	$script_text = eregi_replace('--A--preset_number_d--B--',"$preset_number_d",$script_text);
+	$script_text = eregi_replace('--A--preset_number_e--B--',"$preset_number_e",$script_text);
+	$script_text = eregi_replace('--A--preset_number_f--B--',"$preset_number_f",$script_text);
+	$script_text = eregi_replace('--A--preset_dtmf_a--B--',"$preset_dtmf_a",$script_text);
+	$script_text = eregi_replace('--A--preset_dtmf_b--B--',"$preset_dtmf_b",$script_text);
 	$script_text = eregi_replace("\n","
",$script_text); @@ -7362,6 +7387,19 @@ if ($ADD==1111111) echo ""; echo ""; echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo ""; echo "
"; # END Insert Field @@ -20618,6 +20656,19 @@ if ($ADD==3111111) echo ""; echo ""; echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo ""; echo "
"; # END Insert Field