diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index e0097a8f..38491924 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -566,6 +566,14 @@ OTHER CHANGES: 161. Added 'add_did' function to the Non-Agent API. +162. Added new SOURCESELECT Custom Field Type, it 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. Also added the ability to + perform basic Math functions within a SCRIPT Custom Field using values + from other fields in the equations. For more information on how both of + these new features work, see the Field Options help in the admin web + 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 105ed21e..2b60c3f3 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -2811,7 +2811,7 @@ field_name VARCHAR(5000), field_description VARCHAR(100), field_rank SMALLINT(5), field_help VARCHAR(1000), -field_type ENUM('TEXT','AREA','SELECT','MULTI','RADIO','CHECKBOX','DATE','TIME','DISPLAY','SCRIPT','HIDDEN','READONLY','HIDEBLOB','SWITCH') default 'TEXT', +field_type ENUM('TEXT','AREA','SELECT','MULTI','RADIO','CHECKBOX','DATE','TIME','DISPLAY','SCRIPT','HIDDEN','READONLY','HIDEBLOB','SWITCH','SOURCESELECT') default 'TEXT', field_options VARCHAR(5000), field_size SMALLINT(5), field_max SMALLINT(5), @@ -4744,4 +4744,4 @@ INSERT INTO vicidial_settings_containers VALUES ('INTERNATIONAL_DNC_IMPORT','Pro UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1616',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1617',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 32e8bfb4..bf9f33e7 100644 --- a/agc_2-X/trunk/extras/upgrade_2.14.sql +++ b/agc_2-X/trunk/extras/upgrade_2.14.sql @@ -624,7 +624,7 @@ ALTER TABLE vicidial_inbound_groups ADD park_file_name VARCHAR(100) default ''; UPDATE system_settings SET db_schema_version='1543',db_schema_update_date=NOW() where db_schema_version < 1543; -ALTER TABLE vicidial_lists_fields MODIFY field_type ENUM('TEXT','AREA','SELECT','MULTI','RADIO','CHECKBOX','DATE','TIME','DISPLAY','SCRIPT','HIDDEN','READONLY','HIDEBLOB','SWITCH') default 'TEXT'; +ALTER TABLE vicidial_lists_fields MODIFY field_type ENUM('TEXT','AREA','SELECT','MULTI','RADIO','CHECKBOX','DATE','TIME','DISPLAY','SCRIPT','HIDDEN','READONLY','HIDEBLOB','SWITCH','SOURCESELECT') default 'TEXT'; UPDATE system_settings SET db_schema_version='1544',db_schema_update_date=NOW() where db_schema_version < 1544; @@ -1430,3 +1430,7 @@ index (drop_time) ) ENGINE=MyISAM; UPDATE system_settings SET db_schema_version='1616',db_schema_update_date=NOW() where db_schema_version < 1616; + +ALTER TABLE vicidial_lists_fields MODIFY field_type ENUM('TEXT','AREA','SELECT','MULTI','RADIO','CHECKBOX','DATE','TIME','DISPLAY','SCRIPT','HIDDEN','READONLY','HIDEBLOB','SWITCH','SOURCESELECT') default 'TEXT'; + +UPDATE system_settings SET db_schema_version='1617',db_schema_update_date=NOW() where db_schema_version < 1617; diff --git a/agc_2-X/trunk/www/agc/Evaluator.php b/agc_2-X/trunk/www/agc/Evaluator.php new file mode 100644 index 00000000..bb50db90 --- /dev/null +++ b/agc_2-X/trunk/www/agc/Evaluator.php @@ -0,0 +1,240 @@ +pos; + $ist = ($this->text[$this->pos] ?? false) == '"'; + if ($ist) { + $this->pos++; + if (($ist = strpos($this->text, '"', $this->pos)) === false) return false; + $kind = 4; + $value = substr($this->text, $this->pos, $ist - $this->pos); + $this->pos = $ist + 1; + return true; + } + while ((($char = $this->text[$this->pos] ?? false) !== false) && (ctype_alnum($char) || in_array($char, ['.', '_']))) + $this->pos++; + if (!$len = $this->pos - $ops) return false; + $str = substr($this->text, $ops, $len); + if (is_numeric($str)) $kind = 1; + else { + if (ctype_digit($str[0]) || (strpos($str, '.') !== false)) return false; + $kind = $char == '(' ? 3 : 2; + } + $value = $str; + return true; +} + +private function getVariable(string $name) { + $value = $this->variables[$name] ?? null; + if (!isset($value) && isset($this->onVariable)) { + call_user_func_array($this->onVariable, [$name, &$value]); + $this->variables[$name] = $value; + } + if (!isset($value)) {return "Math Error: Unknown variable";} + // throw new Exception('Unknown variable: '.$name, 5); + return $value; +} + +private function addArgument(&$arguments, $argument) { + if ($argument == '') {return "Math Error: Empty argument";} + // throw new Exception('Empty argument', 4); + $arguments[] = $argument; +} + +private function getArguments(&$arguments = []): bool { + $b = 1; + $this->pos++; + $mark = $this->pos; + while ((($char = $this->text[$this->pos] ?? false) !== false) && ($b > 0)) { + if (($char == ',') && ($b == 1)) { + $this->addArgument($arguments, substr($this->text, $mark, $this->pos - $mark)); + $mark = $this->pos + 1; + } + elseif ($char == ')') $b--; + elseif ($char == '(') $b++; + $this->pos++; + } + if (!in_array($char, [false, '+', '-', '/', '*', '^', '%', ')'])) + return false; + $this->addArgument($arguments, substr($this->text, $mark, $this->pos - $mark - 1)); + return true; +} + +private function proArguments($arguments) { + $ops = $this->pos; + $otx = $this->text; + $result = []; + foreach ($arguments as $argument) + $result[] = $this->perform($argument); + $this->pos = $ops; + $this->text = $otx; + return $result; +} + +private function getFunction(string $name) { + $routine = $this->functions[$name] ?? null; + if (!isset($routine) && isset($this->onFunction)) { + call_user_func_array($this->onFunction, [$name, &$routine]); + $this->functions[$name] = $routine; + } + if (!isset($routine)) {return "Math Error: Unknown function";} + // throw new Exception('Unknown function: '.$name, 6); + if (!$this->getArguments($arguments)) {return "Math Error: Syntax error";} + // throw new Exception('Syntax error', 1); + if (isset($routine['arc']) && ($routine['arc'] != count($arguments))) {return "Math Error: Invalid argument count";} + // throw new Exception('Invalid argument count', 3); + return call_user_func_array($routine['ref'], $this->proArguments($arguments)); +} + +private function isNumer($value): bool { + return is_float($value) || is_integer($value); +} + +private function checkNumers($a, $b) { + if ($this->isNumer($a) && $this->isNumer($b)) return; + {return "Math Error: Non-numeric value";} +// throw new Exception('Non-numeric value', 8); +} + +private function checkString($a) { + if (is_string($a)) return; + {return "Math Error: Non-string value";} +// throw new Exception('Non-string value', 9); +} + +private function term() { + $minus = false; + while ((($char = $this->text[$this->pos] ?? false) !== false) && in_array($char, ['-', '+'])) { + $negat = $char == '-'; + $minus = $minus ? ($negat ? false : true) : $negat; + $this->pos++; + } + if ($this->text[$this->pos] == '(') { + $this->pos++; + $value = $this->calculate(); + $this->pos++; + if (!in_array($this->text[$this->pos] ?? false, [false, '+', '-', '/', '*', '^', '%', ')'])) {return "Math Error: Syntax error";} + // throw new Exception('Syntax error', 1); + return $minus ? - $value : $value; + } + if (!$this->getIdentity($kind, $name)) {return "Math Error: Syntax error";} + // throw new Exception('Syntax error', 1); + switch ($kind) { + case 1: $value = (float) $name; break; + case 2: $value = $this->getVariable($name); break; + case 3: $value = $this->getFunction($name); break; + case 4: $value = $name; break; + } + return $minus ? - $value : $value;; +} + +private function subTerm() { + $value = $this->term(); + while (in_array($char = $this->text[$this->pos] ?? false, ['*', '/', '^', '%'])) { + $this->pos++; + $term = $this->term(); + $this->checkNumers($value, $term); + switch ($char) { + case '*': + if ( (!is_numeric($value)) or (strlen($value) < 1) or (!is_numeric($term)) or (strlen($term) < 1) ) {return "Math Error: Empty variable";} + // throw new Exception('Empty variable', 7); + $value *= $term; + break; + case '/': + if ($term == 0) {return "Math Error: Division by zero";} + // throw new Exception('Division by zero', 7); + $value /= $term; + break; + case '^': + $value **= $term; + break; + case '%': + $value %= $term; + break; + } + } + return $value; +} + +private function calculate() { + $value = $this->subTerm(); + while (in_array($char = $this->text[$this->pos] ?? false, ['+', '-'])) { + $this->pos++; + $subTerm = $this->subTerm(); + if (($char == '+') && is_string($value)) { + $this->checkString($subTerm); + $value .= $subTerm; + continue; + } + $this->checkNumers($value, $subTerm); + if ( (strlen($subTerm) < 1) or (!is_numeric($subTerm)) ) {return "Math Error: Empty variable";} + // throw new Exception('Empty variable', 7); + if ($char == '-') $subTerm = -$subTerm; + $value += $subTerm; + } + return $value; +} + +private function perform(string $formula) { + $this->pos = 0; + $this->text = $formula; + return $this->calculate(); +} + +public function execute(string $formula) { + $b = 0; + for ($i = 0; $i < strlen($formula); $i++) { + switch ($formula[$i]) { + case '(': $b++; break; + case ')': $b--; break; + } + } + if ($b != 0) {return "Math Error: Unmatched brackets";} + // throw new Exception('Unmatched brackets', 2); + $i = strpos($formula, '"'); + if ($i === false) + $formula = str_replace(' ', '', strtolower($formula)); + else { + $cleaned = ''; + $l = strlen($formula); + $s = 0; + $b = false; + do { + if ($b) $i++; + $part = substr($formula, $s, $i - $s); + if (!$b) $part = str_replace(' ', '', strtolower($part)); + $s = $i; + $b = !$b; + $cleaned .= $part; + $d = $s + 1; + if ($l < $d) break; + } while (($i = strpos($formula, '"', $d)) !== false); + if ($l != $s) + $cleaned .= str_replace(' ', '', strtolower(substr($formula, $s))); + $formula = $cleaned; + } + return $this->perform($formula); +} + +} \ No newline at end of file diff --git a/agc_2-X/trunk/www/agc/functions.php b/agc_2-X/trunk/www/agc/functions.php index 3cf530e4..e78ab9ac 100644 --- a/agc_2-X/trunk/www/agc/functions.php +++ b/agc_2-X/trunk/www/agc/functions.php @@ -4,7 +4,7 @@ # # functions for agent scripts # -# Copyright (C) 2020 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2021 Matt Florell LICENSE: AGPLv2 # # # CHANGES: @@ -49,7 +49,8 @@ # 181004-1644 - Fix for defaut field in AREA type # 191013-1029 - Fixes for PHP7 # 200406-1204 - Fix for gender default field population -# +# 210211-0145 - Added SOURCESELECT field type, added basic Math equations to SCRIPT custom field types +# # $mysql_queries = 26 @@ -343,6 +344,7 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i $custom_required_fields_multi='|'; require("dbconnect_mysqli.php"); + require("Evaluator.php"); $CFoutput=''; $stmt="SHOW TABLES LIKE \"custom_$list_id\";"; @@ -538,7 +540,7 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i } $field_HTML=''; - if ($A_field_type[$o]=='SELECT') + if ( ($A_field_type[$o]=='SELECT') or ($A_field_type[$o]=='SOURCESELECT') ) { $change_trigger=''; $default_field_flag=0; @@ -553,19 +555,76 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i { $field_HTML .= "\n"; } @@ -649,7 +708,7 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i # If options were printed for SELECT, MULTI, RADIO or CHECKBOX and required is set, mark as a required field if ($te_printed > 0) { - if ($A_field_type[$o]=='SELECT') + if ( ($A_field_type[$o]=='SELECT') or ($A_field_type[$o]=='SOURCESELECT') ) { if ( ($A_field_required[$o] == 'Y') or ( ($A_field_required[$o] == 'INBOUND_ONLY') and (preg_match("/^Y\d\d\d\d\d\d\d/",$call_id)) ) ) {$custom_required_fields_select .= "$A_field_label[$o]|";} @@ -861,7 +920,7 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i ##### BEGIN parsing for vicidial variables ##### $NOTESout=''; - if (preg_match("/--A--|--U--/",$CFoutput)) + if (preg_match("/--A--|--U--|--M--/",$CFoutput)) { if ( (preg_match('/--A--user_custom_|--U--user_custom_/i',$CFoutput)) or (preg_match('/--A--fullname|--U--fullname/i',$CFoutput)) ) { @@ -1316,6 +1375,29 @@ function custom_list_fields_values($lead_id,$list_id,$uniqueid,$user,$DB,$call_i $o++; } + # check for Math formulas + if ( (preg_match("/--M--/",$CFoutput)) or (preg_match("/--N--/",$CFoutput)) ) + { + $DBM=0; + $evaluator = new \Matex\Evaluator(); + preg_match_all("/--M--(.*?)--N--/", $CFoutput, $MathMatch); + $MathMatch_count = count($MathMatch[0]); + $Mct=0; + while ($MathMatch_count > $Mct) + { + $temp_MathEq = $MathMatch[0][$Mct]; + $temp_MathEq = preg_replace("/--M--|--N--/",'',$temp_MathEq); + $temp_MathEq_orig = $temp_MathEq; + $temp_MathEq = preg_replace("/[^- \+\-\*\^\.\(\)\%\/0-9]/",'',$temp_MathEq); + + $temp_MathResult = $evaluator->execute($temp_MathEq); + if ($DBM > 0) {$CFoutput .= "MATH DEBUG: $Mct|$temp_MathEq|$temp_MathResult|\n";} + $CFoutput = str_replace("--M--$temp_MathEq_orig--N--","$temp_MathResult",$CFoutput); + + $Mct++; + } + } + if ($DB > 0) {echo "$CFoutput
\n";} } ##### END parsing for vicidial variables ##### 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 1e0ba922..4dc0a566 100644 --- a/agc_2-X/trunk/www/agc/vdc_form_display.php +++ b/agc_2-X/trunk/www/agc/vdc_form_display.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2021 Matt Florell LICENSE: AGPLv2 # # This script is designed display the contents of the FORM tab in the agent # interface, as well as take submission of the form submission when the agent @@ -45,10 +45,11 @@ # 180503-1813 - Added code for SWITCH field type # 200406-1137 - Added hide_gender and gender default population # 201117-2056 - Changes for better compatibility with non-latin data input +# 210211-0146 - Added SOURCESELECT field type # -$version = '2.14-35'; -$build = '201117-2056'; +$version = '2.14-36'; +$build = '210211-0146'; $php_script = 'vdc_form_display.php'; require_once("dbconnect_mysqli.php"); diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index ed8fdcaa..300d8464 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -5434,12 +5434,13 @@ if ($SSscript_remove_js > 0) # 210124-0947 - Added copy_user Non-Agent API function # 210207-0915 - Added Shared Debug Page to admin utilities # 210210-1601 - Added add_did Non-Agent API function +# 210211-1145 - Added Matex use information # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.14-786a'; -$build = '210210-1601'; +$admin_version = '2.14-787a'; +$build = '210211-1145'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -44905,6 +44906,14 @@ if ($ADD==999995) echo "

"._QXZ("Other integrated software disclaimers").":

\n"; + echo "
\n"; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + + echo ""; + echo "
"._QXZ("Matex").": "._QXZ("Copyright").":   "._QXZ("Matex PHP Mathematical expression parser and evaluator library was written by Dorin Marcoci").", © 2021
"._QXZ("License").":   "._QXZ("Chart.js is licensed under the")." MIT "._QXZ("open source license")."
"._QXZ("Source Code").":   "._QXZ("Matex original source code is available at")." "._QXZ("this link").".
 
\n"; echo ""; 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 31ecfcd8..9ef233f5 100644 --- a/agc_2-X/trunk/www/vicidial/admin_lists_custom.php +++ b/agc_2-X/trunk/www/vicidial/admin_lists_custom.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2021 Matt Florell LICENSE: AGPLv2 # # this screen manages the custom lists fields in ViciDial # @@ -53,10 +53,11 @@ # 180502-2215 - Added new help display # 180504-1807 - Added new SWITCH field type # 191013-1014 - Fixes for PHP7 +# 210211-0032 - Added SOURCESELECT field type # -$admin_version = '2.14-44'; -$build = '191013-1014'; +$admin_version = '2.14-45'; +$build = '210211-0032'; require("dbconnect_mysqli.php"); require("functions.php"); @@ -821,7 +822,7 @@ if ( ($action == "ADD_CUSTOM_FIELD") and ($list_id > 99) ) else { $TEST_valid_options=0; - if ( ($field_type=='SELECT') or ($field_type=='MULTI') or ($field_type=='RADIO') or ($field_type=='CHECKBOX') or ($field_type=='SWITCH') ) + if ( ($field_type=='SELECT') or ($field_type=='SOURCESELECT') or ($field_type=='MULTI') or ($field_type=='RADIO') or ($field_type=='CHECKBOX') or ($field_type=='SWITCH') ) { $TESTfield_options_array = explode("\n",$field_options); $TESTfield_options_count = count($TESTfield_options_array); @@ -829,9 +830,12 @@ if ( ($action == "ADD_CUSTOM_FIELD") and ($list_id > 99) ) $switch_list_self=0; while ($te < $TESTfield_options_count) { - if (preg_match("/,/",$TESTfield_options_array[$te])) + if (preg_match("/,|\|/",$TESTfield_options_array[$te])) { - $TESTfield_options_value_array = explode(",",$TESTfield_options_array[$te]); + if ($field_type=='SOURCESELECT') + {$TESTfield_options_value_array = explode('|',$TESTfield_options_array[$te]);} + else + {$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++;} if ( ($field_type=='SWITCH') and ($TESTfield_options_value_array[0] == "$list_id") ) @@ -842,8 +846,8 @@ if ( ($action == "ADD_CUSTOM_FIELD") and ($list_id > 99) ) $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 ""._QXZ("ERROR: You must enter field options when adding a SELECT, MULTI, RADIO or CHECKBOX field type")." - $list_id|$field_label|$field_type|$switch_list_self|$field_options\n
";} + if ( ( ($field_type=='SELECT') or ($field_type=='SOURCESELECT') 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 ""._QXZ("ERROR: You must enter field options when adding a SELECT, MULTI, RADIO, CHECKBOX or SOURCESELECT field type")." - $list_id|$field_label|$field_type|$switch_list_self|$field_options\n
";} else { if ( ($field_type=='SWITCH') and ($switch_list_self < 1) ) @@ -967,7 +971,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELD_SUBMIT") and ($list_id > 99) and ($field_i else { $TEST_valid_options=0; - if ( ($field_type=='SELECT') or ($field_type=='MULTI') or ($field_type=='RADIO') or ($field_type=='CHECKBOX') or ($field_type=='SWITCH') ) + if ( ($field_type=='SELECT') or ($field_type=='SOURCESELECT') or ($field_type=='MULTI') or ($field_type=='RADIO') or ($field_type=='CHECKBOX') or ($field_type=='SWITCH') ) { $TESTfield_options_array = explode("\n",$field_options); $TESTfield_options_count = count($TESTfield_options_array); @@ -975,9 +979,12 @@ if ( ($action == "MODIFY_CUSTOM_FIELD_SUBMIT") and ($list_id > 99) and ($field_i $switch_list_self=0; while ($te < $TESTfield_options_count) { - if (preg_match("/,/",$TESTfield_options_array[$te])) + if (preg_match("/,|\|/",$TESTfield_options_array[$te])) { - $TESTfield_options_value_array = explode(",",$TESTfield_options_array[$te]); + if ($field_type=='SOURCESELECT') + {$TESTfield_options_value_array = explode('|',$TESTfield_options_array[$te]);} + else + {$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++;} if ( ($field_type=='SWITCH') and ($TESTfield_options_value_array[0] == "$list_id") ) @@ -989,8 +996,8 @@ if ( ($action == "MODIFY_CUSTOM_FIELD_SUBMIT") and ($list_id > 99) and ($field_i $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 ""._QXZ("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
";} + if ( ( ($field_type=='SELECT') or ($field_type=='SOURCESELECT') 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 ""._QXZ("ERROR: You must enter field options when updating a SELECT, MULTI, RADIO, CHECKBOX or SOURCESELECT field type")." - $list_id|$field_label|$field_type|$field_options\n
";} else { if ( ($field_type=='SWITCH') and ($switch_list_self < 1) ) @@ -1230,7 +1237,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) $encrypt_icon=''; if ($A_field_encrypt[$o] == 'Y') {$encrypt_icon = " \""._QXZ("Encrypted";} - if ($A_field_type[$o]=='SELECT') + if ( ($A_field_type[$o]=='SELECT') or ($A_field_type[$o]=='SOURCESELECT') ) { $field_HTML .= "\n"; } - if ( ($A_field_type[$o]=='SELECT') or ($A_field_type[$o]=='MULTI') or ($A_field_type[$o]=='RADIO') or ($A_field_type[$o]=='CHECKBOX') or ($A_field_type[$o]=='SWITCH') ) + if ( ($A_field_type[$o]=='SELECT') or ($A_field_type[$o]=='SOURCESELECT') or ($A_field_type[$o]=='MULTI') or ($A_field_type[$o]=='RADIO') or ($A_field_type[$o]=='CHECKBOX') or ($A_field_type[$o]=='SWITCH') ) { $field_options_array = explode("\n",$A_field_options[$o]); $field_options_count = count($field_options_array); $te=0; while ($te < $field_options_count) { - if (preg_match("/,/",$field_options_array[$te])) + if (preg_match("/,|\|/",$field_options_array[$te])) { $field_selected=''; - $field_options_value_array = explode(",",$field_options_array[$te]); + if ($A_field_type[$o]=='SOURCESELECT') + {$field_options_value_array = explode('|',$field_options_array[$te]);} + else + {$field_options_value_array = explode(",",$field_options_array[$te]);} if ( ($A_field_type[$o]=='SELECT') or ($A_field_type[$o]=='MULTI') ) { if ($A_field_default[$o] == "$field_options_value_array[0]") {$field_selected = 'SELECTED';} $field_HTML .= "\n"; } + if ($A_field_type[$o]=='SOURCESELECT') + { + if (preg_match("/^option=>/i",$field_options_value_array[0])) + { + $field_options_value_array[0] = preg_replace("/^option=>/i",'',$field_options_value_array[0]); + if ($A_field_default[$o] == "$field_options_value_array[0]") {$field_selected = 'SELECTED';} + $field_HTML .= "\n"; + } + } if ( ($A_field_type[$o]=='RADIO') or ($A_field_type[$o]=='CHECKBOX') ) { if ($A_multi_position[$o]=='VERTICAL') @@ -1282,7 +1301,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) $te++; } } - if ( ($A_field_type[$o]=='SELECT') or ($A_field_type[$o]=='MULTI') ) + if ( ($A_field_type[$o]=='SELECT') or ($A_field_type[$o]=='SOURCESELECT') or ($A_field_type[$o]=='MULTI') ) { $field_HTML .= "\n"; } @@ -1519,6 +1538,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) echo "\n"; echo "\n"; echo "\n"; + echo "\n"; echo "\n"; echo " $NWB#lists_fields-field_type$NWE \n"; echo "
\n"; @@ -1622,6 +1642,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) echo "\n"; echo "\n"; echo "\n"; + echo "\n"; echo "\n"; echo " $NWB#lists_fields-field_type$NWE \n"; echo "\n"; @@ -1880,16 +1901,22 @@ function add_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$field $field_options_ENUM=''; $field_cost=1; - if ( ($field_type=='SELECT') or ($field_type=='RADIO') ) + if ( ($field_type=='SELECT') or ($field_type=='SOURCESELECT') or ($field_type=='RADIO') ) { $field_options_array = explode("\n",$field_options); $field_options_count = count($field_options_array); $te=0; while ($te < $field_options_count) { - if (preg_match("/,/",$field_options_array[$te])) + if (preg_match("/,|\|/",$field_options_array[$te])) { - $field_options_value_array = explode(",",$field_options_array[$te]); + if ($field_type=='SOURCESELECT') + { + $field_options_value_array = explode('|',$field_options_array[$te]); + $field_options_value_array[0] = preg_replace("/^option=>/i",'',$field_options_value_array[0]); + } + else + {$field_options_value_array = explode(",",$field_options_array[$te]);} $field_options_ENUM .= "'$field_options_value_array[0]',"; } $te++; @@ -2068,16 +2095,22 @@ function modify_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$fi $field_options_ENUM=''; $field_cost=1; - if ( ($field_type=='SELECT') or ($field_type=='RADIO') ) + if ( ($field_type=='SELECT') or ($field_type=='SOURCESELECT') or ($field_type=='RADIO') ) { $field_options_array = explode("\n",$field_options); $field_options_count = count($field_options_array); $te=0; while ($te < $field_options_count) { - if (preg_match("/,/",$field_options_array[$te])) + if (preg_match("/,|\|/",$field_options_array[$te])) { - $field_options_value_array = explode(",",$field_options_array[$te]); + if ($field_type=='SOURCESELECT') + { + $field_options_value_array = explode('|',$field_options_array[$te]); + $field_options_value_array[0] = preg_replace("/^option=>/i",'',$field_options_value_array[0]); + } + else + {$field_options_value_array = explode(",",$field_options_array[$te]);} $field_options_ENUM .= "'$field_options_value_array[0]',"; } $te++; diff --git a/agc_2-X/trunk/www/vicidial/help_documentation.txt b/agc_2-X/trunk/www/vicidial/help_documentation.txt index 92bd4172..fc9b173c 100644 --- a/agc_2-X/trunk/www/vicidial/help_documentation.txt +++ b/agc_2-X/trunk/www/vicidial/help_documentation.txt @@ -1,4 +1,4 @@ -# version: 20210103084501 +# version: 20210211025401 users-user User ID 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. users-pass Password This field is where you put the users password. Must be at least 2 characters in length. 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. users-force_change_password Force Change Password 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. @@ -444,8 +444,8 @@ lists_fields-field_description Field Description The description of this fi lists_fields-field_rank Field Rank The order in which these fields is displayed to the agent from lowest on top to highest on the bottom. lists_fields-field_order Field Order 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. lists_fields-field_help Field Help 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. -lists_fields-field_type Field Type 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. -lists_fields-field_options Field Options 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. 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--. 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. +lists_fields-field_type Field Type 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. +lists_fields-field_options Field Options 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. 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 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:
source=>province
value=>Ontario
option=>|select month here
option=>September|September
option=>October|October
value=>Nova Scotia
option=>|select month here
option=>June|June
option=>July|July
option=>August|August
value=>British Columbia
option=>|select month here
option=>January|January
option=>February|February
option=>March|March
value=>
option=>|no match
lists_fields-multi_position Option Position 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. lists_fields-field_size Field Size 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. lists_fields-field_max Field Max 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("Pure-knob").": "._QXZ("Copyright").":   "._QXZ("The pure-knob javascript library was written by Andre Plötze").", © 2018
"._QXZ("Field Options")." $A_field_rank[$o]: $NWB#lists_fields-field_options$NWE
"._QXZ("Field Options").": $NWB#lists_fields-field_options$NWE