From a68f2af2e5b50f3397ed1905b139229461366c07 Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 1 Oct 2015 01:12:58 +0000 Subject: [PATCH] Added logging of DNC list insertion and deletion to vicidial_dnc_log table git-svn-id: svn://192.168.202.10@2389 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/UPGRADE | 2 + agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi | 41 ++++++++-- .../agi/agi-VDADinbound_NI_DNC_CIDlookup.agi | 13 +++- agc_2-X/trunk/agi/cm_dnc.agi | 11 ++- .../trunk/extras/MySQL_AST_CREATE_tables.sql | 11 ++- agc_2-X/trunk/extras/upgrade_2.12.sql | 11 +++ agc_2-X/trunk/www/agc/vdc_db_query.php | 51 ++++++++----- agc_2-X/trunk/www/vicidial/admin.php | 76 ++++++++++++++++++- 8 files changed, 182 insertions(+), 34 deletions(-) diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index b6967cf2..e3c9382e 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -159,6 +159,8 @@ OTHER CHANGES: 36. Added did_carrier_description, sorting by columns in DID list page, integer sort for user list page. +37. Added logging of DNC list insertion and deletion to vicidial_dnc_log table + diff --git a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi index 3604ef31..6f480b4a 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# agi-VDAD_ALL_outbound.agi version 2.10 +# agi-VDAD_ALL_outbound.agi version 2.12 # # runs when an outbound call is answered. This script will # send the calls out to the agents that are logged in. @@ -46,7 +46,7 @@ #exten => 8366,4,AGI(agi-VDAD_ALL_outbound.agi,SURVEY-----LB-----US_pol_survey_hello-----1238-----8-----US_pol_survey_transfer-----US_thanks_no_contact-----OPTOUT-----DNC) #exten => 8366,5,Hangup # -# Copyright (C) 2014 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2015 Matt Florell LICENSE: AGPLv2 # # changes: # 80218-2027 - First Build @@ -112,12 +112,13 @@ # 140617-1946 - Added single-digit change to text for TTS # 141211-1635 - Added cpd_unknown_action campaign option and list_id added to AST_send_URL calls # 141219-1219 - Fixed issue related to QM logging +# 150928-1822 - Added dnc logging # $script = 'agi-VDAD_ALL_outbound.agi'; $AGILOG = '0'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=108; +$mysql_log_count=119; $one_mysql_log=0; use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second @@ -1131,7 +1132,7 @@ if ($call_handle_method =~ /REMIND/) $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + $dbhP=$dbhA; $mysql_count='01109'; $MEL_aff_rows=$sthArows; &mysql_error_logging; if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; @@ -1189,7 +1190,7 @@ if ($call_handle_method =~ /SURVEY/) $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + $dbhP=$dbhA; $mysql_count='01110'; $MEL_aff_rows=$sthArows; &mysql_error_logging; if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; @@ -1212,7 +1213,7 @@ if ($call_handle_method =~ /SURVEY/) $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + $dbhP=$dbhA; $mysql_count='01111'; $MEL_aff_rows=$sthArows; &mysql_error_logging; if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; @@ -1360,6 +1361,10 @@ if ($call_handle_method =~ /SURVEY/) $agi_string = "-- VDAD vicidial_dnc insert: $affected_rows|$VDADphone"; &agi_output; } + $stmtA="INSERT INTO vicidial_dnc_log SET phone_number='$VDADphone', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='OUTAGI';"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01112'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} } if (($use_campaign_dnc =~ /Y|AREACODE/) && ($survey_ni_status eq "DNC")) { @@ -1387,6 +1392,10 @@ if ($call_handle_method =~ /SURVEY/) $agi_string = "-- VDAD vicidial_campaign_dnc insert: $affected_rows|$VDADphone|$VDADcampaign|$temp_campaign_id"; &agi_output; } + $stmtA="INSERT INTO vicidial_dnc_log SET phone_number='$VDADphone', campaign_id='$temp_campaign_id', action='add', action_date=NOW(), user='OUTAGI';"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01113'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} } $AGI->hangup(); @@ -1460,6 +1469,10 @@ if ($call_handle_method =~ /SURVEY/) $agi_string = "-- VDAD vicidial_dnc insert: $affected_rows|$VDADphone"; &agi_output; } + $stmtA="INSERT INTO vicidial_dnc_log SET phone_number='$VDADphone', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='OUTAGI';"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01114'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} } if (($use_campaign_dnc =~ /Y|AREACODE/) && ($survey_third_status eq "DNC")) { @@ -1487,6 +1500,10 @@ if ($call_handle_method =~ /SURVEY/) $agi_string = "-- VDAD vicidial_campaign_dnc insert: $affected_rows|$VDADphone|$VDADcampaign|$temp_campaign_id"; &agi_output; } + $stmtA="INSERT INTO vicidial_dnc_log SET phone_number='$VDADphone', campaign_id='$temp_campaign_id', action='add', action_date=NOW(), user='OUTAGI';"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01119'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} } if (length($survey_third_exten) > 0) @@ -1575,6 +1592,10 @@ if ($call_handle_method =~ /SURVEY/) $agi_string = "-- VDAD vicidial_dnc insert: $affected_rows|$VDADphone"; &agi_output; } + $stmtA="INSERT INTO vicidial_dnc_log SET phone_number='$VDADphone', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='OUTAGI';"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01115'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} } if (($use_campaign_dnc =~ /Y|AREACODE/) && ($survey_fourth_status eq "DNC")) { @@ -1602,6 +1623,10 @@ if ($call_handle_method =~ /SURVEY/) $agi_string = "-- VDAD vicidial_campaign_dnc insert: $affected_rows|$VDADphone|$VDADcampaign|$temp_campaign_id"; &agi_output; } + $stmtA="INSERT INTO vicidial_dnc_log SET phone_number='$VDADphone', campaign_id='$temp_campaign_id', action='add', action_date=NOW(), user='OUTAGI';"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01116'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} } if (length($survey_fourth_exten) > 0) @@ -2059,7 +2084,7 @@ while ($drop_timer <= $DROP_TIME) $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + $dbhP=$dbhA; $mysql_count='01117'; $MEL_aff_rows=$sthArows; &mysql_error_logging; if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; @@ -2082,7 +2107,7 @@ while ($drop_timer <= $DROP_TIME) $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + $dbhP=$dbhA; $mysql_count='01118'; $MEL_aff_rows=$sthArows; &mysql_error_logging; if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; diff --git a/agc_2-X/trunk/agi/agi-VDADinbound_NI_DNC_CIDlookup.agi b/agc_2-X/trunk/agi/agi-VDADinbound_NI_DNC_CIDlookup.agi index 867b82fb..06f5fbd2 100644 --- a/agc_2-X/trunk/agi/agi-VDADinbound_NI_DNC_CIDlookup.agi +++ b/agc_2-X/trunk/agi/agi-VDADinbound_NI_DNC_CIDlookup.agi @@ -1,5 +1,7 @@ #!/usr/bin/perl # +# NOTE: IT IS RECOMMENDED THAT YOU USE cm_dnc.agi THROUGH A CALL MENU INSTEAD! +# # agi-VDADinbound_NI_DNC_CIDlookup.agi version 2.0.5 *DBI-version* # # runs when a call comes in from an inbound call. This script will @@ -17,11 +19,12 @@ #exten => 1234,4,AGI(agi-VDADinbound_NI_DNC_CIDlookup.agi,YES-----TESTCAMP) #exten => 1234,5,Hangup # -# Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2015 Matt Florell LICENSE: AGPLv2 # # changes: # 60914-1051 - First draft # 80909-0614 - Added optional field for campaign so that vicidial_campaign_dnc could be used +# 150928-1822 - Added dnc logging # $script = 'agi-VDADinbound_NI_DNC_CIDlookup.agi'; @@ -285,6 +288,10 @@ if ($pin =~ /3/) # set the phone_number to DNC { ### add the number to the vicidial_dnc table $stmtA = "INSERT INTO vicidial_dnc SET phone_number='$phone_number';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} + + $stmtA="INSERT INTO vicidial_dnc_log SET phone_number='$phone_number', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='OLDAGI';"; $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} } @@ -292,6 +299,10 @@ if ($pin =~ /3/) # set the phone_number to DNC { ### add the number to the vicidial_campaign_dnc table $stmtA = "INSERT INTO vicidial_campaign_dnc SET phone_number='$phone_number',campaign_id='$campaign_id';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} + + $stmtA="INSERT INTO vicidial_dnc_log SET phone_number='$phone_number', campaign_id='$campaign_id', action='add', action_date=NOW(), user='OLDAGI';"; $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} } diff --git a/agc_2-X/trunk/agi/cm_dnc.agi b/agc_2-X/trunk/agi/cm_dnc.agi index fcbfc2d3..37c976be 100644 --- a/agc_2-X/trunk/agi/cm_dnc.agi +++ b/agc_2-X/trunk/agi/cm_dnc.agi @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# cm_dnc.agi version 2.8 +# cm_dnc.agi version 2.12 # # Designed to work with Cell Menus to allow setting of a number as DNC or NI # This script is meant as a replacecment for the agi-VDADinbound_NI_DNC_CIDlookup.agi @@ -23,6 +23,7 @@ # 121109-1623 - First draft # 130108-1817 - Changes for Asterisk 1.8 compatibility # 130925-1825 - Added variable filter to prevent DID SQL injection attack +# 150928-1822 - Added dnc logging # $script = 'cm_dnc.agi'; @@ -278,6 +279,10 @@ if ($new_status =~ /DNC/) # set the phone_number to DNC { ### add the number to the vicidial_dnc table $stmtA = "INSERT IGNORE INTO vicidial_dnc SET phone_number='$phone_number';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} + + $stmtA="INSERT INTO vicidial_dnc_log SET phone_number='$phone_number', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='CMAGI';"; $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} } @@ -285,6 +290,10 @@ if ($new_status =~ /DNC/) # set the phone_number to DNC { ### add the number to the vicidial_campaign_dnc table $stmtA = "INSERT IGNORE INTO vicidial_campaign_dnc SET phone_number='$phone_number',campaign_id='$campaign_id';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} + + $stmtA="INSERT INTO vicidial_dnc_log SET phone_number='$phone_number', campaign_id='$campaign_id', action='add', action_date=NOW(), user='CMAGI';"; $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} } diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index d118d310..7fd0e9bd 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -3318,6 +3318,15 @@ user_group VARCHAR(20) default '---ALL---', container_entry MEDIUMTEXT ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +CREATE TABLE vicidial_dnc_log ( +phone_number VARCHAR(18) NOT NULL, +campaign_id VARCHAR(8) NOT NULL, +action ENUM('add','delete') default 'add', +action_date DATETIME NOT NULL, +user VARCHAR(20) default '', +index (phone_number) +) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; + ALTER TABLE vicidial_email_list MODIFY message text character set utf8; @@ -3567,4 +3576,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version'; UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1431',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1432',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.12.sql b/agc_2-X/trunk/extras/upgrade_2.12.sql index ff8bf089..a8348999 100644 --- a/agc_2-X/trunk/extras/upgrade_2.12.sql +++ b/agc_2-X/trunk/extras/upgrade_2.12.sql @@ -292,3 +292,14 @@ UPDATE system_settings SET db_schema_version='1430',db_schema_update_date=NOW() ALTER TABLE vicidial_inbound_dids ADD did_carrier_description VARCHAR(255) default ''; UPDATE system_settings SET db_schema_version='1431',db_schema_update_date=NOW() where db_schema_version < 1431; + +CREATE TABLE vicidial_dnc_log ( +phone_number VARCHAR(18) NOT NULL, +campaign_id VARCHAR(8) NOT NULL, +action ENUM('add','delete') default 'add', +action_date DATETIME NOT NULL, +user VARCHAR(20) default '', +index (phone_number) +) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; + +UPDATE system_settings SET db_schema_version='1432',db_schema_update_date=NOW() where db_schema_version < 1432; diff --git a/agc_2-X/trunk/www/agc/vdc_db_query.php b/agc_2-X/trunk/www/agc/vdc_db_query.php index 8b48885d..276e40d5 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -389,13 +389,14 @@ # 150728-1049 - Added option for secondary sorting by vendor_lead_code, Issue #833 # 150814-1057 - Added compatibility for custom fields data option # 150923-2013 - Added DID custom variables to call data transmission +# 150928-1818 - Added dnc logging # -$version = '2.12-284'; -$build = '150923-2013'; +$version = '2.12-285'; +$build = '150928-1818'; $php_script = 'vdc_db_query.php'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=616; +$mysql_log_count=635; $one_mysql_log=0; $DB=0; $SSagent_debug_logging=0; @@ -1876,7 +1877,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT lead_id FROM vicidial_list where alt_phone='$phone_number' $manual_dial_search_filterSQL order by modify_date desc LIMIT 1;"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00617',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $man_leadID_ct = mysqli_num_rows($rslt); if ($man_leadID_ct > 0) {$MDF_search_flag='ALT'; $agent_dialed_type='ALT';} @@ -1885,7 +1886,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT lead_id FROM vicidial_list where address3='$phone_number' $manual_dial_search_filterSQL order by modify_date desc LIMIT 1;"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00618',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $man_leadID_ct = mysqli_num_rows($rslt); if ($man_leadID_ct > 0) {$MDF_search_flag='ADDR3'; $agent_dialed_type='ADDR3';} @@ -2142,7 +2143,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT count(*) FROM vicidial_list where alt_phone='$phone_number' and list_id IN($camp_lists);"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00619',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysqli_fetch_row($rslt); $MDF_search_flag='ALT'; @@ -2152,7 +2153,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT count(*) FROM vicidial_list where address3='$phone_number' and list_id IN($camp_lists);"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00620',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysqli_fetch_row($rslt); $MDF_search_flag='ADDR3'; @@ -2239,7 +2240,7 @@ if ($ACTION == 'manDiaLnextCaLL') $USERfSQL=''; $stmt="SELECT lead_filter_id FROM vicidial_users where user='$user';"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00621',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $camp_nohopper_ct = mysqli_num_rows($rslt); if ($camp_nohopper_ct > 0) @@ -2251,7 +2252,7 @@ if ($ACTION == 'manDiaLnextCaLL') { $stmt="SELECT lead_filter_sql FROM vicidial_lead_filters where lead_filter_id='$USERlead_filter_id';"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00622',$user,$server_ip,$session_name,$one_mysql_log);} $filtersql_ct = mysqli_num_rows($rslt); if ($DB) {echo "$filtersql_ct|$stmt\n";} if ($filtersql_ct > 0) @@ -3994,7 +3995,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "SELECT campaign_script from vicidial_campaigns where campaign_id='$campaign';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00623',$user,$server_ip,$session_name,$one_mysql_log);} $VC_script_ct = mysqli_num_rows($rslt); if ($VC_script_ct > 0) { @@ -4028,7 +4029,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "SELECT agent_script_override,list_description from vicidial_lists where list_id='$list_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00624',$user,$server_ip,$session_name,$one_mysql_log);} $VC_script_ct = mysqli_num_rows($rslt); if ($VC_script_ct > 0) { @@ -4137,7 +4138,7 @@ if ($ACTION == 'manDiaLnextCaLL') $stmt = "SELECT script_color from vicidial_scripts where script_id='$VDCL_campaign_script';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00625',$user,$server_ip,$session_name,$one_mysql_log);} $VDIG_scrptcolor_ct = mysqli_num_rows($rslt); if ($VDIG_scrptcolor_ct > 0) { @@ -4493,7 +4494,7 @@ if ($ACTION == 'manDiaLonly') { $stmt="SELECT count(*) FROM vicidial_list where alt_phone='$phone_number' and list_id IN($camp_lists);"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00626',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysqli_fetch_row($rslt); $MDF_search_flag='ALT'; @@ -4503,7 +4504,7 @@ if ($ACTION == 'manDiaLonly') { $stmt="SELECT count(*) FROM vicidial_list where address3='$phone_number' and list_id IN($camp_lists);"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00627',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $row=mysqli_fetch_row($rslt); $MDF_search_flag='ADDR3'; @@ -6850,7 +6851,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "SELECT script_color from vicidial_scripts where script_id='$VDCL_campaign_script';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00628',$user,$server_ip,$session_name,$one_mysql_log);} $VDIG_scrptcolor_ct = mysqli_num_rows($rslt); if ($VDIG_scrptcolor_ct > 0) { @@ -7168,7 +7169,7 @@ if ($ACTION == 'VDADcheckINCOMING') $stmt = "SELECT script_color from vicidial_scripts where script_id='$VDCL_ingroup_script';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00629',$user,$server_ip,$session_name,$one_mysql_log);} $VDIG_scrptcolor_ct = mysqli_num_rows($rslt); if ($VDIG_scrptcolor_ct > 0) { @@ -8233,7 +8234,7 @@ if ($ACTION == 'VDADcheckINCOMINGemail') $stmt = "SELECT script_color from vicidial_scripts where script_id='$VDCL_ingroup_script';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00630',$user,$server_ip,$session_name,$one_mysql_log);} $VDIG_scrptcolor_ct = mysqli_num_rows($rslt); if ($VDIG_scrptcolor_ct > 0) { @@ -9293,7 +9294,7 @@ if ($ACTION == 'LeaDSearcHSelecTUpdatE') $stmt = "SELECT script_color from vicidial_scripts where script_id='$VDCL_ingroup_script';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00631',$user,$server_ip,$session_name,$one_mysql_log);} $VDIG_scrptcolor_ct = mysqli_num_rows($rslt); if ($VDIG_scrptcolor_ct > 0) { @@ -9895,6 +9896,10 @@ if ($ACTION == 'updateDISPO') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00147',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $insert_into_dnc++; + $stmt="INSERT INTO vicidial_dnc_log SET phone_number='$row[0]', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='$user';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00632',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} } if ( ( ($use_campaign_dnc=='Y') or ($use_campaign_dnc=='AREACODE') ) and (preg_match("/\|$log_dispo_choice\|/i", $DNC_string_check) ) ) { @@ -9916,6 +9921,10 @@ if ($ACTION == 'updateDISPO') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00149',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $insert_into_dnc++; + $stmt="INSERT INTO vicidial_dnc_log SET phone_number='$row[0]', campaign_id='$temp_campaign_id', action='add', action_date=NOW(), user='$user';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00633',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} } } @@ -10777,7 +10786,7 @@ if ($ACTION == 'updateDISPO') $stmt="SELECT url_rank,url_statuses,url_address from vicidial_url_multi where campaign_id='$DUcampaign_id' and entry_type='$DUentry_type' and url_type='dispo' and active='Y' order by url_rank limit 1000;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00634',$user,$server_ip,$session_name,$one_mysql_log);} $VUM_ct = mysqli_num_rows($rslt); $k=0; while ($VUM_ct > $k) @@ -11339,7 +11348,7 @@ if ($ACTION == 'RUNurls') { $stmt="SELECT url FROM vicidial_url_log where url_log_id='$urls_split[$k]';"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00635',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} $urlid_ct = mysqli_num_rows($rslt); if ($urlid_ct > 0) @@ -13825,7 +13834,7 @@ if ($ACTION == 'LEADINFOview') { $stmt="SELECT field_encrypt,field_show_hide FROM vicidial_lists_fields where list_id='$entry_list_id' and field_label='$A_field_name[$o]';"; $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00635',$user,$server_ip,$session_name,$one_mysql_log);} $fieldset_to_print = mysqli_num_rows($rslt); if ($fieldset_to_print > 0) { diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 301790f9..63658041 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -3601,12 +3601,13 @@ else # 150925-2126 - Added user_hide_realtime options # 150927-0820 - Added did_carrier_description, sorting by columns in DID list page, integer sort for user list page # 150928-1235 - Separated User Group permissions for Inbound Report report by in-group and by DID +# 150928-1817 - Added DNC logging and DNC phone number log search # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.12-513a'; -$build = '150928-1235'; +$admin_version = '2.12-514a'; +$build = '150928-1817'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -5812,6 +5813,58 @@ if ($ADD==121) $o++; } + # DNC Log Search + if (strlen($phone) > 2) + { + echo "
"._QXZ("SEARCHING FOR PHONE NUMBER IN DNC LIST LOGS").": $phone

\n"; + + $stmt = "SELECT campaign_id,action,action_date,user FROM vicidial_dnc_log where phone_number='$phone' order by action_date desc limit 1000;"; + $rslt=mysql_to_mysqli($stmt, $link); + $vdl_ct = mysqli_num_rows($rslt); + $i=0; + if ($vdl_ct > 0) + { + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + } + else + { + echo _QXZ("No Results Found")."\n"; + } + while ($vdl_ct > $i) + { + if (preg_match('/1$|3$|5$|7$|9$/i', $i)) + {$bgcolor='bgcolor="#B9CBFD"';} + else + {$bgcolor='bgcolor="#9BB9FB"';} + $row=mysqli_fetch_row($rslt); + $vdl_campaign = $row[0]; + $vdl_action = $row[1]; + $vdl_action_date = $row[2]; + $vdl_user = $row[3]; + + echo ""; + echo ""; + echo ""; + echo "\n"; + + $i++; + } + + echo "
"._QXZ("CAMPAIGN").""._QXZ("ACTION").""._QXZ("DATE")."   "._QXZ("USER")."  
"; + if ($vdl_campaign == '-SYSINT-') + {echo "$vdl_campaign";} + else + {echo "$vdl_campaign";} + echo " $vdl_action $vdl_action_date$vdl_user
\n"; + echo "


\n"; + } + + # Add / Delete from DNC if (strlen($phone_numbers) > 2) { $PN = explode("\n",$phone_numbers); @@ -5843,6 +5896,9 @@ if ($ADD==121) $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='DELETE', record_id='$PN[$p]', event_code='ADMIN DELETE NUMBER FROM DNC LIST', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); + + $stmt="INSERT INTO vicidial_dnc_log SET phone_number='$PN[$p]', campaign_id='-SYSINT-', action='delete', action_date=NOW(), user='$PHP_AUTH_USER';"; + $rslt=mysql_to_mysqli($stmt, $link); } } else @@ -5866,6 +5922,9 @@ if ($ADD==121) $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='DELETE', record_id='$PN[$p]', event_code='ADMIN DELETE NUMBER FROM CAMPAIGN DNC LIST $campaign_id', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); + + $stmt="INSERT INTO vicidial_dnc_log SET phone_number='$PN[$p]', campaign_id='$campaign_id', action='delete', action_date=NOW(), user='$PHP_AUTH_USER';"; + $rslt=mysql_to_mysqli($stmt, $link); } } ##### END DELETE FROM DNC ##### @@ -5894,6 +5953,9 @@ if ($ADD==121) $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='ADD', record_id='$PN[$p]', event_code='ADMIN ADD NUMBER TO DNC LIST', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); + + $stmt="INSERT INTO vicidial_dnc_log SET phone_number='$PN[$p]', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='$PHP_AUTH_USER';"; + $rslt=mysql_to_mysqli($stmt, $link); } } else @@ -5917,6 +5979,9 @@ if ($ADD==121) $stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='LISTS', event_type='ADD', record_id='$PN[$p]', event_code='ADMIN ADD NUMBER TO CAMPAIGN DNC LIST $campaign_id', event_sql=\"$SQL_log\", event_notes='';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); + + $stmt="INSERT INTO vicidial_dnc_log SET phone_number='$PN[$p]', campaign_id='$campaign_id', action='add', action_date=NOW(), user='$PHP_AUTH_USER';"; + $rslt=mysql_to_mysqli($stmt, $link); } } ##### END ADD TO DNC ##### @@ -5942,6 +6007,13 @@ if ($ADD==121) echo "\n"; echo "\n"; + echo "
"._QXZ("DNC LOG SEARCH")."
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "
"._QXZ("Phone Number").":
\n"; + if ( ($LOGuser_level >= 9) and ( (preg_match("/Download List/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) ) { echo "
"._QXZ("Download numbers in this list to a file").":
\n";