';
$header_nonselected_bold='';
$lists_color = '#FFFF99';
$lists_font = 'BLACK';
$lists_color = '#E6E6E6';
$subcamp_color = '#C6C6C6';
##### END Set variables to make header show properly #####
require("admin_header.php");
if ( ($LOGcustom_fields_modify < 1) or ($LOGuser_level < 8) )
{
echo "You are not authorized to view this section\n";
exit;
}
if ($SScustom_fields_enabled < 1)
{
echo "ERROR: Custom Fields are not active on this system\n";
exit;
}
$NWB = " ";
if ($DB > 0)
{
echo "$DB,$action,$ip,$user,$copy_option,$field_id,$list_id,$source_list_id,$field_label,$field_name,$field_description,$field_rank,$field_help,$field_type,$field_options,$field_size,$field_max,$field_default,$field_required,$field_cost,$multi_position,$name_position,$field_order";
}
################################################################################
##### BEGIN copy fields to a list form
if ($action == "COPY_FIELDS_FORM")
{
##### get lists listing for dynamic pulldown
$stmt="SELECT list_id,list_name from vicidial_lists order by list_id";
$rsltx=mysql_to_mysqli($stmt, $link);
$lists_to_print = mysqli_num_rows($rsltx);
$lists_list='';
$o=0;
while ($lists_to_print > $o)
{
$rowx=mysqli_fetch_row($rsltx);
$lists_list .= "\n";
$o++;
}
echo "
\n";
echo "";
echo " Copy Fields to Another List
\n";
}
### END copy fields to a list form
################################################################################
##### BEGIN copy list fields submit
if ( ($action == "COPY_FIELDS_SUBMIT") and ($list_id > 99) and ($source_list_id > 99) and (strlen($copy_option) > 2) )
{
if ($list_id=="$source_list_id")
{echo "ERROR: You cannot copy fields to the same list: $list_id|$source_list_id\n ";}
else
{
$table_exists=0;
#$linkCUSTOM=mysql_connect("$VARDB_server:$VARDB_port", "$VARDB_custom_user","$VARDB_custom_pass");
$linkCUSTOM=mysqli_connect("$VARDB_server", "$VARDB_custom_user", "$VARDB_custom_pass", "$VARDB_database", "$VARDB_port");
if (!$linkCUSTOM)
{
die('MySQL connect ERROR: ' . mysqli_error($linkCUSTOM));
}
# if (!$linkCUSTOM) {die("Could not connect: $VARDB_server|$VARDB_port|$VARDB_database|$VARDB_custom_user|$VARDB_custom_pass" . mysqli_error());}
#mysql_select_db("$VARDB_database", $linkCUSTOM);
$stmt="SELECT count(*) from vicidial_lists_fields where list_id='$source_list_id';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
$fieldscount_to_print = mysqli_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$source_field_exists = $rowx[0];
}
$stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
$fieldscount_to_print = mysqli_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$field_exists = $rowx[0];
}
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
$rslt=mysql_to_mysqli($stmt, $link);
$tablecount_to_print = mysqli_num_rows($rslt);
if ($tablecount_to_print > 0)
{$table_exists = 1;}
if ($DB>0) {echo "$stmt|$tablecount_to_print|$table_exists";}
if ($source_field_exists < 1)
{echo "ERROR: Source list has no custom fields\n ";}
else
{
##### REPLACE option #####
if ($copy_option=='REPLACE')
{
if ($DB > 0) {echo "Starting REPLACE copy\n ";}
if ($table_exists > 0)
{
$stmt="SELECT field_id,field_label from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;";
$rslt=mysql_to_mysqli($stmt, $link);
$fields_to_print = mysqli_num_rows($rslt);
$fields_list='';
$o=0;
while ($fields_to_print > $o)
{
$rowx=mysqli_fetch_row($rslt);
$A_field_id[$o] = $rowx[0];
$A_field_label[$o] = $rowx[1];
$o++;
}
$o=0;
while ($fields_to_print > $o)
{
### delete field function
delete_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$A_field_id[$o],$list_id,$A_field_label[$o],$A_field_name[$o],$A_field_description[$o],$A_field_rank[$o],$A_field_help[$o],$A_field_type[$o],$A_field_options[$o],$A_field_size[$o],$A_field_max[$o],$A_field_default[$o],$A_field_required[$o],$A_field_cost[$o],$A_multi_position[$o],$A_name_position[$o],$A_field_order[$o],$vicidial_list_fields);
echo "SUCCESS: Custom Field Deleted - $list_id|$A_field_label[$o]\n ";
$o++;
}
}
$copy_option='APPEND';
}
##### APPEND option #####
if ($copy_option=='APPEND')
{
if ($DB > 0) {echo "Starting APPEND copy\n ";}
$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='$source_list_id' order by field_rank,field_order,field_label;";
$rslt=mysql_to_mysqli($stmt, $link);
$fields_to_print = mysqli_num_rows($rslt);
$fields_list='';
$o=0;
while ($fields_to_print > $o)
{
$rowx=mysqli_fetch_row($rslt);
$A_field_id[$o] = $rowx[0];
$A_field_label[$o] = $rowx[1];
$A_field_name[$o] = $rowx[2];
$A_field_description[$o] = $rowx[3];
$A_field_rank[$o] = $rowx[4];
$A_field_help[$o] = $rowx[5];
$A_field_type[$o] = $rowx[6];
$A_field_options[$o] = $rowx[7];
$A_field_size[$o] = $rowx[8];
$A_field_max[$o] = $rowx[9];
$A_field_default[$o] = $rowx[10];
$A_field_cost[$o] = $rowx[11];
$A_field_required[$o] = $rowx[12];
$A_multi_position[$o] = $rowx[13];
$A_name_position[$o] = $rowx[14];
$A_field_order[$o] = $rowx[15];
$o++;
$rank_select .= "";
}
$o=0;
while ($fields_to_print > $o)
{
$new_field_exists=0;
if ($table_exists > 0)
{
$stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id' and field_label='$A_field_label[$o]';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
$fieldscount_to_print = mysqli_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$new_field_exists = $rowx[0];
}
}
if ($new_field_exists < 1)
{
$temp_field_label = $A_field_label[$o];
if (preg_match("/\|$temp_field_label\|/i",$vicidial_list_fields))
{$A_field_label[$o] = strtolower($A_field_label[$o]);}
### add field function
add_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$A_field_id[$o],$list_id,$A_field_label[$o],$A_field_name[$o],$A_field_description[$o],$A_field_rank[$o],$A_field_help[$o],$A_field_type[$o],$A_field_options[$o],$A_field_size[$o],$A_field_max[$o],$A_field_default[$o],$A_field_required[$o],$A_field_cost[$o],$A_multi_position[$o],$A_name_position[$o],$A_field_order[$o],$vicidial_list_fields,$mysql_reserved_words);
echo "SUCCESS: Custom Field Added - $list_id|$A_field_label[$o]\n ";
if ($table_exists < 1) {$table_exists=1;}
}
$o++;
}
}
##### UPDATE option #####
if ($copy_option=='UPDATE')
{
if ($DB > 0) {echo "Starting UPDATE copy\n ";}
if ($table_exists < 1)
{echo "ERROR: Table does not exist custom_$list_id\n ";}
else
{
$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='$source_list_id' order by field_rank,field_order,field_label;";
$rslt=mysql_to_mysqli($stmt, $link);
$fields_to_print = mysqli_num_rows($rslt);
$fields_list='';
$o=0;
while ($fields_to_print > $o)
{
$rowx=mysqli_fetch_row($rslt);
$A_field_id[$o] = $rowx[0];
$A_field_label[$o] = $rowx[1];
$A_field_name[$o] = $rowx[2];
$A_field_description[$o] = $rowx[3];
$A_field_rank[$o] = $rowx[4];
$A_field_help[$o] = $rowx[5];
$A_field_type[$o] = $rowx[6];
$A_field_options[$o] = $rowx[7];
$A_field_size[$o] = $rowx[8];
$A_field_max[$o] = $rowx[9];
$A_field_default[$o] = $rowx[10];
$A_field_cost[$o] = $rowx[11];
$A_field_required[$o] = $rowx[12];
$A_multi_position[$o] = $rowx[13];
$A_name_position[$o] = $rowx[14];
$A_field_order[$o] = $rowx[15];
$o++;
}
$o=0;
while ($fields_to_print > $o)
{
$stmt="SELECT field_id from vicidial_lists_fields where list_id='$list_id' and field_label='$A_field_label[$o]';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
$fieldscount_to_print = mysqli_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$current_field_id = $rowx[0];
### modify field function
modify_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$current_field_id,$list_id,$A_field_label[$o],$A_field_name[$o],$A_field_description[$o],$A_field_rank[$o],$A_field_help[$o],$A_field_type[$o],$A_field_options[$o],$A_field_size[$o],$A_field_max[$o],$A_field_default[$o],$A_field_required[$o],$A_field_cost[$o],$A_multi_position[$o],$A_name_position[$o],$A_field_order[$o],$vicidial_list_fields);
echo "SUCCESS: Custom Field Modified - $list_id|$A_field_label[$o]\n ";
}
$o++;
}
}
}
}
$action = "MODIFY_CUSTOM_FIELDS";
}
}
### END copy list fields submit
################################################################################
##### BEGIN delete custom field confirmation
if ( ($action == "DELETE_CUSTOM_FIELD_CONFIRMATION") and ($list_id > 99) and ($field_id > 0) and (strlen($field_label) > 0) )
{
$stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id' and field_label='$field_label';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
$fieldscount_to_print = mysqli_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$field_exists = $rowx[0];
}
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
$rslt=mysql_to_mysqli($stmt, $link);
$tablecount_to_print = mysqli_num_rows($rslt);
if ($tablecount_to_print > 0)
{$table_exists = 1;}
if ($DB>0) {echo "$stmt|$tablecount_to_print|$table_exists";}
if ($field_exists < 1)
{echo "ERROR: Field does not exist\n ";}
else
{
if ($table_exists < 1)
{echo "ERROR: Table does not exist custom_$list_id\n ";}
else
{
echo "
";
}
}
$action = "MODIFY_CUSTOM_FIELDS";
}
### END delete custom field confirmation
################################################################################
##### BEGIN delete custom field
if ( ($action == "DELETE_CUSTOM_FIELD") and ($list_id > 99) and ($field_id > 0) and (strlen($field_label) > 0) and ($ConFiRm=='YES') )
{
$table_exists=0;
#$linkCUSTOM=mysql_connect("$VARDB_server:$VARDB_port", "$VARDB_custom_user","$VARDB_custom_pass");
#if (!$linkCUSTOM) {die("Could not connect: $VARDB_server|$VARDB_port|$VARDB_database|$VARDB_custom_user|$VARDB_custom_pass" . mysqli_error());}
#mysql_select_db("$VARDB_database", $linkCUSTOM);
$linkCUSTOM=mysqli_connect("$VARDB_server", "$VARDB_custom_user", "$VARDB_custom_pass", "$VARDB_database", "$VARDB_port");
if (!$linkCUSTOM)
{
die('MySQL connect ERROR: ' . mysqli_error($linkCUSTOM));
}
$stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id' and field_label='$field_label';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
$fieldscount_to_print = mysqli_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$field_exists = $rowx[0];
}
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
$rslt=mysql_to_mysqli($stmt, $link);
$tablecount_to_print = mysqli_num_rows($rslt);
if ($tablecount_to_print > 0)
{$table_exists = 1;}
if ($DB>0) {echo "$stmt|$tablecount_to_print|$table_exists";}
if ($field_exists < 1)
{echo "ERROR: Field does not exist\n ";}
else
{
if ($table_exists < 1)
{echo "ERROR: Table does not exist custom_$list_id\n ";}
else
{
### delete field function
delete_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$field_id,$list_id,$field_label,$field_name,$field_description,$field_rank,$field_help,$field_type,$field_options,$field_size,$field_max,$field_default,$field_required,$field_cost,$multi_position,$name_position,$field_order,$vicidial_list_fields);
echo "SUCCESS: Custom Field Deleted - $list_id|$field_label\n ";
}
}
$action = "MODIFY_CUSTOM_FIELDS";
}
### END delete custom field
################################################################################
##### BEGIN add new custom field
if ( ($action == "ADD_CUSTOM_FIELD") and ($list_id > 99) )
{
$stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id' and field_label='$field_label';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
$fieldscount_to_print = mysqli_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$field_exists = $rowx[0];
}
if ( (strlen($field_label)<1) or (strlen($field_name)<2) or (strlen($field_size)<1) )
{echo "ERROR: You must enter a field label, field name and field size - $list_id|$field_label|$field_name|$field_size\n ";}
else
{
if ( ( ($field_type=='TEXT') or ($field_type=='READONLY') or ($field_type=='HIDDEN') ) and ($field_max < strlen($field_default)) )
{echo "ERROR: Default value cannot be longer than maximum field length - $list_id|$field_label|$field_name|$field_max|$field_default|\n ";}
else
{
if (preg_match("/\|$field_label\|/i",$mysql_reserved_words))
{echo "ERROR: You cannot use reserved words for field labels - $list_id|$field_label|$field_name|$field_size\n ";}
else
{
$TEST_valid_options=0;
if ( ($field_type=='SELECT') or ($field_type=='MULTI') or ($field_type=='RADIO') or ($field_type=='CHECKBOX') )
{
$TESTfield_options_array = explode("\n",$field_options);
$TESTfield_options_count = count($TESTfield_options_array);
$te=0;
while ($te < $TESTfield_options_count)
{
if (preg_match("/,/",$TESTfield_options_array[$te]))
{
$TESTfield_options_value_array = explode(",",$TESTfield_options_array[$te]);
if ( (strlen($TESTfield_options_value_array[0]) > 0) and (strlen($TESTfield_options_value_array[1]) > 0) )
{$TEST_valid_options++;}
}
$te++;
}
$field_options_ENUM = preg_replace("/.$/",'',$field_options_ENUM);
}
if ( ( ($field_type=='SELECT') or ($field_type=='MULTI') or ($field_type=='RADIO') or ($field_type=='CHECKBOX') ) and ( (!preg_match("/,/",$field_options)) or (!preg_match("/\n/",$field_options)) or (strlen($field_options)<6) or ($TEST_valid_options < 1) ) )
{echo "ERROR: You must enter field options when adding a SELECT, MULTI, RADIO or CHECKBOX field type - $list_id|$field_label|$field_type|$field_options\n ";}
else
{
if ($field_exists > 0)
{echo "ERROR: Field already exists for this list - $list_id|$field_label\n ";}
else
{
$table_exists=0;
#$linkCUSTOM=mysql_connect("$VARDB_server:$VARDB_port", "$VARDB_custom_user","$VARDB_custom_pass");
#if (!$linkCUSTOM) {die("Could not connect: $VARDB_server|$VARDB_port|$VARDB_database|$VARDB_custom_user|$VARDB_custom_pass" . mysqli_error());}
#mysql_select_db("$VARDB_database", $linkCUSTOM);
$linkCUSTOM=mysqli_connect("$VARDB_server", "$VARDB_custom_user", "$VARDB_custom_pass", "$VARDB_database", "$VARDB_port");
if (!$linkCUSTOM)
{
die('MySQL connect ERROR: ' . mysqli_error($linkCUSTOM));
}
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
$rslt=mysql_to_mysqli($stmt, $link);
$tablecount_to_print = mysqli_num_rows($rslt);
if ($tablecount_to_print > 0)
{$table_exists = 1;}
if ($DB>0) {echo "$stmt|$tablecount_to_print|$table_exists";}
if (preg_match("/\|$field_label\|/i",$vicidial_list_fields))
{$field_label = strtolower($field_label);}
### add field function
add_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$field_id,$list_id,$field_label,$field_name,$field_description,$field_rank,$field_help,$field_type,$field_options,$field_size,$field_max,$field_default,$field_required,$field_cost,$multi_position,$name_position,$field_order,$vicidial_list_fields,$mysql_reserved_words);
echo "SUCCESS: Custom Field Added - $list_id|$field_label\n ";
}
}
}
}
}
$action = "MODIFY_CUSTOM_FIELDS";
}
### END add new custom field
################################################################################
##### BEGIN modify custom field submission
if ( ($action == "MODIFY_CUSTOM_FIELD_SUBMIT") and ($list_id > 99) and ($field_id > 0) )
{
### connect to your vtiger database
#$linkCUSTOM=mysql_connect("$VARDB_server:$VARDB_port", "$VARDB_custom_user","$VARDB_custom_pass");
#if (!$linkCUSTOM) {die("Could not connect: $VARDB_server|$VARDB_port|$VARDB_database|$VARDB_custom_user|$VARDB_custom_pass" . mysqli_error());}
#mysql_select_db("$VARDB_database", $linkCUSTOM);
$linkCUSTOM=mysqli_connect("$VARDB_server", "$VARDB_custom_user", "$VARDB_custom_pass", "$VARDB_database", "$VARDB_port");
if (!$linkCUSTOM)
{
die('MySQL connect ERROR: ' . mysqli_error($linkCUSTOM));
}
$stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id' and field_id='$field_id';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
$fieldscount_to_print = mysqli_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$field_exists = $rowx[0];
}
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
$rslt=mysql_to_mysqli($stmt, $link);
$tablecount_to_print = mysqli_num_rows($rslt);
if ($tablecount_to_print > 0)
{$table_exists = 1;}
if ($DB>0) {echo "$stmt|$tablecount_to_print|$table_exists";}
if ($field_exists < 1)
{echo "ERROR: Field does not exist\n ";}
else
{
if ($table_exists < 1)
{echo "ERROR: Table does not exist\n ";}
else
{
if ( ( ($field_type=='TEXT') or ($field_type=='READONLY') or ($field_type=='HIDDEN') ) and ($field_max < strlen($field_default)) )
{echo "ERROR: Default value cannot be longer than maximum field length - $list_id|$field_label|$field_name|$field_max|$field_default|\n ";}
else
{
$TEST_valid_options=0;
if ( ($field_type=='SELECT') or ($field_type=='MULTI') or ($field_type=='RADIO') or ($field_type=='CHECKBOX') )
{
$TESTfield_options_array = explode("\n",$field_options);
$TESTfield_options_count = count($TESTfield_options_array);
$te=0;
while ($te < $TESTfield_options_count)
{
if (preg_match("/,/",$TESTfield_options_array[$te]))
{
$TESTfield_options_value_array = explode(",",$TESTfield_options_array[$te]);
if ( (strlen($TESTfield_options_value_array[0]) > 0) and (strlen($TESTfield_options_value_array[1]) > 0) )
{$TEST_valid_options++;}
}
$te++;
}
$field_options_ENUM = preg_replace("/.$/",'',$field_options_ENUM);
}
if ( ( ($field_type=='SELECT') or ($field_type=='MULTI') or ($field_type=='RADIO') or ($field_type=='CHECKBOX') ) and ( (!preg_match("/,/",$field_options)) or (!preg_match("/\n/",$field_options)) or (strlen($field_options)<6) or ($TEST_valid_options < 1) ) )
{echo "ERROR: You must enter field options when updating a SELECT, MULTI, RADIO or CHECKBOX field type - $list_id|$field_label|$field_type|$field_options\n ";}
else
{
### modify field function
modify_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$field_id,$list_id,$field_label,$field_name,$field_description,$field_rank,$field_help,$field_type,$field_options,$field_size,$field_max,$field_default,$field_required,$field_cost,$multi_position,$name_position,$field_order,$vicidial_list_fields);
echo "SUCCESS: Custom Field Modified - $list_id|$field_label\n ";
}
}
}
}
$action = "MODIFY_CUSTOM_FIELDS";
}
### END modify custom field submission
################################################################################
##### BEGIN modify custom fields for list
if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) )
{
echo "\n";
echo "
\n";
$custom_records_count=0;
$stmt="SHOW TABLES LIKE \"custom_$list_id\";";
$rslt=mysql_to_mysqli($stmt, $link);
$tablecount_to_print = mysqli_num_rows($rslt);
if ($tablecount_to_print > 0)
{$table_exists = 1;}
if ($DB>0) {echo "$stmt|$tablecount_to_print|$table_exists";}
if ($table_exists > 0)
{
$stmt="SELECT count(*) from custom_$list_id;";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
$fieldscount_to_print = mysqli_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$custom_records_count = $rowx[0];
}
}
echo "";
echo " Modify Custom Fields: List ID $list_id ";
echo "Records in this custom table: $custom_records_count \n";
echo "
\n";
}
### END modify custom fields for list
################################################################################
##### BEGIN list lists as well as the number of custom fields in each list
if ($action == "LIST")
{
$stmt="SELECT list_id,list_name,active,campaign_id from vicidial_lists order by list_id;";
$rslt=mysql_to_mysqli($stmt, $link);
$lists_to_print = mysqli_num_rows($rslt);
$o=0;
while ($lists_to_print > $o)
{
$rowx=mysqli_fetch_row($rslt);
$A_list_id[$o] = $rowx[0];
$A_list_name[$o] = $rowx[1];
$A_active[$o] = $rowx[2];
$A_campaign_id[$o] = $rowx[3];
$o++;
}
echo " LIST LISTINGS WITH CUSTOM FIELDS COUNT:\n";
echo "
\n";
echo "
";
echo "
LIST ID
";
echo "
LIST NAME
";
echo "
ACTIVE
";
echo "
CAMPAIGN
\n";
echo "
CUSTOM FIELDS
\n";
echo "
MODIFY
\n";
echo "
\n";
$o=0;
while ($lists_to_print > $o)
{
$A_list_fields_count[$o]=0;
$stmt="SELECT count(*) from vicidial_lists_fields where list_id='$A_list_id[$o]';";
if ($DB>0) {echo "$stmt";}
$rslt=mysql_to_mysqli($stmt, $link);
$fieldscount_to_print = mysqli_num_rows($rslt);
if ($fieldscount_to_print > 0)
{
$rowx=mysqli_fetch_row($rslt);
$A_list_fields_count[$o] = $rowx[0];
}
if (preg_match('/1$|3$|5$|7$|9$/i', $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "
\n";
}
### END list lists as well as the number of custom fields in each list
################################################################################
##### BEGIN admin log display
if ($action == "ADMIN_LOG")
{
if ($LOGuser_level >= 9)
{
echo "
\n";
echo "";
$stmt="SELECT admin_log_id,event_date,user,ip_address,event_section,event_type,record_id,event_code from vicidial_admin_log where event_section='CUSTOM_FIELDS' and record_id='$list_id' order by event_date desc limit 10000;";
$rslt=mysql_to_mysqli($stmt, $link);
$logs_to_print = mysqli_num_rows($rslt);
echo " ADMIN CHANGE LOG: Section Records - $category - $stage\n";
echo "
\n";
echo "
";
echo "
ID
";
echo "
DATE TIME
";
echo "
USER
\n";
echo "
IP
\n";
echo "
SECTION
\n";
echo "
TYPE
\n";
echo "
RECORD ID
\n";
echo "
DESCRIPTION
\n";
echo "
GOTO
\n";
echo "
\n";
$logs_printed = '';
$o=0;
while ($logs_to_print > $o)
{
$row=mysqli_fetch_row($rslt);
if (preg_match('/USER|AGENT/i', $row[4])) {$record_link = "ADD=3&user=$row[6]";}
if (preg_match('/CAMPAIGN/i', $row[4])) {$record_link = "ADD=31&campaign_id=$row[6]";}
if (preg_match('/LIST/i', $row[4])) {$record_link = "ADD=311&list_id=$row[6]";}
if (preg_match('/SCRIPT/i', $row[4])) {$record_link = "ADD=3111111&script_id=$row[6]";}
if (preg_match('/FILTER/i', $row[4])) {$record_link = "ADD=31111111&lead_filter_id=$row[6]";}
if (preg_match('/INGROUP/i', $row[4])) {$record_link = "ADD=3111&group_id=$row[6]";}
if (preg_match('/DID/i', $row[4])) {$record_link = "ADD=3311&did_id=$row[6]";}
if (preg_match('/USERGROUP/i', $row[4])) {$record_link = "ADD=311111&user_group=$row[6]";}
if (preg_match('/REMOTEAGENT/i', $row[4])) {$record_link = "ADD=31111&remote_agent_id=$row[6]";}
if (preg_match('/PHONE/i', $row[4])) {$record_link = "ADD=10000000000";}
if (preg_match('/CALLTIME/i', $row[4])) {$record_link = "ADD=311111111&call_time_id=$row[6]";}
if (preg_match('/SHIFT/i', $row[4])) {$record_link = "ADD=331111111&shift_id=$row[6]";}
if (preg_match('/CONFTEMPLATE/i', $row[4])) {$record_link = "ADD=331111111111&template_id=$row[6]";}
if (preg_match('/CARRIER/i', $row[4])) {$record_link = "ADD=341111111111&carrier_id=$row[6]";}
if (preg_match('/SERVER/i', $row[4])) {$record_link = "ADD=311111111111&server_id=$row[6]";}
if (preg_match('/CONFERENCE/i', $row[4])) {$record_link = "ADD=1000000000000";}
if (preg_match('/SYSTEM/i', $row[4])) {$record_link = "ADD=311111111111111";}
if (preg_match('/CATEGOR/i', $row[4])) {$record_link = "ADD=331111111111111";}
if (preg_match('/GROUPALIAS/i', $row[4])) {$record_link = "ADD=33111111111&group_alias_id=$row[6]";}
if (preg_match('/1$|3$|5$|7$|9$/i', $o))
{$bgcolor='bgcolor="#B9CBFD"';}
else
{$bgcolor='bgcolor="#9BB9FB"';}
echo "