Lines 306-336
sub transferbook {
Link Here
|
306 |
my ( $tbr, $barcode, $ignoreRs ) = @_; |
306 |
my ( $tbr, $barcode, $ignoreRs ) = @_; |
307 |
my $messages; |
307 |
my $messages; |
308 |
my $dotransfer = 1; |
308 |
my $dotransfer = 1; |
309 |
my $itemnumber = GetItemnumberFromBarcode( $barcode ); |
309 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
310 |
my $issue = GetItemIssue($itemnumber); |
|
|
311 |
my $biblio = GetBiblioFromItemNumber($itemnumber); |
312 |
|
310 |
|
313 |
# bad barcode.. |
311 |
# bad barcode.. |
314 |
if ( not $itemnumber ) { |
312 |
unless ( $item ) { |
315 |
$messages->{'BadBarcode'} = $barcode; |
313 |
$messages->{'BadBarcode'} = $barcode; |
316 |
$dotransfer = 0; |
314 |
$dotransfer = 0; |
317 |
} |
315 |
} |
318 |
|
316 |
|
|
|
317 |
my $itemnumber = $item->itemnumber; |
318 |
my $issue = GetOpenIssue($itemnumber); |
319 |
# get branches of book... |
319 |
# get branches of book... |
320 |
my $hbr = $biblio->{'homebranch'}; |
320 |
my $hbr = $item->homebranch; |
321 |
my $fbr = $biblio->{'holdingbranch'}; |
321 |
my $fbr = $item->holdingbranch; |
322 |
|
322 |
|
323 |
# if using Branch Transfer Limits |
323 |
# if using Branch Transfer Limits |
324 |
if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) { |
324 |
if ( C4::Context->preference("UseBranchTransferLimits") == 1 ) { |
|
|
325 |
my $code = C4::Context->preference("BranchTransferLimitsType") eq 'ccode' ? $item->ccode : $item->biblio->biblioitem->itemtype; # BranchTransferLimitsType is 'ccode' or 'itemtype' |
325 |
if ( C4::Context->preference("item-level_itypes") && C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ) { |
326 |
if ( C4::Context->preference("item-level_itypes") && C4::Context->preference("BranchTransferLimitsType") eq 'itemtype' ) { |
326 |
if ( ! IsBranchTransferAllowed( $tbr, $fbr, $biblio->{'itype'} ) ) { |
327 |
if ( ! IsBranchTransferAllowed( $tbr, $fbr, $item->itype ) ) { |
327 |
$messages->{'NotAllowed'} = $tbr . "::" . $biblio->{'itype'}; |
328 |
$messages->{'NotAllowed'} = $tbr . "::" . $item->itype; |
328 |
$dotransfer = 0; |
329 |
$dotransfer = 0; |
329 |
} |
330 |
} |
330 |
} elsif ( ! IsBranchTransferAllowed( $tbr, $fbr, $biblio->{ C4::Context->preference("BranchTransferLimitsType") } ) ) { |
331 |
} elsif ( ! IsBranchTransferAllowed( $tbr, $fbr, $code ) ) { |
331 |
$messages->{'NotAllowed'} = $tbr . "::" . $biblio->{ C4::Context->preference("BranchTransferLimitsType") }; |
332 |
$messages->{'NotAllowed'} = $tbr . "::" . $code; |
332 |
$dotransfer = 0; |
333 |
$dotransfer = 0; |
333 |
} |
334 |
} |
334 |
} |
335 |
} |
335 |
|
336 |
|
336 |
# if is permanent... |
337 |
# if is permanent... |
Lines 374-380
sub transferbook {
Link Here
|
374 |
|
375 |
|
375 |
} |
376 |
} |
376 |
ModDateLastSeen( $itemnumber ); |
377 |
ModDateLastSeen( $itemnumber ); |
377 |
return ( $dotransfer, $messages, $biblio ); |
378 |
return ( $dotransfer, $messages ); |
378 |
} |
379 |
} |
379 |
|
380 |
|
380 |
|
381 |
|
Lines 673-679
sub CanBookBeIssued {
Link Here
|
673 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
674 |
my $onsite_checkout = $params->{onsite_checkout} || 0; |
674 |
my $override_high_holds = $params->{override_high_holds} || 0; |
675 |
my $override_high_holds = $params->{override_high_holds} || 0; |
675 |
|
676 |
|
676 |
my $item = GetItem(GetItemnumberFromBarcode( $barcode )); |
677 |
my $item = GetItem(undef, $barcode ); |
677 |
my $issue = GetItemIssue($item->{itemnumber}); |
678 |
my $issue = GetItemIssue($item->{itemnumber}); |
678 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
679 |
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); |
679 |
$item->{'itemtype'}=$item->{'itype'}; |
680 |
$item->{'itemtype'}=$item->{'itype'}; |
Lines 1147-1154
sub CanBookBeReturned {
Link Here
|
1147 |
|
1148 |
|
1148 |
sub checkHighHolds { |
1149 |
sub checkHighHolds { |
1149 |
my ( $item, $borrower ) = @_; |
1150 |
my ( $item, $borrower ) = @_; |
1150 |
my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); |
|
|
1151 |
my $branch = _GetCircControlBranch( $item, $borrower ); |
1151 |
my $branch = _GetCircControlBranch( $item, $borrower ); |
|
|
1152 |
my $item_object = Koha::Items->find( $item->{itemnumber} ); |
1152 |
|
1153 |
|
1153 |
my $return_data = { |
1154 |
my $return_data = { |
1154 |
exceeded => 0, |
1155 |
exceeded => 0, |
Lines 1207-1217
sub checkHighHolds {
Link Here
|
1207 |
|
1208 |
|
1208 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
1209 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
1209 |
|
1210 |
|
1210 |
my $itype = |
1211 |
my $itype = $item_object->effective_itemtype; |
1211 |
( C4::Context->preference('item-level_itypes') ) |
|
|
1212 |
? $biblio->{'itype'} |
1213 |
: $biblio->{'itemtype'}; |
1214 |
|
1215 |
my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
1212 |
my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
1216 |
|
1213 |
|
1217 |
my $decreaseLoanHighHoldsDuration = C4::Context->preference('decreaseLoanHighHoldsDuration'); |
1214 |
my $decreaseLoanHighHoldsDuration = C4::Context->preference('decreaseLoanHighHoldsDuration'); |
Lines 1300-1314
sub AddIssue {
Link Here
|
1300 |
# find which item we issue |
1297 |
# find which item we issue |
1301 |
my $item = GetItem( '', $barcode ) |
1298 |
my $item = GetItem( '', $barcode ) |
1302 |
or return; # if we don't get an Item, abort. |
1299 |
or return; # if we don't get an Item, abort. |
|
|
1300 |
my $item_object = Koha::Items->find( { barcode => $barcode } ); |
1303 |
|
1301 |
|
1304 |
my $branch = _GetCircControlBranch( $item, $borrower ); |
1302 |
my $branch = _GetCircControlBranch( $item, $borrower ); |
1305 |
|
1303 |
|
1306 |
# get actual issuing if there is one |
1304 |
# get actual issuing if there is one |
1307 |
my $actualissue = GetItemIssue( $item->{itemnumber} ); |
1305 |
my $actualissue = GetItemIssue( $item->{itemnumber} ); |
1308 |
|
1306 |
|
1309 |
# get biblioinformation for this item |
|
|
1310 |
my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); |
1311 |
|
1312 |
# check if we just renew the issue. |
1307 |
# check if we just renew the issue. |
1313 |
if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'} |
1308 |
if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'} |
1314 |
and not $switch_onsite_checkout ) { |
1309 |
and not $switch_onsite_checkout ) { |
Lines 1362-1371
sub AddIssue {
Link Here
|
1362 |
|
1357 |
|
1363 |
# Record in the database the fact that the book was issued. |
1358 |
# Record in the database the fact that the book was issued. |
1364 |
unless ($datedue) { |
1359 |
unless ($datedue) { |
1365 |
my $itype = |
1360 |
my $itype = $item_object->effective_itemtype; |
1366 |
( C4::Context->preference('item-level_itypes') ) |
|
|
1367 |
? $biblio->{'itype'} |
1368 |
: $biblio->{'itemtype'}; |
1369 |
$datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
1361 |
$datedue = CalcDateDue( $issuedate, $itype, $branch, $borrower ); |
1370 |
|
1362 |
|
1371 |
} |
1363 |
} |
Lines 1466-1472
sub AddIssue {
Link Here
|
1466 |
logaction( |
1458 |
logaction( |
1467 |
"CIRCULATION", "ISSUE", |
1459 |
"CIRCULATION", "ISSUE", |
1468 |
$borrower->{'borrowernumber'}, |
1460 |
$borrower->{'borrowernumber'}, |
1469 |
$biblio->{'itemnumber'} |
1461 |
$item->{'itemnumber'} |
1470 |
) if C4::Context->preference("IssueLog"); |
1462 |
) if C4::Context->preference("IssueLog"); |
1471 |
} |
1463 |
} |
1472 |
return $issue; |
1464 |
return $issue; |
Lines 1864-1870
sub AddReturn {
Link Here
|
1864 |
} |
1856 |
} |
1865 |
|
1857 |
|
1866 |
# full item data, but no borrowernumber or checkout info (no issue) |
1858 |
# full item data, but no borrowernumber or checkout info (no issue) |
1867 |
# we know GetItem should work because GetItemnumberFromBarcode worked |
|
|
1868 |
my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch"; |
1859 |
my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch"; |
1869 |
# get the proper branch to which to return the item |
1860 |
# get the proper branch to which to return the item |
1870 |
my $returnbranch = $item->{$hbr} || $branch ; |
1861 |
my $returnbranch = $item->{$hbr} || $branch ; |
Lines 2863-2869
sub AddRenewal {
Link Here
|
2863 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); |
2854 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); |
2864 |
|
2855 |
|
2865 |
my $item = GetItem($itemnumber) or return; |
2856 |
my $item = GetItem($itemnumber) or return; |
2866 |
my $biblio = GetBiblioFromItemNumber($itemnumber) or return; |
2857 |
my $item_object = Koha::Items->find( $itemnumber ); # Should replace $item |
|
|
2858 |
my $biblio = $item_object->biblio; |
2867 |
|
2859 |
|
2868 |
my $dbh = C4::Context->dbh; |
2860 |
my $dbh = C4::Context->dbh; |
2869 |
|
2861 |
|
Lines 2891-2898
sub AddRenewal {
Link Here
|
2891 |
# based on the value of the RenewalPeriodBase syspref. |
2883 |
# based on the value of the RenewalPeriodBase syspref. |
2892 |
unless ($datedue) { |
2884 |
unless ($datedue) { |
2893 |
|
2885 |
|
2894 |
my $itemtype = (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'}; |
2886 |
my $itemtype = $item_object->effective_itemtype; |
2895 |
|
|
|
2896 |
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? |
2887 |
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? |
2897 |
dt_from_string( $issuedata->{date_due} ) : |
2888 |
dt_from_string( $issuedata->{date_due} ) : |
2898 |
DateTime->now( time_zone => C4::Context->tz()); |
2889 |
DateTime->now( time_zone => C4::Context->tz()); |
Lines 2910-2923
sub AddRenewal {
Link Here
|
2910 |
$sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber ); |
2901 |
$sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber ); |
2911 |
|
2902 |
|
2912 |
# Update the renewal count on the item, and tell zebra to reindex |
2903 |
# Update the renewal count on the item, and tell zebra to reindex |
2913 |
$renews = $biblio->{'renewals'} + 1; |
2904 |
$renews = $item->{renewals} + 1; |
2914 |
ModItem({ renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $biblio->{'biblionumber'}, $itemnumber); |
2905 |
ModItem({ renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->{biblionumber}, $itemnumber); |
2915 |
|
2906 |
|
2916 |
# Charge a new rental fee, if applicable? |
2907 |
# Charge a new rental fee, if applicable? |
2917 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2908 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2918 |
if ( $charge > 0 ) { |
2909 |
if ( $charge > 0 ) { |
2919 |
my $accountno = getnextacctno( $borrowernumber ); |
2910 |
my $accountno = getnextacctno( $borrowernumber ); |
2920 |
my $item = GetBiblioFromItemNumber($itemnumber); |
|
|
2921 |
my $manager_id = 0; |
2911 |
my $manager_id = 0; |
2922 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
2912 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
2923 |
$sth = $dbh->prepare( |
2913 |
$sth = $dbh->prepare( |
Lines 2927-2933
sub AddRenewal {
Link Here
|
2927 |
VALUES (now(),?,?,?,?,?,?,?,?)" |
2917 |
VALUES (now(),?,?,?,?,?,?,?,?)" |
2928 |
); |
2918 |
); |
2929 |
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id, |
2919 |
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id, |
2930 |
"Renewal of Rental Item $item->{'title'} $item->{'barcode'}", |
2920 |
"Renewal of Rental Item " . $item_object->title . " $item->{'barcode'}", |
2931 |
'Rent', $charge, $itemnumber ); |
2921 |
'Rent', $charge, $itemnumber ); |
2932 |
} |
2922 |
} |
2933 |
|
2923 |
|
Lines 3749-3757
sub ProcessOfflineOperation {
Link Here
|
3749 |
sub ProcessOfflineReturn { |
3739 |
sub ProcessOfflineReturn { |
3750 |
my $operation = shift; |
3740 |
my $operation = shift; |
3751 |
|
3741 |
|
3752 |
my $itemnumber = C4::Items::GetItemnumberFromBarcode( $operation->{barcode} ); |
3742 |
my $item = Koha::Items->find({barcode => $operation->{barcode}}); |
3753 |
|
3743 |
|
3754 |
if ( $itemnumber ) { |
3744 |
if ( $item ) { |
|
|
3745 |
my $itemnumber = $item->itemnumber; |
3755 |
my $issue = GetOpenIssue( $itemnumber ); |
3746 |
my $issue = GetOpenIssue( $itemnumber ); |
3756 |
if ( $issue ) { |
3747 |
if ( $issue ) { |
3757 |
MarkIssueReturned( |
3748 |
MarkIssueReturned( |
Lines 3780-3789
sub ProcessOfflineIssue {
Link Here
|
3780 |
my $borrower = C4::Members::GetMember( cardnumber => $operation->{cardnumber} ); |
3771 |
my $borrower = C4::Members::GetMember( cardnumber => $operation->{cardnumber} ); |
3781 |
|
3772 |
|
3782 |
if ( $borrower->{borrowernumber} ) { |
3773 |
if ( $borrower->{borrowernumber} ) { |
3783 |
my $itemnumber = C4::Items::GetItemnumberFromBarcode( $operation->{barcode} ); |
3774 |
my $item = Koha::Items->find({ barcode => $operation->{barcode} }); |
3784 |
unless ($itemnumber) { |
3775 |
unless ($item) { |
3785 |
return "Barcode not found."; |
3776 |
return "Barcode not found."; |
3786 |
} |
3777 |
} |
|
|
3778 |
my $itemnumber = $item->itemnumber; |
3787 |
my $issue = GetOpenIssue( $itemnumber ); |
3779 |
my $issue = GetOpenIssue( $itemnumber ); |
3788 |
|
3780 |
|
3789 |
if ( $issue and ( $issue->{borrowernumber} ne $borrower->{borrowernumber} ) ) { # Item already issued to another borrower, mark it returned |
3781 |
if ( $issue and ( $issue->{borrowernumber} ne $borrower->{borrowernumber} ) ) { # Item already issued to another borrower, mark it returned |