my $dbh = C4::Context->dbh;
my $sth;
my $input = new CGI;
-my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
+my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user(
{
template_name => "reserve/request.tmpl",
query => $input,
my $branches = GetBranches();
my $itemtypes = GetItemTypes();
-my $default = C4::Context->userenv->{branch};
-my @values;
-my %label_of;
-
-foreach my $branchcode ( sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches ) {
- push @values, $branchcode;
- $label_of{$branchcode} = $branches->{$branchcode}->{branchname};
+my $userbranch = '';
+if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+ $userbranch = C4::Context->userenv->{'branch'};
}
-my $CGIbranch = CGI::scrolling_list(
- -name => 'pickup',
- -id => 'pickup',
- -values => \@values,
- -default => $default,
- -labels => \%label_of,
- -size => 1,
- -multiple => 0,
- );
+
# Select borrowers infos
my $findborrower = $input->param('findborrower');
$findborrower = '' unless defined $findborrower;
$findborrower =~ s|,| |g;
my $borrowernumber_hold = $input->param('borrowernumber') || '';
-my $borrowerslist;
my $messageborrower;
my $warnings;
my $messages;
$borrowernumber_hold = $borrowers->[0]->{'borrowernumber'};
}
else {
- $borrowerslist = $borrowers;
+ $template->param( borrower_list => sort_borrowerlist($borrowers));
}
} else {
$messageborrower = "'$findborrower'";
$template->param( messageborrower => $messageborrower );
-my $CGIselectborrower;
-if ($borrowerslist) {
- my @values;
- my %labels;
-
- foreach my $borrower (
- sort {
- uc($a->{surname}
- . $a->{firstname}) cmp uc($b->{surname}
- . $b->{firstname})
- } @{$borrowerslist}
- )
- {
- push @values, $borrower->{borrowernumber};
-
- $labels{ $borrower->{borrowernumber} } = sprintf(
- '%s, %s ... (%s - %s) ... %s',
- $borrower->{surname} ||'', $borrower->{firstname} || '',
- $borrower->{cardnumber} || '', $borrower->{categorycode} || '',
- $borrower->{address} || '',
- );
- }
-
- $CGIselectborrower = CGI::scrolling_list(
- -name => 'borrowernumber',
- -values => \@values,
- -labels => \%labels,
- -size => 7,
- -multiple => 0,
- );
-}
-
# FIXME launch another time GetMember perhaps until
my $borrowerinfo = GetMember( borrowernumber => $borrowernumber_hold );
# if independent branches is on we need to check if the person can reserve
# for branches they arent logged in to
- if ( C4::Context->preference("IndependantBranches") ) {
+ if ( C4::Context->preference("IndependentBranches") ) {
if (! C4::Context->preference("canreservefromotherbranches")){
# cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
my $userenv = C4::Context->userenv;
$reserve{'barcode'} = $res->{'barcode'};
$reserve{'priority'} = $res->{'priority'};
$reserve{'lowestPriority'} = $res->{'lowestPriority'};
- $reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'});
$reserve{'optionloop'} = \@optionloop;
$reserve{'suspend'} = $res->{'suspend'};
$reserve{'suspend_until'} = $res->{'suspend_until'};
+
+ if ( C4::Context->preference('IndependentBranches') && $flags->{'superlibrarian'} != 1 ) {
+ $reserve{'branchloop'} = [ GetBranchDetail($res->{'branchcode'}) ];
+ } else {
+ $reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'});
+ }
+
push( @reserveloop, \%reserve );
}
my $time = time();
$template->param(
- CGIbranch => $CGIbranch,
-
+ branchloop => GetBranchesLoop($userbranch),
time => $time,
fixedRank => $fixedRank,
);
borrower_branchcode => $borrowerinfo->{'branchcode'},
);
}
- $template->param(CGIselectborrower => $CGIselectborrower) if defined $CGIselectborrower;
$biblioloopiter{biblionumber} = $biblionumber;
$biblioloopiter{title} = $dat->{title};
$template->param( biblioloop => \@biblioloop );
$template->param( biblionumbers => $biblionumbers );
-$template->param( DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar() );
if ($multihold) {
$template->param( multi_hold => 1 );
# printout the page
output_html_with_http_headers $input, $cookie, $template->output;
+
+sub sort_borrowerlist {
+ my $borrowerslist = shift;
+ my $ref = [];
+ push @{$ref}, sort {
+ uc( $a->{surname} . $a->{firstname} ) cmp
+ uc( $b->{surname} . $b->{firstname} )
+ } @{$borrowerslist};
+ return $ref;
+}