Bug 5549 : Due Date calculation in issue needs to be HH:MM aware
[koha.git] / circ / circulation.pl
blob11b40a4132b1ea4d439faae883c549f752279f83
1 #!/usr/bin/perl
3 # script to execute issuing of books
5 # Copyright 2000-2002 Katipo Communications
6 # copyright 2010 BibLibre
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 use strict;
24 use warnings;
25 use CGI;
26 use C4::Output;
27 use C4::Auth qw/:DEFAULT get_session/;
28 use C4::Dates qw/format_date/;
29 use C4::Branch; # GetBranches
30 use C4::Koha; # GetPrinter
31 use C4::Circulation;
32 use C4::Overdues qw/CheckBorrowerDebarred/;
33 use C4::Members;
34 use C4::Biblio;
35 use C4::Reserves;
36 use C4::Context;
37 use CGI::Session;
38 use C4::Members::Attributes qw(GetBorrowerAttributes);
40 use Date::Calc qw(
41 Today
42 Add_Delta_YM
43 Add_Delta_Days
44 Date_to_Days
46 use List::MoreUtils qw/uniq/;
50 # PARAMETERS READING
52 my $query = new CGI;
54 my $sessionID = $query->cookie("CGISESSID") ;
55 my $session = get_session($sessionID);
57 # branch and printer are now defined by the userenv
58 # but first we have to check if someone has tried to change them
60 my $branch = $query->param('branch');
61 if ($branch){
62 # update our session so the userenv is updated
63 $session->param('branch', $branch);
64 $session->param('branchname', GetBranchName($branch));
67 my $printer = $query->param('printer');
68 if ($printer){
69 # update our session so the userenv is updated
70 $session->param('branchprinter', $printer);
73 if (!C4::Context->userenv && !$branch){
74 if ($session->param('branch') eq 'NO_LIBRARY_SET'){
75 # no branch set we can't issue
76 print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
77 exit;
81 my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
83 template_name => 'circ/circulation.tmpl',
84 query => $query,
85 type => "intranet",
86 authnotrequired => 0,
87 flagsrequired => { circulate => 'circulate_remaining_permissions' },
91 my $branches = GetBranches();
93 my @failedrenews = $query->param('failedrenew'); # expected to be itemnumbers
94 my %renew_failed;
95 for (@failedrenews) { $renew_failed{$_} = 1; }
97 my $findborrower = $query->param('findborrower');
98 $findborrower =~ s|,| |g;
99 my $borrowernumber = $query->param('borrowernumber');
101 $branch = C4::Context->userenv->{'branch'};
102 $printer = C4::Context->userenv->{'branchprinter'};
105 # If AutoLocation is not activated, we show the Circulation Parameters to chage settings of librarian
106 if (C4::Context->preference("AutoLocation") != 1) {
107 $template->param(ManualLocation => 1);
110 if (C4::Context->preference("DisplayClearScreenButton")) {
111 $template->param(DisplayClearScreenButton => 1);
114 if (C4::Context->preference("UseTablesortForCirc")) {
115 $template->param(UseTablesortForCirc => 1);
118 my $barcode = $query->param('barcode') || '';
119 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
121 $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
122 my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate');
123 my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate');
124 my $issueconfirmed = $query->param('issueconfirmed');
125 my $cancelreserve = $query->param('cancelreserve');
126 my $organisation = $query->param('organisations');
127 my $print = $query->param('print');
128 my $newexpiry = $query->param('dateexpiry');
129 my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice
131 # Check if stickyduedate is turned off
132 if ( $barcode ) {
133 # was stickyduedate loaded from session?
134 if ( $stickyduedate && ! $query->param("stickyduedate") ) {
135 $session->clear( 'stickyduedate' );
136 $stickyduedate = $query->param('stickyduedate');
137 $duedatespec = $query->param('duedatespec');
141 my ($datedue,$invalidduedate);
143 my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
144 if($duedatespec_allow){
145 if ($duedatespec) {
146 if ($duedatespec =~ C4::Dates->regexp('syspref')) {
147 my $tempdate = C4::Dates->new($duedatespec);
148 $datedue = $tempdate;
149 } else {
150 $invalidduedate = 1;
151 $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
156 my $todaysdate = C4::Dates->new->output('iso');
158 # check and see if we should print
159 if ( $barcode eq '' && $print eq 'maybe' ) {
160 $print = 'yes';
163 my $inprocess = ($barcode eq '') ? '' : $query->param('inprocess');
164 if ( $barcode eq '' && $query->param('charges') eq 'yes' ) {
165 $template->param(
166 PAYCHARGES => 'yes',
167 borrowernumber => $borrowernumber
171 if ( $print eq 'yes' && $borrowernumber ne '' ) {
172 PrintIssueSlip($session->param('branch') || $branch, $borrowernumber);
173 $query->param( 'borrowernumber', '' );
174 $borrowernumber = '';
178 # STEP 2 : FIND BORROWER
179 # if there is a list of find borrowers....
181 my $borrowerslist;
182 my $message;
183 if ($findborrower) {
184 my $borrowers = Search($findborrower, 'cardnumber');
185 my @borrowers = @$borrowers;
186 if (C4::Context->preference("AddPatronLists")) {
187 $template->param(
188 "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
190 if (C4::Context->preference("AddPatronLists")=~/code/){
191 my $categories = GetBorrowercategoryList;
192 $categories->[0]->{'first'} = 1;
193 $template->param(categories=>$categories);
196 if ( $#borrowers == -1 ) {
197 $query->param( 'findborrower', '' );
198 $message = "'$findborrower'";
200 elsif ( $#borrowers == 0 ) {
201 $query->param( 'borrowernumber', $borrowers[0]->{'borrowernumber'} );
202 $query->param( 'barcode', '' );
203 $borrowernumber = $borrowers[0]->{'borrowernumber'};
205 else {
206 $borrowerslist = \@borrowers;
210 # get the borrower information.....
211 my $borrower;
212 if ($borrowernumber) {
213 $borrower = GetMemberDetails( $borrowernumber, 0 );
214 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
216 # Warningdate is the date that the warning starts appearing
217 my ( $today_year, $today_month, $today_day) = Today();
218 my ($warning_year, $warning_month, $warning_day) = split /-/, $borrower->{'dateexpiry'};
219 my ( $enrol_year, $enrol_month, $enrol_day) = split /-/, $borrower->{'dateenrolled'};
220 # Renew day is calculated by adding the enrolment period to today
221 my ( $renew_year, $renew_month, $renew_day);
222 if ($enrol_year*$enrol_month*$enrol_day>0) {
223 ( $renew_year, $renew_month, $renew_day) =
224 Add_Delta_YM( $enrol_year, $enrol_month, $enrol_day,
225 0 , $borrower->{'enrolmentperiod'});
227 # if the expiry date is before today ie they have expired
228 if ( !$borrower->{'dateexpiry'} || $warning_year*$warning_month*$warning_day==0
229 || Date_to_Days($today_year, $today_month, $today_day )
230 > Date_to_Days($warning_year, $warning_month, $warning_day) )
232 #borrowercard expired, no issues
233 $template->param(
234 flagged => "1",
235 noissues => "1",
236 expired => "1",
237 renewaldate => format_date("$renew_year-$renew_month-$renew_day")
240 # check for NotifyBorrowerDeparture
241 elsif ( C4::Context->preference('NotifyBorrowerDeparture') &&
242 Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
243 Date_to_Days( $today_year, $today_month, $today_day ) )
245 # borrower card soon to expire warn librarian
246 $template->param("warndeparture" => format_date($borrower->{dateexpiry}),
247 flagged => "1",);
248 if (C4::Context->preference('ReturnBeforeExpiry')){
249 $template->param("returnbeforeexpiry" => 1);
252 $template->param(
253 overduecount => $od,
254 issuecount => $issue,
255 finetotal => $fines
258 my $debar = CheckBorrowerDebarred($borrowernumber);
259 if ($debar) {
260 $template->param( 'userdebarred' => 1 );
261 $template->param( 'debarredcomment' => $borrower->{debarredcomment} );
262 if ( $debar ne "9999-12-31" ) {
263 $template->param( 'userdebarreddate' => C4::Dates::format_date($debar) );
270 # STEP 3 : ISSUING
273 if ($barcode) {
274 # always check for blockers on issuing
275 my ( $error, $question ) =
276 CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess );
277 my $blocker = $invalidduedate ? 1 : 0;
279 delete $question->{'DEBT'} if ($debt_confirmed);
280 foreach my $impossible ( keys %$error ) {
281 $template->param(
282 $impossible => $$error{$impossible},
283 IMPOSSIBLE => 1
285 $blocker = 1;
287 if( !$blocker ){
288 my $confirm_required = 0;
289 unless($issueconfirmed){
290 # Get the item title for more information
291 my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
292 $template->{VARS}->{'additional_materials'} = $getmessageiteminfo->{'materials'};
293 $template->param( itemhomebranch => $getmessageiteminfo->{'homebranch'} );
295 # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
296 foreach my $needsconfirmation ( keys %$question ) {
297 $template->param(
298 $needsconfirmation => $$question{$needsconfirmation},
299 getTitleMessageIteminfo => $getmessageiteminfo->{'title'},
300 getBarcodeMessageIteminfo => $getmessageiteminfo->{'barcode'},
301 NEEDSCONFIRMATION => 1
303 $confirm_required = 1;
306 unless($confirm_required) {
307 AddIssue( $borrower, $barcode, $datedue, $cancelreserve );
308 $inprocess = 1;
312 # FIXME If the issue is confirmed, we launch another time GetMemberIssuesAndFines, now display the issue count after issue
313 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
314 $template->param( issuecount => $issue );
317 # reload the borrower info for the sake of reseting the flags.....
318 if ($borrowernumber) {
319 $borrower = GetMemberDetails( $borrowernumber, 0 );
322 ##################################################################################
323 # BUILD HTML
324 # show all reserves of this borrower, and the position of the reservation ....
325 if ($borrowernumber) {
327 # new op dev
328 # now we show the status of the borrower's reservations
329 my @borrowerreserv = GetReservesFromBorrowernumber($borrowernumber );
330 my @reservloop;
331 my @WaitingReserveLoop;
333 foreach my $num_res (@borrowerreserv) {
334 my %getreserv;
335 my %getWaitingReserveInfo;
336 my $getiteminfo = GetBiblioFromItemNumber( $num_res->{'itemnumber'} );
337 my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $getiteminfo->{'itype'} : $getiteminfo->{'itemtype'} );
338 my ( $transfertwhen, $transfertfrom, $transfertto ) =
339 GetTransfers( $num_res->{'itemnumber'} );
341 $getreserv{waiting} = 0;
342 $getreserv{transfered} = 0;
343 $getreserv{nottransfered} = 0;
345 $getreserv{reservedate} = format_date( $num_res->{'reservedate'} );
346 $getreserv{reservenumber} = $num_res->{'reservenumber'};
347 $getreserv{title} = $getiteminfo->{'title'};
348 $getreserv{itemtype} = $itemtypeinfo->{'description'};
349 $getreserv{author} = $getiteminfo->{'author'};
350 $getreserv{barcodereserv} = $getiteminfo->{'barcode'};
351 $getreserv{itemcallnumber} = $getiteminfo->{'itemcallnumber'};
352 $getreserv{biblionumber} = $getiteminfo->{'biblionumber'};
353 $getreserv{waitingat} = GetBranchName( $num_res->{'branchcode'} );
354 # check if we have a waiting status for reservations
355 if ( $num_res->{'found'} eq 'W' ) {
356 $getreserv{color} = 'reserved';
357 $getreserv{waiting} = 1;
358 # genarate information displaying only waiting reserves
359 $getWaitingReserveInfo{title} = $getiteminfo->{'title'};
360 $getWaitingReserveInfo{biblionumber} = $getiteminfo->{'biblionumber'};
361 $getWaitingReserveInfo{itemtype} = $itemtypeinfo->{'description'};
362 $getWaitingReserveInfo{author} = $getiteminfo->{'author'};
363 $getWaitingReserveInfo{reservedate} = format_date( $num_res->{'reservedate'} );
364 $getWaitingReserveInfo{waitingat} = GetBranchName( $num_res->{'branchcode'} );
365 $getWaitingReserveInfo{waitinghere} = 1 if $num_res->{'branchcode'} eq $branch;
367 # check transfers with the itemnumber foud in th reservation loop
368 if ($transfertwhen) {
369 $getreserv{color} = 'transfered';
370 $getreserv{transfered} = 1;
371 $getreserv{datesent} = format_date($transfertwhen);
372 $getreserv{frombranch} = GetBranchName($transfertfrom);
373 } elsif ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'}) {
374 $getreserv{nottransfered} = 1;
375 $getreserv{nottransferedby} = GetBranchName( $getiteminfo->{'holdingbranch'} );
378 # if we don't have a reserv on item, we put the biblio infos and the waiting position
379 if ( $getiteminfo->{'title'} eq '' ) {
380 my $getbibinfo = GetBiblioData( $num_res->{'biblionumber'} );
382 $getreserv{color} = 'inwait';
383 $getreserv{title} = $getbibinfo->{'title'};
384 $getreserv{nottransfered} = 0;
385 $getreserv{itemtype} = $itemtypeinfo->{'description'};
386 $getreserv{author} = $getbibinfo->{'author'};
387 $getreserv{biblionumber} = $num_res->{'biblionumber'};
389 $getreserv{waitingposition} = $num_res->{'priority'};
390 push( @reservloop, \%getreserv );
392 # if we have a reserve waiting, initiate waitingreserveloop
393 if ($getreserv{waiting} == 1) {
394 push (@WaitingReserveLoop, \%getWaitingReserveInfo)
399 # return result to the template
400 $template->param(
401 countreserv => scalar @reservloop,
402 reservloop => \@reservloop ,
403 WaitingReserveLoop => \@WaitingReserveLoop,
405 $template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' );
408 # make the issued books table.
409 my $todaysissues = '';
410 my $previssues = '';
411 my @todaysissues;
412 my @previousissues;
413 my @relissues;
414 my @relprevissues;
415 my $displayrelissues;
417 my $totalprice = 0;
419 sub build_issue_data {
420 my $issueslist = shift;
421 my $relatives = shift;
423 # split in 2 arrays for today & previous
424 foreach my $it ( @$issueslist ) {
425 my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $it->{'itype'} : $it->{'itemtype'} );
427 # set itemtype per item-level_itype syspref - FIXME this is an ugly hack
428 $it->{'itemtype'} = ( C4::Context->preference( 'item-level_itypes' ) ) ? $it->{'itype'} : $it->{'itemtype'};
430 ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
431 $it->{'itemnumber'}, $it->{'borrowernumber'}
433 $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
434 my ($can_renew, $can_renew_error) = CanBookBeRenewed(
435 $it->{'borrowernumber'},$it->{'itemnumber'}
437 $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
438 my ( $restype, $reserves, undef ) = CheckReserves( $it->{'itemnumber'} );
439 $it->{'can_renew'} = $can_renew;
440 $it->{'can_confirm'} = !$can_renew && !$restype;
441 $it->{'renew_error'} = $restype;
442 $it->{'checkoutdate'} = C4::Dates->new($it->{'issuedate'},'iso')->output('syspref');
443 $it->{'issuingbranchname'} = GetBranchName($it->{'branchcode'});
445 $totalprice += $it->{'replacementprice'};
446 $it->{'itemtype'} = $itemtypeinfo->{'description'};
447 $it->{'itemtype_image'} = $itemtypeinfo->{'imageurl'};
448 $it->{'dd'} = format_date($it->{'date_due'});
449 $it->{'displaydate'} = format_date($it->{'issuedate'});
450 $it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ;
451 ($it->{'author'} eq '') and $it->{'author'} = ' ';
452 $it->{'renew_failed'} = $renew_failed{$it->{'itemnumber'}};
454 if ( $todaysdate eq $it->{'issuedate'} or $todaysdate eq $it->{'lastreneweddate'} ) {
455 (!$relatives) ? push @todaysissues, $it : push @relissues, $it;
456 } else {
457 (!$relatives) ? push @previousissues, $it : push @relprevissues, $it;
462 if ($borrower) {
464 # Getting borrower relatives
465 my @relborrowernumbers = GetMemberRelatives($borrower->{'borrowernumber'});
466 #push @borrowernumbers, $borrower->{'borrowernumber'};
468 # get each issue of the borrower & separate them in todayissues & previous issues
469 my $issueslist = GetPendingIssues($borrower->{'borrowernumber'});
470 my $relissueslist = [];
471 if ( @relborrowernumbers ) {
472 $relissueslist = GetPendingIssues(@relborrowernumbers);
475 build_issue_data($issueslist, 0);
476 build_issue_data($relissueslist, 1);
478 $displayrelissues = scalar($relissueslist);
480 if ( C4::Context->preference( "todaysIssuesDefaultSortOrder" ) eq 'asc' ) {
481 @todaysissues = sort { $a->{'timestamp'} cmp $b->{'timestamp'} } @todaysissues;
483 else {
484 @todaysissues = sort { $b->{'timestamp'} cmp $a->{'timestamp'} } @todaysissues;
487 if ( C4::Context->preference( "previousIssuesDefaultSortOrder" ) eq 'asc' ){
488 @previousissues = sort { $a->{'date_due'} cmp $b->{'date_due'} } @previousissues;
490 else {
491 @previousissues = sort { $b->{'date_due'} cmp $a->{'date_due'} } @previousissues;
496 my @values;
497 my %labels;
498 my $CGIselectborrower;
499 if ($borrowerslist) {
500 foreach (
501 sort {(lc $a->{'surname'} cmp lc $b->{'surname'} || lc $a->{'firstname'} cmp lc $b->{'firstname'})
502 } @$borrowerslist
505 push @values, $_->{'borrowernumber'};
506 $labels{ $_->{'borrowernumber'} } =
507 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'} - $_->{'branchcode'}) ... $_->{'address'} ";
509 $CGIselectborrower = CGI::scrolling_list(
510 -name => 'borrowernumber',
511 -class => 'focus',
512 -id => 'borrowernumber',
513 -values => \@values,
514 -labels => \%labels,
515 -ondblclick => 'document.forms[\'mainform\'].submit()',
516 -size => 7,
517 -tabindex => '',
518 -multiple => 0
522 #title
523 my $flags = $borrower->{'flags'};
524 foreach my $flag ( sort keys %$flags ) {
525 $template->param( flagged=> 1);
526 $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
527 if ( $flags->{$flag}->{'noissues'} ) {
528 $template->param(
529 flagged => 1,
530 noissues => 'true',
532 if ( $flag eq 'GNA' ) {
533 $template->param( gna => 'true' );
535 elsif ( $flag eq 'LOST' ) {
536 $template->param( lost => 'true' );
538 elsif ( $flag eq 'DBARRED' ) {
539 $template->param( dbarred => 'true' );
541 elsif ( $flag eq 'CHARGES' ) {
542 $template->param(
543 charges => 'true',
544 chargesmsg => $flags->{'CHARGES'}->{'message'},
545 chargesamount => $flags->{'CHARGES'}->{'amount'},
546 charges_is_blocker => 1
549 elsif ( $flag eq 'CREDITS' ) {
550 $template->param(
551 credits => 'true',
552 creditsmsg => $flags->{'CREDITS'}->{'message'},
553 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
557 else {
558 if ( $flag eq 'CHARGES' ) {
559 $template->param(
560 charges => 'true',
561 flagged => 1,
562 chargesmsg => $flags->{'CHARGES'}->{'message'},
563 chargesamount => $flags->{'CHARGES'}->{'amount'},
566 elsif ( $flag eq 'CREDITS' ) {
567 $template->param(
568 credits => 'true',
569 creditsmsg => $flags->{'CREDITS'}->{'message'},
570 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
573 elsif ( $flag eq 'ODUES' ) {
574 $template->param(
575 odues => 'true',
576 flagged => 1,
577 oduesmsg => $flags->{'ODUES'}->{'message'}
580 my $items = $flags->{$flag}->{'itemlist'};
581 if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
582 $template->param( nonreturns => 'true' );
585 elsif ( $flag eq 'NOTES' ) {
586 $template->param(
587 notes => 'true',
588 flagged => 1,
589 notesmsg => $flags->{'NOTES'}->{'message'}
595 my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
596 $amountold =~ s/^.*\$//; # remove upto the $, if any
598 my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
600 if ( $borrower->{'category_type'} eq 'C') {
601 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
602 my $cnt = scalar(@$catcodes);
603 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
604 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
607 my $CGIorganisations;
608 my $member_of_institution;
609 if ( C4::Context->preference("memberofinstitution") ) {
610 my $organisations = get_institutions();
611 my @orgs;
612 my %org_labels;
613 foreach my $organisation ( keys %$organisations ) {
614 push @orgs, $organisation;
615 $org_labels{$organisation} = $organisations->{$organisation}->{'surname'};
617 $member_of_institution = 1;
618 $CGIorganisations = CGI::popup_menu(
619 -id => 'organisations',
620 -name => 'organisations',
621 -labels => \%org_labels,
622 -values => \@orgs,
626 my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch );
627 if($lib_messages_loop){ $template->param(flagged => 1 ); }
629 my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch );
630 if($bor_messages_loop){ $template->param(flagged => 1 ); }
632 # Computes full borrower address
633 my (undef, $roadttype_hashref) = &GetRoadTypes();
634 my $address = $borrower->{'streetnumber'}.' '.$roadttype_hashref->{$borrower->{'streettype'}}.' '.$borrower->{'address'};
636 my $fast_cataloging = 0;
637 if (defined getframeworkinfo('FA')) {
638 $fast_cataloging = 1
641 if (C4::Context->preference('ExtendedPatronAttributes')) {
642 my $attributes = GetBorrowerAttributes($borrowernumber);
643 $template->param(
644 ExtendedPatronAttributes => 1,
645 extendedattributes => $attributes
649 $template->param(
650 lib_messages_loop => $lib_messages_loop,
651 bor_messages_loop => $bor_messages_loop,
652 all_messages_del => C4::Context->preference('AllowAllMessageDeletion'),
653 findborrower => $findborrower,
654 borrower => $borrower,
655 borrowernumber => $borrowernumber,
656 branch => $branch,
657 branchname => GetBranchName($borrower->{'branchcode'}),
658 printer => $printer,
659 printername => $printer,
660 firstname => $borrower->{'firstname'},
661 surname => $borrower->{'surname'},
662 showname => $borrower->{'showname'},
663 category_type => $borrower->{'category_type'},
664 dateexpiry => format_date($newexpiry),
665 expiry => format_date($borrower->{'dateexpiry'}),
666 categorycode => $borrower->{'categorycode'},
667 categoryname => $borrower->{description},
668 address => $address,
669 address2 => $borrower->{'address2'},
670 email => $borrower->{'email'},
671 emailpro => $borrower->{'emailpro'},
672 borrowernotes => $borrower->{'borrowernotes'},
673 city => $borrower->{'city'},
674 state => $borrower->{'state'},
675 zipcode => $borrower->{'zipcode'},
676 country => $borrower->{'country'},
677 phone => $borrower->{'phone'} || $borrower->{'mobile'},
678 cardnumber => $borrower->{'cardnumber'},
679 othernames => $borrower->{'othernames'},
680 amountold => $amountold,
681 barcode => $barcode,
682 stickyduedate => $stickyduedate,
683 duedatespec => $duedatespec,
684 message => $message,
685 CGIselectborrower => $CGIselectborrower,
686 totalprice => sprintf('%.2f', $totalprice),
687 totaldue => sprintf('%.2f', $total),
688 todayissues => \@todaysissues,
689 previssues => \@previousissues,
690 relissues => \@relissues,
691 relprevissues => \@relprevissues,
692 displayrelissues => $displayrelissues,
693 inprocess => $inprocess,
694 memberofinstution => $member_of_institution,
695 CGIorganisations => $CGIorganisations,
696 is_child => ($borrower->{'category_type'} eq 'C'),
697 circview => 1,
698 soundon => C4::Context->preference("SoundOn"),
699 fast_cataloging => $fast_cataloging,
700 CircAutoPrintQuickSlip => C4::Context->preference("CircAutoPrintQuickSlip"),
701 activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
704 # save stickyduedate to session
705 if ($stickyduedate) {
706 $session->param( 'stickyduedate', $duedatespec );
709 my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
710 $template->param( picture => 1 ) if $picture;
712 # get authorised values with type of BOR_NOTES
714 my $canned_notes = GetAuthorisedValues("BOR_NOTES");
716 $template->param(
717 debt_confirmed => $debt_confirmed,
718 SpecifyDueDate => $duedatespec_allow,
719 CircAutocompl => C4::Context->preference("CircAutocompl"),
720 AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
721 dateformat => C4::Context->preference("dateformat"),
722 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
723 canned_bor_notes_loop => $canned_notes,
725 output_html_with_http_headers $query, $cookie, $template->output;