add field group filter

This commit is contained in:
daniel 2018-12-03 18:00:41 +01:00
parent 0c27534ca3
commit a03adb1762
5 changed files with 57 additions and 10 deletions

View File

@ -1,6 +1,6 @@
START TRANSACTION; 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 ''; ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `module_status` varchar(600) default '';

View File

@ -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 `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 `recursion` int(1) unsigned default '0';
ALTER TABLE `tagent_custom_fields_filter` ADD COLUMN `group_search` int(10) unsigned default '0';

View File

@ -32,6 +32,7 @@ $append_tab_filter = (bool)get_parameter('append_tab_filter', 0);
$create_filter_cf = (bool)get_parameter('create_filter_cf', 0); $create_filter_cf = (bool)get_parameter('create_filter_cf', 0);
$update_filter_cf = (bool)get_parameter('update_filter_cf', 0); $update_filter_cf = (bool)get_parameter('update_filter_cf', 0);
$delete_filter_cf = (bool)get_parameter('delete_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){ if ($get_custom_fields_data){
$name_custom_fields = get_parameter("name_custom_fields", 0); $name_custom_fields = get_parameter("name_custom_fields", 0);
@ -465,6 +466,7 @@ if($build_table_save_filter){
'', '', '', '', '', '', '', '',
true, false, true, '', false true, false, true, '', false
); );
$table->data[0][3] = html_print_submit_button (__('Load filter'), 'load_filter', false, 'class="sub upd"', true); $table->data[0][3] = html_print_submit_button (__('Load filter'), 'load_filter', false, 'class="sub upd"', true);
echo "<form action='' method='post'>"; echo "<form action='' method='post'>";
@ -486,7 +488,16 @@ if($append_tab_filter){
echo "<div id='msg_error_create'></div>"; echo "<div id='msg_error_create'></div>";
$table->data[0][0] = __('Filter name'); $table->data[0][0] = __('Filter name');
$table->data[0][1] = html_print_input_text('id_name', '', '', 15, 255, true); $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{ else{
echo "<div id='msg_error_update'></div>"; echo "<div id='msg_error_update'></div>";
@ -494,12 +505,22 @@ if($append_tab_filter){
$array_filters = get_filters_custom_fields_view(0, true); $array_filters = get_filters_custom_fields_view(0, true);
$table->data[0][0] = __('Filter name'); $table->data[0][0] = __('Filter name');
$table->data[0][1] = html_print_select( $table->data[0][1] = html_print_select(
$array_filters, 'id_name', $array_filters, 'id_name', '',
'', '', __('None'), -1, 'filter_name_change_group(this.value)',
true, false, true, '', false __('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][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); html_print_table($table);
@ -515,6 +536,7 @@ if($create_filter_cf){
//initialize vars //initialize vars
$filters = json_decode(io_safe_output(get_parameter("filters", '')), true); $filters = json_decode(io_safe_output(get_parameter("filters", '')), true);
$name_filter = get_parameter("name_filter", ''); $name_filter = get_parameter("name_filter", '');
$group_search = get_parameter("group_search", 0);
//check that the name is not empty //check that the name is not empty
if($name_filter == ''){ if($name_filter == ''){
@ -553,6 +575,7 @@ if($create_filter_cf){
//insert //insert
$values = array(); $values = array();
$values['name'] = $name_filter; $values['name'] = $name_filter;
$values['group_search'] = $group_search;
$values['id_group'] = $filters['group']; $values['id_group'] = $filters['group'];
$values['id_custom_field'] = $filters['id_custom_fields']; $values['id_custom_field'] = $filters['id_custom_fields'];
$values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']); $values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']);
@ -591,6 +614,7 @@ if($update_filter_cf){
//initialize vars //initialize vars
$filters = json_decode(io_safe_output(get_parameter("filters", '')), true); $filters = json_decode(io_safe_output(get_parameter("filters", '')), true);
$id_filter = get_parameter("id_filter", ''); $id_filter = get_parameter("id_filter", '');
$group_search = get_parameter("group_search", 0);
//check selected filter //check selected filter
if($id_filter == -1){ if($id_filter == -1){
@ -621,6 +645,7 @@ if($update_filter_cf){
//array values update //array values update
$values = array(); $values = array();
$values['id_group'] = $filters['group']; $values['id_group'] = $filters['group'];
$values['group_search'] = $group_search;
$values['id_custom_field'] = $filters['id_custom_fields']; $values['id_custom_field'] = $filters['id_custom_fields'];
$values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']); $values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']);
$values['id_status'] = json_encode($filters['id_status']); $values['id_status'] = json_encode($filters['id_status']);
@ -697,6 +722,16 @@ if($delete_filter_cf){
return; 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);
}

View File

@ -533,4 +533,13 @@ function get_filters_custom_fields_view($id = 0, $for_select = false, $name = ""
} }
return $result; 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;
}
?> ?>

View File

@ -3373,5 +3373,6 @@ CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` (
`module_search` varchar(600) default '', `module_search` varchar(600) default '',
`module_status` varchar(600) default '', `module_status` varchar(600) default '',
`recursion` int(1) unsigned default '0', `recursion` int(1) unsigned default '0',
`group_search` int(10) unsigned default '0',
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8; ) ENGINE = InnoDB DEFAULT CHARSET=utf8;