3 # script to execute issuing of books
5 # Copyright 2000-2002 Katipo Communications
6 # copyright 2010 BibLibre
7 # Copyright 2011 PTFS-Europe Ltd.
8 # Copyright 2012 software.coop and MJ Ray
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along
22 # with Koha; if not, write to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 use C4
::Auth qw
/:DEFAULT get_session/;
31 use C4
::Dates qw
/format_date/;
32 use C4
::Branch
; # GetBranches
33 use C4
::Koha
; # GetPrinter
35 use C4
::Overdues qw
/CheckBorrowerDebarred/;
43 use C4
::Members
::Attributes
qw(GetBorrowerAttributes);
52 use List
::MoreUtils qw
/uniq/;
60 my $sessionID = $query->cookie("CGISESSID") ;
61 my $session = get_session
($sessionID);
63 # branch and printer are now defined by the userenv
64 # but first we have to check if someone has tried to change them
66 my $branch = $query->param('branch');
68 # update our session so the userenv is updated
69 $session->param('branch', $branch);
70 $session->param('branchname', GetBranchName
($branch));
73 my $printer = $query->param('printer');
75 # update our session so the userenv is updated
76 $session->param('branchprinter', $printer);
79 if (!C4
::Context
->userenv && !$branch){
80 if ($session->param('branch') eq 'NO_LIBRARY_SET'){
81 # no branch set we can't issue
82 print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
87 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
89 template_name
=> 'circ/circulation.tmpl',
93 flagsrequired
=> { circulate
=> 'circulate_remaining_permissions' },
97 my $branches = GetBranches
();
99 my @failedrenews = $query->param('failedrenew'); # expected to be itemnumbers
100 our %renew_failed = ();
101 for (@failedrenews) { $renew_failed{$_} = 1; }
103 my @failedreturns = $query->param('failedreturn');
104 our %return_failed = ();
105 for (@failedreturns) { $return_failed{$_} = 1; }
107 my $findborrower = $query->param('findborrower') || q{};
108 $findborrower =~ s
|,| |g
;
109 my $borrowernumber = $query->param('borrowernumber');
111 $branch = C4
::Context
->userenv->{'branch'};
112 $printer = C4
::Context
->userenv->{'branchprinter'};
115 # If AutoLocation is not activated, we show the Circulation Parameters to chage settings of librarian
116 if (C4
::Context
->preference("AutoLocation") != 1) {
117 $template->param(ManualLocation
=> 1);
120 if (C4
::Context
->preference("DisplayClearScreenButton")) {
121 $template->param(DisplayClearScreenButton
=> 1);
124 if (C4
::Context
->preference("UseTablesortForCirc")) {
125 $template->param(UseTablesortForCirc
=> 1);
128 my $barcode = $query->param('barcode') || q{};
129 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
131 $barcode = barcodedecode
($barcode) if( $barcode && C4
::Context
->preference('itemBarcodeInputFilter'));
132 my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate');
133 my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate');
134 my $issueconfirmed = $query->param('issueconfirmed');
135 my $cancelreserve = $query->param('cancelreserve');
136 my $organisation = $query->param('organisations');
137 my $print = $query->param('print') || q{};
138 my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice
139 my $charges = $query->param('charges') || q{};
141 # Check if stickyduedate is turned off
143 # was stickyduedate loaded from session?
144 if ( $stickyduedate && ! $query->param("stickyduedate") ) {
145 $session->clear( 'stickyduedate' );
146 $stickyduedate = $query->param('stickyduedate');
147 $duedatespec = $query->param('duedatespec');
151 my ($datedue,$invalidduedate);
153 my $duedatespec_allow = C4
::Context
->preference('SpecifyDueDate');
154 if($duedatespec_allow){
156 if ($duedatespec =~ C4
::Dates
->regexp('syspref')) {
157 $datedue = dt_from_string
($duedatespec);
160 $template->param(IMPOSSIBLE
=>1, INVALID_DATE
=>$duedatespec);
165 our $todaysdate = C4
::Dates
->new->output('iso');
167 # check and see if we should print
168 if ( $barcode eq '' && $print eq 'maybe' ) {
172 my $inprocess = ($barcode eq '') ?
'' : $query->param('inprocess');
173 if ( $barcode eq '' && $charges eq 'yes' ) {
176 borrowernumber
=> $borrowernumber
180 if ( $print eq 'yes' && $borrowernumber ne '' ) {
181 if ( C4
::Context
->boolean_preference('printcirculationslips') ) {
182 my $letter = IssueSlip
($branch, $borrowernumber, "QUICK");
183 NetworkPrint
($letter->{content
});
185 $query->param( 'borrowernumber', '' );
186 $borrowernumber = '';
190 # STEP 2 : FIND BORROWER
191 # if there is a list of find borrowers....
196 my $borrowers = Search
($findborrower, 'cardnumber') || [];
197 if (C4
::Context
->preference("AddPatronLists")) {
199 "AddPatronLists_".C4
::Context
->preference("AddPatronLists")=> "1",
201 if (C4
::Context
->preference("AddPatronLists")=~/code/){
202 my $categories = GetBorrowercategoryList
;
203 $categories->[0]->{'first'} = 1;
204 $template->param(categories
=>$categories);
207 if ( @
$borrowers == 0 ) {
208 $query->param( 'findborrower', '' );
209 $message = "'$findborrower'";
211 elsif ( @
$borrowers == 1 ) {
212 $borrowernumber = $borrowers->[0]->{'borrowernumber'};
213 $query->param( 'borrowernumber', $borrowernumber );
214 $query->param( 'barcode', '' );
217 $borrowerslist = $borrowers;
221 # get the borrower information.....
223 if ($borrowernumber) {
224 $borrower = GetMemberDetails
( $borrowernumber, 0 );
225 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines
( $borrowernumber );
227 # Warningdate is the date that the warning starts appearing
228 my ( $today_year, $today_month, $today_day) = Today
();
229 my ($warning_year, $warning_month, $warning_day) = split /-/, $borrower->{'dateexpiry'};
230 my ( $enrol_year, $enrol_month, $enrol_day) = split /-/, $borrower->{'dateenrolled'};
231 # Renew day is calculated by adding the enrolment period to today
232 my ( $renew_year, $renew_month, $renew_day);
233 if ($enrol_year*$enrol_month*$enrol_day>0) {
234 ( $renew_year, $renew_month, $renew_day) =
235 Add_Delta_YM
( $enrol_year, $enrol_month, $enrol_day,
236 0 , $borrower->{'enrolmentperiod'});
238 # if the expiry date is before today ie they have expired
239 if ( !$borrower->{'dateexpiry'} || $warning_year*$warning_month*$warning_day==0
240 || Date_to_Days
($today_year, $today_month, $today_day )
241 > Date_to_Days
($warning_year, $warning_month, $warning_day) )
243 #borrowercard expired, no issues
248 renewaldate
=> format_date
("$renew_year-$renew_month-$renew_day")
251 # check for NotifyBorrowerDeparture
252 elsif ( C4
::Context
->preference('NotifyBorrowerDeparture') &&
253 Date_to_Days
(Add_Delta_Days
($warning_year,$warning_month,$warning_day,- C4
::Context
->preference('NotifyBorrowerDeparture'))) <
254 Date_to_Days
( $today_year, $today_month, $today_day ) )
256 # borrower card soon to expire warn librarian
257 $template->param("warndeparture" => format_date
($borrower->{dateexpiry
}),
259 if (C4
::Context
->preference('ReturnBeforeExpiry')){
260 $template->param("returnbeforeexpiry" => 1);
265 issuecount
=> $issue,
269 my $debar = CheckBorrowerDebarred
($borrowernumber);
271 $template->param( 'userdebarred' => 1 );
272 $template->param( 'debarredcomment' => $borrower->{debarredcomment
} );
273 if ( $debar ne "9999-12-31" ) {
274 $template->param( 'userdebarreddate' => C4
::Dates
::format_date
($debar) );
285 # always check for blockers on issuing
286 my ( $error, $question, $alerts ) =
287 CanBookBeIssued
( $borrower, $barcode, $datedue , $inprocess );
288 my $blocker = $invalidduedate ?
1 : 0;
290 $template->param( alert
=> $alerts );
292 # Get the item title for more information
293 my $getmessageiteminfo = GetBiblioFromItemNumber
(undef,$barcode);
295 authvalcode_notforloan
=> C4
::Koha
::GetAuthValCode
('items.notforloan', $getmessageiteminfo->{'frameworkcode'}),
297 # Fix for bug 7494: optional checkout-time fallback search for a book
299 if ( $error->{'UNKNOWN_BARCODE'}
300 && C4
::Context
->preference("itemBarcodeFallbackSearch") )
302 $template->param( FALLBACK
=> 1 );
304 my $query = "kw=" . $barcode;
305 my ( $searcherror, $results, $total_hits ) = SimpleSearch
($query);
307 # if multiple hits, offer options to librarian
308 if ( $total_hits > 0 ) {
310 foreach my $hit ( @
{$results} ) {
312 TransformMarcToKoha
( C4
::Context
->dbh,
313 MARC
::Record
->new_from_usmarc($hit) );
315 # offer all barcodes individually
316 foreach my $barcode ( sort split(/\s*\|\s*/, $chosen->{barcode
}) ) {
317 my %chosen_single = %{$chosen};
318 $chosen_single{barcode
} = $barcode;
319 push( @options, \
%chosen_single );
322 $template->param( options
=> \
@options );
326 delete $question->{'DEBT'} if ($debt_confirmed);
327 foreach my $impossible ( keys %$error ) {
329 $impossible => $$error{$impossible},
335 my $confirm_required = 0;
336 unless($issueconfirmed){
337 # Get the item title for more information
338 my $getmessageiteminfo = GetBiblioFromItemNumber
(undef,$barcode);
339 $template->{VARS
}->{'additional_materials'} = $getmessageiteminfo->{'materials'};
340 $template->param( itemhomebranch
=> $getmessageiteminfo->{'homebranch'} );
342 # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
343 foreach my $needsconfirmation ( keys %$question ) {
345 $needsconfirmation => $$question{$needsconfirmation},
346 getTitleMessageIteminfo
=> $getmessageiteminfo->{'title'},
347 getBarcodeMessageIteminfo
=> $getmessageiteminfo->{'barcode'},
348 NEEDSCONFIRMATION
=> 1
350 $confirm_required = 1;
353 unless($confirm_required) {
354 AddIssue
( $borrower, $barcode, $datedue, $cancelreserve );
359 # FIXME If the issue is confirmed, we launch another time GetMemberIssuesAndFines, now display the issue count after issue
360 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines
( $borrowernumber );
361 $template->param( issuecount
=> $issue );
364 # reload the borrower info for the sake of reseting the flags.....
365 if ($borrowernumber) {
366 $borrower = GetMemberDetails
( $borrowernumber, 0 );
369 ##################################################################################
371 # show all reserves of this borrower, and the position of the reservation ....
372 if ($borrowernumber) {
375 # now we show the status of the borrower's reservations
376 my @borrowerreserv = GetReservesFromBorrowernumber
($borrowernumber );
378 my @WaitingReserveLoop;
380 foreach my $num_res (@borrowerreserv) {
382 my %getWaitingReserveInfo;
383 my $getiteminfo = GetBiblioFromItemNumber
( $num_res->{'itemnumber'} );
384 my $itemtypeinfo = getitemtypeinfo
( (C4
::Context
->preference('item-level_itypes')) ?
$getiteminfo->{'itype'} : $getiteminfo->{'itemtype'} );
385 my ( $transfertwhen, $transfertfrom, $transfertto ) =
386 GetTransfers
( $num_res->{'itemnumber'} );
388 $getreserv{waiting
} = 0;
389 $getreserv{transfered
} = 0;
390 $getreserv{nottransfered
} = 0;
392 $getreserv{reservedate
} = format_date
( $num_res->{'reservedate'} );
393 $getreserv{reserve_id
} = $num_res->{'reserve_id'};
394 $getreserv{title
} = $getiteminfo->{'title'};
395 $getreserv{subtitle
} = GetRecordValue
('subtitle', GetMarcBiblio
($getiteminfo->{biblionumber
}), GetFrameworkCode
($getiteminfo->{biblionumber
}));
396 $getreserv{itemtype
} = $itemtypeinfo->{'description'};
397 $getreserv{author
} = $getiteminfo->{'author'};
398 $getreserv{barcodereserv
} = $getiteminfo->{'barcode'};
399 $getreserv{itemcallnumber
} = $getiteminfo->{'itemcallnumber'};
400 $getreserv{biblionumber
} = $getiteminfo->{'biblionumber'};
401 $getreserv{waitingat
} = GetBranchName
( $num_res->{'branchcode'} );
402 $getreserv{suspend
} = $num_res->{'suspend'};
403 $getreserv{suspend_until
} = $num_res->{'suspend_until'};
404 # check if we have a waiting status for reservations
405 if ( $num_res->{'found'} && $num_res->{'found'} eq 'W' ) {
406 $getreserv{color
} = 'reserved';
407 $getreserv{waiting
} = 1;
408 # genarate information displaying only waiting reserves
409 $getWaitingReserveInfo{title
} = $getiteminfo->{'title'};
410 $getWaitingReserveInfo{biblionumber
} = $getiteminfo->{'biblionumber'};
411 $getWaitingReserveInfo{itemtype
} = $itemtypeinfo->{'description'};
412 $getWaitingReserveInfo{author
} = $getiteminfo->{'author'};
413 $getWaitingReserveInfo{itemcallnumber
} = $getiteminfo->{'itemcallnumber'};
414 $getWaitingReserveInfo{reservedate
} = format_date
( $num_res->{'reservedate'} );
415 $getWaitingReserveInfo{waitingat
} = GetBranchName
( $num_res->{'branchcode'} );
416 $getWaitingReserveInfo{waitinghere
} = 1 if $num_res->{'branchcode'} eq $branch;
418 # check transfers with the itemnumber foud in th reservation loop
419 if ($transfertwhen) {
420 $getreserv{color
} = 'transfered';
421 $getreserv{transfered
} = 1;
422 $getreserv{datesent
} = format_date
($transfertwhen);
423 $getreserv{frombranch
} = GetBranchName
($transfertfrom);
424 } elsif ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'}) {
425 $getreserv{nottransfered
} = 1;
426 $getreserv{nottransferedby
} = GetBranchName
( $getiteminfo->{'holdingbranch'} );
429 # if we don't have a reserv on item, we put the biblio infos and the waiting position
430 if ( $getiteminfo->{'title'} eq '' ) {
431 my $getbibinfo = GetBiblioData
( $num_res->{'biblionumber'} );
433 $getreserv{color
} = 'inwait';
434 $getreserv{title
} = $getbibinfo->{'title'};
435 $getreserv{subtitle
} = GetRecordValue
('subtitle', GetMarcBiblio
($num_res->{biblionumber
}), GetFrameworkCode
($num_res->{biblionumber
}));
436 $getreserv{nottransfered
} = 0;
437 $getreserv{itemtype
} = $itemtypeinfo->{'description'};
438 $getreserv{author
} = $getbibinfo->{'author'};
439 $getreserv{biblionumber
} = $num_res->{'biblionumber'};
441 $getreserv{waitingposition
} = $num_res->{'priority'};
442 $getreserv{expirationdate
} = $num_res->{'expirationdate'};
443 push( @reservloop, \
%getreserv );
445 # if we have a reserve waiting, initiate waitingreserveloop
446 if ($getreserv{waiting
} == 1) {
447 push (@WaitingReserveLoop, \
%getWaitingReserveInfo)
452 # return result to the template
454 countreserv
=> scalar @reservloop,
455 reservloop
=> \
@reservloop ,
456 WaitingReserveLoop
=> \
@WaitingReserveLoop,
458 $template->param( adultborrower
=> 1 ) if ( $borrower->{'category_type'} eq 'A' );
461 # make the issued books table.
462 my $todaysissues = '';
464 our @todaysissues = ();
465 our @previousissues = ();
467 our @relprevissues = ();
468 my $displayrelissues;
472 sub build_issue_data
{
473 my $issueslist = shift;
474 my $relatives = shift;
476 # split in 2 arrays for today & previous
477 foreach my $it ( @
$issueslist ) {
478 my $itemtypeinfo = getitemtypeinfo
( (C4
::Context
->preference('item-level_itypes')) ?
$it->{'itype'} : $it->{'itemtype'} );
480 # set itemtype per item-level_itype syspref - FIXME this is an ugly hack
481 $it->{'itemtype'} = ( C4
::Context
->preference( 'item-level_itypes' ) ) ?
$it->{'itype'} : $it->{'itemtype'};
483 ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges
(
484 $it->{'itemnumber'}, $it->{'borrowernumber'}
486 $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
487 my ($can_renew, $can_renew_error) = CanBookBeRenewed
(
488 $it->{'borrowernumber'},$it->{'itemnumber'}
490 $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
491 my $restype = C4
::Reserves
::GetReserveStatus
( $it->{'itemnumber'} );
492 $it->{'can_renew'} = $can_renew;
493 $it->{'can_confirm'} = !$can_renew && !$restype;
494 $it->{'renew_error'} = ( $restype eq "Waiting" or $restype eq "Reserved" ) ?
1 : 0;
495 $it->{'checkoutdate'} = C4
::Dates
->new($it->{'issuedate'},'iso')->output('syspref');
496 $it->{'issuingbranchname'} = GetBranchName
($it->{'branchcode'});
498 $totalprice += $it->{'replacementprice'} || 0;
499 $it->{'itemtype'} = $itemtypeinfo->{'description'};
500 $it->{'itemtype_image'} = $itemtypeinfo->{'imageurl'};
501 $it->{'dd_sort'} = $it->{'date_due'};
502 $it->{'dd'} = output_pref
($it->{'date_due'});
503 $it->{'displaydate_sort'} = $it->{'issuedate'};
504 $it->{'displaydate'} = output_pref
($it->{'issuedate'});
505 #$it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ;
506 $it->{'od'} = $it->{'overdue'};
507 $it->{'subtitle'} = GetRecordValue
('subtitle', GetMarcBiblio
($it->{biblionumber
}), GetFrameworkCode
($it->{biblionumber
}));
508 $it->{'renew_failed'} = $renew_failed{$it->{'itemnumber'}};
509 $it->{'return_failed'} = $return_failed{$it->{'barcode'}};
511 if ( ( $it->{'issuedate'} && $it->{'issuedate'} gt $todaysdate )
512 || ( $it->{'lastreneweddate'} && $it->{'lastreneweddate'} gt $todaysdate ) ) {
513 (!$relatives) ?
push @todaysissues, $it : push @relissues, $it;
515 (!$relatives) ?
push @previousissues, $it : push @relprevissues, $it;
522 # Getting borrower relatives
523 my @relborrowernumbers = GetMemberRelatives
($borrower->{'borrowernumber'});
524 #push @borrowernumbers, $borrower->{'borrowernumber'};
526 # get each issue of the borrower & separate them in todayissues & previous issues
527 my $issueslist = GetPendingIssues
($borrower->{'borrowernumber'});
528 my $relissueslist = [];
529 if ( @relborrowernumbers ) {
530 $relissueslist = GetPendingIssues
(@relborrowernumbers);
533 build_issue_data
($issueslist, 0);
534 build_issue_data
($relissueslist, 1);
536 $displayrelissues = scalar($relissueslist);
538 if ( C4
::Context
->preference( "todaysIssuesDefaultSortOrder" ) eq 'asc' ) {
539 @todaysissues = sort { $a->{'timestamp'} cmp $b->{'timestamp'} } @todaysissues;
542 @todaysissues = sort { $b->{'timestamp'} cmp $a->{'timestamp'} } @todaysissues;
545 if ( C4
::Context
->preference( "previousIssuesDefaultSortOrder" ) eq 'asc' ){
546 @previousissues = sort { $a->{'date_due'} cmp $b->{'date_due'} } @previousissues;
549 @previousissues = sort { $b->{'date_due'} cmp $a->{'date_due'} } @previousissues;
556 my $CGIselectborrower;
557 if ($borrowerslist) {
559 sort {(lc $a->{'surname'} cmp lc $b->{'surname'} || lc $a->{'firstname'} cmp lc $b->{'firstname'})
563 push @values, $_->{'borrowernumber'};
564 $labels{ $_->{'borrowernumber'} } =
565 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'} - $_->{'branchcode'}) ... $_->{'address'} ";
567 $CGIselectborrower = CGI
::scrolling_list
(
568 -name
=> 'borrowernumber',
570 -id
=> 'borrowernumber',
573 -ondblclick
=> 'document.forms[\'mainform\'].submit()',
581 my $flags = $borrower->{'flags'};
582 foreach my $flag ( sort keys %$flags ) {
583 $template->param( flagged
=> 1);
584 $flags->{$flag}->{'message'} =~ s
#\n#<br />#g;
585 if ( $flags->{$flag}->{'noissues'} ) {
589 if ( $flag eq 'GNA' ) {
590 $template->param( gna
=> 'true' );
592 elsif ( $flag eq 'LOST' ) {
593 $template->param( lost
=> 'true' );
595 elsif ( $flag eq 'DBARRED' ) {
596 $template->param( dbarred
=> 'true' );
598 elsif ( $flag eq 'CHARGES' ) {
601 chargesmsg
=> $flags->{'CHARGES'}->{'message'},
602 chargesamount
=> $flags->{'CHARGES'}->{'amount'},
603 charges_is_blocker
=> 1
606 elsif ( $flag eq 'CREDITS' ) {
609 creditsmsg
=> $flags->{'CREDITS'}->{'message'},
610 creditsamount
=> sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
615 if ( $flag eq 'CHARGES' ) {
618 chargesmsg
=> $flags->{'CHARGES'}->{'message'},
619 chargesamount
=> $flags->{'CHARGES'}->{'amount'},
622 elsif ( $flag eq 'CREDITS' ) {
625 creditsmsg
=> $flags->{'CREDITS'}->{'message'},
626 creditsamount
=> sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
629 elsif ( $flag eq 'ODUES' ) {
632 oduesmsg
=> $flags->{'ODUES'}->{'message'}
635 my $items = $flags->{$flag}->{'itemlist'};
636 if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
637 $template->param( nonreturns
=> 'true' );
640 elsif ( $flag eq 'NOTES' ) {
643 notesmsg
=> $flags->{'NOTES'}->{'message'}
649 my $amountold = $borrower->{flags
}->{'CHARGES'}->{'message'} || 0;
650 $amountold =~ s/^.*\$//; # remove upto the $, if any
652 my ( $total, $accts, $numaccts) = GetMemberAccountRecords
( $borrowernumber );
654 if ( $borrower->{'category_type'} eq 'C') {
655 my ( $catcodes, $labels ) = GetborCatFromCatType
( 'A', 'WHERE category_type = ?' );
656 my $cnt = scalar(@
$catcodes);
657 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
658 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
661 my $CGIorganisations;
662 my $member_of_institution;
663 if ( C4
::Context
->preference("memberofinstitution") ) {
664 my $organisations = get_institutions
();
667 foreach my $organisation ( keys %$organisations ) {
668 push @orgs, $organisation;
669 $org_labels{$organisation} = $organisations->{$organisation}->{'surname'};
671 $member_of_institution = 1;
672 $CGIorganisations = CGI
::popup_menu
(
673 -id
=> 'organisations',
674 -name
=> 'organisations',
675 -labels
=> \
%org_labels,
680 my $lib_messages_loop = GetMessages
( $borrowernumber, 'L', $branch );
681 if($lib_messages_loop){ $template->param(flagged
=> 1 ); }
683 my $bor_messages_loop = GetMessages
( $borrowernumber, 'B', $branch );
684 if($bor_messages_loop){ $template->param(flagged
=> 1 ); }
686 # Computes full borrower address
688 push @fulladdress, $borrower->{'streetnumber'} if ( $borrower->{'streetnumber'} );
689 push @fulladdress, &GetRoadTypeDetails
( $borrower->{'streettype'} ) if ( $borrower->{'streettype'} );
690 push @fulladdress, $borrower->{'address'} if ( $borrower->{'address'} );
692 my $fast_cataloging = 0;
693 if (defined getframeworkinfo
('FA')) {
697 if (C4
::Context
->preference('ExtendedPatronAttributes')) {
698 my $attributes = GetBorrowerAttributes
($borrowernumber);
700 ExtendedPatronAttributes
=> 1,
701 extendedattributes
=> $attributes
706 lib_messages_loop
=> $lib_messages_loop,
707 bor_messages_loop
=> $bor_messages_loop,
708 all_messages_del
=> C4
::Context
->preference('AllowAllMessageDeletion'),
709 findborrower
=> $findborrower,
710 borrower
=> $borrower,
711 borrowernumber
=> $borrowernumber,
713 branchname
=> GetBranchName
($borrower->{'branchcode'}),
715 printername
=> $printer,
716 firstname
=> $borrower->{'firstname'},
717 surname
=> $borrower->{'surname'},
718 showname
=> $borrower->{'showname'},
719 category_type
=> $borrower->{'category_type'},
720 was_renewed
=> $query->param('was_renewed') ?
1 : 0,
721 expiry
=> format_date
($borrower->{'dateexpiry'}),
722 categorycode
=> $borrower->{'categorycode'},
723 categoryname
=> $borrower->{description
},
724 address
=> join(' ', @fulladdress),
725 address2
=> $borrower->{'address2'},
726 email
=> $borrower->{'email'},
727 emailpro
=> $borrower->{'emailpro'},
728 borrowernotes
=> $borrower->{'borrowernotes'},
729 city
=> $borrower->{'city'},
730 state => $borrower->{'state'},
731 zipcode
=> $borrower->{'zipcode'},
732 country
=> $borrower->{'country'},
733 phone
=> $borrower->{'phone'} || $borrower->{'mobile'},
734 cardnumber
=> $borrower->{'cardnumber'},
735 othernames
=> $borrower->{'othernames'},
736 amountold
=> $amountold,
738 stickyduedate
=> $stickyduedate,
739 duedatespec
=> $duedatespec,
741 CGIselectborrower
=> $CGIselectborrower,
742 totalprice
=> sprintf('%.2f', $totalprice),
743 totaldue
=> sprintf('%.2f', $total),
744 todayissues
=> \
@todaysissues,
745 previssues
=> \
@previousissues,
746 relissues
=> \
@relissues,
747 relprevissues
=> \
@relprevissues,
748 displayrelissues
=> $displayrelissues,
749 inprocess
=> $inprocess,
750 memberofinstution
=> $member_of_institution,
751 CGIorganisations
=> $CGIorganisations,
752 is_child
=> ($borrower->{'category_type'} eq 'C'),
754 soundon
=> C4
::Context
->preference("SoundOn"),
755 fast_cataloging
=> $fast_cataloging,
756 CircAutoPrintQuickSlip
=> C4
::Context
->preference("CircAutoPrintQuickSlip"),
757 activeBorrowerRelationship
=> (C4
::Context
->preference('borrowerRelationship') ne ''),
758 SuspendHoldsIntranet
=> C4
::Context
->preference('SuspendHoldsIntranet'),
759 AutoResumeSuspendedHolds
=> C4
::Context
->preference('AutoResumeSuspendedHolds'),
760 RoutingSerials
=> C4
::Context
->preference('RoutingSerials'),
763 # save stickyduedate to session
764 if ($stickyduedate) {
765 $session->param( 'stickyduedate', $duedatespec );
768 my ($picture, $dberror) = GetPatronImage
($borrower->{'cardnumber'});
769 $template->param( picture
=> 1 ) if $picture;
771 # get authorised values with type of BOR_NOTES
773 my $canned_notes = GetAuthorisedValues
("BOR_NOTES");
776 debt_confirmed
=> $debt_confirmed,
777 SpecifyDueDate
=> $duedatespec_allow,
778 CircAutocompl
=> C4
::Context
->preference("CircAutocompl"),
779 AllowRenewalLimitOverride
=> C4
::Context
->preference("AllowRenewalLimitOverride"),
780 export_remove_fields
=> C4
::Context
->preference("ExportRemoveFields"),
781 export_with_csv_profile
=> C4
::Context
->preference("ExportWithCsvProfile"),
782 canned_bor_notes_loop
=> $canned_notes,
785 output_html_with_http_headers
$query, $cookie, $template->output;