diff --git a/UPGRADE b/UPGRADE index 3df82014..64ab9a9a 100644 --- a/UPGRADE +++ b/UPGRADE @@ -76,6 +76,8 @@ OTHER CHANGES: enabled in System Settings. Calls must be passed from an outbound campaign or an in-group. +8. Added ability to download the Max System Stats and display by date range. + diff --git a/bin/VICIDIAL_IN_new_leads_file.pl b/bin/VICIDIAL_IN_new_leads_file.pl index 54e07b0a..0d9d6035 100644 --- a/bin/VICIDIAL_IN_new_leads_file.pl +++ b/bin/VICIDIAL_IN_new_leads_file.pl @@ -10,7 +10,7 @@ # # NOTE: the machine this is run on must have a servers entry in the database # -# Copyright (C) 2011 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2012 Matt Florell LICENSE: AGPLv2 # # # CHANGES @@ -53,9 +53,10 @@ # 110424-0948 - Added time-zone-code-gmt option to use time zone code from the owner field # 110705-1913 - Added options for USACAN prefix(no 0 or 1) and valid areacode filtering # 110929-1423 - Added new format for abbreviated timezone in owner(pipe30tz) and list creation options +# 120713-1009 - Added new --duplicate-tnm-delete option to check for a duplicate phone with different title and delete existing if found in same list # -$version = '110929-1423'; +$version = '120713-1009'; $secX = time(); $MT[0]=''; @@ -173,6 +174,9 @@ if (length($ARGV[0])>1) print " [--duplicate-system-check] = checks for the same phone number in the entire system before inserting lead\n"; print " [--duplicate-tap-list-check] = checks for the same title/alt-number in the same list ID before inserting lead\n"; print " [--duplicate-tap-system-check] = checks for the same title/alt-number in the entire system before inserting lead\n"; + print " [--duplicate-tnm-delete] = checks for same phone and title in same list then deletes original if title is different\n"; + print " [--dob-mmddyyy] = checks for slashes in the date of birth field and formats from MM/DD/YYYY to MySQL\n"; + print " [--dob-ddmmyyy] = checks for slashes in the date of birth field and formats from DD/MM/YYYY to MySQL\n"; print " [--postal-code-gmt] = checks for the time zone based on the postal code given where available\n"; print " [--time-zone-code-gmt] = checks for the time zone based on the owner field time zone code given where available\n"; print " [--ftp-pull] = grabs lead files from a remote FTP server, uses REPORTS FTP login information\n"; @@ -326,6 +330,21 @@ if (length($ARGV[0])>1) $duptapchecksys=1; if ($q < 1) {print "\n----- DUPLICATE TITLE/ALT-PHONE SYSTEM CHECK -----\n\n";} } + if ($args =~ /-duplicate-tnm-delete/i) + { + $duptnmdelete=1; + if ($q < 1) {print "\n----- DUPLICATE TITLE DIFF DELETE -----\n\n";} + } + if ($args =~ /--dob-mmddyyy/i) + { + $dob_mmddyyy=1; + if ($q < 1) {print "\n----- DOB FORMAT MMDDYYYY -----\n\n";} + } + if ($args =~ /--dob-ddmmyyy/i) + { + $dob_ddmmyyy=1; + if ($q < 1) {print "\n----- DOB FORMAT DDMMYYYY -----\n\n";} + } if ($args =~ /-postal-code-gmt/i) { $postalgmt=1; @@ -614,7 +633,7 @@ foreach(@FILES) $new_list_id = "$list_id_prefix$listdate$x"; while ( ($xloop < 10000) && ($dup_list_id > 0) ) { - $stmtA = "select count(*) from vicidial_lists where list_id='$new_list_id';"; + $stmtA = "SELECT count(*) from vicidial_lists where list_id='$new_list_id';"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1199,7 +1218,7 @@ foreach(@FILES) } ### look up the custom CID to use for this state - $stmtA = "select cid from vicidial_custom_cid where state='$state';"; + $stmtA = "SELECT cid from vicidial_custom_cid where state='$state';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1311,7 +1330,7 @@ foreach(@FILES) } ### look up the custom CID to use for this state - $stmtA = "select cid from vicidial_custom_cid where state='$state';"; + $stmtA = "SELECT cid from vicidial_custom_cid where state='$state';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1432,7 +1451,7 @@ foreach(@FILES) } ### look up the custom CID to use for this state - $stmtA = "select cid from vicidial_custom_cid where state='$state';"; + $stmtA = "SELECT cid from vicidial_custom_cid where state='$state';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1517,7 +1536,7 @@ foreach(@FILES) } ### look up the custom CID to use for this state - $stmtA = "select cid from vicidial_custom_cid where state='$state';"; + $stmtA = "SELECT cid from vicidial_custom_cid where state='$state';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1610,13 +1629,13 @@ foreach(@FILES) $called_count = $m[23]; $called_count =~ s/\D|\r|\n|\t//gi; if (length($called_count)<1) {$called_count=0;} $status = $m[24]; $status =~ s/ |\r|\n|\t//gi; if (length($status)<1) {$status='NEW';} $insert_date = $m[25]; $insert_date =~ s/\r|\n|\t|[a-zA-Z]//gi; if (length($insert_date)<6) {$insert_date=$pulldate0;} - if ($insert_date =~ /\//) - { - @iD = split(/\//, $insert_date); - $iD[0] = sprintf("%02d", $iD[0]); - $iD[1] = sprintf("%02d", $iD[1]); - $insert_date = "$iD[2]-$iD[0]-$iD[1]"; - } + if ($insert_date =~ /\//) + { + @iD = split(/\//, $insert_date); + $iD[0] = sprintf("%02d", $iD[0]); + $iD[1] = sprintf("%02d", $iD[1]); + $insert_date = "$iD[2]-$iD[0]-$iD[1]"; + } $multi_alt_phones = $m[26]; $map_count=0; @@ -1661,6 +1680,20 @@ foreach(@FILES) { $phone_code = $forcephonecode; # set phone_code to override value } + if ( ($dob_mmddyyy > 0) && ($date_of_birth =~ /\//) ) + { + @iD = split(/\//, $date_of_birth); + $iD[0] = sprintf("%02d", $iD[0]); + $iD[1] = sprintf("%02d", $iD[1]); + $date_of_birth = "$iD[2]-$iD[0]-$iD[1]"; + } + if ( ($dob_ddmmyyy > 0) && ($date_of_birth =~ /\//) ) + { + @iD = split(/\//, $date_of_birth); + $iD[0] = sprintf("%02d", $iD[0]); + $iD[1] = sprintf("%02d", $iD[1]); + $date_of_birth = "$iD[2]-$iD[1]-$iD[0]"; + } if ($DBX) {print "$a|$phone_number\n";} @@ -1681,7 +1714,7 @@ foreach(@FILES) if ( ($usacan_areacode_check > 0) && ($valid_lead > 0) ) { $USarea = substr($phone_number, 0, 3); - $stmtA = "select count(*) from vicidial_phone_codes where areacode='$USarea' and country_code='1';"; + $stmtA = "SELECT count(*) from vicidial_phone_codes where areacode='$USarea' and country_code='1';"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1702,7 +1735,7 @@ foreach(@FILES) if ($dupchecksys > 0) { $dup_lead=0; - $stmtA = "select count(*) from vicidial_list where phone_number='$phone_number';"; + $stmtA = "SELECT count(*) from vicidial_list where phone_number='$phone_number';"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1724,7 +1757,7 @@ foreach(@FILES) if ($dupcheck > 0) { $dup_lead=0; - $stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' limit 1;"; + $stmtA = "SELECT list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' limit 1;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1748,7 +1781,7 @@ foreach(@FILES) $dup_lead=0; $dup_lists=''; - $stmtA = "select count(*) from vicidial_lists where list_id='$list_id';"; + $stmtA = "SELECT count(*) from vicidial_lists where list_id='$list_id';"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1757,7 +1790,7 @@ foreach(@FILES) $sthA->finish(); if ($ci_recs > 0) { - $stmtA = "select campaign_id from vicidial_lists where list_id='$list_id';"; + $stmtA = "SELECT campaign_id from vicidial_lists where list_id='$list_id';"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1765,7 +1798,7 @@ foreach(@FILES) $dup_camp = $aryA[0]; $sthA->finish(); - $stmtA = "select list_id from vicidial_lists where campaign_id='$dup_camp';"; + $stmtA = "SELECT list_id from vicidial_lists where campaign_id='$dup_camp';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1779,7 +1812,7 @@ foreach(@FILES) $sthA->finish(); chop($dup_lists); - $stmtA = "select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;"; + $stmtA = "SELECT list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1803,7 +1836,7 @@ foreach(@FILES) if ($duptapchecksys > 0) { $dup_lead=0; - $stmtA = "select count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone';"; + $stmtA = "SELECT count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone';"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1825,7 +1858,7 @@ foreach(@FILES) if ($duptapchecklist > 0) { $dup_lead=0; - $stmtA = "select list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' limit 1;"; + $stmtA = "SELECT list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' limit 1;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1843,7 +1876,35 @@ foreach(@FILES) {$dup_lead++;} } } + ##### Check for duplicate phone with different title in vicidial_list table for one list_id, delete if different ##### + if ( ($dup_lead > 0) && ($duptnmdelete > 0) ) + { + $tnm_delete=0; + $tnm_lead_id=''; + $stmtA = "SELECT lead_id,title from vicidial_list where phone_number='$phone_number' and list_id='$list_id' limit 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $tnm_lead_id = $aryA[0]; + $tnm_title_check = $aryA[1]; + if ( (length($tnm_title_check) > 0) && (length($title) > 0) && ($tnm_title_check !~ /^$title$/) ) + {$tnm_delete++;} + } + $sthA->finish(); + if ($tnm_delete > 0) + { + $stmtZ = "DELETE FROM vicidial_list where lead_id='$tnm_lead_id' limit 1;"; + if (!$T) {$affected_rows = $dbhA->do($stmtZ); } # or die "Couldn't execute query: |$stmtZ|\n"; + if($DB){print STDERR "\n|$affected_rows|$tnm_title_check|$title|$tnm_lead_id|$list_id|$stmtZ|\n";} + $tnm_delete_count++; + } + } + ##### final checks before inserting the lead if ( (length($phone_number)>6) && ($dup_lead < 1) && ($valid_lead > 0) ) { if ( ($duptapchecklist > 0) || ($duptapchecksys > 0) ) @@ -1867,7 +1928,7 @@ foreach(@FILES) { if ($phone_code =~ /^1$/) { - $stmtA = "select postal_code,state,GMT_offset,DST,DST_range,country,country_code from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; + $stmtA = "SELECT postal_code,state,GMT_offset,DST,DST_range,country,country_code from vicidial_postal_codes where country_code='$phone_code' and postal_code LIKE \"$postal_code%\";"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1893,7 +1954,7 @@ foreach(@FILES) $dst='N'; $gmt_offset=0; - $stmtA="select GMT_offset from vicidial_phone_codes where tz_code='$owner' and country_code='$phone_code' limit 1;"; + $stmtA="SELECT GMT_offset from vicidial_phone_codes where tz_code='$owner' and country_code='$phone_code' limit 1;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1907,7 +1968,7 @@ foreach(@FILES) } $sthA->finish(); - $stmtA = "select distinct DST_range from vicidial_phone_codes where tz_code='$owner' and country_code='$phone_code' order by DST_range desc limit 1;"; + $stmtA = "SELECT distinct DST_range from vicidial_phone_codes where tz_code='$owner' and country_code='$phone_code' order by DST_range desc limit 1;"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1927,7 +1988,7 @@ foreach(@FILES) ### UNITED STATES ### if ($phone_code =~ /^1$/) { - $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $stmtA = "SELECT country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1947,7 +2008,7 @@ foreach(@FILES) ### MEXICO ### if ($phone_code =~ /^52$/) { - $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; + $stmtA = "SELECT country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and areacode='$USarea';"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1967,7 +2028,7 @@ foreach(@FILES) ### AUSTRALIA ### if ($phone_code =~ /^61$/) { - $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; + $stmtA = "SELECT country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code' and state='$state';"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1987,7 +2048,7 @@ foreach(@FILES) ### ALL OTHER COUNTRY CODES ### if (!$PC_processed) { - $stmtA = "select country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code';"; + $stmtA = "SELECT country_code,country,areacode,state,GMT_offset,DST,DST_range,geographic_description from vicidial_phone_codes where country_code='$phone_code';"; if($DBX){print STDERR "\n|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -2206,6 +2267,8 @@ foreach(@FILES) {$Falert .= "DUPLICATES: $f\n";} if ($h > 0) {$Falert .= "INVALID PHONES: $h\n";} + if ($tnm_delete_count > 0) + {$Falert .= "TNM DELETE COUNT: $tnm_delete_count\n";} if ($q < 1) {print "$Falert";} print Sout "$Falert"; diff --git a/docs/Extended_VL_fields.txt b/docs/Extended_VL_fields.txt new file mode 100644 index 00000000..391a59e5 --- /dev/null +++ b/docs/Extended_VL_fields.txt @@ -0,0 +1,35 @@ +Extended vicidial_list fields 2012-07-13 + + +These fields were added to allow for more complex Call Menu setups with an +additional 20 TINYINT fields allowed for DTMF Log data storage. + +To enable this feature, you must make the database changes shown at the bottom, +and the options.php file needs to have $extended_vl_fields set to '1'. + + + +Database changes: + +ALTER TABLE vicidial_list +ADD q01 TINYINT(1) default '-1', +ADD q02 TINYINT(1) default '-1', +ADD q03 TINYINT(1) default '-1', +ADD q04 TINYINT(1) default '-1', +ADD q05 TINYINT(1) default '-1', +ADD q06 TINYINT(1) default '-1', +ADD q07 TINYINT(1) default '-1', +ADD q08 TINYINT(1) default '-1', +ADD q09 TINYINT(1) default '-1', +ADD q10 TINYINT(1) default '-1', +ADD q11 TINYINT(1) default '-1', +ADD q12 TINYINT(1) default '-1', +ADD q13 TINYINT(1) default '-1', +ADD q14 TINYINT(1) default '-1', +ADD q15 TINYINT(1) default '-1', +ADD q16 TINYINT(1) default '-1', +ADD q17 TINYINT(1) default '-1', +ADD q18 TINYINT(1) default '-1', +ADD q19 TINYINT(1) default '-1', +ADD q20 TINYINT(1) default '-1'; + diff --git a/www/vicidial/AST_agent_time_detail.php b/www/vicidial/AST_agent_time_detail.php index bd4c89e0..0a44187d 100644 --- a/www/vicidial/AST_agent_time_detail.php +++ b/www/vicidial/AST_agent_time_detail.php @@ -392,13 +392,14 @@ else $max_dead=1; $max_customer=1; $GRAPH=""; - $GRAPH2=""; + $GRAPH2=""; $graph_header="
CALLSTIME CLOCKAGENT TIMEWAITTALKDISPOPAUSEDEADCUSTOMER
CALLSTIME CLOCKAGENT TIMEWAITTALKTALKTIME%DISPOPAUSEDEADCUSTOMER
"; $CALLS_graph=$graph_header.""; $TIMECLOCK_graph=$graph_header.""; $AGENTTIME_graph=$graph_header.""; $WAIT_graph=$graph_header.""; $TALK_graph=$graph_header.""; + $TALKPCT_graph=$graph_header.""; $DISPO_graph=$graph_header.""; $PAUSE_graph=$graph_header.""; $DEAD_graph=$graph_header.""; @@ -569,15 +570,15 @@ else if ($file_download < 1) { $ASCII_text.="AGENT TIME BREAKDOWN:\n"; - $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; - $ASCII_text.="| USER NAME | ID | CALLS | TIME CLOCK | AGENT TIME | WAIT | TALK | DISPO | PAUSE | DEAD | CUSTOMER | |$sub_statusesHTML\n"; - $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + $ASCII_text.="| USER NAME | ID | CALLS | TIME CLOCK | AGENT TIME | WAIT | TALK | TALK TIME %| DISPO | PAUSE | DEAD | CUSTOMER | |$sub_statusesHTML\n"; + $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; } else { - $file_output .= "USER,ID,CALLS,TIME CLOCK,AGENT TIME,WAIT,TALK,DISPO,PAUSE,DEAD,CUSTOMER$sub_statusesFILE\n"; + $file_output .= "USER,ID,CALLS,TIME CLOCK,AGENT TIME,WAIT,TALK,TALK TIME %,DISPO,PAUSE,DEAD,CUSTOMER$sub_statusesFILE\n"; } ##### END print the output to screen or put into file output variable @@ -597,6 +598,7 @@ else $SstatusesHTML=''; $SstatusesFILE=''; $Stime[$m] = ($Swait[$m] + $Stalk[$m] + $Sdispo[$m] + $Spause[$m]); + $Stalkpct[$m]=(100*$Stalk[$m]/$Stime[$m]); $RAWuser = $Suser[$m]; $RAWcalls = $Scalls[$m]; $RAWtimeSEC = $Stime[$m]; @@ -609,6 +611,7 @@ else if (trim($Spause[$m])>$max_pause) {$max_pause=trim($Spause[$m]);} if (trim($Sdead[$m])>$max_dead) {$max_dead=trim($Sdead[$m]);} if (trim($Scustomer[$m])>$max_customer) {$max_customer=trim($Scustomer[$m]);} + if (trim($Stalkpct[$m])>$max_talkpct) {$max_talkpct=trim($Stalkpct[$m]);} $graph_stats[$m][1]=trim($Scalls[$m]); $graph_stats[$m][3]=trim($Stime[$m]); $graph_stats[$m][4]=trim($Swait[$m]); @@ -617,7 +620,9 @@ else $graph_stats[$m][7]=trim($Spause[$m]); $graph_stats[$m][8]=trim($Sdead[$m]); $graph_stats[$m][9]=trim($Scustomer[$m]); + $graph_stats[$m][10]=trim(sprintf("%01.2f", $Stalkpct[$m])); + $Stalkpct[$m]= sprintf("%01.2f", $Stalkpct[$m]); $Swait[$m]= sec_convert($Swait[$m],$TIME_agenttimedetail); $Stalk[$m]= sec_convert($Stalk[$m],$TIME_agenttimedetail); $Sdispo[$m]= sec_convert($Sdispo[$m],$TIME_agenttimedetail); @@ -633,6 +638,7 @@ else $RAWpause = $Spause[$m]; $RAWdead = $Sdead[$m]; $RAWcustomer = $Scustomer[$m]; + $RAWtalkpct = $Stalkpct[$m]; $n=0; $user_name_found=0; @@ -747,6 +753,7 @@ else } ### END loop through each status ### + $Stalkpct[$m]= sprintf("%9s", $Stalkpct[$m])."%"; $Swait[$m]= sprintf("%10s", $Swait[$m]); $Stalk[$m]= sprintf("%10s", $Stalk[$m]); $Sdispo[$m]= sprintf("%10s", $Sdispo[$m]); @@ -774,7 +781,7 @@ else if ($file_download < 1) { - $Toutput = "| $Sname[$m] | $Suser[$m] | $Scalls[$m] | $StimeTC[$m]$TCuserAUTOLOGOUT| $Stime[$m] | $Swait[$m] | $Stalk[$m] | $Sdispo[$m] | $Spause[$m] | $Sdead[$m] | $Scustomer[$m] | |$SstatusesHTML\n"; + $Toutput = "| $Sname[$m] | $Suser[$m] | $Scalls[$m] | $StimeTC[$m]$TCuserAUTOLOGOUT| $Stime[$m] | $Swait[$m] | $Stalk[$m] | $Stalkpct[$m] | $Sdispo[$m] | $Spause[$m] | $Sdead[$m] | $Scustomer[$m] | |$SstatusesHTML\n"; $graph_stats[$m][0]=trim("$Suser[$m] - $Sname[$m]"); #CALLS | TIME CLOCK | AGENT TIME | WAIT | TALK | DISPO | PAUSE | DEAD | CUSTOMER | | LOGIN | TRAIN | TOILET | PRECAL | BREAK | | LUNCH | LAGGED } @@ -783,11 +790,12 @@ else if (strlen($RAWtime)<1) {$RAWtime='0';} if (strlen($RAWwait)<1) {$RAWwait='0';} if (strlen($RAWtalk)<1) {$RAWtalk='0';} + if (strlen($RAWtalkpct)<0) {$RAWtalkpct='0.0%';} if (strlen($RAWdispo)<1) {$RAWdispo='0';} if (strlen($RAWpause)<1) {$RAWpause='0';} if (strlen($RAWdead)<1) {$RAWdead='0';} if (strlen($RAWcustomer)<1) {$RAWcustomer='0';} - $fileToutput = "$RAWname,$RAWuser,$RAWcalls,$RAWtimeTC,$RAWtime,$RAWwait,$RAWtalk,$RAWdispo,$RAWpause,$RAWdead,$RAWcustomer$SstatusesFILE\n"; + $fileToutput = "$RAWname,$RAWuser,$RAWcalls,$RAWtimeTC,$RAWtime,$RAWwait,$RAWtalk,$RAWtalkpct %,$RAWdispo,$RAWpause,$RAWdead,$RAWcustomer$SstatusesFILE\n"; } $TOPsorted_output[$m] = $Toutput; @@ -918,6 +926,7 @@ else ### END loop through each status ### ### call function to calculate and print dialable leads + $TOTtalkpct=sprintf("%01.2f", (100*$TOTtalk/$TOTALtime)); $TOTwait = sec_convert($TOTwait,$TIME_agenttimedetail); $TOTtalk = sec_convert($TOTtalk,$TIME_agenttimedetail); $TOTdispo = sec_convert($TOTdispo,$TIME_agenttimedetail); @@ -927,6 +936,7 @@ else $TOTALtime = sec_convert($TOTALtime,$TIME_agenttimedetail); $TOTtimeTC = sec_convert($TOTtimeTC,$TIME_agenttimedetail); + $hTOTtalkpct = sprintf("%10s", $TOTtalkpct)."%"; $hTOTcalls = sprintf("%8s", $TOTcalls); $hTOTwait = sprintf("%11s", $TOTwait); $hTOTtalk = sprintf("%11s", $TOTtalk); @@ -939,12 +949,12 @@ else ###### END LAST LINE TOTALS FORMATTING ########## - + if ($file_download < 1) { - $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; - $ASCII_text.="| TOTALS AGENTS:$hTOT_AGENTS | $hTOTcalls |$hTOTtimeTC |$hTOTALtime |$hTOTwait |$hTOTtalk |$hTOTdispo |$hTOTpause |$hTOTdead |$hTOTcustomer | |$SUMstatusesHTML\n"; - $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; + $ASCII_text.="| TOTALS AGENTS:$hTOT_AGENTS | $hTOTcalls |$hTOTtimeTC |$hTOTALtime |$hTOTwait |$hTOTtalk |$hTOTtalkpct |$hTOTdispo |$hTOTpause |$hTOTdead |$hTOTcustomer | |$SUMstatusesHTML\n"; + $ASCII_text.="+-----------------+----------+----------+------------+------------+------------+------------+------------+------------+------------+------------+------------+ +$sub_statusesHEAD\n"; if ($AUTOLOGOUTflag > 0) {echo " * denotes AUTOLOGOUT from timeclock\n";} $ASCII_text.="\n\n"; @@ -967,6 +977,7 @@ else $PAUSE_graph.=" "; $DEAD_graph.=" "; $CUSTOMER_graph.=" "; + $TALKPCT_graph.=" "; for ($e=0; $e
AGENT TIME BREAKDOWN
STATUSCALLS
TIME CLOCK
AGENT TIME
WAIT
TALK
TALK TIME %
DISPO
PAUSE
DEAD
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][7], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][8], 'HF')."
".$graph_stats[$d][0]."".sec_convert($graph_stats[$d][9], 'HF')."
".$graph_stats[$d][0]."".$graph_stats[$d][10]." %
"; $DEAD_graph.="TOTAL:".trim($hTOTdead).""; $CUSTOMER_graph.="TOTAL:".trim($hTOTcustomer).""; + $TALKPCT_graph.="AVERAGE:".trim($hTOTtalkpct).""; for ($e=0; $e
 


"; + $GRAPH3="
 


"; # echo $GRAPH.$GRAPH2.$GRAPH3.$max; } else { - $file_output .= "TOTALS,$TOT_AGENTS,$TOTcalls,$TOTtimeTC,$TOTALtime,$TOTwait,$TOTtalk,$TOTdispo,$TOTpause,$TOTdead,$TOTcustomer$SUMstatusesFILE\n"; + $file_output .= "TOTALS,$TOT_AGENTS,$TOTcalls,$TOTtimeTC,$TOTALtime,$TOTwait,$TOTtalk,$TOTtalkpct %,$TOTdispo,$TOTpause,$TOTdead,$TOTcustomer$SUMstatusesFILE\n"; } } diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index e57e0f52..be2aa125 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -1724,6 +1724,10 @@ if (isset($_GET["territory_reset"])) {$territory_reset=$_GET["territory_reset" elseif (isset($_POST["territory_reset"])) {$territory_reset=$_POST["territory_reset"];} if (isset($_GET["hopper_vlc_dup_check"])) {$hopper_vlc_dup_check=$_GET["hopper_vlc_dup_check"];} elseif (isset($_POST["hopper_vlc_dup_check"])) {$hopper_vlc_dup_check=$_POST["hopper_vlc_dup_check"];} +if (isset($_GET["download_max_system_stats_metric"])) {$download_max_system_stats_metric=$_GET["download_max_system_stats_metric"];} + elseif (isset($_POST["download_max_system_stats_metric"])) {$download_max_system_stats_metric=$_POST["download_max_system_stats_metric"];} +if (isset($_GET["download_max_system_stats_metric_name"])) {$download_max_system_stats_metric_name=$_GET["download_max_system_stats_metric_name"];} + elseif (isset($_POST["download_max_system_stats_metric_name"])) {$download_max_system_stats_metric_name=$_POST["download_max_system_stats_metric_name"];} if (isset($_GET["inventory_report"])) {$inventory_report=$_GET["inventory_report"];} elseif (isset($_POST["inventory_report"])) {$inventory_report=$_POST["inventory_report"];} if (isset($_GET["report_rank"])) {$report_rank=$_GET["report_rank"];} @@ -1755,6 +1759,58 @@ if (strlen($dial_status) > 0) $status = $dial_status; } +if ($download_max_system_stats_metric_name) { + if (!$query_date) {$query_date=date("Y-m-d", time()-(29*86400));} + if (!$end_date) { + $end_date=date("Y-m-d", time()); + } else if (strtotime($end_date)>strtotime(date("Y-m-d"))) { + $end_date=date("Y-m-d"); + } + if ($query_date>$end_date) {$query_date=$end_date;} + + $num_graph_days = ceil(abs(strtotime($end_date) - strtotime($query_date)) / 86400)+1; + $CSV_text=""; + + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="total call count in and out") { + download_max_system_stats($campaign_id,$num_graph_days,'system','total_calls','total call count in and out',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="total inbound call count") { + download_max_system_stats($campaign_id,$num_graph_days,'system','total_calls_inbound_all','total inbound call count',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="total outbound call count") { + download_max_system_stats($campaign_id,$num_graph_days,'system','total_calls_outbound_all','total outbound call count',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent calls in and out") { + download_max_system_stats($campaign_id,$num_graph_days,'system','(max_inbound + max_outbound)','most concurrent calls in and out',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent calls inbound total") { + download_max_system_stats($campaign_id,$num_graph_days,'system','max_inbound','most concurrent calls inbound total',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent calls outbound total") { + download_max_system_stats($campaign_id,$num_graph_days,'system','max_outbound','most concurrent calls outbound total',$end_date); + } + if ($download_max_system_stats_metric_name=="ALL" || $download_max_system_stats_metric_name=="most concurrent agents") { + download_max_system_stats($campaign_id,$num_graph_days,'system','max_agents','most concurrent agents',$end_date); + } + + $FILE_TIME = date("Ymd-His"); + $CSVfilename = "MAX_SYSTEM_STATS_$US$FILE_TIME.csv"; + $CSV_text=preg_replace('/ +\"/', '"', $CSV_text); + $CSV_text=preg_replace('/\" +/', '"', $CSV_text); + header('Content-type: application/octet-stream'); + + header("Content-Disposition: attachment; filename=\"$CSVfilename\""); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + ob_clean(); + flush(); + + echo "$CSV_text"; + + exit; +} + ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server,voicemail_timezones,default_voicemail_timezone,default_local_gmt,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,call_menu_qualify_enabled FROM system_settings;"; @@ -3078,12 +3134,13 @@ else # 120526-0827 - Added User Group User Login Report # 120529-2112 - Added safe_harbor_audio_field campaign option # 120706-1255 - Added Max stats date range and call menu qualify_sql options +# 120713-2123 - Added max stats download link and extended_vl option # # 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.6-371a'; -$build = '120706-1255'; +$admin_version = '2.6-372a'; +$build = '120713-2123'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -26660,8 +26717,17 @@ if ($ADD==3511) { echo "\n"; } + + if (file_exists('options.php')) + {require('options.php');} + $extended_vl_fields_OPTIONS=''; + if ($extended_vl_fields > 0) + { + $extended_vl_fields_OPTIONS = ''; + } + echo "$NWB#vicidial_call_menu-dtmf_log$NWE     Log Field: \n"; - echo "$NWB#vicidial_call_menu-dtmf_field$NWE\n"; + echo "$NWB#vicidial_call_menu-dtmf_field$NWE\n"; echo " \n"; echo " Call Menu Options: \n"; @@ -33267,7 +33333,7 @@ if ($ADD==999992) echo "o_cal.a_tpl.yearscroll = false;\n"; echo "// o_cal.a_tpl.weekstart = 1; // Monday week start\n"; echo "    
\n"; - echo "
\n"; + echo "
[DOWNLOAD ALL]
\n"; if ( (preg_match("/Maximum System Stats/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { @@ -33284,31 +33350,38 @@ if ($ADD==999992) } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } else diff --git a/www/vicidial/admin_lists_custom.php b/www/vicidial/admin_lists_custom.php index fef28e1f..48fd4fd7 100644 --- a/www/vicidial/admin_lists_custom.php +++ b/www/vicidial/admin_lists_custom.php @@ -22,10 +22,11 @@ # 111025-1432 - Fixed case sensitivity on list fields # 120122-1349 - Force vicidial_list custom field labels to be all lower case # 120223-2315 - Removed logging of good login passwords if webroot writable is enabled +# 120713-2101 - Added extended_vl_fields option # -$admin_version = '2.4-16'; -$build = '120223-2315'; +$admin_version = '2.4-17'; +$build = '120713-2101'; require("dbconnect.php"); @@ -153,8 +154,16 @@ $STARTtime = date("U"); $TODAY = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); +if (file_exists('options.php')) + {require('options.php');} + $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|status|entry_date|entry_list_id|modify_date|user|'; +if ($extended_vl_fields > 0) + { + $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|status|entry_date|entry_list_id|modify_date|user|q01|q02|q03|q04|q05|q06|q07|q08|q09|q10|q11|q12|q13|q14|q15|q16|q17|q18|q19|q20|'; + } + $mysql_reserved_words = '|accessible|action|add|all|alter|analyze|and|as|asc|asensitive|before|between|bigint|binary|bit|blob|both|by|call|cascade|case|change|char|character|check|collate|column|condition|constraint|continue|convert|create|cross|current_date|current_time|current_timestamp|current_user|cursor|database|databases|date|day_hour|day_microsecond|day_minute|day_second|dec|decimal|declare|default|delayed|delete|desc|describe|deterministic|distinct|distinctrow|div|double|drop|dual|each|else|elseif|enclosed|enum|escaped|exists|exit|explain|false|fetch|float|float4|float8|for|force|foreign|from|fulltext|grant|group|having|high_priority|hour_microsecond|hour_minute|hour_second|if|ignore|in|index|infile|inner|inout|insensitive|insert|int|int1|int2|int3|int4|int8|integer|interval|into|is|iterate|join|key|keys|kill|leading|leave|left|like|limit|linear|lines|load|localtime|localtimestamp|lock|long|longblob|longtext|loop|low_priority|master_ssl_verify_server_cert|match|mediumblob|mediumint|mediumtext|middleint|minute_microsecond|minute_second|mod|modifies|mysql|natural|no|no_write_to_binlog|not|null|numeric|on|optimize|option|optionally|or|order|out|outer|outfile|precision|primary|procedure|purge|range|read|read_only|read_write|reads|real|references|regexp|release|remove|rename|repeat|replace|require|restrict|return|revoke|right|rlike|schema|schemas|second_microsecond|select|sensitive|separator|set|show|smallint|spatial|specific|sql|sql_big_result|sql_calc_found_rows|sql_small_result|sqlexception|sqlstate|sqlwarning|ssl|starting|straight_join|table|terminated|text|then|time|timestamp|tinyblob|tinyint|tinytext|to|trailing|trigger|true|undo|union|unique|unlock|unsigned|update|usage|use|using|utc_date|utc_time|utc_timestamp|values|varbinary|varchar|varcharacter|varying|when|where|while|with|write|xor|year_month|zerofill|'; diff --git a/www/vicidial/functions.php b/www/vicidial/functions.php index 1dd9464c..1d6ed60a 100644 --- a/www/vicidial/functions.php +++ b/www/vicidial/functions.php @@ -13,6 +13,7 @@ # 111222-2124 - Added max stats bar chart function # 120125-1235 - Small changes to max stats function to allow for total system stats # 120213-1417 - Changes to allow for ra stats +# 120713-2137 - Added download function for max stats # ##### reformat seconds into HH:MM:SS or MM:SS ##### @@ -102,28 +103,35 @@ function array_group_count($array, $sort = false) ##### bar chart using max stats data ##### -function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$metric_name,$more_link) +function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$metric_name,$more_link,$END_DATE,$download_link) { $stats_start_time = time(); - $Bstats_date[0]=date("Y-m-d"); + if ($END_DATE) + { + $Bstats_date[0]=$END_DATE; + } + else + { + $Bstats_date[0]=date("Y-m-d"); + } $Btotal_calls[0]=0; $link_text=''; $max_count=0; $i=0; - $NWB = "   \"HELP\""; ### get stats for last X days - $stmt="SELECT stats_date,$metric from vicidial_daily_max_stats where campaign_id='$campaign_id' and stats_flag='OPEN';"; + $stmt="SELECT stats_date,$metric from vicidial_daily_max_stats where campaign_id='$campaign_id' and stats_flag='OPEN' and stats_date<='$Bstats_date[0]';"; if ($metric=='total_calls_inbound_all') - {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_type='INGROUP' and stats_flag='OPEN' group by stats_date;";} + {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_type='INGROUP' and stats_flag='OPEN' and stats_date<='$Bstats_date[0]' group by stats_date;";} if ($metric=='total_calls_outbound_all') - {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_type='CAMPAIGN' and stats_flag='OPEN' group by stats_date;";} + {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_type='CAMPAIGN' and stats_flag='OPEN' and stats_date<='$Bstats_date[0]' group by stats_date;";} if ($metric=='ra_total_calls') - {$stmt="SELECT stats_date,total_calls from vicidial_daily_ra_stats where stats_flag='OPEN' and user='$campaign_id';";} + {$stmt="SELECT stats_date,total_calls from vicidial_daily_ra_stats where stats_flag='OPEN' and stats_date<='$Bstats_date[0]' and user='$campaign_id';";} if ($metric=='ra_concurrent_calls') - {$stmt="SELECT stats_date,max_calls from vicidial_daily_ra_stats where stats_flag='OPEN' and user='$campaign_id';";} + {$stmt="SELECT stats_date,max_calls from vicidial_daily_ra_stats where stats_flag='OPEN' and stats_date<='$Bstats_date[0]' and user='$campaign_id';";} $rslt=mysql_query($stmt, $link); $Xstats_to_print = mysql_num_rows($rslt); if ($Xstats_to_print > 0) @@ -137,8 +145,6 @@ function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$met $stats_start_time = mktime(10, 10, 10, $stats_date_ARRAY[1], $stats_date_ARRAY[2], $stats_date_ARRAY[0]); while($i <= $days_graph) { - $i++; - $stats_start_time = ($stats_start_time - 86400); $Bstats_date[$i] = date("Y-m-d", $stats_start_time); $Btotal_calls[$i]=0; $stmt="SELECT stats_date,$metric from vicidial_daily_max_stats where campaign_id='$campaign_id' and stats_date='$Bstats_date[$i]';"; @@ -150,6 +156,7 @@ function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$met {$stmt="SELECT stats_date,total_calls from vicidial_daily_ra_stats where stats_date='$Bstats_date[$i]' and user='$campaign_id';";} if ($metric=='ra_concurrent_calls') {$stmt="SELECT stats_date,max_calls from vicidial_daily_ra_stats where stats_date='$Bstats_date[$i]' and user='$campaign_id';";} + echo "\n"; $rslt=mysql_query($stmt, $link); $Ystats_to_print = mysql_num_rows($rslt); if ($Ystats_to_print > 0) @@ -158,6 +165,8 @@ function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$met $Btotal_calls[$i] = $rowx[1]; if ($max_count < $Btotal_calls[$i]) {$max_count = $Btotal_calls[$i];} } + $i++; + $stats_start_time = ($stats_start_time - 86400); } if ($max_count < 1) {echo "";} @@ -188,4 +197,90 @@ function horizontal_bar_chart($campaign_id,$days_graph,$title,$link,$metric,$met echo "
\n"; - horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'total_calls','total call count in and out',0,$end_date); + $download_link="[DOWNLOAD]"; + horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'total_calls','total call count in and out',0,$end_date,$download_link); echo "
\n"; - horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'total_calls_inbound_all','total inbound call count',0,$end_date); + $download_link="[DOWNLOAD]"; + horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'total_calls_inbound_all','total inbound call count',0,$end_date,$download_link); echo "
\n"; - horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'total_calls_outbound_all','total outbound call count',0,$end_date); + $download_link="[DOWNLOAD]"; + horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'total_calls_outbound_all','total outbound call count',0,$end_date,$download_link); echo "
\n"; - horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'(max_inbound + max_outbound)','most concurrent calls in and out',0,$end_date); + $download_link="[DOWNLOAD]"; + horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'(max_inbound + max_outbound)','most concurrent calls in and out',0,$end_date,$download_link); echo "
\n"; - horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'max_inbound','most concurrent calls inbound total',0,$end_date); + $download_link="[DOWNLOAD]"; + horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'max_inbound','most concurrent calls inbound total',0,$end_date,$download_link); echo "
\n"; - horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'max_outbound','most concurrent calls outbound total',0,$end_date); + $download_link="[DOWNLOAD]"; + horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'max_outbound','most concurrent calls outbound total',0,$end_date,$download_link); echo "
\n"; - horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'max_agents','most concurrent agents',0,$end_date); + $download_link="[DOWNLOAD]"; + horizontal_bar_chart($campaign_id,$num_graph_days,'system',$link,'max_agents','most concurrent agents',0,$end_date,$download_link); echo "
\n"; } } + +##### bar chart using max stats data ##### +function download_max_system_stats($campaign_id,$days_graph,$title,$metric,$metric_name,$END_DATE) + { + global $CSV_text, $link; + $stats_start_time = time(); + if ($END_DATE) + { + $Bstats_date[0]=$END_DATE; + } + else + { + $Bstats_date[0]=date("Y-m-d"); + } + $Btotal_calls[0]=0; + $link_text=''; + $i=0; + + ### get stats for last X days + $stmt="SELECT stats_date,$metric from vicidial_daily_max_stats where campaign_id='$campaign_id' and stats_flag='OPEN' and stats_date<='$Bstats_date[0]';"; + if ($metric=='total_calls_inbound_all') + {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_type='INGROUP' and stats_flag='OPEN' and stats_date<='$Bstats_date[0]' group by stats_date;";} + if ($metric=='total_calls_outbound_all') + {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_type='CAMPAIGN' and stats_flag='OPEN' and stats_date<='$Bstats_date[0]' group by stats_date;";} + if ($metric=='ra_total_calls') + {$stmt="SELECT stats_date,total_calls from vicidial_daily_ra_stats where stats_flag='OPEN' and stats_date<='$Bstats_date[0]' and user='$campaign_id';";} + if ($metric=='ra_concurrent_calls') + {$stmt="SELECT stats_date,max_calls from vicidial_daily_ra_stats where stats_flag='OPEN' and stats_date<='$Bstats_date[0]' and user='$campaign_id';";} + $rslt=mysql_query($stmt, $link); + $Xstats_to_print = mysql_num_rows($rslt); + if ($Xstats_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $Bstats_date[0] = $rowx[0]; + $Btotal_calls[0] = $rowx[1]; + if ($max_count < $Btotal_calls[0]) {$max_count = $Btotal_calls[0];} + } + $stats_date_ARRAY = explode("-",$Bstats_date[0]); + $stats_start_time = mktime(10, 10, 10, $stats_date_ARRAY[1], $stats_date_ARRAY[2], $stats_date_ARRAY[0]); + while($i <= $days_graph) + { + $Bstats_date[$i] = date("Y-m-d", $stats_start_time); + $Btotal_calls[$i]=0; + $stmt="SELECT stats_date,$metric from vicidial_daily_max_stats where campaign_id='$campaign_id' and stats_date='$Bstats_date[$i]';"; + if ($metric=='total_calls_inbound_all') + {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_date='$Bstats_date[$i]' and stats_type='INGROUP' group by stats_date;";} + if ($metric=='total_calls_outbound_all') + {$stmt="SELECT stats_date,sum(total_calls) from vicidial_daily_max_stats where stats_date='$Bstats_date[$i]' and stats_type='CAMPAIGN' group by stats_date;";} + if ($metric=='ra_total_calls') + {$stmt="SELECT stats_date,total_calls from vicidial_daily_ra_stats where stats_date='$Bstats_date[$i]' and user='$campaign_id';";} + if ($metric=='ra_concurrent_calls') + {$stmt="SELECT stats_date,max_calls from vicidial_daily_ra_stats where stats_date='$Bstats_date[$i]' and user='$campaign_id';";} + $rslt=mysql_query($stmt, $link); + $Ystats_to_print = mysql_num_rows($rslt); + if ($Ystats_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $Btotal_calls[$i] = $rowx[1]; + if ($max_count < $Btotal_calls[$i]) {$max_count = $Btotal_calls[$i];} + } + $i++; + $stats_start_time = ($stats_start_time - 86400); + } + + if ($title=='campaign') {$out_in_type=' outbound';} + if ($title=='in-group') {$out_in_type=' inbound';} + $CSV_text.="\"$days_graph Day $out_in_type $metric_name for this $title\"\n"; + + if ($max_count < 1) + {$CSV_text.="\"no max stats cache summary information available\"\n";} + else + { + $CSV_text.="\"DATE\",\"$metric_name\"\n"; + + $i=0; + while($i < $days_graph) + { + $bar_width = intval($max_multi * $Btotal_calls[$i]); + if ($Btotal_calls[$i] < 1) {$Btotal_calls[$i] = "-none-";} + $CSV_text.="\"$Bstats_date[$i]\",\"$Btotal_calls[$i]\"\n"; + $i++; + } + + $CSV_text.="\n\n"; + } + } ?> \ No newline at end of file diff --git a/www/vicidial/list_download.php b/www/vicidial/list_download.php index fa1d0e31..c6be93f3 100644 --- a/www/vicidial/list_download.php +++ b/www/vicidial/list_download.php @@ -4,7 +4,7 @@ # downloads the entire contents of a vicidial list ID to a flat text file # that is tab delimited # -# Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2012 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -20,6 +20,7 @@ # 100924-1609 - Added ALL-LISTS option for downloading everything # 100929-1919 - Fixed ALL-LISTS download option to include custom fields # 101004-2108 - Added generic custom column headers for custom fields +# 120713-2110 - Added extended_vl_fields option # require("dbconnect.php"); @@ -112,6 +113,16 @@ if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL exit; } +if (file_exists('options.php')) + {require('options.php');} +$extended_vl_fields_SQL=''; +$extended_vl_fields_HEADER=''; +if ($extended_vl_fields > 0) + { + $extended_vl_fields_SQL = ',q01,q02,q03,q04,q05,q06,q07,q08,q09,q10,q11,q12,q13,q14,q15,q16,q17,q18,q19,q20'; + $extended_vl_fields_HEADER = "\tq01\tq02\tq03\tq04\tq05\tq06\tq07\tq08\tq09\tq10\tq11\tq12\tq13\tq14\tq15\tq16\tq17\tq18\tq19\tq20"; + } + $LOGallowed_campaignsSQL=''; if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) { @@ -304,13 +315,13 @@ else { $TXTfilename = "LIST_$list_id$US$FILE_TIME.txt"; $list_id_header=''; - $stmt="select lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner from vicidial_list where list_id='$list_id';"; + $stmt="select lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner $extended_vl_fields_SQL from vicidial_list where list_id='$list_id';"; if ($list_id=='ALL-LISTS') { $list_id_header="list_id\t"; - $stmt="select list_id,lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner from vicidial_list where list_id > 0;"; + $stmt="select list_id,lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner $extended_vl_fields_SQL from vicidial_list where list_id > 0;"; } - $header_row = $list_id_header . "lead_id\tentry_date\tmodify_date\tstatus\tuser\tvendor_lead_code\tsource_id\tlist_id\tgmt_offset_now\tcalled_since_last_reset\tphone_code\tphone_number\ttitle\tfirst_name\tmiddle_initial\tlast_name\taddress1\taddress2\taddress3\tcity\tstate\tprovince\tpostal_code\tcountry_code\tgender\tdate_of_birth\talt_phone\temail\tsecurity_phrase\tcomments\tcalled_count\tlast_local_call_time\trank\towner"; + $header_row = $list_id_header . "lead_id\tentry_date\tmodify_date\tstatus\tuser\tvendor_lead_code\tsource_id\tlist_id\tgmt_offset_now\tcalled_since_last_reset\tphone_code\tphone_number\ttitle\tfirst_name\tmiddle_initial\tlast_name\taddress1\taddress2\taddress3\tcity\tstate\tprovince\tpostal_code\tcountry_code\tgender\tdate_of_birth\talt_phone\temail\tsecurity_phrase\tcomments\tcalled_count\tlast_local_call_time\trank\towner$extended_vl_fields_HEADER"; $header_columns=''; } @@ -342,16 +353,21 @@ while ($i < $leads_to_print) else { $row[29] = preg_replace("/\n|\r/",'!N',$row[29]); + $extended_vl_fields_DATA=''; if ($list_id=='ALL-LISTS') { - $row_data[$i] .= "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\t$row[33]\t$row[34]"; + if ($extended_vl_fields > 0) + {$extended_vl_fields_DATA = "\t$row[33]\t$row[34]\t$row[35]\t$row[36]\t$row[37]\t$row[38]\t$row[39]\t$row[40]\t$row[41]\t$row[42]\t$row[43]\t$row[44]\t$row[45]\t$row[46]\t$row[47]\t$row[48]\t$row[49]\t$row[50]\t$row[51]\t$row[52]";} + $row_data[$i] .= "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\t$row[33]\t$row[34]$extended_vl_fields_DATA"; $export_list_id[$i] = $row[0]; $export_lead_id[$i] = $row[1]; } else { - $row_data[$i] .= "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\t$row[33]"; + if ($extended_vl_fields > 0) + {$extended_vl_fields_DATA = "\t$row[34]\t$row[35]\t$row[36]\t$row[37]\t$row[38]\t$row[39]\t$row[40]\t$row[41]\t$row[42]\t$row[43]\t$row[44]\t$row[45]\t$row[46]\t$row[47]\t$row[48]\t$row[49]\t$row[50]\t$row[51]\t$row[52]\t$row[53]";} + $row_data[$i] .= "$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]\t$row[5]\t$row[6]\t$row[7]\t$row[8]\t$row[9]\t$row[10]\t$row[11]\t$row[12]\t$row[13]\t$row[14]\t$row[15]\t$row[16]\t$row[17]\t$row[18]\t$row[19]\t$row[20]\t$row[21]\t$row[22]\t$row[23]\t$row[24]\t$row[25]\t$row[26]\t$row[27]\t$row[28]\t$row[29]\t$row[30]\t$row[31]\t$row[32]\t$row[33]$extended_vl_fields_DATA"; $export_list_id[$i] = $list_id; $export_lead_id[$i] = $row[0]; } diff --git a/www/vicidial/options-example.php b/www/vicidial/options-example.php index c32d51f7..592a9366 100644 --- a/www/vicidial/options-example.php +++ b/www/vicidial/options-example.php @@ -11,6 +11,7 @@ # 110708-1730 - Added precision time setting # 120102-2112 - Added inventory_allow_realtime option # 120213-1500 - Added option to log non-agent-API calls +# 120713-1915 - Added option for extended vicidial_list fields for long surveys # # used by the realtime_report.php script @@ -63,5 +64,7 @@ $inventory_allow_realtime = 0; # allow real-time report generation for inventory # used by non-agent-API for non-admin functions $api_url_log = 0; # log non-agent-api calls to the vicidial_url_log +# extended vicidial_list fields for long surveys(requires database schema change) +$extended_vl_fields = 0; ?>