View | Details | Raw Unified | Return to bug 22456
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc (-4 / +13 lines)
Lines 152-161 Link Here
152
                            <td class="modify">
152
                            <td class="modify">
153
                                [% IF ( HOLD.is_cancelable_from_opac ) %]
153
                                [% IF ( HOLD.is_cancelable_from_opac ) %]
154
                                    <form id="delete_hold_[% HOLD.reserve_id | html %]" action="/cgi-bin/koha/opac-modrequest.pl" method="post">
154
                                    <form id="delete_hold_[% HOLD.reserve_id | html %]" action="/cgi-bin/koha/opac-modrequest.pl" method="post">
155
                                    <input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
155
                                        <input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
156
                                    <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
156
                                        <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
157
                                    <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>
157
                                        <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>
158
                                </form>
158
                                    </form>
159
                                [% ELSIF HOLD.cancellation_requests.count > 0 %]
160
                                    <button type="submit" class="btn btn-sm btn-danger disabled"><i class="fa fa-remove" aria-hidden="true"></i> [% t('Cancellation requested') | html %]</button>
161
                                [% ELSIF HOLD.is_waiting && HOLD.cancellation_requestable_from_opac %]
162
                                    <form id="req_cancel_hold_[% HOLD.reserve_id | html %]" action="/cgi-bin/koha/opac-modrequest.pl" method="post">
163
                                        <input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
164
                                        <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
165
                                        <input type="hidden" name="cancellation_request" value="1" />
166
                                        <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>
167
                                    </form>
159
                                [% END %]
168
                                [% END %]
160
                            </td>
169
                            </td>
161
                        [% END # / IF onlyinfo %]
170
                        [% END # / IF onlyinfo %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+13 lines)
Lines 1056-1061 Link Here
1056
                );
1056
                );
1057
            });
1057
            });
1058
1058
1059
            $(".btn-req-delete-hold").on("click", function(e){
1060
                e.preventDefault();
1061
                var hold_title = $(this).data("title");
1062
                var reserve_id = $(this).data("reserve_id");
1063
                confirmModal( hold_title, _("Are you sure you want to request cancelling this hold?"), _("Yes"), _("No"), function( result ){
1064
                        $("#bootstrap-confirm-box-modal").remove()
1065
                        if( result ){
1066
                            $("#req_cancel_hold_" + reserve_id ).submit();
1067
                        }
1068
                    }
1069
                );
1070
            });
1071
1059
            $(".btn-delete-article-request").on("click", function(e){
1072
            $(".btn-delete-article-request").on("click", function(e){
1060
                e.preventDefault();
1073
                e.preventDefault();
1061
                var article_request = $(this).data("title");
1074
                var article_request = $(this).data("title");
(-)a/opac/opac-modrequest.pl (-6 / +20 lines)
Lines 26-34 use Modern::Perl; Link Here
26
26
27
use CGI qw ( -utf8 );
27
use CGI qw ( -utf8 );
28
use C4::Output;
28
use C4::Output;
29
use C4::Reserves qw( CanReserveBeCanceledFromOpac );
30
use C4::Auth qw( get_template_and_user );
29
use C4::Auth qw( get_template_and_user );
31
use Koha::Holds;
30
use Koha::Holds;
31
32
my $query = CGI->new;
32
my $query = CGI->new;
33
33
34
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
34
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Lines 40-50 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
40
);
40
);
41
41
42
my $reserve_id = $query->param('reserve_id');
42
my $reserve_id = $query->param('reserve_id');
43
my $cancellation_request = $query->param('cancellation_request');
44
45
if ( $reserve_id && $borrowernumber ) {
46
47
    my $hold = Koha::Holds->find($reserve_id);
48
49
    unless ( $hold->borrowernumber == $borrowernumber ) {
43
50
44
if ($reserve_id && $borrowernumber) {
51
        # whatcha tryin to do?
45
    if ( CanReserveBeCanceledFromOpac($reserve_id, $borrowernumber) ) {
52
        print $query->redirect('/cgi-bin/koha/errors/403.pl');
46
        my $hold = Koha::Holds->find( $reserve_id );
53
        exit;
47
        $hold->cancel if $hold;
54
    }
55
56
    if ($cancellation_request) {
57
        $hold->add_cancellation_request
58
          if $hold->cancellation_requestable_from_opac;
59
    }
60
    else {
61
        $hold->cancel
62
          if $hold->is_cancelable_from_opac;
48
    }
63
    }
49
}
64
}
50
65
51
- 

Return to bug 22456