Bug 13497: Remove the pref AddPatronsLists
[koha.git] / circ / circulation.pl
1 #!/usr/bin/perl
2
3 # script to execute issuing of books
4
5 # Copyright 2000-2002 Katipo Communications
6 # copyright 2010 BibLibre
7 # Copyright 2011 PTFS-Europe Ltd.
8 # Copyright 2012 software.coop and MJ Ray
9 #
10 # This file is part of Koha.
11 #
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
16 #
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License along
22 # with Koha; if not, write to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25 use strict;
26 use warnings;
27 use CGI qw ( -utf8 );
28 use DateTime;
29 use DateTime::Duration;
30 use C4::Output;
31 use C4::Print;
32 use C4::Auth qw/:DEFAULT get_session haspermission/;
33 use C4::Dates qw/format_date/;
34 use C4::Branch; # GetBranches
35 use C4::Koha;   # GetPrinter
36 use C4::Circulation;
37 use C4::Members;
38 use C4::Biblio;
39 use C4::Search;
40 use MARC::Record;
41 use C4::Reserves;
42 use C4::Context;
43 use CGI::Session;
44 use C4::Members::Attributes qw(GetBorrowerAttributes);
45 use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
46 use Koha::DateUtils;
47 use Koha::Database;
48
49 use Date::Calc qw(
50   Today
51   Add_Delta_YM
52   Add_Delta_Days
53   Date_to_Days
54 );
55 use List::MoreUtils qw/uniq/;
56
57
58 #
59 # PARAMETERS READING
60 #
61 my $query = new CGI;
62
63 my $sessionID = $query->cookie("CGISESSID") ;
64 my $session = get_session($sessionID);
65
66 # branch and printer are now defined by the userenv
67 # but first we have to check if someone has tried to change them
68
69 my $branch = $query->param('branch');
70 if ($branch){
71     # update our session so the userenv is updated
72     $session->param('branch', $branch);
73     $session->param('branchname', GetBranchName($branch));
74 }
75
76 my $printer = $query->param('printer');
77 if ($printer){
78     # update our session so the userenv is updated
79     $session->param('branchprinter', $printer);
80 }
81
82 if (!C4::Context->userenv && !$branch){
83     if ($session->param('branch') eq 'NO_LIBRARY_SET'){
84         # no branch set we can't issue
85         print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
86         exit;
87     }
88 }
89
90 my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
91     {
92         template_name   => 'circ/circulation.tt',
93         query           => $query,
94         type            => "intranet",
95         authnotrequired => 0,
96         flagsrequired   => { circulate => 'circulate_remaining_permissions' },
97     }
98 );
99
100 my $branches = GetBranches();
101
102 my $force_allow_issue = $query->param('forceallow') || 0;
103 if (!C4::Auth::haspermission( C4::Context->userenv->{id} , { circulate => 'force_checkout' } )) {
104     $force_allow_issue = 0;
105 }
106
107 my $onsite_checkout = $query->param('onsite_checkout');
108
109 my @failedrenews = $query->param('failedrenew');    # expected to be itemnumbers
110 our %renew_failed = ();
111 for (@failedrenews) { $renew_failed{$_} = 1; }
112
113 my @failedreturns = $query->param('failedreturn');
114 our %return_failed = ();
115 for (@failedreturns) { $return_failed{$_} = 1; }
116
117 my $findborrower = $query->param('findborrower') || q{};
118 $findborrower =~ s|,| |g;
119 my $borrowernumber = $query->param('borrowernumber');
120
121 $branch  = C4::Context->userenv->{'branch'};  
122 $printer = C4::Context->userenv->{'branchprinter'};
123
124
125 # If AutoLocation is not activated, we show the Circulation Parameters to chage settings of librarian
126 if (C4::Context->preference("AutoLocation") != 1) {
127     $template->param(ManualLocation => 1);
128 }
129
130 if (C4::Context->preference("DisplayClearScreenButton")) {
131     $template->param(DisplayClearScreenButton => 1);
132 }
133
134 my $barcode        = $query->param('barcode') || q{};
135 $barcode =~  s/^\s*|\s*$//g; # remove leading/trailing whitespace
136
137 $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
138 my $stickyduedate  = $query->param('stickyduedate') || $session->param('stickyduedate');
139 my $duedatespec    = $query->param('duedatespec')   || $session->param('stickyduedate');
140 my $issueconfirmed = $query->param('issueconfirmed');
141 my $cancelreserve  = $query->param('cancelreserve');
142 my $print          = $query->param('print') || q{};
143 my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice
144 my $charges        = $query->param('charges') || q{};
145
146 # Check if stickyduedate is turned off
147 if ( $barcode ) {
148     # was stickyduedate loaded from session?
149     if ( $stickyduedate && ! $query->param("stickyduedate") ) {
150         $session->clear( 'stickyduedate' );
151         $stickyduedate  = $query->param('stickyduedate');
152         $duedatespec    = $query->param('duedatespec');
153     }
154     $session->param('auto_renew', $query->param('auto_renew'));
155 }
156 else {
157     $session->clear('auto_renew');
158 }
159
160 my ($datedue,$invalidduedate);
161
162 my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
163 if( $onsite_checkout && !$duedatespec_allow ) {
164     $datedue = output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
165     $datedue .= ' 23:59:00';
166 } elsif( $duedatespec_allow ) {
167     if ($duedatespec) {
168         if ($duedatespec =~ C4::Dates->regexp('syspref')) {
169                 $datedue = dt_from_string($duedatespec);
170         } else {
171             $invalidduedate = 1;
172             $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
173         }
174     }
175 }
176
177 our $todaysdate = C4::Dates->new->output('iso');
178
179 # check and see if we should print
180 if ( $barcode eq '' && $print eq 'maybe' ) {
181     $print = 'yes';
182 }
183
184 my $inprocess = ($barcode eq '') ? '' : $query->param('inprocess');
185 if ( $barcode eq '' && $charges eq 'yes' ) {
186     $template->param(
187         PAYCHARGES     => 'yes',
188         borrowernumber => $borrowernumber
189     );
190 }
191
192 if ( $print eq 'yes' && $borrowernumber ne '' ) {
193     if ( C4::Context->boolean_preference('printcirculationslips') ) {
194         my $letter = IssueSlip($branch, $borrowernumber, "QUICK");
195         NetworkPrint($letter->{content});
196     }
197     $query->param( 'borrowernumber', '' );
198     $borrowernumber = '';
199 }
200
201 #
202 # STEP 2 : FIND BORROWER
203 # if there is a list of find borrowers....
204 #
205 my $borrowerslist;
206 my $message;
207 if ($findborrower) {
208     my $borrowers = Search($findborrower, 'cardnumber') || [];
209     my $categories = GetBorrowercategoryList;
210     $categories->[0]->{first} = 1;
211     $template->param( categories => $categories );
212
213     if ( @$borrowers == 0 ) {
214         $query->param( 'findborrower', '' );
215         $message = "'$findborrower'";
216     }
217     elsif ( @$borrowers == 1 ) {
218         $borrowernumber = $borrowers->[0]->{'borrowernumber'};
219         $query->param( 'borrowernumber', $borrowernumber );
220         $query->param( 'barcode',           '' );
221     }
222     else {
223         $borrowerslist = $borrowers;
224     }
225 }
226
227 # get the borrower information.....
228 my $borrower;
229 if ($borrowernumber) {
230     $borrower = GetMemberDetails( $borrowernumber, 0 );
231     my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
232
233     # Warningdate is the date that the warning starts appearing
234     my (  $today_year,   $today_month,   $today_day) = Today();
235     my ($warning_year, $warning_month, $warning_day) = split /-/, $borrower->{'dateexpiry'};
236     my (  $enrol_year,   $enrol_month,   $enrol_day) = split /-/, $borrower->{'dateenrolled'};
237     # Renew day is calculated by adding the enrolment period to today
238     my (  $renew_year,   $renew_month,   $renew_day);
239     if ($enrol_year*$enrol_month*$enrol_day>0) {
240         (  $renew_year,   $renew_month,   $renew_day) =
241         Add_Delta_YM( $enrol_year, $enrol_month, $enrol_day,
242             0 , $borrower->{'enrolmentperiod'});
243     }
244     # if the expiry date is before today ie they have expired
245     if ( !$borrower->{'dateexpiry'} || $warning_year*$warning_month*$warning_day==0
246         || Date_to_Days($today_year,     $today_month, $today_day  ) 
247          > Date_to_Days($warning_year, $warning_month, $warning_day) )
248     {
249         #borrowercard expired, no issues
250         $template->param(
251             flagged  => "1",
252             noissues => ($force_allow_issue) ? 0 : "1",
253             forceallow => $force_allow_issue,
254             expired => "1",
255             renewaldate => format_date("$renew_year-$renew_month-$renew_day")
256         );
257     }
258     # check for NotifyBorrowerDeparture
259     elsif ( C4::Context->preference('NotifyBorrowerDeparture') &&
260             Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
261             Date_to_Days( $today_year, $today_month, $today_day ) ) 
262     {
263         # borrower card soon to expire warn librarian
264         $template->param("warndeparture" => format_date($borrower->{dateexpiry}),
265         flagged       => "1",);
266         if (C4::Context->preference('ReturnBeforeExpiry')){
267             $template->param("returnbeforeexpiry" => 1);
268         }
269     }
270     $template->param(
271         overduecount => $od,
272         issuecount   => $issue,
273         finetotal    => $fines
274     );
275
276     if ( IsDebarred($borrowernumber) ) {
277         $template->param(
278             'userdebarred'    => $borrower->{debarred},
279             'debarredcomment' => $borrower->{debarredcomment},
280         );
281
282         if ( $borrower->{debarred} ne "9999-12-31" ) {
283             $template->param( 'userdebarreddate' =>
284                   C4::Dates::format_date( $borrower->{debarred} ) );
285         }
286     }
287
288 }
289
290 #
291 # STEP 3 : ISSUING
292 #
293 #
294 if ($barcode) {
295     # always check for blockers on issuing
296     my ( $error, $question, $alerts ) =
297     CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess );
298     my $blocker = $invalidduedate ? 1 : 0;
299
300     $template->param( alert => $alerts );
301
302     #  Get the item title for more information
303     my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
304     $template->param(
305         authvalcode_notforloan => C4::Koha::GetAuthValCode('items.notforloan', $getmessageiteminfo->{'frameworkcode'}),
306     );
307     # Fix for bug 7494: optional checkout-time fallback search for a book
308
309     if ( $error->{'UNKNOWN_BARCODE'}
310         && C4::Context->preference("itemBarcodeFallbackSearch") )
311     {
312      $template->param( FALLBACK => 1 );
313
314         my $query = "kw=" . $barcode;
315         my ( $searcherror, $results, $total_hits ) = SimpleSearch($query);
316
317         # if multiple hits, offer options to librarian
318         if ( $total_hits > 0 ) {
319             my @options = ();
320             foreach my $hit ( @{$results} ) {
321                 my $chosen =
322                   TransformMarcToKoha( C4::Context->dbh,
323                     C4::Search::new_record_from_zebra('biblioserver',$hit) );
324
325                 # offer all barcodes individually
326                 if ( $chosen->{barcode} ) {
327                     foreach my $barcode ( sort split(/\s*\|\s*/, $chosen->{barcode}) ) {
328                         my %chosen_single = %{$chosen};
329                         $chosen_single{barcode} = $barcode;
330                         push( @options, \%chosen_single );
331                     }
332                 }
333             }
334             $template->param( options => \@options );
335         }
336     }
337
338     unless( $onsite_checkout and C4::Context->preference("OnSiteCheckoutsForce") ) {
339         delete $question->{'DEBT'} if ($debt_confirmed);
340         foreach my $impossible ( keys %$error ) {
341             $template->param(
342                 $impossible => $$error{$impossible},
343                 IMPOSSIBLE  => 1
344             );
345             $blocker = 1;
346         }
347     }
348     if( !$blocker || $force_allow_issue ){
349         my $confirm_required = 0;
350         unless($issueconfirmed){
351             #  Get the item title for more information
352             my $getmessageiteminfo  = GetBiblioFromItemNumber(undef,$barcode);
353             $template->{VARS}->{'additional_materials'} = $getmessageiteminfo->{'materials'};
354             $template->param( itemhomebranch => $getmessageiteminfo->{'homebranch'} );
355
356             # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
357             foreach my $needsconfirmation ( keys %$question ) {
358                 $template->param(
359                     $needsconfirmation => $$question{$needsconfirmation},
360                     getTitleMessageIteminfo => $getmessageiteminfo->{'title'},
361                     getBarcodeMessageIteminfo => $getmessageiteminfo->{'barcode'},
362                     NEEDSCONFIRMATION  => 1,
363                     onsite_checkout => $onsite_checkout,
364                 );
365                 $confirm_required = 1;
366             }
367         }
368         unless($confirm_required) {
369             AddIssue( $borrower, $barcode, $datedue, $cancelreserve, undef, undef, { onsite_checkout => $onsite_checkout, auto_renew => $session->param('auto_renew') } );
370             $session->clear('auto_renew');
371             $inprocess = 1;
372         }
373     }
374     
375     my ( $od, $issue, $fines ) = GetMemberIssuesAndFines($borrowernumber);
376     $template->param( issuecount => $issue );
377 }
378
379 # reload the borrower info for the sake of reseting the flags.....
380 if ($borrowernumber) {
381     $borrower = GetMemberDetails( $borrowernumber, 0 );
382 }
383
384 ##################################################################################
385 # BUILD HTML
386 # show all reserves of this borrower, and the position of the reservation ....
387 if ($borrowernumber) {
388     $template->param(
389         holds_count => Koha::Database->new()->schema()->resultset('Reserve')
390           ->count( { borrowernumber => $borrowernumber } ) );
391     my @borrowerreserv = GetReservesFromBorrowernumber($borrowernumber);
392
393     my @WaitingReserveLoop;
394     foreach my $num_res (@borrowerreserv) {
395         if ( $num_res->{'found'} && $num_res->{'found'} eq 'W' ) {
396             my $getiteminfo  = GetBiblioFromItemNumber( $num_res->{'itemnumber'} );
397             my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $getiteminfo->{'itype'} : $getiteminfo->{'itemtype'} );
398             my %getWaitingReserveInfo;
399             $getWaitingReserveInfo{title} = $getiteminfo->{'title'};
400             $getWaitingReserveInfo{biblionumber} =
401               $getiteminfo->{'biblionumber'};
402             $getWaitingReserveInfo{itemtype} = $itemtypeinfo->{'description'};
403             $getWaitingReserveInfo{author}   = $getiteminfo->{'author'};
404             $getWaitingReserveInfo{itemcallnumber} =
405               $getiteminfo->{'itemcallnumber'};
406             $getWaitingReserveInfo{reservedate} =
407               format_date( $num_res->{'reservedate'} );
408             $getWaitingReserveInfo{waitingat} =
409               GetBranchName( $num_res->{'branchcode'} );
410             $getWaitingReserveInfo{waitinghere} = 1
411               if $num_res->{'branchcode'} eq $branch;
412             push( @WaitingReserveLoop, \%getWaitingReserveInfo );
413         }
414     }
415     $template->param( WaitingReserveLoop => \@WaitingReserveLoop );
416     $template->param( adultborrower => 1 )
417       if ( $borrower->{'category_type'} eq 'A' );
418 }
419
420 my @values;
421 my %labels;
422 my $selectborrower;
423 if ($borrowerslist) {
424     foreach (
425         sort {(lc $a->{'surname'} cmp lc $b->{'surname'} || lc $a->{'firstname'} cmp lc $b->{'firstname'})
426         } @$borrowerslist
427       )
428     {
429         push @values, $_->{'borrowernumber'};
430         $labels{ $_->{'borrowernumber'} } =
431 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'} - $_->{'branchcode'}) ...  $_->{'address'} ";
432     }
433     $selectborrower = {
434         values => \@values,
435         labels => \%labels,
436     };
437 }
438
439 #title
440 my $flags = $borrower->{'flags'};
441 foreach my $flag ( sort keys %$flags ) {
442     $template->param( flagged=> 1);
443     $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
444     if ( $flags->{$flag}->{'noissues'} ) {
445         $template->param(
446             noissues => ($force_allow_issue) ? 0 : 'true',
447             forceallow => $force_allow_issue,
448         );
449         if ( $flag eq 'GNA' ) {
450             $template->param( gna => 'true' );
451         }
452         elsif ( $flag eq 'LOST' ) {
453             $template->param( lost => 'true' );
454         }
455         elsif ( $flag eq 'DBARRED' ) {
456             $template->param( dbarred => 'true' );
457         }
458         elsif ( $flag eq 'CHARGES' ) {
459             $template->param(
460                 charges    => 'true',
461                 chargesmsg => $flags->{'CHARGES'}->{'message'},
462                 chargesamount => $flags->{'CHARGES'}->{'amount'},
463                 charges_is_blocker => 1
464             );
465         }
466         elsif ( $flag eq 'CREDITS' ) {
467             $template->param(
468                 credits    => 'true',
469                 creditsmsg => $flags->{'CREDITS'}->{'message'},
470                 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
471             );
472         }
473     }
474     else {
475         if ( $flag eq 'CHARGES' ) {
476             $template->param(
477                 charges    => 'true',
478                 chargesmsg => $flags->{'CHARGES'}->{'message'},
479                 chargesamount => $flags->{'CHARGES'}->{'amount'},
480             );
481         }
482         elsif ( $flag eq 'CREDITS' ) {
483             $template->param(
484                 credits    => 'true',
485                 creditsmsg => $flags->{'CREDITS'}->{'message'},
486                 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
487             );
488         }
489         elsif ( $flag eq 'ODUES' ) {
490             $template->param(
491                 odues    => 'true',
492                 oduesmsg => $flags->{'ODUES'}->{'message'}
493             );
494
495             my $items = $flags->{$flag}->{'itemlist'};
496             if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
497                 $template->param( nonreturns => 'true' );
498             }
499         }
500         elsif ( $flag eq 'NOTES' ) {
501             $template->param(
502                 notes    => 'true',
503                 notesmsg => $flags->{'NOTES'}->{'message'}
504             );
505         }
506     }
507 }
508
509 my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
510 $amountold =~ s/^.*\$//;    # remove upto the $, if any
511
512 my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
513
514 if ( $borrowernumber && $borrower->{'category_type'} eq 'C') {
515     my  ( $catcodes, $labels ) =  GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
516     my $cnt = scalar(@$catcodes);
517     $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
518     $template->param( 'catcode' =>    $catcodes->[0])  if $cnt == 1;
519 }
520
521 my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch );
522 if($lib_messages_loop){ $template->param(flagged => 1 ); }
523
524 my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch );
525 if($bor_messages_loop){ $template->param(flagged => 1 ); }
526
527 # Computes full borrower address
528 my @fulladdress;
529 push @fulladdress, $borrower->{'streetnumber'} if ( $borrower->{'streetnumber'} );
530 push @fulladdress, C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $borrower->{'streettype'} ) if ( $borrower->{'streettype'} );
531 push @fulladdress, $borrower->{'address'} if ( $borrower->{'address'} );
532
533 my $fast_cataloging = 0;
534 if (defined getframeworkinfo('FA')) {
535     $fast_cataloging = 1 
536 }
537
538 if (C4::Context->preference('ExtendedPatronAttributes')) {
539     my $attributes = GetBorrowerAttributes($borrowernumber);
540     $template->param(
541         ExtendedPatronAttributes => 1,
542         extendedattributes => $attributes
543     );
544 }
545
546 my @relatives = GetMemberRelatives( $borrower->{'borrowernumber'} );
547 my $relatives_issues_count =
548   Koha::Database->new()->schema()->resultset('Issue')
549   ->count( { borrowernumber => \@relatives } );
550
551 $template->param(
552     lib_messages_loop => $lib_messages_loop,
553     bor_messages_loop => $bor_messages_loop,
554     all_messages_del  => C4::Context->preference('AllowAllMessageDeletion'),
555     findborrower      => $findborrower,
556     borrower          => $borrower,
557     borrowernumber    => $borrowernumber,
558     branch            => $branch,
559     branchname        => GetBranchName($borrower->{'branchcode'}),
560     printer           => $printer,
561     printername       => $printer,
562     firstname         => $borrower->{'firstname'},
563     surname           => $borrower->{'surname'},
564     showname          => $borrower->{'showname'},
565     category_type     => $borrower->{'category_type'},
566     was_renewed       => $query->param('was_renewed') ? 1 : 0,
567     expiry            => format_date($borrower->{'dateexpiry'}),
568     categorycode      => $borrower->{'categorycode'},
569     categoryname      => $borrower->{description},
570     address           => join(' ', @fulladdress),
571     address2          => $borrower->{'address2'},
572     email             => $borrower->{'email'},
573     emailpro          => $borrower->{'emailpro'},
574     borrowernotes     => $borrower->{'borrowernotes'},
575     city              => $borrower->{'city'},
576     state              => $borrower->{'state'},
577     zipcode           => $borrower->{'zipcode'},
578     country           => $borrower->{'country'},
579     phone             => $borrower->{'phone'},
580     mobile            => $borrower->{'mobile'},
581     phonepro          => $borrower->{'phonepro'},
582     cardnumber        => $borrower->{'cardnumber'},
583     othernames        => $borrower->{'othernames'},
584     amountold         => $amountold,
585     barcode           => $barcode,
586     stickyduedate     => $stickyduedate,
587     duedatespec       => $duedatespec,
588     message           => $message,
589     selectborrower    => $selectborrower,
590     totaldue          => sprintf('%.2f', $total),
591     inprocess         => $inprocess,
592     is_child          => ($borrowernumber && $borrower->{'category_type'} eq 'C'),
593     circview => 1,
594     soundon           => C4::Context->preference("SoundOn"),
595     fast_cataloging   => $fast_cataloging,
596     CircAutoPrintQuickSlip   => C4::Context->preference("CircAutoPrintQuickSlip"),
597     activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
598     SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
599     AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
600     RoutingSerials => C4::Context->preference('RoutingSerials'),
601     relatives_issues_count => $relatives_issues_count,
602     relatives_borrowernumbers => \@relatives,
603 );
604
605 # save stickyduedate to session
606 if ($stickyduedate) {
607     $session->param( 'stickyduedate', $duedatespec );
608 }
609
610 my ($picture, $dberror) = GetPatronImage($borrower->{'borrowernumber'});
611 $template->param( picture => 1 ) if $picture;
612
613 # get authorised values with type of BOR_NOTES
614
615 my $canned_notes = GetAuthorisedValues("BOR_NOTES");
616
617 $template->param(
618     debt_confirmed            => $debt_confirmed,
619     SpecifyDueDate            => $duedatespec_allow,
620     CircAutocompl             => C4::Context->preference("CircAutocompl"),
621     AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
622     canned_bor_notes_loop     => $canned_notes,
623     debarments                => GetDebarments({ borrowernumber => $borrowernumber }),
624     todaysdate                => dt_from_string()->set(hour => 23)->set(minute => 59),
625 );
626
627 output_html_with_http_headers $query, $cookie, $template->output;