From 8d406bdd670cfe76e563528795ebaf685b52d58e Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 19 Jun 2007 17:44:31 +0000 Subject: [PATCH] added status category tally gathering to AST_VDadapt.pl added status category tally display to the timeonVDADall display scripts altered database schema to accomodate the tally of status categories git-svn-id: svn://192.168.202.10@640 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/UPGRADE | 4 +- agc_2-X/trunk/bin/AST_VDadapt.pl | 77 ++++++++++++++++++- .../trunk/extras/MySQL_AST_CREATE_tables.sql | 10 ++- agc_2-X/trunk/extras/upgrade_2.0.4.sql | 9 ++- .../trunk/www/vicidial/AST_timeonVDADall.php | 39 +++++++--- .../www/vicidial/AST_timeonVDADallSUMMARY.php | 37 +++++++-- 6 files changed, 155 insertions(+), 21 deletions(-) diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index 2e7e5237..675d083f 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -23,7 +23,9 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom chmod 0777 $PATHweb/vicidial/server_reports/ 4. A new set of changes have been made to the statuses sections in the admin.php - pages allowing for categorizing statuse and modifyig them without delete + pages allowing for categorizing statues and modifyig them without delete. + Also, the gathering of a tally of the statuses in these categories is + now available on the timeonVDADall scripts. 5. The admin.php interface has had more sections broken into sub-sections for easier management and rapid modifications. diff --git a/agc_2-X/trunk/bin/AST_VDadapt.pl b/agc_2-X/trunk/bin/AST_VDadapt.pl index ff2557c6..86db584d 100644 --- a/agc_2-X/trunk/bin/AST_VDadapt.pl +++ b/agc_2-X/trunk/bin/AST_VDadapt.pl @@ -22,6 +22,7 @@ # 70219-1249 - Removed unused references to dial_status_x fields # 70409-1219 - Removed CLOSER-type campaign restriction # 70521-1038 - Fixed bug when no live campaigns are running, define $vicidial_log +# 70619-1339 - Added Status Category tally calculations # # constants @@ -1008,7 +1009,81 @@ if ($VCScalls_five[$i] > 0) } if ($DBX) {print "$campaign_id[$i]|$VCSdrops_five_pct[$i]|$VCSdrops_today_pct[$i]\n";} -$stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today[$i]',answers_today='$VCSanswers_today[$i]',drops_today='$VCSdrops_today[$i]',drops_today_pct='$VCSdrops_today_pct[$i]',drops_answers_today_pct='$VCSdrops_answers_today_pct[$i]',calls_hour='$VCScalls_hour[$i]',answers_hour='$VCSanswers_hour[$i]',drops_hour='$VCSdrops_hour[$i]',drops_hour_pct='$VCSdrops_hour_pct[$i]',calls_halfhour='$VCScalls_halfhour[$i]',answers_halfhour='$VCSanswers_halfhour[$i]',drops_halfhour='$VCSdrops_halfhour[$i]',drops_halfhour_pct='$VCSdrops_halfhour_pct[$i]',calls_fivemin='$VCScalls_five[$i]',answers_fivemin='$VCSanswers_five[$i]',drops_fivemin='$VCSdrops_five[$i]',drops_fivemin_pct='$VCSdrops_five_pct[$i]',calls_onemin='$VCScalls_one[$i]',answers_onemin='$VCSanswers_one[$i]',drops_onemin='$VCSdrops_one[$i]',drops_onemin_pct='$VCSdrops_one_pct[$i]' where campaign_id='$campaign_id[$i]';"; +# DETERMINE WHETHER TO GATHER STATUS CATEGORY STATISTICS +$VSC_categories=0; +$VSCupdateSQL=''; +$stmtA = "SELECT vsc_id from vicidial_status_categories where tovdad_display='Y';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +$rec_count=0; +while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $VSC_categories[$rec_count] = "$aryA[0]"; + $rec_count++; + } +$sthA->finish(); + +$g=0; +foreach (@VSC_categories) + { + $VSCcategory=$VSC_categories[$g]; + $VSCtally=''; + $CATstatusesSQL=''; + # FIND STATUSES IN STATUS CATEGORY + $stmtA = "SELECT status from vicidial_statuses where category='$VSCcategory';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $CATstatusesSQL .= "'$aryA[0]',"; + $rec_count++; + } + # FIND CAMPAIGN_STATUSES IN STATUS CATEGORY + $stmtA = "SELECT status from vicidial_campaign_statuses where category='$VSCcategory' and campaign_id='$campaign_id[$i]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $CATstatusesSQL .= "'$aryA[0]',"; + $rec_count++; + } + chop($CATstatusesSQL); + if (length($CATstatusesSQL)>2) + { + # FIND STATUSES IN STATUS CATEGORY + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN($CATstatusesSQL);"; + # if ($DBX) {print "|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $VSCtally = "$aryA[0]"; + $rec_count++; + } + } + $g++; + if ($DBX) {print " $campaign_id[$i]|$VSCcategory|$VSCtally|$CATstatusesSQL|\n";} + $VSCupdateSQL .= "status_category_$g='$VSCcategory',status_category_count_$g='$VSCtally',"; + } +while ($g < 4) + { + $g++; + $VSCupdateSQL .= "status_category_$g='',status_category_count_$g='0',"; + } +chop($VSCupdateSQL); + +$stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today[$i]',answers_today='$VCSanswers_today[$i]',drops_today='$VCSdrops_today[$i]',drops_today_pct='$VCSdrops_today_pct[$i]',drops_answers_today_pct='$VCSdrops_answers_today_pct[$i]',calls_hour='$VCScalls_hour[$i]',answers_hour='$VCSanswers_hour[$i]',drops_hour='$VCSdrops_hour[$i]',drops_hour_pct='$VCSdrops_hour_pct[$i]',calls_halfhour='$VCScalls_halfhour[$i]',answers_halfhour='$VCSanswers_halfhour[$i]',drops_halfhour='$VCSdrops_halfhour[$i]',drops_halfhour_pct='$VCSdrops_halfhour_pct[$i]',calls_fivemin='$VCScalls_five[$i]',answers_fivemin='$VCSanswers_five[$i]',drops_fivemin='$VCSdrops_five[$i]',drops_fivemin_pct='$VCSdrops_five_pct[$i]',calls_onemin='$VCScalls_one[$i]',answers_onemin='$VCSanswers_one[$i]',drops_onemin='$VCSdrops_one[$i]',drops_onemin_pct='$VCSdrops_one_pct[$i]',$VSCupdateSQL where campaign_id='$campaign_id[$i]';"; $affected_rows = $dbhA->do($stmtA); if ($DBX) {print "$campaign_id[$i]|$stmtA|\n";} } diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index dc0e9ee5..fb7b8595 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -819,7 +819,15 @@ drops_onemin INT(9) UNSIGNED default '0', drops_onemin_pct VARCHAR(6) default '0', differential_onemin VARCHAR(20) default '0', agents_average_onemin VARCHAR(20) default '0', -balance_trunk_fill SMALLINT(5) UNSIGNED default '0' +balance_trunk_fill SMALLINT(5) UNSIGNED default '0', +status_category_1 VARCHAR(20), +status_category_count_1 INT(9) UNSIGNED default '0', +status_category_2 VARCHAR(20), +status_category_count_2 INT(9) UNSIGNED default '0', +status_category_3 VARCHAR(20), +status_category_count_3 INT(9) UNSIGNED default '0', +status_category_4 VARCHAR(20), +status_category_count_4 INT(9) UNSIGNED default '0' ); CREATE TABLE vicidial_dnc ( diff --git a/agc_2-X/trunk/extras/upgrade_2.0.4.sql b/agc_2-X/trunk/extras/upgrade_2.0.4.sql index 7853b7e1..bae5cc30 100644 --- a/agc_2-X/trunk/extras/upgrade_2.0.4.sql +++ b/agc_2-X/trunk/extras/upgrade_2.0.4.sql @@ -28,7 +28,14 @@ ALTER TABLE vicidial_statuses ADD category VARCHAR(20) default 'UNDEFINED'; INSERT INTO vicidial_status_categories (vsc_id,vsc_name) values('UNDEFINED','Default Category'); - +ALTER TABLE vicidial_campaign_stats ADD status_category_1 VARCHAR(20); +ALTER TABLE vicidial_campaign_stats ADD status_category_count_1 INT(9) UNSIGNED default '0'; +ALTER TABLE vicidial_campaign_stats ADD status_category_2 VARCHAR(20); +ALTER TABLE vicidial_campaign_stats ADD status_category_count_2 INT(9) UNSIGNED default '0'; +ALTER TABLE vicidial_campaign_stats ADD status_category_3 VARCHAR(20); +ALTER TABLE vicidial_campaign_stats ADD status_category_count_3 INT(9) UNSIGNED default '0'; +ALTER TABLE vicidial_campaign_stats ADD status_category_4 VARCHAR(20); +ALTER TABLE vicidial_campaign_stats ADD status_category_count_4 INT(9) UNSIGNED default '0'; diff --git a/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php b/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php index 5946b75a..0e1769d7 100644 --- a/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php +++ b/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php @@ -1,7 +1,7 @@ LICENSE: GPLv2 +# Copyright (C) 2007 Matt Florell LICENSE: GPLv2 # # live real-time stats for the VICIDIAL Auto-Dialer all servers # @@ -26,6 +26,7 @@ # 70111-1600 - Added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns # 70123-1151 - Added non_latin options for substr in display variables, thanks Marin Blu # 70206-1140 - Added call-type statuses to display(A-Auto, M-Manual, I-Inbound/Closer) +# 70619-1339 - Added Status Category tally display # header ("Content-type: text/html; charset=utf-8"); @@ -311,10 +312,10 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $VDhop = $row[0]; -$stmt="select dialable_leads,calls_today,drops_today,drops_answers_today_pct,differential_onemin,agents_average_onemin,balance_trunk_fill,answers_today from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$stmt="select dialable_leads,calls_today,drops_today,drops_answers_today_pct,differential_onemin,agents_average_onemin,balance_trunk_fill,answers_today,status_category_1,status_category_count_1,status_category_2,status_category_count_2,status_category_3,status_category_count_3,status_category_4,status_category_count_4 from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; if ($group=='XXXX-ALL-ACTIVE-XXXX') { - $stmt="select sum(dialable_leads),sum(calls_today),sum(drops_today),avg(drops_answers_today_pct),avg(differential_onemin),avg(agents_average_onemin),sum(balance_trunk_fill),sum(answers_today) from vicidial_campaign_stats;"; + $stmt="select sum(dialable_leads),sum(calls_today),sum(drops_today),avg(drops_answers_today_pct),avg(differential_onemin),avg(agents_average_onemin),sum(balance_trunk_fill),sum(answers_today),min(status_category_1),sum(status_category_count_1),min(status_category_2),sum(status_category_count_2),min(status_category_3),sum(status_category_count_3),min(status_category_4),sum(status_category_count_4) from vicidial_campaign_stats;"; } if ($non_latin > 0) { @@ -322,14 +323,23 @@ $rslt=mysql_query("SET NAMES 'UTF8'"); } $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$DAleads = $row[0]; -$callsTODAY = $row[1]; -$dropsTODAY = $row[2]; -$drpctTODAY = $row[3]; -$diffONEMIN = $row[4]; +$DAleads = $row[0]; +$callsTODAY = $row[1]; +$dropsTODAY = $row[2]; +$drpctTODAY = $row[3]; +$diffONEMIN = $row[4]; $agentsONEMIN = $row[5]; -$balanceFILL = $row[6]; +$balanceFILL = $row[6]; $answersTODAY = $row[7]; +$VSCcat1 = $row[8]; +$VSCcat1tally = $row[9]; +$VSCcat2 = $row[10]; +$VSCcat2tally = $row[11]; +$VSCcat3 = $row[12]; +$VSCcat3tally = $row[13]; +$VSCcat4 = $row[14]; +$VSCcat4tally = $row[15]; + if ( ($diffONEMIN != 0) and ($agentsONEMIN > 0) ) { $diffpctONEMIN = ( ($diffONEMIN / $agentsONEMIN) * 100); @@ -396,6 +406,17 @@ echo "DIFF: echo "ORDER:  $DIALorder     "; echo ""; +echo ""; +echo ""; +if ( (!eregi('NULL',$VSCcat1)) and (strlen($VSCcat1)>0) ) + {echo "$VSCcat1:   $VSCcat1tally       \n";} +if ( (!eregi('NULL',$VSCcat2)) and (strlen($VSCcat2)>0) ) + {echo "$VSCcat2:   $VSCcat2tally       \n";} +if ( (!eregi('NULL',$VSCcat3)) and (strlen($VSCcat3)>0) ) + {echo "$VSCcat3:   $VSCcat3tally       \n";} +if ( (!eregi('NULL',$VSCcat4)) and (strlen($VSCcat4)>0) ) + {echo "$VSCcat4:   $VSCcat4tally       \n";} +echo ""; echo ""; echo ""; diff --git a/agc_2-X/trunk/www/vicidial/AST_timeonVDADallSUMMARY.php b/agc_2-X/trunk/www/vicidial/AST_timeonVDADallSUMMARY.php index 47e1d270..63d17ac8 100644 --- a/agc_2-X/trunk/www/vicidial/AST_timeonVDADallSUMMARY.php +++ b/agc_2-X/trunk/www/vicidial/AST_timeonVDADallSUMMARY.php @@ -1,7 +1,7 @@ LICENSE: GPLv2 +# Copyright (C) 2007 Matt Florell LICENSE: GPLv2 # # Summary for all campaigns live real-time stats for the VICIDIAL Auto-Dialer all servers # @@ -11,6 +11,7 @@ # 61102-1616 - first build # 61215-1131 - added answered calls and drop percent taken from answered calls # 70111-1600 - added ability to use BLEND/INBND/*_C/*_B/*_I as closer campaigns +# 70619-1339 - Added Status Category tally display # header ("Content-type: text/html; charset=utf-8"); @@ -160,17 +161,26 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $VDhop = $row[0]; -$stmt="select dialable_leads,calls_today,drops_today,drops_answers_today_pct,differential_onemin,agents_average_onemin,balance_trunk_fill,answers_today from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; +$stmt="select dialable_leads,calls_today,drops_today,drops_answers_today_pct,differential_onemin,agents_average_onemin,balance_trunk_fill,answers_today,status_category_1,status_category_count_1,status_category_2,status_category_count_2,status_category_3,status_category_count_3,status_category_4,status_category_count_4 from vicidial_campaign_stats where campaign_id='" . mysql_real_escape_string($group) . "';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); -$DAleads = $row[0]; -$callsTODAY = $row[1]; -$dropsTODAY = $row[2]; -$drpctTODAY = $row[3]; -$diffONEMIN = $row[4]; +$DAleads = $row[0]; +$callsTODAY = $row[1]; +$dropsTODAY = $row[2]; +$drpctTODAY = $row[3]; +$diffONEMIN = $row[4]; $agentsONEMIN = $row[5]; -$balanceFILL = $row[6]; +$balanceFILL = $row[6]; $answersTODAY = $row[7]; +$VSCcat1 = $row[8]; +$VSCcat1tally = $row[9]; +$VSCcat2 = $row[10]; +$VSCcat2tally = $row[11]; +$VSCcat3 = $row[12]; +$VSCcat3tally = $row[13]; +$VSCcat4 = $row[14]; +$VSCcat4tally = $row[15]; + if ( ($diffONEMIN != 0) and ($agentsONEMIN > 0) ) { $diffpctONEMIN = ( ($diffONEMIN / $agentsONEMIN) * 100); @@ -229,6 +239,17 @@ echo "DIFF: echo "ORDER:  $DIALorder     "; echo ""; +echo ""; +echo ""; +if ( (!eregi('NULL',$VSCcat1)) and (strlen($VSCcat1)>0) ) + {echo "$VSCcat1:   $VSCcat1tally       \n";} +if ( (!eregi('NULL',$VSCcat2)) and (strlen($VSCcat2)>0) ) + {echo "$VSCcat2:   $VSCcat2tally       \n";} +if ( (!eregi('NULL',$VSCcat3)) and (strlen($VSCcat3)>0) ) + {echo "$VSCcat3:   $VSCcat3tally       \n";} +if ( (!eregi('NULL',$VSCcat4)) and (strlen($VSCcat4)>0) ) + {echo "$VSCcat4:   $VSCcat4tally       \n";} +echo ""; echo ""; echo "";