(MT #1654) followup : corrects tablesorting for authorised_values.pl
[koha.git] / circ / circulation.pl
blobab681f1c7ca36fe8d6bf588f7aff7adaa37da41a
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 if (C4::Context->preference("UseTablesortForCirc")) {
113 $template->param(UseTablesortForCirc => 1);
116 my $barcode = $query->param('barcode') || '';
117 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
119 $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
120 my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate');
121 my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate');
122 my $issueconfirmed = $query->param('issueconfirmed');
123 my $cancelreserve = $query->param('cancelreserve');
124 my $organisation = $query->param('organisations');
125 my $print = $query->param('print');
126 my $newexpiry = $query->param('dateexpiry');
127 my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice
129 # Check if stickyduedate is turned off
130 if ( $barcode ) {
131 # was stickyduedate loaded from session?
132 if ( $stickyduedate && ! $query->param("stickyduedate") ) {
133 $session->clear( 'stickyduedate' );
134 $stickyduedate = $query->param('stickyduedate');
135 $duedatespec = $query->param('duedatespec');
139 my ($datedue,$invalidduedate,$globalduedate);
141 if(C4::Context->preference('globalDueDate') && (C4::Context->preference('globalDueDate') =~ C4::Dates->regexp('syspref'))){
142 $globalduedate = C4::Dates->new(C4::Context->preference('globalDueDate'));
144 my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
145 if($duedatespec_allow){
146 if ($duedatespec) {
147 if ($duedatespec =~ C4::Dates->regexp('syspref')) {
148 my $tempdate = C4::Dates->new($duedatespec);
149 # if ($tempdate and $tempdate->output('iso') gt C4::Dates->new()->output('iso')) {
150 # # i.e., it has to be later than today/now
151 $datedue = $tempdate;
152 # } else {
153 # $invalidduedate = 1;
154 # $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
156 } else {
157 $invalidduedate = 1;
158 $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
160 } else {
161 # pass global due date to tmpl if specifyduedate is true
162 # and we have no barcode (loading circ page but not checking out)
163 if($globalduedate && ! $barcode ){
164 $duedatespec = $globalduedate->output();
165 $stickyduedate = 1;
168 } else {
169 $datedue = $globalduedate if ($globalduedate);
172 my $todaysdate = C4::Dates->new->output('iso');
174 # check and see if we should print
175 if ( $barcode eq '' && $print eq 'maybe' ) {
176 $print = 'yes';
179 my $inprocess = ($barcode eq '') ? '' : $query->param('inprocess');
180 if ( $barcode eq '' && $query->param('charges') eq 'yes' ) {
181 $template->param(
182 PAYCHARGES => 'yes',
183 borrowernumber => $borrowernumber
187 if ( $print eq 'yes' && $borrowernumber ne '' ) {
188 printslip( $borrowernumber );
189 $query->param( 'borrowernumber', '' );
190 $borrowernumber = '';
194 # STEP 2 : FIND BORROWER
195 # if there is a list of find borrowers....
197 my $borrowerslist;
198 my $message;
199 if ($findborrower) {
200 my ($count, $borrowers) = SearchMember($findborrower, 'cardnumber', 'web');
201 my @borrowers = @$borrowers;
202 if (C4::Context->preference("AddPatronLists")) {
203 $template->param(
204 "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
206 if (C4::Context->preference("AddPatronLists")=~/code/){
207 my $categories = GetBorrowercategoryList;
208 $categories->[0]->{'first'} = 1;
209 $template->param(categories=>$categories);
212 if ( $#borrowers == -1 ) {
213 $query->param( 'findborrower', '' );
214 $message = "'$findborrower'";
216 elsif ( $#borrowers == 0 ) {
217 $query->param( 'borrowernumber', $borrowers[0]->{'borrowernumber'} );
218 $query->param( 'barcode', '' );
219 $borrowernumber = $borrowers[0]->{'borrowernumber'};
221 else {
222 $borrowerslist = \@borrowers;
226 # get the borrower information.....
227 my $borrower;
228 if ($borrowernumber) {
229 $borrower = GetMemberDetails( $borrowernumber, 0 );
230 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
232 # Warningdate is the date that the warning starts appearing
233 my ( $today_year, $today_month, $today_day) = Today();
234 my ($warning_year, $warning_month, $warning_day) = split /-/, $borrower->{'dateexpiry'};
235 my ( $enrol_year, $enrol_month, $enrol_day) = split /-/, $borrower->{'dateenrolled'};
236 # Renew day is calculated by adding the enrolment period to today
237 my ( $renew_year, $renew_month, $renew_day);
238 if ($enrol_year*$enrol_month*$enrol_day>0) {
239 ( $renew_year, $renew_month, $renew_day) =
240 Add_Delta_YM( $enrol_year, $enrol_month, $enrol_day,
241 0 , $borrower->{'enrolmentperiod'});
243 # if the expiry date is before today ie they have expired
244 if ( $warning_year*$warning_month*$warning_day==0
245 || Date_to_Days($today_year, $today_month, $today_day )
246 > Date_to_Days($warning_year, $warning_month, $warning_day) )
248 #borrowercard expired, no issues
249 $template->param(
250 flagged => "1",
251 noissues => "1",
252 expired => format_date($borrower->{dateexpiry}),
253 renewaldate => format_date("$renew_year-$renew_month-$renew_day")
256 # check for NotifyBorrowerDeparture
257 elsif ( C4::Context->preference('NotifyBorrowerDeparture') &&
258 Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
259 Date_to_Days( $today_year, $today_month, $today_day ) )
261 # borrower card soon to expire warn librarian
262 $template->param("warndeparture" => format_date($borrower->{dateexpiry}),
263 flagged => "1",);
264 if (C4::Context->preference('ReturnBeforeExpiry')){
265 $template->param("returnbeforeexpiry" => 1);
268 $template->param(
269 overduecount => $od,
270 issuecount => $issue,
271 finetotal => $fines
276 # STEP 3 : ISSUING
279 if ($barcode) {
280 # always check for blockers on issuing
281 my ( $error, $question ) =
282 CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess );
283 my $blocker = $invalidduedate ? 1 : 0;
285 delete $question->{'DEBT'} if ($debt_confirmed);
286 foreach my $impossible ( keys %$error ) {
287 $template->param(
288 $impossible => $$error{$impossible},
289 IMPOSSIBLE => 1
291 $blocker = 1;
293 if( !$blocker ){
294 my $confirm_required = 0;
295 unless($issueconfirmed){
296 # Get the item title for more information
297 my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
298 $template->param( itemhomebranch => $getmessageiteminfo->{'homebranch'} );
300 # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
301 foreach my $needsconfirmation ( keys %$question ) {
302 $template->param(
303 $needsconfirmation => $$question{$needsconfirmation},
304 getTitleMessageIteminfo => $getmessageiteminfo->{'title'},
305 getBarcodeMessageIteminfo => $getmessageiteminfo->{'barcode'},
306 NEEDSCONFIRMATION => 1
308 $confirm_required = 1;
311 unless($confirm_required) {
312 AddIssue( $borrower, $barcode, $datedue, $cancelreserve );
313 $inprocess = 1;
314 if($globalduedate && ! $stickyduedate && $duedatespec_allow ){
315 $duedatespec = $globalduedate->output();
316 $stickyduedate = 1;
321 # FIXME If the issue is confirmed, we launch another time GetMemberIssuesAndFines, now display the issue count after issue
322 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
323 $template->param( issuecount => $issue );
326 # reload the borrower info for the sake of reseting the flags.....
327 if ($borrowernumber) {
328 $borrower = GetMemberDetails( $borrowernumber, 0 );
331 ##################################################################################
332 # BUILD HTML
333 # show all reserves of this borrower, and the position of the reservation ....
334 if ($borrowernumber) {
336 # new op dev
337 # now we show the status of the borrower's reservations
338 my @borrowerreserv = GetReservesFromBorrowernumber($borrowernumber );
339 my @reservloop;
340 my @WaitingReserveLoop;
342 foreach my $num_res (@borrowerreserv) {
343 my %getreserv;
344 my %getWaitingReserveInfo;
345 my $getiteminfo = GetBiblioFromItemNumber( $num_res->{'itemnumber'} );
346 my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $getiteminfo->{'itype'} : $getiteminfo->{'itemtype'} );
347 my ( $transfertwhen, $transfertfrom, $transfertto ) =
348 GetTransfers( $num_res->{'itemnumber'} );
350 $getreserv{waiting} = 0;
351 $getreserv{transfered} = 0;
352 $getreserv{nottransfered} = 0;
354 $getreserv{reservedate} = format_date( $num_res->{'reservedate'} );
355 $getreserv{reservenumber} = $num_res->{'reservenumber'};
356 $getreserv{title} = $getiteminfo->{'title'};
357 $getreserv{itemtype} = $itemtypeinfo->{'description'};
358 $getreserv{author} = $getiteminfo->{'author'};
359 $getreserv{barcodereserv} = $getiteminfo->{'barcode'};
360 $getreserv{itemcallnumber} = $getiteminfo->{'itemcallnumber'};
361 $getreserv{biblionumber} = $getiteminfo->{'biblionumber'};
362 $getreserv{waitingat} = GetBranchName( $num_res->{'branchcode'} );
363 # check if we have a waiting status for reservations
364 if ( $num_res->{'found'} eq 'W' ) {
365 $getreserv{color} = 'reserved';
366 $getreserv{waiting} = 1;
367 # genarate information displaying only waiting reserves
368 $getWaitingReserveInfo{title} = $getiteminfo->{'title'};
369 $getWaitingReserveInfo{biblionumber} = $getiteminfo->{'biblionumber'};
370 $getWaitingReserveInfo{itemtype} = $itemtypeinfo->{'description'};
371 $getWaitingReserveInfo{author} = $getiteminfo->{'author'};
372 $getWaitingReserveInfo{reservedate} = format_date( $num_res->{'reservedate'} );
373 $getWaitingReserveInfo{waitingat} = GetBranchName( $num_res->{'branchcode'} );
374 $getWaitingReserveInfo{waitinghere} = 1 if $num_res->{'branchcode'} eq $branch;
376 # check transfers with the itemnumber foud in th reservation loop
377 if ($transfertwhen) {
378 $getreserv{color} = 'transfered';
379 $getreserv{transfered} = 1;
380 $getreserv{datesent} = format_date($transfertwhen);
381 $getreserv{frombranch} = GetBranchName($transfertfrom);
382 } elsif ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'}) {
383 $getreserv{nottransfered} = 1;
384 $getreserv{nottransferedby} = GetBranchName( $getiteminfo->{'holdingbranch'} );
387 # if we don't have a reserv on item, we put the biblio infos and the waiting position
388 if ( $getiteminfo->{'title'} eq '' ) {
389 my $getbibinfo = GetBiblioData( $num_res->{'biblionumber'} );
391 $getreserv{color} = 'inwait';
392 $getreserv{title} = $getbibinfo->{'title'};
393 $getreserv{nottransfered} = 0;
394 $getreserv{itemtype} = $itemtypeinfo->{'description'};
395 $getreserv{author} = $getbibinfo->{'author'};
396 $getreserv{biblionumber} = $num_res->{'biblionumber'};
398 $getreserv{waitingposition} = $num_res->{'priority'};
399 push( @reservloop, \%getreserv );
401 # if we have a reserve waiting, initiate waitingreserveloop
402 if ($getreserv{waiting} == 1) {
403 push (@WaitingReserveLoop, \%getWaitingReserveInfo)
408 # return result to the template
409 $template->param(
410 countreserv => scalar @reservloop,
411 reservloop => \@reservloop ,
412 WaitingReserveLoop => \@WaitingReserveLoop,
414 $template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' );
417 # make the issued books table.
418 my $todaysissues = '';
419 my $previssues = '';
420 my @todaysissues;
421 my @previousissues;
423 my $totalprice = 0;
425 if ($borrower) {
426 # get each issue of the borrower & separate them in todayissues & previous issues
427 my ($issueslist) = GetPendingIssues($borrower->{'borrowernumber'});
428 # split in 2 arrays for today & previous
429 foreach my $it ( @$issueslist ) {
430 my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $it->{'itype'} : $it->{'itemtype'} );
431 # set itemtype per item-level_itype syspref - FIXME this is an ugly hack
432 $it->{'itemtype'} = ( C4::Context->preference( 'item-level_itypes' ) ) ? $it->{'itype'} : $it->{'itemtype'};
434 ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
435 $it->{'itemnumber'}, $borrower->{'borrowernumber'}
437 $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
438 my ($can_renew, $can_renew_error) = CanBookBeRenewed(
439 $borrower->{'borrowernumber'},$it->{'itemnumber'}
441 $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
442 my ( $restype, $reserves ) = CheckReserves( $it->{'itemnumber'} );
443 $it->{'can_renew'} = $can_renew;
444 $it->{'can_confirm'} = !$can_renew && !$restype;
445 $it->{'renew_error'} = $restype;
446 $it->{'checkoutdate'} = C4::Dates->new($it->{'issuedate'},'iso')->output('syspref');
448 $totalprice += $it->{'replacementprice'};
449 $it->{'itemtype'} = $itemtypeinfo->{'description'};
450 $it->{'itemtype_image'} = $itemtypeinfo->{'imageurl'};
451 $it->{'dd'} = format_date($it->{'date_due'});
452 $it->{'displaydate'} = format_date($it->{'issuedate'});
453 $it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ;
454 ($it->{'author'} eq '') and $it->{'author'} = ' ';
455 $it->{'renew_failed'} = $renew_failed{$it->{'itemnumber'}};
457 if ( $todaysdate eq $it->{'issuedate'} or $todaysdate eq $it->{'lastreneweddate'} ) {
458 push @todaysissues, $it;
459 } else {
460 push @previousissues, $it;
463 if ( C4::Context->preference( "todaysIssuesDefaultSortOrder" ) eq 'asc' ) {
464 @todaysissues = sort { $a->{'timestamp'} cmp $b->{'timestamp'} } @todaysissues;
466 else {
467 @todaysissues = sort { $b->{'timestamp'} cmp $a->{'timestamp'} } @todaysissues;
469 if ( C4::Context->preference( "previousIssuesDefaultSortOrder" ) eq 'asc' ){
470 @previousissues = sort { $a->{'date_due'} cmp $b->{'date_due'} } @previousissues;
472 else {
473 @previousissues = sort { $b->{'date_due'} cmp $a->{'date_due'} } @previousissues;
478 my @values;
479 my %labels;
480 my $CGIselectborrower;
481 if ($borrowerslist) {
482 foreach (
483 sort {(lc $a->{'surname'} cmp lc $b->{'surname'} || lc $a->{'firstname'} cmp lc $b->{'firstname'})
484 } @$borrowerslist
487 push @values, $_->{'borrowernumber'};
488 $labels{ $_->{'borrowernumber'} } =
489 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'}) ... $_->{'address'} ";
491 $CGIselectborrower = CGI::scrolling_list(
492 -name => 'borrowernumber',
493 -class => 'focus',
494 -id => 'borrowernumber',
495 -values => \@values,
496 -labels => \%labels,
497 -size => 7,
498 -tabindex => '',
499 -multiple => 0
503 #title
504 my $flags = $borrower->{'flags'};
505 foreach my $flag ( sort keys %$flags ) {
506 $template->param( flagged=> 1);
507 $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
508 if ( $flags->{$flag}->{'noissues'} ) {
509 $template->param(
510 flagged => 1,
511 noissues => 'true',
513 if ( $flag eq 'GNA' ) {
514 $template->param( gna => 'true' );
516 elsif ( $flag eq 'LOST' ) {
517 $template->param( lost => 'true' );
519 elsif ( $flag eq 'DBARRED' ) {
520 $template->param( dbarred => 'true' );
522 elsif ( $flag eq 'CHARGES' ) {
523 $template->param(
524 charges => 'true',
525 chargesmsg => $flags->{'CHARGES'}->{'message'},
526 chargesamount => $flags->{'CHARGES'}->{'amount'},
527 charges_is_blocker => 1
530 elsif ( $flag eq 'CREDITS' ) {
531 $template->param(
532 credits => 'true',
533 creditsmsg => $flags->{'CREDITS'}->{'message'},
534 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
538 else {
539 if ( $flag eq 'CHARGES' ) {
540 $template->param(
541 charges => 'true',
542 flagged => 1,
543 chargesmsg => $flags->{'CHARGES'}->{'message'},
544 chargesamount => $flags->{'CHARGES'}->{'amount'},
547 elsif ( $flag eq 'CREDITS' ) {
548 $template->param(
549 credits => 'true',
550 creditsmsg => $flags->{'CREDITS'}->{'message'},
551 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
554 elsif ( $flag eq 'ODUES' ) {
555 $template->param(
556 odues => 'true',
557 flagged => 1,
558 oduesmsg => $flags->{'ODUES'}->{'message'}
561 my $items = $flags->{$flag}->{'itemlist'};
562 if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
563 $template->param( nonreturns => 'true' );
566 elsif ( $flag eq 'NOTES' ) {
567 $template->param(
568 notes => 'true',
569 flagged => 1,
570 notesmsg => $flags->{'NOTES'}->{'message'}
576 my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
577 $amountold =~ s/^.*\$//; # remove upto the $, if any
579 my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
581 if ( $borrower->{'category_type'} eq 'C') {
582 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
583 my $cnt = scalar(@$catcodes);
584 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
585 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
588 my $CGIorganisations;
589 my $member_of_institution;
590 if ( C4::Context->preference("memberofinstitution") ) {
591 my $organisations = get_institutions();
592 my @orgs;
593 my %org_labels;
594 foreach my $organisation ( keys %$organisations ) {
595 push @orgs, $organisation;
596 $org_labels{$organisation} = $organisations->{$organisation}->{'surname'};
598 $member_of_institution = 1;
599 $CGIorganisations = CGI::popup_menu(
600 -id => 'organisations',
601 -name => 'organisations',
602 -labels => \%org_labels,
603 -values => \@orgs,
607 my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch );
608 if($lib_messages_loop){ $template->param(flagged => 1 ); }
610 my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch );
611 if($bor_messages_loop){ $template->param(flagged => 1 ); }
613 # Computes full borrower address
614 my (undef, $roadttype_hashref) = &GetRoadTypes();
615 my $address = $borrower->{'streetnumber'}.' '.$roadttype_hashref->{$borrower->{'streettype'}}.' '.$borrower->{'address'};
617 $template->param(
618 lib_messages_loop => $lib_messages_loop,
619 bor_messages_loop => $bor_messages_loop,
620 all_messages_del => C4::Context->preference('AllowAllMessageDeletion'),
621 findborrower => $findborrower,
622 borrower => $borrower,
623 borrowernumber => $borrowernumber,
624 branch => $branch,
625 branchname => GetBranchName($borrower->{'branchcode'}),
626 printer => $printer,
627 printername => $printer,
628 firstname => $borrower->{'firstname'},
629 surname => $borrower->{'surname'},
630 dateexpiry => format_date($newexpiry),
631 expiry => format_date($borrower->{'dateexpiry'}),
632 categorycode => $borrower->{'categorycode'},
633 categoryname => $borrower->{description},
634 address => $address,
635 address2 => $borrower->{'address2'},
636 email => $borrower->{'email'},
637 emailpro => $borrower->{'emailpro'},
638 borrowernotes => $borrower->{'borrowernotes'},
639 city => $borrower->{'city'},
640 zipcode => $borrower->{'zipcode'},
641 country => $borrower->{'country'},
642 phone => $borrower->{'phone'} || $borrower->{'mobile'},
643 cardnumber => $borrower->{'cardnumber'},
644 amountold => $amountold,
645 barcode => $barcode,
646 stickyduedate => $stickyduedate,
647 duedatespec => $duedatespec,
648 message => $message,
649 CGIselectborrower => $CGIselectborrower,
650 totalprice => sprintf('%.2f', $totalprice),
651 totaldue => sprintf('%.2f', $total),
652 todayissues => \@todaysissues,
653 previssues => \@previousissues,
654 inprocess => $inprocess,
655 memberofinstution => $member_of_institution,
656 CGIorganisations => $CGIorganisations,
657 is_child => ($borrower->{'category_type'} eq 'C'),
658 circview => 1,
659 soundon => C4::Context->preference("SoundOn"),
662 # save stickyduedate to session
663 if ($stickyduedate) {
664 $session->param( 'stickyduedate', $duedatespec );
667 my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
668 $template->param( picture => 1 ) if $picture;
670 # get authorised values with type of BOR_NOTES
672 my $canned_notes = GetAuthorisedValues("BOR_NOTES");
674 $template->param(
675 debt_confirmed => $debt_confirmed,
676 SpecifyDueDate => $duedatespec_allow,
677 CircAutocompl => C4::Context->preference("CircAutocompl"),
678 AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
679 dateformat => C4::Context->preference("dateformat"),
680 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
681 canned_bor_notes_loop => $canned_notes,
683 output_html_with_http_headers $query, $cookie, $template->output;