Bug 22456: Allow requesting cancellation from the OPAC
Sponsored-by: Montgomery County Public Libraries Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
a40f8f697f
commit
f717314385
|
|
@ -152,10 +152,19 @@
|
|||
<td class="modify">
|
||||
[% IF ( HOLD.is_cancelable_from_opac ) %]
|
||||
<form id="delete_hold_[% HOLD.reserve_id | html %]" action="/cgi-bin/koha/opac-modrequest.pl" method="post">
|
||||
<input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
|
||||
<input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
|
||||
<button data-title="[% INCLUDE 'biblio-title-head.inc' biblio=HOLD.biblio %]" data-reserve_id="[% HOLD.reserve_id | html %]" type="submit" class="btn btn-sm btn-danger btn-delete-hold"><i class="fa fa-remove" aria-hidden="true"></i> [% tp('Cancel hold button', 'Cancel') | html %]</button>
|
||||
</form>
|
||||
<input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
|
||||
<input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
|
||||
<button data-title="[% INCLUDE 'biblio-title-head.inc' biblio=HOLD.biblio %]" data-reserve_id="[% HOLD.reserve_id | html %]" type="submit" class="btn btn-sm btn-danger btn-delete-hold"><i class="fa fa-remove" aria-hidden="true"></i> [% tp('Cancel hold button', 'Cancel') | html %]</button>
|
||||
</form>
|
||||
[% ELSIF HOLD.cancellation_requests.count > 0 %]
|
||||
<button type="submit" class="btn btn-sm btn-danger disabled"><i class="fa fa-remove" aria-hidden="true"></i> [% t('Cancellation requested') | html %]</button>
|
||||
[% ELSIF HOLD.is_waiting && HOLD.cancellation_requestable_from_opac %]
|
||||
<form id="req_cancel_hold_[% HOLD.reserve_id | html %]" action="/cgi-bin/koha/opac-modrequest.pl" method="post">
|
||||
<input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
|
||||
<input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
|
||||
<input type="hidden" name="cancellation_request" value="1" />
|
||||
<button data-title="[% INCLUDE 'biblio-title-head.inc' biblio=HOLD.biblio %]" data-reserve_id="[% HOLD.reserve_id | html %]" type="submit" class="btn btn-sm btn-danger btn-req-delete-hold"><i class="fa fa-remove" aria-hidden="true"></i> [% tp('Cancellation request hold button', 'Request cancellation') | html %]</button>
|
||||
</form>
|
||||
[% END %]
|
||||
</td>
|
||||
[% END # / IF onlyinfo %]
|
||||
|
|
|
|||
|
|
@ -1056,6 +1056,19 @@
|
|||
);
|
||||
});
|
||||
|
||||
$(".btn-req-delete-hold").on("click", function(e){
|
||||
e.preventDefault();
|
||||
var hold_title = $(this).data("title");
|
||||
var reserve_id = $(this).data("reserve_id");
|
||||
confirmModal( hold_title, _("Are you sure you want to request cancelling this hold?"), _("Yes"), _("No"), function( result ){
|
||||
$("#bootstrap-confirm-box-modal").remove()
|
||||
if( result ){
|
||||
$("#req_cancel_hold_" + reserve_id ).submit();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$(".btn-delete-article-request").on("click", function(e){
|
||||
e.preventDefault();
|
||||
var article_request = $(this).data("title");
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ use Modern::Perl;
|
|||
|
||||
use CGI qw ( -utf8 );
|
||||
use C4::Output;
|
||||
use C4::Reserves qw( CanReserveBeCanceledFromOpac );
|
||||
use C4::Auth qw( get_template_and_user );
|
||||
use Koha::Holds;
|
||||
|
||||
my $query = CGI->new;
|
||||
|
||||
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
||||
|
|
@ -40,11 +40,26 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
|||
);
|
||||
|
||||
my $reserve_id = $query->param('reserve_id');
|
||||
my $cancellation_request = $query->param('cancellation_request');
|
||||
|
||||
if ($reserve_id && $borrowernumber) {
|
||||
if ( CanReserveBeCanceledFromOpac($reserve_id, $borrowernumber) ) {
|
||||
my $hold = Koha::Holds->find( $reserve_id );
|
||||
$hold->cancel if $hold;
|
||||
if ( $reserve_id && $borrowernumber ) {
|
||||
|
||||
my $hold = Koha::Holds->find($reserve_id);
|
||||
|
||||
unless ( $hold->borrowernumber == $borrowernumber ) {
|
||||
|
||||
# whatcha tryin to do?
|
||||
print $query->redirect('/cgi-bin/koha/errors/403.pl');
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($cancellation_request) {
|
||||
$hold->add_cancellation_request
|
||||
if $hold->cancellation_requestable_from_opac;
|
||||
}
|
||||
else {
|
||||
$hold->cancel
|
||||
if $hold->is_cancelable_from_opac;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue