use C4::Context;
use CGI::Session;
use C4::Members::Attributes qw(GetBorrowerAttributes);
-use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
+use Koha::Patron;
+use Koha::Patron::Debarments qw(GetDebarments IsDebarred);
use Koha::DateUtils;
use Koha::Database;
+use Koha::Patron::Messages;
+use Koha::Patron::Images;
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
use Date::Calc qw(
Today
- Add_Delta_YM
Add_Delta_Days
Date_to_Days
);
use List::MoreUtils qw/uniq/;
-
#
# PARAMETERS READING
#
}
my $barcodes = [];
-if ( my $barcode = $query->param('barcode') ) {
+my $barcode = $query->param('barcode');
+# Barcode given by user could be '0'
+if ( $barcode || $barcode eq '0' ) {
$barcodes = [ $barcode ];
} else {
my $filefh = $query->upload('uploadfile');
push @$barcodes, split( /\s\n/, $list );
$barcodes = [ map { $_ =~ /^\s*$/ ? () : $_ } @$barcodes ];
} else {
- @$barcodes = $query->param('barcodes');
+ @$barcodes = $query->multi_param('barcodes');
}
}
my $onsite_checkout = $query->param('onsite_checkout');
-my @failedrenews = $query->param('failedrenew'); # expected to be itemnumbers
+my @failedrenews = $query->multi_param('failedrenew'); # expected to be itemnumbers
our %renew_failed = ();
for (@failedrenews) { $renew_failed{$_} = 1; }
-my @failedreturns = $query->param('failedreturn');
+my @failedreturns = $query->multi_param('failedreturn');
our %return_failed = ();
for (@failedreturns) { $return_failed{$_} = 1; }
$branch = C4::Context->userenv->{'branch'};
$printer = C4::Context->userenv->{'branchprinter'};
-
# If AutoLocation is not activated, we show the Circulation Parameters to chage settings of librarian
if (C4::Context->preference("AutoLocation") != 1) {
$template->param(ManualLocation => 1);
my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate');
$duedatespec = eval { output_pref( { dt => dt_from_string( $duedatespec ), dateformat => 'iso' }); }
if ( $duedatespec );
-
+my $restoreduedatespec = $query->param('restoreduedatespec') || $session->param('stickyduedate') || $duedatespec;
+if ($restoreduedatespec eq "highholds_empty") {
+ undef $restoreduedatespec;
+}
my $issueconfirmed = $query->param('issueconfirmed');
my $cancelreserve = $query->param('cancelreserve');
my $print = $query->param('print') || q{};
my ( $today_year, $today_month, $today_day) = Today();
my ($warning_year, $warning_month, $warning_day) = split /-/, $borrower->{'dateexpiry'};
my ( $enrol_year, $enrol_month, $enrol_day) = split /-/, $borrower->{'dateenrolled'};
- # Renew day is calculated by adding the enrolment period to today
- my ( $renew_year, $renew_month, $renew_day);
- if ($enrol_year*$enrol_month*$enrol_day>0) {
- ( $renew_year, $renew_month, $renew_day) =
- Add_Delta_YM( $enrol_year, $enrol_month, $enrol_day,
- 0 , $borrower->{'enrolmentperiod'});
- }
# if the expiry date is before today ie they have expired
if ( !$borrower->{'dateexpiry'} || $warning_year*$warning_month*$warning_day==0
|| Date_to_Days($today_year, $today_month, $today_day )
{
#borrowercard expired, no issues
$template->param(
- flagged => "1",
noissues => ($force_allow_issue) ? 0 : "1",
forceallow => $force_allow_issue,
expired => "1",
- renewaldate => "$renew_year-$renew_month-$renew_day",
);
}
# check for NotifyBorrowerDeparture
{
# borrower card soon to expire warn librarian
$template->param( "warndeparture" => $borrower->{dateexpiry} ,
- flagged => "1"
);
if (C4::Context->preference('ReturnBeforeExpiry')){
$template->param("returnbeforeexpiry" => 1);
{
$template_params->{FALLBACK} = 1;
+ my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
my $query = "kw=" . $barcode;
- my ( $searcherror, $results, $total_hits ) = SimpleSearch($query);
+ my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10);
# if multiple hits, offer options to librarian
if ( $total_hits > 0 ) {
my @options = ();
foreach my $hit ( @{$results} ) {
my $chosen =
- TransformMarcToKoha( C4::Context->dbh,
- C4::Search::new_record_from_zebra('biblioserver',$hit) );
+ TransformMarcToKoha( C4::Search::new_record_from_zebra('biblioserver',$hit) );
# offer all barcodes individually
if ( $chosen->{barcode} ) {
my $confirm_required = 0;
unless($issueconfirmed){
# Get the item title for more information
- $template_params->{additional_materials} = $iteminfo->{'materials'};
+ my $materials = $iteminfo->{'materials'};
+ my $avcode = GetAuthValCode('items.materials');
+ if ($avcode) {
+ $materials = GetKohaAuthorisedValueLib($avcode, $materials);
+ }
+ $template_params->{additional_materials} = $materials;
$template_params->{itemhomebranch} = $iteminfo->{'homebranch'};
# pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
if ($question->{RESERVE_WAITING} or $question->{RESERVED}){
$template->param(
- reserveborrowernumber => $question->{'resborrowernumber'},
- itembiblionumber => $getmessageiteminfo->{'biblionumber'}
+ reserveborrowernumber => $question->{'resborrowernumber'}
);
}
+ $template->param(
+ itembiblionumber => $getmessageiteminfo->{'biblionumber'}
+ );
+
+
+
$template_params->{issuecount} = $issue;
if ( $iteminfo ) {
# show all reserves of this borrower, and the position of the reservation ....
if ($borrowernumber) {
my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } );
+ my $waiting_holds = $holds->waiting;
$template->param(
holds_count => $holds->count(),
- WaitingHolds => scalar $holds->waiting(),
+ WaitingHolds => $waiting_holds,
);
$template->param( adultborrower => 1 ) if ( $borrower->{category_type} eq 'A' || $borrower->{category_type} eq 'I' );
#title
my $flags = $borrower->{'flags'};
foreach my $flag ( sort keys %$flags ) {
- $template->param( flagged=> 1);
$flags->{$flag}->{'message'} =~ s#\n#<br />#g;
if ( $flags->{$flag}->{'noissues'} ) {
$template->param(
}
}
-my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
+my $amountold = $borrower->{flags} ? $borrower->{flags}->{'CHARGES'}->{'message'} || 0 : 0;
$amountold =~ s/^.*\$//; # remove upto the $, if any
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
$template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
}
-my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch );
-if($lib_messages_loop){ $template->param(flagged => 1 ); }
+my $librarian_messages = Koha::Patron::Messages->search(
+ {
+ borrowernumber => $borrowernumber,
+ message_type => 'L',
+ }
+);
-my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch );
-if($bor_messages_loop){ $template->param(flagged => 1 ); }
+my $patron_messages = Koha::Patron::Messages->search(
+ {
+ borrowernumber => $borrowernumber,
+ message_type => 'B',
+ }
+);
my $fast_cataloging = 0;
if (defined getframeworkinfo('FA')) {
?'batch_checkout_view'
: 'circview';
-my @relatives = GetMemberRelatives( $borrower->{'borrowernumber'} );
+my @relatives;
+if ( $borrowernumber ) {
+ if ( my $patron = Koha::Patrons->find( $borrower->{borrowernumber} ) ) {
+ if ( my $guarantor = $patron->guarantor ) {
+ push @relatives, $guarantor->borrowernumber;
+ push @relatives, $_->borrowernumber for $patron->siblings;
+ } else {
+ push @relatives, $_->borrowernumber for $patron->guarantees;
+ }
+ }
+}
my $relatives_issues_count =
Koha::Database->new()->schema()->resultset('Issue')
->count( { borrowernumber => \@relatives } );
$template->param(%$borrower);
+# Restore date if changed by holds and/or save stickyduedate to session
+if ($restoreduedatespec || $stickyduedate) {
+ $duedatespec = $restoreduedatespec || $duedatespec;
+
+ if ($stickyduedate) {
+ $session->param( 'stickyduedate', $duedatespec );
+ }
+} elsif (defined($duedatespec) && !defined($restoreduedatespec)) {
+ undef $duedatespec;
+}
+
$template->param(
- lib_messages_loop => $lib_messages_loop,
- bor_messages_loop => $bor_messages_loop,
- all_messages_del => C4::Context->preference('AllowAllMessageDeletion'),
+ librarian_messages => $librarian_messages,
+ patron_messages => $patron_messages,
findborrower => $findborrower,
borrower => $borrower,
borrowernumber => $borrowernumber,
+ categoryname => $borrower->{'description'},
branch => $branch,
branchname => GetBranchName($borrower->{'branchcode'}),
printer => $printer,
printername => $printer,
- was_renewed => $query->param('was_renewed') ? 1 : 0,
+ was_renewed => scalar $query->param('was_renewed') ? 1 : 0,
expiry => $borrower->{'dateexpiry'},
roadtype => $roadtype,
amountold => $amountold,
barcodes => $barcodes,
stickyduedate => $stickyduedate,
duedatespec => $duedatespec,
+ restoreduedatespec => $restoreduedatespec,
message => $message,
totaldue => sprintf('%.2f', $total),
inprocess => $inprocess,
relatives_borrowernumbers => \@relatives,
);
-# save stickyduedate to session
-if ($stickyduedate) {
- $session->param( 'stickyduedate', $duedatespec );
-}
-
-my ($picture, $dberror) = GetPatronImage($borrower->{'borrowernumber'});
-$template->param( picture => 1 ) if $picture;
+my $patron_image = Koha::Patron::Images->find($borrower->{borrowernumber});
+$template->param( picture => 1 ) if $patron_image;
# get authorised values with type of BOR_NOTES
debt_confirmed => $debt_confirmed,
SpecifyDueDate => $duedatespec_allow,
CircAutocompl => C4::Context->preference("CircAutocompl"),
- AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
canned_bor_notes_loop => $canned_notes,
debarments => GetDebarments({ borrowernumber => $borrowernumber }),
todaysdate => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),