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

(-)a/C4/Reserves.pm (-4 / +6 lines)
Lines 970-975 sub ModReserve { Link Here
970
    my $suspend_until = $params->{'suspend_until'};
970
    my $suspend_until = $params->{'suspend_until'};
971
    my $borrowernumber = $params->{'borrowernumber'};
971
    my $borrowernumber = $params->{'borrowernumber'};
972
    my $biblionumber = $params->{'biblionumber'};
972
    my $biblionumber = $params->{'biblionumber'};
973
    my $cancellation_reason = $params->{'cancellation_reason'};
973
974
974
    return if $rank eq "W";
975
    return if $rank eq "W";
975
    return if $rank eq "n";
976
    return if $rank eq "n";
Lines 987-993 sub ModReserve { Link Here
987
    $hold ||= Koha::Holds->find($reserve_id);
988
    $hold ||= Koha::Holds->find($reserve_id);
988
989
989
    if ( $rank eq "del" ) {
990
    if ( $rank eq "del" ) {
990
        $hold->cancel;
991
        $hold->cancel({ cancellation_reason => $cancellation_reason });
991
    }
992
    }
992
    elsif ($rank =~ /^\d+/ and $rank > 0) {
993
    elsif ($rank =~ /^\d+/ and $rank > 0) {
993
        logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->unblessed) )
994
        logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->unblessed) )
Lines 1172-1178 sub ModReserveAffect { Link Here
1172
1173
1173
=head2 ModReserveCancelAll
1174
=head2 ModReserveCancelAll
1174
1175
1175
  ($messages,$nextreservinfo) = &ModReserveCancelAll($itemnumber,$borrowernumber);
1176
  ($messages,$nextreservinfo) = &ModReserveCancelAll($itemnumber,$borrowernumber,$reason);
1176
1177
1177
function to cancel reserv,check other reserves, and transfer document if it's necessary
1178
function to cancel reserv,check other reserves, and transfer document if it's necessary
1178
1179
Lines 1181-1192 function to cancel reserv,check other reserves, and transfer document if it's ne Link Here
1181
sub ModReserveCancelAll {
1182
sub ModReserveCancelAll {
1182
    my $messages;
1183
    my $messages;
1183
    my $nextreservinfo;
1184
    my $nextreservinfo;
1184
    my ( $itemnumber, $borrowernumber ) = @_;
1185
    my ( $itemnumber, $borrowernumber, $cancellation_reason ) = @_;
1186
    warn "RESON: $cancellation_reason";
1185
1187
1186
    #step 1 : cancel the reservation
1188
    #step 1 : cancel the reservation
1187
    my $holds = Koha::Holds->search({ itemnumber => $itemnumber, borrowernumber => $borrowernumber });
1189
    my $holds = Koha::Holds->search({ itemnumber => $itemnumber, borrowernumber => $borrowernumber });
1188
    return unless $holds->count;
1190
    return unless $holds->count;
1189
    $holds->next->cancel;
1191
    $holds->next->cancel({ cancellation_reason => $cancellation_reason });
1190
1192
1191
    #step 2 launch the subroutine of the others reserves
1193
    #step 2 launch the subroutine of the others reserves
1192
    ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber);
1194
    ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber);
(-)a/Koha/Hold.pm (+31 lines)
Lines 24-31 use Carp; Link Here
24
use Data::Dumper qw(Dumper);
24
use Data::Dumper qw(Dumper);
25
25
26
use C4::Context qw(preference);
26
use C4::Context qw(preference);
27
use C4::Letters;
27
use C4::Log;
28
use C4::Log;
28
29
30
use Koha::AuthorisedValues;
29
use Koha::DateUtils qw(dt_from_string output_pref);
31
use Koha::DateUtils qw(dt_from_string output_pref);
30
use Koha::Patrons;
32
use Koha::Patrons;
31
use Koha::Biblios;
33
use Koha::Biblios;
Lines 356-361 sub cancel { Link Here
356
        sub {
358
        sub {
357
            $self->cancellationdate( dt_from_string->strftime( '%Y-%m-%d %H:%M:%S' ) );
359
            $self->cancellationdate( dt_from_string->strftime( '%Y-%m-%d %H:%M:%S' ) );
358
            $self->priority(0);
360
            $self->priority(0);
361
            $self->cancellation_reason( $params->{cancellation_reason} );
359
            $self->_move_to_old;
362
            $self->_move_to_old;
360
            $self->SUPER::delete(); # Do not add a DELETE log
363
            $self->SUPER::delete(); # Do not add a DELETE log
361
364
Lines 379-384 sub cancel { Link Here
379
                );
382
                );
380
            }
383
            }
381
384
385
            if ( $params->{cancellation_reason} ) {
386
                my $letter = C4::Letters::GetPreparedLetter(
387
                    module                 => 'reserves',
388
                    letter_code            => 'HOLD_CANCELLATION',
389
                    message_transport_type => 'email',
390
                    branchcode             => $self->borrower->branchcode,
391
                    lang                   => $self->borrower->lang,
392
                    tables                 => {
393
                        branches    => $self->borrower->branchcode,
394
                        borrowers   => $self->borrowernumber,
395
                        items       => $self->itemnumber,
396
                        biblio      => $self->biblionumber,
397
                        biblioitems => $self->biblionumber,
398
                        reserves    => $self->unblessed,
399
                    }
400
                );
401
402
                if ($letter) {
403
                    C4::Letters::EnqueueLetter(
404
                        {
405
                            letter                   => $letter,
406
                            borrowernumber         => $self->borrowernumber,
407
                            message_transport_type => 'email',
408
                        }
409
                    );
410
                }
411
            }
412
382
            C4::Log::logaction( 'HOLDS', 'CANCEL', $self->reserve_id, Dumper($self->unblessed) )
413
            C4::Log::logaction( 'HOLDS', 'CANCEL', $self->reserve_id, Dumper($self->unblessed) )
383
                if C4::Context->preference('HoldsLog');
414
                if C4::Context->preference('HoldsLog');
384
        }
415
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (-3 / +14 lines)
Lines 1-4 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE AuthorisedValues %]
3
[% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
2
<table>
4
<table>
3
    <tr>
5
    <tr>
4
        [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
6
        [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
Lines 31-40 Link Here
31
                <input type="hidden" name="borrowernumber" value="[% hold.borrowernumber | html %]" />
33
                <input type="hidden" name="borrowernumber" value="[% hold.borrowernumber | html %]" />
32
                <input type="hidden" name="biblionumber" value="[% hold.biblionumber | html %]" />
34
                <input type="hidden" name="biblionumber" value="[% hold.biblionumber | html %]" />
33
                [% IF Koha.Preference('HoldsSplitQueue') == "nothing" && !hold.found %]
35
                [% IF Koha.Preference('HoldsSplitQueue') == "nothing" && !hold.found %]
34
                    <select name="rank-request">
36
                    <select name="rank-request" class="rank-request" data-hold-id="[% hold.reserve_id %]">
35
                [% ELSE %]
37
                [% ELSE %]
36
                    <input type="hidden" name="rank-request" value="[% hold.priority | html %]">
38
                    <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id %]">
37
                    <select name="rank-request" disabled="disabled">
39
                    <select name="rank-request" class="rank-request" disabled="disabled" data-hold-id="[% hold.reserve_id %]">
38
                [% END %]
40
                [% END %]
39
                    [% IF ( hold.found ) %]
41
                    [% IF ( hold.found ) %]
40
                        [% IF ( hold.intransit ) %]
42
                        [% IF ( hold.intransit ) %]
Lines 71-76 Link Here
71
73
72
                    <option value="del">del</option>
74
                    <option value="del">del</option>
73
                </select>
75
                </select>
76
77
                [% IF hold_cancellation %]
78
                    <select class="cancellation-reason" name="cancellation-reason-[% hold.reserve_id %]" id="cancellation-reason-[% hold.reserve_id %]" data-hold-id="[% hold.reserve_id %]">
79
                        <option value="">No reason given</option>
80
                        [% FOREACH reason IN hold_cancellation %]
81
                            <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
82
                        [% END %]
83
                    </select>
84
                [% END %]
74
            </td>
85
            </td>
75
86
76
            [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
87
            [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+10 lines)
Lines 939-944 Link Here
939
939
940
                                    <fieldset class="action">
940
                                    <fieldset class="action">
941
                                        <input type="submit" class="cancel" name="submit" value="Cancel marked holds" />
941
                                        <input type="submit" class="cancel" name="submit" value="Cancel marked holds" />
942
943
                                        [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
944
                                        [% IF hold_cancellation %]
945
                                            <select name="cancellation-reason">
946
                                                <option value="">No reason given</option>
947
                                                [% FOREACH reason IN hold_cancellation %]
948
                                                    <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
949
                                                [% END %]
950
                                            </select>
951
                                        [% END %]
942
                                    </fieldset>
952
                                    </fieldset>
943
                                </form>
953
                                </form>
944
954
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+10 lines)
Lines 819-824 Link Here
819
819
820
                                        <fieldset class="action">
820
                                        <fieldset class="action">
821
                                            <input type="submit" class="cancel" name="submit" value="Cancel marked holds" />
821
                                            <input type="submit" class="cancel" name="submit" value="Cancel marked holds" />
822
823
                                            [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
824
                                            [% IF hold_cancellation %]
825
                                                <select name="cancellation-reason">
826
                                                    <option value="">No reason given</option>
827
                                                    [% FOREACH reason IN hold_cancellation %]
828
                                                        <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
829
                                                    [% END %]
830
                                                </select>
831
                                            [% END %]
822
                                        </fieldset>
832
                                        </fieldset>
823
                                    </form>
833
                                    </form>
824
834
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+10 lines)
Lines 961-966 Link Here
961
        columns_settings_borrowers_table = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]
961
        columns_settings_borrowers_table = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]
962
962
963
        $(document).ready(function() {
963
        $(document).ready(function() {
964
            $(".cancellation-reason").hide();
965
            $(".rank-request").on("change", function(){
966
                const reserve_id = $(this).data('hold-id');
967
                if ( $(this).val() == "del" ) {
968
                    $(`#cancellation-reason-${reserve_id}`).show();
969
                } else {
970
                    $(`#cancellation-reason-${reserve_id}`).hide();
971
                }
972
            });
973
964
            [% SET active = clubs ? 1 : 0 %]
974
            [% SET active = clubs ? 1 : 0 %]
965
            $('#circ_holds_select').tabs({
975
            $('#circ_holds_select').tabs({
966
                active: [% active | $raw %],
976
                active: [% active | $raw %],
(-)a/reserve/modrequest.pl (-1 / +2 lines)
Lines 71-76 else { Link Here
71
    for (my $i=0;$i<$count;$i++){
71
    for (my $i=0;$i<$count;$i++){
72
        undef $itemnumber[$i] if !$itemnumber[$i];
72
        undef $itemnumber[$i] if !$itemnumber[$i];
73
        my $suspend_until = $query->param( "suspend_until_" . $reserve_id[$i] );
73
        my $suspend_until = $query->param( "suspend_until_" . $reserve_id[$i] );
74
        my $cancellation_reason = $query->param("cancellation-reason-$reserve_id[$i]") || $query->param("cancellation-reason");
74
        my $params = {
75
        my $params = {
75
            rank => $rank[$i],
76
            rank => $rank[$i],
76
            reserve_id => $reserve_id[$i],
77
            reserve_id => $reserve_id[$i],
Lines 78-83 else { Link Here
78
            branchcode => $branch[$i],
79
            branchcode => $branch[$i],
79
            itemnumber => $itemnumber[$i],
80
            itemnumber => $itemnumber[$i],
80
            defined $suspend_until ? ( suspend_until => $suspend_until ) : (),
81
            defined $suspend_until ? ( suspend_until => $suspend_until ) : (),
82
            cancellation_reason => $cancellation_reason,
81
        };
83
        };
82
        if (C4::Context->preference('AllowHoldDateInFuture')) {
84
        if (C4::Context->preference('AllowHoldDateInFuture')) {
83
            $params->{reservedate} = $reservedates[$i] ? dt_from_string($reservedates[$i]) : undef;
85
            $params->{reservedate} = $reservedates[$i] ? dt_from_string($reservedates[$i]) : undef;
84
- 

Return to bug 25534