Fix overdue list if you do not specify a branchcode.
[koha_fer] / circ / overdue.pl
index 8373908..3797926 100755 (executable)
@@ -25,6 +25,7 @@ use CGI;
 use C4::Auth;
 use C4::Branch;
 use C4::Dates qw/format_date/;
+use Date::Calc qw/Today/;
 
 my $input = new CGI;
 my $type    = $input->param('type');
@@ -55,7 +56,8 @@ my $dbh = C4::Context->dbh;
 # download the complete CSV
 if ($op eq 'csv') {
 warn "BRANCH : $branchfilter";
-    my $csv = `../misc/cronjobs/overduenotices-csv.pl -c -n -b $branchfilter`;
+    my $lib = $branchfilter ? "-library $branchfilter" :'';
+    my $csv = `../misc/cronjobs/overdue_notices.pl -csv -n $lib`;
     print $input->header(-type => 'application/vnd.sun.xml.calc',
                         -encoding    => 'utf-8',
                         -attachment=>"overdues.csv",
@@ -93,16 +95,6 @@ my $onlymine=C4::Context->preference('IndependantBranches') &&
              C4::Context->userenv->{branch};
 my $branches = GetBranches($onlymine);
 my @branchloop;
-my @selectflags;
-push @selectflags, " ";#
-push @selectflags,"gonenoaddress";#
-push @selectflags,"debarred";#
-push @selectflags,"lost";#
-my $CGIflags=CGI::scrolling_list( -name     => 'borflags',
-            -id =>'borflags',
-            -values   => \@selectflags,
-            -size     => 1,
-            -multiple => 0 );
 
 foreach my $thisbranch ( sort keys %$branches ) {
      my %row = (
@@ -119,7 +111,6 @@ $template->param( branchloop => \@branchloop,
 $template->param(borcatloop=> \@borcatloop,
           itemtypeloop => \@itemtypeloop,
           branchloop=> \@branchloop,
-          CGIflags     => $CGIflags,
           borname => $bornamefilter,
           order => $order,
           showall => $showall);
@@ -135,12 +126,8 @@ my $phone;
 my $email;
 my $title;
 my $author;
-my @datearr    = localtime( time() );
-my $todaysdate =
-    ( 1900 + $datearr[5] ) . '-'
-  . sprintf( "%0.2d", ( $datearr[4] + 1 ) ) . '-'
-  . sprintf( "%0.2d", $datearr[3] );
 
+my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", Today());
 
 $bornamefilter =~s/\*/\%/g;
 $bornamefilter =~s/\?/\_/g;
@@ -208,7 +195,7 @@ while (my $data=$sth->fetchrow_hashref) {
 }
 
 $template->param(
-    todaysdate  => $todaysdate,
+    todaysdate  => format_date($todaysdate),
     overdueloop => \@overduedata
 );