Added the ability to deduplicate leads based upon statuses in the web based lead loader using templates only

git-svn-id: svn://192.168.202.10@2004 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2013-07-29 19:31:17 +00:00
parent 8a66427512
commit ff27977a36
6 changed files with 240 additions and 93 deletions
+3
View File
@@ -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.
@@ -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();
+3
View File
@@ -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;
@@ -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<count($template_statuses); $q++) {
echo "<!-- $template_statuses[$q] //-->\n";
$status_str.="$template_statuses[$q]|";
}
echo "<!-- $status_str //-->";
$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 "<!-- $ins_stmt //-->";
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="<?php echo $vicidial_listloader_fields; ?>";
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) {
</select></font><?php echo "$NWB#vicidial_template_maker-list_id$NWE"; ?>
</td>
</tr>
<tr bgcolor="#D9E6FE">
<td width='25%' align="right"><font class="standard">Statuses to dedupe against (optional):</font></td>
<td width='75%'>
<span id='statuses_display'>
<select id='template_statuses' name='template_statuses[]' size=5 multiple>
<option value='--ALL--' selected>--ALL DISPOSITIONS--</option>
<?php
$stmt="SELECT status, status_name from vicidial_statuses order by status;";
$rslt=mysql_query($stmt, $link);
$num_rows = mysql_num_rows($rslt);
$count=0;
while ( $num_rows > $count )
{
$row = mysql_fetch_row($rslt);
echo "\t\t\t<option value='$row[0]'>$row[0] - $row[1]</option>\n";
$count++;
}
?>
</select></font><?php echo "$NWB#vicidial_template_maker-list_id$NWE"; ?>
</span>
</td>
</tr>
<tr bgcolor="#D9E6FE">
<th colspan='2'><input type='submit' name='submit_template' onClick="return checkForm(this.form)" value='SUBMIT TEMPLATE'></th>
</tr>
@@ -446,6 +497,8 @@ if (mysql_num_rows($template_rslt)>0) {
</table>
</tr></td>
</table>
<input type="hidden" id="sample_template_file_name" name="sample_template_file_name">
<input type="hidden" id="convert_command" name="convert_command">
<input type="hidden" id="template_file_type" name="template_file_type">
<input type="hidden" id="template_file_delimiter" name="template_file_delimiter">
<input type="hidden" id="template_file_buffer" name="template_file_buffer">
@@ -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;
}
}
</script>
<title>ADMINISTRATION: Lead Loader</title>
@@ -467,8 +502,8 @@ if ( (!$OK_to_process) or ( ($leadfile) and ($file_layout!="standard" && $file_l
<td align=left><font face="arial, helvetica" size=2><input type=radio name="file_layout" value="standard" checked>Standard Format&nbsp;&nbsp;&nbsp;&nbsp;<input type=radio name="file_layout" value="custom">Custom layout&nbsp;&nbsp;&nbsp;&nbsp;<input type=radio name="file_layout" value="template">Custom Template <?php echo "$NWB#vicidial_list_loader-file_layout$NWE"; ?></td>
</tr>
<tr>
<td align=right><B><font face="arial, helvetica" size=2>Custom template to use:</font></B></td>
<td align=left><select name="template_id">
<td align=right valign=top><B><font face="arial, helvetica" size=2>Custom template to use:</font></B></td>
<td align=left><select name="template_id" id="template_id">
<?php
$template_stmt="select template_id, template_name from vicidial_custom_leadloader_templates order by template_id asc";
$template_rslt=mysql_query($template_stmt, $link);
@@ -481,7 +516,7 @@ if ( (!$OK_to_process) or ( ($leadfile) and ($file_layout!="standard" && $file_l
echo "<option value='' selected>--No custom templates defined--</option>";
}
?>
</select> <a href='AST_admin_template_maker.php'><font face="arial, helvetica" size=1>template builder</font></a><?php echo "$NWB#vicidial_list_loader-template_id$NWE"; ?></td>
</select> <a href='AST_admin_template_maker.php'><font face="arial, helvetica" size=1>template builder</font></a><?php echo "$NWB#vicidial_list_loader-template_id$NWE"; ?><BR><a href='#' onClick="TemplateSpecs()"><font face="arial, helvetica" size=1>View template info</font></a></td>
<tr>
<td align=right width="25%"><font face="arial, helvetica" size=2>Lead Duplicate Check: </font></td>
<td align=left width="75%"><font face="arial, helvetica" size=1><select size=1 name=dupcheck>
@@ -1064,6 +1099,11 @@ if (($leadfile) && ($LF_path))
$standard_variables=$template_row["standard_variables"];
$custom_table=$template_row["custom_table"];
$custom_variables=$template_row["custom_variables"];
$template_statuses=$template_row["template_statuses"];
if (strlen($template_statuses)>0) {
$template_statuses=preg_replace('/\|/', "','", $template_statuses);
$statuses_clause=" and status in ('$template_statuses') ";
}
$standard_fields_ary=explode("|", $standard_variables);
for ($i=0; $i<count($standard_fields_ary); $i++)
{
@@ -1149,11 +1189,15 @@ if (($leadfile) && ($LF_path))
print "<center><font face='arial, helvetica' size=3 color='#009900'><B>Processing $delim_name file using template $template_id... ($tab_count|$pipe_count)\n";
if (strlen($list_id_override)>0)
{
print "<BR><BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR><BR>";
print "<BR>LIST ID OVERRIDE FOR THIS FILE: $list_id_override<BR>";
}
if (strlen($phone_code_override)>0)
{
print "<BR><BR>PHONE CODE OVERRIDE FOR THIS FILE: $phone_code_override<BR><BR>\n";
print "<BR>PHONE CODE OVERRIDE FOR THIS FILE: $phone_code_override<BR>\n";
}
if (strlen($template_statuses)>0)
{
print "<BR>OMITTING DUPLICATES AGAINST FOLLOWING STATUSES ONLY: ".preg_replace('/\'/', '', $template_statuses)."<BR>\n";
}
while (!feof($file))
{
@@ -1266,7 +1310,7 @@ if (($leadfile) && ($LF_path))
}
$dup_lists = preg_replace('/,$/i', '',$dup_lists);
$stmt="select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) limit 1;";
$stmt="select list_id from vicidial_list where phone_number='$phone_number' and list_id IN($dup_lists) $statuses_clause limit 1;";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
@@ -1288,7 +1332,7 @@ if (($leadfile) && ($LF_path))
if (preg_match("/DUPSYS/i",$dupcheck))
{
$dup_lead=0;
$stmt="select list_id from vicidial_list where phone_number='$phone_number';";
$stmt="select list_id from vicidial_list where phone_number='$phone_number' $statuses_clause;";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
@@ -1308,7 +1352,7 @@ if (($leadfile) && ($LF_path))
if (preg_match("/DUPLIST/i",$dupcheck))
{
$dup_lead=0;
$stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id';";
$stmt="select count(*) from vicidial_list where phone_number='$phone_number' and list_id='$list_id' $statuses_clause;";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
@@ -1327,7 +1371,7 @@ if (($leadfile) && ($LF_path))
if (preg_match("/DUPTITLEALTPHONELIST/i",$dupcheck))
{
$dup_lead=0;
$stmt="select count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id';";
$stmt="select count(*) from vicidial_list where title='$title' and alt_phone='$alt_phone' and list_id='$list_id' $statuses_clause;";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
@@ -1347,7 +1391,7 @@ if (($leadfile) && ($LF_path))
if (preg_match("/DUPTITLEALTPHONESYS/i",$dupcheck))
{
$dup_lead=0;
$stmt="select list_id from vicidial_list where title='$title' and alt_phone='$alt_phone';";
$stmt="select list_id from vicidial_list where title='$title' and alt_phone='$alt_phone' $statuses_clause;";
$rslt=mysql_query($stmt, $link);
$pc_recs = mysql_num_rows($rslt);
if ($pc_recs > 0)
@@ -9,6 +9,7 @@
# 120529-1345 - Filename filter fix
# 130610-1101 - Finalized changing of all ereg instances to preg
# 130619-0902 - Added filtering of input to prevent SQL injection attacks and new user auth
# 130719-1914 - Added SQL to show template statuses to dedupe against, fixed issue where list IDs should be disabled until lead file for template is uploaded
#
require("dbconnect.php");
@@ -20,9 +21,11 @@ if (isset($_GET["list_id"])) {$list_id=$_GET["list_id"];}
elseif (isset($_POST["list_id"])) {$list_id=$_POST["list_id"];}
if (isset($_GET["custom_fields_enabled"])) {$custom_fields_enabled=$_GET["custom_fields_enabled"];}
elseif (isset($_POST["custom_fields_enabled"])) {$custom_fields_enabled=$_POST["custom_fields_enabled"];}
$sample_template_file=$_FILES["sample_template_file"];
$LF_orig = $_FILES['sample_template_file']['name'];
$LF_path = $_FILES['sample_template_file']['tmp_name'];
if (isset($_GET["sample_template_file_name"])) {$sample_template_file_name=$_GET["sample_template_file_name"];}
elseif (isset($_POST["sample_template_file_name"])) {$sample_template_file_name=$_POST["sample_template_file_name"];}
if (isset($_FILES["sample_template_file"])) {$sample_template_file_name=$_FILES["sample_template_file"]['name'];}
@@ -30,8 +33,12 @@ if (isset($_GET["form_action"])) {$form_action=$_GET["form_action"];}
elseif (isset($_POST["form_action"])) {$form_action=$_POST["form_action"];}
if (isset($_GET["delimiter"])) {$delimiter=$_GET["delimiter"];}
elseif (isset($_POST["delimiter"])) {$delimiter=$_POST["delimiter"];}
if (isset($_GET["template_id"])) {$template_id=$_GET["template_id"];}
elseif (isset($_POST["template_id"])) {$template_id=$_POST["template_id"];}
if (isset($_GET["buffer"])) {$buffer=$_GET["buffer"];}
elseif (isset($_POST["buffer"])) {$buffer=$_POST["buffer"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];}
#############################################
##### START SYSTEM_SETTINGS LOOKUP #####
@@ -106,6 +113,19 @@ if ( (preg_match("/;|:|\/|\^|\[|\]|\"|\'|\*/",$LF_orig)) or (preg_match("/;|:|\/
exit;
}
if ($template_id) {
$stmt="select * from vicidial_custom_leadloader_templates where template_id='$template_id'";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_array($rslt);
echo "TEMPLATE ID: $template_id\n";
echo "TEMPLATE INFO: $row[template_name]";
if (strlen($row["template_description"])>0) {echo " - $row[template_description]";}
echo "\nWILL LOAD INTO LIST: $row[list_id]\n";
if (strlen($row["custom_table"])>0) {echo "USES CUSTOM TABLE: YES\n";} else {echo "USES CUSTOM TABLE: NO\n";}
if (strlen($row["template_statuses"])>0) {echo "WILL ONLY DEDUPE AGAINST STATUSES: ".preg_replace('/\|/', ',', $row["template_statuses"])."\n";}
exit;
}
if ($form_action=="prime_file" && $sample_template_file_name)
{
$delim_set=0;
@@ -115,7 +135,7 @@ if ($form_action=="prime_file" && $sample_template_file_name)
copy($LF_path, "/tmp/$sample_template_file_name");
$new_filename = preg_replace("/\.csv$|\.xls$|\.xlsx$|\.ods$|\.sxc$/i", '.txt', $sample_template_file_name);
$convert_command = "$WeBServeRRooT/$admin_web_directory/sheet2tab.pl /tmp/$sample_template_file_name /tmp/$new_filename";
passthru("$convert_command");
passthru("$convert_command", $fail_msg);
$lead_file = "/tmp/$new_filename";
if ($DB > 0) {echo "|$convert_command|";}
@@ -153,9 +173,13 @@ if ($form_action=="prime_file" && $sample_template_file_name)
else
{$delimiter="|";}
echo "<script language='Javascript'>\n";
#echo "parent.document.getElementById(\"sample_template_file_name\").value='$fail_msg';\n";
#echo "parent.document.getElementById(\"convert_command\").value='$convert_command';\n";
echo "parent.document.getElementById(\"template_file_type\").value='$template_file_type';\n";
echo "parent.document.getElementById(\"template_file_delimiter\").value='".urlencode($delimiter)."';\n";
echo "parent.document.getElementById(\"template_file_buffer\").value='".urlencode($buffer)."';\n";
echo "parent.document.getElementById(\"template_list_id\").disabled=false;\n";
echo "parent.document.getElementById(\"template_statuses\").disabled=false;\n";
echo "</script>";
$field_check=explode($delimiter, $buffer);
flush();
@@ -166,107 +190,126 @@ else if ($form_action=="update_template")
}
else
{
if ($list_id)
{
$campaign_stmt="select campaign_id from vicidial_lists where list_id='$list_id'";
$campaign_rslt=mysql_query($campaign_stmt, $link);
if (mysql_num_rows($campaign_rslt)>0)
{
$campaign_row=mysql_fetch_row($campaign_rslt);
$campaign_id=$campaign_row[0];
}
$stmt="select status, status_name from vicidial_statuses UNION select status, status_name from vicidial_campaign_statuses where campaign_id='$campaign_id' order by status, status_name asc";
$rslt=mysql_query($stmt, $link);
echo "<select id='template_statuses' name='template_statuses[]' size=5 multiple>\n";
echo "\t<option value='--ALL--' selected>--ALL DISPOSITIONS--</option>\n";
while ($row=mysql_fetch_array($rslt))
{
echo "\t<option value='$row[status]'>$row[status] - $row[status_name]</option>\n";
}
echo "</select>\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 "<B>** $form_action</b>"; 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 "<table border=0 width='100%' cellpadding=0 cellspacing=0>";
$rslt=mysql_query("$fields_stmt", $link);
$custom_fields_count=mysql_num_fields($rslt)-$vl_fields_count;
for ($i=0; $i<mysql_num_fields($rslt); $i++)
{
if (preg_match('/'.mysql_field_name($rslt, $i).'/', $vicidial_list_fields)) {$bgcolor="#D9E6FE";} else {$bgcolor="#FED9D9";}
echo " <tr bgcolor='$bgcolor'>\r\n";
echo " <td align=right nowrap><font class=standard>".strtoupper(preg_replace('/_/i', ' ', mysql_field_name($rslt, $i))).": </font></td>\r\n";
if (mysql_field_name($rslt, $i)!="list_id")
{
echo " <td align=left><select name='$field_prefix".mysql_field_name($rslt, $i)."_field' onChange='DrawTemplateStrings()'>\r\n";
echo " <option value='-1'>(none)</option>\r\n";
for ($j=0; $j<count($row); $j++)
{
preg_replace('/\"/i', '', $row[$j]);
echo " <option value='$j'>\"$row[$j]\"</option>\r\n";
}
$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";
echo " </select></td>\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 "<center><font face='arial, helvetica' size=3 color='#009900'><B>Processing $delim_name file...\n";
$row=explode($delimiter, preg_replace('/[\'\"]/i', '', $buffer));
# echo "delimiter: $delimiter<BR>$buffer<BR>";
}
echo "<table border=0 width='100%' cellpadding=0 cellspacing=0>";
$rslt=mysql_query("$fields_stmt", $link);
$custom_fields_count=mysql_num_fields($rslt)-$vl_fields_count;
for ($i=0; $i<mysql_num_fields($rslt); $i++)
{
if (preg_match('/'.mysql_field_name($rslt, $i).'/', $vicidial_list_fields)) {$bgcolor="#D9E6FE";} else {$bgcolor="#FED9D9";}
echo " <tr bgcolor='$bgcolor'>\r\n";
echo " <td align=right nowrap><font class=standard>".strtoupper(preg_replace('/_/i', ' ', mysql_field_name($rslt, $i))).": </font></td>\r\n";
if (mysql_field_name($rslt, $i)!="list_id")
{
echo " <td align=left><select name='$field_prefix".mysql_field_name($rslt, $i)."_field' onChange='DrawTemplateStrings()'>\r\n";
echo " <option value='-1'>(none)</option>\r\n";
for ($j=0; $j<count($row); $j++)
else
{
preg_replace('/\"/i', '', $row[$j]);
echo " <option value='$j'>\"$row[$j]\"</option>\r\n";
echo " <td align=left>&nbsp;<font class='standard_bold'>$list_id<input type='hidden' name='".$field_prefix.$list_id."' value='$list_id'></font></td>\r\n";
}
echo " </select></td>\r\n";
echo " </tr>\r\n";
}
else
{
echo " <td align=left>&nbsp;<font class='standard_bold'>$list_id<input type='hidden' name='".$field_prefix.$list_id."' value='$list_id'></font></td>\r\n";
}
echo " </tr>\r\n";
}
echo "</table>";
echo "</table>";
}
?>