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