use C4::Auth qw(check_cookie_auth);
use C4::Biblio qw(GetMarcBiblio GetFrameworkCode GetRecordValue );
-use C4::Branch qw(GetBranchName);
use C4::Charset;
use C4::Circulation qw(GetTransfers);
use C4::Context;
-use Koha::Database;
use Koha::DateUtils;
+use Koha::Holds;
+use Koha::ItemTypes;
+use Koha::Libraries;
my $input = new CGI;
my $offset = $input->param('iDisplayStart');
my $results_per_page = $input->param('iDisplayLength');
my $sorting_direction = $input->param('sSortDir_0') || 'desc';
-my $sorting_column = $sort_columns[ $input->param('iSortCol_0') ]
- || 'reservedate';
+my $iSortCol = $input->param('iSortCol_0') // 0;
+my $sorting_column = $sort_columns[$iSortCol] // 'reservedate';
binmode STDOUT, ":encoding(UTF-8)";
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
-my $holds_rs = $schema->resultset('Reserve')->search(
+my $holds_rs = Koha::Holds->search(
{ borrowernumber => $borrowernumber },
{
- prefetch => { 'item' => 'biblio' },
order_by => { "-$sorting_direction" => $sorting_column }
}
);
my $biblionumber = $h->biblio()->biblionumber();
+ my $itemtype_limit;
+ if ( $h->itemtype ) {
+ my $itemtype = Koha::ItemTypes->find( $h->itemtype );
+ $itemtype_limit = $itemtype->translated_description;
+ }
+
+ my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
+ for my $library ( @$libraries ) {
+ $library->{selected} = 1 if $library->{branchcode} eq $h->branchcode();
+ }
my $hold = {
DT_RowId => $h->reserve_id(),
biblionumber => $biblionumber,
title => $h->biblio()->title(),
author => $h->biblio()->author(),
reserve_id => $h->reserve_id(),
+ branchcode => $h->branch()->branchname(),
+ branches => $libraries,
reservedate => $h->reservedate(),
expirationdate => $h->expirationdate(),
suspend => $h->suspend(),
suspend_until => $h->suspend_until(),
found => $h->found(),
- waiting => $h->found() eq 'W',
- waiting_at => $h->branchcode()->branchname(),
- waiting_here => $h->branchcode()->branchcode() eq $branch,
+ waiting => $h->is_waiting(),
+ waiting_at => $h->branch()->branchname(),
+ waiting_here => $h->branch()->branchcode() eq $branch,
priority => $h->priority(),
+ itemtype_limit => $itemtype_limit,
subtitle => GetRecordValue(
- 'subtitle', GetMarcBiblio($biblionumber),
+ 'subtitle',
+ GetMarcBiblio({ biblionumber => $biblionumber }),
GetFrameworkCode($biblionumber)
),
reservedate_formatted => $h->reservedate() ? output_pref(
$hold->{color} = 'transferred';
$hold->{transferred} = 1;
$hold->{date_sent} = output_pref( dt_from_string($transferred_when) );
- $hold->{from_branch} = GetBranchName($transferred_from);
+ $hold->{from_branch} = Koha::Libraries->find($transferred_from)->branchname;
}
- elsif ( $item->holdingbranch()->branchcode() ne
- $h->branchcode()->branchcode() )
+ elsif ( $item->holding_branch() && $item->holding_branch()->branchcode() ne
+ $h->branch()->branchcode() )
{
$hold->{not_transferred} = 1;
- $hold->{not_transferred_by} = $h->item()->holdingbranch()->branchname();
+ $hold->{not_transferred_by} = $h->item()->holding_branch()->branchname();
}
}