- my ($sql,$type,$name,$notes) = get_saved_report($report);
- unless ($sql) {
- push @errors, {no_sql_for_id=>$report};
- }
- my @rows = ();
- # if we have at least 1 parameter, and it's not filled, then don't execute but ask for parameters
- if ($sql =~ /<</ && !@sql_params) {
- # split on ??. Each odd (2,4,6,...) entry should be a parameter to fill
- my @split = split /<<|>>/,$sql;
- my @tmpl_parameters;
- for(my $i=0;$i<($#split/2);$i++) {
- my ($text,$authorised_value) = split /\|/,$split[$i*2+1];
- my $input;
- if ($authorised_value) {
- my $dbh=C4::Context->dbh;
- my @authorised_values;
- my %authorised_lib;
- # builds list, depending on authorised value...
- if ( $authorised_value eq "branches" ) {
- my $branches = GetBranchesLoop();
- foreach my $thisbranch (@$branches) {
- push @authorised_values, $thisbranch->{value};
- $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname};
+
+ $template->param(
+ 'limit' => $limit,
+ 'report_id' => $report_id,
+ );
+
+ my ( $sql, $type, $name, $notes );
+ if (my $report = get_saved_report($report_id)) {
+ $sql = $report->{savedsql};
+ $name = $report->{report_name};
+ $notes = $report->{notes};
+
+ my @rows = ();
+ # if we have at least 1 parameter, and it's not filled, then don't execute but ask for parameters
+ if ($sql =~ /<</ && !@sql_params) {
+ # split on ??. Each odd (2,4,6,...) entry should be a parameter to fill
+ my @split = split /<<|>>/,$sql;
+ my @tmpl_parameters;
+ my @authval_errors;
+ for(my $i=0;$i<($#split/2);$i++) {
+ my ($text,$authorised_value) = split /\|/,$split[$i*2+1];
+ my $input;
+ my $labelid;
+ if ( not defined $authorised_value ) {
+ # no authorised value input, provide a text box
+ $input = "text";
+ } elsif ( $authorised_value eq "date" ) {
+ # require a date, provide a date picker
+ $input = 'date';
+ } else {
+ # defined $authorised_value, and not 'date'
+ my $dbh=C4::Context->dbh;
+ my @authorised_values;
+ my %authorised_lib;
+ # builds list, depending on authorised value...
+ if ( $authorised_value eq "branches" ) {
+ my $branches = GetBranchesLoop();
+ foreach my $thisbranch (@$branches) {
+ push @authorised_values, $thisbranch->{value};
+ $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname};
+ }