=cut
-use strict;
-use warnings;
+use Modern::Perl;
# FIXME There are weird things going on with $patron and $borrowernumber in this script
-use Carp 'verbose';
-$SIG{ __DIE__ } = sub { Carp::confess( @_ ) };
-
use CGI qw ( -utf8 );
use DateTime;
use C4::Context;
use Koha::DateUtils;
use Koha::Calendar;
use Koha::BiblioFrameworks;
-use Koha::Checkouts;
+use Koha::Holds;
use Koha::Items;
use Koha::Patrons;
+use Koha::Checkouts;
my $query = new CGI;
if ( $query->param('print_slip') ) {
$template->param(
print_slip => 1,
- borrowernumber => scalar $query->param('borrowernumber'),
+ borrowernumber => scalar $query->param('borrowernumber'), # FIXME We should send a Koha::Patron and raise an error if not exist.
biblionumber => scalar $query->param('biblionumber'),
+ itemnumber => scalar $query->param('itemnumber'),
);
}
my $biblio = $item->biblio;
if ( $cancel_reserve ) {
- CancelReserve({ reserve_id => $reserve_id, charge_cancel_fee => !$forgivemanualholdsexpire });
+ my $hold = Koha::Holds->find( $reserve_id );
+ if ( $hold ) {
+ $hold->cancel( { charge_cancel_fee => !$forgivemanualholdsexpire } );
+ } # FIXME else?
} else {
my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
# diffBranchSend tells ModReserveAffect whether document is expected in this library or not,
my ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber);
my $patron = Koha::Patrons->find( $nextreservinfo );
- my $name = $patron->surname . ", " . $patron->title . " " . $patron->firstname;
+ my $name = $patron ? $patron->surname . ", " . $patron->title . " " . $patron->firstname : '';
if ( $messages->{'transfert'} ) {
$template->param(
itemtitle => $biblio->title,
itembiblionumber => $biblio->biblionumber,
iteminfo => $biblio->author,
name => $name,
- borrowernumber => $borrowernumber,
- borcnum => $patron->cardnumber,
- borfirstname => $patron->firstname,
- borsurname => $patron->surname,
- borcategory => $patron->category->description,
+ patron => $patron,
diffbranch => 1,
);
}
my $item = Koha::Items->find({ barcode => $barcode });
if ( $item ) {
+ $itemnumber = $item->itemnumber;
# Check if we should display a checkin message, based on the the item
# type of the checked in item
my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype );
# make sure return branch respects home branch circulation rules, default to homebranch
my $hbr = GetBranchItemRule($item->homebranch, $itemtype ? $itemtype->itemtype : undef )->{'returnbranch'} || "homebranch";
- $returnbranch = $item->$hbr;
+ $returnbranch = $hbr ne 'noreturn' ? $item->$hbr : $userenv_branch; # can be noreturn, homebranch or holdingbranch
my $materials = $item->materials;
my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
$materials = $descriptions->{lib} // $materials;
- my $issue = Koha::Checkouts->find( { itemnumber => $itemnumber } );
-
- my $biblio = $item->biblio;
+ my $checkout = $item->checkout;
+ my $biblio = $item->biblio;
$template->param(
title => $biblio->title,
homebranch => $item->homebranch,
ccode => $item->ccode,
itembiblionumber => $biblio->biblionumber,
biblionumber => $biblio->biblionumber,
- borrower => $borrower,
additional_materials => $materials,
- issue => $issue,
+ issue => $checkout,
);
} # FIXME else we should not call AddReturn but set BadBarcode directly instead
my $patron = Koha::Patrons->find( $reserve->{'borrowernumber'} );
my $name = $patron->surname . ", " . $patron->title . " " . $patron->firstname;
$template->param(
- # FIXME The full patron object should be passed to the template
- wname => $name,
- wborfirstname => $patron->firstname,
- wborsurname => $patron->surname,
- wborcategory => $patron->category->description,
- wbortitle => $patron->title,
- wborphone => $patron->phone,
- wboremail => $patron->email,
- streetnumber => $patron->streetnumber,
- address => $patron->address,
- address2 => $patron->address2,
- city => $patron->city,
- zipcode => $patron->zipcode,
- state => $patron->state,
- country => $patron->country,
- wborrowernumber => $reserve->{'borrowernumber'},
- wborcnum => $patron->cardnumber,
+ patron => $patron,
);
}
$template->param(
$template->param(
# FIXME The full patron object should be passed to the template
found => 1,
- name => $patron->surname . ", " . $patron->title . " " . $patron->firstname,
- borfirstname => $patron->firstname,
- borsurname => $patron->surname,
- borcategory => $patron->category->description,
- bortitle => $patron->title,
- borphone => $patron->phone,
- boremail => $patron->email,
- boraddress => $patron->address,
- boraddress2 => $patron->address2,
- streetnumber => $patron->streetnumber,
- city => $patron->city,
- zipcode => $patron->zipcode,
- state => $patron->state,
- country => $patron->country,
- borcnum => $patron->cardnumber,
- debarred => $patron->debarred,
- gonenoaddress => $patron->gonenoaddress,
+ patron => $patron,
barcode => $barcode,
destbranch => $reserve->{'branchcode'},
- borrowernumber => $reserve->{'borrowernumber'},
itemnumber => $reserve->{'itemnumber'},
reservenotes => $reserve->{'reservenotes'},
reserve_id => $reserve->{reserve_id},
elsif ( $code eq 'NotIssued' ) {
$err{notissued} = 1;
$err{msg} = '';
- $err{msg} = $messages->{'IsPermanent'} if $messages->{'IsPermanent'};
}
elsif ( $code eq 'LocalUse' ) {
$err{localuse} = 1;
}
elsif ( $code eq 'WasLost' ) {
$err{waslost} = 1;
+ $exit_required_p = 1 if C4::Context->preference("BlockReturnOfLostItems");
}
elsif ( $code eq 'LostItemFeeRefunded' ) {
$template->param( LostItemFeeRefunded => 1 );
$err{withdrawn} = 1;
$exit_required_p = 1 if C4::Context->preference("BlockReturnOfWithdrawnItems");
}
- elsif ( ( $code eq 'IsPermanent' ) && ( not $messages->{'ResFound'} ) ) {
- if ( $messages->{'IsPermanent'} ne $userenv_branch ) {
- $err{ispermanent} = 1;
- $err{msg} = $messages->{'IsPermanent'};
- }
- }
elsif ( $code eq 'WrongTransfer' ) {
; # FIXME... anything to do here?
}
elsif ( $code eq 'NotForLoanStatusUpdated' ) {
$err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
}
+ elsif ( $code eq 'DataCorrupted' ) {
+ $err{data_corrupted} = 1;
+ }
else {
die "Unknown error code $code"; # note we need all the (empty) elsif's above, or we die.
# This forces the issue of staying in sync w/ Circulation.pm
} else {
$ri{return_overdue} = 1 if (DateTime->compare($duedate, $dropboxdate) == -1);
}
- $ri{borrowernumber} = $patron->borrowernumber;
- $ri{borcnum} = $patron->cardnumber;
- $ri{borfirstname} = $patron->firstname;
- $ri{borsurname} = $patron->surname;
- $ri{bortitle} = $patron->title;
- $ri{bornote} = $patron->borrowernotes;
- $ri{borcategorycode}= $patron->categorycode;
- $ri{borissuescount} = Koha::Checkouts->count( { borrowernumber => $b->{'borrowernumber'} } );
+ $ri{patron} = $patron,
+ $ri{borissuescount} = $patron->checkouts->count;
}
else {
$ri{borrowernumber} = $riborrowernumber{$_};
$ri{homebranch} = $item->homebranch;
$ri{holdingbranch} = $item->holdingbranch;
- $ri{location} = $biblio->{'location'};
+ $ri{location} = $item->location;
my $shelfcode = $ri{'location'};
$ri{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
push @riloop, \%ri;
}
+my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count;
+
$template->param(
riloop => \@riloop,
printer => $printer,
forgivemanualholdsexpire => $forgivemanualholdsexpire,
overduecharges => $overduecharges,
AudioAlerts => C4::Context->preference("AudioAlerts"),
- BlockReturnOfWithdrawnItems => C4::Context->preference("BlockReturnOfWithdrawnItems"),
+ pending_checkout_notes => $pending_checkout_notes,
);
$itemnumber = GetItemnumberFromBarcode( $barcode );