|
Lines 1460-1477
sub AddIssue {
Link Here
|
| 1460 |
} |
1460 |
} |
| 1461 |
} |
1461 |
} |
| 1462 |
|
1462 |
|
| 1463 |
ModItem( |
1463 |
$item_object->issues( ( $item_object->issues || 0 ) + 1); |
| 1464 |
{ |
1464 |
$item_object->holdingbranch(C4::Context->userenv->{'branch'}); |
| 1465 |
issues => ( $item_object->issues || 0 ) + 1, |
1465 |
$item_object->itemlost(0); |
| 1466 |
holdingbranch => C4::Context->userenv->{'branch'}, |
1466 |
$item_object->onloan($datedue->ymd()); |
| 1467 |
itemlost => 0, |
1467 |
$item_object->datelastborrowed(DateTime->now( time_zone => C4::Context->tz() )->ymd()); # FIXME we should use dt_from_string here |
| 1468 |
onloan => $datedue->ymd(), |
1468 |
$item_object->store({log_action => 0}); |
| 1469 |
datelastborrowed => DateTime->now( time_zone => C4::Context->tz() )->ymd(), |
|
|
| 1470 |
}, |
| 1471 |
$item_object->biblionumber, |
| 1472 |
$item_object->itemnumber, |
| 1473 |
{ log_action => 0 } |
| 1474 |
); |
| 1475 |
ModDateLastSeen( $item_object->itemnumber ); |
1469 |
ModDateLastSeen( $item_object->itemnumber ); |
| 1476 |
|
1470 |
|
| 1477 |
# If it costs to borrow this book, charge it to the patron's account. |
1471 |
# If it costs to borrow this book, charge it to the patron's account. |
|
Lines 1881-1887
sub AddReturn {
Link Here
|
| 1881 |
. Dumper($issue->unblessed) . "\n"; |
1875 |
. Dumper($issue->unblessed) . "\n"; |
| 1882 |
} else { |
1876 |
} else { |
| 1883 |
$messages->{'NotIssued'} = $barcode; |
1877 |
$messages->{'NotIssued'} = $barcode; |
| 1884 |
ModItem({ onloan => undef }, $item->biblionumber, $item->itemnumber) if defined $item->onloan; |
1878 |
$item->onloan(undef)->store if defined $item->onloan; |
|
|
1879 |
|
| 1885 |
# even though item is not on loan, it may still be transferred; therefore, get current branch info |
1880 |
# even though item is not on loan, it may still be transferred; therefore, get current branch info |
| 1886 |
$doreturn = 0; |
1881 |
$doreturn = 0; |
| 1887 |
# No issue, no borrowernumber. ONLY if $doreturn, *might* you have a $borrower later. |
1882 |
# No issue, no borrowernumber. ONLY if $doreturn, *might* you have a $borrower later. |
|
Lines 1892-1898
sub AddReturn {
Link Here
|
| 1892 |
} |
1887 |
} |
| 1893 |
} |
1888 |
} |
| 1894 |
|
1889 |
|
| 1895 |
my $item_unblessed = $item->unblessed; |
|
|
| 1896 |
# full item data, but no borrowernumber or checkout info (no issue) |
1890 |
# full item data, but no borrowernumber or checkout info (no issue) |
| 1897 |
my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch"; |
1891 |
my $hbr = GetBranchItemRule($item->homebranch, $itemtype)->{'returnbranch'} || "homebranch"; |
| 1898 |
# get the proper branch to which to return the item |
1892 |
# get the proper branch to which to return the item |
|
Lines 1911-1917
sub AddReturn {
Link Here
|
| 1911 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
1905 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
| 1912 |
if ( $item->location ne $update_loc_rules->{_ALL_}) { |
1906 |
if ( $item->location ne $update_loc_rules->{_ALL_}) { |
| 1913 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; |
1907 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{_ALL_} }; |
| 1914 |
ModItem( { location => $update_loc_rules->{_ALL_} }, undef, $itemnumber ); |
1908 |
$item->location($update_loc_rules->{_ALL_})->store; |
| 1915 |
} |
1909 |
} |
| 1916 |
} |
1910 |
} |
| 1917 |
else { |
1911 |
else { |
|
Lines 1920-1926
sub AddReturn {
Link Here
|
| 1920 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
1914 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
| 1921 |
if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { |
1915 |
if ( ($item->location eq $key && $item->location ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->location eq '' && $update_loc_rules->{$key} ne '') ) { |
| 1922 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; |
1916 |
$messages->{'ItemLocationUpdated'} = { from => $item->location, to => $update_loc_rules->{$key} }; |
| 1923 |
ModItem( { location => $update_loc_rules->{$key} }, undef, $itemnumber ); |
1917 |
$item->location($update_loc_rules->{$key})->store; |
| 1924 |
last; |
1918 |
last; |
| 1925 |
} |
1919 |
} |
| 1926 |
} |
1920 |
} |
|
Lines 1939-1945
sub AddReturn {
Link Here
|
| 1939 |
foreach my $key ( keys %$rules ) { |
1933 |
foreach my $key ( keys %$rules ) { |
| 1940 |
if ( $item->notforloan eq $key ) { |
1934 |
if ( $item->notforloan eq $key ) { |
| 1941 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
1935 |
$messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; |
| 1942 |
ModItem( { notforloan => $rules->{$key} }, undef, $itemnumber, { log_action => 0 } ); |
1936 |
$item->notforloan($rules->{$key})->store({ log_action => 0 }); |
| 1943 |
last; |
1937 |
last; |
| 1944 |
} |
1938 |
} |
| 1945 |
} |
1939 |
} |
|
Lines 1947-1953
sub AddReturn {
Link Here
|
| 1947 |
} |
1941 |
} |
| 1948 |
|
1942 |
|
| 1949 |
# check if the return is allowed at this branch |
1943 |
# check if the return is allowed at this branch |
| 1950 |
my ($returnallowed, $message) = CanBookBeReturned($item_unblessed, $branch); |
1944 |
my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch); |
| 1951 |
unless ($returnallowed){ |
1945 |
unless ($returnallowed){ |
| 1952 |
$messages->{'Wrongbranch'} = { |
1946 |
$messages->{'Wrongbranch'} = { |
| 1953 |
Wrongbranch => $branch, |
1947 |
Wrongbranch => $branch, |
|
Lines 1977-1983
sub AddReturn {
Link Here
|
| 1977 |
}; |
1971 |
}; |
| 1978 |
unless ( $@ ) { |
1972 |
unless ( $@ ) { |
| 1979 |
if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) { |
1973 |
if ( C4::Context->preference('CalculateFinesOnReturn') && !$item->itemlost ) { |
| 1980 |
_CalculateAndUpdateFine( { issue => $issue, item => $item_unblessed, borrower => $patron_unblessed, return_date => $return_date } ); |
1974 |
_CalculateAndUpdateFine( { issue => $issue, item => $item->unblessed, borrower => $patron_unblessed, return_date => $return_date } ); |
| 1981 |
} |
1975 |
} |
| 1982 |
} else { |
1976 |
} else { |
| 1983 |
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 ); |
1977 |
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 1990-1996
sub AddReturn {
Link Here
|
| 1990 |
|
1984 |
|
| 1991 |
} |
1985 |
} |
| 1992 |
|
1986 |
|
| 1993 |
ModItem( { onloan => undef }, $item->biblionumber, $item->itemnumber, { log_action => 0 } ); |
1987 |
$item->onloan(undef)->store({ log_action => 0 }); |
| 1994 |
} |
1988 |
} |
| 1995 |
|
1989 |
|
| 1996 |
# the holdingbranch is updated if the document is returned to another location. |
1990 |
# the holdingbranch is updated if the document is returned to another location. |
|
Lines 1998-2004
sub AddReturn {
Link Here
|
| 1998 |
my $item_holding_branch = $item->holdingbranch; |
1992 |
my $item_holding_branch = $item->holdingbranch; |
| 1999 |
if ($item->holdingbranch ne $branch) { |
1993 |
if ($item->holdingbranch ne $branch) { |
| 2000 |
UpdateHoldingbranch($branch, $item->itemnumber); |
1994 |
UpdateHoldingbranch($branch, $item->itemnumber); |
| 2001 |
$item_unblessed->{'holdingbranch'} = $branch; # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later |
1995 |
$item->holdingbranch($branch); # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later |
| 2002 |
} |
1996 |
} |
| 2003 |
|
1997 |
|
| 2004 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
1998 |
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; |
|
Lines 2052-2058
sub AddReturn {
Link Here
|
| 2052 |
|
2046 |
|
| 2053 |
if ( $issue and $issue->is_overdue ) { |
2047 |
if ( $issue and $issue->is_overdue ) { |
| 2054 |
# fix fine days |
2048 |
# fix fine days |
| 2055 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item_unblessed, dt_from_string($issue->date_due), $return_date ); |
2049 |
my ($debardate,$reminder) = _debar_user_on_return( $patron_unblessed, $item->unblessed, dt_from_string($issue->date_due), $return_date ); |
| 2056 |
if ($reminder){ |
2050 |
if ($reminder){ |
| 2057 |
$messages->{'PrevDebarred'} = $debardate; |
2051 |
$messages->{'PrevDebarred'} = $debardate; |
| 2058 |
} else { |
2052 |
} else { |
|
Lines 2111-2117
sub AddReturn {
Link Here
|
| 2111 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
2105 |
if ($doreturn && $circulation_alert->is_enabled_for(\%conditions)) { |
| 2112 |
SendCirculationAlert({ |
2106 |
SendCirculationAlert({ |
| 2113 |
type => 'CHECKIN', |
2107 |
type => 'CHECKIN', |
| 2114 |
item => $item_unblessed, |
2108 |
item => $item->unblessed, |
| 2115 |
borrower => $patron->unblessed, |
2109 |
borrower => $patron->unblessed, |
| 2116 |
branch => $branch, |
2110 |
branch => $branch, |
| 2117 |
}); |
2111 |
}); |
|
Lines 2148-2154
sub AddReturn {
Link Here
|
| 2148 |
! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType ) |
2142 |
! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType ) |
| 2149 |
)) { |
2143 |
)) { |
| 2150 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger; |
2144 |
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger; |
| 2151 |
$debug and warn "item: " . Dumper($item_unblessed); |
2145 |
$debug and warn "item: " . Dumper($item->unblessed); |
| 2152 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger); |
2146 |
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger); |
| 2153 |
$messages->{'WasTransfered'} = 1; |
2147 |
$messages->{'WasTransfered'} = 1; |
| 2154 |
} else { |
2148 |
} else { |
|
Lines 2238-2244
sub MarkIssueReturned {
Link Here
|
| 2238 |
# And finally delete the issue |
2232 |
# And finally delete the issue |
| 2239 |
$issue->delete; |
2233 |
$issue->delete; |
| 2240 |
|
2234 |
|
| 2241 |
ModItem( { 'onloan' => undef }, undef, $itemnumber, { log_action => 0 } ); |
2235 |
$issue->item->onloan(undef)->store({ log_action => 0 }); |
| 2242 |
|
2236 |
|
| 2243 |
if ( C4::Context->preference('StoreLastBorrower') ) { |
2237 |
if ( C4::Context->preference('StoreLastBorrower') ) { |
| 2244 |
my $item = Koha::Items->find( $itemnumber ); |
2238 |
my $item = Koha::Items->find( $itemnumber ); |
|
Lines 2540-2545
sub _FixAccountForLostAndFound {
Link Here
|
| 2540 |
$accountline->discard_changes->status('FOUND'); |
2534 |
$accountline->discard_changes->status('FOUND'); |
| 2541 |
$accountline->store; |
2535 |
$accountline->store; |
| 2542 |
|
2536 |
|
|
|
2537 |
$accountline->item->paidfor('')->store({ log_action => 0 }); |
| 2538 |
|
| 2543 |
if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) { |
2539 |
if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) { |
| 2544 |
$account->reconcile_balance; |
2540 |
$account->reconcile_balance; |
| 2545 |
} |
2541 |
} |
|
Lines 3001-3007
sub AddRenewal {
Link Here
|
| 3001 |
|
2997 |
|
| 3002 |
# Update the renewal count on the item, and tell zebra to reindex |
2998 |
# Update the renewal count on the item, and tell zebra to reindex |
| 3003 |
$renews = ( $item_object->renewals || 0 ) + 1; |
2999 |
$renews = ( $item_object->renewals || 0 ) + 1; |
| 3004 |
ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item_object->biblionumber, $itemnumber, { log_action => 0 } ); |
3000 |
$item_object->renewals($renews); |
|
|
3001 |
$item_object->onloan($datedue); |
| 3002 |
$item_object->store({ log_action => 0 }); |
| 3005 |
|
3003 |
|
| 3006 |
# Charge a new rental fee, if applicable |
3004 |
# Charge a new rental fee, if applicable |
| 3007 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
3005 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
|
Lines 3833-3839
sub LostItem{
Link Here
|
| 3833 |
|
3831 |
|
| 3834 |
#When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch) |
3832 |
#When item is marked lost automatically cancel its outstanding transfers and set items holdingbranch to the transfer source branch (frombranch) |
| 3835 |
if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) { |
3833 |
if (my ( $datesent,$frombranch,$tobranch ) = GetTransfers($itemnumber)) { |
| 3836 |
ModItem({holdingbranch => $frombranch}, undef, $itemnumber); |
3834 |
Koha::Items->find($itemnumber)->holdingbranch($frombranch)->store; |
| 3837 |
} |
3835 |
} |
| 3838 |
my $transferdeleted = DeleteTransfer($itemnumber); |
3836 |
my $transferdeleted = DeleteTransfer($itemnumber); |
| 3839 |
} |
3837 |
} |
|
Lines 3901-3912
sub ProcessOfflineReturn {
Link Here
|
| 3901 |
$itemnumber, |
3899 |
$itemnumber, |
| 3902 |
$operation->{timestamp}, |
3900 |
$operation->{timestamp}, |
| 3903 |
); |
3901 |
); |
| 3904 |
ModItem( |
3902 |
$item->renewals(0); |
| 3905 |
{ renewals => 0, onloan => undef }, |
3903 |
$item->onloan(undef); |
| 3906 |
$issue->{'biblionumber'}, |
3904 |
$item->store({ log_action => 0 }); |
| 3907 |
$itemnumber, |
|
|
| 3908 |
{ log_action => 0 } |
| 3909 |
); |
| 3910 |
return "Success."; |
3905 |
return "Success."; |
| 3911 |
} else { |
3906 |
} else { |
| 3912 |
return "Item not issued."; |
3907 |
return "Item not issued."; |