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