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