Added archive search options to Export Leads Report

git-svn-id: svn://192.168.202.10@2521 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2016-04-20 18:12:22 +00:00
parent d56b5edb97
commit c96c829250
+63 -7
View File
@@ -5,7 +5,7 @@
# vicidial_log and/or vicidial_closer_log information by status, list_id and
# date range. downloads to a flat text file that is tab delimited
#
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2016 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
#
@@ -23,6 +23,7 @@
# 150727-2145 - Enabled user features for hiding phone numbers and lead data
# 150903-1539 - Added compatibility for custom fields data options
# 150909-0749 - Fixed issues with translated select list values, issue #885
# 160420-1407 - Added archive search options
#
$startMS = microtime();
@@ -65,6 +66,10 @@ 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["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];}
elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];}
if (isset($_GET["vicidial_list_archive_only"])) {$vicidial_list_archive_only=$_GET["vicidial_list_archive_only"];}
elseif (isset($_POST["vicidial_list_archive_only"])) {$vicidial_list_archive_only=$_POST["vicidial_list_archive_only"];}
if (strlen($shift)<2) {$shift='ALL';}
@@ -93,6 +98,45 @@ if ($qm_conf_ct > 0)
##### END SETTINGS LOOKUP #####
###########################################
### ARCHIVED DATA CHECK CONFIGURATION
$archives_available="N";
$log_tables_array=array("vicidial_log", "vicidial_closer_log", "vicidial_log_extended", "recording_log", "vicidial_carrier_log", "vicidial_cpd_log", "vicidial_list");
for ($t=0; $t<count($log_tables_array); $t++)
{
$table_name=$log_tables_array[$t];
$archive_table_name=use_archive_table($table_name);
if ($archive_table_name!=$table_name) {$archives_available="Y";}
}
if (preg_match('/VLIST/i', $search_archived_data))
{
$vicidial_list_table=use_archive_table("vicidial_list");
}
else
{
$vicidial_list_table="vicidial_list";
}
if (preg_match('/LOGS/i', $search_archived_data))
{
$vicidial_log_table=use_archive_table("vicidial_log");
$vicidial_closer_log_table=use_archive_table("vicidial_closer_log");
$vicidial_log_extended_table=use_archive_table("vicidial_log_extended");
$recording_log_table=use_archive_table("recording_log");
$vicidial_carrier_log_table=use_archive_table("vicidial_carrier_log");
$vicidial_cpd_log_table=use_archive_table("vicidial_cpd_log");
}
else
{
$vicidial_log_table="vicidial_log";
$vicidial_closer_log_table="vicidial_closer_log";
$vicidial_log_extended_table="vicidial_log_extended";
$recording_log_table="recording_log";
$vicidial_carrier_log_table="vicidial_carrier_log";
$vicidial_cpd_log_table="vicidial_cpd_log";
}
#############
if ($non_latin < 1)
{
$PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER);
@@ -427,7 +471,7 @@ if ($run_export > 0)
$k=0;
if ($RUNcampaign > 0)
{
$stmt = "SELECT vl.call_date,vl.phone_number,vi.status,vl.user,vu.full_name,vl.campaign_id,vi.vendor_lead_code,vi.source_id,vi.list_id,vi.gmt_offset_now,vi.phone_code,vi.phone_number,vi.title,vi.first_name,vi.middle_initial,vi.last_name,vi.address1,vi.address2,vi.address3,vi.city,vi.state,vi.province,vi.postal_code,vi.country_code,vi.gender,vi.date_of_birth,vi.alt_phone,vi.email,vi.security_phrase,vi.comments,vl.length_in_sec,vl.user_group,vl.alt_dial,vi.rank,vi.owner,vi.lead_id,vl.uniqueid,vi.entry_list_id,UNIX_TIMESTAMP(vl.call_date)$export_fields_SQL from vicidial_users vu,vicidial_log vl,vicidial_list vi where vl.call_date >= '$query_date 00:00:00' and vl.call_date <= '$end_date 23:59:59' and vu.user=vl.user and vi.lead_id=vl.lead_id $list_SQL $campaign_SQL $user_group_SQL $status_SQL order by vl.call_date desc limit 500000;";
$stmt = "SELECT vl.call_date,vl.phone_number,vi.status,vl.user,vu.full_name,vl.campaign_id,vi.vendor_lead_code,vi.source_id,vi.list_id,vi.gmt_offset_now,vi.phone_code,vi.phone_number,vi.title,vi.first_name,vi.middle_initial,vi.last_name,vi.address1,vi.address2,vi.address3,vi.city,vi.state,vi.province,vi.postal_code,vi.country_code,vi.gender,vi.date_of_birth,vi.alt_phone,vi.email,vi.security_phrase,vi.comments,vl.length_in_sec,vl.user_group,vl.alt_dial,vi.rank,vi.owner,vi.lead_id,vl.uniqueid,vi.entry_list_id,UNIX_TIMESTAMP(vl.call_date)$export_fields_SQL from vicidial_users vu,".$vicidial_log_table." vl,".$vicidial_list_table." vi where vl.call_date >= '$query_date 00:00:00' and vl.call_date <= '$end_date 23:59:59' and vu.user=vl.user and vi.lead_id=vl.lead_id $list_SQL $campaign_SQL $user_group_SQL $status_SQL order by vl.call_date desc limit 500000;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$outbound_to_print = mysqli_num_rows($rslt);
@@ -520,7 +564,7 @@ if ($run_export > 0)
if ($RUNgroup > 0)
{
$stmtA = "SELECT vl.call_date,vl.phone_number,vi.status,vl.user,vu.full_name,vl.campaign_id,vi.vendor_lead_code,vi.source_id,vi.list_id,vi.gmt_offset_now,vi.phone_code,vi.phone_number,vi.title,vi.first_name,vi.middle_initial,vi.last_name,vi.address1,vi.address2,vi.address3,vi.city,vi.state,vi.province,vi.postal_code,vi.country_code,vi.gender,vi.date_of_birth,vi.alt_phone,vi.email,vi.security_phrase,vi.comments,vl.length_in_sec,vl.user_group,vl.queue_seconds,vi.rank,vi.owner,vi.lead_id,vl.closecallid,vi.entry_list_id,vl.uniqueid,UNIX_TIMESTAMP(vl.call_date)$export_fields_SQL from vicidial_users vu,vicidial_closer_log vl,vicidial_list vi where vl.call_date >= '$query_date 00:00:00' and vl.call_date <= '$end_date 23:59:59' and vu.user=vl.user and vi.lead_id=vl.lead_id $list_SQL $group_SQL $user_group_SQL $status_SQL order by vl.call_date desc limit 500000;";
$stmtA = "SELECT vl.call_date,vl.phone_number,vi.status,vl.user,vu.full_name,vl.campaign_id,vi.vendor_lead_code,vi.source_id,vi.list_id,vi.gmt_offset_now,vi.phone_code,vi.phone_number,vi.title,vi.first_name,vi.middle_initial,vi.last_name,vi.address1,vi.address2,vi.address3,vi.city,vi.state,vi.province,vi.postal_code,vi.country_code,vi.gender,vi.date_of_birth,vi.alt_phone,vi.email,vi.security_phrase,vi.comments,vl.length_in_sec,vl.user_group,vl.queue_seconds,vi.rank,vi.owner,vi.lead_id,vl.closecallid,vi.entry_list_id,vl.uniqueid,UNIX_TIMESTAMP(vl.call_date)$export_fields_SQL from vicidial_users vu,".$vicidial_closer_log_table." vl,".$vicidial_list_table." vi where vl.call_date >= '$query_date 00:00:00' and vl.call_date <= '$end_date 23:59:59' and vu.user=vl.user and vi.lead_id=vl.lead_id $list_SQL $group_SQL $user_group_SQL $status_SQL order by vl.call_date desc limit 500000;";
$rslt=mysql_to_mysqli($stmtA, $link);
if ($DB) {echo "$stmtA\n";}
$inbound_to_print = mysqli_num_rows($rslt);
@@ -624,6 +668,7 @@ if ($run_export > 0)
header('Pragma: public');
ob_clean();
flush();
# echo $stmt."\n";
$i=0;
while ($k > $i)
@@ -671,7 +716,7 @@ if ($run_export > 0)
$rec_id='';
$rec_filename='';
$rec_location='';
$stmt = "SELECT recording_id,filename,location from recording_log where vicidial_id='$export_vicidial_id[$i]' order by recording_id desc LIMIT 10;";
$stmt = "SELECT recording_id,filename,location from ".$recording_log_table." where vicidial_id='$export_vicidial_id[$i]' order by recording_id desc LIMIT 10;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$recordings_ct = mysqli_num_rows($rslt);
@@ -709,7 +754,7 @@ if ($run_export > 0)
{
$uniqueidTEST = $export_uniqueid[$i];
$uniqueidTEST = preg_replace('/\..*$/','',$uniqueidTEST);
$stmt = "SELECT caller_code,server_ip from vicidial_log_extended where uniqueid LIKE \"$uniqueidTEST%\" and lead_id='$export_lead_id[$i]' LIMIT 1;";
$stmt = "SELECT caller_code,server_ip from ".$vicidial_log_extended_table." where uniqueid LIKE \"$uniqueidTEST%\" and lead_id='$export_lead_id[$i]' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$vle_ct = mysqli_num_rows($rslt);
@@ -720,7 +765,7 @@ if ($run_export > 0)
$export_call_id[$i] = $row[0];
}
$stmt = "SELECT hangup_cause,dialstatus,channel,dial_time,answered_time from vicidial_carrier_log where uniqueid LIKE \"$uniqueidTEST%\" and lead_id='$export_lead_id[$i]' LIMIT 1;";
$stmt = "SELECT hangup_cause,dialstatus,channel,dial_time,answered_time from ".$vicidial_carrier_log_table." where uniqueid LIKE \"$uniqueidTEST%\" and lead_id='$export_lead_id[$i]' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$vcarl_ct = mysqli_num_rows($rslt);
@@ -730,7 +775,7 @@ if ($run_export > 0)
$extended_data_b = "\t$row[0]\t$row[1]\t$row[2]\t$row[3]\t$row[4]";
}
$stmt = "SELECT result from vicidial_cpd_log where callerid='$export_call_id[$i]' LIMIT 1;";
$stmt = "SELECT result from ".$vicidial_cpd_log_table." where callerid='$export_call_id[$i]' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$vcpdl_ct = mysqli_num_rows($rslt);
@@ -1166,6 +1211,17 @@ else
echo "<B>"._QXZ("Export Fields").":</B><BR>\n";
echo "<select size=1 name=export_fields><option value='STANDARD' selected>"._QXZ("STANDARD")."</option><option value='EXTENDED'>"._QXZ("EXTENDED")."</option></select>\n";
if ($archives_available=="Y")
{
echo "<BR><BR><B>"._QXZ("Search archived data").":</B><BR>\n";
echo "<select size=1 name='search_archived_data'>";
echo "<option value='' selected>"._QXZ("NO")."</option>";
echo "<option value='LOGS_ONLY'>"._QXZ("LOGS ONLY")."</option>";
echo "<option value='VLIST_ONLY'>"._QXZ("VICIDIAL_LIST")."</option>";
echo "<option value='VLIST_LOGS'>"._QXZ("ALL ARCHIVES")."</option>";
echo "</select>\n";
}
### bottom of first column
echo "</TD><TD ALIGN=LEFT VALIGN=TOP ROWSPAN=2>\n";