Bug 8178 - circ/circulation.pl under plack duplicates checkout rows
[koha.git] / circ / circulation.pl
blobc4001d0cef3c90aaaf7275c8ff00b40dfd469f46
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 $datedue->set_hour(23);
152 $datedue->set_minute(59);
153 } else {
154 $invalidduedate = 1;
155 $template->param(IMPOSSIBLE=>1, INVALID_DATE=>$duedatespec);
160 our $todaysdate = C4::Dates->new->output('iso');
162 # check and see if we should print
163 if ( $barcode eq '' && $print eq 'maybe' ) {
164 $print = 'yes';
167 my $inprocess = ($barcode eq '') ? '' : $query->param('inprocess');
168 if ( $barcode eq '' && $query->param('charges') eq 'yes' ) {
169 $template->param(
170 PAYCHARGES => 'yes',
171 borrowernumber => $borrowernumber
175 if ( $print eq 'yes' && $borrowernumber ne '' ) {
176 if ( C4::Context->boolean_preference('printcirculationslips') ) {
177 my $letter = IssueSlip($branch, $borrowernumber, "QUICK");
178 NetworkPrint($letter->{content});
180 $query->param( 'borrowernumber', '' );
181 $borrowernumber = '';
185 # STEP 2 : FIND BORROWER
186 # if there is a list of find borrowers....
188 my $borrowerslist;
189 my $message;
190 if ($findborrower) {
191 my $borrowers = Search($findborrower, 'cardnumber');
192 my @borrowers = @$borrowers;
193 if (C4::Context->preference("AddPatronLists")) {
194 $template->param(
195 "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
197 if (C4::Context->preference("AddPatronLists")=~/code/){
198 my $categories = GetBorrowercategoryList;
199 $categories->[0]->{'first'} = 1;
200 $template->param(categories=>$categories);
203 if ( $#borrowers == -1 ) {
204 $query->param( 'findborrower', '' );
205 $message = "'$findborrower'";
207 elsif ( $#borrowers == 0 ) {
208 $query->param( 'borrowernumber', $borrowers[0]->{'borrowernumber'} );
209 $query->param( 'barcode', '' );
210 $borrowernumber = $borrowers[0]->{'borrowernumber'};
212 else {
213 $borrowerslist = \@borrowers;
217 # get the borrower information.....
218 my $borrower;
219 if ($borrowernumber) {
220 $borrower = GetMemberDetails( $borrowernumber, 0 );
221 my ( $od, $issue, $fines ) = GetMemberIssuesAndFines( $borrowernumber );
223 # Warningdate is the date that the warning starts appearing
224 my ( $today_year, $today_month, $today_day) = Today();
225 my ($warning_year, $warning_month, $warning_day) = split /-/, $borrower->{'dateexpiry'};
226 my ( $enrol_year, $enrol_month, $enrol_day) = split /-/, $borrower->{'dateenrolled'};
227 # Renew day is calculated by adding the enrolment period to today
228 my ( $renew_year, $renew_month, $renew_day);
229 if ($enrol_year*$enrol_month*$enrol_day>0) {
230 ( $renew_year, $renew_month, $renew_day) =
231 Add_Delta_YM( $enrol_year, $enrol_month, $enrol_day,
232 0 , $borrower->{'enrolmentperiod'});
234 # if the expiry date is before today ie they have expired
235 if ( !$borrower->{'dateexpiry'} || $warning_year*$warning_month*$warning_day==0
236 || Date_to_Days($today_year, $today_month, $today_day )
237 > Date_to_Days($warning_year, $warning_month, $warning_day) )
239 #borrowercard expired, no issues
240 $template->param(
241 flagged => "1",
242 noissues => "1",
243 expired => "1",
244 renewaldate => format_date("$renew_year-$renew_month-$renew_day")
247 # check for NotifyBorrowerDeparture
248 elsif ( C4::Context->preference('NotifyBorrowerDeparture') &&
249 Date_to_Days(Add_Delta_Days($warning_year,$warning_month,$warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
250 Date_to_Days( $today_year, $today_month, $today_day ) )
252 # borrower card soon to expire warn librarian
253 $template->param("warndeparture" => format_date($borrower->{dateexpiry}),
254 flagged => "1",);
255 if (C4::Context->preference('ReturnBeforeExpiry')){
256 $template->param("returnbeforeexpiry" => 1);
259 $template->param(
260 overduecount => $od,
261 issuecount => $issue,
262 finetotal => $fines
265 my $debar = CheckBorrowerDebarred($borrowernumber);
266 if ($debar) {
267 $template->param( 'userdebarred' => 1 );
268 $template->param( 'debarredcomment' => $borrower->{debarredcomment} );
269 if ( $debar ne "9999-12-31" ) {
270 $template->param( 'userdebarreddate' => C4::Dates::format_date($debar) );
277 # STEP 3 : ISSUING
280 if ($barcode) {
281 # always check for blockers on issuing
282 my ( $error, $question, $alerts ) =
283 CanBookBeIssued( $borrower, $barcode, $datedue , $inprocess );
284 my $blocker = $invalidduedate ? 1 : 0;
286 $template->param( alert => $alerts );
288 delete $question->{'DEBT'} if ($debt_confirmed);
289 foreach my $impossible ( keys %$error ) {
290 $template->param(
291 $impossible => $$error{$impossible},
292 IMPOSSIBLE => 1
294 $blocker = 1;
296 if( !$blocker ){
297 my $confirm_required = 0;
298 unless($issueconfirmed){
299 # Get the item title for more information
300 my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode);
301 $template->{VARS}->{'additional_materials'} = $getmessageiteminfo->{'materials'};
302 $template->param( itemhomebranch => $getmessageiteminfo->{'homebranch'} );
304 # pass needsconfirmation to template if issuing is possible and user hasn't yet confirmed.
305 foreach my $needsconfirmation ( keys %$question ) {
306 $template->param(
307 $needsconfirmation => $$question{$needsconfirmation},
308 getTitleMessageIteminfo => $getmessageiteminfo->{'title'},
309 getBarcodeMessageIteminfo => $getmessageiteminfo->{'barcode'},
310 NEEDSCONFIRMATION => 1
312 $confirm_required = 1;
315 unless($confirm_required) {
316 AddIssue( $borrower, $barcode, $datedue, $cancelreserve );
317 $inprocess = 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 $getreserv{suspend} = $num_res->{'suspend'};
364 $getreserv{suspend_until} = $num_res->{'suspend_until'};
365 # check if we have a waiting status for reservations
366 if ( $num_res->{'found'} eq 'W' ) {
367 $getreserv{color} = 'reserved';
368 $getreserv{waiting} = 1;
369 # genarate information displaying only waiting reserves
370 $getWaitingReserveInfo{title} = $getiteminfo->{'title'};
371 $getWaitingReserveInfo{biblionumber} = $getiteminfo->{'biblionumber'};
372 $getWaitingReserveInfo{itemtype} = $itemtypeinfo->{'description'};
373 $getWaitingReserveInfo{author} = $getiteminfo->{'author'};
374 $getWaitingReserveInfo{reservedate} = format_date( $num_res->{'reservedate'} );
375 $getWaitingReserveInfo{waitingat} = GetBranchName( $num_res->{'branchcode'} );
376 $getWaitingReserveInfo{waitinghere} = 1 if $num_res->{'branchcode'} eq $branch;
378 # check transfers with the itemnumber foud in th reservation loop
379 if ($transfertwhen) {
380 $getreserv{color} = 'transfered';
381 $getreserv{transfered} = 1;
382 $getreserv{datesent} = format_date($transfertwhen);
383 $getreserv{frombranch} = GetBranchName($transfertfrom);
384 } elsif ($getiteminfo->{'holdingbranch'} ne $num_res->{'branchcode'}) {
385 $getreserv{nottransfered} = 1;
386 $getreserv{nottransferedby} = GetBranchName( $getiteminfo->{'holdingbranch'} );
389 # if we don't have a reserv on item, we put the biblio infos and the waiting position
390 if ( $getiteminfo->{'title'} eq '' ) {
391 my $getbibinfo = GetBiblioData( $num_res->{'biblionumber'} );
393 $getreserv{color} = 'inwait';
394 $getreserv{title} = $getbibinfo->{'title'};
395 $getreserv{nottransfered} = 0;
396 $getreserv{itemtype} = $itemtypeinfo->{'description'};
397 $getreserv{author} = $getbibinfo->{'author'};
398 $getreserv{biblionumber} = $num_res->{'biblionumber'};
400 $getreserv{waitingposition} = $num_res->{'priority'};
401 push( @reservloop, \%getreserv );
403 # if we have a reserve waiting, initiate waitingreserveloop
404 if ($getreserv{waiting} == 1) {
405 push (@WaitingReserveLoop, \%getWaitingReserveInfo)
410 # return result to the template
411 $template->param(
412 countreserv => scalar @reservloop,
413 reservloop => \@reservloop ,
414 WaitingReserveLoop => \@WaitingReserveLoop,
416 $template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' );
419 # make the issued books table.
420 my $todaysissues = '';
421 my $previssues = '';
422 our @todaysissues = ();
423 our @previousissues = ();
424 our @relissues = ();
425 our @relprevissues = ();
426 my $displayrelissues;
428 our $totalprice = 0;
430 sub build_issue_data {
431 my $issueslist = shift;
432 my $relatives = shift;
434 # split in 2 arrays for today & previous
435 foreach my $it ( @$issueslist ) {
436 my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $it->{'itype'} : $it->{'itemtype'} );
438 # set itemtype per item-level_itype syspref - FIXME this is an ugly hack
439 $it->{'itemtype'} = ( C4::Context->preference( 'item-level_itypes' ) ) ? $it->{'itype'} : $it->{'itemtype'};
441 ($it->{'charge'}, $it->{'itemtype_charge'}) = GetIssuingCharges(
442 $it->{'itemnumber'}, $it->{'borrowernumber'}
444 $it->{'charge'} = sprintf("%.2f", $it->{'charge'});
445 my ($can_renew, $can_renew_error) = CanBookBeRenewed(
446 $it->{'borrowernumber'},$it->{'itemnumber'}
448 $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error;
449 my ( $restype, $reserves, undef ) = CheckReserves( $it->{'itemnumber'} );
450 $it->{'can_renew'} = $can_renew;
451 $it->{'can_confirm'} = !$can_renew && !$restype;
452 $it->{'renew_error'} = $restype;
453 $it->{'checkoutdate'} = C4::Dates->new($it->{'issuedate'},'iso')->output('syspref');
454 $it->{'issuingbranchname'} = GetBranchName($it->{'branchcode'});
456 $totalprice += $it->{'replacementprice'};
457 $it->{'itemtype'} = $itemtypeinfo->{'description'};
458 $it->{'itemtype_image'} = $itemtypeinfo->{'imageurl'};
459 $it->{'dd'} = output_pref($it->{'date_due'});
460 $it->{'displaydate'} = output_pref($it->{'issuedate'});
461 #$it->{'od'} = ( $it->{'date_due'} lt $todaysdate ) ? 1 : 0 ;
462 $it->{'od'} = $it->{'overdue'};
463 ($it->{'author'} eq '') and $it->{'author'} = ' ';
464 $it->{'renew_failed'} = $renew_failed{$it->{'itemnumber'}};
466 if ( $todaysdate eq $it->{'issuedate'} or $todaysdate eq $it->{'lastreneweddate'} ) {
467 (!$relatives) ? push @todaysissues, $it : push @relissues, $it;
468 } else {
469 (!$relatives) ? push @previousissues, $it : push @relprevissues, $it;
474 if ($borrower) {
476 # Getting borrower relatives
477 my @relborrowernumbers = GetMemberRelatives($borrower->{'borrowernumber'});
478 #push @borrowernumbers, $borrower->{'borrowernumber'};
480 # get each issue of the borrower & separate them in todayissues & previous issues
481 my $issueslist = GetPendingIssues($borrower->{'borrowernumber'});
482 my $relissueslist = [];
483 if ( @relborrowernumbers ) {
484 $relissueslist = GetPendingIssues(@relborrowernumbers);
487 build_issue_data($issueslist, 0);
488 build_issue_data($relissueslist, 1);
490 $displayrelissues = scalar($relissueslist);
492 if ( C4::Context->preference( "todaysIssuesDefaultSortOrder" ) eq 'asc' ) {
493 @todaysissues = sort { $a->{'timestamp'} cmp $b->{'timestamp'} } @todaysissues;
495 else {
496 @todaysissues = sort { $b->{'timestamp'} cmp $a->{'timestamp'} } @todaysissues;
499 if ( C4::Context->preference( "previousIssuesDefaultSortOrder" ) eq 'asc' ){
500 @previousissues = sort { $a->{'date_due'} cmp $b->{'date_due'} } @previousissues;
502 else {
503 @previousissues = sort { $b->{'date_due'} cmp $a->{'date_due'} } @previousissues;
508 my @values;
509 my %labels;
510 my $CGIselectborrower;
511 if ($borrowerslist) {
512 foreach (
513 sort {(lc $a->{'surname'} cmp lc $b->{'surname'} || lc $a->{'firstname'} cmp lc $b->{'firstname'})
514 } @$borrowerslist
517 push @values, $_->{'borrowernumber'};
518 $labels{ $_->{'borrowernumber'} } =
519 "$_->{'surname'}, $_->{'firstname'} ... ($_->{'cardnumber'} - $_->{'categorycode'} - $_->{'branchcode'}) ... $_->{'address'} ";
521 $CGIselectborrower = CGI::scrolling_list(
522 -name => 'borrowernumber',
523 -class => 'focus',
524 -id => 'borrowernumber',
525 -values => \@values,
526 -labels => \%labels,
527 -ondblclick => 'document.forms[\'mainform\'].submit()',
528 -size => 7,
529 -tabindex => '',
530 -multiple => 0
534 #title
535 my $flags = $borrower->{'flags'};
536 foreach my $flag ( sort keys %$flags ) {
537 $template->param( flagged=> 1);
538 $flags->{$flag}->{'message'} =~ s#\n#<br />#g;
539 if ( $flags->{$flag}->{'noissues'} ) {
540 $template->param(
541 flagged => 1,
542 noissues => 'true',
544 if ( $flag eq 'GNA' ) {
545 $template->param( gna => 'true' );
547 elsif ( $flag eq 'LOST' ) {
548 $template->param( lost => 'true' );
550 elsif ( $flag eq 'DBARRED' ) {
551 $template->param( dbarred => 'true' );
553 elsif ( $flag eq 'CHARGES' ) {
554 $template->param(
555 charges => 'true',
556 chargesmsg => $flags->{'CHARGES'}->{'message'},
557 chargesamount => $flags->{'CHARGES'}->{'amount'},
558 charges_is_blocker => 1
561 elsif ( $flag eq 'CREDITS' ) {
562 $template->param(
563 credits => 'true',
564 creditsmsg => $flags->{'CREDITS'}->{'message'},
565 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
569 else {
570 if ( $flag eq 'CHARGES' ) {
571 $template->param(
572 charges => 'true',
573 flagged => 1,
574 chargesmsg => $flags->{'CHARGES'}->{'message'},
575 chargesamount => $flags->{'CHARGES'}->{'amount'},
578 elsif ( $flag eq 'CREDITS' ) {
579 $template->param(
580 credits => 'true',
581 creditsmsg => $flags->{'CREDITS'}->{'message'},
582 creditsamount => sprintf("%.02f", -($flags->{'CREDITS'}->{'amount'})), # from patron's pov
585 elsif ( $flag eq 'ODUES' ) {
586 $template->param(
587 odues => 'true',
588 flagged => 1,
589 oduesmsg => $flags->{'ODUES'}->{'message'}
592 my $items = $flags->{$flag}->{'itemlist'};
593 if ( ! $query->param('module') || $query->param('module') ne 'returns' ) {
594 $template->param( nonreturns => 'true' );
597 elsif ( $flag eq 'NOTES' ) {
598 $template->param(
599 notes => 'true',
600 flagged => 1,
601 notesmsg => $flags->{'NOTES'}->{'message'}
607 my $amountold = $borrower->{flags}->{'CHARGES'}->{'message'} || 0;
608 $amountold =~ s/^.*\$//; # remove upto the $, if any
610 my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
612 if ( $borrower->{'category_type'} eq 'C') {
613 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
614 my $cnt = scalar(@$catcodes);
615 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
616 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
619 my $CGIorganisations;
620 my $member_of_institution;
621 if ( C4::Context->preference("memberofinstitution") ) {
622 my $organisations = get_institutions();
623 my @orgs;
624 my %org_labels;
625 foreach my $organisation ( keys %$organisations ) {
626 push @orgs, $organisation;
627 $org_labels{$organisation} = $organisations->{$organisation}->{'surname'};
629 $member_of_institution = 1;
630 $CGIorganisations = CGI::popup_menu(
631 -id => 'organisations',
632 -name => 'organisations',
633 -labels => \%org_labels,
634 -values => \@orgs,
638 my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch );
639 if($lib_messages_loop){ $template->param(flagged => 1 ); }
641 my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch );
642 if($bor_messages_loop){ $template->param(flagged => 1 ); }
644 # Computes full borrower address
645 my (undef, $roadttype_hashref) = &GetRoadTypes();
646 my $address = $borrower->{'streetnumber'}.' '.$roadttype_hashref->{$borrower->{'streettype'}}.' '.$borrower->{'address'};
648 my $fast_cataloging = 0;
649 if (defined getframeworkinfo('FA')) {
650 $fast_cataloging = 1
653 if (C4::Context->preference('ExtendedPatronAttributes')) {
654 my $attributes = GetBorrowerAttributes($borrowernumber);
655 $template->param(
656 ExtendedPatronAttributes => 1,
657 extendedattributes => $attributes
661 $template->param(
662 lib_messages_loop => $lib_messages_loop,
663 bor_messages_loop => $bor_messages_loop,
664 all_messages_del => C4::Context->preference('AllowAllMessageDeletion'),
665 findborrower => $findborrower,
666 borrower => $borrower,
667 borrowernumber => $borrowernumber,
668 branch => $branch,
669 branchname => GetBranchName($borrower->{'branchcode'}),
670 printer => $printer,
671 printername => $printer,
672 firstname => $borrower->{'firstname'},
673 surname => $borrower->{'surname'},
674 showname => $borrower->{'showname'},
675 category_type => $borrower->{'category_type'},
676 dateexpiry => format_date($newexpiry),
677 expiry => format_date($borrower->{'dateexpiry'}),
678 categorycode => $borrower->{'categorycode'},
679 categoryname => $borrower->{description},
680 address => $address,
681 address2 => $borrower->{'address2'},
682 email => $borrower->{'email'},
683 emailpro => $borrower->{'emailpro'},
684 borrowernotes => $borrower->{'borrowernotes'},
685 city => $borrower->{'city'},
686 state => $borrower->{'state'},
687 zipcode => $borrower->{'zipcode'},
688 country => $borrower->{'country'},
689 phone => $borrower->{'phone'} || $borrower->{'mobile'},
690 cardnumber => $borrower->{'cardnumber'},
691 othernames => $borrower->{'othernames'},
692 amountold => $amountold,
693 barcode => $barcode,
694 stickyduedate => $stickyduedate,
695 duedatespec => $duedatespec,
696 message => $message,
697 CGIselectborrower => $CGIselectborrower,
698 totalprice => sprintf('%.2f', $totalprice),
699 totaldue => sprintf('%.2f', $total),
700 todayissues => \@todaysissues,
701 previssues => \@previousissues,
702 relissues => \@relissues,
703 relprevissues => \@relprevissues,
704 displayrelissues => $displayrelissues,
705 inprocess => $inprocess,
706 memberofinstution => $member_of_institution,
707 CGIorganisations => $CGIorganisations,
708 is_child => ($borrower->{'category_type'} eq 'C'),
709 circview => 1,
710 soundon => C4::Context->preference("SoundOn"),
711 fast_cataloging => $fast_cataloging,
712 CircAutoPrintQuickSlip => C4::Context->preference("CircAutoPrintQuickSlip"),
713 activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
714 SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
715 AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
718 # save stickyduedate to session
719 if ($stickyduedate) {
720 $session->param( 'stickyduedate', $duedatespec );
723 my ($picture, $dberror) = GetPatronImage($borrower->{'cardnumber'});
724 $template->param( picture => 1 ) if $picture;
726 # get authorised values with type of BOR_NOTES
728 my $canned_notes = GetAuthorisedValues("BOR_NOTES");
730 $template->param(
731 debt_confirmed => $debt_confirmed,
732 SpecifyDueDate => $duedatespec_allow,
733 CircAutocompl => C4::Context->preference("CircAutocompl"),
734 AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
735 dateformat => C4::Context->preference("dateformat"),
736 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
737 canned_bor_notes_loop => $canned_notes,
740 output_html_with_http_headers $query, $cookie, $template->output;