Fix bug on opac-detail.pl with switch statement
[koha.git] / circ / circulation.pl
blob539b88ca046fe5d5fdd97313660835ad116e7005
1 #!/usr/bin/perl
3 # written 8/5/2002 by Finlay
4 # script to execute issuing of books
6 # Copyright 2000-2002 Katipo Communications
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; FIXME - Bug 2505
25 use CGI;
26 use C4::Output;
27 use C4::Print;
28 use C4::Auth qw/:DEFAULT get_session/;
29 use C4::Dates qw/format_date/;
30 use C4::Branch; # GetBranches
31 use C4::Koha; # GetPrinter
32 use C4::Circulation;
33 use C4::Members;
34 use C4::Biblio;
35 use C4::Reserves;
36 use C4::Context;
37 use CGI::Session;
39 use Date::Calc qw(
40 Today
41 Add_Delta_YM
42 Add_Delta_Days
43 Date_to_Days
48 # PARAMETERS READING
50 my $query = new CGI;
52 my $sessionID = $query->cookie("CGISESSID") ;
53 my $session = get_session($sessionID);
55 # branch and printer are now defined by the userenv
56 # but first we have to check if someone has tried to change them
58 my $branch = $query->param('branch');
59 if ($branch){
60 # update our session so the userenv is updated
61 $session->param('branch', $branch);
62 $session->param('branchname', GetBranchName($branch));
65 my $printer = $query->param('printer');
66 if ($printer){
67 # update our session so the userenv is updated
68 $session->param('branchprinter', $printer);
71 if (!C4::Context->userenv && !$branch){
72 if ($session->param('branch') eq 'NO_LIBRARY_SET'){
73 # no branch set we can't issue
74 print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
75 exit;
79 my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
81 template_name => 'circ/circulation.tmpl',
82 query => $query,
83 type => "intranet",
84 authnotrequired => 0,
85 flagsrequired => { circulate => 'circulate_remaining_permissions' },
89 my $branches = GetBranches();
91 my @failedrenews = $query->param('failedrenew'); # expected to be itemnumbers
92 my %renew_failed;
93 for (@failedrenews) { $renew_failed{$_} = 1; }
95 my $findborrower = $query->param('findborrower');
96 $findborrower =~ s|,| |g;
97 my $borrowernumber = $query->param('borrowernumber');
99 $branch = C4::Context->userenv->{'branch'};
100 $printer = C4::Context->userenv->{'branchprinter'};
103 # If AutoLocation is not activated, we show the Circulation Parameters to chage settings of librarian
104 if (C4::Context->preference("AutoLocation") != 1) {
105 $template->param(ManualLocation => 1);
108 if (C4::Context->preference("DisplayClearScreenButton")) {
109 $template->param(DisplayClearScreenButton => 1);
112 my $barcode = $query->param('barcode') || '';
113 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
115 $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
116 my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate');
117 my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate');
118 my $issueconfirmed = $query->param('issueconfirmed');
119 my $cancelreserve = $query->param('cancelreserve');
120 my $organisation = $query->param('organisations');
121 my $print = $query->param('print');
122 my $newexpiry = $query->param('dateexpiry');
123 my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice
125 # Check if stickyduedate is turned off
126 if ( $barcode ) {
127 # was stickyduedate loaded from session?
128 if ( $stickyduedate && ! $query->param("stickyduedate") ) {
129 $session->clear( 'stickyduedate' );
130 $stickyduedate = $query->param('stickyduedate');
131 $duedatespec = $query->param('duedatespec');
135 my ($datedue,$invalidduedate,$globalduedate);
137 if(C4::Context->preference('globalDueDate') && (C4::Context->preference('globalDueDate') =~ C4::Dates->regexp('syspref'))){
138 $globalduedate = C4::Dates->new(C4::Context->preference('globalDueDate'));
140 my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
141 if($duedatespec_allow){
142 if ($duedatespec) {
143 if ($duedatespec =~ C4::Dates->regexp('syspref')) {
144 my $tempdate = C4::Dates->new($duedatespec);
145 if ($tempdate and $tempdate->output('iso') gt C4::Dates->new()->output('iso')) {
146 # i.e., it has to be later than today/now
147 $datedue = $tempdate;
148 } else {
149 $invalidduedate = 1;
150 $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
152 } else {
153 $invalidduedate = 1;
154 $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
156 } else {
157 # pass global due date to tmpl if specifyduedate is true
158 # and we have no barcode (loading circ page but not checking out)
159 if($globalduedate && ! $barcode ){
160 $duedatespec = $globalduedate->output();
161 $stickyduedate = 1;
164 } else {
165 $datedue = $globalduedate if ($globalduedate);
168 my $todaysdate = C4::Dates->new->output('iso');
170 # check and see if we should print
171 if ( $barcode eq '' && $print eq 'maybe' ) {
172 $print = 'yes';
175 my $inprocess = ($barcode eq '') ? '' : $query->param('inprocess');
176 if ( $barcode eq '' && $query->param('charges') eq 'yes' ) {
177 $template->param(
178 PAYCHARGES => 'yes',
179 borrowernumber => $borrowernumber
183 if ( $print eq 'yes' && $borrowernumber ne '' ) {
184 printslip( $borrowernumber );
185 $query->param( 'borrowernumber', '' );
186 $borrowernumber = '';
190 # STEP 2 : FIND BORROWER
191 # if there is a list of find borrowers....
193 my $borrowerslist;
194 my $message;
195 if ($findborrower) {
196 my ($count, $borrowers) = SearchMember($findborrower, 'cardnumber', 'web');
197 my @borrowers = @$borrowers;
198 if (C4::Context->preference("AddPatronLists")) {
199 $template->param(
200 "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
202 if (C4::Context->preference("AddPatronLists")=~/code/){
203 my $categories = GetBorrowercategoryList;
204 $categories->[0]->{'first'} = 1;
205 $template->param(categories=>$categories);
208 if ( $#borrowers == -1 ) {
209 $query->param( 'findborrower', '' );
210 $message = "'$findborrower'";
212 elsif ( $#borrowers == 0 ) {
213 $query->param( 'borrowernumber', $borrowers[0]->{'borrowernumber'} );
214 $query->param( 'barcode', '' );
215 $borrowernumber = $borrowers[0]->{'borrowernumber'};
217 else {
218 $borrowerslist = \@borrowers;
222 # get the borrower information.....
223 my $borrower;
224 if ($borrowernumber) {
225 $borrower = GetMemberDetails( $borrowernumber, 0 );
226 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
228 # Warningdate is the date that the warning starts appearing
229 my ( $today_year, $today_month, $today_day) = Today();
230 my ($warning_year, $warning_month, $warning_day) = split /-/, $borrower->{'dateexpiry'};
231 my ( $enrol_year, $enrol_month, $enrol_day) = split /-/, $borrower->{'dateenrolled'};
232 # Renew day is calculated by adding the enrolment period to today
233 my ( $renew_year, $renew_month, $renew_day);
234 if ($enrol_year*$enrol_month*$enrol_day>0) {
235 ( $renew_year, $renew_month, $renew_day) =
236 Add_Delta_YM( $enrol_year, $enrol_month, $enrol_day,
237 0 , $borrower->{'enrolmentperiod'});
239 # if the expiry date is before today ie they have expired
240 if ( $warning_year*$warning_month*$warning_day==0
241 || Date_to_Days($today_year, $today_month, $today_day )
242 > Date_to_Days($warning_year, $warning_month, $warning_day) )
244 #borrowercard expired, no issues
245 $template->param(
246 flagged => "1",
247 noissues => "1",
248 expired => format_date($borrower->{dateexpiry}),
249 renewaldate => format_date("$renew_year-$renew_month-$renew_day")
252 # check for NotifyBorrowerDeparture
253 elsif ( C4::Context->preference('NotifyBorrowerDeparture') &&
254 Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
255 Date_to_Days( $today_year, $today_month, $today_day ) )
257 # borrower card soon to expire warn librarian
258 $template->param("warndeparture" => format_date($borrower->{dateexpiry}),
259 flagged => "1",);
260 if (C4::Context->preference('ReturnBeforeExpiry')){
261 $template->param("returnbeforeexpiry" => 1);
264 $template->param(
265 overduecount => $od,
266 issuecount => $issue,
267 finetotal => $fines
272 # STEP 3 : ISSUING
275 if ($barcode) {
276 # always check for blockers on issuing
277 my ( $error, $question ) =
278 CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess );
279 my $blocker = $invalidduedate ? 1 : 0;
281 delete $question->{'DEBT'} if ($debt_confirmed);
282 foreach my $impossible ( keys %$error ) {
283 $template->param(
284 $impossible => $$error{$impossible},
285 IMPOSSIBLE => 1
287 $blocker = 1;
289 if( !$blocker ){
290 my $confirm_required = 0;
291 unless($issueconfirmed){
292 # Get the item title for more information
293 my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
294 $template->param( itemhomebranch => $getmessageiteminfo->{'homebranch'} );
296 # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
297 foreach my $needsconfirmation ( keys %$question ) {
298 $template->param(
299 $needsconfirmation => $$question{$needsconfirmation},
300 getTitleMessageIteminfo => $getmessageiteminfo->{'title'},
301 NEEDSCONFIRMATION => 1
303 $confirm_required = 1;
306 unless($confirm_required) {
307 AddIssue( $borrower, $barcode, $datedue, $cancelreserve );
308 $inprocess = 1;
309 if($globalduedate && ! $stickyduedate && $duedatespec_allow ){
310 $duedatespec = $globalduedate->output();
311 $stickyduedate = 1;
316 # FIXME If the issue is confirmed, we launch another time GetMemberIssuesAndFines, now display the issue count after issue
317 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
318 $template->param( issuecount => $issue );
321 # reload the borrower info for the sake of reseting the flags.....
322 if ($borrowernumber) {
323 $borrower = GetMemberDetails( $borrowernumber, 0 );
326 ##################################################################################
327 # BUILD HTML
328 # show all reserves of this borrower, and the position of the reservation ....
329 if ($borrowernumber) {
331 # new op dev
332 # now we show the status of the borrower's reservations
333 my @borrowerreserv = GetReservesFromBorrowernumber($borrowernumber );
334 my @reservloop;
335 my @WaitingReserveLoop;
337 foreach my $num_res (@borrowerreserv) {
338 my %getreserv;
339 my %getWaitingReserveInfo;
340 my $getiteminfo = GetBiblioFromItemNumber( $num_res->{'itemnumber'} );
341 my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $getiteminfo->{'itype'} : $getiteminfo->{'itemtype'} );
342 my ( $transfertwhen, $transfertfrom, $transfertto ) =
343 GetTransfers( $num_res->{'itemnumber'} );
345 $getreserv{waiting} = 0;
346 $getreserv{transfered} = 0;
347 $getreserv{nottransfered} = 0;
349 $getreserv{reservedate} = format_date( $num_res->{'reservedate'} );
350 $getreserv{title} = $getiteminfo->{'title'};
351 $getreserv{itemtype} = $itemtypeinfo->{'description'};
352 $getreserv{author} = $getiteminfo->{'author'};
353 $getreserv{barcodereserv} = $getiteminfo->{'barcode'};
354 $getreserv{itemcallnumber} = $getiteminfo->{'itemcallnumber'};
355 $getreserv{biblionumber} = $getiteminfo->{'biblionumber'};
356 $getreserv{waitingat} = GetBranchName( $num_res->{'branchcode'} );
357 # check if we have a waiting status for reservations
358 if ( $num_res->{'found'} eq 'W' ) {
359 $getreserv{color} = 'reserved';
360 $getreserv{waiting} = 1;
361 # genarate information displaying only waiting reserves
362 $getWaitingReserveInfo{title} = $getiteminfo->{'title'};
363 $getWaitingReserveInfo{biblionumber} = $getiteminfo->{'biblionumber'};
364 $getWaitingReserveInfo{itemtype} = $itemtypeinfo->{'description'};
365 $getWaitingReserveInfo{author} = $getiteminfo->{'author'};
366 $getWaitingReserveInfo{reservedate} = format_date( $num_res->{'reservedate'} );
367 $getWaitingReserveInfo{waitingat} = GetBranchName( $num_res->{'branchcode'} );
368 $getWaitingReserveInfo{waitinghere} = 1 if $num_res->{'branchcode'} eq $branch;
370 # check transfers with the itemnumber foud in th reservation loop
371 if ($transfertwhen) {
372 $getreserv{color} = 'transfered';
373 $getreserv{transfered} = 1;
374 $getreserv{datesent} = format_date($transfertwhen);
375 $getreserv{frombranch} = GetBranchName($transfertfrom);
376 } elsif ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'}) {
377 $getreserv{nottransfered} = 1;
378 $getreserv{nottransferedby} = GetBranchName( $getiteminfo->{'holdingbranch'} );
381 # if we don't have a reserv on item, we put the biblio infos and the waiting position
382 if ( $getiteminfo->{'title'} eq '' ) {
383 my $getbibinfo = GetBiblioData( $num_res->{'biblionumber'} );
385 $getreserv{color} = 'inwait';
386 $getreserv{title} = $getbibinfo->{'title'};
387 $getreserv{nottransfered} = 0;
388 $getreserv{itemtype} = $itemtypeinfo->{'description'};
389 $getreserv{author} = $getbibinfo->{'author'};
390 $getreserv{biblionumber} = $num_res->{'biblionumber'};
392 $getreserv{waitingposition} = $num_res->{'priority'};
393 push( @reservloop, \%getreserv );
395 # if we have a reserve waiting, initiate waitingreserveloop
396 if ($getreserv{waiting} == 1) {
397 push (@WaitingReserveLoop, \%getWaitingReserveInfo)
402 # return result to the template
403 $template->param(
404 countreserv => scalar @reservloop,
405 reservloop => \@reservloop ,
406 WaitingReserveLoop => \@WaitingReserveLoop,
408 $template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' );
411 # make the issued books table.
412 my $todaysissues = '';
413 my $previssues = '';
414 my @todaysissues;
415 my @previousissues;
417 my $totalprice = 0;
419 if ($borrower) {
420 # get each issue of the borrower & separate them in todayissues & previous issues
421 my ($issueslist) = GetPendingIssues($borrower->{'borrowernumber'});
422 # split in 2 arrays for today & previous
423 foreach my $it ( @$issueslist ) {
424 my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $it->{'itype'} : $it->{'itemtype'} );
425 # set itemtype per item-level_itype syspref - FIXME this is an ugly hack
426 $it->{'itemtype'} = ( C4::Context->preference( 'item-level_itypes' ) ) ? $it->{'itype'} : $it->{'itemtype'};
428 ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
429 $it->{'itemnumber'}, $borrower->{'borrowernumber'}
431 $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
432 my ($can_renew, $can_renew_error) = CanBookBeRenewed(
433 $borrower->{'borrowernumber'},$it->{'itemnumber'}
435 $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
436 my ( $restype, $reserves ) = CheckReserves( $it->{'itemnumber'} );
437 $it->{'can_renew'} = $can_renew;
438 $it->{'can_confirm'} = !$can_renew && !$restype;
439 $it->{'renew_error'} = $restype;
440 $it->{'checkoutdate'} = C4::Dates->new($it->{'issuedate'},'iso')->output('syspref');
442 $totalprice += $it->{'replacementprice'};
443 $it->{'itemtype'} = $itemtypeinfo->{'description'};
444 $it->{'itemtype_image'} = $itemtypeinfo->{'imageurl'};
445 $it->{'dd'} = format_date($it->{'date_due'});
446 $it->{'displaydate'} = format_date($it->{'issuedate'});
447 $it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ;
448 ($it->{'author'} eq '') and $it->{'author'} = ' ';
449 $it->{'renew_failed'} = $renew_failed{$it->{'itemnumber'}};
451 if ( $todaysdate eq $it->{'issuedate'} or $todaysdate eq $it->{'lastreneweddate'} ) {
452 push @todaysissues, $it;
453 } else {
454 push @previousissues, $it;
457 if ( C4::Context->preference( "todaysIssuesDefaultSortOrder" ) eq 'asc' ) {
458 @todaysissues = sort { $a->{'timestamp'} cmp $b->{'timestamp'} } @todaysissues;
460 else {
461 @todaysissues = sort { $b->{'timestamp'} cmp $a->{'timestamp'} } @todaysissues;
463 if ( C4::Context->preference( "previousIssuesDefaultSortOrder" ) eq 'asc' ){
464 @previousissues = sort { $a->{'date_due'} cmp $b->{'date_due'} } @previousissues;
466 else {
467 @previousissues = sort { $b->{'date_due'} cmp $a->{'date_due'} } @previousissues;
472 my @values;
473 my %labels;
474 my $CGIselectborrower;
475 if ($borrowerslist) {
476 foreach (
477 sort {(lc $a->{'surname'} cmp lc $b->{'surname'} || lc $a->{'firstname'} cmp lc $b->{'firstname'})
478 } @$borrowerslist
481 push @values, $_->{'borrowernumber'};
482 $labels{ $_->{'borrowernumber'} } =
483 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'}) ... $_->{'address'} ";
485 $CGIselectborrower = CGI::scrolling_list(
486 -name => 'borrowernumber',
487 -class => 'focus',
488 -id => 'borrowernumber',
489 -values => \@values,
490 -labels => \%labels,
491 -onclick => "window.location = '/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + this.value;",
492 -size => 7,
493 -tabindex => '',
494 -multiple => 0
498 #title
499 my $flags = $borrower->{'flags'};
500 foreach my $flag ( sort keys %$flags ) {
501 $template->param( flagged=> 1);
502 $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
503 if ( $flags->{$flag}->{'noissues'} ) {
504 $template->param(
505 flagged => 1,
506 noissues => 'true',
508 if ( $flag eq 'GNA' ) {
509 $template->param( gna => 'true' );
511 elsif ( $flag eq 'LOST' ) {
512 $template->param( lost => 'true' );
514 elsif ( $flag eq 'DBARRED' ) {
515 $template->param( dbarred => 'true' );
517 elsif ( $flag eq 'CHARGES' ) {
518 $template->param(
519 charges => 'true',
520 chargesmsg => $flags->{'CHARGES'}->{'message'},
521 chargesamount => $flags->{'CHARGES'}->{'amount'},
522 charges_is_blocker => 1
525 elsif ( $flag eq 'CREDITS' ) {
526 $template->param(
527 credits => 'true',
528 creditsmsg => $flags->{'CREDITS'}->{'message'},
529 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
533 else {
534 if ( $flag eq 'CHARGES' ) {
535 $template->param(
536 charges => 'true',
537 flagged => 1,
538 chargesmsg => $flags->{'CHARGES'}->{'message'},
539 chargesamount => $flags->{'CHARGES'}->{'amount'},
542 elsif ( $flag eq 'CREDITS' ) {
543 $template->param(
544 credits => 'true',
545 creditsmsg => $flags->{'CREDITS'}->{'message'},
546 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
549 elsif ( $flag eq 'ODUES' ) {
550 $template->param(
551 odues => 'true',
552 flagged => 1,
553 oduesmsg => $flags->{'ODUES'}->{'message'}
556 my $items = $flags->{$flag}->{'itemlist'};
557 if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
558 $template->param( nonreturns => 'true' );
561 elsif ( $flag eq 'NOTES' ) {
562 $template->param(
563 notes => 'true',
564 flagged => 1,
565 notesmsg => $flags->{'NOTES'}->{'message'}
571 my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
572 $amountold =~ s/^.*\$//; # remove upto the $, if any
574 my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
576 if ( $borrower->{'category_type'} eq 'C') {
577 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
578 my $cnt = scalar(@$catcodes);
579 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
580 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
583 my $CGIorganisations;
584 my $member_of_institution;
585 if ( C4::Context->preference("memberofinstitution") ) {
586 my $organisations = get_institutions();
587 my @orgs;
588 my %org_labels;
589 foreach my $organisation ( keys %$organisations ) {
590 push @orgs, $organisation;
591 $org_labels{$organisation} = $organisations->{$organisation}->{'surname'};
593 $member_of_institution = 1;
594 $CGIorganisations = CGI::popup_menu(
595 -id => 'organisations',
596 -name => 'organisations',
597 -labels => \%org_labels,
598 -values => \@orgs,
602 my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch );
603 if($lib_messages_loop){ $template->param(flagged => 1 ); }
605 my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch );
606 if($bor_messages_loop){ $template->param(flagged => 1 ); }
608 # Computes full borrower address
609 my (undef, $roadttype_hashref) = &GetRoadTypes();
610 my $address = $borrower->{'streetnumber'}.' '.$roadttype_hashref->{$borrower->{'streettype'}}.' '.$borrower->{'address'};
612 $template->param(
613 lib_messages_loop => $lib_messages_loop,
614 bor_messages_loop => $bor_messages_loop,
615 all_messages_del => C4::Context->preference('AllowAllMessageDeletion'),
616 findborrower => $findborrower,
617 borrower => $borrower,
618 borrowernumber => $borrowernumber,
619 branch => $branch,
620 branchname => GetBranchName($borrower->{'branchcode'}),
621 printer => $printer,
622 printername => $printer,
623 firstname => $borrower->{'firstname'},
624 surname => $borrower->{'surname'},
625 dateexpiry => format_date($newexpiry),
626 expiry => format_date($borrower->{'dateexpiry'}),
627 categorycode => $borrower->{'categorycode'},
628 categoryname => $borrower->{description},
629 address => $address,
630 address2 => $borrower->{'address2'},
631 email => $borrower->{'email'},
632 emailpro => $borrower->{'emailpro'},
633 borrowernotes => $borrower->{'borrowernotes'},
634 city => $borrower->{'city'},
635 zipcode => $borrower->{'zipcode'},
636 country => $borrower->{'country'},
637 phone => $borrower->{'phone'} || $borrower->{'mobile'},
638 cardnumber => $borrower->{'cardnumber'},
639 amountold => $amountold,
640 barcode => $barcode,
641 stickyduedate => $stickyduedate,
642 duedatespec => $duedatespec,
643 message => $message,
644 CGIselectborrower => $CGIselectborrower,
645 totalprice => sprintf('%.2f', $totalprice),
646 totaldue => sprintf('%.2f', $total),
647 todayissues => \@todaysissues,
648 previssues => \@previousissues,
649 inprocess => $inprocess,
650 memberofinstution => $member_of_institution,
651 CGIorganisations => $CGIorganisations,
652 is_child => ($borrower->{'category_type'} eq 'C'),
653 circview => 1,
654 soundon => C4::Context->preference("SoundOn"),
657 # save stickyduedate to session
658 if ($stickyduedate) {
659 $session->param( 'stickyduedate', $duedatespec );
662 my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
663 $template->param( picture => 1 ) if $picture;
665 # get authorised values with type of BOR_NOTES
667 my $canned_notes = GetAuthorisedValues("BOR_NOTES");
669 $template->param(
670 debt_confirmed => $debt_confirmed,
671 SpecifyDueDate => $duedatespec_allow,
672 CircAutocompl => C4::Context->preference("CircAutocompl"),
673 AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
674 dateformat => C4::Context->preference("dateformat"),
675 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
676 canned_bor_notes_loop => $canned_notes,
678 output_html_with_http_headers $query, $cookie, $template->output;