diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index 7778997d..704958eb 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -110,6 +110,9 @@ OTHER CHANGES: for agent monitoring. Please read the AGENT_MONITOR.txt document for more information on the dialplan changes necessary to use this script. +12. Added the ability to deduplicate leads based upon statuses in the web based + lead loader using templates only. + 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 748f9ec6..e7bd0f62 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -2704,7 +2704,8 @@ template_description VARCHAR(255) DEFAULT NULL, list_id BIGINT(14) UNSIGNED DEFAULT NULL, standard_variables TEXT, custom_table VARCHAR(20) DEFAULT NULL, -custom_variables TEXT +custom_variables TEXT, +template_statuses VARCHAR(255) ) ENGINE=MyISAM; CREATE TABLE vicidial_session_data ( @@ -3169,4 +3170,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='1354',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1355',db_schema_update_date=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.8.sql b/agc_2-X/trunk/extras/upgrade_2.8.sql index 772b3636..e6545881 100644 --- a/agc_2-X/trunk/extras/upgrade_2.8.sql +++ b/agc_2-X/trunk/extras/upgrade_2.8.sql @@ -63,3 +63,6 @@ index (monitor_time) UPDATE system_settings SET db_schema_version='1354',db_schema_update_date=NOW() where db_schema_version < 1354; +ALTER TABLE vicidial_custom_leadloader_templates ADD template_statuses VARCHAR(255); + +UPDATE system_settings SET db_schema_version='1355',db_schema_update_date=NOW() where db_schema_version < 1355; diff --git a/agc_2-X/trunk/www/vicidial/AST_admin_template_maker.php b/agc_2-X/trunk/www/vicidial/AST_admin_template_maker.php index a84d3f20..88d3d7e3 100644 --- a/agc_2-X/trunk/www/vicidial/AST_admin_template_maker.php +++ b/agc_2-X/trunk/www/vicidial/AST_admin_template_maker.php @@ -9,6 +9,7 @@ # 130514-2127 - Bug fix on Chrome/IE browsers # 130610-1102 - Finalized changing of all ereg instances to preg # 130619-2044 - Added filtering of input to prevent SQL injection attacks and new user auth +# 130719-1914 - Added ability to filter by statuses # require("dbconnect.php"); @@ -32,6 +33,8 @@ if (isset($_GET["file_delimiter"])) {$file_delimiter=$_GET["file_delimiter"]; elseif (isset($_POST["file_delimiter"])) {$file_delimiter=$_POST["file_delimiter"];} if (isset($_GET["template_list_id"])) {$template_list_id=$_GET["template_list_id"];} elseif (isset($_POST["template_list_id"])) {$template_list_id=$_POST["template_list_id"];} +if (isset($_GET["template_statuses"])) {$template_statuses=$_GET["template_statuses"];} + elseif (isset($_POST["template_statuses"])) {$template_statuses=$_POST["template_statuses"];} if (isset($_GET["standard_fields_layout"])) {$standard_fields_layout=$_GET["standard_fields_layout"];} elseif (isset($_POST["standard_fields_layout"])) {$standard_fields_layout=$_POST["standard_fields_layout"];} if (isset($_GET["custom_fields_layout"])) {$custom_fields_layout=$_GET["custom_fields_layout"];} @@ -131,9 +134,22 @@ header ("Pragma: no-cache"); // HTTP/1.0 if ($submit_template=="SUBMIT TEMPLATE" && $template_id && $template_name && $template_list_id && $standard_fields_layout) { + + $status_str=""; + $status_count=count($template_statuses); + for ($q=0; $q\n"; + + $status_str.="$template_statuses[$q]|"; + } + echo ""; + $status_str=preg_replace('/\|$/', '', $status_str); + if (preg_match('/\-\-ALL\-\-/', $status_str)) {$status_str="";} + $custom_table="custom_".$template_list_id; - $ins_stmt="INSERT INTO vicidial_custom_leadloader_templates(template_id, template_name, template_description, list_id, standard_variables, custom_table, custom_variables) values('$template_id', '$template_name', '$template_description', '$template_list_id', '$standard_fields_layout', '$custom_table', '$custom_fields_layout')"; + $ins_stmt="INSERT INTO vicidial_custom_leadloader_templates(template_id, template_name, template_description, list_id, standard_variables, custom_table, custom_variables, template_statuses) values('$template_id', '$template_name', '$template_description', '$template_list_id', '$standard_fields_layout', '$custom_table', '$custom_fields_layout', '$status_str')"; $ins_rslt=mysql_query($ins_stmt, $link); + echo ""; if (mysql_affected_rows($link)>0) { $success_msg="NEW TEMPLATE CREATED SUCCESSFULLY"; @@ -209,8 +225,13 @@ function init() { function PrimeFile() { document.forms[0].submit(); } + function DisplayTemplateFields(list_id) { - if (list_id!='') {var custom_fields_enabled=1;} else {var custom_fields_enabled=0;} + if (list_id!='') { + var custom_fields_enabled=1; + } else { + var custom_fields_enabled=0; + } var template_file_type=document.getElementById("template_file_type").value; var delimiter=document.getElementById("template_file_delimiter").value; var buffer=document.getElementById("template_file_buffer").value; @@ -244,12 +265,16 @@ function DisplayTemplateFields(list_id) { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var StatSpanText = null; StatSpanText = xmlhttp.responseText; - document.getElementById("field_display").innerHTML = StatSpanText; + var output_array=StatSpanText.split("\|\|\|"); + document.getElementById("statuses_display").innerHTML = output_array[0]; + document.getElementById("field_display").innerHTML = output_array[1]; } } delete xmlhttp; } + } + function DrawTemplateStrings() { var vicidial_string=""; var standard_string = ''; @@ -271,6 +296,9 @@ function DrawTemplateStrings() { document.getElementById("custom_fields_layout").value=custom_string; } function loadIFrame(form_action, field_value) { + document.getElementById("template_list_id").disabled=true; // Disable these until the file finishes loading... + document.getElementById("template_statuses").disabled=true; + form_file_name = field_value; if (field_value=="") { document.getElementById('list_data_display').style.display = 'none'; @@ -426,6 +454,29 @@ if (mysql_num_rows($template_rslt)>0) { + + Statuses to dedupe against (optional): + + + + + + @@ -446,6 +497,8 @@ if (mysql_num_rows($template_rslt)>0) { + + diff --git a/agc_2-X/trunk/www/vicidial/admin_listloader_fourth_gen.php b/agc_2-X/trunk/www/vicidial/admin_listloader_fourth_gen.php index 03cce384..5dbe78bb 100644 --- a/agc_2-X/trunk/www/vicidial/admin_listloader_fourth_gen.php +++ b/agc_2-X/trunk/www/vicidial/admin_listloader_fourth_gen.php @@ -50,10 +50,11 @@ # 130420-2056 - Added NANPA prefix validation and timezone options # 130610-0920 - Finalized changing of all ereg instances to preg # 130621-1817 - Added filtering of input to prevent SQL injection attacks and new user auth +# 130719-1914 - Added SQL to filter by template statuses, if template has specific statuses to dedupe against # -$version = '2.8-48'; -$build = '130621-1817'; +$version = '2.8-49'; +$build = '130719-1914'; require("dbconnect.php"); require("functions.php"); @@ -376,6 +377,40 @@ function ParseFileName() } } } +function TemplateSpecs() { + var template_field = document.getElementById("template_id"); + var template_id_value = template_field.options[template_field.selectedIndex].value; + var xmlhttp=false; + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttp = false; + } + } + if (!xmlhttp && typeof XMLHttpRequest!='undefined') { + xmlhttp = new XMLHttpRequest(); + } + if (xmlhttp && template_id_value!="") { + var vs_query = "&template_id="+template_id_value; + xmlhttp.open('POST', 'leadloader_template_display.php'); + xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); + xmlhttp.send(vs_query); + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { + var TemplateInfo = null; + TemplateInfo = xmlhttp.responseText; + if (TemplateInfo.length>0) + { + alert(TemplateInfo); + } + } + } + delete xmlhttp; + } +} ADMINISTRATION: Lead Loader @@ -467,8 +502,8 @@ if ( (!$OK_to_process) or ( ($leadfile) and ($file_layout!="standard" && $file_l Standard Format    Custom layout    Custom Template - Custom template to use: - --No custom templates defined--"; } ?> - template builder + template builder
View template info Lead Duplicate Check: \n"; + echo "\t\n"; + while ($row=mysql_fetch_array($rslt)) + { + echo "\t\n"; + } + echo "\n"; + } + echo "|||"; + if ( (preg_match("/;|:|\/|\^|\[|\]|\"|\'|\*/",$LF_orig)) or (preg_match("/;|:|\/|\^|\[|\]|\"|\'|\*/",$sample_template_file_name)) ) { echo "ERROR: Invalid File Name: $LF_orig $sample_template_file_name\n"; exit; } -# echo "** $form_action"; die; -$fields_stmt = "SELECT list_id, vendor_lead_code, source_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, rank, owner from vicidial_list limit 1"; -$vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|entry_list_id|'; -# $vicidial_listloader_fields = '|vendor_lead_code|source_id|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|rank|owner|'; + $fields_stmt = "SELECT list_id, vendor_lead_code, source_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, rank, owner from vicidial_list limit 1"; -$vl_fields_count=substr_count($vicidial_listloader_fields, "|")-1; + $vicidial_list_fields = '|lead_id|vendor_lead_code|source_id|list_id|gmt_offset_now|called_since_last_reset|phone_code|phone_number|title|first_name|middle_initial|last_name|address1|address2|address3|city|state|province|postal_code|country_code|gender|date_of_birth|alt_phone|email|security_phrase|comments|called_count|last_local_call_time|rank|owner|entry_list_id|'; -##### BEGIN custom fields columns list ### -if ($custom_fields_enabled > 0) - { - $stmt="SHOW TABLES LIKE \"custom_$list_id\";"; - if ($DB>0) {echo "$stmt\n";} - $rslt=mysql_query($stmt, $link); - $tablecount_to_print = mysql_num_rows($rslt); - if ($tablecount_to_print > 0) + $vl_fields_count=substr_count($vicidial_listloader_fields, "|")-1; + + ##### BEGIN custom fields columns list ### + if ($custom_fields_enabled > 0) { - $stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id';"; + $stmt="SHOW TABLES LIKE \"custom_$list_id\";"; if ($DB>0) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); - $fieldscount_to_print = mysql_num_rows($rslt); - if ($fieldscount_to_print > 0) + $tablecount_to_print = mysql_num_rows($rslt); + if ($tablecount_to_print > 0) { - $rowx=mysql_fetch_row($rslt); - $custom_records_count = $rowx[0]; - - $custom_SQL=''; - $stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;"; + $stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id';"; if ($DB>0) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); - $fields_to_print = mysql_num_rows($rslt); - $fields_list=''; - $o=0; - while ($fields_to_print > $o) + $fieldscount_to_print = mysql_num_rows($rslt); + if ($fieldscount_to_print > 0) { $rowx=mysql_fetch_row($rslt); - $A_field_label[$o] = $rowx[1]; - $A_field_type[$o] = $rowx[6]; + $custom_records_count = $rowx[0]; - if ($DB>0) {echo "$A_field_label[$o]|$A_field_type[$o]\n";} - - if ( ($A_field_type[$o]!='DISPLAY') and ($A_field_type[$o]!='SCRIPT') ) + $custom_SQL=''; + $stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;"; + if ($DB>0) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + $fields_to_print = mysql_num_rows($rslt); + $fields_list=''; + $o=0; + while ($fields_to_print > $o) { - if (!preg_match("/\|$A_field_label[$o]\|/",$vicidial_list_fields)) + $rowx=mysql_fetch_row($rslt); + $A_field_label[$o] = $rowx[1]; + $A_field_type[$o] = $rowx[6]; + + if ($DB>0) {echo "$A_field_label[$o]|$A_field_type[$o]\n";} + + if ( ($A_field_type[$o]!='DISPLAY') and ($A_field_type[$o]!='SCRIPT') ) { - $custom_SQL .= ",$A_field_label[$o]"; + if (!preg_match("/\|$A_field_label[$o]\|/",$vicidial_list_fields)) + { + $custom_SQL .= ",$A_field_label[$o]"; + } } + $o++; } - $o++; + + $fields_stmt = "SELECT list_id, vendor_lead_code, source_id, phone_code, phone_number, title, first_name, middle_initial, last_name, address1, address2, address3, city, state, province, postal_code, country_code, gender, date_of_birth, alt_phone, email, security_phrase, comments, rank, owner $custom_SQL from vicidial_list, custom_$list_id limit 1"; + } + } + } + ##### END custom fields columns list ### + + ##### Same code from the listloader page. Since this is a custom template, it's assumed the layout is "custom" instead of "standard" and follows the coding as such + #if (($sample_template_file) && ($LF_path)) + if ($delimiter && $buffer) + { + $total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list=''; + $row=explode($delimiter, preg_replace('/[\'\"]/i', '', $buffer)); + } + + echo ""; + $rslt=mysql_query("$fields_stmt", $link); + $custom_fields_count=mysql_num_fields($rslt)-$vl_fields_count; + for ($i=0; $i\r\n"; + echo " \r\n"; + if (mysql_field_name($rslt, $i)!="list_id") + { + echo " \r\n"; } - } - } -##### END custom fields columns list ### - -##### Same code from the listloader page. Since this is a custom template, it's assumed the layout is "custom" instead of "standard" and follows the coding as such -#if (($sample_template_file) && ($LF_path)) -if ($delimiter && $buffer) - { - $total=0; $good=0; $bad=0; $dup=0; $post=0; $phone_list=''; -# $buffer=rtrim(fgets($file, 4096)); -# $buffer=stripslashes($buffer); -# print "
Processing $delim_name file...\n"; - $row=explode($delimiter, preg_replace('/[\'\"]/i', '', $buffer)); -# echo "delimiter: $delimiter
$buffer
"; - } -echo "
".strtoupper(preg_replace('/_/i', ' ', mysql_field_name($rslt, $i))).":
"; -$rslt=mysql_query("$fields_stmt", $link); -$custom_fields_count=mysql_num_fields($rslt)-$vl_fields_count; -for ($i=0; $i\r\n"; - echo " \r\n"; - if (mysql_field_name($rslt, $i)!="list_id") - { - echo " \r\n"; } - - echo " \r\n"; + echo " \r\n"; } - else - { - echo " \r\n"; - } - echo " \r\n"; - } - echo "
".strtoupper(preg_replace('/_/i', ' ', mysql_field_name($rslt, $i))).":  $list_id
 $list_id
"; + echo ""; } ?>