|
Lines 693-702
sub CanBookBeIssued {
Link Here
|
| 693 |
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE |
693 |
my %issuingimpossible; # filled with problems that causes the issue to be IMPOSSIBLE |
| 694 |
my %alerts; # filled with messages that shouldn't stop issuing, but the librarian should be aware of. |
694 |
my %alerts; # filled with messages that shouldn't stop issuing, but the librarian should be aware of. |
| 695 |
|
695 |
|
| 696 |
my $item = GetItem(GetItemnumberFromBarcode( $barcode )); |
696 |
my $item = GetItem(undef, $barcode); |
| 697 |
my $issue = GetItemIssue($item->{itemnumber}); |
|
|
| 698 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
| 699 |
$item->{'itemtype'}=$item->{'itype'}; |
| 700 |
my $dbh = C4::Context->dbh; |
697 |
my $dbh = C4::Context->dbh; |
| 701 |
|
698 |
|
| 702 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
699 |
# MANDATORY CHECKS - unless item exists, nothing else matters |
|
Lines 705-710
sub CanBookBeIssued {
Link Here
|
| 705 |
} |
702 |
} |
| 706 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
703 |
return ( \%issuingimpossible, \%needsconfirmation ) if %issuingimpossible; |
| 707 |
|
704 |
|
|
|
705 |
my $issue = GetItemIssue($item->{'itemnumber'}); |
| 706 |
my $biblio = GetBiblioItemData($item->{'biblioitemnumber'}); |
| 707 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblio->{'itemtype'}; |
| 708 |
|
| 708 |
# |
709 |
# |
| 709 |
# DUE DATE is OK ? -- should already have checked. |
710 |
# DUE DATE is OK ? -- should already have checked. |
| 710 |
# |
711 |
# |
|
Lines 716-722
sub CanBookBeIssued {
Link Here
|
| 716 |
my $issuedate = $now->clone(); |
717 |
my $issuedate = $now->clone(); |
| 717 |
|
718 |
|
| 718 |
my $branch = _GetCircControlBranch($item,$borrower); |
719 |
my $branch = _GetCircControlBranch($item,$borrower); |
| 719 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblioitem->{'itemtype'}; |
|
|
| 720 |
$duedate = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
720 |
$duedate = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
| 721 |
|
721 |
|
| 722 |
# Offline circ calls AddIssue directly, doesn't run through here |
722 |
# Offline circ calls AddIssue directly, doesn't run through here |
|
Lines 737-743
sub CanBookBeIssued {
Link Here
|
| 737 |
# |
737 |
# |
| 738 |
if ( $borrower->{'category_type'} eq 'X' && ( $item->{barcode} )) { |
738 |
if ( $borrower->{'category_type'} eq 'X' && ( $item->{barcode} )) { |
| 739 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
739 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
| 740 |
&UpdateStats(C4::Context->userenv->{'branch'},'localuse','','',$item->{'itemnumber'},$item->{'itemtype'},$borrower->{'borrowernumber'}, undef, $item->{'ccode'}); |
740 |
&UpdateStats(C4::Context->userenv->{'branch'},'localuse','','',$item->{'itemnumber'},$itype,$borrower->{'borrowernumber'}, undef, $item->{'ccode'}); |
| 741 |
ModDateLastSeen( $item->{'itemnumber'} ); |
741 |
ModDateLastSeen( $item->{'itemnumber'} ); |
| 742 |
return( { STATS => 1 }, {}); |
742 |
return( { STATS => 1 }, {}); |
| 743 |
} |
743 |
} |
|
Lines 863-875
sub CanBookBeIssued {
Link Here
|
| 863 |
} |
863 |
} |
| 864 |
} |
864 |
} |
| 865 |
} |
865 |
} |
| 866 |
elsif ($biblioitem->{'notforloan'} == 1){ |
866 |
elsif ($biblio->{'notforloan'} == 1){ |
| 867 |
if (!C4::Context->preference("AllowNotForLoanOverride")) { |
867 |
if (!C4::Context->preference("AllowNotForLoanOverride")) { |
| 868 |
$issuingimpossible{NOT_FOR_LOAN} = 1; |
868 |
$issuingimpossible{NOT_FOR_LOAN} = 1; |
| 869 |
$issuingimpossible{itemtype_notforloan} = $biblioitem->{'itemtype'}; |
869 |
$issuingimpossible{itemtype_notforloan} = $biblio->{'itemtype'}; |
| 870 |
} else { |
870 |
} else { |
| 871 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
871 |
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; |
| 872 |
$needsconfirmation{itemtype_notforloan} = $biblioitem->{'itemtype'}; |
872 |
$needsconfirmation{itemtype_notforloan} = $biblio->{'itemtype'}; |
| 873 |
} |
873 |
} |
| 874 |
} |
874 |
} |
| 875 |
} |
875 |
} |
|
Lines 968-974
sub CanBookBeIssued {
Link Here
|
| 968 |
|
968 |
|
| 969 |
# get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:" |
969 |
# get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:" |
| 970 |
my $markers = C4::Context->preference('AgeRestrictionMarker' ); |
970 |
my $markers = C4::Context->preference('AgeRestrictionMarker' ); |
| 971 |
my $bibvalues = $biblioitem->{'agerestriction'}; |
971 |
my $bibvalues = $biblio->{'agerestriction'}; |
| 972 |
if (($markers)&&($bibvalues)) |
972 |
if (($markers)&&($bibvalues)) |
| 973 |
{ |
973 |
{ |
| 974 |
# Split $bibvalues to something like FSK 16 or PEGI 6 |
974 |
# Split $bibvalues to something like FSK 16 or PEGI 6 |
|
Lines 1194-1200
sub AddIssue {
Link Here
|
| 1194 |
my $actualissue = GetItemIssue( $item->{itemnumber}); |
1194 |
my $actualissue = GetItemIssue( $item->{itemnumber}); |
| 1195 |
|
1195 |
|
| 1196 |
# get biblioinformation for this item |
1196 |
# get biblioinformation for this item |
| 1197 |
my $biblio = GetBiblioFromItemNumber($item->{itemnumber}); |
1197 |
my $biblio = GetBiblioItemData($item->{'biblioitemnumber'}); |
|
|
1198 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblio->{'itemtype'}; |
| 1198 |
|
1199 |
|
| 1199 |
# |
1200 |
# |
| 1200 |
# check if we just renew the issue. |
1201 |
# check if we just renew the issue. |
|
Lines 1243-1251
sub AddIssue {
Link Here
|
| 1243 |
VALUES (?,?,?,?,?)" |
1244 |
VALUES (?,?,?,?,?)" |
| 1244 |
); |
1245 |
); |
| 1245 |
unless ($datedue) { |
1246 |
unless ($datedue) { |
| 1246 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'}; |
|
|
| 1247 |
$datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
1247 |
$datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
| 1248 |
|
|
|
| 1249 |
} |
1248 |
} |
| 1250 |
$datedue->truncate( to => 'minute'); |
1249 |
$datedue->truncate( to => 'minute'); |
| 1251 |
$sth->execute( |
1250 |
$sth->execute( |
|
Lines 1279-1285
sub AddIssue {
Link Here
|
| 1279 |
ModDateLastSeen( $item->{'itemnumber'} ); |
1278 |
ModDateLastSeen( $item->{'itemnumber'} ); |
| 1280 |
|
1279 |
|
| 1281 |
# If it costs to borrow this book, charge it to the patron's account. |
1280 |
# If it costs to borrow this book, charge it to the patron's account. |
| 1282 |
my ( $charge, $itemtype ) = GetIssuingCharges( |
1281 |
my ( $charge, $charge_itemtype ) = GetIssuingCharges( |
| 1283 |
$item->{'itemnumber'}, |
1282 |
$item->{'itemnumber'}, |
| 1284 |
$borrower->{'borrowernumber'} |
1283 |
$borrower->{'borrowernumber'} |
| 1285 |
); |
1284 |
); |
|
Lines 1296-1302
sub AddIssue {
Link Here
|
| 1296 |
C4::Context->userenv->{'branch'}, |
1295 |
C4::Context->userenv->{'branch'}, |
| 1297 |
'issue', $charge, |
1296 |
'issue', $charge, |
| 1298 |
($sipmode ? "SIP-$sipmode" : ''), $item->{'itemnumber'}, |
1297 |
($sipmode ? "SIP-$sipmode" : ''), $item->{'itemnumber'}, |
| 1299 |
$item->{'itype'}, $borrower->{'borrowernumber'}, undef, $item->{'ccode'} |
1298 |
$itype, $borrower->{'borrowernumber'}, undef, $item->{'ccode'} |
| 1300 |
); |
1299 |
); |
| 1301 |
|
1300 |
|
| 1302 |
# Send a checkout slip. |
1301 |
# Send a checkout slip. |
|
Lines 1304-1310
sub AddIssue {
Link Here
|
| 1304 |
my %conditions = ( |
1303 |
my %conditions = ( |
| 1305 |
branchcode => $branch, |
1304 |
branchcode => $branch, |
| 1306 |
categorycode => $borrower->{categorycode}, |
1305 |
categorycode => $borrower->{categorycode}, |
| 1307 |
item_type => $item->{itype}, |
1306 |
item_type => $itype, |
| 1308 |
notification => 'CHECKOUT', |
1307 |
notification => 'CHECKOUT', |
| 1309 |
); |
1308 |
); |
| 1310 |
if ($circulation_alert->is_enabled_for(\%conditions)) { |
1309 |
if ($circulation_alert->is_enabled_for(\%conditions)) { |
|
Lines 1317-1323
sub AddIssue {
Link Here
|
| 1317 |
} |
1316 |
} |
| 1318 |
} |
1317 |
} |
| 1319 |
|
1318 |
|
| 1320 |
logaction("CIRCULATION", "ISSUE", $borrower->{'borrowernumber'}, $biblio->{'itemnumber'}) |
1319 |
logaction("CIRCULATION", "ISSUE", $borrower->{'borrowernumber'}, $item->{'itemnumber'}) |
| 1321 |
if C4::Context->preference("IssueLog"); |
1320 |
if C4::Context->preference("IssueLog"); |
| 1322 |
} |
1321 |
} |
| 1323 |
return ($datedue); # not necessarily the same as when it came in! |
1322 |
return ($datedue); # not necessarily the same as when it came in! |
|
Lines 1708-1714
sub AddReturn {
Link Here
|
| 1708 |
$branch = C4::Context->userenv->{'branch'} unless $branch; # we trust userenv to be a safe fallback/default |
1707 |
$branch = C4::Context->userenv->{'branch'} unless $branch; # we trust userenv to be a safe fallback/default |
| 1709 |
my $messages; |
1708 |
my $messages; |
| 1710 |
my $borrower; |
1709 |
my $borrower; |
| 1711 |
my $biblio; |
|
|
| 1712 |
my $doreturn = 1; |
1710 |
my $doreturn = 1; |
| 1713 |
my $validTransfert = 0; |
1711 |
my $validTransfert = 0; |
| 1714 |
my $stat_type = 'return'; |
1712 |
my $stat_type = 'return'; |
|
Lines 1739-1745
sub AddReturn {
Link Here
|
| 1739 |
my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed"; |
1737 |
my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed"; |
| 1740 |
# full item data, but no borrowernumber or checkout info (no issue) |
1738 |
# full item data, but no borrowernumber or checkout info (no issue) |
| 1741 |
# we know GetItem should work because GetItemnumberFromBarcode worked |
1739 |
# we know GetItem should work because GetItemnumberFromBarcode worked |
| 1742 |
my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch"; |
1740 |
|
|
|
1741 |
# get biblioinformation for this item |
| 1742 |
my $biblio = GetBiblioItemData($item->{'biblioitemnumber'}); |
| 1743 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblio->{'itemtype'}; |
| 1744 |
|
| 1745 |
my $hbr = GetBranchItemRule($item->{'homebranch'}, $itype)->{'returnbranch'} || "homebranch"; |
| 1743 |
# get the proper branch to which to return the item |
1746 |
# get the proper branch to which to return the item |
| 1744 |
$hbr = $item->{$hbr} || $branch ; |
1747 |
$hbr = $item->{$hbr} || $branch ; |
| 1745 |
# if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch) |
1748 |
# if $hbr was "noreturn" or any other non-item table value, then it should 'float' (i.e. stay at this branch) |
|
Lines 1887-1893
sub AddReturn {
Link Here
|
| 1887 |
UpdateStats( |
1890 |
UpdateStats( |
| 1888 |
$branch, $stat_type, '0', '', |
1891 |
$branch, $stat_type, '0', '', |
| 1889 |
$item->{'itemnumber'}, |
1892 |
$item->{'itemnumber'}, |
| 1890 |
$biblio->{'itemtype'}, |
1893 |
$itype, |
| 1891 |
$borrowernumber, undef, $item->{'ccode'} |
1894 |
$borrowernumber, undef, $item->{'ccode'} |
| 1892 |
); |
1895 |
); |
| 1893 |
|
1896 |
|
|
Lines 1896-1902
sub AddReturn {
Link Here
|
| 1896 |
my %conditions = ( |
1899 |
my %conditions = ( |
| 1897 |
branchcode => $branch, |
1900 |
branchcode => $branch, |
| 1898 |
categorycode => $borrower->{categorycode}, |
1901 |
categorycode => $borrower->{categorycode}, |
| 1899 |
item_type => $item->{itype}, |
1902 |
item_type => $itype, |
| 1900 |
notification => 'CHECKIN', |
1903 |
notification => 'CHECKIN', |
| 1901 |
); |
1904 |
); |
| 1902 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
1905 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
|
Lines 2466-2478
sub CanBookBeRenewed {
Link Here
|
| 2466 |
|
2469 |
|
| 2467 |
my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ) or return; |
2470 |
my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ) or return; |
| 2468 |
my $item = GetItem($itemnumber) or return; |
2471 |
my $item = GetItem($itemnumber) or return; |
| 2469 |
my $itemissue = GetItemIssue($itemnumber) or return; |
2472 |
my $issue = GetItemIssue($itemnumber) or return; |
|
|
2473 |
my $biblio = GetBiblioItemData($item->{'biblioitemnumber'}); |
| 2474 |
my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblio->{'itemtype'}; |
| 2470 |
|
2475 |
|
| 2471 |
my $branchcode = _GetCircControlBranch($item, $borrower); |
2476 |
my $branchcode = _GetCircControlBranch($item, $borrower); |
| 2472 |
|
2477 |
|
| 2473 |
my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode); |
2478 |
my $issuingrule = GetIssuingRule($borrower->{categorycode}, $itype, $branchcode); |
| 2474 |
|
2479 |
|
| 2475 |
if ( ( $issuingrule->{renewalsallowed} > $itemissue->{renewals} ) || $override_limit ) { |
2480 |
if ( ( $issuingrule->{renewalsallowed} > $issue->{renewals} ) || $override_limit ) { |
| 2476 |
$renewokay = 1; |
2481 |
$renewokay = 1; |
| 2477 |
} else { |
2482 |
} else { |
| 2478 |
$error = "too_many"; |
2483 |
$error = "too_many"; |
|
Lines 2517-2524
sub AddRenewal {
Link Here
|
| 2517 |
my $branch = shift; |
2522 |
my $branch = shift; |
| 2518 |
my $datedue = shift; |
2523 |
my $datedue = shift; |
| 2519 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); |
2524 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); |
|
|
2525 |
|
| 2520 |
my $item = GetItem($itemnumber) or return; |
2526 |
my $item = GetItem($itemnumber) or return; |
| 2521 |
my $biblio = GetBiblioFromItemNumber($itemnumber) or return; |
2527 |
my $biblio = GetBiblioItemData($item->{'biblioitemnumber'}) or return; |
|
|
2528 |
my $itype = (C4::Context->preference('item-level_itypes')) ? $item->{'itype'} : $biblio->{'itemtype'}; |
| 2522 |
|
2529 |
|
| 2523 |
my $dbh = C4::Context->dbh; |
2530 |
my $dbh = C4::Context->dbh; |
| 2524 |
# Find the issues record for this book |
2531 |
# Find the issues record for this book |
|
Lines 2540-2551
sub AddRenewal {
Link Here
|
| 2540 |
unless ($datedue) { |
2547 |
unless ($datedue) { |
| 2541 |
|
2548 |
|
| 2542 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) or return; |
2549 |
my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) or return; |
| 2543 |
my $itemtype = (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'}; |
|
|
| 2544 |
|
2550 |
|
| 2545 |
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? |
2551 |
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? |
| 2546 |
dt_from_string( $issuedata->{date_due} ) : |
2552 |
dt_from_string( $issuedata->{date_due} ) : |
| 2547 |
DateTime->now( time_zone => C4::Context->tz()); |
2553 |
DateTime->now( time_zone => C4::Context->tz()); |
| 2548 |
$datedue = CalcDateDue($datedue, $itemtype, $issuedata->{'branchcode'}, $borrower, 'is a renewal'); |
2554 |
$datedue = CalcDateDue($datedue, $itype, $issuedata->{'branchcode'}, $borrower, 'is a renewal'); |
| 2549 |
} |
2555 |
} |
| 2550 |
|
2556 |
|
| 2551 |
# Update the issues record to have the new due date, and a new count |
2557 |
# Update the issues record to have the new due date, and a new count |
|
Lines 2560-2567
sub AddRenewal {
Link Here
|
| 2560 |
$sth->finish; |
2566 |
$sth->finish; |
| 2561 |
|
2567 |
|
| 2562 |
# Update the renewal count on the item, and tell zebra to reindex |
2568 |
# Update the renewal count on the item, and tell zebra to reindex |
| 2563 |
$renews = $biblio->{'renewals'} + 1; |
2569 |
$renews = $item->{'renewals'} + 1; |
| 2564 |
ModItem({ renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $biblio->{'biblionumber'}, $itemnumber); |
2570 |
ModItem({ renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{'biblionumber'}, $itemnumber); |
| 2565 |
|
2571 |
|
| 2566 |
# Charge a new rental fee, if applicable? |
2572 |
# Charge a new rental fee, if applicable? |
| 2567 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2573 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
|
Lines 2588-2594
sub AddRenewal {
Link Here
|
| 2588 |
my %conditions = ( |
2594 |
my %conditions = ( |
| 2589 |
branchcode => $branch, |
2595 |
branchcode => $branch, |
| 2590 |
categorycode => $borrower->{categorycode}, |
2596 |
categorycode => $borrower->{categorycode}, |
| 2591 |
item_type => $item->{itype}, |
2597 |
item_type => $itype, |
| 2592 |
notification => 'CHECKOUT', |
2598 |
notification => 'CHECKOUT', |
| 2593 |
); |
2599 |
); |
| 2594 |
if ($circulation_alert->is_enabled_for(\%conditions)) { |
2600 |
if ($circulation_alert->is_enabled_for(\%conditions)) { |
|
Lines 2602-2608
sub AddRenewal {
Link Here
|
| 2602 |
} |
2608 |
} |
| 2603 |
|
2609 |
|
| 2604 |
# Log the renewal |
2610 |
# Log the renewal |
| 2605 |
UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber, undef, $item->{'ccode'}); |
2611 |
UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $itype, $borrowernumber, undef, $item->{'ccode'}); |
| 2606 |
return $datedue; |
2612 |
return $datedue; |
| 2607 |
} |
2613 |
} |
| 2608 |
|
2614 |
|
| 2609 |
- |
|
|