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

(-)a/C4/Reserves.pm (-5 / +9 lines)
Lines 1369-1379 sub SuspendAll { Link Here
1369
1369
1370
    my @holds = Koha::Holds->search($params);
1370
    my @holds = Koha::Holds->search($params);
1371
1371
1372
    if ($suspend) {
1372
    HOLD: foreach my $hold ( @holds ) {
1373
        map { $_->suspend_hold($suspend_until) } @holds;
1373
        if ($suspend) {
1374
    }
1374
            if ( $hold->biblio->itemtype ) {
1375
    else {
1375
                next HOLD if Koha::ItemTypes->find({ itemtype => $hold->biblio->itemtype })->can_suspend_hold == 0;
1376
        map { $_->resume() } @holds;
1376
            }
1377
            $hold->suspend_hold($suspend_until);
1378
        } else {
1379
            $hold->resume();
1380
        }
1377
    }
1381
    }
1378
}
1382
}
1379
1383
(-)a/Koha/Template/Plugin/ItemTypes.pm (+20 lines)
Lines 30-35 sub GetDescription { Link Here
30
    return $itemtype ? $itemtype->translated_description : q{};
30
    return $itemtype ? $itemtype->translated_description : q{};
31
}
31
}
32
32
33
sub CanSuspendHold {
34
    my ( $self, $itemtypecode ) = @_;
35
    my $itemtype = Koha::ItemTypes->find( $itemtypecode );
36
    if ( $itemtype ) {
37
        return $itemtype->can_suspend_hold;
38
    } else {
39
        return 1; # Default should be "yes"
40
    }
41
}
42
43
sub CanCancelHold {
44
    my ( $self, $itemtypecode ) = @_;
45
    my $itemtype = Koha::ItemTypes->find( $itemtypecode );
46
    if ( $itemtype ) {
47
        return $itemtype->can_cancel_hold;
48
    } else {
49
        return 1; # Default should be "yes"
50
    }
51
}
52
33
sub Get {
53
sub Get {
34
    return Koha::ItemTypes->search_with_localization->unblessed;
54
    return Koha::ItemTypes->search_with_localization->unblessed;
35
}
55
}
(-)a/admin/itemtypes.pl (+6 lines)
Lines 105-110 if ( $op eq 'add_form' ) { Link Here
105
    my $checkinmsgtype = $input->param('checkinmsgtype');
105
    my $checkinmsgtype = $input->param('checkinmsgtype');
106
    my $hideinopac     = $input->param('hideinopac') // 0;
106
    my $hideinopac     = $input->param('hideinopac') // 0;
107
    my $searchcategory = $input->param('searchcategory');
107
    my $searchcategory = $input->param('searchcategory');
108
    my $can_suspend_hold = $input->param('can_suspend_hold');
109
    my $can_cancel_hold  = $input->param('can_cancel_hold');
108
110
109
    if ( $itemtype and $is_a_modif ) {    # it's a modification
111
    if ( $itemtype and $is_a_modif ) {    # it's a modification
110
        $itemtype->description($description);
112
        $itemtype->description($description);
Lines 121-126 if ( $op eq 'add_form' ) { Link Here
121
        $itemtype->sip_media_type($sip_media_type);
123
        $itemtype->sip_media_type($sip_media_type);
122
        $itemtype->hideinopac($hideinopac);
124
        $itemtype->hideinopac($hideinopac);
123
        $itemtype->searchcategory($searchcategory);
125
        $itemtype->searchcategory($searchcategory);
126
        $itemtype->can_suspend_hold($can_suspend_hold);
127
        $itemtype->can_cancel_hold($can_cancel_hold);
124
128
125
        eval {
129
        eval {
126
          $itemtype->store;
130
          $itemtype->store;
Lines 150-155 if ( $op eq 'add_form' ) { Link Here
150
                sip_media_type      => $sip_media_type,
154
                sip_media_type      => $sip_media_type,
151
                hideinopac          => $hideinopac,
155
                hideinopac          => $hideinopac,
152
                searchcategory      => $searchcategory,
156
                searchcategory      => $searchcategory,
157
                can_suspend_hold    => $can_suspend_hold,
158
                can_cancel_hold     => $can_cancel_hold,
153
            }
159
            }
154
        );
160
        );
155
        eval {
161
        eval {
(-)a/installer/data/mysql/atomicupdate/bug_22833-block_suspend_and_cancel_holds.perl (+31 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
    unless ( column_exists('itemtypes', 'can_suspend_holds') ) {
5
        $dbh->do(
6
            qq{
7
                ALTER TABLE itemtypes
8
                ADD
9
                  can_suspend_hold TINYINT(1) DEFAULT 1 NOT NULL
10
                AFTER
11
                  searchcategory
12
              }
13
        );
14
    }
15
16
    unless ( column_exists('itemtypes', 'can_cancel_holds') ) {
17
        $dbh->do(
18
            qq{
19
                ALTER TABLE itemtypes
20
                ADD
21
                  can_cancel_hold TINYINT(1) DEFAULT 1 NOT NULL
22
                AFTER
23
                  can_suspend_holds
24
              }
25
        );
26
    }
27
28
    # Always end with this (adjust the bug info)
29
    SetVersion( $DBversion );
30
    print "Upgrade to $DBversion done (Bug 22833 - Block suspend and cancel on holds)\n";
31
}
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 934-939 CREATE TABLE `itemtypes` ( -- defines the item types Link Here
934
  sip_media_type VARCHAR(3) DEFAULT NULL, -- SIP2 protocol media type for this itemtype
934
  sip_media_type VARCHAR(3) DEFAULT NULL, -- SIP2 protocol media type for this itemtype
935
  hideinopac tinyint(1) NOT NULL DEFAULT 0, -- Hide the item type from the search options in OPAC
935
  hideinopac tinyint(1) NOT NULL DEFAULT 0, -- Hide the item type from the search options in OPAC
936
  searchcategory varchar(80) default NULL, -- Group this item type with others with the same value on OPAC search options
936
  searchcategory varchar(80) default NULL, -- Group this item type with others with the same value on OPAC search options
937
  can_suspend_hold TINYINT(1) DEFAULT 1 NOT NULL, -- Should patrons be able to suspend holds on records with this record level itemtype in the OPAC
938
  can_cancel_hold TINYINT(1) DEFAULT 1 NOT NULL, -- Should patrons be able to cancel holds on records with this record level itemtype in the OPAC
937
  PRIMARY KEY  (`itemtype`),
939
  PRIMARY KEY  (`itemtype`),
938
  UNIQUE KEY `itemtype` (`itemtype`)
940
  UNIQUE KEY `itemtype` (`itemtype`)
939
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
941
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (+18 lines)
Lines 286-291 Item types administration Link Here
286
                        [% END %]
286
                        [% END %]
287
                    </select>
287
                    </select>
288
                </li>
288
                </li>
289
                <li>
290
                    <label for="can_suspend_hold">Hold can be suspended in OPAC: </label>
291
                    [% IF ( itemtype.can_suspend_hold ) %]
292
                        <input type="checkbox" id="can_suspend_hold" name="can_suspend_hold" checked="checked" value="1" />
293
                    [% ELSE %]
294
                        <input type="checkbox" id="can_suspend_hold" name="can_suspend_hold" value="1" />
295
                    [% END %]
296
                    <span class="hint">If not checked, holds on records of this type can not be suspended in the OPAC or in bulk in the staff client.</span>
297
                </li>
298
                <li>
299
                    <label for="can_suspend_hold">Hold can be cancelled in OPAC: </label>
300
                    [% IF ( itemtype.can_cancel_hold ) %]
301
                        <input type="checkbox" id="can_cancel_hold" name="can_cancel_hold" checked="checked" value="1" />
302
                    [% ELSE %]
303
                        <input type="checkbox" id="can_cancel_hold" name="can_cancel_hold" value="1" />
304
                    [% END %]
305
                    <span class="hint">If not checked, holds on records of this type can not be cancelled in the OPAC.</span>
306
                </li>
289
                <li><label for="branches">Library limitation: </label>
307
                <li><label for="branches">Library limitation: </label>
290
                    <select id="branches" name="branches" multiple size="10">
308
                    <select id="branches" name="branches" multiple size="10">
291
                        <option value="">All libraries</option>
309
                        <option value="">All libraries</option>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc (-3 / +2 lines)
Lines 137-143 Link Here
137
                        </td>
137
                        </td>
138
                        [% IF SuspendHoldsOpac and ! onlyinfo %]
138
                        [% IF SuspendHoldsOpac and ! onlyinfo %]
139
                            <td>
139
                            <td>
140
                                [% IF ( HOLD.is_cancelable_from_opac ) %]
140
                                [% IF ( HOLD.is_cancelable_from_opac && ItemTypes.CanSuspendHold( HOLD.biblio.biblioitem.itemtype ) ) %]
141
                                    [% IF HOLD.suspend %]
141
                                    [% IF HOLD.suspend %]
142
                                        <form class="form-inline" action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
142
                                        <form class="form-inline" action="/cgi-bin/koha/opac-modrequest-suspend.pl" method="post">
143
                                            <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
143
                                            <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
Lines 183-189 Link Here
183
                        [% END # / IF SuspendHoldsOpac %]
183
                        [% END # / IF SuspendHoldsOpac %]
184
                        [% IF ! onlyinfo %]
184
                        [% IF ! onlyinfo %]
185
                            <td class="modify">
185
                            <td class="modify">
186
                                [% IF ( HOLD.is_cancelable_from_opac ) %]
186
                                [% IF ( HOLD.is_cancelable_from_opac && ItemTypes.CanCancelHold( HOLD.biblio.biblioitem.itemtype ) ) %]
187
                                    <form action="/cgi-bin/koha/opac-modrequest.pl" method="post">
187
                                    <form action="/cgi-bin/koha/opac-modrequest.pl" method="post">
188
                                    <input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
188
                                    <input type="hidden" name="biblionumber" value="[% HOLD.biblionumber | html %]" />
189
                                    <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
189
                                    <input type="hidden" name="reserve_id" value="[% HOLD.reserve_id | html %]" />
190
- 

Return to bug 22833