From a03adb1762335f3840a288f1ccfcb1c4a20cf3cb Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 3 Dec 2018 18:00:41 +0100 Subject: [PATCH] add field group filter --- pandora_console/extras/mr/23.sql | 2 +- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 + .../include/ajax/custom_fields.php | 53 +++++++++++++++---- .../include/functions_custom_fields.php | 9 ++++ pandora_console/pandoradb.sql | 1 + 5 files changed, 57 insertions(+), 10 deletions(-) diff --git a/pandora_console/extras/mr/23.sql b/pandora_console/extras/mr/23.sql index e14f68a304..a602023e3b 100644 --- a/pandora_console/extras/mr/23.sql +++ b/pandora_console/extras/mr/23.sql @@ -1,6 +1,6 @@ START TRANSACTION; ---ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default ''; +ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `group_search` int(10) unsigned default '0'; ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default ''; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 5b81170b8c..5b98fdbec0 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1830,3 +1830,5 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default ''; ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `recursion` int(1) unsigned default '0'; + +ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `group_search` int(10) unsigned default '0'; diff --git a/pandora_console/include/ajax/custom_fields.php b/pandora_console/include/ajax/custom_fields.php index e06fb07980..d24dd88b40 100644 --- a/pandora_console/include/ajax/custom_fields.php +++ b/pandora_console/include/ajax/custom_fields.php @@ -32,6 +32,7 @@ $append_tab_filter = (bool)get_parameter('append_tab_filter', 0); $create_filter_cf = (bool)get_parameter('create_filter_cf', 0); $update_filter_cf = (bool)get_parameter('update_filter_cf', 0); $delete_filter_cf = (bool)get_parameter('delete_filter_cf', 0); +$change_name_filter = (bool)get_parameter('change_name_filter', 0); if ($get_custom_fields_data){ $name_custom_fields = get_parameter("name_custom_fields", 0); @@ -457,7 +458,7 @@ if($build_table_save_filter){ $table->id = 'save_filter_form'; $table->width = '100%'; $table->class = 'databox'; - + $array_filters = get_filters_custom_fields_view(0, true); $table->data[0][0] = __('Filter name'); $table->data[0][1] = html_print_select( @@ -465,9 +466,10 @@ if($build_table_save_filter){ '', '', '', '', true, false, true, '', false ); + $table->data[0][3] = html_print_submit_button (__('Load filter'), 'load_filter', false, 'class="sub upd"', true); - - echo "
"; + + echo ""; html_print_table($table); echo "
"; } @@ -486,7 +488,16 @@ if($append_tab_filter){ echo "
"; $table->data[0][0] = __('Filter name'); $table->data[0][1] = html_print_input_text('id_name', '', '', 15, 255, true); - $table->data[0][2] = html_print_submit_button (__('Create filter'), 'create_filter', false, 'class="sub upd"', true); + + $table->data[0][2] = __('Group'); + $table->data[0][3] = html_print_select_groups( + $config['id_user'], 'AR', true, 'group_search', + 0, '', '', '0', true, false, + false, '', false, '', false, false, + 'id_grupo', false + ); + + $table->data[0][4] = html_print_submit_button (__('Create filter'), 'create_filter', false, 'class="sub upd"', true); } else{ echo "
"; @@ -494,12 +505,22 @@ if($append_tab_filter){ $array_filters = get_filters_custom_fields_view(0, true); $table->data[0][0] = __('Filter name'); $table->data[0][1] = html_print_select( - $array_filters, 'id_name', - '', '', __('None'), -1, - true, false, true, '', false + $array_filters, 'id_name', '', + 'filter_name_change_group(this.value)', + __('None'), -1, true, false, true, + '', false ); + + $table->data[1][0] = __('Group'); + $table->data[1][1] = html_print_select_groups( + $config['id_user'], 'AR', true, 'group_search_up', + $group, '', '', '0', true, false, + false, '', false, '', false, false, + 'id_grupo', false + ); + $table->data[0][2] = html_print_submit_button (__('Delete filter'), 'delete_filter', false, 'class="sub upd"', true); - $table->data[0][3] = html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd"', true); + $table->data[1][2] = html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd"', true); } html_print_table($table); @@ -515,6 +536,7 @@ if($create_filter_cf){ //initialize vars $filters = json_decode(io_safe_output(get_parameter("filters", '')), true); $name_filter = get_parameter("name_filter", ''); + $group_search = get_parameter("group_search", 0); //check that the name is not empty if($name_filter == ''){ @@ -553,6 +575,7 @@ if($create_filter_cf){ //insert $values = array(); $values['name'] = $name_filter; + $values['group_search'] = $group_search; $values['id_group'] = $filters['group']; $values['id_custom_field'] = $filters['id_custom_fields']; $values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']); @@ -591,6 +614,7 @@ if($update_filter_cf){ //initialize vars $filters = json_decode(io_safe_output(get_parameter("filters", '')), true); $id_filter = get_parameter("id_filter", ''); + $group_search = get_parameter("group_search", 0); //check selected filter if($id_filter == -1){ @@ -621,6 +645,7 @@ if($update_filter_cf){ //array values update $values = array(); $values['id_group'] = $filters['group']; + $values['group_search'] = $group_search; $values['id_custom_field'] = $filters['id_custom_fields']; $values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']); $values['id_status'] = json_encode($filters['id_status']); @@ -697,7 +722,17 @@ if($delete_filter_cf){ return; } +if($change_name_filter){ + $id_filter = get_parameter("id_filter", 0); + if(isset($id_filter)){ + $res = get_group_filter_custom_field_view($id_filter); + echo json_encode($res); + return; + } + + return json_encode(false); +} -} \ No newline at end of file +} diff --git a/pandora_console/include/functions_custom_fields.php b/pandora_console/include/functions_custom_fields.php index 7b18fb0b0d..e22956adf1 100644 --- a/pandora_console/include/functions_custom_fields.php +++ b/pandora_console/include/functions_custom_fields.php @@ -533,4 +533,13 @@ function get_filters_custom_fields_view($id = 0, $for_select = false, $name = "" } return $result; } + +function get_group_filter_custom_field_view ($id){ + if(isset($id)){ + $res = db_get_row_filter('tagent_custom_fields_filter',array('id' => $id)); + return $res; + } + return false; +} + ?> \ No newline at end of file diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index aa2d2aedb4..054204d85a 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3373,5 +3373,6 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( `module_search` varchar(600) default '', `module_status` varchar(600) default '', `recursion` int(1) unsigned default '0', + `group_search` int(10) unsigned default '0', PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file