{= # # # This template is invoked from the user agent GUI only (URL request) # It is the central entry point for URL requests # # include "templates.util.base_util"; include "templates.util.html"; include "templates.util.encoding"; include "templates.statistics.dynamic_reports.assemble_report_page"; include "templates.statistics.dynamic_reports.assemble_standby_page"; include "templates.statistics.dynamic_reports.assemble_no_permission_page"; include "templates.statistics.util.get_default_report_name"; include "templates.statistics.util.get_url_composition_id"; include "templates.statistics.filters.zoom.create_zoom_filters"; debug_message("\n\n\n#### #### reports.cfv START \n"); debug_message("\n\n" . node_as_string("command_line") . "\n"); # # # CONTROL FLOW # # # # GENERAL CHECKS # # # 1. Session timed out # # --> Show log in page # # 2. User has no permission to view this profile or report # # --> Show no permission page # # # 3. The specified profile or report does not exist # # --> Show alert page # # # 4. The database does not exist or is just building or updating # # --> Show database progress THIS HAS BEEN MOVED to request_report.cfv! # # 5. Another report task is already active # # --> As it should be possible to view reports in multiple # web browser windows or tabs per user we shouldn't cancel # any active report task. # # # # # URL HANDLING # # Note, we expect any URL to be complete at this point. This means we don't add # any default date_filter or any other default value to the URL in this page # because in many cases we don't know the source of the URL. The URL source # could be the Admin interface, a bookmark or a URL link on a customer page. # That means that i.e. a default date_time filter has to be part of the URL. # (For the admin profiles page we have to add default date_time filters, if any, # to the URL!) # # One exception for URL completeness is the report_name, it can be omitted. In this # case we add the default report to the URL. # # # URL TYPES # # # 1. Fresh URL (with or without report_name) # # --> Show report progress (Loading info only, no progress) # Show an immediate loading page and generate the # report_job_id and report in the background, # as we do for any report request background call. # # 2. Preset URL # This report has been created via a background server call from the reports GUI. # The URL has been preset in the background just before sending the URL. # The checksum of the preset URL is associated with a report_job_id, this # report is ready to go # # --> Assemble the report # # # Session & URL based log-in handling # # string session_id = volatile.session_id; debug_message("\n\n#### session_id: " . session_id . "\n\n"); # # # Profile # # string profile_name = command_line.profile; node profiles = "profiles"; node profile = profiles{profile_name}; string profile_label = @profile{"label"}; # debug_message("\n\n#### profile_name: " . profile_name . "\n\n"); # # # # # # Set general variables # # # # # # # # Check for number of licensed profiles # # # handle_valid_number_of_profiles(profiles); # # # # # Check RBAC permissions # # # # bool is_root_admin = get_is_root_admin(); bool is_access_reports = is_root_admin; # Set default super_role node session_info = new_node(); node super_role = new_node(); if (!is_root_admin) then ( # # Check if the user has permission to access the reports of this profile # session_info = "sessions_cache." . session_id . ".session_info"; is_access_reports = get_access_reports_permission(session_id, profile_name); if (is_access_reports) then ( # # Get the super role of this profile which is required when assembling the report page # super_role = get_super_role_of_profile(session_id, profile_name); ); ); if (is_access_reports) then ( # # # Handle web_browser_session_id # # string web_browser_session_id = command_line.web_browser_session_id; # # # # # # Set report variables # # # # # bool is_calendar = command_line.calendar; string url_report_name = command_line.report_name; string report_name = url_report_name; string zoom_info_id = command_line.zoom_info_id; bool is_zoom_items = (!is_calendar and (zoom_info_id != "")); string date_filter = command_line.date_filter; string command_line_filter = command_line.filters; string command_line_filter_comment = command_line.filters_comment; string filter_id = command_line.filter_id; string report_info_id = command_line.report_info_id; string report_job_id; if (!is_calendar and (report_name eq "")) then ( report_name = get_default_report_name(profile_name, true); ); string session_profile_path = "sessions_cache." . session_id . ".profiles." . profile_name; # # # # Check if this is a report which has been zoomed into a new tab or window # # # if (is_zoom_items) then ( # Create new date_filter and/or filters from zoom_info and # override any date_filter and/or filters given in the URL if (?(session_profile_path . ".zoom_infos." . zoom_info_id)) then ( node zoom_info = session_profile_path . ".zoom_infos." . zoom_info_id; node zoom_info_result = create_zoom_filters(session_id, is_root_admin, profile_name, zoom_info); if (@zoom_info_result{"date_filter"} ne "") then ( date_filter = @zoom_info_result{"date_filter"}; ); if (@zoom_info_result{"filter_id"} ne "") then ( filter_id = @zoom_info_result{"filter_id"}; ); ); ) else ( # if not is_zoom_items # # # # # # Check if this is a preset report page or standby page # # # # # string report_task_id; bool is_ready_report = false; # Note, an empty url_report_name is allowed because we want to keep the original # URL without any report name if the url doesn't contain one at the initial request. string url_composition_id = get_url_composition_id( profile_name, url_report_name, date_filter, command_line_filter, command_line_filter_comment, filter_id, report_info_id, is_calendar, web_browser_session_id ); debug_message("\n\n#### reports.cfv, url_composition_id: " . url_composition_id . "\n\n"); # debug_message("\n\n#### session_profile_path: " . session_profile_path . "\n\n"); # Note, the subnode "preset_time" only exists as long as the # preset_node has not been validated at this point. It will be deleted # for the first request where we match the url_composition_id. # DEBUG_BEGIN # if (?(session_profile_path . "." . url_composition_id)) then ( # # debug_message("#### url_composition_id path exists: YES \n"); # debug_message("\n" . node_as_string(session_profile_path . "." . url_composition_id) . "\n"); # ) # else ( # # debug_message("#### url_composition_id path exists: NO \n"); # ); # DEBUG_END if (?(session_profile_path . "." . url_composition_id . ".preset_time")) then ( node preset_node = session_profile_path . "." . url_composition_id; int preset_time = @preset_node{"preset_time"}; if ((now() - preset_time) < 20) then ( report_job_id = @preset_node{"report_job_id"}; is_ready_report = @preset_node{"is_ready_report"}; if (!is_ready_report) then ( report_task_id = @preset_node{"report_task_id"}; ); ); # Delete the "preset_time" subnode which indicates that the preset url is out of date! delete_node(preset_node{"preset_time"}); save_node(preset_node); ); debug_message("\n\n#### reports.cfv - report_job_id: " . report_job_id . "\n"); debug_message("#### reports.cfv - report_task_id: " . report_task_id . "\n"); debug_message("#### reports.cfv - is_ready_report: " . is_ready_report . "\n"); ); string report_label; if (!is_calendar) then ( report_label = string_to_html(get_expanded_label(@(profile . ".statistics.reports." . report_name . ".label"))); ) else ( report_label = string_to_html(lang_stats.calendar.label); ); string page_title = string_to_html(profile_label) . " - " . report_label; if (is_ready_report) then ( # # # Assemble the report page # # debug_message("\n\n#### report.cfv - REPORT IS READY - start assemble_report_page() \n\n\n"); debug_message("\n\n#### reports.cfv - session_id: " . session_id . "\n"); debug_message("#### reports.cfv - is_root_admin: " . is_root_admin . "\n"); debug_message("#### reports.cfv - super_role: " . node_as_string(super_role) . "\n"); debug_message("#### reports.cfv - profile_name: " . profile_name . "\n"); debug_message("#### reports.cfv - profile_label: " . profile_label . "\n"); debug_message("#### reports.cfv - report_job_id: " . report_job_id . "\n"); debug_message("#### reports.cfv - page_title: " . page_title . "\n"); assemble_report_page( session_id, web_browser_session_id, is_root_admin, session_info, super_role, profile_name, profile_label, report_name, report_job_id, page_title ); ) else ( # # # Assemble the standby page # # debug_message("#### report.cfv - REPORT IS NOT READY - start assemble_standby_page() \n"); assemble_standby_page( session_id, web_browser_session_id, is_root_admin, profile_name, profile_label, url_report_name, report_name, is_calendar, date_filter, command_line_filter, command_line_filter_comment, filter_id, report_info_id, report_job_id, report_task_id, page_title ); ); ) # if is_access_reports else ( assemble_no_permission_page(profile_name, profile_label); ); debug_message("\n\n\n#### reports.cfv END \n\n\n"); =}