Added ability to search by callerid number when calls come into a DID and send matches to a different route

Added ability to clean up callerid numbers when calls come into a DID
Renamed "In-Groups" header in admin.php to "Inbound" to reflect that it is not just for In-groups, but includes DIDs and Call Menus as well
Added ability to download DNC numbers from the internal and campaign-specific DNC lists

git-svn-id: svn://192.168.202.10@1494 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2010-08-05 20:01:55 +00:00
parent 30ada491ff
commit 824648e3f3
9 changed files with 1176 additions and 94 deletions
+200 -53
View File
@@ -16,6 +16,7 @@
# 100702-1335 - Added custom fields
# 100712-1324 - Added system setting slave server option
# 100802-2347 - Added User Group Allowed Reports option validation
# 100804-1745 - Added option to download DNC and FPGN lists
#
require("dbconnect.php");
@@ -31,8 +32,13 @@ if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];}
if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];}
elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];}
if (isset($_GET["group_id"])) {$group_id=$_GET["group_id"];}
elseif (isset($_POST["group_id"])) {$group_id=$_POST["group_id"];}
if (isset($_GET["download_type"])) {$download_type=$_GET["download_type"];}
elseif (isset($_POST["download_type"])) {$download_type=$_POST["download_type"];}
if (strlen($shift)<2) {$shift='ALL';}
if ($group_id=='SYSTEM_INTERNAL') {$download_type='systemdnc';}
$report_name = 'Download List';
$db_source = 'M';
@@ -111,39 +117,148 @@ if ( (!eregi("-ALL",$LOGallowed_campaigns)) )
$LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')";
}
$stmt="select count(*) from vicidial_lists where list_id='$list_id' $LOGallowed_campaignsSQL;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$count_to_print = mysql_num_rows($rslt);
if ($count_to_print > 0)
if ($download_type == 'systemdnc')
{
$row=mysql_fetch_row($rslt);
$lists_allowed =$row[0];
$i++;
##### System DNC list validation #####
$event_code_type='SYSTEM INTERNAL DNC';
if (strlen($LOGallowed_campaignsSQL) > 2)
{
echo "You are not allowed to download this list: $list_id\n";
exit;
}
$stmt="select count(*) from vicidial_dnc;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$count_to_print = mysql_num_rows($rslt);
if ($count_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$leads_count =$row[0];
$i++;
}
if ($leads_count < 1)
{
echo "There are no phone numbers in list: SYSTEM INTERNAL DNC\n";
exit;
}
}
elseif ($download_type == 'dnc')
{
##### Campaign DNC list validation #####
$event_code_type='CAMPAIGN DNC';
$stmt="select count(*) from vicidial_campaigns where campaign_id='$group_id' $LOGallowed_campaignsSQL;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$count_to_print = mysql_num_rows($rslt);
if ($count_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$lists_allowed =$row[0];
$i++;
}
if ($lists_allowed < 1)
{
echo "You are not allowed to download this list: $group_id\n";
exit;
}
$stmt="select count(*) from vicidial_campaign_dnc where campaign_id='$group_id';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$count_to_print = mysql_num_rows($rslt);
if ($count_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$leads_count =$row[0];
$i++;
}
if ($leads_count < 1)
{
echo "There are no leads in Campaign DNC list: $group_id\n";
exit;
}
}
elseif ($download_type == 'fpgn')
{
##### Filter Phone Group list validation #####
$event_code_type='FILTER PHONE GROUP';
$stmt="select count(*) from vicidial_filter_phone_groups where filter_phone_group_id='$group_id';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$count_to_print = mysql_num_rows($rslt);
if ($count_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$lists_allowed =$row[0];
$i++;
}
if ($lists_allowed < 1)
{
echo "You are not allowed to download this list: $group_id\n";
exit;
}
$stmt="select count(*) from vicidial_filter_phone_numbers where filter_phone_group_id='$group_id';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$count_to_print = mysql_num_rows($rslt);
if ($count_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$leads_count =$row[0];
$i++;
}
if ($leads_count < 1)
{
echo "There are no leads in this filter phone group: $group_id\n";
exit;
}
}
else
{
##### list download validation #####
$event_code_type='LIST';
$stmt="select count(*) from vicidial_lists where list_id='$list_id' $LOGallowed_campaignsSQL;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$count_to_print = mysql_num_rows($rslt);
if ($count_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$lists_allowed =$row[0];
$i++;
}
if ($lists_allowed < 1)
{
echo "You are not allowed to download this list: $list_id\n";
exit;
}
$stmt="select count(*) from vicidial_list where list_id='$list_id';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$count_to_print = mysql_num_rows($rslt);
if ($count_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$leads_count =$row[0];
$i++;
}
if ($leads_count < 1)
{
echo "There are no leads in list_id: $list_id\n";
exit;
}
}
if ($lists_allowed < 1)
{
echo "You are not allowed to download this list: $list_id\n";
exit;
}
$stmt="select count(*) from vicidial_list where list_id='$list_id';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$count_to_print = mysql_num_rows($rslt);
if ($count_to_print > 0)
{
$row=mysql_fetch_row($rslt);
$leads_count =$row[0];
$i++;
}
if ($leads_count < 1)
{
echo "There are no leads in list_id: $list_id\n";
exit;
}
$US='_';
$MT[0]='';
@@ -156,16 +271,35 @@ if (!isset($group)) {$group = '';}
if (!isset($query_date)) {$query_date = $NOW_DATE;}
if (!isset($end_date)) {$end_date = $NOW_DATE;}
### LOG INSERTION Admin Log Table ###
$SQL_log = "$stmt|$stmtA|";
$SQL_log = ereg_replace(';','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='EXPORT', record_id='$list_id', event_code='ADMIN EXPORT LIST', event_sql=\"$SQL_log\", event_notes='';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
$TXTfilename = "LIST_$list_id$US$FILE_TIME.txt";
if ($download_type == 'systemdnc')
{
$TXTfilename = "SYSTEM_DNC_$FILE_TIME.txt";
$header_row = "phone_number";
$header_columns='';
$stmt="select phone_number from vicidial_dnc;";
}
elseif ($download_type == 'dnc')
{
$TXTfilename = "DNC_$group_id$US$FILE_TIME.txt";
$header_row = "phone_number";
$header_columns='';
$stmt="select phone_number from vicidial_campaign_dnc where campaign_id='$group_id';";
}
elseif ($download_type == 'fpgn')
{
$TXTfilename = "FPGN_$group_id$US$FILE_TIME.txt";
$header_row = "phone_number";
$header_columns='';
$stmt="select phone_number from vicidial_filter_phone_numbers where filter_phone_group_id='$group_id';";
}
else
{
$TXTfilename = "LIST_$list_id$US$FILE_TIME.txt";
$header_row = "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_columns='';
$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';";
}
// We'll be outputting a TXT file
header('Content-type: application/octet-stream');
@@ -178,10 +312,8 @@ header('Pragma: public');
ob_clean();
flush();
$header_row = "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_columns='';
$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';";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$leads_to_print = mysql_num_rows($rslt);
@@ -190,16 +322,22 @@ while ($i < $leads_to_print)
{
$row=mysql_fetch_row($rslt);
$row[29] = preg_replace("/\n|\r/",'!N',$row[29]);
$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]";
$export_lead_id[$i] = $row[0];
if ( ($download_type == 'systemdnc') or ($download_type == 'dnc') or ($download_type == 'fpgn') )
{
$row_data[$i] .= "$row[0]";
}
else
{
$row[29] = preg_replace("/\n|\r/",'!N',$row[29]);
$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]";
$export_lead_id[$i] = $row[0];
}
$i++;
}
if ($custom_fields_enabled > 0)
if ( ($custom_fields_enabled > 0) and ($event_code_type=='LIST') )
{
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
if ($DB>0) {echo "$stmt";}
@@ -207,9 +345,9 @@ if ($custom_fields_enabled > 0)
$tablecount_to_print = mysql_num_rows($rslt);
if ($tablecount_to_print > 0)
{
$stmt = "describe custom_$list_id;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$stmtA = "describe custom_$list_id;";
$rslt=mysql_query($stmtA, $link);
if ($DB) {echo "$stmtA\n";}
$columns_ct = mysql_num_rows($rslt);
$u=0;
while ($columns_ct > $u)
@@ -225,9 +363,9 @@ if ($custom_fields_enabled > 0)
$i=0;
while ($i < $leads_to_print)
{
$stmt = "SELECT * from custom_$list_id where lead_id='$export_lead_id[$i]' limit 1;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$stmtA = "SELECT * from custom_$list_id where lead_id='$export_lead_id[$i]' limit 1;";
$rslt=mysql_query($stmtA, $link);
if ($DB) {echo "$stmtA\n";}
$customfield_ct = mysql_num_rows($rslt);
if ($customfield_ct > 0)
{
@@ -250,6 +388,15 @@ if ($custom_fields_enabled > 0)
}
### LOG INSERTION Admin Log Table ###
$SQL_log = "$stmt|$stmtA|";
$SQL_log = ereg_replace(';','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LEADS', event_type='EXPORT', record_id='$list_id', event_code='ADMIN EXPORT $event_code_type', event_sql=\"$SQL_log\", event_notes='';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
echo "$header_row$header_columns\r\n";
$i=0;