diff --git a/agc_2-X/branches/agc_2.2.0/UPGRADE b/agc_2-X/branches/agc_2.2.0/UPGRADE index 5b045e3e..0a360622 100644 --- a/agc_2-X/branches/agc_2.2.0/UPGRADE +++ b/agc_2-X/branches/agc_2.2.0/UPGRADE @@ -400,6 +400,9 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom 98. Added Swedish Agent translation +99. Added headers to the list export and calls export reports + + diff --git a/agc_2-X/branches/agc_2.2.0/www/vicidial/list_download.php b/agc_2-X/branches/agc_2.2.0/www/vicidial/list_download.php index a2ca94b4..d1bcb77b 100644 --- a/agc_2-X/branches/agc_2.2.0/www/vicidial/list_download.php +++ b/agc_2-X/branches/agc_2.2.0/www/vicidial/list_download.php @@ -12,6 +12,7 @@ # 90508-0644 - Changed to PHP long tags # 90721-1238 - Added rank and owner as vicidial_list fields # 100119-1039 - Filtered comments for \n newlines +# 100508-1439 - Added header row to output # require("dbconnect.php"); @@ -112,6 +113,8 @@ header('Pragma: public'); ob_clean(); flush(); +echo "lead_id\tentry_date\tmodify_date\tstatus\tuser\tvendor_lead_code\tsource_id\tlist_id\tgmt_offset_now\tcalled_since_last_reset\tphone_code\tphone_number\ttitle\tfirst_name\tmiddle_initial\tlast_name\taddress1\taddress2\taddress3\tcity\tstate\tprovince\tpostal_code\tcountry_code\tgender\tdate_of_birth\talt_phone\temail\tsecurity_phrase\tcomments\tcalled_count\tlast_local_call_time\trank\towner\r\n"; + $stmt="select lead_id,entry_date,modify_date,status,user,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 from vicidial_list where list_id='$list_id';"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index 5927403e..a3f189f4 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -135,6 +135,8 @@ OTHER CHANGES: 30. Added Hold Time Option Minimum option to in-groups which will prevent the hold time option from running until a minimum number of hold seconds. +31. Added headers to the list export and calls export reports + diff --git a/agc_2-X/trunk/docs/CUSTOM_FIELDS.txt b/agc_2-X/trunk/docs/CUSTOM_FIELDS.txt index 31d5c4ca..12afa281 100644 --- a/agc_2-X/trunk/docs/CUSTOM_FIELDS.txt +++ b/agc_2-X/trunk/docs/CUSTOM_FIELDS.txt @@ -81,7 +81,8 @@ field_default VARCHAR(255), field_cost SMALLINT(5), field_required ENUM('Y','N') default 'N', name_position ENUM('LEFT','TOP') default 'LEFT', -multi_position ENUM('HORIZONTAL','VERTICAL') default 'HORIZONTAL' +multi_position ENUM('HORIZONTAL','VERTICAL') default 'HORIZONTAL', +field_order SMALLINT(5) default '1' ); CREATE UNIQUE INDEX listfield on vicidial_lists_fields (list_id, field_label); 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 53e1a06a..88c8924e 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -2085,7 +2085,8 @@ field_default VARCHAR(255), field_cost SMALLINT(5), field_required ENUM('Y','N') default 'N', name_position ENUM('LEFT','TOP') default 'LEFT', -multi_position ENUM('HORIZONTAL','VERTICAL') default 'HORIZONTAL' +multi_position ENUM('HORIZONTAL','VERTICAL') default 'HORIZONTAL', +field_order SMALLINT(5) default '1' ); CREATE UNIQUE INDEX listfield on vicidial_lists_fields (list_id, field_label); @@ -2229,7 +2230,7 @@ ALTER TABLE vicidial_agent_log_archive MODIFY agent_log_id INT(9) UNSIGNED NOT N CREATE TABLE vicidial_carrier_log_archive LIKE vicidial_carrier_log; -UPDATE system_settings SET db_schema_version='1218',db_schema_update_date=NOW(); +UPDATE system_settings SET db_schema_version='1219',db_schema_update_date=NOW(); GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/agc_2-X/trunk/extras/upgrade_2.4.sql b/agc_2-X/trunk/extras/upgrade_2.4.sql index 0a0b6017..52b6fee7 100644 --- a/agc_2-X/trunk/extras/upgrade_2.4.sql +++ b/agc_2-X/trunk/extras/upgrade_2.4.sql @@ -309,3 +309,7 @@ ALTER TABLE vicidial_lists_fields ADD multi_position ENUM('HORIZONTAL','VERTICAL ALTER TABLE vicidial_inbound_groups ADD hold_time_option_minimum SMALLINT(5) default '0'; UPDATE system_settings SET db_schema_version='1218',db_schema_update_date=NOW(); + +ALTER TABLE vicidial_lists_fields ADD field_order SMALLINT(5) default '1'; + +UPDATE system_settings SET db_schema_version='1219',db_schema_update_date=NOW(); diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt index 25c33939..b3baf52a 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt @@ -170,6 +170,18 @@ ADD COPIED CARRIER|| Source Carrier|| COPIED CARRIER ADDED|| Copy A Carrier|| +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|| +Copy Fields to Another List|| +List ID to Copy Fields to|| +List ID to Copy Fields From|| +Copy Option|| +When copying field definitions from one list to another, you have a few options for how the copying process works. APPEND will add the fields that are not present in the destination list, if there are matching field labels those will remained untouched, no custom field data will be deleted or modified using this option. UPDATE will update the common field_label fields in the destination list to the field definitions from the source list. custom field data may be modified or lost using this option. REPLACE will remove all existing custom fields in the destination list and replace them with the custom fields from the source list, all custom field data will be deleted using this option|| +ERROR: Source list has no custom fields|| +SUCCESS: Custom Field Added|| +SUCCESS: Custom Field Modified|| +SUCCESS: Custom Field Deleted|| +Copy List Custom Fields|| +ERROR: You cannot copy fields to the same list|| AST_VICIDIAL_ingrouplist.php diff --git a/agc_2-X/trunk/www/vicidial/admin_header.php b/agc_2-X/trunk/www/vicidial/admin_header.php index de9705be..f469f120 100644 --- a/agc_2-X/trunk/www/vicidial/admin_header.php +++ b/agc_2-X/trunk/www/vicidial/admin_header.php @@ -1024,6 +1024,8 @@ $SScustom_fields_enabled = $row[3]; ?> >   > List Custom Fields + >   + > Copy List Custom Fields 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 87003409..3f080801 100644 --- a/agc_2-X/trunk/www/vicidial/admin_lists_custom.php +++ b/agc_2-X/trunk/www/vicidial/admin_lists_custom.php @@ -8,10 +8,12 @@ # changes: # 100506-1801 - First Build # 100507-1027 - Added name position and options position, added extra space for name and help +# 100508-1855 - Added field_order to allow for multiple fields on the same line +# 100509-0922 - Added copy fields options # -$admin_version = '2.4-2'; -$build = '100507-1027'; +$admin_version = '2.4-4'; +$build = '100509-0922'; require("dbconnect.php"); @@ -55,6 +57,12 @@ if (isset($_GET["name_position"])) {$name_position=$_GET["name_position"];} elseif (isset($_POST["name_position"])) {$name_position=$_POST["name_position"];} 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["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"];} + elseif (isset($_POST["copy_option"])) {$copy_option=$_POST["copy_option"];} if (isset($_GET["ConFiRm"])) {$ConFiRm=$_GET["ConFiRm"];} elseif (isset($_POST["ConFiRm"])) {$ConFiRm=$_POST["ConFiRm"];} if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} @@ -78,6 +86,8 @@ if ($non_latin < 1) $field_rank = ereg_replace("[^0-9]","",$field_rank); $field_size = ereg_replace("[^0-9]","",$field_size); $field_max = ereg_replace("[^0-9]","",$field_max); + $field_order = ereg_replace("[^0-9]","",$field_order); + $source_list_id = ereg_replace("[^0-9]","",$source_list_id); $field_required = ereg_replace("[^NY]","",$field_required); @@ -87,6 +97,7 @@ if ($non_latin < 1) $multi_position = ereg_replace("[^0-9a-zA-Z]","",$multi_position); $field_label = ereg_replace("[^_0-9a-zA-Z]","",$field_label); + $copy_option = ereg_replace("[^_0-9a-zA-Z]","",$copy_option); $field_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$field_name); $field_description = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$field_description); @@ -131,6 +142,7 @@ if ($WeBRooTWritablE > 0) $date = date("r"); $ip = getenv("REMOTE_ADDR"); $browser = getenv("HTTP_USER_AGENT"); +$user = $PHP_AUTH_USER; if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) { @@ -225,6 +237,11 @@ if ($action == "HELP") Field Rank - The order in which these fields is displayed to the agent from lowest on top to highest on the bottom.

+ +
+ 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. +

+

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. @@ -275,6 +292,10 @@ if ($action == "HELP") Field Name Position - If set to LEFT, this field name will appear to the left of the field, if set to TOP the field name will take up the entire line and appear above the field. Default is LEFT.

+
+
+ Copy Option - When copying field definitions from one list to another, you have a few options for how the copying process works. APPEND will add the fields that are not present in the destination list, if there are matching field labels those will remained untouched, no custom field data will be deleted or modified using this option. UPDATE will update the common field_label fields in the destination list to the field definitions from the source list. custom field data may be modified or lost using this option. REPLACE will remove all existing custom fields in the destination list and replace them with the custom fields from the source list, all custom field data will be deleted using this option. +

\"HELP\"
"; +if ($DB > 0) +{ +echo "$DB,$action,$ip,$user,$copy_option,$field_id,$list_id,$source_list_id,$field_label,$field_name,$field_description,$field_rank,$field_help,$field_type,$field_options,$field_size,$field_max,$field_default,$field_required,$field_cost,$multi_position,$name_position,$field_order"; +} + + + + + +################################################################################ +##### BEGIN copy fields to a list form +if ($action == "COPY_FIELDS_FORM") + { + ##### get lists listing for dynamic pulldown + $stmt="SELECT list_id,list_name from vicidial_lists order by list_id"; + $rsltx=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rsltx); + $lists_list=''; + $o=0; + while ($lists_to_print > $o) + { + $rowx=mysql_fetch_row($rsltx); + $lists_list .= "\n"; + $o++; + } + + echo "
\n"; + echo ""; + echo "
Copy Fields to Another List
\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
List ID to Copy Fields From:
List ID to Copy Fields to:
Copy Option: $NWB#vicidial_lists_fields-copy_option$NWE
\n"; + echo "
\n"; + } +### END copy fields to a list form + + + + +################################################################################ +##### BEGIN copy list fields submit +if ( ($action == "COPY_FIELDS_SUBMIT") and ($list_id > 99) and ($source_list_id > 99) and (strlen($copy_option) > 2) ) + { + if ($list_id=="$source_list_id") + {echo "ERROR: You cannot copy fields to the same list: $list_id|$source_list_id";} + 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" . mysql_error());} + mysql_select_db("$VARDB_database", $linkCUSTOM); + + $stmt="SELECT count(*) from vicidial_lists_fields where list_id='$source_list_id';"; + if ($DB>0) {echo "$stmt";} + $rslt=mysql_query($stmt, $link); + $fieldscount_to_print = mysql_num_rows($rslt); + if ($fieldscount_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $source_field_exists = $rowx[0]; + } + + $stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id';"; + if ($DB>0) {echo "$stmt";} + $rslt=mysql_query($stmt, $link); + $fieldscount_to_print = mysql_num_rows($rslt); + if ($fieldscount_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $field_exists = $rowx[0]; + } + + $stmt="SHOW TABLES LIKE \"custom_$list_id\";"; + if ($DB>0) {echo "$stmt";} + $rslt=mysql_query($stmt, $link); + $tablecount_to_print = mysql_num_rows($rslt); + if ($tablecount_to_print > 0) + {$table_exists = 1;} + + if ($source_field_exists < 1) + {echo "ERROR: Source list has no custom fields\n
";} + else + { + ##### REPLACE option ##### + if ($copy_option=='REPLACE') + { + if ($DB > 0) {echo "Starting REPLACE copy\n
";} + if ($table_exists > 0) + { + $stmt="SELECT field_id,field_label from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;"; + $rslt=mysql_query($stmt, $link); + $fields_to_print = mysql_num_rows($rslt); + $fields_list=''; + $o=0; + while ($fields_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $A_field_id[$o] = $rowx[0]; + $A_field_label[$o] = $rowx[1]; + $o++; + } + + $o=0; + while ($fields_to_print > $o) + { + ### delete field function + delete_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$A_field_id[$o],$list_id,$A_field_label[$o],$A_field_name[$o],$A_field_description[$o],$A_field_rank[$o],$A_field_help[$o],$A_field_type[$o],$A_field_options[$o],$A_field_size[$o],$A_field_max[$o],$A_field_default[$o],$A_field_required[$o],$A_field_cost[$o],$A_multi_position[$o],$A_name_position[$o],$A_field_order[$o]); + + echo "SUCCESS: Custom Field Deleted - $list_id|$A_field_label[$o]\n
"; + $o++; + } + } + $copy_option='APPEND'; + } + ##### APPEND option ##### + if ($copy_option=='APPEND') + { + if ($DB > 0) {echo "Starting APPEND copy\n
";} + $stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$source_list_id' order by field_rank,field_order,field_label;"; + $rslt=mysql_query($stmt, $link); + $fields_to_print = mysql_num_rows($rslt); + $fields_list=''; + $o=0; + while ($fields_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $A_field_id[$o] = $rowx[0]; + $A_field_label[$o] = $rowx[1]; + $A_field_name[$o] = $rowx[2]; + $A_field_description[$o] = $rowx[3]; + $A_field_rank[$o] = $rowx[4]; + $A_field_help[$o] = $rowx[5]; + $A_field_type[$o] = $rowx[6]; + $A_field_options[$o] = $rowx[7]; + $A_field_size[$o] = $rowx[8]; + $A_field_max[$o] = $rowx[9]; + $A_field_default[$o] = $rowx[10]; + $A_field_cost[$o] = $rowx[11]; + $A_field_required[$o] = $rowx[12]; + $A_multi_position[$o] = $rowx[13]; + $A_name_position[$o] = $rowx[14]; + $A_field_order[$o] = $rowx[15]; + + $o++; + $rank_select .= ""; + } + + $o=0; + while ($fields_to_print > $o) + { + $new_field_exists=0; + if ($table_exists > 0) + { + $stmt="SELECT count(*) from vicidial_lists_fields where list_id='$list_id' and field_label='$A_field_label[$o]';"; + if ($DB>0) {echo "$stmt";} + $rslt=mysql_query($stmt, $link); + $fieldscount_to_print = mysql_num_rows($rslt); + if ($fieldscount_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $new_field_exists = $rowx[0]; + } + } + if ($new_field_exists < 1) + { + ### add field function + add_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$A_field_id[$o],$list_id,$A_field_label[$o],$A_field_name[$o],$A_field_description[$o],$A_field_rank[$o],$A_field_help[$o],$A_field_type[$o],$A_field_options[$o],$A_field_size[$o],$A_field_max[$o],$A_field_default[$o],$A_field_required[$o],$A_field_cost[$o],$A_multi_position[$o],$A_name_position[$o],$A_field_order[$o]); + + echo "SUCCESS: Custom Field Added - $list_id|$A_field_label[$o]\n
"; + + if ($table_exists < 1) {$table_exists=1;} + } + $o++; + } + } + ##### UPDATE option ##### + if ($copy_option=='UPDATE') + { + if ($DB > 0) {echo "Starting UPDATE copy\n
";} + if ($table_exists < 1) + {echo "ERROR: Table does not exist\n
";} + else + { + $stmt="SELECT field_id,field_label,field_name,field_description,field_rank,field_help,field_type,field_options,field_size,field_max,field_default,field_cost,field_required,multi_position,name_position,field_order from vicidial_lists_fields where list_id='$source_list_id' order by field_rank,field_order,field_label;"; + $rslt=mysql_query($stmt, $link); + $fields_to_print = mysql_num_rows($rslt); + $fields_list=''; + $o=0; + while ($fields_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $A_field_id[$o] = $rowx[0]; + $A_field_label[$o] = $rowx[1]; + $A_field_name[$o] = $rowx[2]; + $A_field_description[$o] = $rowx[3]; + $A_field_rank[$o] = $rowx[4]; + $A_field_help[$o] = $rowx[5]; + $A_field_type[$o] = $rowx[6]; + $A_field_options[$o] = $rowx[7]; + $A_field_size[$o] = $rowx[8]; + $A_field_max[$o] = $rowx[9]; + $A_field_default[$o] = $rowx[10]; + $A_field_cost[$o] = $rowx[11]; + $A_field_required[$o] = $rowx[12]; + $A_multi_position[$o] = $rowx[13]; + $A_name_position[$o] = $rowx[14]; + $A_field_order[$o] = $rowx[15]; + $o++; + } + + $o=0; + while ($fields_to_print > $o) + { + $stmt="SELECT field_id from vicidial_lists_fields where list_id='$list_id' and field_label='$A_field_label[$o]';"; + if ($DB>0) {echo "$stmt";} + $rslt=mysql_query($stmt, $link); + $fieldscount_to_print = mysql_num_rows($rslt); + if ($fieldscount_to_print > 0) + { + $rowx=mysql_fetch_row($rslt); + $current_field_id = $rowx[0]; + + ### modify field function + modify_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$current_field_id,$list_id,$A_field_label[$o],$A_field_name[$o],$A_field_description[$o],$A_field_rank[$o],$A_field_help[$o],$A_field_type[$o],$A_field_options[$o],$A_field_size[$o],$A_field_max[$o],$A_field_default[$o],$A_field_required[$o],$A_field_cost[$o],$A_multi_position[$o],$A_name_position[$o],$A_field_order[$o]); + + echo "SUCCESS: Custom Field Modified - $list_id|$A_field_label[$o]\n
"; + } + $o++; + } + } + } + } + + $action = "MODIFY_CUSTOM_FIELDS"; + } + } +### END copy list fields submit + + @@ -366,6 +639,7 @@ if ( ($action == "DELETE_CUSTOM_FIELD_CONFIRMATION") and ($list_id > 99) and ($f + ################################################################################ ##### BEGIN delete custom field if ( ($action == "DELETE_CUSTOM_FIELD") and ($list_id > 99) and ($field_id > 0) and (strlen($field_label) > 0) and ($ConFiRm=='YES') ) @@ -400,27 +674,10 @@ if ( ($action == "DELETE_CUSTOM_FIELD") and ($list_id > 99) and ($field_id > 0) {echo "ERROR: Table does not exist\n
";} else { - $stmtCUSTOM="ALTER TABLE custom_$list_id DROP $field_label;"; - $rsltCUSTOM=mysql_query($stmtCUSTOM, $linkCUSTOM); - $table_update = mysql_affected_rows($linkCUSTOM); - if ($DB) {echo "$table_update|$stmtCUSTOM\n";} - if (!$rsltCUSTOM) {die('Could not execute: ' . mysql_error());} + ### delete field function + delete_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$field_id,$list_id,$field_label,$field_name,$field_description,$field_rank,$field_help,$field_type,$field_options,$field_size,$field_max,$field_default,$field_required,$field_cost,$multi_position,$name_position,$field_order); - $stmt="DELETE FROM vicidial_lists_fields WHERE field_label='$field_label' and field_id='$field_id' and list_id='$list_id' LIMIT 1;"; - $rslt=mysql_query($stmt, $link); - $field_update = mysql_affected_rows($link); - if ($DB) {echo "$field_update|$stmt\n";} - if (!$rslt) {die('Could not execute: ' . mysql_error());} - - echo "

THIS CUSTOM FIELD HAS BEEN DELETED: $field_label - $field_id - $list_id

"; - - ### LOG INSERTION Admin Log Table ### - $SQL_log = "$stmt|$stmtCUSTOM"; - $SQL_log = ereg_replace(';','',$SQL_log); - $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$ip', event_section='CUSTOM_FIELDS', event_type='DELETE', record_id='$list_id', event_code='ADMIN DELETE CUSTOM LIST FIELD', event_sql=\"$SQL_log\", event_notes='';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); + echo "SUCCESS: Custom Field Deleted - $list_id|$field_label\n
"; } } @@ -461,98 +718,10 @@ if ( ($action == "ADD_CUSTOM_FIELD") and ($list_id > 99) ) {echo "ERROR: Field already exists for this list - $list_id|$field_label\n
";} else { - if ($table_exists < 1) - {$field_sql = "CREATE TABLE custom_$list_id (lead_id INT(9) UNSIGNED PRIMARY KEY NOT NULL, $field_label ";} - else - {$field_sql = "ALTER TABLE custom_$list_id ADD $field_label ";} + ### add field function + add_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$field_id,$list_id,$field_label,$field_name,$field_description,$field_rank,$field_help,$field_type,$field_options,$field_size,$field_max,$field_default,$field_required,$field_cost,$multi_position,$name_position,$field_order); - $field_options_ENUM=''; - $field_cost=1; - if ( ($field_type=='SELECT') 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])) - { - $field_options_value_array = explode(",",$field_options_array[$te]); - $field_options_ENUM .= "'$field_options_value_array[0]',"; - } - $te++; - } - $field_options_ENUM = preg_replace("/.$/",'',$field_options_ENUM); - $field_sql .= "ENUM($field_options_ENUM) "; - $field_cost = strlen($field_options_ENUM); - } - if ( ($field_type=='MULTI') or ($field_type=='CHECKBOX') ) - { - $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])) - { - $field_options_value_array = explode(",",$field_options_array[$te]); - $field_options_ENUM .= "'$field_options_value_array[0]',"; - } - $te++; - } - $field_options_ENUM = preg_replace("/.$/",'',$field_options_ENUM); - $field_cost = strlen($field_options_ENUM); - $field_sql .= "VARCHAR($field_cost) "; - } - if ($field_type=='TEXT') - { - $field_sql .= "VARCHAR($field_max) "; - $field_cost = ($field_max + $field_cost); - } - if ($field_type=='AREA') - { - $field_sql .= "TEXT "; - $field_cost = 15; - } - if ($field_type=='DATE') - { - $field_sql .= "DATE "; - $field_cost = 10; - } - if ($field_type=='TIME') - { - $field_sql .= "TIME "; - $field_cost = 8; - } - $field_cost = ($field_cost * 3); # account for utf8 database - - if ( ($field_default != 'NULL') and ($field_type!='AREA') and ($field_type!='DATE') and ($field_type!='TIME') ) - {$field_sql .= "default '$field_default'";} - - if ($table_exists < 1) - {$field_sql .= ");";} - else - {$field_sql .= ";";} - - $stmtCUSTOM="$field_sql"; - $rsltCUSTOM=mysql_query($stmtCUSTOM, $linkCUSTOM); - $table_update = mysql_affected_rows($linkCUSTOM); - if ($DB) {echo "$table_update|$stmtCUSTOM\n";} - if (!$rsltCUSTOM) {die('Could not execute: ' . mysql_error());} - - $stmt="INSERT INTO vicidial_lists_fields set field_label='$field_label',field_name='$field_name',field_description='$field_description',field_rank='$field_rank',field_help='$field_help',field_type='$field_type',field_options='$field_options',field_size='$field_size',field_max='$field_max',field_default='$field_default',field_required='$field_required',field_cost='$field_cost',list_id='$list_id',multi_position='$multi_position',name_position='$name_position';"; - $rslt=mysql_query($stmt, $link); - $field_update = mysql_affected_rows($link); - if ($DB) {echo "$field_update|$stmt\n";} - if (!$rslt) {die('Could not execute: ' . mysql_error());} - - ### LOG INSERTION Admin Log Table ### - $SQL_log = "$stmt|$stmtCUSTOM"; - $SQL_log = ereg_replace(';','',$SQL_log); - $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$ip', event_section='CUSTOM_FIELDS', event_type='ADD', record_id='$list_id', event_code='ADMIN ADD CUSTOM LIST FIELD', event_sql=\"$SQL_log\", event_notes='';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); + echo "SUCCESS: Custom Field Added - $list_id|$field_label\n
"; } $action = "MODIFY_CUSTOM_FIELDS"; @@ -596,91 +765,10 @@ if ( ($action == "MODIFY_CUSTOM_FIELD_SUBMIT") and ($list_id > 99) and ($field_i {echo "ERROR: Table does not exist\n
";} else { - $field_sql = "ALTER TABLE custom_$list_id MODIFY $field_label "; - $field_options_ENUM=''; - $field_cost=1; - if ( ($field_type=='SELECT') 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])) - { - $field_options_value_array = explode(",",$field_options_array[$te]); - $field_options_ENUM .= "'$field_options_value_array[0]',"; - } - $te++; - } - $field_options_ENUM = preg_replace("/.$/",'',$field_options_ENUM); - $field_sql .= "ENUM($field_options_ENUM) "; - $field_cost = strlen($field_options_ENUM); - } - if ( ($field_type=='MULTI') or ($field_type=='CHECKBOX') ) - { - $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])) - { - $field_options_value_array = explode(",",$field_options_array[$te]); - $field_options_ENUM .= "'$field_options_value_array[0]',"; - } - $te++; - } - $field_options_ENUM = preg_replace("/.$/",'',$field_options_ENUM); - $field_cost = strlen($field_options_ENUM); - $field_sql .= "VARCHAR($field_cost) "; - } - if ($field_type=='TEXT') - { - $field_sql .= "VARCHAR($field_max) "; - $field_cost = ($field_max + $field_cost); - } - if ($field_type=='AREA') - { - $field_sql .= "TEXT "; - $field_cost = 15; - } - if ($field_type=='DATE') - { - $field_sql .= "DATE "; - $field_cost = 10; - } - if ($field_type=='TIME') - { - $field_sql .= "TIME "; - $field_cost = 8; - } - $field_cost = ($field_cost * 3); # account for utf8 database + ### modify field function + modify_field_function($DB,$link,$linkCUSTOM,$ip,$user,$table_exists,$field_id,$list_id,$field_label,$field_name,$field_description,$field_rank,$field_help,$field_type,$field_options,$field_size,$field_max,$field_default,$field_required,$field_cost,$multi_position,$name_position,$field_order); - if ( ($field_default == 'NULL') or ($field_type=='AREA') or ($field_type=='DATE') or ($field_type=='TIME') ) - {$field_sql .= ";";} - else - {$field_sql .= "default '$field_default';";} - - $stmtCUSTOM="$field_sql"; - $rsltCUSTOM=mysql_query($stmtCUSTOM, $linkCUSTOM); - $field_update = mysql_affected_rows($linkCUSTOM); - if ($DB) {echo "$field_update|$stmtCUSTOM\n";} - if (!$rsltCUSTOM) {die('Could not execute: ' . mysql_error());} - - $stmt="UPDATE vicidial_lists_fields set field_label='$field_label',field_name='$field_name',field_description='$field_description',field_rank='$field_rank',field_help='$field_help',field_type='$field_type',field_options='$field_options',field_size='$field_size',field_max='$field_max',field_default='$field_default',field_required='$field_required',field_cost='$field_cost',multi_position='$multi_position',name_position='$name_position' where list_id='$list_id' and field_id='$field_id';"; - $rslt=mysql_query($stmt, $link); - $field_update = mysql_affected_rows($link); - if ($DB) {echo "$field_update|$stmt\n";} - if (!$rslt) {die('Could not execute: ' . mysql_error());} - - ### LOG INSERTION Admin Log Table ### - $SQL_log = "$stmt|$stmtCUSTOM"; - $SQL_log = ereg_replace(';','',$SQL_log); - $SQL_log = addslashes($SQL_log); - $stmt="INSERT INTO vicidial_admin_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$ip', event_section='CUSTOM_FIELDS', event_type='MODIFY', record_id='$list_id', event_code='ADMIN MODIFY CUSTOM LIST FIELD', event_sql=\"$SQL_log\", event_notes='';"; - if ($DB) {echo "|$stmt|\n";} - $rslt=mysql_query($stmt, $link); + echo "SUCCESS: Custom Field Modified - $list_id|$field_label\n
"; } } @@ -725,7 +813,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) echo "Records in this custom table: $custom_records_count
\n"; echo "
\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 from vicidial_lists_fields where list_id='$list_id' order by field_rank,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 from vicidial_lists_fields where list_id='$list_id' order by field_rank,field_order,field_label;"; $rslt=mysql_query($stmt, $link); $fields_to_print = mysql_num_rows($rslt); $fields_list=''; @@ -748,6 +836,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) $A_field_required[$o] = $rowx[12]; $A_multi_position[$o] = $rowx[13]; $A_name_position[$o] = $rowx[14]; + $A_field_order[$o] = $rowx[15]; $o++; $rank_select .= ""; @@ -774,7 +863,7 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) {$bgcolor='bgcolor="#B9CBFD"';} else {$bgcolor='bgcolor="#9BB9FB"';} - echo ""; + echo ""; echo ""; echo ""; echo ""; @@ -805,19 +894,31 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) {echo "";} $o=0; + $last_field_rank=0; while ($fields_to_print > $o) { - echo "\n"; + echo "";} + { + if ($last_field_rank=="$A_field_rank[$o]") + {echo "  ";} + else + {echo "\n"; + echo " $field_HTML\n"; } + $last_field_rank=$A_field_rank[$o]; $o++; } - echo "
$A_field_rank[$o]    
$A_field_rank[$o] - $A_field_order[$o]     $A_field_label[$o]     $A_field_name[$o]     $A_field_type[$o]    
There are no custom fields for this list
"; + { + echo "
"; + } echo "$A_field_name[$o]"; if ($A_name_position[$o]=='TOP') {echo "     help+
";} else - {echo "
";} + } $field_HTML=''; if ($A_field_type[$o]=='SELECT') @@ -936,15 +1037,18 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) } if ($A_name_position[$o]=='LEFT') - {echo " $field_HTML   help+";} + { + echo " $field_HTML   help+"; + } else { - echo " $field_HTML


\n"; + echo "

\n"; ### MODIFY FIELDS ### @@ -968,7 +1072,15 @@ if ( ($action == "MODIFY_CUSTOM_FIELDS") and ($list_id > 99) ) echo "Field Rank $A_field_rank[$o]:   $NWB#vicidial_lists_fields-field_rank$NWE \n"; + echo "   $NWB#vicidial_lists_fields-field_rank$NWE \n"; + echo "         Field Order:   $NWB#vicidial_lists_fields-field_order$NWE \n"; echo "Field Name $A_field_rank[$o]: $NWB#vicidial_lists_fields-field_name$NWE \n"; echo "Field Name Position $A_field_rank[$o]: \n"; echo "$rank_select\n"; echo "\n"; - echo "   $NWB#vicidial_lists_fields-field_rank$NWE \n"; + echo "   $NWB#vicidial_lists_fields-field_rank$NWE \n"; + echo "         Field Order:   $NWB#vicidial_lists_fields-field_order$NWE \n"; echo "Field Label: $NWB#vicidial_lists_fields-field_label$NWE \n"; echo "Field Name: $NWB#vicidial_lists_fields-field_name$NWE \n"; echo "Field Name Position: