Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 633 lines (590 sloc) 28.1 KB
#!/usr/bin/perl
# Copyright 2000-2010 LibLime
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use warnings;
use CGI;
use C4::Output;
use C4::Print;
use C4::Auth qw/:DEFAULT get_session/;
use C4::Dates qw/format_date/;
use C4::Branch; # GetBranches
use C4::Koha; # GetPrinter
use C4::Circulation qw/:DEFAULT circ_exception_permissions get_circ_exceptions/;
use C4::Members;
use C4::ProxyRelationships qw/GetProxyRelationships/;
use C4::Biblio;
use C4::Reserves;
use C4::Context;
use C4::Debug;
use CGI::Session;
use Data::Dumper;
my $query = new CGI;
my $sessionID = $query->cookie("CGISESSID");
my $session = get_session($sessionID);
if (!C4::Context->userenv){
if ($session->param('branch') eq 'NO_LIBRARY_SET'){
# no branch set we can't issue
print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
exit;
}
}
my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
{
template_name => 'circ/circulation.tmpl',
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { circulate => 'circulate_remaining_permissions' },
}
);
my $branches = GetBranches();
my @failedrenews = $query->param('failedrenew'); # expected to be itemnumbers, passed from reserve/renewscript.pl
my %renew_failed;
for (@failedrenews) { $renew_failed{$_} = 1; }
my $findborrower = $query->param('findborrower') || '';
$findborrower =~ s|,| |g;
my $borrowernumber = $query->param('borrowernumber');
my $proxy_borrowernumber = $query->param('proxy_borrowernumber');
my $barcode = $query->param('barcode') || '';
my $or_barcode = $query->param('or_barcode');
if ($or_barcode && !$barcode) {
$barcode = $or_barcode;
}
$barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
$barcode = barcodedecode($barcode) if( $barcode && (C4::Context->preference('itemBarcodeInputFilter') || C4::Context->preference('itembarcodelength')));
my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate');
my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate');
my $cancelreserve = $query->param('cancelreserve');
my $organisation = $query->param('organisations');
my $newexpiry = $query->param('dateexpiry');
my $branch = C4::Context->userenv->{'branch'};
my $permissions = C4::Context->userenv->{'permissions'};
my $borrowerslist;
my $no_patron_found;
if ($findborrower && ! $borrowernumber) {
my ($count, $borrowers) = SearchMember($findborrower, 'cardnumber', 'web');
if ( scalar @$borrowers == 0 ) {
$query->param( 'findborrower', '' );
$no_patron_found = "'$findborrower'";
} elsif ( scalar @$borrowers == 1 ) {
$borrowernumber = $borrowers->[0]->{'borrowernumber'};
} else {
$borrowerslist = $borrowers;
}
}
my @new_overrides = ($query->param('overridden_blocks')) ? split(',',$query->param('overridden_blocks')) : ();
my $overridden_blocks = {};
for (@new_overrides) {
$overridden_blocks->{$_} = 1;
}
# my @new_confirmed = ($query->param('confirmed_blocks')) ? split(',',$query->param('confirmed_blocks')) : ();
# manage circ_session ( certain overrides should remain valid for the duration of a 'circ session',
# defined as repeated actions on the same patron (e.g. checking out several items) )
my $session_overrides = $session->param('circ_overrides') || [];
# my $confirmed = $session->param('circ_confirmed') || [];
my @overrides = @$session_overrides;
$debug and warn "new overrides: " . join(',',@new_overrides);
$debug and warn "session overrides: " . join(',',@overrides);
my $patron_exceptions = get_circ_exceptions('patron');
# FIXME : This is inefficient way to ignore overrides that shouldn't be stored in session.
if($borrowernumber && $session->param('circ_context')
&& $session->param('circ_context') eq 'circulation.pl'
&& $session->param('circ_borrower') == $borrowernumber){
# if we have new overrides, store them in session.
my $update_overrides = 0;
for my $new_or (@new_overrides) {
unless( grep { $_ eq $new_or } @overrides ){
push @overrides, $new_or;
# only store patron-level block overrides in the session.
if( grep { $_ eq $new_or } keys %$patron_exceptions ){
push @$session_overrides, $new_or;
$update_overrides = 1;
}
}
}
if($update_overrides){
# this seems to be unnecessary, as CGI::Session->param returns a reference, so modifying it will update the session when $session goes out of scope.
$session->param('circ_overrides', $session_overrides);
}
$session->flush() if($update_overrides);
} else {
# new circ session.
# FIXME: if a user leaves circulation.pl and returns, it should end the session. (it doesn't)
$session->param('circ_context', 'circulation.pl');
$session->param('circ_borrower', $borrowernumber);
$session->clear('circ_overrides');
$session->clear('temp_permissions');
}
# was stickyduedate loaded from session but subsequently turned off?
if ( $stickyduedate && ! $query->param("stickyduedate") ) {
$session->clear('stickyduedate');
$stickyduedate = $query->param('stickyduedate');
$duedatespec = $query->param('duedatespec');
}
my ($datedue,$invalidduedate,$globalduedate);
if(C4::Context->preference('globalDueDate') && (C4::Context->preference('globalDueDate') =~ C4::Dates->regexp('syspref'))){
# FIXME: Would be cleaner to deprecate globalDueDate now that Term loans are available.
$globalduedate = C4::Dates->new(C4::Context->preference('globalDueDate'));
}
my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
if($duedatespec_allow){
if ($duedatespec) {
if ($duedatespec =~ C4::Dates->regexp('syspref')) {
my $tempdate = C4::Dates->new($duedatespec);
if ($tempdate and $tempdate->output('iso') gt C4::Dates->new()->output('iso')) {
# i.e., it has to be later than today/now
$datedue = $tempdate;
} else {
$invalidduedate = $duedatespec;
}
} else {
$invalidduedate = $duedatespec;
}
} else {
# pass global due date to tmpl if specifyduedate is true
# and we have no barcode (loading circ page but not checking out)
if($globalduedate && ! $barcode ){
$duedatespec = $globalduedate->output();
$stickyduedate = 1;
}
}
} else {
$datedue = $globalduedate if ($globalduedate);
}
my $today = C4::Dates->new();
my $expiry_date;
# get the borrower information.....
my $borrower;
my $patron_block = []; # patron-level blocks on account.
my $patron_blocked = 0; # patron is prevented from checking out anything.
my $circ_blocked = 0; # patron is prevented from checking out /this item/.
my $can_override_patron = 0; # true if this staff user has all override permissions necessary.
my $allow_override_patron = 1; # true if all block conditions can be overridden.
my @missing_perms; # override permissions this user requires but does not have for the desired transaction.
if ($borrowernumber) {
# patron-level exceptions are contained in $borrower->{'flags'} .
$borrower = GetMemberDetails( $borrowernumber, 0 );
my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
$expiry_date = C4::Dates->new($borrower->{'dateexpiry'},'iso');
# remove redundant flags.
if($borrower->{flags}->{fines_exceed_circ_block_threshold}) {
delete $borrower->{flags}->{patron_has_fines};
}
# pass patronflags that aren't overridable
my $staffnote = ($borrower->{flags}->{'staffnote'}) ? $borrower->{flags}->{'staffnote'}->{'info'} : undef;
my $stats_only = ($borrower->{flags}->{'stats-only'}) ? 1 : 0;
for my $condition ( keys %{$borrower->{flags}} ){
# FIXME: Currently, flags holds some flags that aren't in the circ_exceptions table.
my $exception = circ_exception_permissions('patron',$condition);
next unless $exception;
# next if($exception->{'overridden'}); # could also send these to template to show user that there's an overridden/confirmed block.
# next if( (grep { $_ eq $condition } @$confirmed) && ! $exception->{'block'});
$patron_blocked = 1 if($exception->{'block'});
$can_override_patron = 1 if($exception->{'can_override'});
$allow_override_patron = 0 if($exception->{'block'} && ! $exception->{'allow_override'});
$exception->{'condition'} = $condition;
$exception->{'BLOCK_' . $condition} = 1;
# some patron flags may contain extra information in keys amount or info.
$exception->{'info'} = $borrower->{flags}->{$condition}->{'info'};
$exception->{'amount'} = $borrower->{flags}->{$condition}->{'amount'};
# Gather additional information for those exceptions that have it.
if($condition eq 'patron_card_expired'){
my $renew_date = $today + C4::Dates->new(1,0,$borrower->{'enrolmentperiod'},0);
$exception->{'expired'} = $expiry_date->output(); # this value is already stored in 'info'
$exception->{'renewaldate'} = $renew_date->output();
} elsif($condition eq 'patron_expires_soon'){
$exception->{'warndeparture'} = $expiry_date->output();
$exception->{'returnbeforeexpiry'} = C4::Context->preference('ReturnBeforeExpiry');
$exception->{'expiry'} = $expiry_date->output();
}
if($exception->{'block'}){
unshift @{$patron_block}, $exception;
unless($exception->{'can_override'} || ! $exception->{'allow_override'}) {
push @missing_perms, $condition;
}
} else {
push @$patron_block, $exception;
}
}
$template->param(
patron_blocked => $patron_blocked,
overduecount => $od,
issuecount => $issue,
finetotal => $fines,
allow_override_patron => $allow_override_patron,
can_override_patron => $can_override_patron,
staffnote => $staffnote,
stats_only => $stats_only,
);
# Proxy Relationships
if ($proxy_borrowernumber) {
$template->param(proxy_borrowernumber => $proxy_borrowernumber);
}
my $proxy_relationships = GetProxyRelationships($borrowernumber);
for my $proxy_relationship (@$proxy_relationships) {
# handle expired relationships
unless (!$proxy_relationship->{date_expires} || $proxy_relationship->{date_expires} eq "") {
$proxy_relationship->{expired} = ( C4::Dates->new($proxy_relationship->{date_expires},'iso') < $today );
}
$proxy_relationship->{selected} = 1 if $proxy_relationship->{proxy_borrowernumber} == $proxy_borrowernumber;
}
$template->param(PROXY_RELATIONSHIPS => $proxy_relationships);
}
# get the borrower information.....
my $proxy_borrower;
if ($proxy_borrowernumber) {
$proxy_borrower = GetMemberDetails( $proxy_borrowernumber, 0 );
my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $proxy_borrowernumber );
my $proxy_expiry_date = C4::Dates->new($proxy_borrower->{'dateexpiry'},'iso');
my $proxy_enroll_date = C4::Dates->new($proxy_borrower->{'dateenrolled'},'iso');
if($today > $proxy_expiry_date){
#borrowercard expired, no issues
my $renew_date = $today + C4::Dates->new(1,0,$proxy_borrower->{'enrolmentperiod'},0);
my $block_info = { expired => $proxy_expiry_date->output(),
renewaldate => $renew_date->output(),
};
## FIXME ### This is broken now.
push @$patron_block, { patron_card_expired => $block_info } ;
} elsif ( C4::Context->preference('NotifyBorrowerDeparture') && ( $proxy_expiry_date - C4::Dates->new(1,0,0,C4::Context->preference('NotifyBorrowerDeparture')) < $today ) ){
# borrower card expires soon.
my $block_info = { warndeparture => $expiry_date->output(),
returnbeforeexpiry => C4::Context->preference('ReturnBeforeExpiry'),
};
push @$patron_block, { patron_expires_soon => $block_info } ;
}
}
my $issue_to_borrower = ($proxy_borrower) ? $proxy_borrower : $borrower;
if($patron_block){
$template->param(
PATRON_BLOCK => $patron_block,
);
}
# Attempt checkout to patron
#
if ($barcode) {
my $status = {};
my $circ_exception = {};
if($invalidduedate){
$status->{'invalid'} = 1;
$template->param( INVALID_DATE => $invalidduedate );
} else {
( $status, $circ_exception ) = CanBookBeIssued( $borrower, $barcode, $datedue , undef );
if ($status->{block}) {
my $still_blocked = 0;
foreach ( keys %{$circ_exception} ) {
if ($overridden_blocks->{$_}) {
# delete $circ_exception->{$_};
$circ_exception->{$_}->{overridden} = 1;
}
else {
$still_blocked = 1;
}
}
if (!$still_blocked) {
$status->{block} = $still_blocked;
$status->{can_override} = 0;
$status->{allow_override} = 0;
$status->{require_confirm} = 0;
}
}
}
# CIRC_BLOCK
# each array entry in CIRC_BLOCK will have keys block, allow_override, require_confirm, can_override.
# can_override is true if this user has permission to complete the transaction.
my $blocker = 0;
if($status->{'invalid'}) {
$template->param( IMPOSSIBLE => 1 );
# todo : get info from circ_exception on why blocker.
$blocker = 1;
$template->param( $circ_exception ); # fix that.
} else {
# Get the item & bib data from barcode.
my $iteminfo = GetBiblioFromItemNumber(undef,$barcode);
my @circ_exception_loop;
for my $condition ( keys %$circ_exception ){
# CanBookBeIssued calls C4::Circulation::circ_exception_permissions; overrides stored in the session will already be accounted for
# remove block if it's been overridden, but keep the exception in case it requires confirmation.
$circ_exception->{$condition}->{'block'} = 0 if($circ_exception->{$condition}->{'block'} && grep { $_ eq $condition } @overrides );
if($circ_exception->{$condition}->{'block'}){
$circ_blocked = 1;
$debug and warn "BLOCKED: $condition";
unshift @circ_exception_loop, $circ_exception->{$condition};
push @missing_perms, $condition unless($circ_exception->{$condition}->{'can_override'} || ! $circ_exception->{$condition}->{'allow_override'});
} elsif($circ_exception->{$condition}->{'require_confirm'}) {
push @circ_exception_loop, $circ_exception->{$condition};
}
}
if( ! $status->{'invalid'} && ! $circ_blocked ){
$debug and warn "Issuing item $iteminfo->{'itemnumber'} to $borrowernumber";
$cancelreserve = 1;
my ($issue_date, $issue_error) = AddIssue( $issue_to_borrower, $iteminfo->{'itemnumber'}, $datedue, $cancelreserve, undef, undef, $borrowernumber );
if($issue_error){
$template->param( issue_error => 1 ,
"ERROR_$issue_error" => 1 ) ;
}
if ($proxy_borrowernumber) {
$template->param(proxy_checkout_successful => 1);
$template->param(proxy_just_charged_firstname => $proxy_borrower->{'firstname'});
$template->param(proxy_just_charged_surname => $proxy_borrower->{'surname'});
$template->param(proxy_just_charged_cardnumber => $proxy_borrower->{'cardnumber'});
}
if($globalduedate && ! $stickyduedate && $duedatespec_allow ){
$duedatespec = $globalduedate->output();
$stickyduedate = 1;
}
# If the checkout is successful, RELOAD borrower to display updated info.
my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
$borrower = GetMemberDetails( $borrowernumber, 0 );
$template->param( issuecount => $issue );
} else {
# i.e. checkout failed, or needs confirmed.
$template->param( itemtitle => $iteminfo->{'title'},
itemhomebranch => $iteminfo->{'homebranch'},
CIRC_BLOCK => \@circ_exception_loop,
circ_blocked => $circ_blocked,
require_confirm => $status->{'require_confirm'},
allow_override_circ => $status->{'allow_override'},
can_override_circ => $status->{'can_override'},
);
# these exceptions need to be in place even if the checkout was successful ( for require_confirms ).
}
}
}
##################################################################################
# BUILD HTML
# show all reserves of this borrower, and the position of the reservation ....
if ($borrowernumber) {
# Patron HOLDS
my @borrowerreserv = GetReservesFromBorrowernumber($borrowernumber );
my @reservloop;
my @WaitingReserveLoop;
foreach my $num_res (@borrowerreserv) {
my %getreserv;
if($num_res->{itemnumber}){
my $getiteminfo = GetBiblioFromItemNumber( $num_res->{'itemnumber'} );
my $itemtypeinfo = getitemtypeinfo( $getiteminfo->{'itemtype'} );
my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers( $num_res->{'itemnumber'} );
$getreserv{reservedate} = format_date( $num_res->{'reservedate'} );
$getreserv{title} = $getiteminfo->{'title'};
$getreserv{itemtype} = $itemtypeinfo->{'description'};
$getreserv{author} = $getiteminfo->{'author'};
$getreserv{barcodereserv} = $getiteminfo->{'barcode'};
$getreserv{itemcallnumber} = $getiteminfo->{'itemcallnumber'};
$getreserv{biblionumber} = $getiteminfo->{'biblionumber'};
$getreserv{waitingat} = GetBranchName( $num_res->{'branchcode'} );
if ( $num_res->{'found'} && $num_res->{'found'} eq 'W' ) {
# information for filled and waiting holds
$getreserv{hold_status} = 'reserved';
$getreserv{waiting} = 1;
$getreserv{waitingat} = GetBranchName( $num_res->{'branchcode'} );
$getreserv{waitinghere} = 1 if $num_res->{'branchcode'} eq $branch;
push (@WaitingReserveLoop, \%getreserv)
}
# check transfers with the itemnumber found in the reservation loop
if ($transfertwhen) {
$getreserv{hold_status} = 'transfered';
$getreserv{transfered} = 1;
$getreserv{datesent} = format_date($transfertwhen);
$getreserv{frombranch} = GetBranchName($transfertfrom);
} elsif ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'}) {
$getreserv{awaitingtransferfrom} = GetBranchName( $getiteminfo->{'holdingbranch'} );
}
} else { # if we don't have an itemnumber, get biblio info and the waiting position
my $getbibinfo = GetBiblioData( $num_res->{'biblionumber'} );
my $getbibtype = getitemtypeinfo( $getbibinfo->{'itemtype'} ); # fixme - we should have item-level reserves here ?
$getreserv{hold_status} = 'inwait';
$getreserv{title} = $getbibinfo->{'title'};
$getreserv{itemtype} = $getbibtype->{'description'};
$getreserv{author} = $getbibinfo->{'author'};
$getreserv{biblionumber} = $num_res->{'biblionumber'};
}
$getreserv{waitingposition} = $num_res->{'priority'};
push( @reservloop, \%getreserv );
}
# return result to the template
$template->param(
countreserv => scalar @reservloop,
reservloop => \@reservloop ,
WaitingReserveLoop => \@WaitingReserveLoop,
);
### Patron's Checkouts ###
my @hourlyissues;
my @todaysissues;
my @previousissues;
my %issuetypes;
my $renewal_permission_on_hold = circ_exception_permissions('checkout','renewal_on_hold');
my $renewal_permission_too_many = circ_exception_permissions('checkout','renewals_exceed_maxrenewals');
my $renewals_may_be_overridden = 0;
my ($issueslist) = GetPendingIssues($borrower->{'borrowernumber'});
# split in 3 arrays for hourly, today's & previous
foreach my $it ( @$issueslist ) {
my $issue_date = C4::Dates->new($it->{'issuedate'},'iso');
my $lastrenew_date = ($it->{'lastrenewdate'}) ? C4::Dates->new($it->{'lastrenewdate'},'iso') : undef;
my ($can_renew, $can_renew_error) = CanBookBeRenewed( $borrower->{'borrowernumber'},$it->{'itemnumber'} );
$it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
my ( $restype, $reserves ) = CheckReserves( $it->{'itemnumber'} );
$it->{'can_renew'} = $can_renew;
if($can_renew_error){
if($can_renew_error eq 'too_many'){
$it->{'can_OR_renew'} = $renewal_permission_too_many->{'can_override'};
} elsif($can_renew_error eq 'on_reserve') {
$it->{'can_OR_renew'} = $renewal_permission_on_hold->{'can_override'};
}
}
$renewals_may_be_overridden = 1 if($it->{'can_OR_renew'});
$it->{'renew_error'} = $restype;
my $duedate = C4::Dates->new($it->{'duedate'},'iso');
$it->{'dd'} = $duedate->output();
$it->{'renew_failed'} = $renew_failed{$it->{'itemnumber'}};
if( $it->{'loan_type'} eq 'hourly' ){
$it->{'dt'} = $duedate->output(C4::Context->preference('TimeFormat') || '24hr');
$it->{'od'} = ( $duedate lt $today ) ? 1 : 0 ; # datetime comparison
push @hourlyissues, $it;
$issuetypes{'hourly'}++;
} elsif ( $issue_date == $today || ( $lastrenew_date && ( $today == $lastrenew_date ))) {
push @todaysissues, $it;
$issuetypes{'today'}++;
} else {
$it->{'od'} = ( $duedate < $today ) ? 1 : 0 ; #date-only comparison
push @previousissues, $it;
$issuetypes{'previous'}++;
}
}
if ( C4::Context->preference( "todaysIssuesDefaultSortOrder" ) eq 'asc' ) {
@todaysissues = sort { $a->{'issuedate'} cmp $b->{'issuedate'} } @todaysissues;
} else {
@todaysissues = sort { $b->{'issuedate'} cmp $a->{'issuedate'} } @todaysissues;
}
if ( C4::Context->preference( "previousIssuesDefaultSortOrder" ) eq 'asc' ){
@previousissues = sort { $a->{'duedate'} cmp $b->{'duedate'} } @previousissues;
} else {
@previousissues = sort { $b->{'duedate'} cmp $a->{'duedate'} } @previousissues;
}
# Patron categories :
if ( $borrower->{'category_type'} eq 'C') {
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
my $cnt = scalar(@$catcodes);
$template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
$template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
} elsif($borrower->{'category_type'} eq 'A'){
$template->param( adultborrower => 1 );
}
# save stickyduedate to session
if ($stickyduedate) {
$session->param( 'stickyduedate', $duedatespec );
}
my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
$template->param( picture => 1 ) if $picture;
# template parameters dependent on valid borrower:
$template->param(
branchname => GetBranchName($borrower->{'branchcode'}),
firstname => $borrower->{'firstname'},
surname => $borrower->{'surname'},
dateexpiry => ($newexpiry) ? C4::Dates->new($newexpiry,'iso')->output() : '',
categorycode => $borrower->{'categorycode'},
categoryname => $borrower->{description},
address => $borrower->{'address'},
address2 => $borrower->{'address2'},
email => $borrower->{'email'},
emailpro => $borrower->{'emailpro'},
borrowernotes => $borrower->{'borrowernotes'},
city => $borrower->{'city'},
zipcode => $borrower->{'zipcode'},
country => $borrower->{'country'},
phone => $borrower->{'phone'} || $borrower->{'mobile'},
cardnumber => $borrower->{'cardnumber'},
barcode => $barcode,
stickyduedate => $stickyduedate,
duedatespec => $duedatespec,
todayissues => \@todaysissues,
previssues => \@previousissues,
hourlyissues => \@hourlyissues,
issuetypes => (scalar(keys(%issuetypes)) > 1) ? 1 : 0,
is_child => ($borrower->{'category_type'} eq 'C'),
SpecifyDueDate => $duedatespec_allow,
has_block => $patron_blocked || $circ_blocked,
missing_perms => join(',',@missing_perms),
OR_renewals => $renewals_may_be_overridden,
);
} else {
### No borrower: build search results list
my @values;
my %labels;
my $CGIselectborrower;
if ($borrowerslist) {
foreach (
sort {(lc $a->{'surname'} cmp lc $b->{'surname'} || lc $a->{'firstname'} cmp lc $b->{'firstname'})
} @$borrowerslist
)
{
push @values, $_->{'borrowernumber'};
$labels{ $_->{'borrowernumber'} } = "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'}) ... $_->{'address'} ";
}
$CGIselectborrower = CGI::scrolling_list(
-name => 'borrowernumber',
-class => 'focus',
-id => 'borrowernumber',
-values => \@values,
-labels => \%labels,
-onclick => "window.location = '/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + this.value;",
-size => 7,
-tabindex => '',
-multiple => 0
);
}
if (C4::Context->preference("AddPatronLists")) {
$template->param( "AddPatronLists_".C4::Context->preference("AddPatronLists") => "1" );
if (C4::Context->preference("AddPatronLists")=~/code/){
my $categories = GetBorrowercategoryList;
$categories->[0]->{'first'} = 1;
$template->param(categories=>$categories);
}
}
$template->param(
no_patron_found => $no_patron_found,
CGIselectborrower => $CGIselectborrower,
);
}
my $CGIorganisations;
my $member_of_institution;
if ( C4::Context->preference("memberofinstitution") ) {
my $organisations = get_institutions();
my @orgs;
my %org_labels;
foreach my $organisation ( keys %$organisations ) {
push @orgs, $organisation;
$org_labels{$organisation} = $organisations->{$organisation}->{'surname'};
}
$member_of_institution = 1;
$CGIorganisations = CGI::popup_menu(
-id => 'organisations',
-name => 'organisations',
-labels => \%org_labels,
-values => \@orgs,
);
}
$template->param(
findborrower => $findborrower,
borrower => $borrower,
borrowernumber => $borrowernumber,
branch => $branch,
memberofinstution => $member_of_institution,
CGIorganisations => $CGIorganisations,
circview => 1,
);
output_html_with_http_headers $query, $cookie, $template->output;
Something went wrong with that request. Please try again.