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

(-)a/C4/Reserves.pm (+34 lines)
Lines 1132-1137 sub ModReserve { Link Here
1132
    if ( $rank eq "del" ) {
1132
    if ( $rank eq "del" ) {
1133
        $hold->cancel({ cancellation_reason => $cancellation_reason });
1133
        $hold->cancel({ cancellation_reason => $cancellation_reason });
1134
    }
1134
    }
1135
    elsif ( $rank eq "recall" ) {
1136
        if ( !$biblionumber ) {
1137
            $biblionumber = $hold->biblionumber;
1138
        }
1139
        my $biblio = Koha::Biblios->find( $biblionumber );
1140
        if ( !$borrowernumber ) {
1141
            $borrowernumber = $hold->borrowernumber;
1142
        }
1143
        my $patron = Koha::Patrons->find( $borrowernumber );
1144
        if ( $hold->item_level_hold ) {
1145
            if ( $hold->item->can_be_recalled({ patron => $patron, hold_convert => 1 }) ) {
1146
                my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
1147
                    patron => $patron,
1148
                    biblio => $biblio,
1149
                    branchcode => $branchcode,
1150
                    expirationdate => $date,
1151
                    interface => 'intranet',
1152
                    item => $hold->item,
1153
                });
1154
                $hold->cancel({ cancellation_reason => 'RECALLED' });
1155
            }
1156
        } else {
1157
            if ( $biblio->can_be_recalled({ patron => $patron, hold_convert => 1 }) ) {
1158
                my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
1159
                    patron => $patron,
1160
                    biblio => $biblio,
1161
                    branchcode => $branchcode,
1162
                    expirationdate => $date,
1163
                    interface => 'intranet',
1164
                });
1165
                $hold->cancel({ cancellation_reason => 'RECALLED' });
1166
            }
1167
        }
1168
    }
1135
    elsif ($hold->found && $hold->priority eq '0' && $date) {
1169
    elsif ($hold->found && $hold->priority eq '0' && $date) {
1136
        logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold )
1170
        logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold )
1137
            if C4::Context->preference('HoldsLog');
1171
            if C4::Context->preference('HoldsLog');
(-)a/Koha/Biblio.pm (-1 / +3 lines)
Lines 1785-1790 sub recalls { Link Here
1785
1785
1786
Does biblio-level checks and returns the items attached to this biblio that are available for recall
1786
Does biblio-level checks and returns the items attached to this biblio that are available for recall
1787
1787
1788
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.
1789
1788
=cut
1790
=cut
1789
1791
1790
sub can_be_recalled {
1792
sub can_be_recalled {
Lines 1810-1816 sub can_be_recalled { Link Here
1810
    my @all_itemnumbers;
1812
    my @all_itemnumbers;
1811
    foreach my $item ( @all_items ) {
1813
    foreach my $item ( @all_items ) {
1812
        push( @all_itemnumbers, $item->itemnumber );
1814
        push( @all_itemnumbers, $item->itemnumber );
1813
        if ( $item->can_be_recalled({ patron => $patron }) ) {
1815
        if ( $item->can_be_recalled({ patron => $patron, hold_convert => $params->{hold_convert} }) ) {
1814
            push( @itemtypes, $item->effective_itemtype );
1816
            push( @itemtypes, $item->effective_itemtype );
1815
            push( @itemnumbers, $item->itemnumber );
1817
            push( @itemnumbers, $item->itemnumber );
1816
            push( @items, $item );
1818
            push( @items, $item );
(-)a/Koha/Item.pm (-1 / +5 lines)
Lines 2085-2090 sub recall { Link Here
2085
2085
2086
Does item-level checks and returns if items can be recalled by this borrower
2086
Does item-level checks and returns if items can be recalled by this borrower
2087
2087
2088
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.
2089
2088
=cut
2090
=cut
2089
2091
2090
sub can_be_recalled {
2092
sub can_be_recalled {
Lines 2136-2142 sub can_be_recalled { Link Here
2136
        return 0 if ( Koha::Checkouts->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
2138
        return 0 if ( Koha::Checkouts->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
2137
2139
2138
        # check if this patron has already reserved this item
2140
        # check if this patron has already reserved this item
2139
        return 0 if ( Koha::Holds->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
2141
        unless ( $params->{hold_convert} ) {
2142
            return 0 if ( Koha::Holds->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
2143
        }
2140
    }
2144
    }
2141
2145
2142
    # check item availability
2146
    # check item availability
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (+6 lines)
Lines 68-73 Link Here
68
                                <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
68
                                <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
69
                            [% END %]
69
                            [% END %]
70
                                <option value="del">del</option>
70
                                <option value="del">del</option>
71
                                [% IF Koha.Preference('UseRecalls') AND Koha.Preference('RecallsInterface') != 'opac' %]
72
                                    <option value="recall">recall</option>
73
                                [% END %]
71
                            </select>
74
                            </select>
72
                        [% ELSE %]
75
                        [% ELSE %]
73
                            <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]">
76
                            <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]">
Lines 83-88 Link Here
83
                            [% ELSE %]
86
                            [% ELSE %]
84
                                <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
87
                                <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
85
                            [% END %]
88
                            [% END %]
89
                                [% IF Koha.Preference('UseRecalls') AND Koha.Preference('RecallsInterface') != 'opac' %]
90
                                    <option value="recall">recall</option>
91
                                [% END %]
86
                            </select>
92
                            </select>
87
                        [% END %]
93
                        [% END %]
88
                    [% ELSE %]
94
                    [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt (-18 / +237 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 36-61 Link Here
36
<div class="col-sm-10 col-sm-push-2">
45
<div class="col-sm-10 col-sm-push-2">
37
<main>
46
<main>
38
47
39
    <h1>Existing recalls</h1>
48
    <h1>Recalls</h1>
40
49
41
    [% IF Koha.Preference('UseRecalls') %]
50
=======
42
        [% IF recalls.count %]
51
    <h2>Place a recall on [% INCLUDE 'biblio-title.inc' link = 1 %]</h2>
43
            <div class="page-section">
52
44
                <form method="post" action="/cgi-bin/koha/recalls/request.pl">
53
    [% IF patron %]
45
                    <input type="hidden" name="op" value="cancel_multiple_recalls">
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
                    <input type="hidden" name="op" value="request">
95
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
96
                    [% IF error %]
97
                        <input type="submit" class="btn btn-default" value="Place recall" disabled="disabled">
98
                    [% ELSE %]
99
                        <input type="submit" class="btn btn-default" value="Place recall">
100
                    [% END %]
101
                    <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% biblio.biblionumber | uri %]" class="cancel">Cancel</a>
102
                </fieldset>
103
104
                <table id="items">
105
                    <caption>Place a recall on a specific item</caption>
106
                    <thead>
107
                    <tr>
108
                        <th>&nbsp;</th>
109
                        <th>Item type</th>
110
                        <th>Barcode</th>
111
                        [% UNLESS ( single_branch_mode ) %]
112
                            <th>Home library</th>
113
                            <th>Last location</th>
114
                        [% END %]
115
                        <th>Collection</th>
116
                        <th>Call number</th>
117
                        <th>Copy number</th>
118
                        <th>Vol no.</th>
119
                        <th>Information</th>
120
                    </tr>
121
                    </thead>
122
                    <tbody>
123
                    [% FOREACH item IN items %]<tr>
124
                    <td>
125
                        [% IF item.can_be_recalled( patron => patron ) %]
126
                            <input type="radio" class="itemnumber" name="itemnumber" value="[% item.itemnumber | html %]">
127
                        [% ELSE %]
128
                            <span class="error">
129
                                <i class="fa fa-times fa-lg" title="Cannot be recalled"></i>
130
                            </span>
131
                        [% END %]
132
                        </td>
133
                        <td>[% ItemTypes.GetDescription( item.effective_itemtype ) | html %]</td>
134
                        <td>[% item.barcode | html %]</td>
135
                        [% UNLESS ( single_branch_mode ) %]
136
                            <td>[% Branches.GetName( item.homebranch ) | html %]</td>
137
                            <td>[% Branches.GetName( item.holdingbranch) | html %]</td>
138
                        [% END %]
139
                        <td>[% AuthorisedValues.GetByCode( 'CCODE', item.ccode, 1 ) | html %]</td>
140
                        <td>[% item.itemcallnumber | html %]</td>
141
                        <td>[% item.copynumber | html %]</td>
142
                        <td>[% item.enumchron | html %]</td>
143
                        <td>
144
                            [% IF ( item.checkout ) %]
145
                                <span class="checkedout">Due [% item.checkout.date_due | $KohaDates %]</span>
146
                            [% ELSIF ( item.get_transfer ) %]
147
                                <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>
148
                            [% END %]
149
                            [% IF ( item.itemlost || item.withdrawn ) %]
150
                                <span class="lost">Unavailable (lost or missing)</span>
151
                            [% END %]
152
                            [% IF ( item.notforloan ) %]
153
                                <span class="notforloan">Not for loan ([% item.notforloan | html %])</span>
154
                            [% END %]
155
                            [% hold = item.current_holds.next %]
156
                            [% IF ( item.recall ) %]
157
                                <span class="waiting">
158
                                [% IF ( item.recall.waiting_date ) %]
159
                                    Waiting for patron at [% Branches.GetName( item.recall.pickup_library_id ) | html %] since [% item.recall.waiting_date | $KohaDates %].
160
                                [% ELSIF ( item.recall.item_id == item.itemnumber ) %]
161
                                    Recalled by patron expected at [% Branches.GetName( item.recall.pickup_library_id ) | html %] since [% item.recall.created_date | $KohaDates %].
162
                                [% END %]
163
                                </span>
164
                            [% ELSIF ( hold.waitingdate ) %]
165
                                <span class="waiting">
166
                                    Waiting for patron at [% Branches.GetName( hold.branchcode ) | html %] since [% hold.waitingdate | $KohaDates %].
167
                                </span>
168
                            [% ELSIF ( hold.borrowernumber == logged_in_user.borrowernumber ) %]
169
                                <span class="waiting">
170
                                    Patron has already placed a <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% patron.borrowernumber | uri %]#reserves">reserve</a> on this item.
171
                                </span>
172
                            [% END # / IF ( item.recall or hold ) %]
173
                        </td>
174
                    </tr>[% END %]
175
                    </tbody>
176
                </table>
177
178
                <fieldset class="action">
179
                    <input type="hidden" name="op" value="request">
46
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
180
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
47
                    <input type="checkbox" id="select_all"> <span id="select_all_text">Select all</span>
181
                    [% IF error %]
48
                    [% INCLUDE 'recalls.inc' %]
182
                        <input type="submit" class="btn btn-default" value="Place recall" disabled="disabled">
49
                    <fieldset class="action">
183
                    [% ELSE %]
50
                        <button type="submit" id="cancel_selected" class="btn btn-default btn-sm">Cancel selected recalls</button>
184
                        <input type="submit" class="btn btn-default" value="Place recall">
51
                    </fieldset>
185
                    [% END %]
52
                </form>
186
                    <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% biblio.biblionumber | uri %]" class="cancel">Cancel</a>
53
            </div> <!-- /.page-section -->
187
                </fieldset>
188
            </form>
189
190
        </fieldset>
191
192
    [% ELSE %]
193
194
        [% IF Koha.Preference('RecallsInterface') == 'opac' %]
195
        <div class="dialog alert">
196
            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.
197
        </div>
54
        [% ELSE %]
198
        [% ELSE %]
55
            <div class="dialog message">No recalls have been made.</div>
199
200
        <fieldset>
201
            <h2>Search patrons</h2>
202
            <div id="circ_recalls_select" class="toptabs">
203
                <ul class="nav nav-tabs" role="tablist">
204
                    <li role="presentation" class="active"><a href="#recalls_patronsearch_pane" aria-controls="recalls_patronsearch_pane" role="tab" data-toggle="tab">Patrons</a></li>
205
                </ul>
206
                <div class="tab-content">
207
                    <div id="recalls_patronsearch_pane" role="tabpanel" class="tab-pane active">
208
                        [% PROCESS patron_search_filters_simple %]
209
                        [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %]
210
                    </div>
211
                </div> <!-- /.tab-content -->
212
            </div>
213
        </fieldset>
214
56
        [% END %]
215
        [% END %]
57
    [% ELSE %]
216
58
        <div class="dialog message">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>
217
        <h2>Existing recalls</h2>
218
219
        [% IF Koha.Preference('UseRecalls') %]
220
            [% IF recalls.count %]
221
                <div class="page-section">
222
                    <form method="post" action="/cgi-bin/koha/recalls/request.pl">
223
                        <input type="hidden" name="op" value="cancel_multiple_recalls">
224
                        <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
225
                        <input type="checkbox" id="select_all"> <span id="select_all_text">Select all</span>
226
                        [% INCLUDE 'recalls.inc' %]
227
                        <fieldset class="action">
228
                            <button type="submit" id="cancel_selected" class="btn btn-default btn-sm">Cancel selected recalls</button>
229
                        </fieldset>
230
                    </form>
231
                </div> <!-- /.page-section -->
232
            [% ELSE %]
233
                <div class="dialog message">No recalls have been made.</div>
234
            [% END %]
235
        [% ELSE %]
236
            <div class="dialog message">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>
237
        [% END %]
238
59
    [% END %]
239
    [% END %]
60
240
61
</main>
241
</main>
Lines 74-79 Link Here
74
    [% Asset.js("js/recalls.js") | $raw %]
254
    [% Asset.js("js/recalls.js") | $raw %]
75
    [% INCLUDE 'datatables.inc' %]
255
    [% INCLUDE 'datatables.inc' %]
76
    [% INCLUDE 'columns_settings.inc' %]
256
    [% INCLUDE 'columns_settings.inc' %]
257
    [% INCLUDE 'calendar.inc' %]
258
    [% SET url_biblio_params = "biblionumber=" _ biblio.biblionumber %]
259
    [% 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' %]
260
    <script>
261
        table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
262
        $(document).ready(function(){
263
            $("#recalls_patronsearch").on("submit", filter);
264
            [% UNLESS patron %]
265
                [% IF ( PatronAutoComplete ) %]
266
                    patron_autocomplete($("#search_patron_filter"), { 'link-to': 'recall', 'url-params': '[% url_biblio_params | url %]' });
267
                [% END %]
268
            [% END %]
269
            $("#items").dataTable($.extend(true, {}, dataTablesDefaults, {
270
                'bPaginate': false,
271
                "sDom": '<"top pager"ilf>t',
272
            }));
273
274
            //Override fieldset styling for dataTables search box
275
            $("div.top.pager").css("margin-left","1em");
276
            $(".dataTables_filter label").css({
277
                "width":"auto",
278
                "margin-right":"0em"
279
            });
280
            $("#type").click(function() {
281
                if(this.checked){
282
                    $("input[name=itemnumber]").each(function() {
283
                        $(this).prop("checked", false);
284
                    });
285
                }
286
            });
287
            $("input[name=itemnumber]").click(function() {
288
                $("input[name=itemnumber]").each(function() {
289
                    if(this.checked){
290
                        $("#type").prop("checked", false);
291
                    }
292
                });
293
            });
294
        });
295
    </script>
77
[% END %]
296
[% END %]
78
297
79
[% INCLUDE 'intranet-bottom.inc' %]
298
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+8 lines)
Lines 208-213 Link Here
208
                        <p>No club with this name, please, try another</p>
208
                        <p>No club with this name, please, try another</p>
209
                    </div>
209
                    </div>
210
                [% END %]
210
                [% END %]
211
212
                [% IF ( recallerror ) %]
213
                    <div class="dialog alert">
214
                        <h3>Hold cannot be converted to a recall</h3>
215
                        <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>
216
                    </div>
217
                [% END %]
218
211
                <fieldset>
219
                <fieldset>
212
                    [% UNLESS multi_hold %]
220
                    [% UNLESS multi_hold %]
213
                        [% IF clubcount %]
221
                        [% IF clubcount %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-1 / +3 lines)
Lines 495-501 function patron_autocomplete(node, options) { Link Here
495
                    ? "/cgi-bin/koha/circ/circulation.pl"
495
                    ? "/cgi-bin/koha/circ/circulation.pl"
496
                    : link_to == 'reserve'
496
                    : link_to == 'reserve'
497
                        ? "/cgi-bin/koha/reserve/request.pl"
497
                        ? "/cgi-bin/koha/reserve/request.pl"
498
                        : "/cgi-bin/koha/members/moremember.pl";
498
                        : link_to == 'recall'
499
                            ? "/cgi-bin/koha/recalls/request.pl"
500
                            : "/cgi-bin/koha/members/moremember.pl";
499
                item.link += (url_params ? '?' + url_params + '&' : "?") + 'borrowernumber=' + item.patron_id;
501
                item.link += (url_params ? '?' + url_params + '&' : "?") + 'borrowernumber=' + item.patron_id;
500
            } else {
502
            } else {
501
                item.link = null;
503
                item.link = null;
(-)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 '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 '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 'cancel_multiple_recalls' ) {
45
if ( $op eq '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 '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 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 80-85 else { Link Here
80
            $params->{reservedate} = $reservedates[$i] || undef;
81
            $params->{reservedate} = $reservedates[$i] || undef;
81
        }
82
        }
82
83
84
        if ( $rank[$i] eq 'recall' and !$recallerror ) {
85
            my $hold = Koha::Holds->find( $reserve_id[$i] );
86
            if ( !$hold->biblio->can_be_recalled({ patron => $hold->patron }) ) {
87
                $recallerror = 1;
88
            }
89
        }
90
83
        try {
91
        try {
84
            ModReserve($params);
92
            ModReserve($params);
85
        } catch {
93
        } catch {
Lines 120-125 if ( $from eq 'borrower'){ Link Here
120
    print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrower[0]");
128
    print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrower[0]");
121
} else {
129
} else {
122
     my $url = URI->new("/cgi-bin/koha/reserve/request.pl");
130
     my $url = URI->new("/cgi-bin/koha/reserve/request.pl");
123
     $url->query_form( biblionumber => [@biblionumber]);
131
     if ( $recallerror ) {
132
         $url->query_form( biblionumber => [@biblionumber], recallerror => 1 );
133
     } else {
134
         $url->query_form( biblionumber => [@biblionumber] );
135
     }
124
     print $query->redirect($url);
136
     print $query->redirect($url);
125
}
137
}
(-)a/reserve/request.pl (+5 lines)
Lines 717-722 $template->param( pickup => $pickup || C4::Context->userenv->{branch} ); Link Here
717
717
718
$template->param(borrowernumber => $borrowernumber_hold);
718
$template->param(borrowernumber => $borrowernumber_hold);
719
719
720
my $recallerror = $input->param('recallerror');
721
if ( $recallerror ) {
722
    $template->param( recallerror => 1 );
723
}
724
720
# printout the page
725
# printout the page
721
output_html_with_http_headers $input, $cookie, $template->output;
726
output_html_with_http_headers $input, $cookie, $template->output;
722
727
(-)a/t/db_dependent/Holds.t (-1 / +79 lines)
Lines 1887-1889 subtest 'EmailPatronWhenHoldIsPlaced tests' => sub { Link Here
1887
1887
1888
    $schema->storage->txn_rollback;
1888
    $schema->storage->txn_rollback;
1889
};
1889
};
1890
- 
1890
1891
subtest 'ModReserve to convert a hold to a recall' => sub {
1892
    plan tests => 2;
1893
1894
    $schema->storage->txn_begin;
1895
1896
    my $category = $builder->build({ source => 'Category' });
1897
    my $branch = $builder->build({ source => 'Branch' })->{ branchcode };
1898
    my $biblio = $builder->build_sample_biblio( { itemtype => 'DUMMY' } );
1899
    my $item = $builder->build_sample_item(
1900
        { library => $branch, biblionumber => $biblio->biblionumber } );
1901
1902
    my $patron = Koha::Patron->new(
1903
        {
1904
            firstname    => 'my firstname',
1905
            surname      => 'whatever surname',
1906
            categorycode => $category->{categorycode},
1907
            branchcode   => $branch,
1908
        }
1909
    )->store;
1910
    my $borrowernumber = $patron->borrowernumber;
1911
1912
    my $patron2 = Koha::Patron->new(
1913
        {
1914
            firstname    => 'my firstname',
1915
            surname      => 'whatever surname',
1916
            categorycode => $category->{categorycode},
1917
            branchcode   => $branch,
1918
        }
1919
    )->store;
1920
1921
    t::lib::Mocks::mock_preference("UseRecalls", 1);
1922
    t::lib::Mocks::mock_userenv( { branchcode => $branch } );
1923
1924
    C4::Circulation::AddIssue( $patron2->unblessed, $item->barcode );
1925
1926
    Koha::CirculationRules->set_rules({
1927
        branchcode => undef,
1928
        categorycode => undef,
1929
        itemtype => undef,
1930
        rules => {
1931
            recalls_allowed => 5,
1932
            recalls_per_record => 1,
1933
            on_shelf_recalls => 'any',
1934
        },
1935
    });
1936
1937
    my $reserve_id = AddReserve(
1938
        {
1939
            branchcode     => $branch,
1940
            borrowernumber => $borrowernumber,
1941
            biblionumber   => $biblio->biblionumber,
1942
            priority       =>
1943
              C4::Reserves::CalculatePriority( $biblio->biblionumber ),
1944
            itemnumber => $item->id,
1945
        }
1946
    );
1947
1948
    my $hold = Koha::Holds->find($reserve_id);
1949
    my $before_recalls = Koha::Recalls->search->filter_by_current->count;
1950
1951
    ModReserve(
1952
        {
1953
            reserve_id     => $hold->id,
1954
            expirationdate => '1981-06-10',
1955
            priority       => 99,
1956
            rank           => "recall",
1957
            itemnumber     => $item->id,
1958
        }
1959
    );
1960
1961
    $hold = Koha::Holds->find($reserve_id);
1962
    my $after_recalls = Koha::Recalls->search->filter_by_current->count;
1963
1964
    ok( !defined $hold, 'Hold was cancelled' );
1965
    is( $after_recalls, $before_recalls + 1, 'Recall count increased by 1 as hold was converted to a recall' );
1966
1967
    $schema->storage->txn_rollback;
1968
};

Return to bug 31391