From 13ef469ebfde8f37132344761623805f8c86c3d4 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 8 Aug 2014 14:58:54 +0000 Subject: [PATCH] Added Log Archive search git-svn-id: svn://192.168.202.10@2158 3d104415-ff17-0410-8863-d5cf3c621b8a --- www/vicidial/admin_search_lead.php | 303 ++++++++++++++++++++++++++--- 1 file changed, 278 insertions(+), 25 deletions(-) diff --git a/www/vicidial/admin_search_lead.php b/www/vicidial/admin_search_lead.php index 47c664f3..e0d578c2 100644 --- a/www/vicidial/admin_search_lead.php +++ b/www/vicidial/admin_search_lead.php @@ -1,12 +1,12 @@ LICENSE: AGPLv2 +# admin_search_lead.php version 2.10 +# +# Copyright (C) 2014 Matt Florell LICENSE: AGPLv2 # # AST GUI database administration search for lead info # admin_modify_lead.php # -# this is the administration lead information search screen, the administrator +# this is the administration lead information search screen, the administrator # just needs to enter the leadID and then they can view and modify the information # in the record for that lead # @@ -34,6 +34,7 @@ # 130621-1714 - Added filtering of input to prevent SQL injection attacks and new user auth # 130902-0747 - Changed to mysqli PHP functions # 130926-2048 - Added option to search vicidial_list_archive table +# 140724-1240 - Added the abilty to search the log archive tables # require("dbconnect_mysqli.php"); @@ -55,8 +56,12 @@ if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];} if (isset($_GET["log_phone"])) {$log_phone=$_GET["log_phone"];} elseif (isset($_POST["log_phone"])) {$log_phone=$_POST["log_phone"];} if (isset($_GET["log_lead_id"])) {$log_lead_id=$_GET["log_lead_id"];} - elseif (isset($_POST["log_lead_id"])) {$log_lead_id=$_POST["log_lead_id"];} -if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["log_lead_id"])) {$log_lead_id=$_POST["log_lead_id"];} +if (isset($_GET["log_phone_archive"])) {$log_phone_archive=$_GET["log_phone_archive"];} + elseif (isset($_POST["log_phone_archive"])) {$log_phone_archive=$_POST["log_phone_archive"];} +if (isset($_GET["log_lead_id_archive"])) {$log_lead_id_archive=$_GET["log_lead_id_archive"];} + elseif (isset($_POST["log_lead_id_archive"])) {$log_lead_id_archive=$_POST["log_lead_id_archive"];} +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"];} @@ -282,17 +287,17 @@ echo " Lead search: $vendor_id $phone $lead_id $status $list_id $user\n"; echo date("l F j, Y G:i:s A"); echo "
\n"; -if ( (!$vendor_id) and (!$phone) and (!$lead_id) and (!$log_phone) and (!$log_lead_id) and ( (strlen($status)<1) and (strlen($list_id)<1) and (strlen($user)<1) and (strlen($owner)<1) ) and ( (strlen($first_name)<1) and (strlen($last_name)<1) )) +if ( (!$vendor_id) and (!$phone) and (!$lead_id) and (!$log_phone) and (!$log_lead_id) and (!$log_phone_archive) and (!$log_lead_id_archive) and ( (strlen($status)<1) and (strlen($list_id)<1) and (strlen($user)<1) and (strlen($owner)<1) ) and ( (strlen($first_name)<1) and (strlen($last_name)<1) )) { ### Lead search echo "
\n"; echo "
\n"; echo "\n"; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; - + $archive_stmt="SHOW TABLES LIKE '%vicidial_list_archive%'"; $archive_rslt=mysql_to_mysqli($archive_stmt, $link); if (mysqli_num_rows($archive_rslt)>0) @@ -300,30 +305,30 @@ if ( (!$vendor_id) and (!$phone) and (!$lead_id) and (!$log_phone) and (!$log_ echo ""; echo ""; echo "\n"; - echo ""; - echo ""; + echo ""; + echo ""; } echo ""; echo ""; echo "\n"; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; echo ""; echo "\n"; echo ""; echo ""; - - echo ""; - echo ""; + + echo ""; + echo ""; echo ""; echo ""; echo "\n"; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; echo ""; @@ -334,8 +339,8 @@ if ( (!$vendor_id) and (!$phone) and (!$lead_id) and (!$log_phone) and (!$log_ echo ""; echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; echo ""; @@ -348,20 +353,35 @@ if ( (!$vendor_id) and (!$phone) and (!$lead_id) and (!$log_phone) and (!$log_ ### Log search echo "
\n"; echo "
"; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; echo ""; echo "\n"; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; echo ""; echo "\n"; echo ""; echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo "\n"; + echo ""; + echo ""; + echo ""; + + echo ""; + echo "\n"; + echo ""; + echo ""; echo ""; @@ -609,7 +629,240 @@ else ##### END Log search ##### + ##### BEGIN Log archive search ##### + if ( (strlen($log_lead_id_archive)>0) or (strlen($log_phone_archive)>0) ) + { + if (strlen($log_lead_id_archive)>0) + { + $stmtA="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec,alt_dial from vicidial_log_archive where lead_id='" . mysqli_real_escape_string($link, $log_lead_id_archive) . "' $LOGallowed_listsSQL"; + $stmtB="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec from vicidial_closer_log_archive where lead_id='" . mysqli_real_escape_string($link, $log_lead_id_archive) . "' $LOGallowed_listsSQL"; + } + if (strlen($log_phone_archive)>0) + { + $stmtA="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec,alt_dial from vicidial_log_archive where phone_number='" . mysqli_real_escape_string($link, $log_phone_archive) . "' $LOGallowed_listsSQL"; + $stmtB="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec from vicidial_closer_log_archive where phone_number='" . mysqli_real_escape_string($link, $log_phone_archive) . "' $LOGallowed_listsSQL"; + $stmtC="SELECT extension,caller_id_number,did_id,call_date from vicidial_did_log where caller_id_number='" . mysqli_real_escape_string($link, $log_phone_archive) . "'"; + } + if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) + { + mysqli_close($link); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect_mysqli.php"); + echo "\n"; + } + + $rslt=mysql_to_mysqli("$stmtA", $link); + $results_to_print = mysqli_num_rows($rslt); + if ( ($results_to_print < 1) and ($results_to_printX < 1) ) + { + echo "\n

\n"; + echo "There are no outbound calls matching your search criteria

\n"; + echo "
\n"; + } + else + { + echo "
OUTBOUND LOG RESULTS: $results_to_print
\n"; + echo "
Lead Search Options:
Lead Search Options:
Archive search:    
 
$label_vendor_lead_code(vendor lead code):  
 
$label_phone_number:  
$label_alt_phone search:  
 
Lead ID:  
 
Status:   User:  
Owner:  
 
$label_first_name:    
Log Search Options:
Log Search Options:
Lead ID:  
 
$label_phone_number Dialed:  
 
Archived Log Search Options:
Lead ID:  
$label_phone_number Dialed:  
 
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysqli_fetch_row($rslt); + if ($LOGadmin_hide_phone_data != '0') + { + if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";} + $phone_temp = $row[1]; + if (strlen($phone_temp) > 0) + { + if ($LOGadmin_hide_phone_data == '4_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);} + elseif ($LOGadmin_hide_phone_data == '3_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);} + elseif ($LOGadmin_hide_phone_data == '2_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);} + else + {$row[1] = preg_replace("/./",'X',$phone_temp);} + } + } + $o++; + $search_lead = $row[0]; + if (preg_match('/1$|3$|5$|7$|9$/i', $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
#LEAD ID  PHONE  CAMPAIGN  CALL DATE  STATUS  USER  LIST ID  LENGTH  DIAL
$o$row[0]$row[1]$row[2]$row[3]$row[4]$row[5]$row[6]$row[7]$row[8]
\n"; + } + + $rslt=mysql_to_mysqli("$stmtB", $link); + $results_to_print = mysqli_num_rows($rslt); + if ( ($results_to_print < 1) and ($results_to_printX < 1) ) + { + echo "\n

\n"; + echo "There are no inbound calls matching your search criteria

\n"; + echo "
\n"; + } + else + { + echo "
INBOUND LOG RESULTS: $results_to_print
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysqli_fetch_row($rslt); + if ($LOGadmin_hide_phone_data != '0') + { + if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";} + $phone_temp = $row[1]; + if (strlen($phone_temp) > 0) + { + if ($LOGadmin_hide_phone_data == '4_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);} + elseif ($LOGadmin_hide_phone_data == '3_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);} + elseif ($LOGadmin_hide_phone_data == '2_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);} + else + {$row[1] = preg_replace("/./",'X',$phone_temp);} + } + } + $o++; + $search_lead = $row[0]; + if (preg_match('/1$|3$|5$|7$|9$/i', $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
#LEAD ID  PHONE  INGROUP  CALL DATE  STATUS  USER  LIST ID  LENGTH  
$o$row[0]$row[1]$row[2]$row[3]$row[4]$row[5]$row[6]$row[7]
\n"; + } + + if (strlen($stmtC) > 10) + { + $rslt=mysql_to_mysqli("$stmtC", $link); + $results_to_print = mysqli_num_rows($rslt); + if ( ($results_to_print < 1) and ($results_to_printX < 1) ) + { + echo "\n

\n"; + echo "There are no inbound did calls matching your search criteria

\n"; + echo "
\n"; + } + else + { + echo "
INBOUND DID LOG RESULTS: $results_to_print
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $o=0; + while ($results_to_print > $o) + { + $row=mysqli_fetch_row($rslt); + if ($LOGadmin_hide_phone_data != '0') + { + if ($DB > 0) {echo "HIDEPHONEDATA|$row[1]|$LOGadmin_hide_phone_data|\n";} + $phone_temp = $row[1]; + if (strlen($phone_temp) > 0) + { + if ($LOGadmin_hide_phone_data == '4_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 4)) . substr($phone_temp,-4,4);} + elseif ($LOGadmin_hide_phone_data == '3_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 3)) . substr($phone_temp,-3,3);} + elseif ($LOGadmin_hide_phone_data == '2_DIGITS') + {$row[1] = str_repeat("X", (strlen($phone_temp) - 2)) . substr($phone_temp,-2,2);} + else + {$row[1] = preg_replace("/./",'X',$phone_temp);} + } + } + $o++; + $search_lead = $row[0]; + if (preg_match('/1$|3$|5$|7$|9$/i', $o)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
#DID  PHONE  DID ID  CALL DATE  
$o$row[0]$row[1]$row[2]$row[3]
\n"; + } + } + + ### LOG INSERTION Admin Log Table ### + $SQL_log = "$stmt|"; + $SQL_log = preg_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='SEARCH', record_id='$search_lead', event_code='ADMIN SEARCH LEAD', event_sql=\"$SQL_log\", event_notes='ARCHIVE';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + + $ENDtime = date("U"); + + $RUNtime = ($ENDtime - $STARTtime); + + echo "\n\n\n


\nNEW SEARCH"; + + echo "\n\n\n


\nscript runtime: $RUNtime seconds"; + + echo "\n\n\n"; + + exit; + } + ##### END Log search ##### ##### BEGIN Lead search #####