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

(-)a/C4/Reserves.pm (+37 lines)
Lines 1115-1120 sub ModReserve { Link Here
1115
1115
1116
    if ( $rank eq "del" ) {
1116
    if ( $rank eq "del" ) {
1117
        $hold->cancel( { cancellation_reason => $cancellation_reason } );
1117
        $hold->cancel( { cancellation_reason => $cancellation_reason } );
1118
    } elsif ( $rank eq "recall" ) {
1119
        if ( !$biblionumber ) {
1120
            $biblionumber = $hold->biblionumber;
1121
        }
1122
        my $biblio = Koha::Biblios->find($biblionumber);
1123
        if ( !$borrowernumber ) {
1124
            $borrowernumber = $hold->borrowernumber;
1125
        }
1126
        my $patron = Koha::Patrons->find($borrowernumber);
1127
        if ( $hold->item_level_hold ) {
1128
            if ( $hold->item->can_be_recalled( { patron => $patron, hold_convert => 1 } ) ) {
1129
                my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall(
1130
                    {
1131
                        patron         => $patron,
1132
                        biblio         => $biblio,
1133
                        branchcode     => $branchcode,
1134
                        expirationdate => $date,
1135
                        interface      => 'intranet',
1136
                        item           => $hold->item,
1137
                    }
1138
                );
1139
                $hold->cancel( { cancellation_reason => 'RECALLED' } );
1140
            }
1141
        } else {
1142
            if ( $biblio->can_be_recalled( { patron => $patron, hold_convert => 1 } ) ) {
1143
                my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall(
1144
                    {
1145
                        patron         => $patron,
1146
                        biblio         => $biblio,
1147
                        branchcode     => $branchcode,
1148
                        expirationdate => $date,
1149
                        interface      => 'intranet',
1150
                    }
1151
                );
1152
                $hold->cancel( { cancellation_reason => 'RECALLED' } );
1153
            }
1154
        }
1118
    } elsif ( $hold->found && $hold->priority eq '0' && $date ) {
1155
    } elsif ( $hold->found && $hold->priority eq '0' && $date ) {
1119
1156
1120
        # The only column that can be updated for a found hold is the expiration date
1157
        # The only column that can be updated for a found hold is the expiration date
(-)a/Koha/Biblio.pm (-1 / +3 lines)
Lines 2165-2170 sub recalls { Link Here
2165
2165
2166
Does biblio-level checks and returns the items attached to this biblio that are available for recall
2166
Does biblio-level checks and returns the items attached to this biblio that are available for recall
2167
2167
2168
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.
2169
2168
=cut
2170
=cut
2169
2171
2170
sub can_be_recalled {
2172
sub can_be_recalled {
Lines 2190-2196 sub can_be_recalled { Link Here
2190
    my @all_itemnumbers;
2192
    my @all_itemnumbers;
2191
    foreach my $item (@all_items) {
2193
    foreach my $item (@all_items) {
2192
        push( @all_itemnumbers, $item->itemnumber );
2194
        push( @all_itemnumbers, $item->itemnumber );
2193
        if ( $item->can_be_recalled( { patron => $patron } ) ) {
2195
        if ( $item->can_be_recalled( { patron => $patron, hold_convert => $params->{hold_convert} } ) ) {
2194
            push( @itemtypes,   $item->effective_itemtype );
2196
            push( @itemtypes,   $item->effective_itemtype );
2195
            push( @itemnumbers, $item->itemnumber );
2197
            push( @itemnumbers, $item->itemnumber );
2196
            push( @items,       $item );
2198
            push( @items,       $item );
(-)a/Koha/Item.pm (-3 / +8 lines)
Lines 2439-2444 sub recall { Link Here
2439
2439
2440
Does item-level checks and returns if items can be recalled by this borrower
2440
Does item-level checks and returns if items can be recalled by this borrower
2441
2441
2442
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.
2443
2442
=cut
2444
=cut
2443
2445
2444
sub can_be_recalled {
2446
sub can_be_recalled {
Lines 2500-2508 sub can_be_recalled { Link Here
2500
            ->count > 0 );
2502
            ->count > 0 );
2501
2503
2502
        # check if this patron has already reserved this item
2504
        # check if this patron has already reserved this item
2503
        return 0
2505
        unless ( $params->{hold_convert} ) {
2504
            if ( Koha::Holds->search( { itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber } )
2506
            return 0
2505
            ->count > 0 );
2507
                if (
2508
                Koha::Holds->search( { itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber } )
2509
                ->count > 0 );
2510
        }
2506
    }
2511
    }
2507
2512
2508
    # check item availability
2513
    # check item availability
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (+6 lines)
Lines 66-71 Link Here
66
                                    <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
66
                                    <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
67
                                [% END %]
67
                                [% END %]
68
                                <option value="del">del</option>
68
                                <option value="del">del</option>
69
                                [% IF Koha.Preference('UseRecalls') AND Koha.Preference('RecallsInterface') != 'opac' %]
70
                                    <option value="recall">recall</option>
71
                                [% END %]
69
                            </select>
72
                            </select>
70
                        [% ELSE %]
73
                        [% ELSE %]
71
                            <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]" />
74
                            <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]" />
Lines 81-86 Link Here
81
                                [% ELSE %]
84
                                [% ELSE %]
82
                                    <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
85
                                    <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
83
                                [% END %]
86
                                [% END %]
87
                                [% IF Koha.Preference('UseRecalls') AND Koha.Preference('RecallsInterface') != 'opac' %]
88
                                    <option value="recall">recall</option>
89
                                [% END %]
84
                            </select>
90
                            </select>
85
                        [% END %]
91
                        [% END %]
86
                    [% ELSE %]
92
                    [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt (-19 / +230 lines)
Lines 2-13 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
17
<title
9
    >[% FILTER collapse %]
18
    >[% FILTER collapse %]
10
        [% t("Existing recalls") | html %]
19
        [% t("Place a recall") | html %]
11
        &rsaquo; [% t("Recalls") | html %] &rsaquo; [% t("Koha") | html %]
20
        &rsaquo; [% t("Recalls") | html %] &rsaquo; [% t("Koha") | html %]
12
    [% END %]</title
21
    [% END %]</title
13
>
22
>
Lines 27-66 Link Here
27
            [% INCLUDE 'biblio-title.inc' link = 1 %]
36
            [% INCLUDE 'biblio-title.inc' link = 1 %]
28
        [% END %]
37
        [% END %]
29
        [% WRAPPER breadcrumb_item bc_active= 1 %]
38
        [% WRAPPER breadcrumb_item bc_active= 1 %]
30
            <span>Existing recalls</span>
39
            <span>Place a recall</span>
31
        [% END %]
40
        [% END %]
32
    [% END #/ WRAPPER breadcrumbs %]
41
    [% END #/ WRAPPER breadcrumbs %]
33
[% END #/ WRAPPER sub-header.inc %]
42
[% END #/ WRAPPER sub-header.inc %]
34
43
35
[% WRAPPER 'main-container.inc' aside='biblio-view-menu' %]
44
[% WRAPPER 'main-container.inc' aside='biblio-view-menu' %]
36
    <h1>Existing recalls</h1>
45
    <h1>Recalls</h1>
37
46
38
    [% IF Koha.Preference('UseRecalls') %]
47
    <h2>Place a recall on [% INCLUDE 'biblio-title.inc' link = 1 %]</h2>
39
        [% IF recalls.count %]
48
40
            <div class="page-section">
49
    [% IF patron %]
41
                <form method="post" action="/cgi-bin/koha/recalls/request.pl">
50
51
        [% IF error %]
52
            <div class="dialog alert"> Unable to place a recall. Check your circulation rules. </div>
53
        [% END %]
54
55
        <fieldset class="rows">
56
            <legend>Recall details</legend>
57
            <form id="recallform" action="/cgi-bin/koha/recalls/request.pl" method="post">
58
                <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]" />
59
60
                <ol>
61
                    <li>
62
                        <label for="borrowernumber">Patron:</label> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% INCLUDE 'patron-title.inc' %]</a>
63
                        <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
64
                    </li>
65
66
                    [% UNLESS ( single_branch_mode ) %]
67
                        <li>
68
                            <label for="pickup">Pick up at:</label>
69
                            <select name="pickup" id="pickup">
70
                                [% FOREACH branch IN branches %]
71
                                    [% IF branch.branchcode == patron.branchcode %]
72
                                        <option value="[% branch.branchcode | html %]" selected>[% Branches.GetName( branch.branchcode ) | html %]</option>
73
                                    [% ELSE %]
74
                                        <option value="[% branch.branchcode | html %]">[% Branches.GetName( branch.branchcode ) | html %]</option>
75
                                    [% END %]
76
                                [% END %]
77
                            </select>
78
                        </li>
79
                    [% END %]
80
81
                    <li> <label for="expirationdate">Recall not needed after:</label> <input type="text" name="expirationdate" id="expirationdate" size="20" class="flatpickr" /> </li>
82
                    <li> <label for="type">Recall next available item</label> <input type="checkbox" name="type" id="type" checked /> </li>
83
                </ol>
84
85
                <fieldset class="action">
86
                    [% INCLUDE 'csrf-token.inc' %]
87
                    <input type="hidden" name="op" value="cud-request" />
88
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]" />
89
                    [% IF error %]
90
                        <input type="submit" class="btn btn-default" value="Place recall" disabled="disabled" />
91
                    [% ELSE %]
92
                        <input type="submit" class="btn btn-default" value="Place recall" />
93
                    [% END %]
94
                    <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% biblio.biblionumber | uri %]" class="cancel">Cancel</a>
95
                </fieldset>
96
97
                <table id="items">
98
                    <caption>Place a recall on a specific item</caption>
99
                    <thead>
100
                        <tr>
101
                            <th>&nbsp;</th>
102
                            <th>Item type</th>
103
                            <th>Barcode</th>
104
                            [% UNLESS ( single_branch_mode ) %]
105
                                <th>Home library</th>
106
                                <th>Last location</th>
107
                            [% END %]
108
                            <th>Collection</th>
109
                            <th>Call number</th>
110
                            <th>Copy number</th>
111
                            <th>Vol no.</th>
112
                            <th>Information</th>
113
                        </tr>
114
                    </thead>
115
                    <tbody>
116
                        [% FOREACH item IN items %]
117
                            <tr>
118
                                <td>
119
                                    [% IF item.can_be_recalled( patron => patron ) %]
120
                                        <input type="radio" class="itemnumber" name="itemnumber" value="[% item.itemnumber | html %]" />
121
                                    [% ELSE %]
122
                                        <span class="error">
123
                                            <i class="fa fa-times fa-lg" title="Cannot be recalled"></i>
124
                                        </span>
125
                                    [% END %]
126
                                </td>
127
                                <td>[% ItemTypes.GetDescription( item.effective_itemtype ) | html %]</td>
128
                                <td>[% item.barcode | html %]</td>
129
                                [% UNLESS ( single_branch_mode ) %]
130
                                    <td>[% Branches.GetName( item.homebranch ) | html %]</td>
131
                                    <td>[% Branches.GetName( item.holdingbranch) | html %]</td>
132
                                [% END %]
133
                                <td>[% AuthorisedValues.GetByCode( 'CCODE', item.ccode, 1 ) | html %]</td>
134
                                <td>[% item.itemcallnumber | html %]</td>
135
                                <td>[% item.copynumber | html %]</td>
136
                                <td>[% item.enumchron | html %]</td>
137
                                <td>
138
                                    [% IF ( item.checkout ) %]
139
                                        <span class="checkedout">Due [% item.checkout.date_due | $KohaDates %]</span>
140
                                    [% ELSIF ( item.get_transfer ) %]
141
                                        <span class="intransit"
142
                                            >In transit from [% Branches.GetName( item.get_transfer.frombranch ) | html %] to [% Branches.GetName( item.get_transfer.tobranch ) | html %] since
143
                                            [% item.get_transfer.datesent | $KohaDates %]</span
144
                                        >
145
                                    [% END %]
146
                                    [% IF ( item.itemlost || item.withdrawn ) %]
147
                                        <span class="lost">Unavailable (lost or missing)</span>
148
                                    [% END %]
149
                                    [% IF ( item.notforloan ) %]
150
                                        <span class="notforloan">Not for loan ([% item.notforloan | html %])</span>
151
                                    [% END %]
152
                                    [% hold = item.current_holds.next %]
153
                                    [% IF ( item.recall ) %]
154
                                        <span class="waiting">
155
                                            [% IF ( item.recall.waiting_date ) %]
156
                                                Waiting for patron at [% Branches.GetName( item.recall.pickup_library_id ) | html %] since [% item.recall.waiting_date | $KohaDates %].
157
                                            [% ELSIF ( item.recall.item_id == item.itemnumber ) %]
158
                                                Recalled by patron expected at [% Branches.GetName( item.recall.pickup_library_id ) | html %] since [% item.recall.created_date | $KohaDates %].
159
                                            [% END %]
160
                                        </span>
161
                                    [% ELSIF ( hold.waitingdate ) %]
162
                                        <span class="waiting"> Waiting for patron at [% Branches.GetName( hold.branchcode ) | html %] since [% hold.waitingdate | $KohaDates %]. </span>
163
                                    [% ELSIF ( hold.borrowernumber == logged_in_user.borrowernumber ) %]
164
                                        <span class="waiting"> Patron has already placed a <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% patron.borrowernumber | uri %]#reserves">reserve</a> on this item. </span>
165
                                    [% END # / IF ( item.recall or hold ) %]
166
                                </td>
167
                            </tr>
168
                        [% END %]
169
                    </tbody>
170
                </table>
171
172
                <fieldset class="action">
42
                    [% INCLUDE 'csrf-token.inc' %]
173
                    [% INCLUDE 'csrf-token.inc' %]
43
                    <input type="hidden" name="op" value="cud-cancel_multiple_recalls" />
174
                    <input type="hidden" name="op" value="cud-request" />
44
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]" />
175
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]" />
45
                    <input type="checkbox" id="select_all" /> <span id="select_all_text">Select all</span>
176
                    [% IF error %]
46
                    [% INCLUDE 'recalls.inc' %]
177
                        <input type="submit" class="btn btn-default" value="Place recall" disabled="disabled" />
47
                    <fieldset class="action">
178
                    [% ELSE %]
48
                        <button type="submit" id="cancel_selected" class="btn btn-default btn-sm">Cancel selected recalls</button>
179
                        <input type="submit" class="btn btn-default" value="Place recall" />
49
                    </fieldset>
180
                    [% END %]
50
                </form>
181
                    <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% biblio.biblionumber | uri %]" class="cancel">Cancel</a>
51
            </div>
182
                </fieldset>
52
            <!-- /.page-section -->
183
            </form>
184
        </fieldset>
185
    [% ELSE %]
186
187
        [% IF Koha.Preference('RecallsInterface') == 'opac' %]
188
            <div class="dialog alert"> 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. </div>
53
        [% ELSE %]
189
        [% ELSE %]
54
            <div class="alert alert-info">No recalls have been made.</div>
190
            <fieldset>
191
                <h2>Search patrons</h2>
192
                <div id="circ_recalls_select" class="toptabs">
193
                    <ul class="nav nav-tabs" role="tablist">
194
                        <li role="presentation" class="active"><a href="#recalls_patronsearch_pane" aria-controls="recalls_patronsearch_pane" role="tab" data-toggle="tab">Patrons</a></li>
195
                    </ul>
196
                    <div class="tab-content">
197
                        <div id="recalls_patronsearch_pane" role="tabpanel" class="tab-pane active">
198
                            [% PROCESS patron_search_filters_simple %]
199
                            [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %]
200
                        </div>
201
                    </div>
202
                    <!-- /.tab-content -->
203
                </div>
204
            </fieldset>
205
        [% END %]
206
207
        <h2>Existing recalls</h2>
208
209
        [% IF Koha.Preference('UseRecalls') %]
210
            [% IF recalls.count %]
211
                <div class="page-section">
212
                    <form method="post" action="/cgi-bin/koha/recalls/request.pl">
213
                        [% INCLUDE 'csrf-token.inc' %]
214
                        <input type="hidden" name="op" value="cud-cancel_multiple_recalls" />
215
                        <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]" />
216
                        <input type="checkbox" id="select_all" /> <span id="select_all_text">Select all</span>
217
                        [% INCLUDE 'recalls.inc' %]
218
                        <fieldset class="action">
219
                            <button type="submit" id="cancel_selected" class="btn btn-default btn-sm">Cancel selected recalls</button>
220
                        </fieldset>
221
                    </form>
222
                </div>
223
                <!-- /.page-section -->
224
            [% ELSE %]
225
                <div class="alert alert-info">No recalls have been made.</div>
226
            [% END %]
227
        [% ELSE %]
228
            <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>
55
        [% END %]
229
        [% END %]
56
    [% ELSE %]
57
        <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>
58
    [% END %]
230
    [% END %]
59
[% END %]
231
[% END %]
60
232
61
[% MACRO jsinclude BLOCK %]
233
[% MACRO jsinclude BLOCK %]
62
    [% Asset.js("js/recalls.js") | $raw %]
234
    [% Asset.js("js/recalls.js") | $raw %]
63
    [% INCLUDE 'datatables.inc' %]
235
    [% INCLUDE 'datatables.inc' %]
236
    [% INCLUDE 'calendar.inc' %]
237
    [% SET url_biblio_params = "biblionumber=" _ biblio.biblionumber %]
238
    [% 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' %]
239
    <script>
240
        table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
241
        $(document).ready(function(){
242
            $("#recalls_patronsearch").on("submit", filter);
243
            [% UNLESS patron %]
244
                [% IF ( PatronAutoComplete ) %]
245
                    patron_autocomplete($("#search_patron_filter"), { 'link-to': 'recall', 'url-params': '[% url_biblio_params | url %]' });
246
                [% END %]
247
            [% END %]
248
            $("#items").dataTable($.extend(true, {}, dataTablesDefaults, {
249
                'bPaginate': false,
250
                "sDom": '<"top pager"ilf>t',
251
            }));
252
253
            //Override fieldset styling for dataTables search box
254
            $("div.top.pager").css("margin-left","1em");
255
            $(".dataTables_filter label").css({
256
                "width":"auto",
257
                "margin-right":"0em"
258
            });
259
            $("#type").click(function() {
260
                if(this.checked){
261
                    $("input[name=itemnumber]").each(function() {
262
                        $(this).prop("checked", false);
263
                    });
264
                }
265
            });
266
            $("input[name=itemnumber]").click(function() {
267
                $("input[name=itemnumber]").each(function() {
268
                    if(this.checked){
269
                        $("#type").prop("checked", false);
270
                    }
271
                });
272
            });
273
        });
274
    </script>
64
[% END %]
275
[% END %]
65
276
66
[% INCLUDE 'intranet-bottom.inc' %]
277
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+8 lines)
Lines 251-256 Link Here
251
                <p>No club with this name, please, try another</p>
251
                <p>No club with this name, please, try another</p>
252
            </div>
252
            </div>
253
        [% END %]
253
        [% END %]
254
255
        [% IF ( recallerror ) %]
256
            <div class="dialog alert">
257
                <h3>Hold cannot be converted to a recall</h3>
258
                <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>
259
            </div>
260
        [% END %]
261
254
        <fieldset>
262
        <fieldset>
255
            [% UNLESS multi_hold %]
263
            [% UNLESS multi_hold %]
256
                [% IF clubcount %]
264
                [% IF clubcount %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-1 / +3 lines)
Lines 756-762 function patron_autocomplete(node, options) { Link Here
756
                    ? "/cgi-bin/koha/circ/circulation.pl"
756
                    ? "/cgi-bin/koha/circ/circulation.pl"
757
                    : link_to == "reserve"
757
                    : link_to == "reserve"
758
                      ? "/cgi-bin/koha/reserve/request.pl"
758
                      ? "/cgi-bin/koha/reserve/request.pl"
759
                      : "/cgi-bin/koha/members/moremember.pl";
759
                      : link_to == "recall"
760
                        ? "/cgi-bin/koha/recalls/request.pl"
761
                        : "/cgi-bin/koha/members/moremember.pl";
760
            item.link +=
762
            item.link +=
761
                (url_params ? "?" + url_params + "&" : "?") +
763
                (url_params ? "?" + url_params + "&" : "?") +
762
                "borrowernumber=" +
764
                "borrowernumber=" +
(-)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 123-132 if ( C4::Context->preference('UseRecalls') and C4::Context->preference('RecallsI Link Here
123
                $error = 'failed';
129
                $error = 'failed';
124
            }
130
            }
125
        }
131
        }
126
    } elsif ( $op eq 'cud-cancel' ) {
127
        my $recall_id = $query->param('recall_id');
128
        Koha::Recalls->find($recall_id)->set_cancelled;
129
        print $query->redirect('/cgi-bin/koha/opac-user.pl');
130
    }
132
    }
131
133
132
    my $branches           = Koha::Libraries->search();
134
    my $branches           = Koha::Libraries->search();
(-)a/recalls/request.pl (-13 / +118 lines)
Lines 35-64 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
35
    }
35
    }
36
);
36
);
37
37
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 } );
41
my $biblio         = Koha::Biblios->find($biblionumber);
42
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
} elsif ( $op eq 'cud-request' ) {
50
51
    if (    C4::Context->preference('UseRecalls')
52
        and C4::Context->preference('RecallsInterface') ne 'opac'
53
        and $borrowernumber )
54
    {
55
        my $patron = Koha::Patrons->find($borrowernumber);
56
57
        unless ( $biblio->can_be_recalled( { patron => $patron } ) ) { $error = 'unavailable'; }
58
        my $items = Koha::Items->search( { biblionumber => $biblionumber } )->as_list;
59
60
        # check if already recalled
61
        my $recalled = $biblio->recalls->filter_by_current->search( { patron_id => $borrowernumber } )->count;
62
        if ( defined $recalled and $recalled > 0 ) {
63
            my $recalls_per_record = Koha::CirculationRules->get_effective_rule(
64
                {
65
                    categorycode => $patron->categorycode,
66
                    branchcode   => undef,
67
                    itemtype     => undef,
68
                    rule_name    => 'recalls_per_record'
69
                }
70
            );
71
            if (    defined $recalls_per_record
72
                and $recalls_per_record->rule_value
73
                and $recalled >= $recalls_per_record->rule_value )
74
            {
75
                $error = 'duplicate';
76
            }
77
        }
78
79
        if ( !defined $error ) {
80
            my $pickuploc  = $input->param('pickup');
81
            my $expdate    = $input->param('expirationdate');
82
            my $level      = $input->param('type');
83
            my $itemnumber = $input->param('itemnumber');
84
85
            my ( $recall, $due_interval, $due_date );
86
87
            if ( !defined $level and defined $itemnumber ) {
88
                my $item = Koha::Items->find($itemnumber);
89
                if ( $item->can_be_recalled( { patron => $patron } ) ) {
90
                    ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall(
91
                        {
92
                            patron         => $patron,
93
                            biblio         => $biblio,
94
                            branchcode     => $pickuploc,
95
                            item           => $item,
96
                            expirationdate => $expdate,
97
                            interface      => 'staff',
98
                        }
99
                    );
100
                } else {
101
                    $error = 'cannot';
102
                }
103
            } else {
104
                if ( $biblio->can_be_recalled( { patron => $patron } ) ) {
105
                    ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall(
106
                        {
107
                            patron         => $patron,
108
                            biblio         => $biblio,
109
                            branchcode     => $pickuploc,
110
                            expirationdate => $expdate,
111
                            interface      => 'staff',
112
                        }
113
                    );
114
                } else {
115
                    $error = 'cannot';
116
                }
117
            }
118
            if ( !defined $recall ) {
119
                $error = 'failed';
120
            } else {
121
122
                # successful recall, go back to Recalls tab
123
                print $input->redirect("/cgi-bin/koha/recalls/request.pl?biblionumber=$biblionumber");
124
            }
125
        }
126
    }
49
}
127
}
50
128
51
if ( $op eq 'list' ) {
129
if ($borrowernumber) {
52
    $recalls = Koha::Recalls->search( { biblio_id => $biblionumber, completed => 0 } );
130
    my $patron = Koha::Patrons->find($borrowernumber);
53
    $biblio  = Koha::Biblios->find($biblionumber);
131
132
    if (    C4::Context->preference('UseRecalls')
133
        and C4::Context->preference('RecallsInterface') ne 'opac'
134
        and $patron
135
        and $patron->borrowernumber )
136
    {
137
        if ( !$biblio->can_be_recalled( { patron => $patron } ) ) {
138
            $error = 1;
139
        }
140
141
        $template->param(
142
            patron => $patron,
143
        );
144
    }
54
}
145
}
55
146
147
my $recalls            = Koha::Recalls->search( { biblio_id => $biblionumber, completed => 0 } );
148
my $branches           = Koha::Libraries->search;
149
my $single_branch_mode = $branches->count == 1;
150
my $items              = Koha::Items->search( { biblionumber => $biblionumber } );
151
56
$template->param(
152
$template->param(
57
    recalls     => $recalls,
153
    recalls            => $recalls,
58
    recallsview => 1,
154
    recallsview        => 1,
59
    biblio      => $biblio,
155
    biblio             => $biblio,
60
    checkboxes  => 1,
156
    checkboxes         => 1,
157
    branches           => $branches,
158
    items              => $items,
159
    error              => $error,
160
    single_branch_mode => $single_branch_mode,
61
    C4::Search::enabled_staff_search_views,
161
    C4::Search::enabled_staff_search_views,
162
    attribute_type_codes => (
163
        C4::Context->preference('ExtendedPatronAttributes')
164
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
165
        : []
166
    ),
62
);
167
);
63
168
64
output_html_with_http_headers $input, $cookie, $template->output;
169
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/reserve/modrequest.pl (-1 / +13 lines)
Lines 46-51 my @branch = $query->multi_param('pickup'); Link Here
46
my @itemnumber      = $query->multi_param('itemnumber');
46
my @itemnumber      = $query->multi_param('itemnumber');
47
my @biblionumber    = $query->multi_param('biblionumber');
47
my @biblionumber    = $query->multi_param('biblionumber');
48
my $count           = @rank;
48
my $count           = @rank;
49
my $recallerror;
49
50
50
@biblionumber = uniq @biblionumber;
51
@biblionumber = uniq @biblionumber;
51
52
Lines 68-73 if ( $op eq 'cud-cancelall' || $op eq 'cud-modifyall' ) { Link Here
68
            $params->{reservedate} = $reservedates[$i] || undef;
69
            $params->{reservedate} = $reservedates[$i] || undef;
69
        }
70
        }
70
71
72
        if ( $rank[$i] eq 'recall' and !$recallerror ) {
73
            my $hold = Koha::Holds->find( $reserve_id[$i] );
74
            if ( !$hold->biblio->can_be_recalled( { patron => $hold->patron } ) ) {
75
                $recallerror = 1;
76
            }
77
        }
78
71
        try {
79
        try {
72
            ModReserve($params);
80
            ModReserve($params);
73
        } catch {
81
        } catch {
Lines 105-110 if ( $from eq 'borrower' ) { Link Here
105
    print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrower[0]");
113
    print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrower[0]");
106
} else {
114
} else {
107
    my $url = URI->new("/cgi-bin/koha/reserve/request.pl");
115
    my $url = URI->new("/cgi-bin/koha/reserve/request.pl");
108
    $url->query_form( biblionumber => [@biblionumber] );
116
    if ($recallerror) {
117
        $url->query_form( biblionumber => [@biblionumber], recallerror => 1 );
118
    } else {
119
        $url->query_form( biblionumber => [@biblionumber] );
120
    }
109
    print $query->redirect($url);
121
    print $query->redirect($url);
110
}
122
}
(-)a/reserve/request.pl (+5 lines)
Lines 750-755 $template->param( borrowernumber => $borrowernumber_hold ); Link Here
750
750
751
$template->param( failed_holds => \@failed_holds );
751
$template->param( failed_holds => \@failed_holds );
752
752
753
my $recallerror = $input->param('recallerror');
754
if ($recallerror) {
755
    $template->param( recallerror => 1 );
756
}
757
753
# printout the page
758
# printout the page
754
output_html_with_http_headers $input, $cookie, $template->output;
759
output_html_with_http_headers $input, $cookie, $template->output;
755
760
(-)a/t/db_dependent/Holds.t (-1 / +79 lines)
Lines 2109-2111 subtest 'EmailPatronWhenHoldIsPlaced tests' => sub { Link Here
2109
2109
2110
    $schema->storage->txn_rollback;
2110
    $schema->storage->txn_rollback;
2111
};
2111
};
2112
- 
2112
2113
subtest 'ModReserve to convert a hold to a recall' => sub {
2114
    plan tests => 2;
2115
2116
    $schema->storage->txn_begin;
2117
2118
    my $category = $builder->build( { source => 'Category' } );
2119
    my $branch   = $builder->build( { source => 'Branch' } )->{branchcode};
2120
    my $biblio   = $builder->build_sample_biblio( { itemtype => 'DUMMY' } );
2121
    my $item     = $builder->build_sample_item( { library => $branch, biblionumber => $biblio->biblionumber } );
2122
2123
    my $patron = Koha::Patron->new(
2124
        {
2125
            firstname    => 'my firstname',
2126
            surname      => 'whatever surname',
2127
            categorycode => $category->{categorycode},
2128
            branchcode   => $branch,
2129
        }
2130
    )->store;
2131
    my $borrowernumber = $patron->borrowernumber;
2132
2133
    my $patron2 = Koha::Patron->new(
2134
        {
2135
            firstname    => 'my firstname',
2136
            surname      => 'whatever surname',
2137
            categorycode => $category->{categorycode},
2138
            branchcode   => $branch,
2139
        }
2140
    )->store;
2141
2142
    t::lib::Mocks::mock_preference( "UseRecalls", 1 );
2143
    t::lib::Mocks::mock_userenv( { branchcode => $branch } );
2144
2145
    C4::Circulation::AddIssue( $patron2->unblessed, $item->barcode );
2146
2147
    Koha::CirculationRules->set_rules(
2148
        {
2149
            branchcode   => undef,
2150
            categorycode => undef,
2151
            itemtype     => undef,
2152
            rules        => {
2153
                recalls_allowed    => 5,
2154
                recalls_per_record => 1,
2155
                on_shelf_recalls   => 'any',
2156
            },
2157
        }
2158
    );
2159
2160
    my $reserve_id = AddReserve(
2161
        {
2162
            branchcode     => $branch,
2163
            borrowernumber => $borrowernumber,
2164
            biblionumber   => $biblio->biblionumber,
2165
            priority       => C4::Reserves::CalculatePriority( $biblio->biblionumber ),
2166
            itemnumber     => $item->id,
2167
        }
2168
    );
2169
2170
    my $hold           = Koha::Holds->find($reserve_id);
2171
    my $before_recalls = Koha::Recalls->search->filter_by_current->count;
2172
2173
    ModReserve(
2174
        {
2175
            reserve_id     => $hold->id,
2176
            expirationdate => '1981-06-10',
2177
            priority       => 99,
2178
            rank           => "recall",
2179
            itemnumber     => $item->id,
2180
        }
2181
    );
2182
2183
    $hold = Koha::Holds->find($reserve_id);
2184
    my $after_recalls = Koha::Recalls->search->filter_by_current->count;
2185
2186
    ok( !defined $hold, 'Hold was cancelled' );
2187
    is( $after_recalls, $before_recalls + 1, 'Recall count increased by 1 as hold was converted to a recall' );
2188
2189
    $schema->storage->txn_rollback;
2190
};

Return to bug 31391