$name, 'display_on_front' => $display_on_front, 'is_password_type' => $is_password_type, 'combo_values' => $combo_values, ] ); ui_print_success_message(__('Field successfully created')); } } // Update field. if ($update_field) { // Check if name field is empty. if ($name != '') { $values = [ 'name' => $name, 'display_on_front' => $display_on_front, 'is_password_type' => $is_password_type, 'combo_values' => $combo_values, ]; $result = db_process_sql_update('tagent_custom_fields', $values, ['id_field' => $id_field]); } else { $result = false; } if ($result !== false) { ui_print_success_message(__('Field successfully updated')); } else { ui_print_error_message(__('There was a problem modifying field')); } } // Delete field. if ($delete_field) { $result = db_process_sql_delete( 'tagent_custom_fields', ['id_field' => $id_field] ); if (!$result) { ui_print_error_message(__('There was a problem deleting field')); } else { ui_print_success_message(__('Field successfully deleted')); } } // Prepare pagination. $offset = (int) get_parameter('offset'); $limit = $config['block_size']; $count_fields = db_get_value('count(*)', 'tagent_custom_fields'); $fields = db_get_all_rows_filter( 'tagent_custom_fields', [ 'limit' => $limit, 'offset' => $offset, ] ); $table = new stdClass(); $table->width = '100%'; $table->class = 'info_table'; if ($fields) { $table->head = []; $table->head[0] = __('ID'); $table->head[1] = __('Field'); $table->head[2] = __('Display on front').ui_print_help_tip(__('The fields with display on front enabled will be displayed into the agent details'), true); $table->head[3] = __('Actions'); $table->align = []; $table->align[0] = 'left'; $table->align[2] = 'left'; $table->align[3] = 'left'; $table->size[3] = '8%'; $table->data = []; } else { include_once $config['homedir'].'/general/first_task/fields_manager.php'; return; } if ($fields === false) { $fields = []; } foreach ($fields as $field) { $data[0] = $field['id_field']; $data[1] = ''.$field['name'].''; if ($field['display_on_front']) { $data[2] = html_print_image('images/tick.png', true); } else { $data[2] = html_print_image('images/icono_stop.png', true, ['style' => 'width:21px;height:21px;']); } $table->cellclass[][3] = 'action_buttons'; $data[3] = ''.html_print_image('images/config.png', true, ['alt' => __('Edit'), 'title' => __('Edit'), 'border' => '0']).''; $data[3] .= ''.html_print_image('images/cross.png', true, ['alt' => __('Delete'), 'title' => __('Delete'), 'border' => '0']).''; array_push($table->data, $data); } if ($fields) { ui_pagination($count_fields, false, $offset); html_print_table($table); ui_pagination($count_fields, false, $offset, 0, false, 'offset', true, 'pagination-bottom'); } echo '
'; echo '
'; html_print_submit_button(__('Create field'), 'crt', false, 'class="sub next"'); echo '
'; echo '
';