diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE
index 99e46490..894055fa 100644
--- a/agc_2-X/trunk/UPGRADE
+++ b/agc_2-X/trunk/UPGRADE
@@ -220,6 +220,9 @@ OTHER CHANGES:
55. Added new Real-Time Whiteboard multi-report
+56. Added the ability to include duplicate custom text fields in a custom fields
+ form in the agent screen.
+
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 8df34401..ea4620c6 100644
--- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql
+++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql
@@ -2663,7 +2663,8 @@ name_position ENUM('LEFT','TOP') default 'LEFT',
multi_position ENUM('HORIZONTAL','VERTICAL') default 'HORIZONTAL',
field_order SMALLINT(5) default '1',
field_encrypt ENUM('Y','N') default 'N',
-field_show_hide ENUM('DISABLED','X_OUT_ALL','LAST_1','LAST_2','LAST_3','LAST_4','FIRST_1_LAST_4') default 'DISABLED'
+field_show_hide ENUM('DISABLED','X_OUT_ALL','LAST_1','LAST_2','LAST_3','LAST_4','FIRST_1_LAST_4') default 'DISABLED',
+field_duplicate ENUM('Y','N') default 'N'
) ENGINE=MyISAM;
CREATE UNIQUE INDEX listfield on vicidial_lists_fields (list_id, field_label);
@@ -4096,4 +4097,4 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_
UPDATE system_settings set vdc_agent_api_active='1';
-UPDATE system_settings SET db_schema_version='1523',db_schema_update_date=NOW(),reload_timestamp=NOW();
+UPDATE system_settings SET db_schema_version='1524',db_schema_update_date=NOW(),reload_timestamp=NOW();
diff --git a/agc_2-X/trunk/extras/upgrade_2.14.sql b/agc_2-X/trunk/extras/upgrade_2.14.sql
index 2e39dd6d..d0c95a12 100644
--- a/agc_2-X/trunk/extras/upgrade_2.14.sql
+++ b/agc_2-X/trunk/extras/upgrade_2.14.sql
@@ -429,3 +429,7 @@ ALTER TABLE vicidial_callbacks_archive ADD email_result ENUM('SENT','FAILED','NO
INSERT INTO vicidial_settings_containers(container_id,container_notes,container_type,user_group,container_entry) VALUES ('AGENT_CALLBACK_EMAIL ','Scheduled callback email alert settings','OTHER','---ALL---','; sending email address\r\nemail_from => vicidial@local.server\r\n\r\n; subject of the email\r\nemail_subject => Scheduled callback alert for --A--agent_name--B--\r\n\r\nemail_body_begin => \r\nThis is a reminder that you have a scheduled callback right now for the following lead:\r\n\r\nName: --A--first_name--B-- --A--last_name--B--\r\nPhone: --A--phone_number--B--\r\nAlt. phone: --A--alt_phone--B--\r\nEmail: --A--email--B--\r\nCB Comments: --A--callback_comments--B--\r\nLead Comments: --A--comments--B--\r\n\r\nPlease don\'t respond to this, fool.\r\n\r\nemail_body_end');
UPDATE system_settings SET db_schema_version='1523',db_schema_update_date=NOW() where db_schema_version < 1523;
+
+ALTER TABLE vicidial_lists_fields ADD field_duplicate ENUM('Y','N') default 'N';
+
+UPDATE system_settings SET db_schema_version='1524',db_schema_update_date=NOW() where db_schema_version < 1524;
diff --git a/agc_2-X/trunk/www/agc/functions.php b/agc_2-X/trunk/www/agc/functions.php
index 9ed3b3ca..dbf07e50 100644
--- a/agc_2-X/trunk/www/agc/functions.php
+++ b/agc_2-X/trunk/www/agc/functions.php
@@ -41,6 +41,7 @@
# 170526-2141 - Added additional auth variable filtering, issue #1016
# 170528-1029 - Fix for rare inbound logging issue #1017, Added variable filtering
# 171021-1340 - Fix to update default field if duplicate field in custom fields changed
+# 171116-2333 - Added code for duplicate custom fields
#
# $mysql_queries = 26
@@ -349,11 +350,14 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
$custom_records_count = $rowx[0];
$select_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 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,field_duplicate from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'05004',$user,$server_ip,$session_name,$one_mysql_log);}
$fields_to_print = mysqli_num_rows($rslt);
$fields_list='';
+ $duplicates_list='';
+ $duplicates_master_list='';
+ $duplicates_count=0;
$o=0;
while ($fields_to_print > $o)
{
@@ -374,9 +378,25 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
$A_multi_position[$o] = $rowx[13];
$A_name_position[$o] = $rowx[14];
$A_field_order[$o] = $rowx[15];
+ $A_field_duplicate[$o] = $rowx[16];
$A_field_value[$o] = '';
- if (!preg_match("/\|$A_field_label[$o]\|/i",$vicidial_list_fields))
+ if ($A_field_duplicate[$o] == 'Y')
+ {
+ $A_master_field[$o] = preg_replace("/_DUPLICATE_.*/",'',$A_field_label[$o]);
+ $A_field_value[$o] = '--A--' . $A_master_field[$o] . '--B--';
+
+ if (!preg_match("/\|$A_master_field[$o]\|/i",$duplicates_master_list))
+ {
+ $duplicates_count++;
+ $duplicates_master_list .= "|$A_master_field[$o]|";
+ }
+ if (!preg_match("/\|$A_field_label[$o]\|/i",$duplicates_list))
+ {
+ $duplicates_list .= "|$A_field_label[$o]|";
+ }
+ }
+ if ( (!preg_match("/\|$A_field_label[$o]\|/i",$vicidial_list_fields)) and (!preg_match("/\|$A_master_field[$o]\|/i",$vicidial_list_fields)) )
{
if ( ($A_field_type[$o]=='DISPLAY') or ($A_field_type[$o]=='SCRIPT') )
{
@@ -385,8 +405,16 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
}
else
{
- $select_SQL .= "$A_field_label[$o],";
- $A_field_select[$o]=$A_field_label[$o];
+ if ($A_field_duplicate[$o]=='Y')
+ {
+ $select_SQL .= "$A_master_field[$o],";
+ $A_field_select[$o]=$A_field_label[$o];
+ }
+ else
+ {
+ $select_SQL .= "$A_field_label[$o],";
+ $A_field_select[$o]=$A_field_label[$o];
+ }
}
}
else
@@ -423,6 +451,8 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
{$A_field_value[$o]='';}
if (preg_match("/\|$A_field_label[$o]\|/i",$vicidial_list_fields))
{$A_field_value[$o] = '--A--' . $A_field_label[$o] . '--B--';}
+ if (preg_match("/_DUPLICATE_\d\d\d/",$A_field_label[$o]))
+ {$A_field_value[$o] = '--A--' . $A_master_field[$o] . '--B--';}
$o++;
}
}
@@ -563,8 +593,52 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
if ($A_field_type[$o]=='TEXT')
{
$change_trigger='';
+ $default_field_flag=0;
if (preg_match("/\|$A_field_label[$o]\|/i",$vicidial_list_fields))
- {$change_trigger="onchange=\"update_default_vd_field('$A_field_label[$o]');\"";}
+ {
+ $change_trigger="onchange=\"update_default_vd_field('$A_field_label[$o]');\"";
+ $default_field_flag++;
+ }
+
+ if ( ($duplicates_count > 0) and ( (preg_match("/\|$A_field_label[$o]\|/i",$duplicates_master_list)) or (preg_match("/\|$A_field_label[$o]\|/i",$duplicates_list)) ) )
+ {
+ $update_dup_fields='';
+ $update_dup_ct=0;
+ if (preg_match("/\|$A_field_label[$o]\|/i",$duplicates_master_list))
+ {
+ $master_field = $A_field_label[$o];
+ $master_field_match = $master_field . '_DUPLICATE_.*';
+ $dup_fields = explode('|',$duplicates_list);
+ $dup_fields_ct = count($dup_fields);
+ $df=0;
+ while ($dup_fields_ct > $df)
+ {
+ if (preg_match("/$master_field_match/",$dup_fields[$df]))
+ {$update_dup_fields .= "$dup_fields[$df]|"; $update_dup_ct++;}
+ $df++;
+ }
+ }
+ if (preg_match("/\|$A_field_label[$o]\|/i",$duplicates_list))
+ {
+ $master_field = preg_replace("/_DUPLICATE_.*/",'',$A_field_label[$o]);
+ if (preg_match("/\|$master_field\|/i",$vicidial_list_fields))
+ {$default_field_flag++;}
+ $update_dup_fields .= "$master_field|"; $update_dup_ct++;
+ $master_field_match = $master_field . '_DUPLICATE_.*';
+ $dup_fields = explode('|',$duplicates_list);
+ $dup_fields_ct = count($dup_fields);
+ $df=0;
+ while ($dup_fields_ct > $df)
+ {
+ if ( (preg_match("/$master_field_match/",$dup_fields[$df])) and ($dup_fields[$df] != $A_field_label[$o]) )
+ {$update_dup_fields .= "$dup_fields[$df]|"; $update_dup_ct++;}
+ $df++;
+ }
+ }
+ $update_dup_fields = preg_replace("/\|$/",'',$update_dup_fields);
+ $change_trigger="onchange=\"update_dup_field('$A_field_label[$o]','$update_dup_fields',$update_dup_ct,$default_field_flag,'$master_field');\"";
+ }
+
if ($A_field_default[$o]=='NULL') {$A_field_default[$o]='';}
if (strlen($A_field_value[$o]) < 1) {$A_field_value[$o] = $A_field_default[$o];}
$field_HTML .= "\n";
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 16d514a9..a6e8cc0d 100644
--- a/agc_2-X/trunk/www/agc/vdc_db_query.php
+++ b/agc_2-X/trunk/www/agc/vdc_db_query.php
@@ -438,10 +438,11 @@
# 170912-1618 - Fix for no-hopper dnc dialing issue
# 171018-1310 - Added code for campaign scheduled callback email alerts
# 171026-0107 - Added optional queue_log logging
+# 171116-2334 - Added code for duplicate fields
#
-$version = '2.14-332';
-$build = '171026-0107';
+$version = '2.14-333';
+$build = '171116-2334';
$php_script = 'vdc_db_query.php';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=700;
@@ -4906,7 +4907,7 @@ if ($ACTION == 'manDiaLnextCaLL')
$custom_field_values='----------';
$custom_field_types='|';
### find the names of all custom fields, if any
- $stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY') and field_label NOT IN('entry_date','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');";
+ $stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY') and field_label NOT IN('entry_date','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') and field_label NOT LIKE \"%_DUPLICATE_%\";";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00334',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
@@ -12665,6 +12666,7 @@ if ($ACTION == 'updateDISPO')
if (strlen($FORMcustom_field_names)>2)
{
$custom_field_names = preg_replace("/^\||\|$/",'',$FORMcustom_field_names);
+ $custom_field_names = preg_replace("/\|.*_DUPLICATE_.*\|/",'|',$custom_field_names);
$custom_field_names = preg_replace("/\|/",",",$custom_field_names);
$custom_field_names_ARY = explode(',',$custom_field_names);
$custom_field_names_ct = count($custom_field_names_ARY);
diff --git a/agc_2-X/trunk/www/agc/vdc_form_display.php b/agc_2-X/trunk/www/agc/vdc_form_display.php
index fd9736d8..b275313f 100644
--- a/agc_2-X/trunk/www/agc/vdc_form_display.php
+++ b/agc_2-X/trunk/www/agc/vdc_form_display.php
@@ -41,10 +41,11 @@
# 170331-2300 - Added more debug logging
# 170428-1215 - Small fix for admin modify lead display
# 171021-1339 - Fix to update default field if duplicate field in custom fields changed
+# 171116-2333 - Added code for duplicate fields
#
-$version = '2.14-31';
-$build = '171021-1339';
+$version = '2.14-32';
+$build = '171116-2333';
$php_script = 'vdc_form_display.php';
require_once("dbconnect_mysqli.php");
@@ -351,7 +352,7 @@ if ($stage=='SUBMIT')
{
$update_SQL='';
$VL_update_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 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,field_duplicate from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'06003',$user,$server_ip,$session_name,$one_mysql_log);}
$fields_to_print = mysqli_num_rows($rslt);
@@ -369,6 +370,7 @@ if ($stage=='SUBMIT')
$A_field_size[$o] = $rowx[8];
$A_field_max[$o] = $rowx[9];
$A_field_required[$o] = $rowx[12];
+ $A_field_duplicate[$o] = $rowx[16];
$A_field_value[$o] = '';
$field_name_id = $A_field_label[$o];
@@ -411,19 +413,22 @@ if ($stage=='SUBMIT')
}
else
{
- if (preg_match("/\|$A_field_label[$o]\|/i",$vicidial_list_fields))
- {
- $VL_update_SQL .= "$A_field_label[$o]=\"$A_field_value[$o]\",";
+ if (!preg_match("/_DUPLICATE_\d\d\d/",$A_field_label[$o]))
+ {
+ if (preg_match("/\|$A_field_label[$o]\|/i",$vicidial_list_fields))
+ {
+ $VL_update_SQL .= "$A_field_label[$o]=\"$A_field_value[$o]\",";
+ }
+ else
+ {
+ $update_SQL .= "$A_field_label[$o]=\"$A_field_value[$o]\",";
+ }
}
- else
- {
- $update_SQL .= "$A_field_label[$o]=\"$A_field_value[$o]\",";
- }
-
$SUBMIT_output .= "$A_field_name[$o]: $A_field_value[$o]
";
}
$o++;
}
+ # $SUBMIT_output .= "$update_SQL
$VL_update_SQL";
$custom_update_count=0;
if (strlen($update_SQL)>3)
@@ -536,6 +541,21 @@ else
echo " var tempvalue = document.getElementById(taskfield).value;\n";
echo " parent.document.getElementById(taskfield).value = tempvalue;\n";
echo " }\n";
+ echo " function update_dup_field(taskmasterfield,taskupdatefields,taskupdatecount,taskdefaultflag,taskdefaultfield) \n";
+ echo " {\n";
+# echo " alert('1: ' + taskmasterfield + ' 2: ' + taskupdatefields + ' 3: ' + taskupdatecount + ' 4: ' + taskdefaultflag);\n";
+ echo " var tempmastervalue = document.getElementById(taskmasterfield).value;\n";
+ echo " var update_fields_array=taskupdatefields.split(\"|\");\n";
+ echo " var temp_ct=0;\n";
+ echo " while (taskupdatecount > temp_ct)\n";
+ echo " {\n";
+ echo " var temp_updating_field = update_fields_array[temp_ct];\n";
+ echo " document.getElementById(temp_updating_field).value = tempmastervalue;\n";
+ echo " temp_ct++;\n";
+ echo " }\n";
+ echo " if (taskdefaultflag=='1')\n";
+ echo " {parent.document.getElementById(taskdefaultfield).value = tempmastervalue;}\n";
+ echo " }\n";
echo " \n";
echo " \n";
echo "\n";
diff --git a/agc_2-X/trunk/www/vicidial/admin_lists_custom.php b/agc_2-X/trunk/www/vicidial/admin_lists_custom.php
index fd41f151..573efb78 100644
--- a/agc_2-X/trunk/www/vicidial/admin_lists_custom.php
+++ b/agc_2-X/trunk/www/vicidial/admin_lists_custom.php
@@ -44,10 +44,11 @@
# 170301-0827 - Enabled required custom fields with INBOUND_ONLY option
# 170321-1553 - Fixed list view permissions issue #1005
# 170409-1558 - Added IP List validation code
+# 171116-1544 - Added option for duplicate custom field entries(field_duplicate)
#
-$admin_version = '2.14-36';
-$build = '170409-1558';
+$admin_version = '2.14-37';
+$build = '171116-1544';
require("dbconnect_mysqli.php");
require("functions.php");
@@ -93,6 +94,8 @@ if (isset($_GET["multi_position"])) {$multi_position=$_GET["multi_position"];
elseif (isset($_POST["multi_position"])) {$multi_position=$_POST["multi_position"];}
if (isset($_GET["field_order"])) {$field_order=$_GET["field_order"];}
elseif (isset($_POST["field_order"])) {$field_order=$_POST["field_order"];}
+if (isset($_GET["field_duplicate"])) {$field_duplicate=$_GET["field_duplicate"];}
+ elseif (isset($_POST["field_duplicate"])) {$field_duplicate=$_POST["field_duplicate"];}
if (isset($_GET["source_list_id"])) {$source_list_id=$_GET["source_list_id"];}
elseif (isset($_POST["source_list_id"])) {$source_list_id=$_POST["source_list_id"];}
if (isset($_GET["copy_option"])) {$copy_option=$_GET["copy_option"];}
@@ -149,6 +152,7 @@ if ($non_latin < 1)
$source_list_id = preg_replace('/[^0-9]/','',$source_list_id);
$field_required = preg_replace('/[^_A-Z]/','',$field_required);
+ $field_duplicate = preg_replace('/[^_A-Z]/','',$field_duplicate);
$field_type = preg_replace('/[^0-9a-zA-Z]/','',$field_type);
$ConFiRm = preg_replace('/[^0-9a-zA-Z]/','',$ConFiRm);
@@ -369,7 +373,7 @@ $NWE = "')\">
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";
+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,$field_duplicate";
}
@@ -476,7 +480,7 @@ if ( ($action == "COPY_FIELDS_SUBMIT") and ($list_id > 99) and ($source_list_id
if ($DB > 0) {echo _QXZ("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;";
+ $stmt="SELECT field_id,field_label,field_duplicate,field_type 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='';
@@ -486,6 +490,8 @@ if ( ($action == "COPY_FIELDS_SUBMIT") and ($list_id > 99) and ($source_list_id
$rowx=mysqli_fetch_row($rslt);
$A_field_id[$o] = $rowx[0];
$A_field_label[$o] = $rowx[1];
+ $A_field_duplicate[$o] = $rowx[2];
+ $A_field_type[$o] = $rowx[3];
$o++;
}
@@ -493,7 +499,7 @@ if ( ($action == "COPY_FIELDS_SUBMIT") and ($list_id > 99) and ($source_list_id
while ($fields_to_print > $o)
{
### delete field function
- $SQLsuccess = 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);
+ $SQLsuccess = 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],$A_field_duplicate[$o],$vicidial_list_fields);
if ($SQLsuccess > 0)
{echo _QXZ("SUCCESS: Custom Field Deleted")." - $list_id|$A_field_label[$o]\n
";}
@@ -506,7 +512,7 @@ if ( ($action == "COPY_FIELDS_SUBMIT") and ($list_id > 99) and ($source_list_id
if ($copy_option=='APPEND')
{
if ($DB > 0) {echo _QXZ("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;";
+ $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,field_duplicate 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='';
@@ -530,6 +536,7 @@ if ( ($action == "COPY_FIELDS_SUBMIT") and ($list_id > 99) and ($source_list_id
$A_multi_position[$o] = $rowx[13];
$A_name_position[$o] = $rowx[14];
$A_field_order[$o] = $rowx[15];
+ $A_field_duplicate[$o] = $rowx[16];
$o++;
$rank_select .= "";
@@ -552,13 +559,28 @@ if ( ($action == "COPY_FIELDS_SUBMIT") and ($list_id > 99) and ($source_list_id
$new_field_exists = $rowx[0];
}
}
- if ($new_field_exists < 1)
+ if ( ($new_field_exists < 1) or ($A_field_duplicate[$o] == 'Y') )
{
if (preg_match("/\|$temp_field_label\|/i",$vicidial_list_fields))
{$A_field_label[$o] = strtolower($A_field_label[$o]);}
+ if ($A_field_duplicate[$o] == 'Y')
+ {
+ $duplicate_field_count=0;
+ $stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id' and field_label LIKE \"$A_field_label[$o]%\";";
+ if ($DB>0) {echo "$stmt";}
+ $rslt=mysql_to_mysqli($stmt, $link);
+ $dupscount_to_print = mysqli_num_rows($rslt);
+ if ($dupscount_to_print > 0)
+ {
+ $rowx=mysqli_fetch_row($rslt);
+ $duplicate_field_count = $rowx[0];
+ }
+ $A_field_label[$o] .= "_DUPLICATE_" . sprintf('%03d', $duplicate_field_count);
+ }
+
### add field function
- $SQLsuccess = 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);
+ $SQLsuccess = 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],$A_field_duplicate[$o],$vicidial_list_fields,$mysql_reserved_words);
if ($SQLsuccess > 0)
{echo _QXZ("SUCCESS: Custom Field Added")." - $list_id|$A_field_label[$o]\n
";}
@@ -576,11 +598,11 @@ if ( ($action == "COPY_FIELDS_SUBMIT") and ($list_id > 99) and ($source_list_id
if ($copy_option=='UPDATE')
{
if ($DB > 0) {echo _QXZ("Starting UPDATE copy")."\n
";}
- if ( ($table_exists < 1) and (!preg_match("/\|$field_label\|/i",$vicidial_list_fields)) )
+ if ( ($table_exists < 1) and (!preg_match("/\|$field_label\|/i",$vicidial_list_fields)) and ($field_duplicate=='N') )
{echo ""._QXZ("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;";
+ $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,field_duplicate 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='';
@@ -620,7 +642,7 @@ if ( ($action == "COPY_FIELDS_SUBMIT") and ($list_id > 99) and ($source_list_id
$current_field_id = $rowx[0];
### modify field function
- $SQLsuccess = 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);
+ $SQLsuccess = 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],$A_field_duplicate[$o],$vicidial_list_fields);
if ($SQLsuccess > 0)
{echo _QXZ("SUCCESS: Custom Field Modified")." - $list_id|$A_field_label[$o]\n
";}
@@ -665,11 +687,11 @@ if ( ($action == "DELETE_CUSTOM_FIELD_CONFIRMATION") and ($list_id > 99) and ($f
{echo ""._QXZ("ERROR: Field does not exist")."\n
";}
else
{
- if ( ($table_exists < 1) and (!preg_match("/\|$field_label\|/i",$vicidial_list_fields)) )
+ if ( ($table_exists < 1) and (!preg_match("/\|$field_label\|/i",$vicidial_list_fields)) and ($field_duplicate=='N') )
{echo ""._QXZ("ERROR: Table does not exist")." custom_$list_id\n
";}
else
{
- echo "
"._QXZ("CLICK HERE TO CONFIRM DELETION OF THIS CUSTOM FIELD").": $field_label - $field_id - $list_id
";
+ echo "
"._QXZ("CLICK HERE TO CONFIRM DELETION OF THIS CUSTOM FIELD").": $field_label - $field_id - $list_id
";
}
}
@@ -720,7 +742,7 @@ if ( ($action == "DELETE_CUSTOM_FIELD") and ($list_id > 99) and ($field_id > 0)
else
{
### delete field function
- $SQLsuccess = 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);
+ $SQLsuccess = 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,$field_duplicate,$vicidial_list_fields);
if ($SQLsuccess > 0)
{echo _QXZ("SUCCESS: Custom Field Deleted")." - $list_id|$field_label\n
";}
@@ -783,36 +805,61 @@ if ( ($action == "ADD_CUSTOM_FIELD") and ($list_id > 99) )
{echo ""._QXZ("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)
+ if ( ($field_exists > 0) and ($field_duplicate != 'Y') )
{echo ""._QXZ("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)
+ if ( ($field_exists < 1) and ($field_duplicate == 'Y') )
+ {echo ""._QXZ("ERROR: Field set to duplicate but original does not exist for this list")." - $list_id|$field_label|$field_duplicate\n
";}
+ else
{
- die('MySQL '._QXZ("connect ERROR").': '. mysqli_connect_error());
+ if ( ($field_type!='TEXT') and ($field_duplicate == 'Y') )
+ {echo ""._QXZ("ERROR: Field set to duplicate but not TEXT type")." - $list_id|$field_label|$field_duplicate|$field_type\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 '._QXZ("connect ERROR").': '. mysqli_connect_error());
+ }
+
+ $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);}
+
+ if ($field_duplicate == 'Y')
+ {
+ $duplicate_field_count=0;
+ $stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id' and field_label LIKE \"$field_label%\";";
+ if ($DB>0) {echo "$stmt";}
+ $rslt=mysql_to_mysqli($stmt, $link);
+ $dupscount_to_print = mysqli_num_rows($rslt);
+ if ($dupscount_to_print > 0)
+ {
+ $rowx=mysqli_fetch_row($rslt);
+ $duplicate_field_count = $rowx[0];
+ }
+ $field_label .= "_DUPLICATE_" . sprintf('%03d', $duplicate_field_count);
+ }
+
+ ### add field function
+ $SQLsuccess = 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,$field_duplicate,$vicidial_list_fields,$mysql_reserved_words);
+
+ if ($SQLsuccess > 0)
+ {echo _QXZ("SUCCESS: Custom Field Added")." - $list_id|$field_label\n
";}
+ }
}
-
- $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
- $SQLsuccess = 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);
-
- if ($SQLsuccess > 0)
- {echo _QXZ("SUCCESS: Custom Field Added")." - $list_id|$field_label\n
";}
}
}
}
@@ -858,11 +905,14 @@ if ( ($action == "MODIFY_CUSTOM_FIELD_SUBMIT") and ($list_id > 99) and ($field_i
{$table_exists = 1;}
if ($DB>0) {echo "$stmt|$tablecount_to_print|$table_exists";}
+ if ($field_duplicate=='Y')
+ {$field_type='TEXT';}
+
if ($field_exists < 1)
{echo ""._QXZ("ERROR: Field does not exist")."\n
";}
else
{
- if ( ($table_exists < 1) and (!preg_match("/\|$field_label\|/i",$vicidial_list_fields)) )
+ if ( ($table_exists < 1) and (!preg_match("/\|$field_label\|/i",$vicidial_list_fields)) and ($field_duplicate=='N') )
{echo ""._QXZ("ERROR: Table does not exist")."\n
";}
else
{
@@ -894,7 +944,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELD_SUBMIT") and ($list_id > 99) and ($field_i
else
{
### modify field function
- $SQLsuccess = 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);
+ $SQLsuccess = 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,$field_duplicate,$vicidial_list_fields);
if ($SQLsuccess > 0)
{echo _QXZ("SUCCESS: Custom Field Modified")." - $list_id|$field_label\n
";}
@@ -960,7 +1010,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) )
echo _QXZ("Records in this custom table").": $custom_records_count
\n";
echo "
| "._QXZ("Field Label")." $A_field_rank[$o]: | $LcolorB$A_field_label[$o]$LcolorE $NWB#lists_fields-field_label$NWE |
| "._QXZ("Field Duplicate")." $A_field_rank[$o]: | $A_field_duplicate[$o] $NWB#lists_fields-field_duplicate$NWE |
| \n"; - echo ""._QXZ("DELETE THIS CUSTOM FIELD").""; + echo ""._QXZ("DELETE THIS CUSTOM FIELD").""; echo " | |