- foreach my $it (keys %$issueslist) {
- my $issuedate = $issueslist->{$it}->{'timestamp'};
- $issuedate = substr($issuedate, 0, 8);
- if ($todaysdate == $issuedate) {
- push @todaysissues, $issueslist->{$it};
- } else {
- push @previousissues, $issueslist->{$it};
- }
- my $tcolor = '';
- my $pcolor = '';
- foreach my $book (sort {$b->{'timestamp'} <=> $a->{'timestamp'}} @todaysissues){
- my $dd = $book->{'date_due'};
- my $datedue = $book->{'date_due'};
- $dd=format_date($dd);
- $datedue=~s/-//g;
- if ($datedue < $todaysdate) {
- $dd="<font color=red>$dd</font>\n";
- }
- ($tcolor eq $linecolor1) ? ($tcolor=$linecolor2) : ($tcolor=$linecolor1);
- $book->{'dd'}=$dd;
- $book->{'tcolor'}=$tcolor;
- push @realtodayissues,$book;
- }
- ($tcolor eq $linecolor1) ? ($tcolor=$linecolor2) : ($tcolor=$linecolor1);
- $book->{'dd'}=$dd;
- $book->{'tcolor'}=$tcolor;
- push @realtodayissues,$book
-}
- # FIXME - For small and private libraries, it'd be nice if this
- # table included a "Return" link next to each book, so that you
- # don't have to remember the book's bar code and type it in on the
- # "Returns" page.
-
- # This is in the template now, so its possible for a small library to make that link in their
- # template
-
- foreach my $book (sort {$a->{'date_due'} cmp $b->{'date_due'}} @previousissues){
- my $dd = $book->{'date_due'};
- my $datedue = $book->{'date_due'};
- $dd=format_date($dd);
- $datedue=~s/-//g;
- if ($datedue < $todaysdate) {
- $dd="<font color=red>$dd</font>\n";
- }
+
+ # split in 2 arrays for today & previous
+ my $dbh = C4::Context->dbh;
+ foreach my $it ( keys %$issueslist ) {
+ my $issuedate = $issueslist->{$it}->{'timestamp'};
+ $issuedate =~ s/-//g;
+ $issuedate = substr( $issuedate, 0, 8 );
+
+ # to let perl sort this correctly
+ $issueslist->{$it}->{'timestamp'} =~ s/(-|\:| )//g;
+
+ if ( $todaysdate == $issuedate ) {
+ (
+ $issueslist->{$it}->{'charge'},
+ $issueslist->{$it}->{'itemtype_charge'}
+ )
+ = calc_charges(
+ $dbh,
+ $issueslist->{$it}->{'itemnumber'},
+ $borrower->{'borrowernumber'}
+ );
+ $issueslist->{$it}->{'charge'} =
+ sprintf( "%.2f", $issueslist->{$it}->{'charge'} );
+ (
+ $issueslist->{$it}->{'can_renew'},
+ $issueslist->{$it}->{'can_renew_error'}
+ )
+ = renewstatus(
+ \%env,
+ $borrower->{'borrowernumber'},
+ $issueslist->{$it}->{'itemnumber'}
+ );
+ my ( $restype, $reserves ) =
+ CheckReserves( $issueslist->{$it}->{'itemnumber'} );
+ if ($restype) {
+ $issueslist->{$it}->{'can_renew'} = 0;
+ }
+ push @todaysissues, $issueslist->{$it};
+ }
+ else {
+ (
+ $issueslist->{$it}->{'charge'},
+ $issueslist->{$it}->{'itemtype_charge'}
+ )
+ = calc_charges(
+ $dbh,
+ $issueslist->{$it}->{'itemnumber'},
+ $borrower->{'borrowernumber'}
+ );
+ $issueslist->{$it}->{'charge'} =
+ sprintf( "%.2f", $issueslist->{$it}->{'charge'} );
+ (
+ $issueslist->{$it}->{'can_renew'},
+ $issueslist->{$it}->{'can_renew_error'}
+ )
+ = renewstatus(
+ \%env,
+ $borrower->{'borrowernumber'},
+ $issueslist->{$it}->{'itemnumber'}
+ );
+ my ( $restype, $reserves ) =
+ CheckReserves( $issueslist->{$it}->{'itemnumber'} );
+ if ($restype) {
+ $issueslist->{$it}->{'can_renew'} = 0;
+ }
+ push @previousissues, $issueslist->{$it};
+ }
+ }
+ my $od; # overdues
+ my $i = 0;
+ my $togglecolor;
+
+ # parses today & build Template array
+ foreach my $book ( sort { $b->{'timestamp'} <=> $a->{'timestamp'} }
+ @todaysissues )
+ {
+ #warn "TIMESTAMP".$book->{'timestamp'};
+ # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
+ $issued_itemtypes_count->{ $book->{'itemtype'} }++;
+
+ my $dd = $book->{'date_due'};
+ my $datedue = $book->{'date_due'};
+
+ #$dd=format_date($dd);
+ $datedue =~ s/-//g;
+ if ( $datedue < $todaysdate ) {
+ $od = 1;
+ }
+ else {
+ $od = 0;
+ }
+ if ( $i % 2 ) {
+ $togglecolor = 0;
+ }
+ else {
+ $togglecolor = 1;
+ }
+ $book->{'togglecolor'} = $togglecolor;
+ $book->{'od'} = format_date($od);
+ $book->{'dd'} = format_date($dd);
+ if ( $book->{'author'} eq '' ) {
+ $book->{'author'} = ' ';
+ }
+ push @realtodayissues, $book;
+ $i++;
+ }
+
+ # parses previous & build Template array
+ $i = 0;
+ foreach my $book ( sort { $a->{'date_due'} cmp $b->{'date_due'} }
+ @previousissues )
+ {
+
+ # ADDED BY JF: NEW ITEMTYPE COUNT DISPLAY
+ $issued_itemtypes_count->{ $book->{'itemtype'} }++;
+
+ my $dd = format_date($book->{'date_due'});
+ my $datedue = format_date($book->{'date_due'});
+
+ #$dd=format_date($dd);
+ my $pcolor = '';
+ my $od = '';
+ $datedue =~ s/-//g;
+ if ( $datedue < $todaysdate ) {
+ $od = 1;
+ }
+ else {
+ $od = 0;
+ }
+ if ( $i % 2 ) {
+ $togglecolor = 0;
+ }
+ else {
+ $togglecolor = 1;
+ }
+ $book->{'togglecolor'} = $togglecolor;
+ $book->{'dd'} = $dd;
+ $book->{'od'} = $od;
+ if ( $book->{'author'} eq '' ) {
+ $book->{'author'} = ' ';
+ }
+ push @realprevissues, $book;
+ $i++;
+ }