diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index 975ebe3a..73e08a62 100644 --- a/docs/NON-AGENT_API.txt +++ b/docs/NON-AGENT_API.txt @@ -1,4 +1,4 @@ -NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-02-09 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-02-10 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -171,6 +171,7 @@ Changes: 201201-1625 - Added group_by_campaign option to agent_stats_export function 210113-1714 - Added copy_user function 210209-2014 - Added add_did function +210210-1627 - Added duplicate check with more X-day options for add_lead function API Functions use the 'function' variable @@ -899,7 +900,7 @@ duplicate_check - Check for duplicate records in the system, can select more tha DUPNAMEPHONELIST - check for duplicate first_name, last_name and phone_number in same list DUPNAMEPHONECAMP - check for duplicate first_name, last_name and phone_number in all lists for this list's campaign DUPNAMEPHONESYS - check for duplicate first_name, last_name and phone_number in entire system - " 90DAY - Added to one of the above duplicate checks(i.e. "DUPSYS90DAY"), only checks leads loaded in last 90 days + " 30/60/90/180/360DAY - Added to one of the above duplicate checks(i.e. "DUPSYS90DAY"), only checks leads loaded in last 90 days usacan_prefix_check - Y or N, default is N. Check for a valid 4th digit for USA and Canada phone numbers (cannot be 0 or 1) usacan_areacode_check - Y or N, default is N. Check for a valid areacode for USA and Canada phone numbers(also checks for 10-digit length) nanpa_ac_prefix_check - Y or N, default is N. Check for a valid NANPA areacode and prefix, if optional NANPA data is on the system diff --git a/www/vicidial/admin_listloader_fourth_gen.php b/www/vicidial/admin_listloader_fourth_gen.php index 457a422b..9bfd20e9 100644 --- a/www/vicidial/admin_listloader_fourth_gen.php +++ b/www/vicidial/admin_listloader_fourth_gen.php @@ -2,7 +2,7 @@ # admin_listloader_fourth_gen.php - version 2.14 # (based upon - new_listloader_superL.php script) # -# Copyright (C) 2020 Matt Florell,Joe Johnson LICENSE: AGPLv2 +# Copyright (C) 2021 Matt Florell,Joe Johnson LICENSE: AGPLv2 # # ViciDial web-based lead loader from formatted file # @@ -78,10 +78,11 @@ # 190503-1547 - Added enable_status_mismatch_leadloader_option # 200812-1745 - Added international DNC scrub option # 200922-1013 - Added web_loader_phone_strip system setting feature +# 210210-1602 - Added duplicate check with more X-day options # -$version = '2.14-76'; -$build = '200922-1013'; +$version = '2.14-77'; +$build = '210210-1602'; require("dbconnect_mysqli.php"); require("functions.php"); @@ -724,9 +725,21 @@ if ( (!$OK_to_process) or ( ($leadfile) and ($file_layout!="standard" && $file_l + + + + + + + + + + + + @@ -997,15 +1010,20 @@ if ($OK_to_process) { print "
"._QXZ("PHONE NUMBER PREFIX STRIP SYSTEM SETTING ENABLED").": $SSweb_loader_phone_strip
\n"; } - $ninetydaySQL=''; - if (preg_match("/90DAY/i",$dupcheck)) + $multidaySQL=''; + if (preg_match("/30DAY|60DAY|90DAY|180DAY|360DAY/i",$dupcheck)) { - $ninetyday = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d")-90,date("Y"))); - $ninetydaySQL = "and entry_date > \"$ninetyday\""; - if ($DB > 0) {echo "DEBUG: 90day SQL: |$ninetydaySQL|";} + $day_val=30; + if (preg_match("/30DAY/i",$dupcheck)) {$day_val=30;} + if (preg_match("/60DAY/i",$dupcheck)) {$day_val=60;} + if (preg_match("/90DAY/i",$dupcheck)) {$day_val=90;} + if (preg_match("/180DAY/i",$dupcheck)) {$day_val=180;} + if (preg_match("/360DAY/i",$dupcheck)) {$day_val=360;} + $multiday = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d")-$day_val,date("Y"))); + $multidaySQL = "and entry_date > \"$multiday\""; + if ($DB > 0) {echo "DEBUG: $day_val day SQL: |$multidaySQL|";} } - if ($custom_fields_enabled > 0) { $tablecount_to_print=0; @@ -1249,7 +1267,7 @@ if ($OK_to_process) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -1272,7 +1290,7 @@ if ($OK_to_process) if ($dup_lead < 1) { - $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $ninetydaySQL $statuses_clause limit 1;"; + $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $multidaySQL $statuses_clause limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -1300,7 +1318,7 @@ if ($OK_to_process) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -1324,7 +1342,7 @@ if ($OK_to_process) if ($dup_lead < 1) { - $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -1351,7 +1369,7 @@ if ($OK_to_process) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -1373,7 +1391,7 @@ if ($OK_to_process) if ($dup_lead < 1) { - $stmt="SELECT count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -1400,7 +1418,7 @@ if ($OK_to_process) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -1422,7 +1440,7 @@ if ($OK_to_process) if ($dup_lead < 1) { - $stmt="SELECT count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -1449,7 +1467,7 @@ if ($OK_to_process) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -1471,7 +1489,7 @@ if ($OK_to_process) if ($dup_lead < 1) { - $stmt="SELECT list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -1831,12 +1849,18 @@ if (($leadfile) && ($LF_path)) { print "
"._QXZ("PHONE NUMBER PREFIX STRIP SYSTEM SETTING ENABLED").": $SSweb_loader_phone_strip
\n"; } - $ninetydaySQL=''; - if (preg_match("/90DAY/i",$dupcheck)) + $multidaySQL=''; + if (preg_match("/30DAY|60DAY|90DAY|180DAY|360DAY/i",$dupcheck)) { - $ninetyday = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d")-90,date("Y"))); - $ninetydaySQL = "and entry_date > \"$ninetyday\""; - if ($DB > 0) {echo "DEBUG: 90day SQL: |$ninetydaySQL|";} + $day_val=30; + if (preg_match("/30DAY/i",$dupcheck)) {$day_val=30;} + if (preg_match("/60DAY/i",$dupcheck)) {$day_val=60;} + if (preg_match("/90DAY/i",$dupcheck)) {$day_val=90;} + if (preg_match("/180DAY/i",$dupcheck)) {$day_val=180;} + if (preg_match("/360DAY/i",$dupcheck)) {$day_val=360;} + $multiday = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d")-$day_val,date("Y"))); + $multidaySQL = "and entry_date > \"$multiday\""; + if ($DB > 0) {echo "DEBUG: $day_val day SQL: |$multidaySQL|";} } # If a list is being scrubbed against a country's DNC list, block the list from being dialed and purge any lead from the hopper that belongs to that list. @@ -1989,7 +2013,7 @@ if (($leadfile) && ($LF_path)) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -2011,7 +2035,7 @@ if (($leadfile) && ($LF_path)) if ($dup_lead < 1) { - $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $ninetydaySQL $statuses_clause limit 1;"; + $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $multidaySQL $statuses_clause limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -2040,7 +2064,7 @@ if (($leadfile) && ($LF_path)) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -2062,7 +2086,7 @@ if (($leadfile) && ($LF_path)) if ($dup_lead < 1) { - $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -2089,7 +2113,7 @@ if (($leadfile) && ($LF_path)) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -2111,7 +2135,7 @@ if (($leadfile) && ($LF_path)) if ($dup_lead < 1) { - $stmt="SELECT count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -2137,7 +2161,7 @@ if (($leadfile) && ($LF_path)) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -2159,7 +2183,7 @@ if (($leadfile) && ($LF_path)) if ($dup_lead < 1) { - $stmt="SELECT count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -2186,7 +2210,7 @@ if (($leadfile) && ($LF_path)) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -2208,7 +2232,7 @@ if (($leadfile) && ($LF_path)) if ($dup_lead < 1) { - $stmt="SELECT list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -2592,12 +2616,18 @@ if (($leadfile) && ($LF_path)) { print "
"._QXZ("PHONE NUMBER PREFIX STRIP SYSTEM SETTING ENABLED").": $SSweb_loader_phone_strip
\n"; } - $ninetydaySQL=''; - if (preg_match("/90DAY/i",$dupcheck)) + $multidaySQL=''; + if (preg_match("/30DAY|60DAY|90DAY|180DAY|360DAY/i",$dupcheck)) { - $ninetyday = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d")-90,date("Y"))); - $ninetydaySQL = "and entry_date > \"$ninetyday\""; - if ($DB > 0) {echo "DEBUG: 90day SQL: |$ninetydaySQL|";} + $day_val=30; + if (preg_match("/30DAY/i",$dupcheck)) {$day_val=30;} + if (preg_match("/60DAY/i",$dupcheck)) {$day_val=60;} + if (preg_match("/90DAY/i",$dupcheck)) {$day_val=90;} + if (preg_match("/180DAY/i",$dupcheck)) {$day_val=180;} + if (preg_match("/360DAY/i",$dupcheck)) {$day_val=360;} + $multiday = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d")-$day_val,date("Y"))); + $multidaySQL = "and entry_date > \"$multiday\""; + if ($DB > 0) {echo "DEBUG: $day_val day SQL: |$multidaySQL|";} } # If a list is being scrubbed against a country's DNC list, block the list from being dialed and purge any lead from the hopper that belongs to that list. @@ -2744,7 +2774,7 @@ if (($leadfile) && ($LF_path)) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -2766,7 +2796,7 @@ if (($leadfile) && ($LF_path)) if ($dup_lead < 1) { - $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $ninetydaySQL $statuses_clause limit 1;"; + $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $multidaySQL $statuses_clause limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -2795,7 +2825,7 @@ if (($leadfile) && ($LF_path)) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -2817,7 +2847,7 @@ if (($leadfile) && ($LF_path)) if ($dup_lead < 1) { - $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT list_id from vicidial_list where phone_number='$phone_number' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -2844,7 +2874,7 @@ if (($leadfile) && ($LF_path)) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -2866,7 +2896,7 @@ if (($leadfile) && ($LF_path)) if ($dup_lead < 1) { - $stmt="SELECT count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -2892,7 +2922,7 @@ if (($leadfile) && ($LF_path)) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -2914,7 +2944,7 @@ if (($leadfile) && ($LF_path)) if ($dup_lead < 1) { - $stmt="SELECT count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -2941,7 +2971,7 @@ if (($leadfile) && ($LF_path)) { if (preg_match('/USING CHECK/', $status_mismatch_action)) { - $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $ninetydaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; + $stmt="SELECT list_id, lead_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $multidaySQL $mismatch_clause order by entry_date desc $mismatch_limit"; } else { @@ -2963,7 +2993,7 @@ if (($leadfile) && ($LF_path)) if ($dup_lead < 1) { - $stmt="SELECT list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $ninetydaySQL $statuses_clause;"; + $stmt="SELECT list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $multidaySQL $statuses_clause;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index 2ad44363..c04c5875 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -160,10 +160,11 @@ # 201214-1547 - Fixes for PHP8 compatibility # 210113-1714 - Added copy_user function # 210209-2014 - Added add_did function +# 210210-1627 - Added duplicate check with more X-day options for add_lead function # -$version = '2.14-137'; -$build = '210209-2014'; +$version = '2.14-138'; +$build = '210210-1627'; $api_url_log = 0; $startMS = microtime(); @@ -11055,12 +11056,18 @@ if ($function == 'add_lead') ### END checking for DNC if defined ### ### START checking for duplicate if defined ### - $ninetydaySQL=''; - if (preg_match("/90DAY/i",$duplicate_check)) + $multidaySQL=''; + if (preg_match("/30DAY|60DAY|90DAY|180DAY|360DAY/i",$duplicate_check)) { - $ninetyday = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d")-90,date("Y"))); - $ninetydaySQL = "and entry_date > \"$ninetyday\""; - if ($DB > 0) {echo "DEBUG: 90day SQL: |$ninetydaySQL|";} + $day_val=30; + if (preg_match("/30DAY/i",$duplicate_check)) {$day_val=30;} + if (preg_match("/60DAY/i",$duplicate_check)) {$day_val=60;} + if (preg_match("/90DAY/i",$duplicate_check)) {$day_val=90;} + if (preg_match("/180DAY/i",$duplicate_check)) {$day_val=180;} + if (preg_match("/360DAY/i",$duplicate_check)) {$day_val=360;} + $multiday = date("Y-m-d H:i:s", mktime(date("H"),date("i"),date("s"),date("m"),date("d")-$day_val,date("Y"))); + $multidaySQL = "and entry_date > \"$multiday\""; + if ($DB > 0) {echo "DEBUG: $day_val day SQL: |$multidaySQL|";} } if (preg_match("/CAMP/i",$duplicate_check)) # find lists within campaign @@ -11094,7 +11101,7 @@ if ($function == 'add_lead') { if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPLIST\n";} $duplicate_found=0; - $stmt="SELECT lead_id,list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $ninetydaySQL limit 1;"; + $stmt="SELECT lead_id,list_id from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $multidaySQL limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -11119,7 +11126,7 @@ if ($function == 'add_lead') { if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPCAMP - $duplicate_lists\n";} $duplicate_found=0; - $stmt="SELECT lead_id,list_id from vicidial_list where phone_number='$phone_number' and list_id IN($duplicate_lists) $ninetydaySQL limit 1;"; + $stmt="SELECT lead_id,list_id from vicidial_list where phone_number='$phone_number' and list_id IN($duplicate_lists) $multidaySQL limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -11144,7 +11151,7 @@ if ($function == 'add_lead') { if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPSYS\n";} $duplicate_found=0; - $stmt="SELECT lead_id,list_id from vicidial_list where phone_number='$phone_number' $ninetydaySQL limit 1;"; + $stmt="SELECT lead_id,list_id from vicidial_list where phone_number='$phone_number' $multidaySQL limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -11169,7 +11176,7 @@ if ($function == 'add_lead') { if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPTITLEALTPHONELIST\n";} $duplicate_found=0; - $stmt="SELECT lead_id,list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $ninetydaySQL limit 1;"; + $stmt="SELECT lead_id,list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $multidaySQL limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -11194,7 +11201,7 @@ if ($function == 'add_lead') { if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPTITLEALTPHONECAMP\n";} $duplicate_found=0; - $stmt="SELECT lead_id,list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id IN($duplicate_lists) $ninetydaySQL limit 1;"; + $stmt="SELECT lead_id,list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id IN($duplicate_lists) $multidaySQL limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -11219,7 +11226,7 @@ if ($function == 'add_lead') { if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPTITLEALTPHONESYS\n";} $duplicate_found=0; - $stmt="SELECT lead_id,list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $ninetydaySQL limit 1;"; + $stmt="SELECT lead_id,list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $multidaySQL limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -11244,7 +11251,7 @@ if ($function == 'add_lead') { if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPNAMEPHONELIST\n";} $duplicate_found=0; - $stmt="SELECT lead_id,list_id from vicidial_list where first_name='$first_name' and last_name='$last_name' and phone_number='$phone_number' $ninetydaySQL and list_id='$list_id' limit 1;"; + $stmt="SELECT lead_id,list_id from vicidial_list where first_name='$first_name' and last_name='$last_name' and phone_number='$phone_number' $multidaySQL and list_id='$list_id' limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -11269,7 +11276,7 @@ if ($function == 'add_lead') { if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPNAMEPHONECAMP\n";} $duplicate_found=0; - $stmt="SELECT lead_id,list_id from vicidial_list where first_name='$first_name' and last_name='$last_name' and phone_number='$phone_number' and list_id IN($duplicate_lists) $ninetydaySQL limit 1;"; + $stmt="SELECT lead_id,list_id from vicidial_list where first_name='$first_name' and last_name='$last_name' and phone_number='$phone_number' and list_id IN($duplicate_lists) $multidaySQL limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0) @@ -11294,7 +11301,7 @@ if ($function == 'add_lead') { if ($DB>0) {echo "DEBUG: Checking for duplicates - DUPNAMEPHONESYS\n";} $duplicate_found=0; - $stmt="SELECT lead_id,list_id from vicidial_list where first_name='$first_name' and last_name='$last_name' and phone_number='$phone_number' $ninetydaySQL limit 1;"; + $stmt="SELECT lead_id,list_id from vicidial_list where first_name='$first_name' and last_name='$last_name' and phone_number='$phone_number' $multidaySQL limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); $pc_recs = mysqli_num_rows($rslt); if ($pc_recs > 0)