Added only_field option for refresh of already-loaded custom form SOURCESELECT element, cascading SOURCESELECT custom field refreshes.

git-svn-id: svn://192.168.202.10@3419 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2021-04-05 03:29:51 +00:00
parent f985cb2dfb
commit 6de9686467
4 changed files with 330 additions and 44 deletions
+121 -33
View File
@@ -53,6 +53,7 @@
# 210211-1916 - Disable SCRIPT custom fields Math functions on older PHP versions
# 210310-1322 - Added BUTTON field type
# 210401-2132 - Fixed issue #1271, security_phrase field not populating in custom fields form
# 210404-0902 - Added function to refresh a single field
#
# $mysql_queries = 26
@@ -326,7 +327,7 @@ function user_authorization($user,$pass,$user_option,$user_update,$bcrypt,$retur
##### BEGIN custom_list_fields_values - gather values for display of custom list fields for a lead #####
function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_id,$did_id,$did_extension,$did_pattern,$did_description,$dialed_number,$dialed_label)
function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_id,$did_id,$did_extension,$did_pattern,$did_description,$dialed_number,$dialed_label,$only_field,$source_field,$source_field_value)
{
$STARTtime = date("U");
$TODAY = date("Y-m-d");
@@ -345,6 +346,7 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
$custom_required_fields_radio='|';
$custom_required_fields_select='|';
$custom_required_fields_multi='|';
$custom_refresh_fields='|';
require("dbconnect_mysqli.php");
@@ -370,9 +372,14 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
{
$rowx=mysqli_fetch_row($rslt);
$custom_records_count = $rowx[0];
$only_fieldSQL='';
if (strlen($only_field) > 0)
{
$only_fieldSQL = "and field_label='$only_field'";
}
$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,field_duplicate 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' $only_fieldSQL 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);
@@ -509,42 +516,54 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
##### END grab the data from custom table for the lead_id
$CFoutput .= "<input type=hidden name=stage id=stage value=\"SUBMIT\">\n";
$CFoutput .= "<center><TABLE cellspacing=2 cellpadding=2>\n";
if ($fields_to_print < 1)
{$CFoutput .= "<tr bgcolor=white align=center><td colspan=4><font size=1>"._QXZ("There are no custom fields for this list")."</td></tr>";}
if (strlen($only_field) < 1)
{
$CFoutput .= "<input type=hidden name=stage id=stage value=\"SUBMIT\">\n";
$CFoutput .= "<center><TABLE cellspacing=2 cellpadding=2>\n";
if ($fields_to_print < 1)
{$CFoutput .= "<tr bgcolor=white align=center><td colspan=4><font size=1>"._QXZ("There are no custom fields for this list")."</td></tr>";}
}
$o=0;
$last_field_rank=0;
while ($fields_to_print > $o)
{
$helpHTML='';
if (strlen($A_field_help[$o])>0)
if ( (strlen($A_field_help[$o])>0) and (strlen($only_field) < 1) )
{$helpHTML="&nbsp; <a href=\"javascript:open_help('HELP_$A_field_label[$o]','$A_field_help[$o]');\">"._QXZ("help")."+</a>";}
if ($last_field_rank=="$A_field_rank[$o]")
if ( ($last_field_rank=="$A_field_rank[$o]") and (strlen($only_field) < 1) )
{$CFoutput .= " &nbsp; &nbsp; &nbsp; &nbsp; ";}
else
{
$CFoutput .= "</td></tr>\n";
$CFoutput .= "<tr bgcolor=white><td align=";
if ( ($A_name_position[$o]=='TOP') or ($A_field_type[$o]=='SCRIPT') )
{$CFoutput .= "left colspan=2";}
else
{$CFoutput .= "right";}
$CFoutput .= "><font size=2>";
if (strlen($only_field) < 1)
{
$CFoutput .= "</td></tr>\n";
$CFoutput .= "<tr bgcolor=white><td align=";
if ( ($A_name_position[$o]=='TOP') or ($A_field_type[$o]=='SCRIPT') )
{$CFoutput .= "left colspan=2";}
else
{$CFoutput .= "right";}
$CFoutput .= "><font size=2>";
}
}
if ( ($A_field_type[$o]!='SCRIPT') and ($A_field_type[$o]!='HIDDEN') and ($A_field_type[$o]!='HIDEBLOB') )
if ( ($A_field_type[$o]!='SCRIPT') and ($A_field_type[$o]!='HIDDEN') and ($A_field_type[$o]!='HIDEBLOB') and (strlen($only_field) < 1) )
{$CFoutput .= "<B>$A_field_name[$o]</B>";}
if ( ($A_name_position[$o]=='TOP') or ($A_field_type[$o]=='SCRIPT') )
if ( ( ($A_name_position[$o]=='TOP') or ($A_field_type[$o]=='SCRIPT') ) and (strlen($only_field) < 1) )
{$CFoutput .= " &nbsp; <span style=\"position:static;\" id=P_HELP_$A_field_label[$o]></span><span style=\"position:static;background:white;\" id=HELP_$A_field_label[$o]> $helpHTML</span><BR>";}
else
{
if ($last_field_rank=="$A_field_rank[$o]")
{$CFoutput .= " &nbsp;";}
else
{$CFoutput .= "</td><td align=left><font size=2>";}
if (strlen($only_field) < 1)
{
if ($last_field_rank=="$A_field_rank[$o]")
{$CFoutput .= " &nbsp;";}
else
{$CFoutput .= "</td><td align=left><font size=2>";}
}
}
if (strlen($only_field) < 1)
{
$field_HTML="<span id='field_content_$A_field_label[$o]'>";
}
$field_HTML='';
if ( ($A_field_type[$o]=='SELECT') or ($A_field_type[$o]=='SOURCESELECT') )
{
@@ -555,6 +574,10 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
$change_trigger="onchange=\"update_default_vd_select('$A_field_label[$o]');\"";
$default_field_flag++;
}
if (strlen($change_trigger) < 1)
{
$change_trigger="onchange=\"catchall_field_change('$A_field_label[$o]');\"";
}
$field_HTML .= "<select size=1 name=$A_field_label[$o] id=$A_field_label[$o] $change_trigger>\n";
}
if ($A_field_type[$o]=='MULTI')
@@ -576,11 +599,48 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
{
$sourceselect_field = preg_replace("/^source=>/i",'',trim($field_options_array[0]));
$sourceselect_value='';
$sourceselect_type='';
$sourceselect_default=0;
##### grab the source field data from main or custom table for the lead_id
if (preg_match("/\|$sourceselect_field\|/i",$vicidial_list_fields))
{$stmt="SELECT $sourceselect_field FROM vicidial_list where lead_id='$lead_id' LIMIT 1;";}
{
$sourceselect_default=1;
$sourceselect_type='TEXT';
if (preg_match("/^gender$/i",$sourceselect_field)) {$sourceselect_type='SELECT';}
$stmt="SELECT $sourceselect_field FROM vicidial_list where lead_id='$lead_id' LIMIT 1;";
}
else
{$stmt="SELECT $sourceselect_field FROM custom_$list_id where lead_id='$lead_id' LIMIT 1;";}
{
$stmt="SELECT field_type FROM vicidial_lists_fields where list_id='$list_id' and field_label='$sourceselect_field' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'05XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$sourcetype_ct = mysqli_num_rows($rslt);
if ($sourcetype_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$sourceselect_type = $row[0];
}
$stmt="SELECT $sourceselect_field FROM custom_$list_id where lead_id='$lead_id' LIMIT 1;";
}
if ( (strlen($only_field) > 0) and (strlen($source_field_value) > 0) and (preg_match("/^$sourceselect_field$/i",$source_field)) )
{
$sourceselect_value = $source_field_value;
if ($DB) {echo "Using form field value: |$only_field|$source_field_value|$source_field|\n";}
if ($sourceselect_value == '--BLANK--') {$sourceselect_value='';}
}
else
{
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'05XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
$sourceselect_ct = mysqli_num_rows($rslt);
if ($sourceselect_ct > 0)
{
$row=mysqli_fetch_row($rslt);
$sourceselect_value = $row[0];
}
}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'05XXX',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
@@ -590,7 +650,9 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
$row=mysqli_fetch_row($rslt);
$sourceselect_value = $row[0];
}
$custom_refresh_fields .= "$sourceselect_field $sourceselect_type $sourceselect_default $A_field_label[$o] $A_field_type[$o]|";
$temp_sourcematch = "value=>$sourceselect_value";
if ($DB) {echo "Starting SOURCESELECT: |$sourceselect_field|$sourceselect_value|$temp_sourcematch| |$only_field|$source_field_value|$source_field|\n";}
if ($DB) {echo "Starting SOURCESELECT: |$sourceselect_field|$sourceselect_value|$temp_sourcematch|\n";}
$temp_matchfound=0; $NFA=0;
while ( ($te < $field_options_count) and ($temp_matchfound < 2) )
@@ -745,7 +807,11 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
$change_trigger="onchange=\"update_default_vd_field('$A_field_label[$o]');\"";
$default_field_flag++;
}
if (strlen($change_trigger) < 1)
{
$change_trigger="onchange=\"catchall_field_change('$A_field_label[$o]');\"";
}
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='';
@@ -800,6 +866,10 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
$change_trigger="onchange=\"update_default_vd_field('$A_field_label[$o]');\"";
$default_field_flag++;
}
if (strlen($change_trigger) < 1)
{
$change_trigger="onchange=\"catchall_field_change('$A_field_label[$o]');\"";
}
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 .= "<textarea name=$A_field_label[$o] id=$A_field_label[$o] ROWS=$A_field_max[$o] COLS=$A_field_size[$o] $change_trigger>$A_field_value[$o]</textarea>";
@@ -916,7 +986,12 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
$field_HTML .= "</SELECT>";
}
if ( ($A_name_position[$o]=='LEFT') and ($A_field_type[$o]!='SCRIPT') and ($A_field_type[$o]!='HIDDEN') and ($A_field_type[$o]!='HIDEBLOB') )
if (strlen($only_field) < 1)
{
$field_HTML .= "</span>";
}
if ( ($A_name_position[$o]=='LEFT') and ($A_field_type[$o]!='SCRIPT') and ($A_field_type[$o]!='HIDDEN') and ($A_field_type[$o]!='HIDEBLOB') and (strlen($only_field) < 1) )
{
$CFoutput .= " $field_HTML <span style=\"position:static;\" id=P_HELP_$A_field_label[$o]></span><span style=\"position:static;background:white;\" id=HELP_$A_field_label[$o]> $helpHTML</span>";
}
@@ -928,7 +1003,17 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
$last_field_rank=$A_field_rank[$o];
$o++;
}
$CFoutput .= "</td></tr></table>\n";
$CFoutput_prefix='';
if (strlen($only_field) < 1)
{
$CFoutput .= "</td></tr></table>\n";
$CFoutput_prefix .= " <script language=\"Javascript\">\n";
$CFoutput_prefix .= " var custom_refresh_fields = '$custom_refresh_fields';\n";
$CFoutput_prefix .= " </script>\n";
}
$CFoutput = "$CFoutput_prefix$CFoutput";
}
else
{$CFoutput .= _QXZ("ERROR: no custom list fields")."\n";}
@@ -1423,11 +1508,14 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i
if ($DB > 0) {echo "$CFoutput<BR>\n";}
}
##### END parsing for vicidial variables #####
echo "<input type=hidden name=custom_required id=custom_required value=\"$custom_required_fields\">\n";
echo "<input type=hidden name=custom_required_check id=custom_required_check value=\"$custom_required_fields_check\">\n";
echo "<input type=hidden name=custom_required_radio id=custom_required_radio value=\"$custom_required_fields_radio\">\n";
echo "<input type=hidden name=custom_required_select id=custom_required_select value=\"$custom_required_fields_select\">\n";
echo "<input type=hidden name=custom_required_multi id=custom_required_multi value=\"$custom_required_fields_multi\">\n";
if (strlen($only_field) < 1)
{
echo "<input type=hidden name=custom_required id=custom_required value=\"$custom_required_fields\">\n";
echo "<input type=hidden name=custom_required_check id=custom_required_check value=\"$custom_required_fields_check\">\n";
echo "<input type=hidden name=custom_required_radio id=custom_required_radio value=\"$custom_required_fields_radio\">\n";
echo "<input type=hidden name=custom_required_select id=custom_required_select value=\"$custom_required_fields_select\">\n";
echo "<input type=hidden name=custom_required_multi id=custom_required_multi value=\"$custom_required_fields_multi\">\n";
}
return $CFoutput;
}
+5 -5
View File
@@ -1943,7 +1943,7 @@ if ($ACTION == 'UpdateFields')
$custom_field_values='q--------q';
$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','SWITCH') 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_%\";";
$stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY','SWITCH','BUTTON') 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,'00720',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
@@ -5426,7 +5426,7 @@ if ($ACTION == 'manDiaLnextCaLL')
$custom_field_values='q--------q';
$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','SWITCH') 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_%\";";
$stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY','SWITCH','BUTTON') 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";}
@@ -9762,7 +9762,7 @@ if ($ACTION == 'VDADcheckINCOMING')
$custom_field_values='q--------q';
$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','SWITCH') 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_%\";";
$stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY','SWITCH','BUTTON') 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,'00339',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
@@ -11098,7 +11098,7 @@ if ($ACTION == 'VDADcheckINCOMINGother')
$custom_field_values='q--------q';
$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','SWITCH') 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_%\";";
$stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY','SWITCH','BUTTON') 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,'00512',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
@@ -12220,7 +12220,7 @@ if ($ACTION == 'LeaDSearcHSelecTUpdatE')
$custom_field_values='q--------q';
$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','SWITCH') 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_%\";";
$stmt = "SELECT field_label,field_type FROM vicidial_lists_fields where list_id='$entry_list_id' and field_type NOT IN('SCRIPT','DISPLAY','SWITCH','BUTTON') 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,'00479',$user,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
+201 -3
View File
@@ -50,10 +50,11 @@
# 210310-1115 - Added BUTTON field type with SubmitRefresh function
# 210315-1747 - Added campaign setting for clear_form
# 210329-2025 - Fixed for consistent custom fields values filtering
# 210404-1522 - Added only_field option for refresh of already-loaded custom form SOURCESELECT element
#
$version = '2.14-40';
$build = '210329-2025';
$version = '2.14-41';
$build = '210404-1522';
$php_script = 'vdc_form_display.php';
require_once("dbconnect_mysqli.php");
@@ -208,6 +209,12 @@ if (isset($_GET["hide_gender"])) {$hide_gender=$_GET["hide_gender"];}
elseif (isset($_POST["hide_gender"])) {$hide_gender=$_POST["hide_gender"];}
if (isset($_GET["button_action"])) {$button_action=$_GET["button_action"];}
elseif (isset($_POST["button_action"])) {$button_action=$_POST["button_action"];}
if (isset($_GET["only_field"])) {$only_field=$_GET["only_field"];}
elseif (isset($_POST["only_field"])) {$only_field=$_POST["only_field"];}
if (isset($_GET["source_field"])) {$source_field=$_GET["source_field"];}
elseif (isset($_POST["source_field"])) {$source_field=$_POST["source_field"];}
if (isset($_GET["source_field_value"])) {$source_field_value=$_GET["source_field_value"];}
elseif (isset($_POST["source_field_value"])) {$source_field_value=$_POST["source_field_value"];}
if (isset($_GET["orig_URL"])) {$orig_URL=$_GET["orig_URL"];}
elseif (isset($_POST["orig_URL"])) {$orig_URL=$_POST["orig_URL"];}
if (isset($_GET["DB"])) {$DB=$_GET["DB"];}
@@ -312,6 +319,9 @@ $server_ip = preg_replace("/\'|\"|\\\\|;/","",$server_ip);
$session_id = preg_replace('/[^0-9]/','',$session_id);
$call_id = preg_replace('/[^-_\.0-9a-zA-Z]/','',$call_id);
$button_action = preg_replace('/[^-_0-9a-zA-Z]/','',$button_action);
$only_field = preg_replace('/[^-_0-9a-zA-Z]/','',$only_field);
$source_field = preg_replace('/[^-_0-9a-zA-Z]/','',$source_field);
$source_field_value = preg_replace("/\'|\"|\\\\|;/",'',$source_field_value);
if ($non_latin < 1)
{
@@ -383,6 +393,25 @@ else
# do nothing for now
}
### BEGIN refresh single field ###
if ( ($stage=='REFRESH_SINGLE_FIELD') and (strlen($only_field) > 0) )
{
require_once("functions.php");
$CFoutput = custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_id,$did_id,$did_extension,$did_pattern,$did_description,$dialed_number,$dialed_label,$only_field,$source_field,$source_field_value);
echo "$CFoutput";
if ($SSagent_debug_logging > 0)
{
$stage .= " $only_field";
vicidial_ajax_log($NOW_TIME,$startMS,$link,$ACTION,$php_script,$user,$stage,$lead_id,$session_name,$stmt);
}
exit;
}
### END refresh single field ###
### BEGIN parse submission of the custom fields form ###
if ($stage=='SUBMIT')
@@ -658,6 +687,8 @@ if ($SUBMIT_only < 1)
echo " <link rel=\"stylesheet\" href=\"./css/vicidial_stylesheet.css\">\n";
echo " <script language=\"Javascript\">\n";
echo " var orig_URL = '$vdcURL';\n";
echo " var ajax_timeout=0;\n";
echo " var debug_append='';\n";
echo " function open_help(taskspan,taskhelp) \n";
echo " {\n";
echo " document.getElementById(\"P_\" + taskspan).innerHTML = \" &nbsp; <a href=\\\"javascript:close_help('\" + taskspan + \"','\" + taskhelp + \"');\\\">help-</a><BR> &nbsp; \";\n";
@@ -674,6 +705,12 @@ if ($SUBMIT_only < 1)
echo " {\n";
echo " var tempvalue = document.getElementById(taskfield).value;\n";
echo " parent.document.getElementById(taskfield).value = tempvalue;\n";
# echo " alert('chech refresh:'+ taskfield + ' ' + custom_refresh_fields);\n";
echo " var REFRESHfieldREG = new RegExp('|' + taskfield + ' ',\"g\");\n";
echo " if (custom_refresh_fields.match(REFRESHfieldREG))\n";
echo " {\n";
echo " field_refresh(taskfield);\n";
echo " }\n";
echo " }\n";
if ($hide_gender > 0)
{
@@ -682,6 +719,11 @@ if ($SUBMIT_only < 1)
echo " var taskIndex = document.getElementById(taskfield).selectedIndex;\n";
echo " var taskValue = document.getElementById(taskfield).options[taskIndex].value;\n";
echo " parent.document.getElementById(taskfield).value = taskValue;\n";
echo " var REFRESHfieldREG = new RegExp('|' + taskfield + ' ',\"g\");\n";
echo " if (custom_refresh_fields.match(REFRESHfieldREG))\n";
echo " {\n";
echo " field_refresh(taskfield);\n";
echo " }\n";
echo " }\n";
}
else
@@ -698,6 +740,11 @@ if ($SUBMIT_only < 1)
echo " var genderIndex = parent.document.getElementById('gender_list').selectedIndex;\n";
echo " var genderValue = parent.document.getElementById('gender_list').options[genderIndex].value;\n";
echo " parent.document.getElementById('gender').value = genderValue;\n";
echo " var REFRESHfieldREG = new RegExp('|' + taskfield + ' ',\"g\");\n";
echo " if (custom_refresh_fields.match(REFRESHfieldREG))\n";
echo " {\n";
echo " field_refresh(taskfield);\n";
echo " }\n";
echo " }\n";
}
echo " function update_dup_field(taskmasterfield,taskupdatefields,taskupdatecount,taskdefaultflag,taskdefaultfield) \n";
@@ -714,6 +761,11 @@ if ($SUBMIT_only < 1)
echo " }\n";
echo " if (taskdefaultflag=='1')\n";
echo " {parent.document.getElementById(taskdefaultfield).value = tempmastervalue;}\n";
echo " var REFRESHfieldREG = new RegExp('|' + taskmasterfield + ' ',\"g\");\n";
echo " if (custom_refresh_fields.match(REFRESHfieldREG))\n";
echo " {\n";
echo " field_refresh(taskmasterfield);\n";
echo " }\n";
echo " }\n";
echo " function switch_list(temp_new_list_id)\n";
echo " {\n";
@@ -733,6 +785,150 @@ if ($SUBMIT_only < 1)
echo " document.form_custom_fields.submit();\n";
echo " }\n";
echo " }\n";
echo " function catchall_field_change(taskfield) \n";
echo " {\n";
# echo " alert('chech refresh:'+ taskfield + ' ' + custom_refresh_fields);\n";
echo " var REFRESHfieldREG = new RegExp('|' + taskfield + ' ',\"g\");\n";
echo " if (custom_refresh_fields.match(REFRESHfieldREG))\n";
echo " {\n";
echo " field_refresh(taskfield);\n";
echo " }\n";
echo " }\n";
$only_field_query = "DB=$DB&SIPexten=$SIPexten&SQLdate=$SQLdate&admin_submit=$admin_submit&agent_email=$agent_email&agent_log_id=$agent_log_id&bcrypt=$bcrypt&bgcolor=$bgcolor&button_action=$button_action&call_id=$call_id&called_count=$called_count&camp_script=$camp_script&campaign=$campaign&channel_group=$channel_group&closecallid=$closecallid&closer=$closer&customer_server_ip=$customer_server_ip&customer_zap_channel=$customer_zap_channel&dialed_label=$dialed_label&dialed_number=$dialed_number&did_custom_five=$did_custom_five&did_custom_four=$did_custom_four&did_custom_one=$did_custom_one&did_custom_three=$did_custom_three&did_custom_two=$did_custom_two&did_description=$did_description&did_extension=$did_extension&did_id=$did_id&did_pattern=$did_pattern&epoch=$epoch&fronter=$fronter&fullname=$fullname&group=$group&hide_gender=$hide_gender&in_script=$in_script&lead_id=$lead_id&list_description=$list_description&list_id=$list_id&list_name=$list_name&new_list_id=$new_list_id&original_phone_login=$original_phone_login&parked_by=$parked_by&pass=$pass&phone=$phone&phone_login=$phone_login&phone_pass=$phone_pass&preset_dtmf_a=$preset_dtmf_a&preset_dtmf_b=$preset_dtmf_b&preset_number_a=$preset_number_a&preset_number_b=$preset_number_b&preset_number_c=$preset_number_c&preset_number_d=$preset_number_d&preset_number_e=$preset_number_e&preset_number_f=$preset_number_f&recording_filename=$recording_filename&recording_id=$recording_id&script_height=$script_height&script_width=$script_width&server_ip=$server_ip&server_ip=$server_ip&session_id=$session_id&session_id=$session_id&submit_button=$submit_button&uniqueid=$uniqueid&user=$user&user_custom_five=$user_custom_five&user_custom_four=$user_custom_four&user_custom_one=$user_custom_one&user_custom_three=$user_custom_three&user_custom_two=$user_custom_two&user_group=$user_group&xfercallid=$xfercallid&web_vars=$web_vars&orig_URL=$orig_URL";
?>
// ################################################################################
// Trigger a refresh of a single custom field
function field_refresh(temp_field)
{
if (temp_field.length > 0)
{
var source_field=temp_field;
var source_field_value='';
var only_field='';
//alert('Starting field refresh: '+ temp_field + ' ' + custom_refresh_fields);
//$custom_refresh_fields .= "$sourceselect_field $sourceselect_type $sourceselect_default $A_field_label[$o] $A_field_type[$o]|";
var REFRESHfieldREG = new RegExp('|' + temp_field + ' ',"g");
if (custom_refresh_fields.match(REFRESHfieldREG))
{
var CRF_array=custom_refresh_fields.split("|");
var CRF_count=CRF_array.length;
var CRF_tick=0;
while (CRF_tick < CRF_count)
{
var temp_CRF_value='';
var CRF_field = CRF_array[CRF_tick];
if (CRF_field.length > 0)
{
var temp_CRF_field=CRF_field.split(' ');
if (temp_CRF_field[0] == temp_field)
{
if (temp_CRF_field[2] == '1')
{
// it is a default field, check type and grab value
if (temp_CRF_field[1] == 'TEXT')
{
temp_CRF_value = parent.document.getElementById(temp_field).value;
if (temp_CRF_value == '') {temp_CRF_value='--BLANK--';}
}
if (temp_CRF_field[1] == 'SELECT')
{
var taskIndex = parent.document.getElementById('gender_list').selectedIndex;
temp_CRF_value = parent.document.getElementById('gender_list').options[taskIndex].value;
if (temp_CRF_value == '') {temp_CRF_value='--BLANK--';}
}
}
else
{
// it is a custom field, check type and grab value
if (temp_CRF_field[1] == 'TEXT')
{
temp_CRF_value = document.getElementById(temp_field).value;
if (temp_CRF_value == '') {temp_CRF_value='--BLANK--';}
}
if ( (temp_CRF_field[1] == 'SELECT') || (temp_CRF_field[1] == 'SOURCESELECT') )
{
var taskIndex = document.getElementById(temp_field).selectedIndex;
temp_CRF_value = document.getElementById(temp_field).options[taskIndex].value;
if (temp_CRF_value == '') {temp_CRF_value='--BLANK--';}
}
}
// update the target field now that we know the source field, type and value it is linked to
if (temp_CRF_value != '')
{
var temp_ajax_timeout = (ajax_timeout + 10);
setTimeout(field_refresh_ajax, temp_ajax_timeout, temp_CRF_field[3],temp_CRF_field[0],temp_CRF_value,temp_ajax_timeout);
ajax_timeout = (ajax_timeout + 100);
}
}
}
CRF_tick++;
}
ajax_timeout=0;
}
}
}
// ################################################################################
// Trigger a refresh of a single custom field
function field_refresh_ajax(temp_field,temp_source,temp_source_value,task_timeout)
{
var field_content_span = 'field_content_' + temp_field;
var loading_select = '<select size=1 name=' + temp_field + ' id=' + temp_field + "><option value='' SELECTED><?php echo _QXZ("Refreshing..."); ?></option></select>\n";
//alert('field refresh: '+ field_content_span + ' ' + temp_source + ' ' + temp_source_value);
document.getElementById(field_content_span).innerHTML = loading_select;
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp)
{
LSview_query = "only_field=" + temp_field + "&source_field=" + temp_source + "&source_field_value=" + temp_source_value + "&stage=REFRESH_SINGLE_FIELD&<?php echo $only_field_query ?>";
//document.getElementById("debugbottomspan2").innerHTML = LSview_query;
xmlhttp.open('POST', 'vdc_form_display_encrypt.php');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(LSview_query);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
//alert(xmlhttp.responseText);
document.getElementById(field_content_span).innerHTML = xmlhttp.responseText + "\n";
var REFRESHfieldREG = new RegExp('|' + temp_field + ' ',"g");
if (custom_refresh_fields.match(REFRESHfieldREG))
{
//debug_append = debug_append + "\n" + temp_field + ' timeout: ' + task_timeout;
document.getElementById("debugbottomspan2").insertAdjacentHTML('beforeend',debug_append);
setTimeout(field_refresh, 100, temp_field);
}
}
}
delete xmlhttp;
}
}
<?php
echo " function nothing()\n";
echo " {}\n";
echo " </script>\n";
@@ -759,10 +955,11 @@ if ($SUBMIT_only < 1)
echo "<input type=hidden name=submit_button id=submit_button value=\"READONLY\">\n";
}
$only_field='';
require_once("functions.php");
$CFoutput = custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_id,$did_id,$did_extension,$did_pattern,$did_description,$dialed_number,$dialed_label);
$CFoutput = custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_id,$did_id,$did_extension,$did_pattern,$did_description,$dialed_number,$dialed_label,$only_field,$source_field,$source_field_value);
echo "$CFoutput";
@@ -774,6 +971,7 @@ if ($SUBMIT_only < 1)
echo "<BR><BR><input type=submit name=VCformSubmit id=VCformSubmit value=submit>\n";
}
echo "</form></center><BR><BR>\n";
echo "<br><span id=debugbottomspan2></span>\n";
echo "</BODY></HTML>\n";
}
+3 -3
View File
@@ -1,4 +1,4 @@
# version: 20210327210801
# version: 20210404162701
users-user User ID <QXZ>This field is where you put the users ID number, can be up to 8 digits in length, Must be at least 2 characters in length.</QXZ>
users-pass Password <QXZ>This field is where you put the users password. Must be at least 2 characters in length. Only letters and numbers are allowed in user passwords. A medium strength user password will be at least 10 characters in length, and a strong user password will be at least 20 characters in length and have letters as well as at least one number. It is recommended that you use a longer password if possible, stringing together several unrelated words with no spaces, and a number somewhere in the string. The maximum size of a password is 100 characters.</QXZ>
users-force_change_password Force Change Password <QXZ>If this option is set to Y then the user will be prompted to change their password the next time they log in to the administration webpage or the agent screen. Default is N.</QXZ>
@@ -451,8 +451,8 @@ lists_fields-field_rank Field Rank <QXZ>The order in which these fields is displ
lists_fields-field_order Field Order <QXZ>If more than one field has the same rank, they will be placed on the same line and they will be placed in order by this value from lowest to highest, left to right.</QXZ>
lists_fields-field_rerank Re-Rank Fields Below <QXZ>If set to YES, this option will move existing other fields of an equal or lower rank down on the form by one place. Default is NO.</QXZ>
lists_fields-field_help Field Help <QXZ>Optional field, if you fill it in, the agent will be able to see this text when they click on a help link next to the field in their agent interface.</QXZ>
lists_fields-field_type Field Type <QXZ>This option defines the type of field that will be displayed. TEXT is a standard single-line entry form, AREA is a multi-line text box, SELECT is a single-selection pull-down menu, MULTI is a multiple-select box, RADIO is a list of radio buttons where only one option can be selected, CHECKBOX is a list of checkboxes where multiple options can be selected, DATE is a year month day calendar popup where the agent can select the date and TIME is a time selection box. The default is TEXT. For the SELECT, MULTI, RADIO and CHECKBOX options you must define the option values below in the Field Options box. DISPLAY will display only and not allow for modification by the agent. SCRIPT will also display only, but you are able to use script variables just like in the Scripts feature. SCRIPT fields will also only display the content in the Options, and not the field name like the DISPLAY type does. HIDDEN will not show the agent the field, but will allow the field to have data imported into it and exported from it, as well as have it available to the script tab and web form address. READONLY will display the value of the data in the field, but will not allow the agent to alter the data. HIDEBLOB is similar to HIDDEN except the data storage type on the database is a BLOB type, suitable for binary data or data that needs to be secured. The SWITCH field type allows the agent to switch the lead custom fields to another list, as well as reloading the FORM tab with the new set of list custom fields for the new list. To configure SWITCH type fields, you must define the button values below in the Field Options box. SOURCESELECT is a single-selection pull-down menu where there are multiple sets of options available depending on the value of another field for the lead, see the Field Options help for more details. BUTTON will allow you to commit changes made to the form and reload it, the Field Name will be the text next to the button, the Field Default will be the text on the button, and the Field Options will need to be SubmitRefresh with the Field Size set to 1 for it to function.</QXZ>
lists_fields-field_options Field Options <QXZ>For the SELECT, MULTI, RADIO and CHECKBOX field types, you must define the option values in this box. You must put a list of comma separated option label and option text here with each option one its own line. The first value should have no spaces in it, and neither values should have any punctuation. For example - electric_meter, Electric Meter</QXZ>. <QXZ>For the SCRIPT field types, this field is where you put your script contents. You can use single quote and amphersand characters as well so that you can create links and iframe elements. If you want to put urlencoded fields in this area, make sure you use the --U-- and --V-- flags for your variables instead of using A and B, for example --U--test_field--V--. You can also use the --M-- and --N-- flags to enclose basic Math equations to have them calculated when the script is loaded initially, for example multiplying test_field by 12 would be entered with --M--(--A--test_field--B-- * 12)--N--. For the SWITCH field type, you should define the list ID for the custom fields as well as the text that you want to appear in the button to activate the new form in a comma separated line, with one line for each button you want to appear. For the SWITCH field type, it is a requirement that one of the entries be the current list ID. For BUTTON, the only current option is to put SubmitRefresh as the Field Options, which will commit any changes you have made in the form and reload the form panel. For SOURCESELECT, if this field is set to use the -province- field to determine what values to use, then the first line in the Field Options box should be -source=>province-, without the dashes. The next options line will be the first province value to look for, for example -value=>Ontario-, and if the value for that field for the lead matches, the next lines will be the options to show with the value and display text separated by a pipe. After that, you can add more values each with options after them, like this example below shows: <br>source=>province<br>value=>Ontario<br>option=>|select month here<br>option=>September|September<br>option=>October|October<br>value=>Nova Scotia<br>option=>|select month here<br>option=>June|June<br>option=>July|July<br>option=>August|August<br>value=>British Columbia<br>option=>|select month here<br>option=>January|January<br>option=>February|February<br>option=>March|March<br>value=><br>option=>|no match</QXZ>
lists_fields-field_type Field Type <QXZ>This option defines the type of field that will be displayed. TEXT is a standard single-line entry form, AREA is a multi-line text box, SELECT is a single-selection pull-down menu, MULTI is a multiple-select box, RADIO is a list of radio buttons where only one option can be selected, CHECKBOX is a list of checkboxes where multiple options can be selected, DATE is a year month day calendar popup where the agent can select the date and TIME is a time selection box. The default is TEXT. For the SELECT, MULTI, RADIO and CHECKBOX options you must define the option values below in the Field Options box. DISPLAY will display only and not allow for modification by the agent. SCRIPT will also display only, but you are able to use script variables just like in the Scripts feature. SCRIPT fields will also only display the content in the Options, and not the field name like the DISPLAY type does. HIDDEN will not show the agent the field, but will allow the field to have data imported into it and exported from it, as well as have it available to the script tab and web form address. READONLY will display the value of the data in the field, but will not allow the agent to alter the data. HIDEBLOB is similar to HIDDEN except the data storage type on the database is a BLOB type, suitable for binary data or data that needs to be secured. The SWITCH field type allows the agent to switch the lead custom fields to another list, as well as reloading the FORM tab with the new set of list custom fields for the new list. To configure SWITCH type fields, you must define the button values below in the Field Options box. SOURCESELECT is a single-selection pull-down menu where there are multiple sets of options available depending on the value of another -source- field for the lead, see the Field Options help for more details. If the -source- field that a SOURCESELECT menu is tied to changes in value, the menu will automatically update to reflect the new value of the source. BUTTON will allow you to commit changes made to the form and reload it, the Field Name will be the text next to the button, the Field Default will be the text on the button, and the Field Options will need to be SubmitRefresh with the Field Size set to 1 for it to function.</QXZ>
lists_fields-field_options Field Options <QXZ>For the SELECT, SOURCESELECT, MULTI, RADIO and CHECKBOX field types, you must define the option values in this box. You must put a list of comma separated option label and option text here with each option one its own line. The first value should have no spaces in it, and neither values should have any punctuation. For example - electric_meter, Electric Meter</QXZ>. <QXZ>For the SCRIPT field types, this field is where you put your script contents. You can use single quote and amphersand characters as well so that you can create links and iframe elements. If you want to put urlencoded fields in this area, make sure you use the --U-- and --V-- flags for your variables instead of using A and B, for example --U--test_field--V--. You can also use the --M-- and --N-- flags to enclose basic Math equations to have them calculated when the script is loaded initially, for example multiplying test_field by 12 would be entered with --M--(--A--test_field--B-- * 12)--N--. For the SWITCH field type, you should define the list ID for the custom fields as well as the text that you want to appear in the button to activate the new form in a comma separated line, with one line for each button you want to appear. For the SWITCH field type, it is a requirement that one of the entries be the current list ID. For BUTTON, the only current option is to put SubmitRefresh as the Field Options, which will commit any changes you have made in the form and reload the form panel. For SOURCESELECT, if this field is set to use the -province- field to determine what values to use for example, then the first line in the Field Options box should be -source=>province-, without the dashes. As a note, you can only link a SOURCESELECT menu to a source field that is a TEXT, READONLY or SELECT field type. The next options line will be the first province value to look for, for example -value=>Ontario-, and if the value for that field for the lead matches, the next lines will be the options to show with the value and display text separated by a pipe. After that, you can add more values each with options after them, like the example below shows: <br>source=>province<br>value=>Ontario<br>option=>|select month here<br>option=>September|September<br>option=>October|October<br>value=>Nova Scotia<br>option=>|select month here<br>option=>June|June<br>option=>July|July<br>option=>August|August<br>value=>British Columbia<br>option=>|select month here<br>option=>January|January<br>option=>February|February<br>option=>March|March<br>value=><br>option=>|no match<br>This field is limited to 5000 characters in length, but you can double that by altering the database if you need to.</QXZ>
lists_fields-multi_position Option Position <QXZ>For CHECKBOX and RADIO field types only, if set to HORIZONTAL the options will appear on the same line possibly wrapping to the line below if there are many options. If set to VERTICAL there will be only one option per line. Default is HORIZONTAL.</QXZ>
lists_fields-field_size Field Size <QXZ>This setting will mean different things depending on what the field type is. For TEXT fields, the size is the number of characters that will show in the field. For AREA fields, the size is the width of the text box in characters. For MULTI fields, this setting defines the number of options to be shown in the multi select list. For SELECT, RADIO, CHECKBOX, DATE and TIME this setting is ignored. For BUTTON fields this must be set to 1.</QXZ>
lists_fields-field_max Field Max <QXZ>This setting will mean different things depending on what the field type is. For TEXT, HIDDEN and READONLY fields, the size is the maximum number of characters that are allowed in the field. For AREA fields, this field defines the number of rows of text visible in the text box. For MULTI, SELECT, RADIO, CHECKBOX, DATE and TIME this setting is ignored.</QXZ>