Lines 28-40
use C4::Koha;
Link Here
|
28 |
use C4::Biblio; |
28 |
use C4::Biblio; |
29 |
use C4::Items; |
29 |
use C4::Items; |
30 |
use C4::Members; |
30 |
use C4::Members; |
31 |
use C4::Dates; |
31 |
use C4::IssuingRules; |
|
|
32 |
use C4::Dates qw/format_date/; |
32 |
use C4::Calendar; |
33 |
use C4::Calendar; |
33 |
use C4::Accounts; |
34 |
use C4::Accounts; |
|
|
35 |
use C4::Overdues ; |
34 |
use C4::ItemCirculationAlertPreference; |
36 |
use C4::ItemCirculationAlertPreference; |
35 |
use C4::Dates qw(format_date); |
37 |
use C4::Dates qw(format_date); |
36 |
use C4::Message; |
38 |
use C4::Message; |
37 |
use C4::Debug; |
39 |
use C4::Debug; |
|
|
40 |
use YAML; |
38 |
use Date::Calc qw( |
41 |
use Date::Calc qw( |
39 |
Today |
42 |
Today |
40 |
Today_and_Now |
43 |
Today_and_Now |
Lines 43-48
use Date::Calc qw(
Link Here
|
43 |
Date_to_Days |
46 |
Date_to_Days |
44 |
Day_of_Week |
47 |
Day_of_Week |
45 |
Add_Delta_Days |
48 |
Add_Delta_Days |
|
|
49 |
Delta_Days |
50 |
check_date |
51 |
Add_Delta_Days |
46 |
); |
52 |
); |
47 |
use POSIX qw(strftime); |
53 |
use POSIX qw(strftime); |
48 |
use C4::Branch; # GetBranches |
54 |
use C4::Branch; # GetBranches |
Lines 74-82
BEGIN {
Link Here
|
74 |
&GetItemIssues |
80 |
&GetItemIssues |
75 |
&GetBorrowerIssues |
81 |
&GetBorrowerIssues |
76 |
&GetIssuingCharges |
82 |
&GetIssuingCharges |
77 |
&GetIssuingRule |
|
|
78 |
&GetBranchBorrowerCircRule |
79 |
&GetBranchItemRule |
80 |
&GetBiblioIssues |
83 |
&GetBiblioIssues |
81 |
&GetOpenIssue |
84 |
&GetOpenIssue |
82 |
&AnonymiseIssueHistory |
85 |
&AnonymiseIssueHistory |
Lines 99-104
BEGIN {
Link Here
|
99 |
&CreateBranchTransferLimit |
102 |
&CreateBranchTransferLimit |
100 |
&DeleteBranchTransferLimits |
103 |
&DeleteBranchTransferLimits |
101 |
); |
104 |
); |
|
|
105 |
|
102 |
} |
106 |
} |
103 |
|
107 |
|
104 |
=head1 NAME |
108 |
=head1 NAME |
Lines 347-462
sub TooMany {
Link Here
|
347 |
my $item = shift; |
351 |
my $item = shift; |
348 |
my $cat_borrower = $borrower->{'categorycode'}; |
352 |
my $cat_borrower = $borrower->{'categorycode'}; |
349 |
my $dbh = C4::Context->dbh; |
353 |
my $dbh = C4::Context->dbh; |
350 |
my $branch; |
354 |
my $exactbranch; |
351 |
# Get which branchcode we need |
355 |
# Get which branchcode we need |
352 |
$branch = _GetCircControlBranch($item,$borrower); |
356 |
$exactbranch = _GetCircControlBranch($item,$borrower); |
353 |
my $type = (C4::Context->preference('item-level_itypes')) |
357 |
my $itype = (C4::Context->preference('item-level_itypes')) |
354 |
? $item->{'itype'} # item-level |
358 |
? $item->{'itype'} # item-level |
355 |
: $item->{'itemtype'}; # biblio-level |
359 |
: $item->{'itemtype'}; # biblio-level |
356 |
|
360 |
|
357 |
# given branch, patron category, and item type, determine |
361 |
# given branch, patron category, and item type, determine |
358 |
# applicable issuing rule |
362 |
# applicable issuing rule |
359 |
my $issuing_rule = GetIssuingRule($cat_borrower, $type, $branch); |
363 |
my $branchfield = C4::Context->Preference('HomeOrHoldingBranch') || "homebranch"; |
360 |
|
364 |
#By default, Patron is supposed not to be able to borrow |
361 |
# if a rule is found and has a loan limit set, count |
365 |
my $toomany = 1; |
362 |
# how many loans the patron already has that meet that |
366 |
|
363 |
# rule |
367 |
foreach my $branch ( $exactbranch, '*' ) { |
364 |
if (defined($issuing_rule) and defined($issuing_rule->{'maxissueqty'})) { |
368 |
foreach my $type ( $itype, '*' ) { |
365 |
my @bind_params; |
369 |
my $issuing_rule = GetIssuingRule( $cat_borrower, $type, $branch ); |
366 |
my $count_query = "SELECT COUNT(*) FROM issues |
370 |
|
367 |
JOIN items USING (itemnumber) "; |
371 |
# if a rule is found and has a loan limit set, count |
368 |
|
372 |
# how many loans the patron already has that meet that |
369 |
my $rule_itemtype = $issuing_rule->{itemtype}; |
373 |
# rule |
370 |
if ($rule_itemtype eq "*") { |
374 |
if ( defined($issuing_rule) and defined( $issuing_rule->{'maxissueqty'} ) ) { |
371 |
# matching rule has the default item type, so count only |
375 |
my @bind_params; |
372 |
# those existing loans that don't fall under a more |
376 |
my $count_query = "SELECT COUNT(*) FROM issues |
373 |
# specific rule |
377 |
JOIN items USING (itemnumber) "; |
374 |
if (C4::Context->preference('item-level_itypes')) { |
378 |
|
375 |
$count_query .= " WHERE items.itype NOT IN ( |
379 |
my $rule_itemtype = $issuing_rule->{itemtype}; |
376 |
SELECT itemtype FROM issuingrules |
380 |
if ($rule_itemtype eq "*") { |
377 |
WHERE branchcode = ? |
381 |
# matching rule has the default item type, so count all the items issued for that branch no |
378 |
AND (categorycode = ? OR categorycode = ?) |
382 |
# those existing loans that don't fall under a more |
379 |
AND itemtype <> '*' |
383 |
# specific rule Not QUITE |
380 |
) "; |
384 |
if (C4::Context->preference('item-level_itypes')) { |
381 |
} else { |
385 |
$count_query .= " WHERE items.itype NOT IN ( |
382 |
$count_query .= " JOIN biblioitems USING (biblionumber) |
386 |
SELECT itemtype FROM issuingrules |
383 |
WHERE biblioitems.itemtype NOT IN ( |
387 |
WHERE branchcode = ? |
384 |
SELECT itemtype FROM issuingrules |
388 |
AND (categorycode = ? OR categorycode = ?) |
385 |
WHERE branchcode = ? |
389 |
AND itemtype <> '*' |
386 |
AND (categorycode = ? OR categorycode = ?) |
390 |
)"; |
387 |
AND itemtype <> '*' |
391 |
} else { |
388 |
) "; |
392 |
$count_query .= " JOIN biblioitems USING (biblionumber) |
389 |
} |
393 |
WHERE biblioitems.itemtype NOT IN ( |
390 |
push @bind_params, $issuing_rule->{branchcode}; |
394 |
SELECT itemtype FROM issuingrules |
391 |
push @bind_params, $issuing_rule->{categorycode}; |
395 |
WHERE branchcode = ? |
392 |
push @bind_params, $cat_borrower; |
396 |
AND (categorycode = ? OR categorycode = ?) |
393 |
} else { |
397 |
AND itemtype <> '*' |
394 |
# rule has specific item type, so count loans of that |
398 |
)"; |
395 |
# specific item type |
399 |
} |
396 |
if (C4::Context->preference('item-level_itypes')) { |
400 |
push @bind_params, $issuing_rule->{branchcode}; |
397 |
$count_query .= " WHERE items.itype = ? "; |
401 |
push @bind_params, $issuing_rule->{categorycode}; |
398 |
} else { |
402 |
push @bind_params, $cat_borrower; |
399 |
$count_query .= " JOIN biblioitems USING (biblionumber) |
403 |
} else { |
400 |
WHERE biblioitems.itemtype= ? "; |
404 |
# rule has specific item type, so count loans of that |
401 |
} |
405 |
# specific item type |
402 |
push @bind_params, $type; |
406 |
if (C4::Context->preference('item-level_itypes')) { |
403 |
} |
407 |
$count_query .= " WHERE items.itype = ? "; |
404 |
|
408 |
} else { |
405 |
$count_query .= " AND borrowernumber = ? "; |
409 |
$count_query .= " JOIN biblioitems USING (biblionumber) |
406 |
push @bind_params, $borrower->{'borrowernumber'}; |
410 |
WHERE biblioitems.itemtype= ? "; |
407 |
my $rule_branch = $issuing_rule->{branchcode}; |
411 |
} |
408 |
if ($rule_branch ne "*") { |
412 |
push @bind_params, $type; |
409 |
if (C4::Context->preference('CircControl') eq 'PickupLibrary') { |
413 |
} |
410 |
$count_query .= " AND issues.branchcode = ? "; |
|
|
411 |
push @bind_params, $branch; |
412 |
} elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') { |
413 |
; # if branch is the patron's home branch, then count all loans by patron |
414 |
} else { |
415 |
$count_query .= " AND items.homebranch = ? "; |
416 |
push @bind_params, $branch; |
417 |
} |
418 |
} |
419 |
|
420 |
my $count_sth = $dbh->prepare($count_query); |
421 |
$count_sth->execute(@bind_params); |
422 |
my ($current_loan_count) = $count_sth->fetchrow_array; |
423 |
|
414 |
|
424 |
my $max_loans_allowed = $issuing_rule->{'maxissueqty'}; |
415 |
$count_query .= " AND borrowernumber = ? "; |
425 |
if ($current_loan_count >= $max_loans_allowed) { |
416 |
push @bind_params, $borrower->{'borrowernumber'}; |
426 |
return ($current_loan_count, $max_loans_allowed); |
417 |
my $rule_branch = $issuing_rule->{branchcode}; |
427 |
} |
418 |
if ( $rule_branch ne "*" ) { |
428 |
} |
419 |
if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) { |
|
|
420 |
$count_query .= " AND issues.branchcode = ? "; |
421 |
push @bind_params, $branch; |
422 |
} elsif ( C4::Context->preference('CircControl') eq 'PatronLibrary' ) { |
423 |
; # if branch is the patron's home branch, then count all loans by patron |
424 |
} else { |
425 |
$count_query .= " AND items.$branchfield = ? "; |
426 |
push @bind_params, $branch; |
427 |
} |
428 |
} |
429 |
|
429 |
|
430 |
# Now count total loans against the limit for the branch |
430 |
my $count_sth = $dbh->prepare($count_query); |
431 |
my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower); |
431 |
$count_sth->execute(@bind_params); |
432 |
if (defined($branch_borrower_circ_rule->{maxissueqty})) { |
432 |
my ($current_loan_count) = $count_sth->fetchrow_array; |
433 |
my @bind_params = (); |
|
|
434 |
my $branch_count_query = "SELECT COUNT(*) FROM issues |
435 |
JOIN items USING (itemnumber) |
436 |
WHERE borrowernumber = ? "; |
437 |
push @bind_params, $borrower->{borrowernumber}; |
438 |
|
439 |
if (C4::Context->preference('CircControl') eq 'PickupLibrary') { |
440 |
$branch_count_query .= " AND issues.branchcode = ? "; |
441 |
push @bind_params, $branch; |
442 |
} elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') { |
443 |
; # if branch is the patron's home branch, then count all loans by patron |
444 |
} else { |
445 |
$branch_count_query .= " AND items.homebranch = ? "; |
446 |
push @bind_params, $branch; |
447 |
} |
448 |
my $branch_count_sth = $dbh->prepare($branch_count_query); |
449 |
$branch_count_sth->execute(@bind_params); |
450 |
my ($current_loan_count) = $branch_count_sth->fetchrow_array; |
451 |
|
433 |
|
452 |
my $max_loans_allowed = $branch_borrower_circ_rule->{maxissueqty}; |
434 |
my $max_loans_allowed = $issuing_rule->{'maxissueqty'}; |
453 |
if ($current_loan_count >= $max_loans_allowed) { |
435 |
if ( $current_loan_count >= $max_loans_allowed ) { |
454 |
return ($current_loan_count, $max_loans_allowed); |
436 |
return 1,$current_loan_count,$max_loans_allowed; |
|
|
437 |
} |
438 |
else { |
439 |
$toomany=0; |
440 |
} |
441 |
} |
455 |
} |
442 |
} |
456 |
} |
443 |
} |
457 |
|
444 |
return $toomany; |
458 |
# OK, the patron can issue !!! |
|
|
459 |
return; |
460 |
} |
445 |
} |
461 |
|
446 |
|
462 |
=head2 itemissues |
447 |
=head2 itemissues |
Lines 684-690
sub CanBookBeIssued {
Link Here
|
684 |
|
669 |
|
685 |
my $branch = _GetCircControlBranch($item,$borrower); |
670 |
my $branch = _GetCircControlBranch($item,$borrower); |
686 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblioitem->{'itemtype'}; |
671 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblioitem->{'itemtype'}; |
687 |
$duedate = CalcDateDue( C4::Dates->new( $issuedate, 'iso' ), $itype, $branch, $borrower ); |
672 |
my $loanlength = GetLoanLength( $borrower->{'categorycode'}, $itype, $branch ); |
|
|
673 |
unless ($loanlength or C4::Context->preference("AllowNotForLoanOverride")) { |
674 |
$issuingimpossible{LOAN_LENGTH_UNDEFINED} = "$borrower->{'categorycode'}, $itype, $branch"; |
675 |
} |
676 |
$duedate = CalcDateDue( C4::Dates->new( $issuedate, 'iso' ), $itype, $branch, $borrower ) ; |
688 |
|
677 |
|
689 |
# Offline circ calls AddIssue directly, doesn't run through here |
678 |
# Offline circ calls AddIssue directly, doesn't run through here |
690 |
# So issuingimpossible should be ok. |
679 |
# So issuingimpossible should be ok. |
Lines 712-726
sub CanBookBeIssued {
Link Here
|
712 |
$issuingimpossible{CARD_LOST} = 1; |
701 |
$issuingimpossible{CARD_LOST} = 1; |
713 |
} |
702 |
} |
714 |
if ( $borrower->{flags}->{'DBARRED'} ) { |
703 |
if ( $borrower->{flags}->{'DBARRED'} ) { |
715 |
$issuingimpossible{DEBARRED} = 1; |
704 |
if (my $dateenddebarred=$borrower->{flags}->{'DBARRED'}->{'dateend'}){ |
|
|
705 |
$issuingimpossible{DEBARRED} = format_date($dateenddebarred); |
706 |
} |
707 |
else { |
708 |
$issuingimpossible{DEBARRED} = 1; |
709 |
} |
716 |
} |
710 |
} |
717 |
if ( $borrower->{'dateexpiry'} eq '0000-00-00') { |
711 |
if ( $borrower->{'dateexpiry'} eq '0000-00-00') { |
718 |
$issuingimpossible{EXPIRED} = 1; |
712 |
$issuingimpossible{EXPIRED} = 1; |
719 |
} else { |
713 |
} else { |
720 |
my @expirydate= split /-/,$borrower->{'dateexpiry'}; |
714 |
my @expirydate = split (/-/, $borrower->{'dateexpiry'}); |
721 |
if($expirydate[0]==0 || $expirydate[1]==0|| $expirydate[2]==0 || |
715 |
if ( $expirydate[0] == 0 |
722 |
Date_to_Days(Today) > Date_to_Days( @expirydate )) { |
716 |
|| $expirydate[1] == 0 |
723 |
$issuingimpossible{EXPIRED} = 1; |
717 |
|| $expirydate[2] == 0 |
|
|
718 |
|| Date_to_Days(Today) > Date_to_Days(@expirydate) ) { |
719 |
$issuingimpossible{EXPIRED} = 1; |
724 |
} |
720 |
} |
725 |
} |
721 |
} |
726 |
# |
722 |
# |
Lines 769-786
sub CanBookBeIssued {
Link Here
|
769 |
# |
765 |
# |
770 |
# JB34 CHECKS IF BORROWERS DONT HAVE ISSUE TOO MANY BOOKS |
766 |
# JB34 CHECKS IF BORROWERS DONT HAVE ISSUE TOO MANY BOOKS |
771 |
# |
767 |
# |
772 |
my ($current_loan_count, $max_loans_allowed) = TooMany( $borrower, $item->{biblionumber}, $item ); |
768 |
my @toomany = TooMany( $borrower, $item->{biblionumber}, $item ); |
773 |
# if TooMany max_loans_allowed returns 0 the user doesn't have permission to check out this book |
769 |
|
774 |
if ($max_loans_allowed eq 0) { |
770 |
if ( $toomany[0] == 1 && scalar(@toomany)<3) { |
775 |
$needsconfirmation{PATRON_CANT} = 1; |
771 |
$needsconfirmation{PATRON_CANT} = 1; |
776 |
} else { |
772 |
} elsif (scalar(@toomany)==3) { |
777 |
if($max_loans_allowed){ |
773 |
$needsconfirmation{TOO_MANY} = "$toomany[1] / $toomany[2]"; |
778 |
$needsconfirmation{TOO_MANY} = 1; |
|
|
779 |
$needsconfirmation{current_loan_count} = $current_loan_count; |
780 |
$needsconfirmation{max_loans_allowed} = $max_loans_allowed; |
781 |
} |
782 |
} |
774 |
} |
783 |
|
775 |
|
|
|
776 |
|
784 |
# |
777 |
# |
785 |
# ITEM CHECKING |
778 |
# ITEM CHECKING |
786 |
# |
779 |
# |
Lines 817-824
sub CanBookBeIssued {
Link Here
|
817 |
} |
810 |
} |
818 |
} |
811 |
} |
819 |
} |
812 |
} |
820 |
if ( $item->{'wthdrawn'} && $item->{'wthdrawn'} == 1 ) |
813 |
if ( $item->{'damaged'} && $item->{'damaged'} > 0 ){ |
821 |
{ |
814 |
$needsconfirmation{DAMAGED} = $item->{'damaged'}; |
|
|
815 |
my $fw = GetFrameworkCode($item->{biblionumber}); |
816 |
my $category = GetAuthValCode('items.damaged',$fw); |
817 |
my $authorizedvalues = GetAuthorisedValues($category, $item->{damaged}); |
818 |
|
819 |
foreach my $authvalue (@$authorizedvalues){ |
820 |
$needsconfirmation{DAMAGED} = $authvalue->{lib} if $authvalue->{'authorised_value'} eq $item->{'damaged'}; |
821 |
} |
822 |
|
823 |
} |
824 |
if ( $item->{'wthdrawn'} && $item->{'wthdrawn'} == 1 ) { |
822 |
$issuingimpossible{WTHDRAWN} = 1; |
825 |
$issuingimpossible{WTHDRAWN} = 1; |
823 |
} |
826 |
} |
824 |
if ( $item->{'restricted'} |
827 |
if ( $item->{'restricted'} |
Lines 826-840
sub CanBookBeIssued {
Link Here
|
826 |
{ |
829 |
{ |
827 |
$issuingimpossible{RESTRICTED} = 1; |
830 |
$issuingimpossible{RESTRICTED} = 1; |
828 |
} |
831 |
} |
|
|
832 |
my $userenv = C4::Context->userenv; |
833 |
my $branch=$userenv->{branch}; |
834 |
my $hbr= $item->{ C4::Context->preference("HomeOrHoldingBranch") }; |
829 |
if ( C4::Context->preference("IndependantBranches") ) { |
835 |
if ( C4::Context->preference("IndependantBranches") ) { |
830 |
my $userenv = C4::Context->userenv; |
|
|
831 |
if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { |
836 |
if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { |
832 |
$issuingimpossible{ITEMNOTSAMEBRANCH} = 1 |
837 |
$issuingimpossible{ITEMNOTSAMEBRANCH} = 1 |
833 |
if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} ); |
838 |
if ( $hbr ne $branch ); |
834 |
$needsconfirmation{BORRNOTSAMEBRANCH} = GetBranchName( $borrower->{'branchcode'} ) |
839 |
$needsconfirmation{BORRNOTSAMEBRANCH} = GetBranchName( $borrower->{'branchcode'} ) |
835 |
if ( $borrower->{'branchcode'} ne $userenv->{branch} ); |
840 |
if ( $borrower->{'branchcode'} ne $userenv->{branch} ); |
836 |
} |
841 |
} |
837 |
} |
842 |
} |
|
|
843 |
my $branchtransferfield=C4::Context->preference("BranchTransferLimitsType") eq "ccode" ? "ccode" : "itype"; |
844 |
if ( C4::Context->preference("UseBranchTransferLimits") |
845 |
and !IsBranchTransferAllowed( $branch, $hbr, $item->{ $branchtransferfield } ) ) { |
846 |
$needsconfirmation{BRANCH_TRANSFER_NOT_ALLOWED} = $hbr; |
847 |
} |
848 |
|
838 |
|
849 |
|
839 |
# |
850 |
# |
840 |
# CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER |
851 |
# CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER |
Lines 875-904
sub CanBookBeIssued {
Link Here
|
875 |
my ( $resborrower ) = C4::Members::GetMemberDetails( $resbor, 0 ); |
886 |
my ( $resborrower ) = C4::Members::GetMemberDetails( $resbor, 0 ); |
876 |
my $branches = GetBranches(); |
887 |
my $branches = GetBranches(); |
877 |
my $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'}; |
888 |
my $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'}; |
878 |
if ( $resbor ne $borrower->{'borrowernumber'} && $restype eq "Waiting" ) |
889 |
if( $resbor ne $borrower->{'borrowernumber'}){ |
879 |
{ |
890 |
if ( $restype eq "Waiting" ) { |
880 |
# The item is on reserve and waiting, but has been |
891 |
# The item is on reserve and waiting, but has been |
881 |
# reserved by some other patron. |
892 |
# reserved by some other patron. |
882 |
$needsconfirmation{RESERVE_WAITING} = 1; |
893 |
$needsconfirmation{RESERVE_WAITING} = |
883 |
$needsconfirmation{'resfirstname'} = $resborrower->{'firstname'}; |
894 |
"$resborrower->{'firstname'} $resborrower->{'surname'} ($resborrower->{'cardnumber'}, $branchname)"; |
884 |
$needsconfirmation{'ressurname'} = $resborrower->{'surname'}; |
895 |
} |
885 |
$needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'}; |
896 |
elsif ( $restype eq "Reserved" ) { |
886 |
$needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'}; |
897 |
# The item is on reserve for someone else. |
887 |
$needsconfirmation{'resbranchname'} = $branchname; |
898 |
$needsconfirmation{RESERVED} = |
888 |
$needsconfirmation{'reswaitingdate'} = format_date($res->{'waitingdate'}); |
899 |
"$res->{'reservedate'} : $resborrower->{'firstname'} $resborrower->{'surname'} ($resborrower->{'cardnumber'})"; |
889 |
} |
900 |
} |
890 |
elsif ( $restype eq "Reserved" ) { |
|
|
891 |
# The item is on reserve for someone else. |
892 |
$needsconfirmation{RESERVED} = 1; |
893 |
$needsconfirmation{'resfirstname'} = $resborrower->{'firstname'}; |
894 |
$needsconfirmation{'ressurname'} = $resborrower->{'surname'}; |
895 |
$needsconfirmation{'rescardnumber'} = $resborrower->{'cardnumber'}; |
896 |
$needsconfirmation{'resborrowernumber'} = $resborrower->{'borrowernumber'}; |
897 |
$needsconfirmation{'resbranchname'} = $branchname; |
898 |
$needsconfirmation{'resreservedate'} = format_date($res->{'reservedate'}); |
899 |
} |
901 |
} |
900 |
} |
902 |
} |
901 |
return ( \%issuingimpossible, \%needsconfirmation ); |
903 |
return ( \%issuingimpossible, \%needsconfirmation ); |
902 |
} |
904 |
} |
903 |
|
905 |
|
904 |
=head2 AddIssue |
906 |
=head2 AddIssue |
Lines 979-985
sub AddIssue {
Link Here
|
979 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
981 |
# who wants to borrow it now. mark it returned before issuing to the new borrower |
980 |
AddReturn( |
982 |
AddReturn( |
981 |
$item->{'barcode'}, |
983 |
$item->{'barcode'}, |
982 |
C4::Context->userenv->{'branch'} |
984 |
C4::Context->userenv->{'branch'}, |
|
|
985 |
undef, |
986 |
undef, |
987 |
1 |
983 |
); |
988 |
); |
984 |
} |
989 |
} |
985 |
|
990 |
|
Lines 1012-1018
sub AddIssue {
Link Here
|
1012 |
ModReserve(1, |
1017 |
ModReserve(1, |
1013 |
$res->{'biblionumber'}, |
1018 |
$res->{'biblionumber'}, |
1014 |
$res->{'borrowernumber'}, |
1019 |
$res->{'borrowernumber'}, |
1015 |
$res->{'branchcode'} |
1020 |
$res->{'branchcode'}, |
|
|
1021 |
undef, |
1022 |
$res->{'reservenumber'} |
1016 |
); |
1023 |
); |
1017 |
} |
1024 |
} |
1018 |
} |
1025 |
} |
Lines 1101-1110
sub AddIssue {
Link Here
|
1101 |
branch => $branch, |
1108 |
branch => $branch, |
1102 |
}); |
1109 |
}); |
1103 |
} |
1110 |
} |
|
|
1111 |
|
1112 |
logaction( "CIRCULATION", "ISSUE", $borrower->{'borrowernumber'}, $item->{'itemnumber'} ) |
1113 |
if C4::Context->preference("IssueLog"); |
1104 |
} |
1114 |
} |
1105 |
|
1115 |
|
1106 |
logaction("CIRCULATION", "ISSUE", $borrower->{'borrowernumber'}, $biblio->{'biblionumber'}) |
|
|
1107 |
if C4::Context->preference("IssueLog"); |
1108 |
} |
1116 |
} |
1109 |
return ($datedue); # not necessarily the same as when it came in! |
1117 |
return ($datedue); # not necessarily the same as when it came in! |
1110 |
} |
1118 |
} |
Lines 1119-1432
Get loan length for an itemtype, a borrower type and a branch
Link Here
|
1119 |
|
1127 |
|
1120 |
sub GetLoanLength { |
1128 |
sub GetLoanLength { |
1121 |
my ( $borrowertype, $itemtype, $branchcode ) = @_; |
1129 |
my ( $borrowertype, $itemtype, $branchcode ) = @_; |
1122 |
my $dbh = C4::Context->dbh; |
1130 |
my $loanlength=GetIssuingRule($borrowertype,$itemtype,$branchcode); |
1123 |
my $sth = |
1131 |
return $loanlength->{issuelength}; |
1124 |
$dbh->prepare( |
|
|
1125 |
"select issuelength from issuingrules where categorycode=? and itemtype=? and branchcode=? and issuelength is not null" |
1126 |
); |
1127 |
# warn "in get loan lenght $borrowertype $itemtype $branchcode "; |
1128 |
# try to find issuelength & return the 1st available. |
1129 |
# check with borrowertype, itemtype and branchcode, then without one of those parameters |
1130 |
$sth->execute( $borrowertype, $itemtype, $branchcode ); |
1131 |
my $loanlength = $sth->fetchrow_hashref; |
1132 |
return $loanlength->{issuelength} |
1133 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1134 |
|
1135 |
$sth->execute( $borrowertype, "*", $branchcode ); |
1136 |
$loanlength = $sth->fetchrow_hashref; |
1137 |
return $loanlength->{issuelength} |
1138 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1139 |
|
1140 |
$sth->execute( "*", $itemtype, $branchcode ); |
1141 |
$loanlength = $sth->fetchrow_hashref; |
1142 |
return $loanlength->{issuelength} |
1143 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1144 |
|
1145 |
$sth->execute( "*", "*", $branchcode ); |
1146 |
$loanlength = $sth->fetchrow_hashref; |
1147 |
return $loanlength->{issuelength} |
1148 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1149 |
|
1150 |
$sth->execute( $borrowertype, $itemtype, "*" ); |
1151 |
$loanlength = $sth->fetchrow_hashref; |
1152 |
return $loanlength->{issuelength} |
1153 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1154 |
|
1155 |
$sth->execute( $borrowertype, "*", "*" ); |
1156 |
$loanlength = $sth->fetchrow_hashref; |
1157 |
return $loanlength->{issuelength} |
1158 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1159 |
|
1160 |
$sth->execute( "*", $itemtype, "*" ); |
1161 |
$loanlength = $sth->fetchrow_hashref; |
1162 |
return $loanlength->{issuelength} |
1163 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1164 |
|
1165 |
$sth->execute( "*", "*", "*" ); |
1166 |
$loanlength = $sth->fetchrow_hashref; |
1167 |
return $loanlength->{issuelength} |
1168 |
if defined($loanlength) && $loanlength->{issuelength} ne 'NULL'; |
1169 |
|
1170 |
# if no rule is set => 21 days (hardcoded) |
1171 |
return 21; |
1172 |
} |
1173 |
|
1174 |
|
1175 |
=head2 GetHardDueDate |
1176 |
|
1177 |
my ($hardduedate,$hardduedatecompare) = &GetHardDueDate($borrowertype,$itemtype,branchcode) |
1178 |
|
1179 |
Get the Hard Due Date and it's comparison for an itemtype, a borrower type and a branch |
1180 |
|
1181 |
=cut |
1182 |
|
1183 |
sub GetHardDueDate { |
1184 |
my ( $borrowertype, $itemtype, $branchcode ) = @_; |
1185 |
my $dbh = C4::Context->dbh; |
1186 |
my $sth = |
1187 |
$dbh->prepare( |
1188 |
"select hardduedate, hardduedatecompare from issuingrules where categorycode=? and itemtype=? and branchcode=?" |
1189 |
); |
1190 |
$sth->execute( $borrowertype, $itemtype, $branchcode ); |
1191 |
my $results = $sth->fetchrow_hashref; |
1192 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1193 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1194 |
|
1195 |
$sth->execute( $borrowertype, "*", $branchcode ); |
1196 |
$results = $sth->fetchrow_hashref; |
1197 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1198 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1199 |
|
1200 |
$sth->execute( "*", $itemtype, $branchcode ); |
1201 |
$results = $sth->fetchrow_hashref; |
1202 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1203 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1204 |
|
1205 |
$sth->execute( "*", "*", $branchcode ); |
1206 |
$results = $sth->fetchrow_hashref; |
1207 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1208 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1209 |
|
1210 |
$sth->execute( $borrowertype, $itemtype, "*" ); |
1211 |
$results = $sth->fetchrow_hashref; |
1212 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1213 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1214 |
|
1215 |
$sth->execute( $borrowertype, "*", "*" ); |
1216 |
$results = $sth->fetchrow_hashref; |
1217 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1218 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1219 |
|
1220 |
$sth->execute( "*", $itemtype, "*" ); |
1221 |
$results = $sth->fetchrow_hashref; |
1222 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1223 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1224 |
|
1225 |
$sth->execute( "*", "*", "*" ); |
1226 |
$results = $sth->fetchrow_hashref; |
1227 |
return (C4::Dates->new($results->{hardduedate}, 'iso'),$results->{hardduedatecompare}) |
1228 |
if defined($results) && $results->{hardduedate} ne 'NULL'; |
1229 |
|
1230 |
# if no rule is set => return undefined |
1231 |
return (undef, undef); |
1232 |
} |
1233 |
|
1234 |
=head2 GetIssuingRule |
1235 |
|
1236 |
my $irule = &GetIssuingRule($borrowertype,$itemtype,branchcode) |
1237 |
|
1238 |
FIXME - This is a copy-paste of GetLoanLength |
1239 |
as a stop-gap. Do not wish to change API for GetLoanLength |
1240 |
this close to release, however, Overdues::GetIssuingRules is broken. |
1241 |
|
1242 |
Get the issuing rule for an itemtype, a borrower type and a branch |
1243 |
Returns a hashref from the issuingrules table. |
1244 |
|
1245 |
=cut |
1246 |
|
1247 |
sub GetIssuingRule { |
1248 |
my ( $borrowertype, $itemtype, $branchcode ) = @_; |
1249 |
my $dbh = C4::Context->dbh; |
1250 |
my $sth = $dbh->prepare( "select * from issuingrules where categorycode=? and itemtype=? and branchcode=? and issuelength is not null" ); |
1251 |
my $irule; |
1252 |
|
1253 |
$sth->execute( $borrowertype, $itemtype, $branchcode ); |
1254 |
$irule = $sth->fetchrow_hashref; |
1255 |
return $irule if defined($irule) ; |
1256 |
|
1257 |
$sth->execute( $borrowertype, "*", $branchcode ); |
1258 |
$irule = $sth->fetchrow_hashref; |
1259 |
return $irule if defined($irule) ; |
1260 |
|
1261 |
$sth->execute( "*", $itemtype, $branchcode ); |
1262 |
$irule = $sth->fetchrow_hashref; |
1263 |
return $irule if defined($irule) ; |
1264 |
|
1265 |
$sth->execute( "*", "*", $branchcode ); |
1266 |
$irule = $sth->fetchrow_hashref; |
1267 |
return $irule if defined($irule) ; |
1268 |
|
1269 |
$sth->execute( $borrowertype, $itemtype, "*" ); |
1270 |
$irule = $sth->fetchrow_hashref; |
1271 |
return $irule if defined($irule) ; |
1272 |
|
1273 |
$sth->execute( $borrowertype, "*", "*" ); |
1274 |
$irule = $sth->fetchrow_hashref; |
1275 |
return $irule if defined($irule) ; |
1276 |
|
1277 |
$sth->execute( "*", $itemtype, "*" ); |
1278 |
$irule = $sth->fetchrow_hashref; |
1279 |
return $irule if defined($irule) ; |
1280 |
|
1281 |
$sth->execute( "*", "*", "*" ); |
1282 |
$irule = $sth->fetchrow_hashref; |
1283 |
return $irule if defined($irule) ; |
1284 |
|
1285 |
# if no rule matches, |
1286 |
return undef; |
1287 |
} |
1288 |
|
1289 |
=head2 GetBranchBorrowerCircRule |
1290 |
|
1291 |
my $branch_cat_rule = GetBranchBorrowerCircRule($branchcode, $categorycode); |
1292 |
|
1293 |
Retrieves circulation rule attributes that apply to the given |
1294 |
branch and patron category, regardless of item type. |
1295 |
The return value is a hashref containing the following key: |
1296 |
|
1297 |
maxissueqty - maximum number of loans that a |
1298 |
patron of the given category can have at the given |
1299 |
branch. If the value is undef, no limit. |
1300 |
|
1301 |
This will first check for a specific branch and |
1302 |
category match from branch_borrower_circ_rules. |
1303 |
|
1304 |
If no rule is found, it will then check default_branch_circ_rules |
1305 |
(same branch, default category). If no rule is found, |
1306 |
it will then check default_borrower_circ_rules (default |
1307 |
branch, same category), then failing that, default_circ_rules |
1308 |
(default branch, default category). |
1309 |
|
1310 |
If no rule has been found in the database, it will default to |
1311 |
the buillt in rule: |
1312 |
|
1313 |
maxissueqty - undef |
1314 |
|
1315 |
C<$branchcode> and C<$categorycode> should contain the |
1316 |
literal branch code and patron category code, respectively - no |
1317 |
wildcards. |
1318 |
|
1319 |
=cut |
1320 |
|
1321 |
sub GetBranchBorrowerCircRule { |
1322 |
my $branchcode = shift; |
1323 |
my $categorycode = shift; |
1324 |
|
1325 |
my $branch_cat_query = "SELECT maxissueqty |
1326 |
FROM branch_borrower_circ_rules |
1327 |
WHERE branchcode = ? |
1328 |
AND categorycode = ?"; |
1329 |
my $dbh = C4::Context->dbh(); |
1330 |
my $sth = $dbh->prepare($branch_cat_query); |
1331 |
$sth->execute($branchcode, $categorycode); |
1332 |
my $result; |
1333 |
if ($result = $sth->fetchrow_hashref()) { |
1334 |
return $result; |
1335 |
} |
1336 |
|
1337 |
# try same branch, default borrower category |
1338 |
my $branch_query = "SELECT maxissueqty |
1339 |
FROM default_branch_circ_rules |
1340 |
WHERE branchcode = ?"; |
1341 |
$sth = $dbh->prepare($branch_query); |
1342 |
$sth->execute($branchcode); |
1343 |
if ($result = $sth->fetchrow_hashref()) { |
1344 |
return $result; |
1345 |
} |
1346 |
|
1347 |
# try default branch, same borrower category |
1348 |
my $category_query = "SELECT maxissueqty |
1349 |
FROM default_borrower_circ_rules |
1350 |
WHERE categorycode = ?"; |
1351 |
$sth = $dbh->prepare($category_query); |
1352 |
$sth->execute($categorycode); |
1353 |
if ($result = $sth->fetchrow_hashref()) { |
1354 |
return $result; |
1355 |
} |
1356 |
|
1357 |
# try default branch, default borrower category |
1358 |
my $default_query = "SELECT maxissueqty |
1359 |
FROM default_circ_rules"; |
1360 |
$sth = $dbh->prepare($default_query); |
1361 |
$sth->execute(); |
1362 |
if ($result = $sth->fetchrow_hashref()) { |
1363 |
return $result; |
1364 |
} |
1365 |
|
1366 |
# built-in default circulation rule |
1367 |
return { |
1368 |
maxissueqty => undef, |
1369 |
}; |
1370 |
} |
1371 |
|
1372 |
=head2 GetBranchItemRule |
1373 |
|
1374 |
my $branch_item_rule = GetBranchItemRule($branchcode, $itemtype); |
1375 |
|
1376 |
Retrieves circulation rule attributes that apply to the given |
1377 |
branch and item type, regardless of patron category. |
1378 |
|
1379 |
The return value is a hashref containing the following key: |
1380 |
|
1381 |
holdallowed => Hold policy for this branch and itemtype. Possible values: |
1382 |
0: No holds allowed. |
1383 |
1: Holds allowed only by patrons that have the same homebranch as the item. |
1384 |
2: Holds allowed from any patron. |
1385 |
|
1386 |
This searches branchitemrules in the following order: |
1387 |
|
1388 |
* Same branchcode and itemtype |
1389 |
* Same branchcode, itemtype '*' |
1390 |
* branchcode '*', same itemtype |
1391 |
* branchcode and itemtype '*' |
1392 |
|
1393 |
Neither C<$branchcode> nor C<$categorycode> should be '*'. |
1394 |
|
1395 |
=cut |
1396 |
|
1397 |
sub GetBranchItemRule { |
1398 |
my ( $branchcode, $itemtype ) = @_; |
1399 |
my $dbh = C4::Context->dbh(); |
1400 |
my $result = {}; |
1401 |
|
1402 |
my @attempts = ( |
1403 |
['SELECT holdallowed |
1404 |
FROM branch_item_rules |
1405 |
WHERE branchcode = ? |
1406 |
AND itemtype = ?', $branchcode, $itemtype], |
1407 |
['SELECT holdallowed |
1408 |
FROM default_branch_circ_rules |
1409 |
WHERE branchcode = ?', $branchcode], |
1410 |
['SELECT holdallowed |
1411 |
FROM default_branch_item_rules |
1412 |
WHERE itemtype = ?', $itemtype], |
1413 |
['SELECT holdallowed |
1414 |
FROM default_circ_rules'], |
1415 |
); |
1416 |
|
1417 |
foreach my $attempt (@attempts) { |
1418 |
my ($query, @bind_params) = @{$attempt}; |
1419 |
|
1420 |
# Since branch/category and branch/itemtype use the same per-branch |
1421 |
# defaults tables, we have to check that the key we want is set, not |
1422 |
# just that a row was returned |
1423 |
return $result if ( defined( $result->{'holdallowed'} = $dbh->selectrow_array( $query, {}, @bind_params ) ) ); |
1424 |
} |
1425 |
|
1426 |
# built-in default circulation rule |
1427 |
return { |
1428 |
holdallowed => 2, |
1429 |
}; |
1430 |
} |
1132 |
} |
1431 |
|
1133 |
|
1432 |
=head2 AddReturn |
1134 |
=head2 AddReturn |
Lines 1504-1511
patron who last borrowed the book.
Link Here
|
1504 |
=cut |
1206 |
=cut |
1505 |
|
1207 |
|
1506 |
sub AddReturn { |
1208 |
sub AddReturn { |
1507 |
my ( $barcode, $branch, $exemptfine, $dropbox ) = @_; |
1209 |
my ( $barcode, $branch, $exemptfine, $dropbox, $force) = @_; |
1508 |
if ($branch and not GetBranchDetail($branch)) { |
1210 |
if ( $branch and not GetBranchDetail($branch) ) { |
1509 |
warn "AddReturn error: branch '$branch' not found. Reverting to " . C4::Context->userenv->{'branch'}; |
1211 |
warn "AddReturn error: branch '$branch' not found. Reverting to " . C4::Context->userenv->{'branch'}; |
1510 |
undef $branch; |
1212 |
undef $branch; |
1511 |
} |
1213 |
} |
Lines 1549-1557
sub AddReturn {
Link Here
|
1549 |
my $branches = GetBranches(); # a potentially expensive call for a non-feature. |
1251 |
my $branches = GetBranches(); # a potentially expensive call for a non-feature. |
1550 |
$branches->{$hbr}->{PE} and $messages->{'IsPermanent'} = $hbr; |
1252 |
$branches->{$hbr}->{PE} and $messages->{'IsPermanent'} = $hbr; |
1551 |
} |
1253 |
} |
1552 |
|
1254 |
my $branchtransferfield=C4::Context->preference("BranchTransferLimitsType") eq "ccode" ? "ccode" : "itype"; |
|
|
1255 |
$debug && warn "$branch, $hbr, ",C4::Context->preference("BranchTransferLimitsType")," ,",$item->{ $branchtransferfield } ; |
1256 |
$debug && warn Dump($item); |
1257 |
$debug && warn IsBranchTransferAllowed( $branch, $hbr, $item->{ C4::Context->preference("BranchTransferLimitsType") } ); |
1553 |
# if indy branches and returning to different branch, refuse the return |
1258 |
# if indy branches and returning to different branch, refuse the return |
1554 |
if ($hbr ne $branch && C4::Context->preference("IndependantBranches")){ |
1259 |
if ( !$force && ($hbr ne $branch) |
|
|
1260 |
&& (C4::Context->preference("IndependantBranches") |
1261 |
or ( C4::Context->preference("UseBranchTransferLimits") |
1262 |
and !IsBranchTransferAllowed( $branch, $hbr, $item->{$branchtransferfield } ) ) |
1263 |
) |
1264 |
){ |
1555 |
$messages->{'Wrongbranch'} = { |
1265 |
$messages->{'Wrongbranch'} = { |
1556 |
Wrongbranch => $branch, |
1266 |
Wrongbranch => $branch, |
1557 |
Rightbranch => $hbr, |
1267 |
Rightbranch => $hbr, |
Lines 1562-1568
sub AddReturn {
Link Here
|
1562 |
# FIXME - even in an indy branches situation, there should |
1272 |
# FIXME - even in an indy branches situation, there should |
1563 |
# still be an option for the library to accept the item |
1273 |
# still be an option for the library to accept the item |
1564 |
# and transfer it to its owning library. |
1274 |
# and transfer it to its owning library. |
1565 |
return ( $doreturn, $messages, $issue, $borrower ); |
|
|
1566 |
} |
1275 |
} |
1567 |
|
1276 |
|
1568 |
if ( $item->{'wthdrawn'} ) { # book has been cancelled |
1277 |
if ( $item->{'wthdrawn'} ) { # book has been cancelled |
Lines 1573-1584
sub AddReturn {
Link Here
|
1573 |
# case of a return of document (deal with issues and holdingbranch) |
1282 |
# case of a return of document (deal with issues and holdingbranch) |
1574 |
if ($doreturn) { |
1283 |
if ($doreturn) { |
1575 |
$borrower or warn "AddReturn without current borrower"; |
1284 |
$borrower or warn "AddReturn without current borrower"; |
1576 |
my $circControlBranch; |
1285 |
my $circControlBranch; |
1577 |
if ($dropbox) { |
1286 |
if ($dropbox) { |
1578 |
# define circControlBranch only if dropbox mode is set |
1287 |
$circControlBranch = _GetCircControlBranch( $item, $borrower ); |
1579 |
# don't allow dropbox mode to create an invalid entry in issues (issuedate > today) |
1288 |
# don't allow dropbox mode to create an invalid entry in issues (issuedate > returndate) FIXME: actually checks eq, not gt |
1580 |
# FIXME: check issuedate > returndate, factoring in holidays |
1289 |
undef($dropbox) if ( $item->{'issuedate'} eq C4::Dates->today('iso') ); |
1581 |
$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );; |
|
|
1582 |
} |
1290 |
} |
1583 |
|
1291 |
|
1584 |
if ($borrowernumber) { |
1292 |
if ($borrowernumber) { |
Lines 1586-1600
sub AddReturn {
Link Here
|
1586 |
$messages->{'WasReturned'} = 1; # FIXME is the "= 1" right? This could be the borrower hash. |
1294 |
$messages->{'WasReturned'} = 1; # FIXME is the "= 1" right? This could be the borrower hash. |
1587 |
} |
1295 |
} |
1588 |
|
1296 |
|
1589 |
ModItem({ onloan => undef }, $issue->{'biblionumber'}, $item->{'itemnumber'}); |
1297 |
ModItem( { renewals=>0, onloan => undef }, $issue->{'biblionumber'}, $item->{'itemnumber'} ); |
|
|
1298 |
# the holdingbranch is updated if the document is returned to another location. |
1299 |
# this is always done regardless of whether the item was on loan or not |
1300 |
if ( $item->{'holdingbranch'} ne $branch ) { |
1301 |
UpdateHoldingbranch( $branch, $item->{'itemnumber'} ); |
1302 |
$item->{'holdingbranch'} = $branch; # update item data holdingbranch too |
1303 |
} |
1590 |
} |
1304 |
} |
1591 |
|
1305 |
|
1592 |
# the holdingbranch is updated if the document is returned to another location. |
|
|
1593 |
# this is always done regardless of whether the item was on loan or not |
1594 |
if ($item->{'holdingbranch'} ne $branch) { |
1595 |
UpdateHoldingbranch($branch, $item->{'itemnumber'}); |
1596 |
$item->{'holdingbranch'} = $branch; # update item data holdingbranch too |
1597 |
} |
1598 |
ModDateLastSeen( $item->{'itemnumber'} ); |
1306 |
ModDateLastSeen( $item->{'itemnumber'} ); |
1599 |
|
1307 |
|
1600 |
# check if we have a transfer for this document |
1308 |
# check if we have a transfer for this document |
Lines 1621-1631
sub AddReturn {
Link Here
|
1621 |
_FixAccountForLostAndReturned($item->{'itemnumber'}, $borrowernumber, $barcode); # can tolerate undef $borrowernumber |
1329 |
_FixAccountForLostAndReturned($item->{'itemnumber'}, $borrowernumber, $barcode); # can tolerate undef $borrowernumber |
1622 |
$messages->{'WasLost'} = 1; |
1330 |
$messages->{'WasLost'} = 1; |
1623 |
} |
1331 |
} |
|
|
1332 |
if ($item->{'notforloan'}){ |
1333 |
$messages->{'NotForLoan'} = $item->{'notforloan'}; |
1334 |
} |
1335 |
if ($item->{'damaged'}){ |
1336 |
$messages->{'Damaged'} = $item->{'damaged'}; |
1337 |
} |
1624 |
|
1338 |
|
1625 |
# fix up the overdues in accounts... |
1339 |
if ($borrowernumber && $doreturn) { |
1626 |
if ($borrowernumber) { |
1340 |
# fix up the overdues in accounts... |
1627 |
my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox); |
1341 |
my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox); |
1628 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined |
1342 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined |
|
|
1343 |
|
1344 |
# fix fine days |
1345 |
my $debardate = _FixFineDaysOnReturn($borrower, $item, $issue->{date_due}); |
1346 |
$messages->{'Debarred'} = $debardate if($debardate); |
1347 |
|
1348 |
# get fines for the borrower |
1349 |
my $fineamount = C4::Overdues::GetFine($borrowernumber); |
1350 |
$messages->{'HaveFines'} = $fineamount if($fineamount); |
1351 |
|
1629 |
} |
1352 |
} |
1630 |
|
1353 |
|
1631 |
# find reserves..... |
1354 |
# find reserves..... |
Lines 1661-1680
sub AddReturn {
Link Here
|
1661 |
branch => $branch, |
1384 |
branch => $branch, |
1662 |
}); |
1385 |
}); |
1663 |
} |
1386 |
} |
1664 |
|
1387 |
|
1665 |
logaction("CIRCULATION", "RETURN", $borrowernumber, $item->{'biblionumber'}) |
1388 |
logaction( "CIRCULATION", "RETURN", $borrowernumber, $item->{'itemnumber'} ) |
1666 |
if C4::Context->preference("ReturnLog"); |
1389 |
if C4::Context->preference("ReturnLog"); |
1667 |
|
1390 |
|
1668 |
# FIXME: make this comment intelligible. |
1391 |
# FIXME: make this comment intelligible. |
1669 |
#adding message if holdingbranch is non equal a userenv branch to return the document to homebranch |
1392 |
#adding message if holdingbranch is non equal a userenv branch to return the document to homebranch |
1670 |
#we check, if we don't have reserv or transfert for this document, if not, return it to homebranch . |
1393 |
#we check, if we don't have reserv or transfert for this document, if not, return it to homebranch . |
1671 |
|
1394 |
|
1672 |
if (($doreturn or $messages->{'NotIssued'}) and !$resfound and ($branch ne $hbr) and not $messages->{'WrongTransfer'}){ |
1395 |
if ( ($doreturn or $messages->{'NotIssued'}) and ( $branch ne $hbr ) and not $messages->{'WrongTransfer'} and ( $validTransfert ne 1 ) ) { |
1673 |
if ( C4::Context->preference("AutomaticItemReturn" ) or |
1396 |
if (C4::Context->preference("AutomaticItemReturn") |
1674 |
(C4::Context->preference("UseBranchTransferLimits") and |
1397 |
or ( C4::Context->preference("UseBranchTransferLimits") |
1675 |
! IsBranchTransferAllowed($branch, $hbr, $item->{C4::Context->preference("BranchTransferLimitsType")} ) |
1398 |
and !IsBranchTransferAllowed( $branch, $hbr, $item->{ $branchtransferfield } ) ) |
1676 |
)) { |
1399 |
) { |
1677 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->{'itemnumber'},$branch, $hbr; |
1400 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->{'itemnumber'}, $branch, $hbr; |
1678 |
$debug and warn "item: " . Dumper($item); |
1401 |
$debug and warn "item: " . Dumper($item); |
1679 |
ModItemTransfer($item->{'itemnumber'}, $branch, $hbr); |
1402 |
ModItemTransfer($item->{'itemnumber'}, $branch, $hbr); |
1680 |
$messages->{'WasTransfered'} = 1; |
1403 |
$messages->{'WasTransfered'} = 1; |
Lines 1749-1754
sub MarkIssueReturned {
Link Here
|
1749 |
$sth_del->execute($borrowernumber, $itemnumber); |
1472 |
$sth_del->execute($borrowernumber, $itemnumber); |
1750 |
} |
1473 |
} |
1751 |
|
1474 |
|
|
|
1475 |
=head2 _FixFineDaysOnReturn |
1476 |
|
1477 |
&_FixFineDaysOnReturn($borrower, $item, $datedue); |
1478 |
|
1479 |
C<$borrower> borrower hashref |
1480 |
|
1481 |
C<$item> item hashref |
1482 |
|
1483 |
C<$datedue> date due |
1484 |
|
1485 |
Internal function, called only by AddReturn that calculate and update the user fine days, and debars him |
1486 |
|
1487 |
=cut |
1488 |
|
1489 |
sub _FixFineDaysOnReturn { |
1490 |
my ($borrower, $item, $datedue) = @_; |
1491 |
|
1492 |
if($datedue){ |
1493 |
$datedue = C4::Dates->new($datedue,"iso"); |
1494 |
}else{ |
1495 |
return; |
1496 |
} |
1497 |
|
1498 |
my $branchcode =_GetCircControlBranch($item, $borrower); |
1499 |
my $calendar = C4::Calendar->new( branchcode => $branchcode ); |
1500 |
my $today = C4::Dates->new(); |
1501 |
|
1502 |
my $deltadays = $calendar->daysBetween($datedue, C4::Dates->new()); |
1503 |
|
1504 |
my $circcontrol = C4::Context::preference('CircControl'); |
1505 |
my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode); |
1506 |
my $finedays = $issuingrule->{finedays}; |
1507 |
# exit if no finedays defined |
1508 |
return unless $finedays; |
1509 |
my $grace = $issuingrule->{firstremind}; |
1510 |
|
1511 |
if( $deltadays - $grace > 0){ |
1512 |
my @newdate = Add_Delta_Days(Today(), $deltadays * $finedays ); |
1513 |
my $isonewdate = join('-',@newdate); |
1514 |
my ($deby, $debm, $debd) = split(/-/,$borrower->{debarred}); |
1515 |
if(check_date($deby, $debm, $debd)){ |
1516 |
my @olddate = split(/-/, $borrower->{debarred}); |
1517 |
|
1518 |
if(Delta_Days(@olddate,@newdate) > 0){ |
1519 |
C4::Members::DebarMember($borrower->{borrowernumber}, $isonewdate); |
1520 |
return $isonewdate; |
1521 |
} |
1522 |
}else{ |
1523 |
C4::Members::DebarMember($borrower->{borrowernumber}, $isonewdate); |
1524 |
return $isonewdate; |
1525 |
} |
1526 |
} |
1527 |
} |
1528 |
|
1529 |
|
1752 |
=head2 _FixOverduesOnReturn |
1530 |
=head2 _FixOverduesOnReturn |
1753 |
|
1531 |
|
1754 |
&_FixOverduesOnReturn($brn,$itm, $exemptfine, $dropboxmode); |
1532 |
&_FixOverduesOnReturn($brn,$itm, $exemptfine, $dropboxmode); |
Lines 1923-1930
sub _GetCircControlBranch {
Link Here
|
1923 |
my $circcontrol = C4::Context->preference('CircControl'); |
1701 |
my $circcontrol = C4::Context->preference('CircControl'); |
1924 |
my $branch; |
1702 |
my $branch; |
1925 |
|
1703 |
|
1926 |
if ($circcontrol eq 'PickupLibrary') { |
1704 |
if ($circcontrol eq 'PickupLibrary' && C4::Context->userenv->{'branch'}) { |
1927 |
$branch= C4::Context->userenv->{'branch'} if C4::Context->userenv; |
1705 |
$branch= C4::Context->userenv->{'branch'}; |
1928 |
} elsif ($circcontrol eq 'PatronLibrary') { |
1706 |
} elsif ($circcontrol eq 'PatronLibrary') { |
1929 |
$branch=$borrower->{branchcode}; |
1707 |
$branch=$borrower->{branchcode}; |
1930 |
} else { |
1708 |
} else { |
Lines 1960-1966
sub GetItemIssue {
Link Here
|
1960 |
my ($itemnumber) = @_; |
1738 |
my ($itemnumber) = @_; |
1961 |
return unless $itemnumber; |
1739 |
return unless $itemnumber; |
1962 |
my $sth = C4::Context->dbh->prepare( |
1740 |
my $sth = C4::Context->dbh->prepare( |
1963 |
"SELECT * |
1741 |
"SELECT *, issues.renewals as 'issues.renewals' |
1964 |
FROM issues |
1742 |
FROM issues |
1965 |
LEFT JOIN items ON issues.itemnumber=items.itemnumber |
1743 |
LEFT JOIN items ON issues.itemnumber=items.itemnumber |
1966 |
WHERE issues.itemnumber=?"); |
1744 |
WHERE issues.itemnumber=?"); |
Lines 2031-2037
sub GetItemIssues {
Link Here
|
2031 |
} |
1809 |
} |
2032 |
my $results = $sth->fetchall_arrayref({}); |
1810 |
my $results = $sth->fetchall_arrayref({}); |
2033 |
foreach (@$results) { |
1811 |
foreach (@$results) { |
2034 |
$_->{'overdue'} = ($_->{'date_due'} lt $today) ? 1 : 0; |
1812 |
$_->{'overdue'} = ( $_->{'date_due'} lt $today && !defined($_->{return_date}) ) ? 1 : 0; |
2035 |
} |
1813 |
} |
2036 |
return $results; |
1814 |
return $results; |
2037 |
} |
1815 |
} |
Lines 2138-2206
already renewed the loan. $error will contain the reason the renewal can not pro
Link Here
|
2138 |
sub CanBookBeRenewed { |
1916 |
sub CanBookBeRenewed { |
2139 |
|
1917 |
|
2140 |
# check renewal status |
1918 |
# check renewal status |
2141 |
my ( $borrowernumber, $itemnumber, $override_limit ) = @_; |
1919 |
my ( $borrowernumber, $itemnumber ) = @_; |
2142 |
my $dbh = C4::Context->dbh; |
1920 |
my $dbh = C4::Context->dbh; |
2143 |
my $renews = 1; |
1921 |
my $renews = 1; |
2144 |
my $renewokay = 0; |
1922 |
my $renewokay = 1; |
2145 |
my $error; |
1923 |
my $error; |
2146 |
|
1924 |
|
2147 |
# Look in the issues table for this item, lent to this borrower, |
1925 |
# Look in the issues table for this item, lent to this borrower, |
2148 |
# and not yet returned. |
1926 |
# and not yet returned. |
2149 |
|
1927 |
|
2150 |
# Look in the issues table for this item, lent to this borrower, |
1928 |
# Look in the issues table for this item, lent to this borrower, |
2151 |
# and not yet returned. |
1929 |
# and not yet returned. |
2152 |
my %branch = ( |
1930 |
my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ) or return undef; |
2153 |
'ItemHomeLibrary' => 'items.homebranch', |
1931 |
my $item = GetItem($itemnumber) or return undef; |
2154 |
'PickupLibrary' => 'items.holdingbranch', |
1932 |
my $itemissue = GetItemIssue($itemnumber) or return undef; |
2155 |
'PatronLibrary' => 'borrowers.branchcode' |
1933 |
my $branchcode = _GetCircControlBranch($item, $borrower); |
2156 |
); |
1934 |
if ($itemissue->{'overdue'}){ |
2157 |
my $controlbranch = $branch{C4::Context->preference('CircControl')}; |
1935 |
$renewokay=0; |
2158 |
my $itype = C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'; |
1936 |
$error->{message}='overdue'; |
|
|
1937 |
} |
2159 |
|
1938 |
|
2160 |
my $sthcount = $dbh->prepare(" |
1939 |
my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode); |
2161 |
SELECT |
1940 |
|
2162 |
borrowers.categorycode, biblioitems.itemtype, issues.renewals, renewalsallowed, $controlbranch |
1941 |
if ( $issuingrule->{renewalsallowed} <= $itemissue->{'issues.renewals'} ) { |
2163 |
FROM issuingrules, |
1942 |
$renewokay=0; |
2164 |
issues |
1943 |
$error->{message} = "too_many"; |
2165 |
LEFT JOIN items USING (itemnumber) |
1944 |
} |
2166 |
LEFT JOIN borrowers USING (borrowernumber) |
|
|
2167 |
LEFT JOIN biblioitems USING (biblioitemnumber) |
2168 |
|
2169 |
WHERE |
2170 |
(issuingrules.categorycode = borrowers.categorycode OR issuingrules.categorycode = '*') |
2171 |
AND |
2172 |
(issuingrules.itemtype = $itype OR issuingrules.itemtype = '*') |
2173 |
AND |
2174 |
(issuingrules.branchcode = $controlbranch OR issuingrules.branchcode = '*') |
2175 |
AND |
2176 |
borrowernumber = ? |
2177 |
AND |
2178 |
itemnumber = ? |
2179 |
ORDER BY |
2180 |
issuingrules.categorycode desc, |
2181 |
issuingrules.itemtype desc, |
2182 |
issuingrules.branchcode desc |
2183 |
LIMIT 1; |
2184 |
"); |
2185 |
|
2186 |
$sthcount->execute( $borrowernumber, $itemnumber ); |
2187 |
if ( my $data1 = $sthcount->fetchrow_hashref ) { |
2188 |
|
2189 |
if ( ( $data1->{renewalsallowed} && $data1->{renewalsallowed} > $data1->{renewals} ) || $override_limit ) { |
2190 |
$renewokay = 1; |
2191 |
} |
2192 |
else { |
2193 |
$error="too_many"; |
2194 |
} |
2195 |
|
2196 |
my ( $resfound, $resrec ) = C4::Reserves::CheckReserves($itemnumber); |
2197 |
if ($resfound) { |
2198 |
$renewokay = 0; |
2199 |
$error="on_reserve" |
2200 |
} |
2201 |
|
1945 |
|
|
|
1946 |
my ( $resfound, $resrec ) = C4::Reserves::CheckReserves($itemnumber); |
1947 |
if ($resfound) { |
1948 |
$renewokay = 0; |
1949 |
$error->{message} = "on_reserve"; |
2202 |
} |
1950 |
} |
2203 |
return ($renewokay,$error); |
1951 |
$error->{renewals} = $itemissue->{'issues.renewals'}; |
|
|
1952 |
$error->{renewalsallowed}= $issuingrule->{renewalsallowed}; |
1953 |
|
1954 |
return ( $renewokay, $error ); |
2204 |
} |
1955 |
} |
2205 |
|
1956 |
|
2206 |
=head2 AddRenewal |
1957 |
=head2 AddRenewal |
Lines 2255-2273
sub AddRenewal {
Link Here
|
2255 |
# based on the value of the RenewalPeriodBase syspref. |
2006 |
# based on the value of the RenewalPeriodBase syspref. |
2256 |
unless ($datedue) { |
2007 |
unless ($datedue) { |
2257 |
|
2008 |
|
2258 |
my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ) or return undef; |
2009 |
my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ) or return undef; |
2259 |
my $itemtype = (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'}; |
2010 |
my $branchcode = _GetCircControlBranch($item, $borrower); |
|
|
2011 |
my $loanlength = GetIssuingRule( $borrower->{categorycode}, $item->{itype}, $branchcode ); |
2012 |
|
2013 |
$datedue = |
2014 |
( C4::Context->preference('RenewalPeriodBase') eq 'date_due' ) |
2015 |
? C4::Dates->new( $issuedata->{date_due}, 'iso' ) |
2016 |
: C4::Dates->new(); |
2017 |
|
2018 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'}; |
2019 |
my $controlbranch = _GetCircControlBranch( $item, $borrower ); |
2020 |
warn "RENEWALPERIOD : ".$loanlength->{renewalperiod}; |
2021 |
my $renewalperiod = $loanlength->{renewalperiod} || GetLoanLength( $borrower->{'categorycode'}, $itype, $controlbranch ); |
2022 |
|
2023 |
$datedue = CalcDateDue( $datedue, $biblio->{'itemtype'}, $issuedata->{'branchcode'}, $borrower, $renewalperiod ); |
2260 |
|
2024 |
|
2261 |
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? |
|
|
2262 |
C4::Dates->new($issuedata->{date_due}, 'iso') : |
2263 |
C4::Dates->new(); |
2264 |
$datedue = CalcDateDue($datedue,$itemtype,$issuedata->{'branchcode'},$borrower); |
2265 |
} |
2025 |
} |
2266 |
|
2026 |
|
2267 |
# Update the issues record to have the new due date, and a new count |
2027 |
# Update the issues record to have the new due date, and a new count |
2268 |
# of how many times it has been renewed. |
2028 |
# of how many times it has been renewed. |
2269 |
my $renews = $issuedata->{'renewals'} + 1; |
2029 |
my $renews = $issuedata->{'renewals'} + 1; |
2270 |
$sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ? |
2030 |
$sth = $dbh->prepare( |
|
|
2031 |
"UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ? |
2271 |
WHERE borrowernumber=? |
2032 |
WHERE borrowernumber=? |
2272 |
AND itemnumber=?" |
2033 |
AND itemnumber=?" |
2273 |
); |
2034 |
); |
Lines 2275-2282
sub AddRenewal {
Link Here
|
2275 |
$sth->finish; |
2036 |
$sth->finish; |
2276 |
|
2037 |
|
2277 |
# Update the renewal count on the item, and tell zebra to reindex |
2038 |
# Update the renewal count on the item, and tell zebra to reindex |
2278 |
$renews = $biblio->{'renewals'} + 1; |
2039 |
$renews = $item->{'renewals'} + 1; |
2279 |
ModItem({ renewals => $renews, onloan => $datedue->output('iso') }, $biblio->{'biblionumber'}, $itemnumber); |
2040 |
ModItem( { renewals => $renews, onloan => $datedue->output('iso') }, undef, $itemnumber ); |
2280 |
|
2041 |
|
2281 |
# Charge a new rental fee, if applicable? |
2042 |
# Charge a new rental fee, if applicable? |
2282 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2043 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
Lines 2692-2711
C<$startdate> = C4::Dates object representing start date of loan period (assum
Link Here
|
2692 |
C<$itemtype> = itemtype code of item in question |
2453 |
C<$itemtype> = itemtype code of item in question |
2693 |
C<$branch> = location whose calendar to use |
2454 |
C<$branch> = location whose calendar to use |
2694 |
C<$borrower> = Borrower object |
2455 |
C<$borrower> = Borrower object |
|
|
2456 |
C<$renewalperiod> = if it's a renewal, give the duration of the renew. If empty, it will be set to initial checkout duration |
2695 |
|
2457 |
|
2696 |
=cut |
2458 |
=cut |
2697 |
|
2459 |
|
2698 |
sub CalcDateDue { |
2460 |
sub CalcDateDue { |
2699 |
my ($startdate,$itemtype,$branch,$borrower) = @_; |
2461 |
my ($startdate,$itemtype,$branch,$borrower,$renewalperiod) = @_; |
2700 |
my $datedue; |
2462 |
my $datedue; |
2701 |
my $loanlength = GetLoanLength($borrower->{'categorycode'},$itemtype, $branch); |
|
|
2702 |
|
2463 |
|
2703 |
# if globalDueDate ON the datedue is set to that date |
2464 |
# if globalDueDate ON the datedue is set to that date |
|
|
2465 |
my $rule = GetIssuingRule($borrower->{'categorycode'},$itemtype, $branch); |
2704 |
if ( C4::Context->preference('globalDueDate') |
2466 |
if ( C4::Context->preference('globalDueDate') |
2705 |
&& ( C4::Context->preference('globalDueDate') =~ C4::Dates->regexp('syspref') ) ) { |
2467 |
&& ( C4::Context->preference('globalDueDate') =~ C4::Dates->regexp('syspref') ) ) { |
2706 |
$datedue = C4::Dates->new( C4::Context->preference('globalDueDate') ); |
2468 |
$datedue = C4::Dates->new( C4::Context->preference('globalDueDate') ); |
2707 |
} else { |
2469 |
} else { |
2708 |
# otherwise, calculate the datedue as normal |
2470 |
# otherwise, calculate the datedue as normal |
|
|
2471 |
my $loanlength = $renewalperiod || $rule->{issuelength}; |
2709 |
if(C4::Context->preference('useDaysMode') eq 'Days') { # ignoring calendar |
2472 |
if(C4::Context->preference('useDaysMode') eq 'Days') { # ignoring calendar |
2710 |
my $timedue = time + ($loanlength) * 86400; |
2473 |
my $timedue = time + ($loanlength) * 86400; |
2711 |
#FIXME - assumes now even though we take a startdate |
2474 |
#FIXME - assumes now even though we take a startdate |
Lines 2717-2734
sub CalcDateDue {
Link Here
|
2717 |
} |
2480 |
} |
2718 |
} |
2481 |
} |
2719 |
|
2482 |
|
2720 |
# if Hard Due Dates are used, retreive them and apply as necessary |
2483 |
my ($hardduedate, $hardduedatecompare) = $rule->{qw(hardduedate hardduedatecompare)}; |
2721 |
my ($hardduedate, $hardduedatecompare) = GetHardDueDate($borrower->{'categorycode'},$itemtype, $branch); |
2484 |
if ( $hardduedate and $hardduedate ne '0000-00-00') { |
2722 |
if ( $hardduedate && $hardduedate->output('iso') && $hardduedate->output('iso') ne '0000-00-00') { |
|
|
2723 |
# if the calculated due date is after the 'before' Hard Due Date (ceiling), override |
2485 |
# if the calculated due date is after the 'before' Hard Due Date (ceiling), override |
2724 |
if ( $datedue->output( 'iso' ) gt $hardduedate->output( 'iso' ) && $hardduedatecompare == -1) { |
2486 |
if ( $datedue->output( 'iso' ) gt $hardduedate && $hardduedatecompare == -1) { |
2725 |
$datedue = $hardduedate; |
2487 |
$datedue = C4::Dates->new( $hardduedate ); |
2726 |
# if the calculated date is before the 'after' Hard Due Date (floor), override |
2488 |
# if the calculated date is before the 'after' Hard Due Date (floor), override |
2727 |
} elsif ( $datedue->output( 'iso' ) lt $hardduedate->output( 'iso' ) && $hardduedatecompare == 1) { |
2489 |
} elsif ( $datedue->output( 'iso' ) lt $hardduedate && $hardduedatecompare == 1) { |
2728 |
$datedue = $hardduedate; |
2490 |
$datedue = C4::Dates->new( $hardduedate ); |
2729 |
# if the hard due date is set to 'exactly', overrride |
2491 |
# if the hard due date is set to 'exactly', overrride |
2730 |
} elsif ( $hardduedatecompare == 0) { |
2492 |
} elsif ( $hardduedatecompare == 0) { |
2731 |
$datedue = $hardduedate; |
2493 |
$datedue = C4::Dates->new( $hardduedate ); |
2732 |
} |
2494 |
} |
2733 |
# in all other cases, keep the date due as it is |
2495 |
# in all other cases, keep the date due as it is |
2734 |
} |
2496 |
} |
Lines 2932-2949
sub CreateBranchTransferLimit {
Link Here
|
2932 |
|
2694 |
|
2933 |
=head2 DeleteBranchTransferLimits |
2695 |
=head2 DeleteBranchTransferLimits |
2934 |
|
2696 |
|
2935 |
DeleteBranchTransferLimits(); |
2697 |
DeleteBranchTransferLimits($tobranch); |
2936 |
|
2698 |
|
2937 |
=cut |
2699 |
=cut |
2938 |
|
2700 |
|
2939 |
sub DeleteBranchTransferLimits { |
2701 |
sub DeleteBranchTransferLimits { |
2940 |
my $dbh = C4::Context->dbh; |
2702 |
my $branch = shift; |
2941 |
my $sth = $dbh->prepare("TRUNCATE TABLE branch_transfer_limits"); |
2703 |
my $dbh = C4::Context->dbh; |
2942 |
$sth->execute(); |
2704 |
my $sth = $dbh->prepare("DELETE FROM branch_transfer_limits WHERE toBranch = ?"); |
|
|
2705 |
$sth->execute($branch); |
2943 |
} |
2706 |
} |
2944 |
|
2707 |
|
2945 |
|
2708 |
1; |
2946 |
1; |
|
|
2947 |
|
2709 |
|
2948 |
__END__ |
2710 |
__END__ |
2949 |
|
2711 |
|