Fixed reserve report script
[koha.git] / readingrec.pl
index 7315dc3..3c1d3e5 100755 (executable)
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
+use C4::Auth;
 use C4::Output;
+use C4::Interface::CGI::Output;
 use CGI;
 use C4::Search;
 use HTML::Template;
+use C4::Date;
 my $input=new CGI;
 
 
@@ -39,36 +42,51 @@ if ($order2 eq ''){
   $order2="date_due desc";
 }
 my $limit=$input->param('limit');
-if ($limit eq 'full'){
+if ($limit eq 'full' || $limit eq 0){
   $limit=0;
 } else {
   $limit=50;
 }
 my ($count,$issues)=allissues($bornum,$order2,$limit);
 
-
-#print $input->header;
-#print startpage();
-#print startmenu('member');
-my $template = gettemplate("members/readingrec.tmpl");
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "members/readingrec.tmpl",
+                               query => $input,
+                               type => "intranet",
+                               authnotrequired => 0,
+                               flagsrequired => {borrowers => 1},
+                               debug => 1,
+                               });
 
 my @loop_reading;
 
 for (my $i=0;$i<$count;$i++){
        my %line;
+       if($i%2){
+               $line{'toggle'} = 1;
+       }
+       $line{biblionumber}=$issues->[$i]->{'biblionumber'};
        $line{title}=$issues->[$i]->{'title'};
        $line{author}=$issues->[$i]->{'author'};
-       $line{returndate}=$issues->[$i]->{'returndate'};
+       $line{classification} = $issues->[$i]->{'classification'};
+       $line{date_due}=format_date($issues->[$i]->{'date_due'});
+       $line{returndate}=format_date($issues->[$i]->{'returndate'});
        $line{volumeddesc}=$issues->[$i]->{'volumeddesc'};
        push(@loop_reading,\%line);
 }
-$template->param(title => $data->{'title'},
+
+$template->param(
+                                               biblionumber => $data->{'biblionumber'},
+                                               title => $data->{'title'},
                                                initials => $data->{'initials'},
                                                surname => $data->{'surname'},
                                                bornum => $bornum,
                                                limit => $limit,
+                                               firstname => $data->{'firstname'},
+                                               cardnumber => $data->{'cardnumber'},
+                                               showfulllink => ($count > 50),                                  
                                                loop_reading => \@loop_reading);
-print "Content-Type: text/html\n\n", $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;