From efb2c0be18bbc92ce4f3b2417415c2260246507e Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 30 Mar 2018 19:00:09 +0000 Subject: [PATCH] Added download of CID Group records feature Added 'active' column to CID Group import in Bulk Tools page git-svn-id: svn://192.168.202.10@2956 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/www/vicidial/admin.php | 9 ++-- .../trunk/www/vicidial/admin_bulk_tools.php | 46 +++++++++++++--- agc_2-X/trunk/www/vicidial/list_download.php | 52 ++++++++++++++++++- 3 files changed, 95 insertions(+), 12 deletions(-) diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index be0c9d49..ffffe245 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -4327,12 +4327,13 @@ else # 180310-2230 - Added bulk change function for campaign and ingroup ranks in user modify page # 180310-2321 - Added source_id_display system option # 180316-0751 - Translated phrases fixes, issue #1081 +# 180330-1425 - Added download of CID Group records feature # # 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.14-665a'; -$build = '180316-0751'; +$admin_version = '2.14-666a'; +$build = '180330-1425'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -35927,7 +35928,9 @@ if ($ADD==396111111111) } if ( ($LOGuser_level >= 9) and ( (preg_match("/Administration Change Log/",$LOGallowed_reports)) or (preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) ) { - echo "

"._QXZ("Click here to see Admin changes to this CID GROUP")."\n"; + echo "

"._QXZ("Click here to see Admin changes to this CID GROUP")."\n"; + + echo "

"._QXZ("Click here to download this CID GROUP")."\n"; } } else diff --git a/agc_2-X/trunk/www/vicidial/admin_bulk_tools.php b/agc_2-X/trunk/www/vicidial/admin_bulk_tools.php index 4ae234d0..49ce1c40 100644 --- a/agc_2-X/trunk/www/vicidial/admin_bulk_tools.php +++ b/agc_2-X/trunk/www/vicidial/admin_bulk_tools.php @@ -23,13 +23,14 @@ # 180213-2245 - Added CID Groups ability for AC-CID section # 180301-1538 - Fixed issue with STATE CID Groups insertion # 180323-1643 - Updated column labels in user copy function to add ones that had been created since script was made. +# 180330-1427 - Added 'active' column to CID Group import # require("dbconnect_mysqli.php"); require("functions.php"); -$version = '2.14-17'; -$build = '180323-1643'; +$version = '2.14-18'; +$build = '180330-1427'; $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; @@ -54,6 +55,7 @@ if (isset($_POST["ACCIDdids"])) {$ACCIDto_insert_raw=$_POST["ACCIDdids"];} if (isset($_POST["ACCIDto_insert"])) {$ACCIDto_insert_CONFIRMED=$_POST["ACCIDto_insert"];} if (isset($_POST["ACCIDdescription"])) {$ACCIDdescription=$_POST["ACCIDdescription"];} if (isset($_POST["ACCIDactive"])) {$ACCIDactive=$_POST["ACCIDactive"];} +if (isset($_POST["ACCIDactiveinput"])) {$ACCIDactiveinput=$_POST["ACCIDactiveinput"];} if (isset($_POST["ACCIDdelete_campaign"])) {$ACCIDdelete_campaign=$_POST["ACCIDdelete_campaign"];} if (isset($_POST["ACCIDdelete_from"])) {$ACCIDdelete_from=$_POST["ACCIDdelete_from"];} if (isset($_POST["ACCIDdelete_from_CONFIRMED"])) {$ACCIDdelete_from_CONFIRMED=$_POST["ACCIDdelete_from_CONFIRMED"];} @@ -85,12 +87,14 @@ if ($ACCIDmethod == "CSV") $ACCIDareacode_raw[$i] = $ACCIDrow[0]; $ACCIDto_insert_raw[$i] = $ACCIDrow[1]; $ACCIDdescription_raw[$i] = $ACCIDrow[2]; + $ACCIDactiveinput_raw[$i] = $ACCIDrow[3]; $i++; } $ACCIDareacode_raw = preg_replace('/[^0-9a-zA-Z]/','',$ACCIDareacode_raw); $ACCIDto_insert_raw = preg_replace('/[^0-9]/','',$ACCIDto_insert_raw); $ACCIDto_insert_raw_ArFilter = array_filter($ACCIDto_insert_raw); $ACCIDdescription_raw = preg_replace('/[^-_.0-9a-zA-Z ]/','',$ACCIDdescription_raw); + $ACCIDactiveinput_raw = preg_replace('/[^A-Z ]/','',$ACCIDactiveinput_raw); } else { @@ -294,7 +298,7 @@ if ($form_to_run == "help") echo "

"; echo "

"; - echo ""._QXZ("AC-CID Bulk Add")." - "._QXZ("This allows you to paste in a listing of CIDs to insert into a campaign AC-CID list or CID Group list. There are two methods to choose from: CIDs must be between 6 and 20 digits in length and only digits 0-9 are allowed. Optionally, you can have the AC-CIDs set to active upon insertion."); + echo ""._QXZ("AC-CID Bulk Add")." - "._QXZ("This allows you to paste in a listing of CIDs to insert into a campaign AC-CID list or CID Group list. There are two methods to choose from: CIDs must be between 6 and 20 digits in length and only digits 0-9 are allowed. Optionally, you can have the AC-CIDs set to active upon insertion."); echo "

"; echo "

"; @@ -502,6 +506,7 @@ if ($form_to_run == "ACCID") $ACCIDto_insert = serialize($ACCIDto_insert); $ACCIDareacode = serialize($ACCIDareacode); if ($ACCIDmethod=="CSV") {$ACCIDdescription_raw = serialize($ACCIDdescription_raw);} + if ($ACCIDmethod=="CSV") {$ACCIDactiveinput_raw = serialize($ACCIDactiveinput_raw);} echo "
"; echo ""; echo ""; @@ -509,6 +514,7 @@ if ($form_to_run == "ACCID") echo ""; echo ""; echo ""; + echo ""; echo ""; echo ""; echo "\n"; @@ -537,6 +543,7 @@ elseif ($form_to_run == "ACCIDconfirmed") if ($ACCIDmethod=="CSV") { $ACCIDdescription = unserialize($ACCIDdescription); + $ACCIDactiveinput = unserialize($ACCIDactiveinput); } else { @@ -604,15 +611,30 @@ elseif ($form_to_run == "ACCIDconfirmed") $INSERTsqlLOG=''; while ($INSERTloopflag == "TRUE") { - $SQL = "INSERT IGNORE INTO vicidial_campaign_cid_areacodes (campaign_id,areacode,outbound_cid,active,cid_description) VALUES ('$ACCIDcampaign','$ACCIDareacode[$INSERTindex]','$ACCIDto_insert_CONFIRMED[$INSERTindex]','$ACCIDactive','$ACCIDdescription[$INSERTindex]')"; + $tempACCIDactive = $ACCIDactive; + if ($ACCIDactive=='F') + { + if (strlen($ACCIDactiveinput[$INSERTindex]) > 0) {$tempACCIDactive = $ACCIDactiveinput[$INSERTindex];} + else {$tempACCIDactive='N';} + } + if ($DB) {echo "|ACCIDactive: $ACCIDactive|$ACCIDactiveinput[$INSERTindex]|$tempACCIDactive|";} + + $SQL = "INSERT IGNORE INTO vicidial_campaign_cid_areacodes (campaign_id,areacode,outbound_cid,active,cid_description) VALUES ('$ACCIDcampaign','$ACCIDareacode[$INSERTindex]','$ACCIDto_insert_CONFIRMED[$INSERTindex]','$tempACCIDactive','$ACCIDdescription[$INSERTindex]')"; $INSERTindex++; if ($INSERTgroup_counter > 0) { $i = 1; while ($i < $INSERTgroup_limit) { - $SQL.= ",('" . $ACCIDcampaign . "','" . $ACCIDareacode[$INSERTindex] . "','" . $ACCIDto_insert_CONFIRMED[$INSERTindex] . "','" . $ACCIDactive . "','" . $ACCIDdescription[$INSERTindex] . "')"; - $SQL_sentence.= " |$ACCIDareacode[$INSERTindex]|$ACCIDto_insert_CONFIRMED[$INSERTindex]|$ACCIDdescription[$INSERTindex]"; + $tempACCIDactive = $ACCIDactive; + if ($ACCIDactive=='F') + { + if (strlen($ACCIDactiveinput[$INSERTindex]) > 0) {$tempACCIDactive = $ACCIDactiveinput[$INSERTindex];} + else {$tempACCIDactive='N';} + } + if ($DB) {echo "|ACCIDactive: $ACCIDactive|$ACCIDactiveinput[$INSERTindex]|$tempACCIDactive|";} + $SQL.= ",('" . $ACCIDcampaign . "','" . $ACCIDareacode[$INSERTindex] . "','" . $ACCIDto_insert_CONFIRMED[$INSERTindex] . "','" . $tempACCIDactive . "','" . $ACCIDdescription[$INSERTindex] . "')"; + $SQL_sentence.= " |$ACCIDareacode[$INSERTindex]|$ACCIDto_insert_CONFIRMED[$INSERTindex]|$ACCIDdescription[$INSERTindex]|$tempACCIDactive"; $i++; $INSERTindex++; } @@ -623,8 +645,15 @@ elseif ($form_to_run == "ACCIDconfirmed") $i = 1; while ($i < $INSERTremainder) { - $SQL.= ",('" . $ACCIDcampaign . "','" . $ACCIDareacode[$INSERTindex] . "','" . $ACCIDto_insert_CONFIRMED[$INSERTindex] . "','" . $ACCIDactive . "','" . $ACCIDdescription[$INSERTindex] . "')"; - $SQL_sentence.= " |$ACCIDareacode[$INSERTindex]|$ACCIDto_insert_CONFIRMED[$INSERTindex]|$ACCIDdescription[$INSERTindex]"; + $tempACCIDactive = $ACCIDactive; + if ($ACCIDactive=='F') + { + if (strlen($ACCIDactiveinput[$INSERTindex]) > 0) {$tempACCIDactive = $ACCIDactiveinput[$INSERTindex];} + else {$tempACCIDactive='N';} + } + if ($DB) {echo "|ACCIDactive: $ACCIDactive|$ACCIDactiveinput[$INSERTindex]|$tempACCIDactive|";} + $SQL.= ",('" . $ACCIDcampaign . "','" . $ACCIDareacode[$INSERTindex] . "','" . $ACCIDto_insert_CONFIRMED[$INSERTindex] . "','" . $tempACCIDactive . "','" . $ACCIDdescription[$INSERTindex] . "')"; + $SQL_sentence.= " |$ACCIDareacode[$INSERTindex]|$ACCIDto_insert_CONFIRMED[$INSERTindex]|$ACCIDdescription[$INSERTindex]|$tempACCIDactive"; $i++; $INSERTindex++; } @@ -1735,6 +1764,7 @@ else echo ""._QXZ("Active?").":\n"; echo ""._QXZ("AC-CIDs").":\n"; echo "\n"; diff --git a/agc_2-X/trunk/www/vicidial/list_download.php b/agc_2-X/trunk/www/vicidial/list_download.php index 73b38e7d..f1a4fae9 100644 --- a/agc_2-X/trunk/www/vicidial/list_download.php +++ b/agc_2-X/trunk/www/vicidial/list_download.php @@ -4,7 +4,7 @@ # downloads the entire contents of a vicidial list ID to a flat text file # that is tab delimited # -# Copyright (C) 2017 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2018 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -34,6 +34,7 @@ # 150903-1538 - Added compatibility for custom fields data options # 170306-0858 - Added proper report URL logging # 170409-1556 - Added IP List validation code +# 180330-1414 - Added option for downloading of CID Groups # $startMS = microtime(); @@ -351,6 +352,44 @@ elseif ($download_type == 'fpgn') exit; } } +elseif ($download_type == 'cidgroup') + { + ##### CID Group list validation ##### + $event_code_type='CID GROUP'; + $stmt="select count(*) from vicidial_cid_groups where cid_group_id='$group_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $count_to_print = mysqli_num_rows($rslt); + if ($count_to_print > 0) + { + $row=mysqli_fetch_row($rslt); + $lists_allowed =$row[0]; + $i++; + } + + if ($lists_allowed < 1) + { + echo _QXZ("You are not allowed to download this list").": $group_id\n"; + exit; + } + + $stmt="select count(*) from vicidial_campaign_cid_areacodes where campaign_id='$group_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $count_to_print = mysqli_num_rows($rslt); + if ($count_to_print > 0) + { + $row=mysqli_fetch_row($rslt); + $leads_count =$row[0]; + $i++; + } + + if ($leads_count < 1) + { + echo _QXZ("There are no records in this CID group").": $group_id\n"; + exit; + } + } else { ##### list download validation ##### @@ -427,6 +466,13 @@ elseif ($download_type == 'fpgn') $header_columns=''; $stmt="select phone_number from vicidial_filter_phone_numbers where filter_phone_group_id='$group_id';"; } +elseif ($download_type == 'cidgroup') + { + $TXTfilename = "CIDGROUP_$group_id$US$FILE_TIME.txt"; + $header_row = "areacodestate,cid,description,active"; + $header_columns=''; + $stmt="select areacode,outbound_cid,cid_description,active from vicidial_campaign_cid_areacodes where campaign_id='$group_id';"; + } else { $TXTfilename = "LIST_$list_id$US$FILE_TIME.txt"; @@ -466,6 +512,10 @@ while ($i < $leads_to_print) { $row_data[$i] .= "$row[0]"; } + elseif ($download_type == 'cidgroup') + { + $row_data[$i] .= "$row[0],$row[1],$row[2],$row[3]"; + } else { if ($LOGadmin_hide_phone_data != '0')