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

(-)a/C4/Reserves.pm (+34 lines)
Lines 1054-1059 sub ModReserve { Link Here
1054
    if ( $rank eq "del" ) {
1054
    if ( $rank eq "del" ) {
1055
        $hold->cancel({ cancellation_reason => $cancellation_reason });
1055
        $hold->cancel({ cancellation_reason => $cancellation_reason });
1056
    }
1056
    }
1057
    elsif ( $rank eq "recall" ) {
1058
        if ( !$biblionumber ) {
1059
            $biblionumber = $hold->biblionumber;
1060
        }
1061
        my $biblio = Koha::Biblios->find( $biblionumber );
1062
        if ( !$borrowernumber ) {
1063
            $borrowernumber = $hold->borrowernumber;
1064
        }
1065
        my $patron = Koha::Patrons->find( $borrowernumber );
1066
        if ( $hold->item_level_hold ) {
1067
            if ( $hold->item->can_be_recalled({ patron => $patron, hold_convert => 1 }) ) {
1068
                my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
1069
                    patron => $patron,
1070
                    biblio => $biblio,
1071
                    branchcode => $branchcode,
1072
                    expirationdate => $date,
1073
                    interface => 'intranet',
1074
                    item => $hold->item,
1075
                });
1076
                $hold->cancel({ cancellation_reason => 'RECALLED' });
1077
            }
1078
        } else {
1079
            if ( $biblio->can_be_recalled({ patron => $patron, hold_convert => 1 }) ) {
1080
                my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
1081
                    patron => $patron,
1082
                    biblio => $biblio,
1083
                    branchcode => $branchcode,
1084
                    expirationdate => $date,
1085
                    interface => 'intranet',
1086
                });
1087
                $hold->cancel({ cancellation_reason => 'RECALLED' });
1088
            }
1089
        }
1090
    }
1057
    elsif ($hold->found && $hold->priority eq '0' && $date) {
1091
    elsif ($hold->found && $hold->priority eq '0' && $date) {
1058
1092
1059
        # The only column that can be updated for a found hold is the expiration date
1093
        # The only column that can be updated for a found hold is the expiration date
(-)a/Koha/Biblio.pm (-1 / +3 lines)
Lines 2074-2079 sub recalls { Link Here
2074
2074
2075
Does biblio-level checks and returns the items attached to this biblio that are available for recall
2075
Does biblio-level checks and returns the items attached to this biblio that are available for recall
2076
2076
2077
if hold_convert $param is included, this is to say that this a check to convert a hold to a recall, so we should not check for an existing hold.
2078
2077
=cut
2079
=cut
2078
2080
2079
sub can_be_recalled {
2081
sub can_be_recalled {
Lines 2099-2105 sub can_be_recalled { Link Here
2099
    my @all_itemnumbers;
2101
    my @all_itemnumbers;
2100
    foreach my $item ( @all_items ) {
2102
    foreach my $item ( @all_items ) {
2101
        push( @all_itemnumbers, $item->itemnumber );
2103
        push( @all_itemnumbers, $item->itemnumber );
2102
        if ( $item->can_be_recalled({ patron => $patron }) ) {
2104
        if ( $item->can_be_recalled({ patron => $patron, hold_convert => $params->{hold_convert} }) ) {
2103
            push( @itemtypes, $item->effective_itemtype );
2105
            push( @itemtypes, $item->effective_itemtype );
2104
            push( @itemnumbers, $item->itemnumber );
2106
            push( @itemnumbers, $item->itemnumber );
2105
            push( @items, $item );
2107
            push( @items, $item );
(-)a/Koha/Item.pm (-1 / +5 lines)
Lines 2324-2329 sub recall { Link Here
2324
2324
2325
Does item-level checks and returns if items can be recalled by this borrower
2325
Does item-level checks and returns if items can be recalled by this borrower
2326
2326
2327
if hold_convert $param is included, this is to say that this a check to convert a hold to a recall, so we should not check for an existing hold.
2328
2327
=cut
2329
=cut
2328
2330
2329
sub can_be_recalled {
2331
sub can_be_recalled {
Lines 2375-2381 sub can_be_recalled { Link Here
2375
        return 0 if ( Koha::Checkouts->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
2377
        return 0 if ( Koha::Checkouts->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
2376
2378
2377
        # check if this patron has already reserved this item
2379
        # check if this patron has already reserved this item
2378
        return 0 if ( Koha::Holds->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
2380
        unless ( $params->{hold_convert} ) {
2381
            return 0 if ( Koha::Holds->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
2382
        }
2379
    }
2383
    }
2380
2384
2381
    # check item availability
2385
    # check item availability
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (+6 lines)
Lines 72-77 Link Here
72
                                <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
72
                                <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
73
                            [% END %]
73
                            [% END %]
74
                                <option value="del">del</option>
74
                                <option value="del">del</option>
75
                                [% IF Koha.Preference('UseRecalls') AND Koha.Preference('RecallsInterface') != 'opac' %]
76
                                    <option value="recall">recall</option>
77
                                [% END %]
75
                            </select>
78
                            </select>
76
                        [% ELSE %]
79
                        [% ELSE %]
77
                            <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]">
80
                            <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]">
Lines 87-92 Link Here
87
                            [% ELSE %]
90
                            [% ELSE %]
88
                                <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
91
                                <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
89
                            [% END %]
92
                            [% END %]
93
                                [% IF Koha.Preference('UseRecalls') AND Koha.Preference('RecallsInterface') != 'opac' %]
94
                                    <option value="recall">recall</option>
95
                                [% END %]
90
                            </select>
96
                            </select>
91
                        [% END %]
97
                        [% END %]
92
                    [% ELSE %]
98
                    [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt (-18 / +238 lines)
Lines 2-12 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE KohaDates %]
4
[% USE KohaDates %]
5
[% USE TablesSettings %]
6
[% USE Branches %]
7
[% USE Categories %]
8
[% USE AuthorisedValues %]
9
[% USE ItemTypes %]
10
[% SET libraries = Branches.all %]
11
[% SET categories = Categories.all.unblessed %]
12
[% SET columns = ['name', 'cardnumber', 'dateofbirth', 'category', 'branch', 'address', 'phone'] %]
13
[% PROCESS "patron-search.inc" %]
5
[% PROCESS 'i18n.inc' %]
14
[% PROCESS 'i18n.inc' %]
6
[% SET footerjs = 1 %]
15
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
16
[% INCLUDE 'doc-head-open.inc' %]
8
<title>[% FILTER collapse %]
17
<title>[% FILTER collapse %]
9
    [% t("Existing recalls") | html %] &rsaquo;
18
    [% t("Place a recall") | html %] &rsaquo;
10
    [% t("Recalls") | html %] &rsaquo;
19
    [% t("Recalls") | html %] &rsaquo;
11
    [% t("Koha") | html %]
20
    [% t("Koha") | html %]
12
[% END %]</title>
21
[% END %]</title>
Lines 26-32 Link Here
26
            [% INCLUDE 'biblio-title.inc' link = 1 %]
35
            [% INCLUDE 'biblio-title.inc' link = 1 %]
27
        [% END %]
36
        [% END %]
28
        [% WRAPPER breadcrumb_item bc_active= 1 %]
37
        [% WRAPPER breadcrumb_item bc_active= 1 %]
29
            <span>Existing recalls</span>
38
            <span>Place a recall</span>
30
        [% END %]
39
        [% END %]
31
    [% END #/ WRAPPER breadcrumbs %]
40
    [% END #/ WRAPPER breadcrumbs %]
32
[% END #/ WRAPPER sub-header.inc %]
41
[% END #/ WRAPPER sub-header.inc %]
Lines 37-63 Link Here
37
<main>
46
<main>
38
    [% INCLUDE 'messages.inc' %]
47
    [% INCLUDE 'messages.inc' %]
39
48
40
    <h1>Existing recalls</h1>
49
    <h1>Recalls</h1>
41
50
42
    [% IF Koha.Preference('UseRecalls') %]
51
    <h2>Place a recall on [% INCLUDE 'biblio-title.inc' link = 1 %]</h2>
43
        [% IF recalls.count %]
52
44
            <div class="page-section">
53
    [% IF patron %]
45
                <form method="post" action="/cgi-bin/koha/recalls/request.pl">
54
55
        [% IF error %]
56
            <div class="dialog alert">
57
                Unable to place a recall. Check your circulation rules.
58
            </div>
59
        [% END %]
60
61
        <fieldset class="rows">
62
            <legend>Recall details</legend>
63
            <form id="recallform" action="/cgi-bin/koha/recalls/request.pl" method="post">
64
                <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
65
66
                <ol>
67
                    <li>
68
                        <label for="borrowernumber">Patron:</label> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% INCLUDE 'patron-title.inc' %]</a>
69
                        <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]">
70
                    </li>
71
72
                    [% UNLESS ( single_branch_mode ) %]<li>
73
                        <label for="pickup">Pick up at:</label>
74
                        <select name="pickup" id="pickup">
75
                            [% FOREACH branch IN branches %]
76
                                [% IF branch.branchcode == patron.branchcode %]
77
                                    <option value="[% branch.branchcode | html %]" selected>[% Branches.GetName( branch.branchcode ) | html %]</option>
78
                                [% ELSE %]
79
                                    <option value="[% branch.branchcode | html %]">[% Branches.GetName( branch.branchcode ) | html %]</option>
80
                                [% END %]
81
                            [% END %]
82
                        </select>
83
                    </li>[% END %]
84
85
                    <li>
86
                        <label for="expirationdate">Recall not needed after:</label> <input type="text" name="expirationdate" id="expirationdate" size="20" class="flatpickr">
87
                    </li>
88
                    <li>
89
                        <label for="type">Recall next available item</label> <input type="checkbox" name="type" id="type" checked>
90
                    </li>
91
                </ol>
92
93
                <fieldset class="action">
94
                    [% INCLUDE 'csrf-token.inc' %]
95
                    <input type="hidden" name="op" value="cud-request">
96
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
97
                    [% IF error %]
98
                        <input type="submit" class="btn btn-default" value="Place recall" disabled="disabled">
99
                    [% ELSE %]
100
                        <input type="submit" class="btn btn-default" value="Place recall">
101
                    [% END %]
102
                    <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% biblio.biblionumber | uri %]" class="cancel">Cancel</a>
103
                </fieldset>
104
105
                <table id="items">
106
                    <caption>Place a recall on a specific item</caption>
107
                    <thead>
108
                    <tr>
109
                        <th>&nbsp;</th>
110
                        <th>Item type</th>
111
                        <th>Barcode</th>
112
                        [% UNLESS ( single_branch_mode ) %]
113
                            <th>Home library</th>
114
                            <th>Last location</th>
115
                        [% END %]
116
                        <th>Collection</th>
117
                        <th>Call number</th>
118
                        <th>Copy number</th>
119
                        <th>Vol no.</th>
120
                        <th>Information</th>
121
                    </tr>
122
                    </thead>
123
                    <tbody>
124
                    [% FOREACH item IN items %]<tr>
125
                    <td>
126
                        [% IF item.can_be_recalled( patron => patron ) %]
127
                            <input type="radio" class="itemnumber" name="itemnumber" value="[% item.itemnumber | html %]">
128
                        [% ELSE %]
129
                            <span class="error">
130
                                <i class="fa fa-times fa-lg" title="Cannot be recalled"></i>
131
                            </span>
132
                        [% END %]
133
                        </td>
134
                        <td>[% ItemTypes.GetDescription( item.effective_itemtype ) | html %]</td>
135
                        <td>[% item.barcode | html %]</td>
136
                        [% UNLESS ( single_branch_mode ) %]
137
                            <td>[% Branches.GetName( item.homebranch ) | html %]</td>
138
                            <td>[% Branches.GetName( item.holdingbranch) | html %]</td>
139
                        [% END %]
140
                        <td>[% AuthorisedValues.GetByCode( 'CCODE', item.ccode, 1 ) | html %]</td>
141
                        <td>[% item.itemcallnumber | html %]</td>
142
                        <td>[% item.copynumber | html %]</td>
143
                        <td>[% item.enumchron | html %]</td>
144
                        <td>
145
                            [% IF ( item.checkout ) %]
146
                                <span class="checkedout">Due [% item.checkout.date_due | $KohaDates %]</span>
147
                            [% ELSIF ( item.get_transfer ) %]
148
                                <span class="intransit">In transit from [% Branches.GetName( item.get_transfer.frombranch ) | html %] to [% Branches.GetName( item.get_transfer.tobranch ) | html %] since [% item.get_transfer.datesent | $KohaDates %]</span>
149
                            [% END %]
150
                            [% IF ( item.itemlost || item.withdrawn ) %]
151
                                <span class="lost">Unavailable (lost or missing)</span>
152
                            [% END %]
153
                            [% IF ( item.notforloan ) %]
154
                                <span class="notforloan">Not for loan ([% item.notforloan | html %])</span>
155
                            [% END %]
156
                            [% hold = item.current_holds.next %]
157
                            [% IF ( item.recall ) %]
158
                                <span class="waiting">
159
                                [% IF ( item.recall.waiting_date ) %]
160
                                    Waiting for patron at [% Branches.GetName( item.recall.pickup_library_id ) | html %] since [% item.recall.waiting_date | $KohaDates %].
161
                                [% ELSIF ( item.recall.item_id == item.itemnumber ) %]
162
                                    Recalled by patron expected at [% Branches.GetName( item.recall.pickup_library_id ) | html %] since [% item.recall.created_date | $KohaDates %].
163
                                [% END %]
164
                                </span>
165
                            [% ELSIF ( hold.waitingdate ) %]
166
                                <span class="waiting">
167
                                    Waiting for patron at [% Branches.GetName( hold.branchcode ) | html %] since [% hold.waitingdate | $KohaDates %].
168
                                </span>
169
                            [% ELSIF ( hold.borrowernumber == logged_in_user.borrowernumber ) %]
170
                                <span class="waiting">
171
                                    Patron has already placed a <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% patron.borrowernumber | uri %]#reserves">reserve</a> on this item.
172
                                </span>
173
                            [% END # / IF ( item.recall or hold ) %]
174
                        </td>
175
                    </tr>[% END %]
176
                    </tbody>
177
                </table>
178
179
                <fieldset class="action">
46
                    [% INCLUDE 'csrf-token.inc' %]
180
                    [% INCLUDE 'csrf-token.inc' %]
47
                    <input type="hidden" name="op" value="cud-cancel_multiple_recalls">
181
                    <input type="hidden" name="op" value="cud-request">
48
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
182
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
49
                    <input type="checkbox" id="select_all"> <span id="select_all_text">Select all</span>
183
                    [% IF error %]
50
                    [% INCLUDE 'recalls.inc' %]
184
                        <input type="submit" class="btn btn-default" value="Place recall" disabled="disabled">
51
                    <fieldset class="action">
185
                    [% ELSE %]
52
                        <button type="submit" id="cancel_selected" class="btn btn-default btn-sm">Cancel selected recalls</button>
186
                        <input type="submit" class="btn btn-default" value="Place recall">
53
                    </fieldset>
187
                    [% END %]
54
                </form>
188
                    <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% biblio.biblionumber | uri %]" class="cancel">Cancel</a>
55
            </div> <!-- /.page-section -->
189
                </fieldset>
190
            </form>
191
192
        </fieldset>
193
194
    [% ELSE %]
195
196
        [% IF Koha.Preference('RecallsInterface') == 'opac' %]
197
        <div class="dialog alert">
198
            Due to the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=RecallsInterface">RecallsInterface system preference</a>, recalls cannot be placed through the staff client.
199
        </div>
56
        [% ELSE %]
200
        [% ELSE %]
57
            <div class="alert alert-info">No recalls have been made.</div>
201
202
        <fieldset>
203
            <h2>Search patrons</h2>
204
            <div id="circ_recalls_select" class="toptabs">
205
                <ul class="nav nav-tabs" role="tablist">
206
                    <li role="presentation" class="active"><a href="#recalls_patronsearch_pane" aria-controls="recalls_patronsearch_pane" role="tab" data-toggle="tab">Patrons</a></li>
207
                </ul>
208
                <div class="tab-content">
209
                    <div id="recalls_patronsearch_pane" role="tabpanel" class="tab-pane active">
210
                        [% PROCESS patron_search_filters_simple %]
211
                        [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %]
212
                    </div>
213
                </div> <!-- /.tab-content -->
214
            </div>
215
        </fieldset>
216
58
        [% END %]
217
        [% END %]
59
    [% ELSE %]
218
60
        <div class="alert alert-info">Recalls have not been enabled. Enable the <a href="/cgi-bin/koha/admin/preferences.pl?tab=circulation">UseRecalls</a> system preference to use recalls.</div>
219
        <h2>Existing recalls</h2>
220
221
        [% IF Koha.Preference('UseRecalls') %]
222
            [% IF recalls.count %]
223
                <div class="page-section">
224
                    <form method="post" action="/cgi-bin/koha/recalls/request.pl">
225
                        [% INCLUDE 'csrf-token.inc' %]
226
                        <input type="hidden" name="op" value="cud-cancel_multiple_recalls">
227
                        <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
228
                        <input type="checkbox" id="select_all"> <span id="select_all_text">Select all</span>
229
                        [% INCLUDE 'recalls.inc' %]
230
                        <fieldset class="action">
231
                            <button type="submit" id="cancel_selected" class="btn btn-default btn-sm">Cancel selected recalls</button>
232
                        </fieldset>
233
                    </form>
234
                </div> <!-- /.page-section -->
235
            [% ELSE %]
236
                <div class="alert alert-info">No recalls have been made.</div>
237
            [% END %]
238
        [% ELSE %]
239
            <div class="alert alert-info">Recalls have not been enabled. Enable the <a href="/cgi-bin/koha/admin/preferences.pl?tab=circulation">UseRecalls</a> system preference to use recalls.</div>
240
        [% END %]
241
61
    [% END %]
242
    [% END %]
62
243
63
</main>
244
</main>
Lines 76-81 Link Here
76
    [% Asset.js("js/recalls.js") | $raw %]
257
    [% Asset.js("js/recalls.js") | $raw %]
77
    [% INCLUDE 'datatables.inc' %]
258
    [% INCLUDE 'datatables.inc' %]
78
    [% INCLUDE 'columns_settings.inc' %]
259
    [% INCLUDE 'columns_settings.inc' %]
260
    [% INCLUDE 'calendar.inc' %]
261
    [% SET url_biblio_params = "biblionumber=" _ biblio.biblionumber %]
262
    [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/recalls/request.pl?' _ url_biblio_params, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/recalls/request.pl?' _ url_biblio_params, redirect_if_attribute_equal => 'cardnumber' %]
263
    <script>
264
        table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
265
        $(document).ready(function(){
266
            $("#recalls_patronsearch").on("submit", filter);
267
            [% UNLESS patron %]
268
                [% IF ( PatronAutoComplete ) %]
269
                    patron_autocomplete($("#search_patron_filter"), { 'link-to': 'recall', 'url-params': '[% url_biblio_params | url %]' });
270
                [% END %]
271
            [% END %]
272
            $("#items").dataTable($.extend(true, {}, dataTablesDefaults, {
273
                'bPaginate': false,
274
                "sDom": '<"top pager"ilf>t',
275
            }));
276
277
            //Override fieldset styling for dataTables search box
278
            $("div.top.pager").css("margin-left","1em");
279
            $(".dataTables_filter label").css({
280
                "width":"auto",
281
                "margin-right":"0em"
282
            });
283
            $("#type").click(function() {
284
                if(this.checked){
285
                    $("input[name=itemnumber]").each(function() {
286
                        $(this).prop("checked", false);
287
                    });
288
                }
289
            });
290
            $("input[name=itemnumber]").click(function() {
291
                $("input[name=itemnumber]").each(function() {
292
                    if(this.checked){
293
                        $("#type").prop("checked", false);
294
                    }
295
                });
296
            });
297
        });
298
    </script>
79
[% END %]
299
[% END %]
80
300
81
[% INCLUDE 'intranet-bottom.inc' %]
301
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+8 lines)
Lines 255-260 Link Here
255
                        <p>No club with this name, please, try another</p>
255
                        <p>No club with this name, please, try another</p>
256
                    </div>
256
                    </div>
257
                [% END %]
257
                [% END %]
258
259
                [% IF ( recallerror ) %]
260
                    <div class="dialog alert">
261
                        <h3>Hold cannot be converted to a recall</h3>
262
                        <p>A recall cannot be placed on one or more holds. Check your <a href="/cgi-bin/koha/admin/smart-rules.pl">circulation and fine rules</a>.</p>
263
                    </div>
264
                [% END %]
265
258
                <fieldset>
266
                <fieldset>
259
                    [% UNLESS multi_hold %]
267
                    [% UNLESS multi_hold %]
260
                        [% IF clubcount %]
268
                        [% IF clubcount %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (+2 lines)
Lines 676-681 function patron_autocomplete(node, options) { Link Here
676
                    ? "/cgi-bin/koha/circ/circulation.pl"
676
                    ? "/cgi-bin/koha/circ/circulation.pl"
677
                    : link_to == "reserve"
677
                    : link_to == "reserve"
678
                    ? "/cgi-bin/koha/reserve/request.pl"
678
                    ? "/cgi-bin/koha/reserve/request.pl"
679
                    : link_to == 'recall'
680
                    ? "/cgi-bin/koha/recalls/request.pl"
679
                    : "/cgi-bin/koha/members/moremember.pl";
681
                    : "/cgi-bin/koha/members/moremember.pl";
680
            item.link +=
682
            item.link +=
681
                (url_params ? "?" + url_params + "&" : "?") +
683
                (url_params ? "?" + url_params + "&" : "?") +
(-)a/opac/opac-recall.pl (-4 / +6 lines)
Lines 36-41 my $op = $query->param('op') || ''; Link Here
36
my $biblionumber = $query->param('biblionumber');
36
my $biblionumber = $query->param('biblionumber');
37
my $biblio = Koha::Biblios->find( $biblionumber );
37
my $biblio = Koha::Biblios->find( $biblionumber );
38
38
39
if ($op eq 'cud-cancel'){
40
    my $recall_id = $query->param('recall_id');
41
    Koha::Recalls->find( $recall_id )->set_cancelled;
42
    print $query->redirect('/cgi-bin/koha/opac-user.pl');
43
}
44
39
if ( C4::Context->preference('UseRecalls') and C4::Context->preference('RecallsInterface') ne 'staff' ) {
45
if ( C4::Context->preference('UseRecalls') and C4::Context->preference('RecallsInterface') ne 'staff' ) {
40
46
41
    my $patron = Koha::Patrons->find( $borrowernumber );
47
    my $patron = Koha::Patrons->find( $borrowernumber );
Lines 112-121 if ( C4::Context->preference('UseRecalls') and C4::Context->preference('RecallsI Link Here
112
                $error = 'failed';
118
                $error = 'failed';
113
            }
119
            }
114
        }
120
        }
115
    } elsif ($op eq 'cud-cancel'){
116
        my $recall_id = $query->param('recall_id');
117
        Koha::Recalls->find( $recall_id )->set_cancelled;
118
        print $query->redirect('/cgi-bin/koha/opac-user.pl');
119
    }
121
    }
120
122
121
    my $branches = Koha::Libraries->search();
123
    my $branches = Koha::Libraries->search();
(-)a/recalls/request.pl (-5 / +93 lines)
Lines 38-64 my ($template, $loggedinuser, $cookie)= get_template_and_user( Link Here
38
my $op = $input->param('op') || 'list';
38
my $op = $input->param('op') || 'list';
39
my @recall_ids = $input->multi_param('recall_ids');
39
my @recall_ids = $input->multi_param('recall_ids');
40
my $biblionumber = $input->param('biblionumber');
40
my $biblionumber = $input->param('biblionumber');
41
my $recalls = Koha::Recalls->search({ biblio_id => $biblionumber, completed => 0 });
42
my $biblio = Koha::Biblios->find( $biblionumber );
41
my $biblio = Koha::Biblios->find( $biblionumber );
42
my $borrowernumber = $input->param('borrowernumber');
43
my $error = $input->param('error');
43
44
44
if ( $op eq 'cud-cancel_multiple_recalls' ) {
45
if ( $op eq 'cud-cancel_multiple_recalls' ) {
45
    foreach my $id ( @recall_ids ) {
46
    foreach my $id ( @recall_ids ) {
46
        Koha::Recalls->find( $id )->set_cancelled;
47
        Koha::Recalls->find( $id )->set_cancelled;
47
    }
48
    }
48
    $op = 'list'
49
}
49
}
50
elsif ( $op eq 'cud-request' ) {
51
52
    if ( C4::Context->preference('UseRecalls') and C4::Context->preference('RecallsInterface') ne 'opac' and $borrowernumber ) {
53
        my $patron = Koha::Patrons->find( $borrowernumber );
54
55
        unless ( $biblio->can_be_recalled({ patron => $patron }) ) { $error = 'unavailable'; }
56
        my $items = Koha::Items->search({ biblionumber => $biblionumber })->as_list;
57
58
        # check if already recalled
59
        my $recalled = $biblio->recalls->filter_by_current->search({ patron_id => $borrowernumber })->count;
60
        if ( defined $recalled and $recalled > 0 ) {
61
            my $recalls_per_record = Koha::CirculationRules->get_effective_rule({
62
                categorycode => $patron->categorycode,
63
                branchcode => undef,
64
                itemtype => undef,
65
                rule_name => 'recalls_per_record'
66
            });
67
            if ( defined $recalls_per_record and $recalls_per_record->rule_value and $recalled >= $recalls_per_record->rule_value ){
68
                $error = 'duplicate';
69
            }
70
        }
71
72
        if ( !defined $error ){
73
            my $pickuploc = $input->param('pickup');
74
            my $expdate = $input->param('expirationdate');
75
            my $level = $input->param('type');
76
            my $itemnumber = $input->param('itemnumber');
77
78
            my ( $recall, $due_interval, $due_date );
79
80
            if ( !defined $level and defined $itemnumber ) {
81
                my $item = Koha::Items->find( $itemnumber );
82
                if ( $item->can_be_recalled({ patron => $patron }) ) {
83
                    ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
84
                        patron => $patron,
85
                        biblio => $biblio,
86
                        branchcode => $pickuploc,
87
                        item => $item,
88
                        expirationdate => $expdate,
89
                        interface => 'staff',
90
                    });
91
                } else {
92
                    $error = 'cannot';
93
                }
94
            } else {
95
                if ( $biblio->can_be_recalled({ patron => $patron }) ) {
96
                    ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
97
                        patron => $patron,
98
                        biblio => $biblio,
99
                        branchcode => $pickuploc,
100
                        expirationdate => $expdate,
101
                        interface => 'staff',
102
                    });
103
                } else {
104
                    $error = 'cannot';
105
                }
106
            }
107
            if ( !defined $recall ) {
108
                $error = 'failed';
109
            } else {
110
                # successful recall, go back to Recalls tab
111
                print $input->redirect("/cgi-bin/koha/recalls/request.pl?biblionumber=$biblionumber");
112
            }
113
        }
114
    }
115
}
116
117
if ( $borrowernumber ) {
118
    my $patron = Koha::Patrons->find( $borrowernumber );
119
120
    if ( C4::Context->preference('UseRecalls') and C4::Context->preference('RecallsInterface') ne 'opac' and $patron and $patron->borrowernumber ) {
121
        if ( !$biblio->can_be_recalled({ patron => $patron }) ) {
122
            $error = 1;
123
        }
50
124
51
if ( $op eq 'list' ) {
125
        $template->param(
52
    $recalls = Koha::Recalls->search({ biblio_id => $biblionumber, completed => 0 });
126
            patron => $patron,
53
    $biblio = Koha::Biblios->find( $biblionumber );
127
        );
128
    }
54
}
129
}
55
130
131
my $recalls = Koha::Recalls->search({ biblio_id => $biblionumber, completed => 0 });
132
my $branches = Koha::Libraries->search;
133
my $single_branch_mode = $branches->count == 1;
134
my $items = Koha::Items->search({ biblionumber => $biblionumber });
135
56
$template->param(
136
$template->param(
57
    recalls     => $recalls,
137
    recalls     => $recalls,
58
    recallsview => 1,
138
    recallsview => 1,
59
    biblio      => $biblio,
139
    biblio      => $biblio,
60
    checkboxes  => 1,
140
    checkboxes  => 1,
141
    branches    => $branches,
142
    items       => $items,
143
    error       => $error,
144
    single_branch_mode => $single_branch_mode,
61
    C4::Search::enabled_staff_search_views,
145
    C4::Search::enabled_staff_search_views,
146
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
147
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
148
        : []
149
    ),
62
);
150
);
63
151
64
output_html_with_http_headers $input, $cookie, $template->output;
152
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/reserve/modrequest.pl (-1 / +13 lines)
Lines 47-52 my @branch = $query->multi_param('pickup'); Link Here
47
my @itemnumber = $query->multi_param('itemnumber');
47
my @itemnumber = $query->multi_param('itemnumber');
48
my @biblionumber = $query->multi_param('biblionumber');
48
my @biblionumber = $query->multi_param('biblionumber');
49
my $count=@rank;
49
my $count=@rank;
50
my $recallerror;
50
51
51
@biblionumber = uniq @biblionumber;
52
@biblionumber = uniq @biblionumber;
52
53
Lines 69-74 if( $op eq 'cud-cancelall' || $op eq 'cud-modifyall' ) { Link Here
69
            $params->{reservedate} = $reservedates[$i] || undef;
70
            $params->{reservedate} = $reservedates[$i] || undef;
70
        }
71
        }
71
72
73
        if ( $rank[$i] eq 'recall' and !$recallerror ) {
74
            my $hold = Koha::Holds->find( $reserve_id[$i] );
75
            if ( !$hold->biblio->can_be_recalled({ patron => $hold->patron }) ) {
76
                $recallerror = 1;
77
            }
78
        }
79
72
        try {
80
        try {
73
            ModReserve($params);
81
            ModReserve($params);
74
        } catch {
82
        } catch {
Lines 109-114 if ( $from eq 'borrower'){ Link Here
109
    print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrower[0]");
117
    print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrower[0]");
110
} else {
118
} else {
111
     my $url = URI->new("/cgi-bin/koha/reserve/request.pl");
119
     my $url = URI->new("/cgi-bin/koha/reserve/request.pl");
112
     $url->query_form( biblionumber => [@biblionumber]);
120
     if ( $recallerror ) {
121
         $url->query_form( biblionumber => [@biblionumber], recallerror => 1 );
122
     } else {
123
         $url->query_form( biblionumber => [@biblionumber] );
124
     }
113
     print $query->redirect($url);
125
     print $query->redirect($url);
114
}
126
}
(-)a/reserve/request.pl (+5 lines)
Lines 730-735 $template->param(borrowernumber => $borrowernumber_hold); Link Here
730
730
731
$template->param( failed_holds => \@failed_holds );
731
$template->param( failed_holds => \@failed_holds );
732
732
733
my $recallerror = $input->param('recallerror');
734
if ( $recallerror ) {
735
    $template->param( recallerror => 1 );
736
}
737
733
# printout the page
738
# printout the page
734
output_html_with_http_headers $input, $cookie, $template->output;
739
output_html_with_http_headers $input, $cookie, $template->output;
735
740
(-)a/t/db_dependent/Holds.t (-1 / +79 lines)
Lines 1879-1881 subtest 'EmailPatronWhenHoldIsPlaced tests' => sub { Link Here
1879
1879
1880
    $schema->storage->txn_rollback;
1880
    $schema->storage->txn_rollback;
1881
};
1881
};
1882
- 
1882
1883
subtest 'ModReserve to convert a hold to a recall' => sub {
1884
    plan tests => 2;
1885
1886
    $schema->storage->txn_begin;
1887
1888
    my $category = $builder->build({ source => 'Category' });
1889
    my $branch = $builder->build({ source => 'Branch' })->{ branchcode };
1890
    my $biblio = $builder->build_sample_biblio( { itemtype => 'DUMMY' } );
1891
    my $item = $builder->build_sample_item(
1892
        { library => $branch, biblionumber => $biblio->biblionumber } );
1893
1894
    my $patron = Koha::Patron->new(
1895
        {
1896
            firstname    => 'my firstname',
1897
            surname      => 'whatever surname',
1898
            categorycode => $category->{categorycode},
1899
            branchcode   => $branch,
1900
        }
1901
    )->store;
1902
    my $borrowernumber = $patron->borrowernumber;
1903
1904
    my $patron2 = Koha::Patron->new(
1905
        {
1906
            firstname    => 'my firstname',
1907
            surname      => 'whatever surname',
1908
            categorycode => $category->{categorycode},
1909
            branchcode   => $branch,
1910
        }
1911
    )->store;
1912
1913
    t::lib::Mocks::mock_preference("UseRecalls", 1);
1914
    t::lib::Mocks::mock_userenv( { branchcode => $branch } );
1915
1916
    C4::Circulation::AddIssue( $patron2->unblessed, $item->barcode );
1917
1918
    Koha::CirculationRules->set_rules({
1919
        branchcode => undef,
1920
        categorycode => undef,
1921
        itemtype => undef,
1922
        rules => {
1923
            recalls_allowed => 5,
1924
            recalls_per_record => 1,
1925
            on_shelf_recalls => 'any',
1926
        },
1927
    });
1928
1929
    my $reserve_id = AddReserve(
1930
        {
1931
            branchcode     => $branch,
1932
            borrowernumber => $borrowernumber,
1933
            biblionumber   => $biblio->biblionumber,
1934
            priority       =>
1935
              C4::Reserves::CalculatePriority( $biblio->biblionumber ),
1936
            itemnumber => $item->id,
1937
        }
1938
    );
1939
1940
    my $hold = Koha::Holds->find($reserve_id);
1941
    my $before_recalls = Koha::Recalls->search->filter_by_current->count;
1942
1943
    ModReserve(
1944
        {
1945
            reserve_id     => $hold->id,
1946
            expirationdate => '1981-06-10',
1947
            priority       => 99,
1948
            rank           => "recall",
1949
            itemnumber     => $item->id,
1950
        }
1951
    );
1952
1953
    $hold = Koha::Holds->find($reserve_id);
1954
    my $after_recalls = Koha::Recalls->search->filter_by_current->count;
1955
1956
    ok( !defined $hold, 'Hold was cancelled' );
1957
    is( $after_recalls, $before_recalls + 1, 'Recall count increased by 1 as hold was converted to a recall' );
1958
1959
    $schema->storage->txn_rollback;
1960
};

Return to bug 31391