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

(-)a/C4/Reserves.pm (+34 lines)
Lines 1115-1120 sub ModReserve { Link Here
1115
    if ( $rank eq "del" ) {
1115
    if ( $rank eq "del" ) {
1116
        $hold->cancel({ cancellation_reason => $cancellation_reason });
1116
        $hold->cancel({ cancellation_reason => $cancellation_reason });
1117
    }
1117
    }
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
                    patron => $patron,
1131
                    biblio => $biblio,
1132
                    branchcode => $branchcode,
1133
                    expirationdate => $date,
1134
                    interface => 'intranet',
1135
                    item => $hold->item,
1136
                });
1137
                $hold->cancel({ cancellation_reason => 'RECALLED' });
1138
            }
1139
        } else {
1140
            if ( $biblio->can_be_recalled({ patron => $patron, hold_convert => 1 }) ) {
1141
                my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
1142
                    patron => $patron,
1143
                    biblio => $biblio,
1144
                    branchcode => $branchcode,
1145
                    expirationdate => $date,
1146
                    interface => 'intranet',
1147
                });
1148
                $hold->cancel({ cancellation_reason => 'RECALLED' });
1149
            }
1150
        }
1151
    }
1118
    elsif ($hold->found && $hold->priority eq '0' && $date) {
1152
    elsif ($hold->found && $hold->priority eq '0' && $date) {
1119
        logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold )
1153
        logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold )
1120
            if C4::Context->preference('HoldsLog');
1154
            if C4::Context->preference('HoldsLog');
(-)a/Koha/Biblio.pm (-1 / +3 lines)
Lines 1283-1288 sub recalls { Link Here
1283
1283
1284
Does biblio-level checks and returns the items attached to this biblio that are available for recall
1284
Does biblio-level checks and returns the items attached to this biblio that are available for recall
1285
1285
1286
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.
1287
1286
=cut
1288
=cut
1287
1289
1288
sub can_be_recalled {
1290
sub can_be_recalled {
Lines 1308-1314 sub can_be_recalled { Link Here
1308
    my @all_itemnumbers;
1310
    my @all_itemnumbers;
1309
    foreach my $item ( @all_items ) {
1311
    foreach my $item ( @all_items ) {
1310
        push( @all_itemnumbers, $item->itemnumber );
1312
        push( @all_itemnumbers, $item->itemnumber );
1311
        if ( $item->can_be_recalled({ patron => $patron }) ) {
1313
        if ( $item->can_be_recalled({ patron => $patron, hold_convert => $params->{hold_convert} }) ) {
1312
            push( @itemtypes, $item->effective_itemtype );
1314
            push( @itemtypes, $item->effective_itemtype );
1313
            push( @itemnumbers, $item->itemnumber );
1315
            push( @itemnumbers, $item->itemnumber );
1314
            push( @items, $item );
1316
            push( @items, $item );
(-)a/Koha/Item.pm (-1 / +5 lines)
Lines 1732-1737 sub recall { Link Here
1732
1732
1733
Does item-level checks and returns if items can be recalled by this borrower
1733
Does item-level checks and returns if items can be recalled by this borrower
1734
1734
1735
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.
1736
1735
=cut
1737
=cut
1736
1738
1737
sub can_be_recalled {
1739
sub can_be_recalled {
Lines 1783-1789 sub can_be_recalled { Link Here
1783
        return 0 if ( Koha::Checkouts->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
1785
        return 0 if ( Koha::Checkouts->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
1784
1786
1785
        # check if this patron has already reserved this item
1787
        # check if this patron has already reserved this item
1786
        return 0 if ( Koha::Holds->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
1788
        unless ( $params->{hold_convert} ) {
1789
            return 0 if ( Koha::Holds->search({ itemnumber => $self->itemnumber, borrowernumber => $patron->borrowernumber })->count > 0 );
1790
        }
1787
    }
1791
    }
1788
1792
1789
    # check item availability
1793
    # check item availability
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (+6 lines)
Lines 64-69 Link Here
64
                            <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
64
                            <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
65
                        [% END %]
65
                        [% END %]
66
                            <option value="del">del</option>
66
                            <option value="del">del</option>
67
                            [% IF Koha.Preference('UseRecalls') AND Koha.Preference('RecallsInterface') != 'opac' %]
68
                            <option value="recall">recall</option>
69
                            [% END %]
67
                        </select>
70
                        </select>
68
                    [% ELSE %]
71
                    [% ELSE %]
69
                        <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]">
72
                        <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]">
Lines 79-84 Link Here
79
                        [% ELSE %]
82
                        [% ELSE %]
80
                            <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
83
                            <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
81
                        [% END %]
84
                        [% END %]
85
                            [% IF Koha.Preference('UseRecalls') AND Koha.Preference('RecallsInterface') != 'opac' %]
86
                            <option value="recall">recall</option>
87
                            [% END %]
82
                        </select>
88
                        </select>
83
                    [% END %]
89
                    [% END %]
84
                [% ELSE %]
90
                [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/request.tt (-17 / +247 lines)
Lines 2-9 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 %]
5
[% SET footerjs = 1 %]
10
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
11
[% INCLUDE 'doc-head-open.inc' %]
12
[% SET libraries = Branches.all %]
13
[% SET categories = Categories.all.unblessed %]
14
[% SET columns = ['name', 'cardnumber', 'dateofbirth', 'category', 'branch', 'address', 'phone'] %]
15
[% PROCESS "patron-search.inc" %]
7
<title>Confirm recalls &rsaquo; Recalls &rsaquo; Koha</title>
16
<title>Confirm recalls &rsaquo; Recalls &rsaquo; Koha</title>
8
[% INCLUDE 'doc-head-close.inc' %]
17
[% INCLUDE 'doc-head-close.inc' %]
9
</head>
18
</head>
Lines 11-45 Link Here
11
[% INCLUDE 'header.inc' %]
20
[% INCLUDE 'header.inc' %]
12
[% INCLUDE 'circ-search.inc' %]
21
[% INCLUDE 'circ-search.inc' %]
13
22
14
<div id="breadcrumbs">
23
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
15
    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
24
    <ol>
16
    <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo;
25
        <li>
17
    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]">[% biblio.title | html %]</a> &rsaquo;
26
            <a href="/cgi-bin/koha/mainpage.pl">Home</a>
18
    Confirm recalls on [% biblio.title | html %]
27
        </li>
19
</div>
28
        <li>
29
            <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
30
        </li>
31
        <li>
32
            [% INCLUDE 'biblio-title.inc' link =1 %]
33
        </li>
34
        <li>
35
            <a href="#" aria-current="page">
36
                Place a recall
37
            </a>
38
        </li>
39
    </ol>
40
</nav>
20
41
21
<div class="main container-fluid">
42
<div class="main container-fluid">
22
<div class="row">
43
<div class="row">
23
<div class="col-sm-10 col-sm-push-2">
44
<div class="col-sm-10 col-sm-push-2">
24
<main>
45
<main>
25
46
26
    <h1>Existing recalls</h1>
47
    <h1>Recalls</h1>
48
49
    <h2>Place a recall on [% INCLUDE 'biblio-title.inc' link = 1 %]</h2>
50
51
    [% IF patron %]
52
53
        [% IF error %]
54
            <div class="dialog alert">
55
                Unable to place a recall. Check your circulation rules.
56
            </div>
57
        [% END %]
58
59
        <fieldset class="rows">
60
            <legend>Recall details</legend>
61
            <form id="recallform" action="/cgi-bin/koha/recalls/request.pl" method="post">
62
                <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
63
64
                <ol>
65
                    <li>
66
                        <label for="borrowernumber">Patron:</label> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% INCLUDE 'patron-title.inc' %]</a>
67
                        <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]">
68
                    </li>
69
70
                    [% UNLESS ( single_branch_mode ) %]<li>
71
                        <label for="pickup">Pick up at:</label>
72
                        <select name="pickup" id="pickup">
73
                            [% FOREACH branch IN branches %]
74
                                [% IF branch.branchcode == patron.branchcode %]
75
                                    <option value="[% branch.branchcode | html %]" selected>[% Branches.GetName( branch.branchcode ) | html %]</option>
76
                                [% ELSE %]
77
                                    <option value="[% branch.branchcode | html %]">[% Branches.GetName( branch.branchcode ) | html %]</option>
78
                                [% END %]
79
                            [% END %]
80
                        </select>
81
                    </li>[% END %]
82
83
                    <li>
84
                        <label for="expirationdate">Recall not needed after:</label> <input type="text" name="expirationdate" id="expirationdate" size="20" class="flatpickr">
85
                    </li>
86
                    <li>
87
                        <label for="type">Recall next available item</label> <input type="checkbox" name="type" id="type" checked>
88
                    </li>
89
                </ol>
90
91
                <fieldset class="action">
92
                    <input type="hidden" name="op" value="request">
93
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
94
                    [% IF error %]
95
                        <input type="submit" class="btn btn-default" value="Place recall" disabled="disabled">
96
                    [% ELSE %]
97
                        <input type="submit" class="btn btn-default" value="Place recall">
98
                    [% END %]
99
                    <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% biblio.biblionumber | uri %]" class="cancel">Cancel</a>
100
                </fieldset>
101
102
                <table id="items">
103
                    <caption>Place a recall on a specific item</caption>
104
                    <thead>
105
                    <tr>
106
                        <th>&nbsp;</th>
107
                        <th>Item type</th>
108
                        <th>Barcode</th>
109
                        [% UNLESS ( single_branch_mode ) %]
110
                            <th>Home library</th>
111
                            <th>Last location</th>
112
                        [% END %]
113
                        <th>Collection</th>
114
                        <th>Call number</th>
115
                        <th>Copy number</th>
116
                        <th>Vol no.</th>
117
                        <th>Information</th>
118
                    </tr>
119
                    </thead>
120
                    <tbody>
121
                    [% FOREACH item IN items %]<tr>
122
                    <td>
123
                        [% IF item.can_be_recalled( patron => patron ) %]
124
                            <input type="radio" class="itemnumber" name="itemnumber" value="[% item.itemnumber | html %]">
125
                        [% ELSE %]
126
                            <span class="error">
127
                                <i class="fa fa-times fa-lg" title="Cannot be recalled"></i>
128
                            </span>
129
                        [% END %]
130
                        </td>
131
                        <td>[% ItemTypes.GetDescription( item.effective_itemtype ) | html %]</td>
132
                        <td>[% item.barcode | html %]</td>
133
                        [% UNLESS ( single_branch_mode ) %]
134
                            <td>[% Branches.GetName( item.homebranch ) | html %]</td>
135
                            <td>[% Branches.GetName( item.holdingbranch) | html %]</td>
136
                        [% END %]
137
                        <td>[% AuthorisedValues.GetByCode( 'CCODE', item.ccode, 1 ) | html %]</td>
138
                        <td>[% item.itemcallnumber | html %]</td>
139
                        <td>[% item.copynumber | html %]</td>
140
                        <td>[% item.enumchron | html %]</td>
141
                        <td>
142
                            [% IF ( item.checkout ) %]
143
                                <span class="checkedout">Due [% item.checkout.date_due | $KohaDates %]</span>
144
                            [% ELSIF ( item.get_transfer ) %]
145
                                <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>
146
                            [% END %]
147
                            [% IF ( item.itemlost || item.withdrawn ) %]
148
                                <span class="lost">Unavailable (lost or missing)</span>
149
                            [% END %]
150
                            [% IF ( item.notforloan ) %]
151
                                <span class="notforloan">Not for loan ([% item.notforloan | html %])</span>
152
                            [% END %]
153
                            [% hold = item.current_holds.next %]
154
                            [% IF ( item.recall ) %]
155
                                <span class="waiting">
156
                                [% IF ( item.recall.waiting_date ) %]
157
                                    Waiting for patron at [% Branches.GetName( item.recall.pickup_library_id ) | html %] since [% item.recall.waiting_date | $KohaDates %].
158
                                [% ELSIF ( item.recall.item_id == item.itemnumber ) %]
159
                                    Recalled by patron expected at [% Branches.GetName( item.recall.pickup_library_id ) | html %] since [% item.recall.created_date | $KohaDates %].
160
                                [% END %]
161
                                </span>
162
                            [% ELSIF ( hold.waitingdate ) %]
163
                                <span class="waiting">
164
                                    Waiting for patron at [% Branches.GetName( hold.branchcode ) | html %] since [% hold.waitingdate | $KohaDates %].
165
                                </span>
166
                            [% ELSIF ( hold.borrowernumber == logged_in_user.borrowernumber ) %]
167
                                <span class="waiting">
168
                                    Patron has already placed a <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% patron.borrowernumber | uri %]#reserves">reserve</a> on this item.
169
                                </span>
170
                            [% END # / IF ( item.recall or hold ) %]
171
                        </td>
172
                    </tr>[% END %]
173
                    </tbody>
174
                </table>
27
175
28
    [% IF Koha.Preference('UseRecalls') %]
29
        [% IF recalls.count %]
30
            <form method="post" action="/cgi-bin/koha/recalls/request.pl">
31
                <input type="hidden" name="op" value="cancel_multiple_recalls">
32
                <input type="checkbox" id="select_all"> <span id="select_all_text">Select all</span>
33
                [% INCLUDE 'recalls.inc' %]
34
                <fieldset class="action">
176
                <fieldset class="action">
35
                    <button type="submit" id="cancel_selected" class="btn btn-default btn-sm">Cancel selected recalls</button>
177
                    <input type="hidden" name="op" value="request">
178
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
179
                    [% IF error %]
180
                        <input type="submit" class="btn btn-default" value="Place recall" disabled="disabled">
181
                    [% ELSE %]
182
                        <input type="submit" class="btn btn-default" value="Place recall">
183
                    [% END %]
184
                    <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% biblio.biblionumber | uri %]" class="cancel">Cancel</a>
36
                </fieldset>
185
                </fieldset>
37
            </form>
186
            </form>
187
188
        </fieldset>
189
190
    [% ELSE %]
191
192
        [% IF Koha.Preference('RecallsInterface') == 'opac' %]
193
        <div class="dialog alert">
194
            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.
195
        </div>
38
        [% ELSE %]
196
        [% ELSE %]
39
            <div class="dialog message">No recalls have been made.</div>
197
198
        <fieldset>
199
            <h2>Search patrons</h2>
200
            <div id="circ_recalls_select" class="toptabs">
201
                <ul class="nav nav-tabs" role="tablist">
202
                    <li role="presentation" class="active"><a href="#recalls_patronsearch_pane" aria-controls="recalls_patronsearch_pane" role="tab" data-toggle="tab">Patrons</a></li>
203
                </ul>
204
                <div class="tab-content">
205
                    <div id="recalls_patronsearch_pane" role="tabpanel" class="tab-pane active">
206
                        [% PROCESS patron_search_filters_simple %]
207
                        [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %]
208
                    </div>
209
                </div> <!-- /.tab-content -->
210
            </div>
211
        </fieldset>
212
40
        [% END %]
213
        [% END %]
41
    [% ELSE %]
214
42
        <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>
215
        <h2>Existing recalls</h2>
216
217
        [% IF Koha.Preference('UseRecalls') %]
218
            [% IF recalls.count %]
219
                <form method="post" action="/cgi-bin/koha/recalls/request.pl">
220
                    <input type="hidden" name="op" value="cancel_multiple_recalls">
221
                    <input type="checkbox" id="select_all"> <span id="select_all_text">Select all</span>
222
                    [% INCLUDE 'recalls.inc' %]
223
                    <fieldset class="action">
224
                        <button type="submit" id="cancel_selected" class="btn btn-default btn-sm">Cancel selected recalls</button>
225
                    </fieldset>
226
                </form>
227
            [% ELSE %]
228
                <div class="dialog message">No recalls have been made.</div>
229
            [% END %]
230
        [% ELSE %]
231
            <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>
232
        [% END %]
233
43
    [% END %]
234
    [% END %]
44
235
45
</main>
236
</main>
Lines 58-63 Link Here
58
    [% Asset.js("js/recalls.js") | $raw %]
249
    [% Asset.js("js/recalls.js") | $raw %]
59
    [% INCLUDE 'datatables.inc' %]
250
    [% INCLUDE 'datatables.inc' %]
60
    [% INCLUDE 'columns_settings.inc' %]
251
    [% INCLUDE 'columns_settings.inc' %]
252
    [% INCLUDE 'calendar.inc' %]
253
    [% SET url_biblio_params = "biblionumber=" _ biblio.biblionumber %]
254
    [% 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' %]
255
    <script>
256
        table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
257
        $(document).ready(function(){
258
            $("#recalls_patronsearch").on("submit", filter);
259
            [% UNLESS patron %]
260
                [% IF ( PatronAutoComplete ) %]
261
                    patron_autocomplete($("#search_patron_filter"), { 'link-to': 'recall', 'url-params': '[% url_biblio_params | url %]' });
262
                [% END %]
263
            [% END %]
264
            $("#items").dataTable($.extend(true, {}, dataTablesDefaults, {
265
                'bPaginate': false,
266
                "sDom": '<"top pager"ilf>t',
267
            }));
268
269
            //Override fieldset styling for dataTables search box
270
            $("div.top.pager").css("margin-left","1em");
271
            $(".dataTables_filter label").css({
272
                "width":"auto",
273
                "margin-right":"0em"
274
            });
275
            $("#type").click(function() {
276
                if(this.checked){
277
                    $("input[name=itemnumber]").each(function() {
278
                        $(this).prop("checked", false);
279
                    });
280
                }
281
            });
282
            $("input[name=itemnumber]").click(function() {
283
                $("input[name=itemnumber]").each(function() {
284
                    if(this.checked){
285
                        $("#type").prop("checked", false);
286
                    }
287
                });
288
            });
289
        });
290
    </script>
61
[% END %]
291
[% END %]
62
292
63
[% INCLUDE 'intranet-bottom.inc' %]
293
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (+8 lines)
Lines 216-221 Link Here
216
                        <p>No club with this name, please, try another</p>
216
                        <p>No club with this name, please, try another</p>
217
                    </div>
217
                    </div>
218
                [% END %]
218
                [% END %]
219
220
                [% IF ( recallerror ) %]
221
                    <div class="dialog alert">
222
                        <h3>Hold cannot be converted to a recall</h3>
223
                        <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>
224
                    </div>
225
                [% END %]
226
219
                <fieldset>
227
                <fieldset>
220
                    [% UNLESS multi_hold %]
228
                    [% UNLESS multi_hold %]
221
                        [% IF clubcount %]
229
                        [% IF clubcount %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js (-1 / +3 lines)
Lines 67-73 function patron_autocomplete(node, options) { Link Here
67
                ? "/cgi-bin/koha/circ/circulation.pl"
67
                ? "/cgi-bin/koha/circ/circulation.pl"
68
                : link_to == 'reserve'
68
                : link_to == 'reserve'
69
                    ? "/cgi-bin/koha/reserve/request.pl"
69
                    ? "/cgi-bin/koha/reserve/request.pl"
70
                    : "/cgi-bin/koha/members/moremember.pl";
70
                    : link_to == 'recall'
71
                        ? "/cgi-bin/koha/recalls/request.pl"
72
                        : "/cgi-bin/koha/members/moremember.pl";
71
            item.link += ( url_params ? '?' + url_params + '&' : "?" ) + 'borrowernumber=' + item.patron_id;
73
            item.link += ( url_params ? '?' + url_params + '&' : "?" ) + 'borrowernumber=' + item.patron_id;
72
        } else {
74
        } else {
73
            item.link = null;
75
            item.link = null;
(-)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 52-57 my @branch = $query->multi_param('pickup'); Link Here
52
my @itemnumber = $query->multi_param('itemnumber');
52
my @itemnumber = $query->multi_param('itemnumber');
53
my @biblionumber = $query->multi_param('biblionumber');
53
my @biblionumber = $query->multi_param('biblionumber');
54
my $count=@rank;
54
my $count=@rank;
55
my $recallerror;
55
56
56
@biblionumber = uniq @biblionumber;
57
@biblionumber = uniq @biblionumber;
57
58
Lines 86-91 else { Link Here
86
            $params->{reservedate} = $reservedates[$i] || undef;
87
            $params->{reservedate} = $reservedates[$i] || undef;
87
        }
88
        }
88
89
90
        if ( $rank[$i] eq 'recall' and !$recallerror ) {
91
            my $hold = Koha::Holds->find( $reserve_id[$i] );
92
            if ( !$hold->biblio->can_be_recalled({ patron => $hold->patron }) ) {
93
                $recallerror = 1;
94
            }
95
        }
96
89
        try {
97
        try {
90
            ModReserve($params);
98
            ModReserve($params);
91
        } catch {
99
        } catch {
Lines 112-117 if ( $from eq 'borrower'){ Link Here
112
    print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrower[0]");
120
    print $query->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrower[0]");
113
} else {
121
} else {
114
     my $url = URI->new("/cgi-bin/koha/reserve/request.pl");
122
     my $url = URI->new("/cgi-bin/koha/reserve/request.pl");
115
     $url->query_form( biblionumber => [@biblionumber]);
123
     if ( $recallerror ) {
124
         $url->query_form( biblionumber => [@biblionumber], recallerror => 1 );
125
     } else {
126
         $url->query_form( biblionumber => [@biblionumber] );
127
     }
116
     print $query->redirect($url);
128
     print $query->redirect($url);
117
}
129
}
(-)a/reserve/request.pl (+5 lines)
Lines 725-730 $template->param( Link Here
725
    borrowernumber => $borrowernumber_hold,
725
    borrowernumber => $borrowernumber_hold,
726
);
726
);
727
727
728
my $recallerror = $input->param('recallerror');
729
if ( $recallerror ) {
730
    $template->param( recallerror => 1 );
731
}
732
728
# printout the page
733
# printout the page
729
output_html_with_http_headers $input, $cookie, $template->output;
734
output_html_with_http_headers $input, $cookie, $template->output;
730
735
(-)a/t/db_dependent/Holds.t (-3 / +81 lines)
Lines 7-13 use t::lib::TestBuilder; Link Here
7
7
8
use C4::Context;
8
use C4::Context;
9
9
10
use Test::More tests => 75;
10
use Test::More tests => 76;
11
use Test::Exception;
11
use Test::Exception;
12
12
13
use MARC::Record;
13
use MARC::Record;
Lines 1795-1798 subtest 'Koha::Holds->get_items_that_can_fill returns items with datecancelled o Link Here
1795
    is($items_that_can_fill3->count, 1, "Koha::Holds->get_items_that_can_fill returns 1 item with correct parameters");
1795
    is($items_that_can_fill3->count, 1, "Koha::Holds->get_items_that_can_fill returns 1 item with correct parameters");
1796
    is($items_that_can_fill4->next, undef, "Koha::Holds->get_items_that_can_fill doesn't return item with undefined datearrived and undefined datecancelled");
1796
    is($items_that_can_fill4->next, undef, "Koha::Holds->get_items_that_can_fill doesn't return item with undefined datearrived and undefined datecancelled");
1797
    is($items_that_can_fill4->count, 0, "Koha::Holds->get_items_that_can_fill returns 0 item");
1797
    is($items_that_can_fill4->count, 0, "Koha::Holds->get_items_that_can_fill returns 0 item");
1798
}
1798
};
1799
1800
subtest 'ModReserve to convert a hold to a recall' => sub {
1801
    plan tests => 2;
1802
1803
    $schema->storage->txn_begin;
1804
1805
    my $category = $builder->build({ source => 'Category' });
1806
    my $branch = $builder->build({ source => 'Branch' })->{ branchcode };
1807
    my $biblio = $builder->build_sample_biblio( { itemtype => 'DUMMY' } );
1808
    my $item = $builder->build_sample_item(
1809
        { library => $branch, biblionumber => $biblio->biblionumber } );
1810
1811
    my $patron = Koha::Patron->new(
1812
        {
1813
            firstname    => 'my firstname',
1814
            surname      => 'whatever surname',
1815
            categorycode => $category->{categorycode},
1816
            branchcode   => $branch,
1817
        }
1818
    )->store;
1819
    my $borrowernumber = $patron->borrowernumber;
1820
1821
    my $patron2 = Koha::Patron->new(
1822
        {
1823
            firstname    => 'my firstname',
1824
            surname      => 'whatever surname',
1825
            categorycode => $category->{categorycode},
1826
            branchcode   => $branch,
1827
        }
1828
    )->store;
1829
1830
    t::lib::Mocks::mock_preference("UseRecalls", 1);
1831
    t::lib::Mocks::mock_userenv( { branchcode => $branch } );
1832
1833
    C4::Circulation::AddIssue( $patron2->unblessed, $item->barcode );
1834
1835
    Koha::CirculationRules->set_rules({
1836
        branchcode => undef,
1837
        categorycode => undef,
1838
        itemtype => undef,
1839
        rules => {
1840
            recalls_allowed => 5,
1841
            recalls_per_record => 1,
1842
            on_shelf_recalls => 'any',
1843
        },
1844
    });
1845
1846
    my $reserve_id = AddReserve(
1847
        {
1848
            branchcode     => $branch,
1849
            borrowernumber => $borrowernumber,
1850
            biblionumber   => $biblio->biblionumber,
1851
            priority       =>
1852
              C4::Reserves::CalculatePriority( $biblio->biblionumber ),
1853
            itemnumber => $item->id,
1854
        }
1855
    );
1856
1857
    my $hold = Koha::Holds->find($reserve_id);
1858
    my $before_recalls = Koha::Recalls->search->filter_by_current->count;
1859
1860
    ModReserve(
1861
        {
1862
            reserve_id     => $hold->id,
1863
            expirationdate => '1981-06-10',
1864
            priority       => 99,
1865
            rank           => "recall",
1866
            itemnumber     => $item->id,
1867
        }
1868
    );
1869
1870
    $hold = Koha::Holds->find($reserve_id);
1871
    my $after_recalls = Koha::Recalls->search->filter_by_current->count;
1872
1873
    ok( !defined $hold, 'Hold was cancelled' );
1874
    is( $after_recalls, $before_recalls + 1, 'Recall count increased by 1 as hold was converted to a recall' );
1875
1876
    $schema->storage->txn_rollback;
1877
};
1799
- 

Return to bug 31391