#!/usr/bin/perl require './jru-lib.pl'; #Return all schedule ids, based on report id sub get_schids{ my $report_name = $_[0]; my @rv; foreach my $schid (keys %schedules){ my %sched = %{$schedules{$schid}}; if($sched{'rep_id'} eq $report_name){ push(@rv, $schid); } } return sort @rv; } &ui_print_header(undef, $text{'reports_title'}, "", "dashboard", 0, 0); print $text{'reports_desc1'}.' '.get_jasper_home(); #load all reports %report_data = scan_for_reports(); %schedules = load_schedules(); my $counter = 0; my @tds = map { "width=".$_."%"} (10, 5, 5, 10, 5, 10, 30, 15, 10); my $crop_len = length(get_jasper_home().'/reports/'); foreach my $dirpath (sort keys %report_data){ my @files = @{$report_data{$dirpath}}; my $report_folder = substr($dirpath, $crop_len); print &ui_hidden_table_start('/'.$report_folder, undef, 2, 'dirpath'.$counter, 0); my $col_tbl = &ui_columns_start(['Name', 'Actions', 'SchID', 'Cron', 'Format', 'Datasource', 'Output', 'Email', 'Optional Params'], 100, 0, \@tds); foreach my $report_name (@files){ my $report_id = ($report_folder) ? $report_folder.'/'.$report_name : $report_folder.$report_name; my @schid_arr = get_schids($report_id); my $jrxml_link = ''.$report_name.""; if(scalar(@schid_arr) == 0){ my @cols; push(@cols, $jrxml_link); push(@cols, 'Add Schedule'); $col_tbl .= &ui_columns_row(\@cols, \@tds); next; } my $first_schid = 1; foreach my $schid (@schid_arr){ my @cols; my %sched = %{$schedules{$schid}}; my %report_files = get_all_reports($report_id, $sched{'rep_file'}); if($first_schid){ @cols = ($jrxml_link); #we show report name only on first schedule }else{ push(@cols, ''); } my @action_links = ('Add Schedule'); if(%report_files){ push(@action_links, 'Cleanup'); push(@action_links, 'Download'); } push(@cols, join(' ', @action_links)); $sched{'schid'} = ''.$schid.""; if($config{'report_ls'} == 1){ #to show all links at once if(%report_files){ my @file_links = map { ''.$_.''} sort keys %report_files; $sched{'rep_file'} = join('
', @file_links); } }elsif($config{'report_ls'} == 2){ $sched{'rep_file'} = 'Browse'; }else{ #to show most recent link if(%report_files){ my @rep_filenames = sort keys %report_files; my $most_recent = $rep_filenames[-1]; $sched{'rep_file'} = ''.$sched{'rep_file'}.''; } } $sched{'url_opt_params'} = join('
', split(/&/, $sched{'url_opt_params'})); push(@cols, ($sched{'schid'}, $sched{'cron'}, $sched{'rep_format'}, $sched{'rep_ds'}, $sched{'rep_file'}, $sched{'rep_rcpt'}, $sched{'url_opt_params'})); $col_tbl .= &ui_columns_row(\@cols, \@tds); $first_schid = 0; } #end foreach($schid) } #end foreach($report_name) $col_tbl .= &ui_columns_end(); print &ui_table_row($report_name, $col_tbl); print &ui_hidden_table_end('dirpath'.$counter); $counter = $counter + 1; } &ui_print_footer("", $text{'index_return'});