Bug 8706 - Private lists can be accessed by anyone
[koha.git] / circ / circulation.pl
blob78ac1a4db93d2f68f8100621bf07e8e204366c58
1 #!/usr/bin/perl
3 # script to execute issuing of books
5 # Copyright 2000-2002 Katipo Communications
6 # copyright 2010 BibLibre
7 # Copyright 2011 PTFS-Europe Ltd.
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along
21 # with Koha; if not, write to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 use strict;
25 use warnings;
26 use CGI;
27 use C4::Output;
28 use C4::Print;
29 use C4::Auth qw/:DEFAULT get_session/;
30 use C4::Dates qw/format_date/;
31 use C4::Branch; # GetBranches
32 use C4::Koha; # GetPrinter
33 use C4::Circulation;
34 use C4::Overdues qw/CheckBorrowerDebarred/;
35 use C4::Members;
36 use C4::Biblio;
37 use C4::Reserves;
38 use C4::Context;
39 use CGI::Session;
40 use C4::Members::Attributes qw(GetBorrowerAttributes);
41 use Koha::DateUtils;
43 use Date::Calc qw(
44 Today
45 Add_Delta_YM
46 Add_Delta_Days
47 Date_to_Days
49 use List::MoreUtils qw/uniq/;
53 # PARAMETERS READING
55 my $query = new CGI;
57 my $sessionID = $query->cookie("CGISESSID") ;
58 my $session = get_session($sessionID);
60 # branch and printer are now defined by the userenv
61 # but first we have to check if someone has tried to change them
63 my $branch = $query->param('branch');
64 if ($branch){
65 # update our session so the userenv is updated
66 $session->param('branch', $branch);
67 $session->param('branchname', GetBranchName($branch));
70 my $printer = $query->param('printer');
71 if ($printer){
72 # update our session so the userenv is updated
73 $session->param('branchprinter', $printer);
76 if (!C4::Context->userenv && !$branch){
77 if ($session->param('branch') eq 'NO_LIBRARY_SET'){
78 # no branch set we can't issue
79 print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
80 exit;
84 my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
86 template_name => 'circ/circulation.tmpl',
87 query => $query,
88 type => "intranet",
89 authnotrequired => 0,
90 flagsrequired => { circulate => 'circulate_remaining_permissions' },
94 my $branches = GetBranches();
96 my @failedrenews = $query->param('failedrenew'); # expected to be itemnumbers
97 our %renew_failed = {};
98 for (@failedrenews) { $renew_failed{$_} = 1; }
100 my $findborrower = $query->param('findborrower');
101 $findborrower =~ s|,| |g;
102 my $borrowernumber = $query->param('borrowernumber');
104 $branch = C4::Context->userenv->{'branch'};
105 $printer = C4::Context->userenv->{'branchprinter'};
108 # If AutoLocation is not activated, we show the Circulation Parameters to chage settings of librarian
109 if (C4::Context->preference("AutoLocation") != 1) {
110 $template->param(ManualLocation => 1);
113 if (C4::Context->preference("DisplayClearScreenButton")) {
114 $template->param(DisplayClearScreenButton => 1);
117 if (C4::Context->preference("UseTablesortForCirc")) {
118 $template->param(UseTablesortForCirc => 1);
121 my $barcode = $query->param('barcode') || '';
122 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
124 $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
125 my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate');
126 my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate');
127 my $issueconfirmed = $query->param('issueconfirmed');
128 my $cancelreserve = $query->param('cancelreserve');
129 my $organisation = $query->param('organisations');
130 my $print = $query->param('print');
131 my $newexpiry = $query->param('dateexpiry');
132 my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice
134 # Check if stickyduedate is turned off
135 if ( $barcode ) {
136 # was stickyduedate loaded from session?
137 if ( $stickyduedate && ! $query->param("stickyduedate") ) {
138 $session->clear( 'stickyduedate' );
139 $stickyduedate = $query->param('stickyduedate');
140 $duedatespec = $query->param('duedatespec');
144 my ($datedue,$invalidduedate);
146 my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
147 if($duedatespec_allow){
148 if ($duedatespec) {
149 if ($duedatespec =~ C4::Dates->regexp('syspref')) {
150 $datedue = dt_from_string($duedatespec);
151 } else {
152 $invalidduedate = 1;
153 $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
158 our $todaysdate = C4::Dates->new->output('iso');
160 # check and see if we should print
161 if ( $barcode eq '' && $print eq 'maybe' ) {
162 $print = 'yes';
165 my $inprocess = ($barcode eq '') ? '' : $query->param('inprocess');
166 if ( $barcode eq '' && $query->param('charges') eq 'yes' ) {
167 $template->param(
168 PAYCHARGES => 'yes',
169 borrowernumber => $borrowernumber
173 if ( $print eq 'yes' && $borrowernumber ne '' ) {
174 if ( C4::Context->boolean_preference('printcirculationslips') ) {
175 my $letter = IssueSlip($branch, $borrowernumber, "QUICK");
176 NetworkPrint($letter->{content});
178 $query->param( 'borrowernumber', '' );
179 $borrowernumber = '';
183 # STEP 2 : FIND BORROWER
184 # if there is a list of find borrowers....
186 my $borrowerslist;
187 my $message;
188 if ($findborrower) {
189 my $borrowers = Search($findborrower, 'cardnumber');
190 my @borrowers = @$borrowers;
191 if (C4::Context->preference("AddPatronLists")) {
192 $template->param(
193 "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
195 if (C4::Context->preference("AddPatronLists")=~/code/){
196 my $categories = GetBorrowercategoryList;
197 $categories->[0]->{'first'} = 1;
198 $template->param(categories=>$categories);
201 if ( $#borrowers == -1 ) {
202 $query->param( 'findborrower', '' );
203 $message = "'$findborrower'";
205 elsif ( $#borrowers == 0 ) {
206 $query->param( 'borrowernumber', $borrowers[0]->{'borrowernumber'} );
207 $query->param( 'barcode', '' );
208 $borrowernumber = $borrowers[0]->{'borrowernumber'};
210 else {
211 $borrowerslist = \@borrowers;
215 # get the borrower information.....
216 my $borrower;
217 if ($borrowernumber) {
218 $borrower = GetMemberDetails( $borrowernumber, 0 );
219 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
221 # Warningdate is the date that the warning starts appearing
222 my ( $today_year, $today_month, $today_day) = Today();
223 my ($warning_year, $warning_month, $warning_day) = split /-/, $borrower->{'dateexpiry'};
224 my ( $enrol_year, $enrol_month, $enrol_day) = split /-/, $borrower->{'dateenrolled'};
225 # Renew day is calculated by adding the enrolment period to today
226 my ( $renew_year, $renew_month, $renew_day);
227 if ($enrol_year*$enrol_month*$enrol_day>0) {
228 ( $renew_year, $renew_month, $renew_day) =
229 Add_Delta_YM( $enrol_year, $enrol_month, $enrol_day,
230 0 , $borrower->{'enrolmentperiod'});
232 # if the expiry date is before today ie they have expired
233 if ( !$borrower->{'dateexpiry'} || $warning_year*$warning_month*$warning_day==0
234 || Date_to_Days($today_year, $today_month, $today_day )
235 > Date_to_Days($warning_year, $warning_month, $warning_day) )
237 #borrowercard expired, no issues
238 $template->param(
239 flagged => "1",
240 noissues => "1",
241 expired => "1",
242 renewaldate => format_date("$renew_year-$renew_month-$renew_day")
245 # check for NotifyBorrowerDeparture
246 elsif ( C4::Context->preference('NotifyBorrowerDeparture') &&
247 Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
248 Date_to_Days( $today_year, $today_month, $today_day ) )
250 # borrower card soon to expire warn librarian
251 $template->param("warndeparture" => format_date($borrower->{dateexpiry}),
252 flagged => "1",);
253 if (C4::Context->preference('ReturnBeforeExpiry')){
254 $template->param("returnbeforeexpiry" => 1);
257 $template->param(
258 overduecount => $od,
259 issuecount => $issue,
260 finetotal => $fines
263 my $debar = CheckBorrowerDebarred($borrowernumber);
264 if ($debar) {
265 $template->param( 'userdebarred' => 1 );
266 $template->param( 'debarredcomment' => $borrower->{debarredcomment} );
267 if ( $debar ne "9999-12-31" ) {
268 $template->param( 'userdebarreddate' => C4::Dates::format_date($debar) );
275 # STEP 3 : ISSUING
278 if ($barcode) {
279 # always check for blockers on issuing
280 my ( $error, $question, $alerts ) =
281 CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess );
282 my $blocker = $invalidduedate ? 1 : 0;
284 $template->param( alert => $alerts );
286 delete $question->{'DEBT'} if ($debt_confirmed);
287 foreach my $impossible ( keys %$error ) {
288 $template->param(
289 $impossible => $$error{$impossible},
290 IMPOSSIBLE => 1
292 $blocker = 1;
294 if( !$blocker ){
295 my $confirm_required = 0;
296 unless($issueconfirmed){
297 # Get the item title for more information
298 my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
299 $template->{VARS}->{'additional_materials'} = $getmessageiteminfo->{'materials'};
300 $template->param( itemhomebranch => $getmessageiteminfo->{'homebranch'} );
302 # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
303 foreach my $needsconfirmation ( keys %$question ) {
304 $template->param(
305 $needsconfirmation => $$question{$needsconfirmation},
306 getTitleMessageIteminfo => $getmessageiteminfo->{'title'},
307 getBarcodeMessageIteminfo => $getmessageiteminfo->{'barcode'},
308 NEEDSCONFIRMATION => 1
310 $confirm_required = 1;
313 unless($confirm_required) {
314 AddIssue( $borrower, $barcode, $datedue, $cancelreserve );
315 $inprocess = 1;
319 # FIXME If the issue is confirmed, we launch another time GetMemberIssuesAndFines, now display the issue count after issue
320 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
321 $template->param( issuecount => $issue );
324 # reload the borrower info for the sake of reseting the flags.....
325 if ($borrowernumber) {
326 $borrower = GetMemberDetails( $borrowernumber, 0 );
329 ##################################################################################
330 # BUILD HTML
331 # show all reserves of this borrower, and the position of the reservation ....
332 if ($borrowernumber) {
334 # new op dev
335 # now we show the status of the borrower's reservations
336 my @borrowerreserv = GetReservesFromBorrowernumber($borrowernumber );
337 my @reservloop;
338 my @WaitingReserveLoop;
340 foreach my $num_res (@borrowerreserv) {
341 my %getreserv;
342 my %getWaitingReserveInfo;
343 my $getiteminfo = GetBiblioFromItemNumber( $num_res->{'itemnumber'} );
344 my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $getiteminfo->{'itype'} : $getiteminfo->{'itemtype'} );
345 my ( $transfertwhen, $transfertfrom, $transfertto ) =
346 GetTransfers( $num_res->{'itemnumber'} );
348 $getreserv{waiting} = 0;
349 $getreserv{transfered} = 0;
350 $getreserv{nottransfered} = 0;
352 $getreserv{reservedate} = format_date( $num_res->{'reservedate'} );
353 $getreserv{reservenumber} = $num_res->{'reservenumber'};
354 $getreserv{title} = $getiteminfo->{'title'};
355 $getreserv{itemtype} = $itemtypeinfo->{'description'};
356 $getreserv{author} = $getiteminfo->{'author'};
357 $getreserv{barcodereserv} = $getiteminfo->{'barcode'};
358 $getreserv{itemcallnumber} = $getiteminfo->{'itemcallnumber'};
359 $getreserv{biblionumber} = $getiteminfo->{'biblionumber'};
360 $getreserv{waitingat} = GetBranchName( $num_res->{'branchcode'} );
361 $getreserv{suspend} = $num_res->{'suspend'};
362 $getreserv{suspend_until} = $num_res->{'suspend_until'};
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 our @todaysissues = ();
421 our @previousissues = ();
422 our @relissues = ();
423 our @relprevissues = ();
424 my $displayrelissues;
426 our $totalprice = 0;
428 sub build_issue_data {
429 my $issueslist = shift;
430 my $relatives = shift;
432 # split in 2 arrays for today & previous
433 foreach my $it ( @$issueslist ) {
434 my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $it->{'itype'} : $it->{'itemtype'} );
436 # set itemtype per item-level_itype syspref - FIXME this is an ugly hack
437 $it->{'itemtype'} = ( C4::Context->preference( 'item-level_itypes' ) ) ? $it->{'itype'} : $it->{'itemtype'};
439 ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
440 $it->{'itemnumber'}, $it->{'borrowernumber'}
442 $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
443 my ($can_renew, $can_renew_error) = CanBookBeRenewed(
444 $it->{'borrowernumber'},$it->{'itemnumber'}
446 $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
447 my ( $restype, $reserves, undef ) = CheckReserves( $it->{'itemnumber'} );
448 $it->{'can_renew'} = $can_renew;
449 $it->{'can_confirm'} = !$can_renew && !$restype;
450 $it->{'renew_error'} = $restype;
451 $it->{'checkoutdate'} = C4::Dates->new($it->{'issuedate'},'iso')->output('syspref');
452 $it->{'issuingbranchname'} = GetBranchName($it->{'branchcode'});
454 $totalprice += $it->{'replacementprice'};
455 $it->{'itemtype'} = $itemtypeinfo->{'description'};
456 $it->{'itemtype_image'} = $itemtypeinfo->{'imageurl'};
457 $it->{'dd'} = output_pref($it->{'date_due'});
458 $it->{'displaydate'} = output_pref($it->{'issuedate'});
459 #$it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ;
460 $it->{'od'} = $it->{'overdue'};
461 ($it->{'author'} eq '') and $it->{'author'} = ' ';
462 $it->{'renew_failed'} = $renew_failed{$it->{'itemnumber'}};
464 if ( $it->{'issuedate'} gt $todaysdate or $it->{'lastreneweddate'} gt $todaysdate ) {
465 (!$relatives) ? push @todaysissues, $it : push @relissues, $it;
466 } else {
467 (!$relatives) ? push @previousissues, $it : push @relprevissues, $it;
472 if ($borrower) {
474 # Getting borrower relatives
475 my @relborrowernumbers = GetMemberRelatives($borrower->{'borrowernumber'});
476 #push @borrowernumbers, $borrower->{'borrowernumber'};
478 # get each issue of the borrower & separate them in todayissues & previous issues
479 my $issueslist = GetPendingIssues($borrower->{'borrowernumber'});
480 my $relissueslist = [];
481 if ( @relborrowernumbers ) {
482 $relissueslist = GetPendingIssues(@relborrowernumbers);
485 build_issue_data($issueslist, 0);
486 build_issue_data($relissueslist, 1);
488 $displayrelissues = scalar($relissueslist);
490 if ( C4::Context->preference( "todaysIssuesDefaultSortOrder" ) eq 'asc' ) {
491 @todaysissues = sort { $a->{'timestamp'} cmp $b->{'timestamp'} } @todaysissues;
493 else {
494 @todaysissues = sort { $b->{'timestamp'} cmp $a->{'timestamp'} } @todaysissues;
497 if ( C4::Context->preference( "previousIssuesDefaultSortOrder" ) eq 'asc' ){
498 @previousissues = sort { $a->{'date_due'} cmp $b->{'date_due'} } @previousissues;
500 else {
501 @previousissues = sort { $b->{'date_due'} cmp $a->{'date_due'} } @previousissues;
506 my @values;
507 my %labels;
508 my $CGIselectborrower;
509 if ($borrowerslist) {
510 foreach (
511 sort {(lc $a->{'surname'} cmp lc $b->{'surname'} || lc $a->{'firstname'} cmp lc $b->{'firstname'})
512 } @$borrowerslist
515 push @values, $_->{'borrowernumber'};
516 $labels{ $_->{'borrowernumber'} } =
517 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'} - $_->{'branchcode'}) ... $_->{'address'} ";
519 $CGIselectborrower = CGI::scrolling_list(
520 -name => 'borrowernumber',
521 -class => 'focus',
522 -id => 'borrowernumber',
523 -values => \@values,
524 -labels => \%labels,
525 -ondblclick => 'document.forms[\'mainform\'].submit()',
526 -size => 7,
527 -tabindex => '',
528 -multiple => 0
532 #title
533 my $flags = $borrower->{'flags'};
534 foreach my $flag ( sort keys %$flags ) {
535 $template->param( flagged=> 1);
536 $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
537 if ( $flags->{$flag}->{'noissues'} ) {
538 $template->param(
539 flagged => 1,
540 noissues => 'true',
542 if ( $flag eq 'GNA' ) {
543 $template->param( gna => 'true' );
545 elsif ( $flag eq 'LOST' ) {
546 $template->param( lost => 'true' );
548 elsif ( $flag eq 'DBARRED' ) {
549 $template->param( dbarred => 'true' );
551 elsif ( $flag eq 'CHARGES' ) {
552 $template->param(
553 charges => 'true',
554 chargesmsg => $flags->{'CHARGES'}->{'message'},
555 chargesamount => $flags->{'CHARGES'}->{'amount'},
556 charges_is_blocker => 1
559 elsif ( $flag eq 'CREDITS' ) {
560 $template->param(
561 credits => 'true',
562 creditsmsg => $flags->{'CREDITS'}->{'message'},
563 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
567 else {
568 if ( $flag eq 'CHARGES' ) {
569 $template->param(
570 charges => 'true',
571 flagged => 1,
572 chargesmsg => $flags->{'CHARGES'}->{'message'},
573 chargesamount => $flags->{'CHARGES'}->{'amount'},
576 elsif ( $flag eq 'CREDITS' ) {
577 $template->param(
578 credits => 'true',
579 creditsmsg => $flags->{'CREDITS'}->{'message'},
580 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
583 elsif ( $flag eq 'ODUES' ) {
584 $template->param(
585 odues => 'true',
586 flagged => 1,
587 oduesmsg => $flags->{'ODUES'}->{'message'}
590 my $items = $flags->{$flag}->{'itemlist'};
591 if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
592 $template->param( nonreturns => 'true' );
595 elsif ( $flag eq 'NOTES' ) {
596 $template->param(
597 notes => 'true',
598 flagged => 1,
599 notesmsg => $flags->{'NOTES'}->{'message'}
605 my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
606 $amountold =~ s/^.*\$//; # remove upto the $, if any
608 my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
610 if ( $borrower->{'category_type'} eq 'C') {
611 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
612 my $cnt = scalar(@$catcodes);
613 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
614 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
617 my $CGIorganisations;
618 my $member_of_institution;
619 if ( C4::Context->preference("memberofinstitution") ) {
620 my $organisations = get_institutions();
621 my @orgs;
622 my %org_labels;
623 foreach my $organisation ( keys %$organisations ) {
624 push @orgs, $organisation;
625 $org_labels{$organisation} = $organisations->{$organisation}->{'surname'};
627 $member_of_institution = 1;
628 $CGIorganisations = CGI::popup_menu(
629 -id => 'organisations',
630 -name => 'organisations',
631 -labels => \%org_labels,
632 -values => \@orgs,
636 my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch );
637 if($lib_messages_loop){ $template->param(flagged => 1 ); }
639 my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch );
640 if($bor_messages_loop){ $template->param(flagged => 1 ); }
642 # Computes full borrower address
643 my (undef, $roadttype_hashref) = &GetRoadTypes();
644 my $address = $borrower->{'streetnumber'}.' '.$roadttype_hashref->{$borrower->{'streettype'}}.' '.$borrower->{'address'};
646 my $fast_cataloging = 0;
647 if (defined getframeworkinfo('FA')) {
648 $fast_cataloging = 1
651 if (C4::Context->preference('ExtendedPatronAttributes')) {
652 my $attributes = GetBorrowerAttributes($borrowernumber);
653 $template->param(
654 ExtendedPatronAttributes => 1,
655 extendedattributes => $attributes
659 $template->param(
660 lib_messages_loop => $lib_messages_loop,
661 bor_messages_loop => $bor_messages_loop,
662 all_messages_del => C4::Context->preference('AllowAllMessageDeletion'),
663 findborrower => $findborrower,
664 borrower => $borrower,
665 borrowernumber => $borrowernumber,
666 branch => $branch,
667 branchname => GetBranchName($borrower->{'branchcode'}),
668 printer => $printer,
669 printername => $printer,
670 firstname => $borrower->{'firstname'},
671 surname => $borrower->{'surname'},
672 showname => $borrower->{'showname'},
673 category_type => $borrower->{'category_type'},
674 dateexpiry => format_date($newexpiry),
675 expiry => format_date($borrower->{'dateexpiry'}),
676 categorycode => $borrower->{'categorycode'},
677 categoryname => $borrower->{description},
678 address => $address,
679 address2 => $borrower->{'address2'},
680 email => $borrower->{'email'},
681 emailpro => $borrower->{'emailpro'},
682 borrowernotes => $borrower->{'borrowernotes'},
683 city => $borrower->{'city'},
684 state => $borrower->{'state'},
685 zipcode => $borrower->{'zipcode'},
686 country => $borrower->{'country'},
687 phone => $borrower->{'phone'} || $borrower->{'mobile'},
688 cardnumber => $borrower->{'cardnumber'},
689 othernames => $borrower->{'othernames'},
690 amountold => $amountold,
691 barcode => $barcode,
692 stickyduedate => $stickyduedate,
693 duedatespec => $duedatespec,
694 message => $message,
695 CGIselectborrower => $CGIselectborrower,
696 totalprice => sprintf('%.2f', $totalprice),
697 totaldue => sprintf('%.2f', $total),
698 todayissues => \@todaysissues,
699 previssues => \@previousissues,
700 relissues => \@relissues,
701 relprevissues => \@relprevissues,
702 displayrelissues => $displayrelissues,
703 inprocess => $inprocess,
704 memberofinstution => $member_of_institution,
705 CGIorganisations => $CGIorganisations,
706 is_child => ($borrower->{'category_type'} eq 'C'),
707 circview => 1,
708 soundon => C4::Context->preference("SoundOn"),
709 fast_cataloging => $fast_cataloging,
710 CircAutoPrintQuickSlip => C4::Context->preference("CircAutoPrintQuickSlip"),
711 activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
712 SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
713 AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
716 # save stickyduedate to session
717 if ($stickyduedate) {
718 $session->param( 'stickyduedate', $duedatespec );
721 my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
722 $template->param( picture => 1 ) if $picture;
724 # get authorised values with type of BOR_NOTES
726 my $canned_notes = GetAuthorisedValues("BOR_NOTES");
728 $template->param(
729 debt_confirmed => $debt_confirmed,
730 SpecifyDueDate => $duedatespec_allow,
731 CircAutocompl => C4::Context->preference("CircAutocompl"),
732 AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
733 dateformat => C4::Context->preference("dateformat"),
734 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
735 canned_bor_notes_loop => $canned_notes,
738 output_html_with_http_headers $query, $cookie, $template->output;