Lines 837-903
sub AutoUnsuspendReserves {
Link Here
|
837 |
map { $_->suspend(0)->suspend_until(undef)->store() } @holds; |
837 |
map { $_->suspend(0)->suspend_until(undef)->store() } @holds; |
838 |
} |
838 |
} |
839 |
|
839 |
|
840 |
=head2 CancelReserve |
|
|
841 |
|
842 |
CancelReserve({ reserve_id => $reserve_id, [ biblionumber => $biblionumber, borrowernumber => $borrrowernumber, itemnumber => $itemnumber, ] [ charge_cancel_fee => 1 ] }); |
843 |
|
844 |
Cancels a reserve. If C<charge_cancel_fee> is passed and the C<ExpireReservesMaxPickUpDelayCharge> syspref is set, charge that fee to the patron's account. |
845 |
|
846 |
=cut |
847 |
|
848 |
sub CancelReserve { |
849 |
my ( $params ) = @_; |
850 |
|
851 |
my $reserve_id = $params->{'reserve_id'}; |
852 |
my $hold; |
853 |
if ( $reserve_id ) { |
854 |
$hold = Koha::Holds->find( $reserve_id ); |
855 |
} else { |
856 |
$hold = Koha::Holds->search( $params ); # biblionumber, borrowernumber, itemnumber |
857 |
} |
858 |
|
859 |
return unless $hold; |
860 |
|
861 |
logaction( 'HOLDS', 'CANCEL', $hold->reserve_id, Dumper($hold->unblessed) ) |
862 |
if C4::Context->preference('HoldsLog'); |
863 |
|
864 |
my $query = " |
865 |
UPDATE reserves |
866 |
SET cancellationdate = now(), |
867 |
priority = 0 |
868 |
WHERE reserve_id = ? |
869 |
"; |
870 |
my $dbh = C4::Context->dbh; |
871 |
my $sth = $dbh->prepare($query); |
872 |
$sth->execute( $reserve_id ); |
873 |
|
874 |
$query = " |
875 |
INSERT INTO old_reserves |
876 |
SELECT * FROM reserves |
877 |
WHERE reserve_id = ? |
878 |
"; |
879 |
$sth = $dbh->prepare($query); |
880 |
$sth->execute( $reserve_id ); |
881 |
|
882 |
$query = " |
883 |
DELETE FROM reserves |
884 |
WHERE reserve_id = ? |
885 |
"; |
886 |
$sth = $dbh->prepare($query); |
887 |
$sth->execute( $reserve_id ); |
888 |
|
889 |
# now fix the priority on the others.... |
890 |
_FixPriority({ biblionumber => $hold->biblionumber }); |
891 |
|
892 |
# and, if desired, charge a cancel fee |
893 |
my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"); |
894 |
if ( $charge && $params->{'charge_cancel_fee'} ) { |
895 |
manualinvoice($hold->borrowernumber, $hold->itemnumber, '', 'HE', $charge); |
896 |
} |
897 |
|
898 |
return $hold->unblessed; |
899 |
} |
900 |
|
901 |
=head2 ModReserve |
840 |
=head2 ModReserve |
902 |
|
841 |
|
903 |
ModReserve({ rank => $rank, |
842 |
ModReserve({ rank => $rank, |
904 |
- |
|
|