=cut
use strict;
+use warnings;
use C4::Branch; # GetBranches get_branchinfos_of
use CGI;
use List::MoreUtils qw/uniq/;
-use Date::Calc qw/Today Date_to_Days/;
+use Date::Calc qw/Date_to_Days/;
use C4::Output;
use C4::Auth;
use C4::Reserves;
use C4::Biblio;
+use C4::Items;
use C4::Koha;
use C4::Circulation;
use C4::Dates qw/format_date/;
use C4::Members;
+use C4::Search; # enabled_staff_search_views
my $dbh = C4::Context->dbh;
my $sth;
my $cardnumber = $input->param('cardnumber');
my $borrowerslist;
my $messageborrower;
+my $warnings;
+my $messages;
-my $date = sprintf( '%04d-%02d-%02d', Today() );
+my $date = C4::Dates->today('iso');
if ($findborrower) {
my ( $count, $borrowers ) =
if ($cardnumber) {
my $borrowerinfo = GetMemberDetails( 0, $cardnumber );
- my $expiry;
my $diffbranch;
my @getreservloop;
my $count_reserv = 0;
GetReserveCount( $borrowerinfo->{'borrowernumber'} );
if ( $number_reserves > C4::Context->preference('maxreserves') ) {
+ $warnings = 1;
$maxreserves = 1;
}
- # we check the date expiricy of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
- if ($borrowerinfo->{'dateexpiry'} ne '0000-00-00') {
- my $warning = (Date_to_Days(split /-/,$date) > Date_to_Days( split /-/,$borrowerinfo->{'dateexpiry'}));
- if ( $warning > 0 ) {
- $expiry = 1;
- }
- } else {
- $expiry = 1;
+ # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn)
+ my $expiry_date = $borrowerinfo->{dateexpiry};
+ my $expiry = 0; # flag set if patron account has expired
+ if ($expiry_date and $expiry_date ne '0000-00-00' and
+ Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) {
+ $messages = $expiry = 1;
+ }else{
+ $expiry = 0;
}
-
+
# check if the borrower make the reserv in a different branch
if ( $borrowerinfo->{'branchcode'} ne C4::Context->userenv->{'branch'} ) {
+ $messages = 1;
$diffbranch = 1;
}
borrowerreservs => $count_reserv,
maxreserves => $maxreserves,
expiry => $expiry,
- diffbranch => $diffbranch
+ diffbranch => $diffbranch,
+ messages => $messages,
+ warnings => $warnings
);
}
'%s, %s ... (%s - %s) ... %s',
$borrower->{surname}, $borrower->{firstname},
$borrower->{cardnumber}, $borrower->{categorycode},
- $borrower->{streetaddress},
+ $borrower->{address},
);
}
}
if ( $borrowerinfo->{borrowernumber} eq $res->{borrowernumber} ) {
+ $warnings = 1;
$alreadyreserved = 1;
}
}
-$template->param( alreadyreserved => $alreadyreserved );
+$template->param( alreadyreserved => $alreadyreserved,
+ messages => $messages,
+ warnings => $warnings );
# FIXME think @optionloop, is maybe obsolete, or must be switchable by a systeme preference fixed rank or not
# make priorities options
my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } )
{
my $item = $iteminfos_of->{$itemnumber};
- $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
- $item->{imageurl} = getitemtypeimagesrc() . "/".$itemtypes->{ $item->{itype} }{imageurl};
- $item->{homebranchname} =
- $branches->{ $item->{homebranch} }{branchname};
+ unless (C4::Context->preference('item-level_itypes')) {
+ $item->{itype} = $biblioitem->{itemtype};
+ }
+
+ $item->{itypename} = $itemtypes->{ $item->{itype} }{description};
+ $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
+ $item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname};
# if the holdingbranch is different than the homebranch, we show the
# holdingbranch of the document too
}
}
- # FIXME: every library will define this differently
- # An item is available only if:
- if (
- not defined $reservedate # not reserved yet
- and $issues->{'date_due'} eq '' # not currently on loan
- and not $item->{itemlost} # not lost
- and not $item->{notforloan} # not forbidden to loan
- and not $item->{cantreserve}
- and $transfertwhen eq '' # not currently on transfert
- )
- {
- $item->{available} = 1;
- }
+ if (IsAvailableForItemLevelRequest($itemnumber) and not $item->{cantreserve}) {
+ $item->{available} = 1;
+ }
# FIXME: move this to a pm
- my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W' AND cancellationdate IS NULL");
+ my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'");
$sth2->execute($item->{ReservedForBorrowernumber},$item->{itemnumber});
while (my $wait_hashref = $sth2->fetchrow_hashref) {
$item->{waitingdate} = format_date($wait_hashref->{waitingdate});
}
# set found to 1 if reserve is waiting for patron pickup
$reserve{'found'} = 1 if $res->{'found'} eq 'W';
+ } elsif ($res->{priority} > 0) {
+ if (defined($res->{itemnumber})) {
+ my $item = GetItem($res->{itemnumber});
+ $reserve{'itemnumber'} = $res->{'itemnumber'};
+ $reserve{'barcodenumber'} = $item->{'barcode'};
+ $reserve{'item_level_hold'} = 1;
+ }
}
# get borrowers reserve info
my @values;
my %label_of;
-foreach my $branchcode ( keys %{$branches} ) {
+foreach my $branchcode (sort keys %{$branches} ) {
push @values, $branchcode;
$label_of{$branchcode} = $branches->{$branchcode}->{branchname};
}
cardnumber => $cardnumber,
CGIselectborrower => $CGIselectborrower,
title => $dat->{title},
- author => $dat->{author}
+ author => $dat->{author},
+ holdsview => 1,
+ borrower_branchname => $branches->{$borrowerinfo->{'branchcode'}}->{'branchname'},
+ borrower_branchcode => $borrowerinfo->{'branchcode'},
);
# printout the page