Lines 1458-1475
sub AddIssue {
Link Here
|
1458 |
} |
1458 |
} |
1459 |
} |
1459 |
} |
1460 |
|
1460 |
|
1461 |
ModItem( |
1461 |
$item_object->issues($item_object->issues + 1); |
1462 |
{ |
1462 |
$item_object->holdingbranch(C4::Context->userenv->{'branch'}); |
1463 |
issues => $item_object->issues + 1, |
1463 |
$item_object->itemlost(0); |
1464 |
holdingbranch => C4::Context->userenv->{'branch'}, |
1464 |
$item_object->onloan($datedue->ymd()); |
1465 |
itemlost => 0, |
1465 |
$item_object->datelastborrowed(DateTime->now( time_zone => C4::Context->tz() )->ymd()); # FIXME we should use dt_from_string here |
1466 |
onloan => $datedue->ymd(), |
1466 |
$item_object->store({log_action => 0}); |
1467 |
datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(), |
|
|
1468 |
}, |
1469 |
$item_object->biblionumber, |
1470 |
$item_object->itemnumber, |
1471 |
{ log_action => 0 } |
1472 |
); |
1473 |
ModDateLastSeen( $item_object->itemnumber ); |
1467 |
ModDateLastSeen( $item_object->itemnumber ); |
1474 |
|
1468 |
|
1475 |
# If it costs to borrow this book, charge it to the patron's account. |
1469 |
# If it costs to borrow this book, charge it to the patron's account. |
Lines 1867-1873
sub AddReturn {
Link Here
|
1867 |
. Dumper($issue->unblessed) . "\n"; |
1861 |
. Dumper($issue->unblessed) . "\n"; |
1868 |
} else { |
1862 |
} else { |
1869 |
$messages->{'NotIssued'} = $barcode; |
1863 |
$messages->{'NotIssued'} = $barcode; |
1870 |
ModItem({ onloan => undef }, $item->biblionumber, $item->itemnumber) if defined $item->onloan; |
1864 |
$item->onloan(undef)->store if defined $item->onloan; |
|
|
1865 |
|
1871 |
# even though item is not on loan, it may still be transferred; therefore, get current branch info |
1866 |
# even though item is not on loan, it may still be transferred; therefore, get current branch info |
1872 |
$doreturn = 0; |
1867 |
$doreturn = 0; |
1873 |
# No issue, no borrowernumber. ONLY if $doreturn, *might* you have a $borrower later. |
1868 |
# No issue, no borrowernumber. ONLY if $doreturn, *might* you have a $borrower later. |
Lines 1878-1884
sub AddReturn {
Link Here
|
1878 |
} |
1873 |
} |
1879 |
} |
1874 |
} |
1880 |
|
1875 |
|
1881 |
my $item_unblessed = $item->unblessed; |
|
|
1882 |
# full item data, but no borrowernumber or checkout info (no issue) |
1876 |
# full item data, but no borrowernumber or checkout info (no issue) |
1883 |
my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch"; |
1877 |
my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch"; |
1884 |
# get the proper branch to which to return the item |
1878 |
# get the proper branch to which to return the item |
Lines 1896-1902
sub AddReturn {
Link Here
|
1896 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
1890 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
1897 |
if ( $item->location ne $update_loc_rules->{_ALL_}) { |
1891 |
if ( $item->location ne $update_loc_rules->{_ALL_}) { |
1898 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; |
1892 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; |
1899 |
ModItem( { location => $update_loc_rules->{_ALL_} }, undef, $itemnumber ); |
1893 |
$item->location($update_loc_rules->{_ALL_})->store; |
1900 |
} |
1894 |
} |
1901 |
} |
1895 |
} |
1902 |
else { |
1896 |
else { |
Lines 1905-1911
sub AddReturn {
Link Here
|
1905 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
1899 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
1906 |
if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { |
1900 |
if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { |
1907 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; |
1901 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; |
1908 |
ModItem( { location => $update_loc_rules->{$key} }, undef, $itemnumber ); |
1902 |
$item->location($update_loc_rules->{$key})->store; |
1909 |
last; |
1903 |
last; |
1910 |
} |
1904 |
} |
1911 |
} |
1905 |
} |
Lines 1924-1930
sub AddReturn {
Link Here
|
1924 |
foreach my $key ( keys %$rules ) { |
1918 |
foreach my $key ( keys %$rules ) { |
1925 |
if ( $item->notforloan eq $key ) { |
1919 |
if ( $item->notforloan eq $key ) { |
1926 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
1920 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
1927 |
ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber, { log_action => 0 } ); |
1921 |
$item->notforloan($rules->{$key})->store({ log_action => 0 }); |
1928 |
last; |
1922 |
last; |
1929 |
} |
1923 |
} |
1930 |
} |
1924 |
} |
Lines 1932-1938
sub AddReturn {
Link Here
|
1932 |
} |
1926 |
} |
1933 |
|
1927 |
|
1934 |
# check if the return is allowed at this branch |
1928 |
# check if the return is allowed at this branch |
1935 |
my ($returnallowed, $message) = CanBookBeReturned($item_unblessed, $branch); |
1929 |
my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch); |
1936 |
unless ($returnallowed){ |
1930 |
unless ($returnallowed){ |
1937 |
$messages->{'Wrongbranch'} = { |
1931 |
$messages->{'Wrongbranch'} = { |
1938 |
Wrongbranch => $branch, |
1932 |
Wrongbranch => $branch, |
Lines 1962-1968
sub AddReturn {
Link Here
|
1962 |
}; |
1956 |
}; |
1963 |
unless ( $@ ) { |
1957 |
unless ( $@ ) { |
1964 |
if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) { |
1958 |
if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) { |
1965 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } ); |
1959 |
_CalculateAndUpdateFine( { issue => $issue, item => $item->unblessed, borrower => $patron_unblessed, return_date => $return_date } ); |
1966 |
} |
1960 |
} |
1967 |
} else { |
1961 |
} else { |
1968 |
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 ); |
1962 |
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 1975-1981
sub AddReturn {
Link Here
|
1975 |
|
1969 |
|
1976 |
} |
1970 |
} |
1977 |
|
1971 |
|
1978 |
ModItem( { onloan => undef }, $item->biblionumber, $item->itemnumber, { log_action => 0 } ); |
1972 |
$item->onloan(undef)->store({ log_action => 0 }); |
1979 |
} |
1973 |
} |
1980 |
|
1974 |
|
1981 |
# the holdingbranch is updated if the document is returned to another location. |
1975 |
# the holdingbranch is updated if the document is returned to another location. |
Lines 1983-1989
sub AddReturn {
Link Here
|
1983 |
my $item_holding_branch = $item->holdingbranch; |
1977 |
my $item_holding_branch = $item->holdingbranch; |
1984 |
if ($item->holdingbranch ne $branch) { |
1978 |
if ($item->holdingbranch ne $branch) { |
1985 |
UpdateHoldingbranch($branch, $item->itemnumber); |
1979 |
UpdateHoldingbranch($branch, $item->itemnumber); |
1986 |
$item_unblessed->{'holdingbranch'} = $branch; # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later |
1980 |
$item->holdingbranch($branch); # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later |
1987 |
} |
1981 |
} |
1988 |
|
1982 |
|
1989 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
1983 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
Lines 2037-2043
sub AddReturn {
Link Here
|
2037 |
|
2031 |
|
2038 |
if ( $issue and $issue->is_overdue ) { |
2032 |
if ( $issue and $issue->is_overdue ) { |
2039 |
# fix fine days |
2033 |
# fix fine days |
2040 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $return_date ); |
2034 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item->unblessed, dt_from_string($issue->date_due), $return_date ); |
2041 |
if ($reminder){ |
2035 |
if ($reminder){ |
2042 |
$messages->{'PrevDebarred'} = $debardate; |
2036 |
$messages->{'PrevDebarred'} = $debardate; |
2043 |
} else { |
2037 |
} else { |
Lines 2090-2096
sub AddReturn {
Link Here
|
2090 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
2084 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
2091 |
SendCirculationAlert({ |
2085 |
SendCirculationAlert({ |
2092 |
type => 'CHECKIN', |
2086 |
type => 'CHECKIN', |
2093 |
item => $item_unblessed, |
2087 |
item => $item->unblessed, |
2094 |
borrower => $patron->unblessed, |
2088 |
borrower => $patron->unblessed, |
2095 |
branch => $branch, |
2089 |
branch => $branch, |
2096 |
}); |
2090 |
}); |
Lines 2118-2124
sub AddReturn {
Link Here
|
2118 |
! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType ) |
2112 |
! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType ) |
2119 |
)) { |
2113 |
)) { |
2120 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->itemnumber,$branch, $returnbranch; |
2114 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s)", $item->itemnumber,$branch, $returnbranch; |
2121 |
$debug and warn "item: " . Dumper($item_unblessed); |
2115 |
$debug and warn "item: " . Dumper($item->unblessed); |
2122 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch); |
2116 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch); |
2123 |
$messages->{'WasTransfered'} = 1; |
2117 |
$messages->{'WasTransfered'} = 1; |
2124 |
} else { |
2118 |
} else { |
Lines 2204-2210
sub MarkIssueReturned {
Link Here
|
2204 |
# And finally delete the issue |
2198 |
# And finally delete the issue |
2205 |
$issue->delete; |
2199 |
$issue->delete; |
2206 |
|
2200 |
|
2207 |
ModItem( { 'onloan' => undef }, undef, $itemnumber, { log_action => 0 } ); |
2201 |
$issue->item->onloan(undef)->store({ log_action => 0 }); |
2208 |
|
2202 |
|
2209 |
if ( C4::Context->preference('StoreLastBorrower') ) { |
2203 |
if ( C4::Context->preference('StoreLastBorrower') ) { |
2210 |
my $item = Koha::Items->find( $itemnumber ); |
2204 |
my $item = Koha::Items->find( $itemnumber ); |
Lines 2485-2490
sub _FixAccountForLostAndReturned {
Link Here
|
2485 |
$accountline->discard_changes->status('RETURNED'); |
2479 |
$accountline->discard_changes->status('RETURNED'); |
2486 |
$accountline->store; |
2480 |
$accountline->store; |
2487 |
|
2481 |
|
|
|
2482 |
$accountline->item->paidfor('')->store({ log_action => 0 }); |
2483 |
|
2488 |
if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) { |
2484 |
if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) { |
2489 |
$account->reconcile_balance; |
2485 |
$account->reconcile_balance; |
2490 |
} |
2486 |
} |
Lines 2927-2933
sub AddRenewal {
Link Here
|
2927 |
|
2923 |
|
2928 |
# Update the renewal count on the item, and tell zebra to reindex |
2924 |
# Update the renewal count on the item, and tell zebra to reindex |
2929 |
$renews = $item_object->renewals + 1; |
2925 |
$renews = $item_object->renewals + 1; |
2930 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item_object->biblionumber, $itemnumber, { log_action => 0 } ); |
2926 |
$item_object->renewals($renews); |
|
|
2927 |
$item_object->onloan($datedue); |
2928 |
$item_object->store({ log_action => 0 }); |
2931 |
|
2929 |
|
2932 |
# Charge a new rental fee, if applicable |
2930 |
# Charge a new rental fee, if applicable |
2933 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2931 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
Lines 3741-3747
sub LostItem{
Link Here
|
3741 |
|
3739 |
|
3742 |
#When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch) |
3740 |
#When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch) |
3743 |
if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) { |
3741 |
if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) { |
3744 |
ModItem({holdingbranch => $frombranch}, undef, $itemnumber); |
3742 |
Koha::Items->find($itemnumber)->holdingbranch($frombranch)->store; |
3745 |
} |
3743 |
} |
3746 |
my $transferdeleted = DeleteTransfer($itemnumber); |
3744 |
my $transferdeleted = DeleteTransfer($itemnumber); |
3747 |
} |
3745 |
} |
Lines 3809-3820
sub ProcessOfflineReturn {
Link Here
|
3809 |
$itemnumber, |
3807 |
$itemnumber, |
3810 |
$operation->{timestamp}, |
3808 |
$operation->{timestamp}, |
3811 |
); |
3809 |
); |
3812 |
ModItem( |
3810 |
$item->renewals(0); |
3813 |
{ renewals => 0, onloan => undef }, |
3811 |
$item->onloan(undef); |
3814 |
$issue->{'biblionumber'}, |
3812 |
$item->store({ log_action => 0 }); |
3815 |
$itemnumber, |
|
|
3816 |
{ log_action => 0 } |
3817 |
); |
3818 |
return "Success."; |
3813 |
return "Success."; |
3819 |
} else { |
3814 |
} else { |
3820 |
return "Item not issued."; |
3815 |
return "Item not issued."; |