Adding Marc Veron
[koha.git] / circ / circulation.pl
blobbcbcb6fb9152a25584a34ad164bf31c83694742a
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::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::Overdues qw/CheckBorrowerDebarred/;
34 use C4::Members;
35 use C4::Biblio;
36 use C4::Reserves;
37 use C4::Context;
38 use CGI::Session;
39 use C4::Members::Attributes qw(GetBorrowerAttributes);
40 use Koha::DateUtils;
42 use Date::Calc qw(
43 Today
44 Add_Delta_YM
45 Add_Delta_Days
46 Date_to_Days
48 use List::MoreUtils qw/uniq/;
52 # PARAMETERS READING
54 my $query = new CGI;
56 my $sessionID = $query->cookie("CGISESSID") ;
57 my $session = get_session($sessionID);
59 # branch and printer are now defined by the userenv
60 # but first we have to check if someone has tried to change them
62 my $branch = $query->param('branch');
63 if ($branch){
64 # update our session so the userenv is updated
65 $session->param('branch', $branch);
66 $session->param('branchname', GetBranchName($branch));
69 my $printer = $query->param('printer');
70 if ($printer){
71 # update our session so the userenv is updated
72 $session->param('branchprinter', $printer);
75 if (!C4::Context->userenv && !$branch){
76 if ($session->param('branch') eq 'NO_LIBRARY_SET'){
77 # no branch set we can't issue
78 print $query->redirect("/cgi-bin/koha/circ/selectbranchprinter.pl");
79 exit;
83 my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
85 template_name => 'circ/circulation.tmpl',
86 query => $query,
87 type => "intranet",
88 authnotrequired => 0,
89 flagsrequired => { circulate => 'circulate_remaining_permissions' },
93 my $branches = GetBranches();
95 my @failedrenews = $query->param('failedrenew'); # expected to be itemnumbers
96 our %renew_failed;
97 for (@failedrenews) { $renew_failed{$_} = 1; }
99 my $findborrower = $query->param('findborrower');
100 $findborrower =~ s|,| |g;
101 my $borrowernumber = $query->param('borrowernumber');
103 $branch = C4::Context->userenv->{'branch'};
104 $printer = C4::Context->userenv->{'branchprinter'};
107 # If AutoLocation is not activated, we show the Circulation Parameters to chage settings of librarian
108 if (C4::Context->preference("AutoLocation") != 1) {
109 $template->param(ManualLocation => 1);
112 if (C4::Context->preference("DisplayClearScreenButton")) {
113 $template->param(DisplayClearScreenButton => 1);
116 if (C4::Context->preference("UseTablesortForCirc")) {
117 $template->param(UseTablesortForCirc => 1);
120 my $barcode = $query->param('barcode') || '';
121 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespace
123 $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
124 my $stickyduedate = $query->param('stickyduedate') || $session->param('stickyduedate');
125 my $duedatespec = $query->param('duedatespec') || $session->param('stickyduedate');
126 my $issueconfirmed = $query->param('issueconfirmed');
127 my $cancelreserve = $query->param('cancelreserve');
128 my $organisation = $query->param('organisations');
129 my $print = $query->param('print');
130 my $newexpiry = $query->param('dateexpiry');
131 my $debt_confirmed = $query->param('debt_confirmed') || 0; # Don't show the debt error dialog twice
133 # Check if stickyduedate is turned off
134 if ( $barcode ) {
135 # was stickyduedate loaded from session?
136 if ( $stickyduedate && ! $query->param("stickyduedate") ) {
137 $session->clear( 'stickyduedate' );
138 $stickyduedate = $query->param('stickyduedate');
139 $duedatespec = $query->param('duedatespec');
143 my ($datedue,$invalidduedate);
145 my $duedatespec_allow = C4::Context->preference('SpecifyDueDate');
146 if($duedatespec_allow){
147 if ($duedatespec) {
148 if ($duedatespec =~ C4::Dates->regexp('syspref')) {
149 $datedue = dt_from_string($duedatespec);
150 $datedue->set_hour(23);
151 $datedue->set_minute(59);
152 } else {
153 $invalidduedate = 1;
154 $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
159 our $todaysdate = C4::Dates->new->output('iso');
161 # check and see if we should print
162 if ( $barcode eq '' && $print eq 'maybe' ) {
163 $print = 'yes';
166 my $inprocess = ($barcode eq '') ? '' : $query->param('inprocess');
167 if ( $barcode eq '' && $query->param('charges') eq 'yes' ) {
168 $template->param(
169 PAYCHARGES => 'yes',
170 borrowernumber => $borrowernumber
174 if ( $print eq 'yes' && $borrowernumber ne '' ) {
175 PrintIssueSlip($session->param('branch') || $branch, $borrowernumber);
176 $query->param( 'borrowernumber', '' );
177 $borrowernumber = '';
181 # STEP 2 : FIND BORROWER
182 # if there is a list of find borrowers....
184 my $borrowerslist;
185 my $message;
186 if ($findborrower) {
187 my $borrowers = Search($findborrower, 'cardnumber');
188 my @borrowers = @$borrowers;
189 if (C4::Context->preference("AddPatronLists")) {
190 $template->param(
191 "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
193 if (C4::Context->preference("AddPatronLists")=~/code/){
194 my $categories = GetBorrowercategoryList;
195 $categories->[0]->{'first'} = 1;
196 $template->param(categories=>$categories);
199 if ( $#borrowers == -1 ) {
200 $query->param( 'findborrower', '' );
201 $message = "'$findborrower'";
203 elsif ( $#borrowers == 0 ) {
204 $query->param( 'borrowernumber', $borrowers[0]->{'borrowernumber'} );
205 $query->param( 'barcode', '' );
206 $borrowernumber = $borrowers[0]->{'borrowernumber'};
208 else {
209 $borrowerslist = \@borrowers;
213 # get the borrower information.....
214 my $borrower;
215 if ($borrowernumber) {
216 $borrower = GetMemberDetails( $borrowernumber, 0 );
217 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
219 # Warningdate is the date that the warning starts appearing
220 my ( $today_year, $today_month, $today_day) = Today();
221 my ($warning_year, $warning_month, $warning_day) = split /-/, $borrower->{'dateexpiry'};
222 my ( $enrol_year, $enrol_month, $enrol_day) = split /-/, $borrower->{'dateenrolled'};
223 # Renew day is calculated by adding the enrolment period to today
224 my ( $renew_year, $renew_month, $renew_day);
225 if ($enrol_year*$enrol_month*$enrol_day>0) {
226 ( $renew_year, $renew_month, $renew_day) =
227 Add_Delta_YM( $enrol_year, $enrol_month, $enrol_day,
228 0 , $borrower->{'enrolmentperiod'});
230 # if the expiry date is before today ie they have expired
231 if ( !$borrower->{'dateexpiry'} || $warning_year*$warning_month*$warning_day==0
232 || Date_to_Days($today_year, $today_month, $today_day )
233 > Date_to_Days($warning_year, $warning_month, $warning_day) )
235 #borrowercard expired, no issues
236 $template->param(
237 flagged => "1",
238 noissues => "1",
239 expired => "1",
240 renewaldate => format_date("$renew_year-$renew_month-$renew_day")
243 # check for NotifyBorrowerDeparture
244 elsif ( C4::Context->preference('NotifyBorrowerDeparture') &&
245 Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
246 Date_to_Days( $today_year, $today_month, $today_day ) )
248 # borrower card soon to expire warn librarian
249 $template->param("warndeparture" => format_date($borrower->{dateexpiry}),
250 flagged => "1",);
251 if (C4::Context->preference('ReturnBeforeExpiry')){
252 $template->param("returnbeforeexpiry" => 1);
255 $template->param(
256 overduecount => $od,
257 issuecount => $issue,
258 finetotal => $fines
261 my $debar = CheckBorrowerDebarred($borrowernumber);
262 if ($debar) {
263 $template->param( 'userdebarred' => 1 );
264 $template->param( 'debarredcomment' => $borrower->{debarredcomment} );
265 if ( $debar ne "9999-12-31" ) {
266 $template->param( 'userdebarreddate' => C4::Dates::format_date($debar) );
273 # STEP 3 : ISSUING
276 if ($barcode) {
277 # always check for blockers on issuing
278 my ( $error, $question ) =
279 CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess );
280 my $blocker = $invalidduedate ? 1 : 0;
282 delete $question->{'DEBT'} if ($debt_confirmed);
283 foreach my $impossible ( keys %$error ) {
284 $template->param(
285 $impossible => $$error{$impossible},
286 IMPOSSIBLE => 1
288 $blocker = 1;
290 if( !$blocker ){
291 my $confirm_required = 0;
292 unless($issueconfirmed){
293 # Get the item title for more information
294 my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
295 $template->{VARS}->{'additional_materials'} = $getmessageiteminfo->{'materials'};
296 $template->param( itemhomebranch => $getmessageiteminfo->{'homebranch'} );
298 # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
299 foreach my $needsconfirmation ( keys %$question ) {
300 $template->param(
301 $needsconfirmation => $$question{$needsconfirmation},
302 getTitleMessageIteminfo => $getmessageiteminfo->{'title'},
303 getBarcodeMessageIteminfo => $getmessageiteminfo->{'barcode'},
304 NEEDSCONFIRMATION => 1
306 $confirm_required = 1;
309 unless($confirm_required) {
310 AddIssue( $borrower, $barcode, $datedue, $cancelreserve );
311 $inprocess = 1;
315 # FIXME If the issue is confirmed, we launch another time GetMemberIssuesAndFines, now display the issue count after issue
316 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
317 $template->param( issuecount => $issue );
320 # reload the borrower info for the sake of reseting the flags.....
321 if ($borrowernumber) {
322 $borrower = GetMemberDetails( $borrowernumber, 0 );
325 ##################################################################################
326 # BUILD HTML
327 # show all reserves of this borrower, and the position of the reservation ....
328 if ($borrowernumber) {
330 # new op dev
331 # now we show the status of the borrower's reservations
332 my @borrowerreserv = GetReservesFromBorrowernumber($borrowernumber );
333 my @reservloop;
334 my @WaitingReserveLoop;
336 foreach my $num_res (@borrowerreserv) {
337 my %getreserv;
338 my %getWaitingReserveInfo;
339 my $getiteminfo = GetBiblioFromItemNumber( $num_res->{'itemnumber'} );
340 my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $getiteminfo->{'itype'} : $getiteminfo->{'itemtype'} );
341 my ( $transfertwhen, $transfertfrom, $transfertto ) =
342 GetTransfers( $num_res->{'itemnumber'} );
344 $getreserv{waiting} = 0;
345 $getreserv{transfered} = 0;
346 $getreserv{nottransfered} = 0;
348 $getreserv{reservedate} = format_date( $num_res->{'reservedate'} );
349 $getreserv{reservenumber} = $num_res->{'reservenumber'};
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 $getreserv{suspend} = $num_res->{'suspend'};
358 $getreserv{suspend_until} = $num_res->{'suspend_until'};
359 # check if we have a waiting status for reservations
360 if ( $num_res->{'found'} eq 'W' ) {
361 $getreserv{color} = 'reserved';
362 $getreserv{waiting} = 1;
363 # genarate information displaying only waiting reserves
364 $getWaitingReserveInfo{title} = $getiteminfo->{'title'};
365 $getWaitingReserveInfo{biblionumber} = $getiteminfo->{'biblionumber'};
366 $getWaitingReserveInfo{itemtype} = $itemtypeinfo->{'description'};
367 $getWaitingReserveInfo{author} = $getiteminfo->{'author'};
368 $getWaitingReserveInfo{reservedate} = format_date( $num_res->{'reservedate'} );
369 $getWaitingReserveInfo{waitingat} = GetBranchName( $num_res->{'branchcode'} );
370 $getWaitingReserveInfo{waitinghere} = 1 if $num_res->{'branchcode'} eq $branch;
372 # check transfers with the itemnumber foud in th reservation loop
373 if ($transfertwhen) {
374 $getreserv{color} = 'transfered';
375 $getreserv{transfered} = 1;
376 $getreserv{datesent} = format_date($transfertwhen);
377 $getreserv{frombranch} = GetBranchName($transfertfrom);
378 } elsif ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'}) {
379 $getreserv{nottransfered} = 1;
380 $getreserv{nottransferedby} = GetBranchName( $getiteminfo->{'holdingbranch'} );
383 # if we don't have a reserv on item, we put the biblio infos and the waiting position
384 if ( $getiteminfo->{'title'} eq '' ) {
385 my $getbibinfo = GetBiblioData( $num_res->{'biblionumber'} );
387 $getreserv{color} = 'inwait';
388 $getreserv{title} = $getbibinfo->{'title'};
389 $getreserv{nottransfered} = 0;
390 $getreserv{itemtype} = $itemtypeinfo->{'description'};
391 $getreserv{author} = $getbibinfo->{'author'};
392 $getreserv{biblionumber} = $num_res->{'biblionumber'};
394 $getreserv{waitingposition} = $num_res->{'priority'};
395 push( @reservloop, \%getreserv );
397 # if we have a reserve waiting, initiate waitingreserveloop
398 if ($getreserv{waiting} == 1) {
399 push (@WaitingReserveLoop, \%getWaitingReserveInfo)
404 # return result to the template
405 $template->param(
406 countreserv => scalar @reservloop,
407 reservloop => \@reservloop ,
408 WaitingReserveLoop => \@WaitingReserveLoop,
410 $template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' );
413 # make the issued books table.
414 my $todaysissues = '';
415 my $previssues = '';
416 our @todaysissues;
417 our @previousissues;
418 our @relissues;
419 our @relprevissues;
420 my $displayrelissues;
422 our $totalprice = 0;
424 sub build_issue_data {
425 my $issueslist = shift;
426 my $relatives = shift;
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'} );
432 # set itemtype per item-level_itype syspref - FIXME this is an ugly hack
433 $it->{'itemtype'} = ( C4::Context->preference( 'item-level_itypes' ) ) ? $it->{'itype'} : $it->{'itemtype'};
435 ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
436 $it->{'itemnumber'}, $it->{'borrowernumber'}
438 $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
439 my ($can_renew, $can_renew_error) = CanBookBeRenewed(
440 $it->{'borrowernumber'},$it->{'itemnumber'}
442 $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
443 my ( $restype, $reserves, undef ) = CheckReserves( $it->{'itemnumber'} );
444 $it->{'can_renew'} = $can_renew;
445 $it->{'can_confirm'} = !$can_renew && !$restype;
446 $it->{'renew_error'} = $restype;
447 $it->{'checkoutdate'} = C4::Dates->new($it->{'issuedate'},'iso')->output('syspref');
448 $it->{'issuingbranchname'} = GetBranchName($it->{'branchcode'});
450 $totalprice += $it->{'replacementprice'};
451 $it->{'itemtype'} = $itemtypeinfo->{'description'};
452 $it->{'itemtype_image'} = $itemtypeinfo->{'imageurl'};
453 $it->{'dd'} = output_pref($it->{'date_due'});
454 $it->{'displaydate'} = output_pref($it->{'issuedate'});
455 #$it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ;
456 $it->{'od'} = $it->{'overdue'};
457 ($it->{'author'} eq '') and $it->{'author'} = ' ';
458 $it->{'renew_failed'} = $renew_failed{$it->{'itemnumber'}};
460 if ( $todaysdate eq $it->{'issuedate'} or $todaysdate eq $it->{'lastreneweddate'} ) {
461 (!$relatives) ? push @todaysissues, $it : push @relissues, $it;
462 } else {
463 (!$relatives) ? push @previousissues, $it : push @relprevissues, $it;
468 if ($borrower) {
470 # Getting borrower relatives
471 my @relborrowernumbers = GetMemberRelatives($borrower->{'borrowernumber'});
472 #push @borrowernumbers, $borrower->{'borrowernumber'};
474 # get each issue of the borrower & separate them in todayissues & previous issues
475 my $issueslist = GetPendingIssues($borrower->{'borrowernumber'});
476 my $relissueslist = [];
477 if ( @relborrowernumbers ) {
478 $relissueslist = GetPendingIssues(@relborrowernumbers);
481 build_issue_data($issueslist, 0);
482 build_issue_data($relissueslist, 1);
484 $displayrelissues = scalar($relissueslist);
486 if ( C4::Context->preference( "todaysIssuesDefaultSortOrder" ) eq 'asc' ) {
487 @todaysissues = sort { $a->{'timestamp'} cmp $b->{'timestamp'} } @todaysissues;
489 else {
490 @todaysissues = sort { $b->{'timestamp'} cmp $a->{'timestamp'} } @todaysissues;
493 if ( C4::Context->preference( "previousIssuesDefaultSortOrder" ) eq 'asc' ){
494 @previousissues = sort { $a->{'date_due'} cmp $b->{'date_due'} } @previousissues;
496 else {
497 @previousissues = sort { $b->{'date_due'} cmp $a->{'date_due'} } @previousissues;
502 my @values;
503 my %labels;
504 my $CGIselectborrower;
505 if ($borrowerslist) {
506 foreach (
507 sort {(lc $a->{'surname'} cmp lc $b->{'surname'} || lc $a->{'firstname'} cmp lc $b->{'firstname'})
508 } @$borrowerslist
511 push @values, $_->{'borrowernumber'};
512 $labels{ $_->{'borrowernumber'} } =
513 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'} - $_->{'branchcode'}) ... $_->{'address'} ";
515 $CGIselectborrower = CGI::scrolling_list(
516 -name => 'borrowernumber',
517 -class => 'focus',
518 -id => 'borrowernumber',
519 -values => \@values,
520 -labels => \%labels,
521 -ondblclick => 'document.forms[\'mainform\'].submit()',
522 -size => 7,
523 -tabindex => '',
524 -multiple => 0
528 #title
529 my $flags = $borrower->{'flags'};
530 foreach my $flag ( sort keys %$flags ) {
531 $template->param( flagged=> 1);
532 $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
533 if ( $flags->{$flag}->{'noissues'} ) {
534 $template->param(
535 flagged => 1,
536 noissues => 'true',
538 if ( $flag eq 'GNA' ) {
539 $template->param( gna => 'true' );
541 elsif ( $flag eq 'LOST' ) {
542 $template->param( lost => 'true' );
544 elsif ( $flag eq 'DBARRED' ) {
545 $template->param( dbarred => 'true' );
547 elsif ( $flag eq 'CHARGES' ) {
548 $template->param(
549 charges => 'true',
550 chargesmsg => $flags->{'CHARGES'}->{'message'},
551 chargesamount => $flags->{'CHARGES'}->{'amount'},
552 charges_is_blocker => 1
555 elsif ( $flag eq 'CREDITS' ) {
556 $template->param(
557 credits => 'true',
558 creditsmsg => $flags->{'CREDITS'}->{'message'},
559 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
563 else {
564 if ( $flag eq 'CHARGES' ) {
565 $template->param(
566 charges => 'true',
567 flagged => 1,
568 chargesmsg => $flags->{'CHARGES'}->{'message'},
569 chargesamount => $flags->{'CHARGES'}->{'amount'},
572 elsif ( $flag eq 'CREDITS' ) {
573 $template->param(
574 credits => 'true',
575 creditsmsg => $flags->{'CREDITS'}->{'message'},
576 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
579 elsif ( $flag eq 'ODUES' ) {
580 $template->param(
581 odues => 'true',
582 flagged => 1,
583 oduesmsg => $flags->{'ODUES'}->{'message'}
586 my $items = $flags->{$flag}->{'itemlist'};
587 if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
588 $template->param( nonreturns => 'true' );
591 elsif ( $flag eq 'NOTES' ) {
592 $template->param(
593 notes => 'true',
594 flagged => 1,
595 notesmsg => $flags->{'NOTES'}->{'message'}
601 my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
602 $amountold =~ s/^.*\$//; # remove upto the $, if any
604 my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
606 if ( $borrower->{'category_type'} eq 'C') {
607 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
608 my $cnt = scalar(@$catcodes);
609 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
610 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
613 my $CGIorganisations;
614 my $member_of_institution;
615 if ( C4::Context->preference("memberofinstitution") ) {
616 my $organisations = get_institutions();
617 my @orgs;
618 my %org_labels;
619 foreach my $organisation ( keys %$organisations ) {
620 push @orgs, $organisation;
621 $org_labels{$organisation} = $organisations->{$organisation}->{'surname'};
623 $member_of_institution = 1;
624 $CGIorganisations = CGI::popup_menu(
625 -id => 'organisations',
626 -name => 'organisations',
627 -labels => \%org_labels,
628 -values => \@orgs,
632 my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch );
633 if($lib_messages_loop){ $template->param(flagged => 1 ); }
635 my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch );
636 if($bor_messages_loop){ $template->param(flagged => 1 ); }
638 # Computes full borrower address
639 my (undef, $roadttype_hashref) = &GetRoadTypes();
640 my $address = $borrower->{'streetnumber'}.' '.$roadttype_hashref->{$borrower->{'streettype'}}.' '.$borrower->{'address'};
642 my $fast_cataloging = 0;
643 if (defined getframeworkinfo('FA')) {
644 $fast_cataloging = 1
647 if (C4::Context->preference('ExtendedPatronAttributes')) {
648 my $attributes = GetBorrowerAttributes($borrowernumber);
649 $template->param(
650 ExtendedPatronAttributes => 1,
651 extendedattributes => $attributes
655 $template->param(
656 lib_messages_loop => $lib_messages_loop,
657 bor_messages_loop => $bor_messages_loop,
658 all_messages_del => C4::Context->preference('AllowAllMessageDeletion'),
659 findborrower => $findborrower,
660 borrower => $borrower,
661 borrowernumber => $borrowernumber,
662 branch => $branch,
663 branchname => GetBranchName($borrower->{'branchcode'}),
664 printer => $printer,
665 printername => $printer,
666 firstname => $borrower->{'firstname'},
667 surname => $borrower->{'surname'},
668 showname => $borrower->{'showname'},
669 category_type => $borrower->{'category_type'},
670 dateexpiry => format_date($newexpiry),
671 expiry => format_date($borrower->{'dateexpiry'}),
672 categorycode => $borrower->{'categorycode'},
673 categoryname => $borrower->{description},
674 address => $address,
675 address2 => $borrower->{'address2'},
676 email => $borrower->{'email'},
677 emailpro => $borrower->{'emailpro'},
678 borrowernotes => $borrower->{'borrowernotes'},
679 city => $borrower->{'city'},
680 state => $borrower->{'state'},
681 zipcode => $borrower->{'zipcode'},
682 country => $borrower->{'country'},
683 phone => $borrower->{'phone'} || $borrower->{'mobile'},
684 cardnumber => $borrower->{'cardnumber'},
685 othernames => $borrower->{'othernames'},
686 amountold => $amountold,
687 barcode => $barcode,
688 stickyduedate => $stickyduedate,
689 duedatespec => $duedatespec,
690 message => $message,
691 CGIselectborrower => $CGIselectborrower,
692 totalprice => sprintf('%.2f', $totalprice),
693 totaldue => sprintf('%.2f', $total),
694 todayissues => \@todaysissues,
695 previssues => \@previousissues,
696 relissues => \@relissues,
697 relprevissues => \@relprevissues,
698 displayrelissues => $displayrelissues,
699 inprocess => $inprocess,
700 memberofinstution => $member_of_institution,
701 CGIorganisations => $CGIorganisations,
702 is_child => ($borrower->{'category_type'} eq 'C'),
703 circview => 1,
704 soundon => C4::Context->preference("SoundOn"),
705 fast_cataloging => $fast_cataloging,
706 CircAutoPrintQuickSlip => C4::Context->preference("CircAutoPrintQuickSlip"),
707 activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
710 # save stickyduedate to session
711 if ($stickyduedate) {
712 $session->param( 'stickyduedate', $duedatespec );
715 my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
716 $template->param( picture => 1 ) if $picture;
718 # get authorised values with type of BOR_NOTES
720 my $canned_notes = GetAuthorisedValues("BOR_NOTES");
722 $template->param(
723 debt_confirmed => $debt_confirmed,
724 SpecifyDueDate => $duedatespec_allow,
725 CircAutocompl => C4::Context->preference("CircAutocompl"),
726 AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
727 dateformat => C4::Context->preference("dateformat"),
728 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
729 canned_bor_notes_loop => $canned_notes,
732 $template->param( AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds') );
734 output_html_with_http_headers $query, $cookie, $template->output;