Lines 1457-1474
sub AddIssue {
Link Here
|
1457 |
} |
1457 |
} |
1458 |
} |
1458 |
} |
1459 |
|
1459 |
|
1460 |
ModItem( |
1460 |
$item_object->issues(($item_object->issues || 0) + 1); |
1461 |
{ |
1461 |
$item_object->holdingbranch(C4::Context->userenv->{'branch'}); |
1462 |
issues => ( $item_object->issues || 0 ) + 1, |
1462 |
$item_object->itemlost(0); |
1463 |
holdingbranch => C4::Context->userenv->{'branch'}, |
1463 |
$item_object->onloan($datedue->ymd()); |
1464 |
itemlost => 0, |
1464 |
$item_object->datelastborrowed(DateTime->now( time_zone => C4::Context->tz() )->ymd()); # FIXME we should use dt_from_string here |
1465 |
onloan => $datedue->ymd(), |
1465 |
$item_object->store({log_action => 0}); |
1466 |
datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(), |
|
|
1467 |
}, |
1468 |
$item_object->biblionumber, |
1469 |
$item_object->itemnumber, |
1470 |
{ log_action => 0 } |
1471 |
); |
1472 |
ModDateLastSeen( $item_object->itemnumber ); |
1466 |
ModDateLastSeen( $item_object->itemnumber ); |
1473 |
|
1467 |
|
1474 |
# If it costs to borrow this book, charge it to the patron's account. |
1468 |
# If it costs to borrow this book, charge it to the patron's account. |
Lines 1866-1872
sub AddReturn {
Link Here
|
1866 |
. Dumper($issue->unblessed) . "\n"; |
1860 |
. Dumper($issue->unblessed) . "\n"; |
1867 |
} else { |
1861 |
} else { |
1868 |
$messages->{'NotIssued'} = $barcode; |
1862 |
$messages->{'NotIssued'} = $barcode; |
1869 |
ModItem({ onloan => undef }, $item->biblionumber, $item->itemnumber) if defined $item->onloan; |
1863 |
$item->onloan(undef)->store if defined $item->onloan; |
|
|
1864 |
|
1870 |
# even though item is not on loan, it may still be transferred; therefore, get current branch info |
1865 |
# even though item is not on loan, it may still be transferred; therefore, get current branch info |
1871 |
$doreturn = 0; |
1866 |
$doreturn = 0; |
1872 |
# No issue, no borrowernumber. ONLY if $doreturn, *might* you have a $borrower later. |
1867 |
# No issue, no borrowernumber. ONLY if $doreturn, *might* you have a $borrower later. |
Lines 1877-1883
sub AddReturn {
Link Here
|
1877 |
} |
1872 |
} |
1878 |
} |
1873 |
} |
1879 |
|
1874 |
|
1880 |
my $item_unblessed = $item->unblessed; |
|
|
1881 |
# full item data, but no borrowernumber or checkout info (no issue) |
1875 |
# full item data, but no borrowernumber or checkout info (no issue) |
1882 |
my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch"; |
1876 |
my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch"; |
1883 |
# get the proper branch to which to return the item |
1877 |
# get the proper branch to which to return the item |
Lines 1895-1901
sub AddReturn {
Link Here
|
1895 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
1889 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
1896 |
if ( $item->location ne $update_loc_rules->{_ALL_}) { |
1890 |
if ( $item->location ne $update_loc_rules->{_ALL_}) { |
1897 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; |
1891 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; |
1898 |
ModItem( { location => $update_loc_rules->{_ALL_} }, undef, $itemnumber ); |
1892 |
$item->location($update_loc_rules->{_ALL_})->store; |
1899 |
} |
1893 |
} |
1900 |
} |
1894 |
} |
1901 |
else { |
1895 |
else { |
Lines 1904-1910
sub AddReturn {
Link Here
|
1904 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
1898 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
1905 |
if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { |
1899 |
if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { |
1906 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; |
1900 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; |
1907 |
ModItem( { location => $update_loc_rules->{$key} }, undef, $itemnumber ); |
1901 |
$item->location($update_loc_rules->{$key})->store; |
1908 |
last; |
1902 |
last; |
1909 |
} |
1903 |
} |
1910 |
} |
1904 |
} |
Lines 1923-1929
sub AddReturn {
Link Here
|
1923 |
foreach my $key ( keys %$rules ) { |
1917 |
foreach my $key ( keys %$rules ) { |
1924 |
if ( $item->notforloan eq $key ) { |
1918 |
if ( $item->notforloan eq $key ) { |
1925 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
1919 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
1926 |
ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber, { log_action => 0 } ); |
1920 |
$item->notforloan($rules->{$key})->store({ log_action => 0 }); |
1927 |
last; |
1921 |
last; |
1928 |
} |
1922 |
} |
1929 |
} |
1923 |
} |
Lines 1931-1937
sub AddReturn {
Link Here
|
1931 |
} |
1925 |
} |
1932 |
|
1926 |
|
1933 |
# check if the return is allowed at this branch |
1927 |
# check if the return is allowed at this branch |
1934 |
my ($returnallowed, $message) = CanBookBeReturned($item_unblessed, $branch); |
1928 |
my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch); |
1935 |
unless ($returnallowed){ |
1929 |
unless ($returnallowed){ |
1936 |
$messages->{'Wrongbranch'} = { |
1930 |
$messages->{'Wrongbranch'} = { |
1937 |
Wrongbranch => $branch, |
1931 |
Wrongbranch => $branch, |
Lines 1961-1967
sub AddReturn {
Link Here
|
1961 |
}; |
1955 |
}; |
1962 |
unless ( $@ ) { |
1956 |
unless ( $@ ) { |
1963 |
if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) { |
1957 |
if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) { |
1964 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } ); |
1958 |
_CalculateAndUpdateFine( { issue => $issue, item => $item->unblessed, borrower => $patron_unblessed, return_date => $return_date } ); |
1965 |
} |
1959 |
} |
1966 |
} else { |
1960 |
} else { |
1967 |
carp "The checkin for the following issue failed, Please go to the about page, section 'data corrupted' to know how to fix this problem ($@)" . Dumper( $issue->unblessed ); |
1961 |
carp "The checkin for the following issue failed, Please go to the about page, section 'data corrupted' to know how to fix this problem ($@)" . Dumper( $issue->unblessed ); |
Lines 1974-1980
sub AddReturn {
Link Here
|
1974 |
|
1968 |
|
1975 |
} |
1969 |
} |
1976 |
|
1970 |
|
1977 |
ModItem( { onloan => undef }, $item->biblionumber, $item->itemnumber, { log_action => 0 } ); |
1971 |
$item->onloan(undef)->store({ log_action => 0 }); |
1978 |
} |
1972 |
} |
1979 |
|
1973 |
|
1980 |
# the holdingbranch is updated if the document is returned to another location. |
1974 |
# the holdingbranch is updated if the document is returned to another location. |
Lines 1982-1988
sub AddReturn {
Link Here
|
1982 |
my $item_holding_branch = $item->holdingbranch; |
1976 |
my $item_holding_branch = $item->holdingbranch; |
1983 |
if ($item->holdingbranch ne $branch) { |
1977 |
if ($item->holdingbranch ne $branch) { |
1984 |
UpdateHoldingbranch($branch, $item->itemnumber); |
1978 |
UpdateHoldingbranch($branch, $item->itemnumber); |
1985 |
$item_unblessed->{'holdingbranch'} = $branch; # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later |
1979 |
$item->holdingbranch($branch); # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later |
1986 |
} |
1980 |
} |
1987 |
|
1981 |
|
1988 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
1982 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
Lines 2036-2042
sub AddReturn {
Link Here
|
2036 |
|
2030 |
|
2037 |
if ( $issue and $issue->is_overdue ) { |
2031 |
if ( $issue and $issue->is_overdue ) { |
2038 |
# fix fine days |
2032 |
# fix fine days |
2039 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $return_date ); |
2033 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item->unblessed, dt_from_string($issue->date_due), $return_date ); |
2040 |
if ($reminder){ |
2034 |
if ($reminder){ |
2041 |
$messages->{'PrevDebarred'} = $debardate; |
2035 |
$messages->{'PrevDebarred'} = $debardate; |
2042 |
} else { |
2036 |
} else { |
Lines 2089-2095
sub AddReturn {
Link Here
|
2089 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
2083 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
2090 |
SendCirculationAlert({ |
2084 |
SendCirculationAlert({ |
2091 |
type => 'CHECKIN', |
2085 |
type => 'CHECKIN', |
2092 |
item => $item_unblessed, |
2086 |
item => $item->unblessed, |
2093 |
borrower => $patron->unblessed, |
2087 |
borrower => $patron->unblessed, |
2094 |
branch => $branch, |
2088 |
branch => $branch, |
2095 |
}); |
2089 |
}); |
Lines 2117-2123
sub AddReturn {
Link Here
|
2117 |
! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType ) |
2111 |
! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType ) |
2118 |
)) { |
2112 |
)) { |
2119 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->itemnumber,$branch, $returnbranch; |
2113 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->itemnumber,$branch, $returnbranch; |
2120 |
$debug and warn "item: " . Dumper($item_unblessed); |
2114 |
$debug and warn "item: " . Dumper($item->unblessed); |
2121 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch); |
2115 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch); |
2122 |
$messages->{'WasTransfered'} = 1; |
2116 |
$messages->{'WasTransfered'} = 1; |
2123 |
} else { |
2117 |
} else { |
Lines 2206-2212
sub MarkIssueReturned {
Link Here
|
2206 |
# And finally delete the issue |
2200 |
# And finally delete the issue |
2207 |
$issue->delete; |
2201 |
$issue->delete; |
2208 |
|
2202 |
|
2209 |
ModItem( { 'onloan' => undef }, undef, $itemnumber, { log_action => 0 } ); |
2203 |
$issue->item->onloan(undef)->store({ log_action => 0 }); |
2210 |
|
2204 |
|
2211 |
if ( C4::Context->preference('StoreLastBorrower') ) { |
2205 |
if ( C4::Context->preference('StoreLastBorrower') ) { |
2212 |
my $item = Koha::Items->find( $itemnumber ); |
2206 |
my $item = Koha::Items->find( $itemnumber ); |
Lines 2499-2504
sub _FixAccountForLostAndReturned {
Link Here
|
2499 |
$accountline->discard_changes->status('RETURNED'); |
2493 |
$accountline->discard_changes->status('RETURNED'); |
2500 |
$accountline->store; |
2494 |
$accountline->store; |
2501 |
|
2495 |
|
|
|
2496 |
$accountline->item->paidfor('')->store({ log_action => 0 }); |
2497 |
|
2502 |
if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) { |
2498 |
if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) { |
2503 |
$account->reconcile_balance; |
2499 |
$account->reconcile_balance; |
2504 |
} |
2500 |
} |
Lines 2941-2947
sub AddRenewal {
Link Here
|
2941 |
|
2937 |
|
2942 |
# Update the renewal count on the item, and tell zebra to reindex |
2938 |
# Update the renewal count on the item, and tell zebra to reindex |
2943 |
$renews = ( $item_object->renewals || 0 ) + 1; |
2939 |
$renews = ( $item_object->renewals || 0 ) + 1; |
2944 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item_object->biblionumber, $itemnumber, { log_action => 0 } ); |
2940 |
$item_object->renewals($renews); |
|
|
2941 |
$item_object->onloan($datedue); |
2942 |
$item_object->store({ log_action => 0 }); |
2945 |
|
2943 |
|
2946 |
# Charge a new rental fee, if applicable |
2944 |
# Charge a new rental fee, if applicable |
2947 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2945 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
Lines 3755-3761
sub LostItem{
Link Here
|
3755 |
|
3753 |
|
3756 |
#When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch) |
3754 |
#When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch) |
3757 |
if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) { |
3755 |
if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) { |
3758 |
ModItem({holdingbranch => $frombranch}, undef, $itemnumber); |
3756 |
Koha::Items->find($itemnumber)->holdingbranch($frombranch)->store; |
3759 |
} |
3757 |
} |
3760 |
my $transferdeleted = DeleteTransfer($itemnumber); |
3758 |
my $transferdeleted = DeleteTransfer($itemnumber); |
3761 |
} |
3759 |
} |
Lines 3823-3834
sub ProcessOfflineReturn {
Link Here
|
3823 |
$itemnumber, |
3821 |
$itemnumber, |
3824 |
$operation->{timestamp}, |
3822 |
$operation->{timestamp}, |
3825 |
); |
3823 |
); |
3826 |
ModItem( |
3824 |
$item->renewals(0); |
3827 |
{ renewals => 0, onloan => undef }, |
3825 |
$item->onloan(undef); |
3828 |
$issue->{'biblionumber'}, |
3826 |
$item->store({ log_action => 0 }); |
3829 |
$itemnumber, |
|
|
3830 |
{ log_action => 0 } |
3831 |
); |
3832 |
return "Success."; |
3827 |
return "Success."; |
3833 |
} else { |
3828 |
} else { |
3834 |
return "Item not issued."; |
3829 |
return "Item not issued."; |