Bug 11559: (QA followup) fix several small issues
[koha.git] / svc / checkouts
index cfd42dc..cc703ae 100755 (executable)
@@ -94,6 +94,7 @@ my $sql = '
 
         itemlost,
         damaged,
+        location,
 
         DATEDIFF( issuedate, CURRENT_DATE() ) AS not_issued_today
     FROM issues
@@ -151,6 +152,7 @@ while ( my $c = $sth->fetchrow_hashref() ) {
         barcode    => $c->{barcode},
         itemtype   => $item_level_itypes ? $c->{itype} : $c->{itemtype},
         itemtype_description => $item_level_itypes ? $c->{itype_description} : $c->{itemtype_description},
+        location   => $c->{location} ? GetAuthorisedValueByCode( 'LOC', $c->{location} ) : q{},
         itemnotes  => $c->{itemnotes},
         branchcode => $c->{branchcode},
         branchname => $c->{branchname},
@@ -207,13 +209,21 @@ while ( my $c = $sth->fetchrow_hashref() ) {
     }
 }
 
+
+@checkouts_today = sort { $a->{timestamp} cmp $b->{timestamp} } @checkouts_today;
 @checkouts_today = reverse(@checkouts_today)
-  if ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' );
+  unless ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' );
+
+@checkouts_previous = sort { $a->{date_due} cmp $b->{date_due} } @checkouts_previous;
 @checkouts_previous = reverse(@checkouts_previous)
   if ( C4::Context->preference('previousIssuesDefaultSortOrder') eq 'desc' );
 
 my @checkouts = ( @checkouts_today, @checkouts_previous );
 
+my $i = 1;
+map { $_->{sort_order} = $i++ } @checkouts;
+
+
 my $data;
 $data->{'iTotalRecords'}        = scalar @checkouts;
 $data->{'iTotalDisplayRecords'} = scalar @checkouts;