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

(-)a/C4/Reserves.pm (+20 lines)
Lines 1119-1124 sub ModReserve { Link Here
1119
    if ( $rank eq "del" ) {
1119
    if ( $rank eq "del" ) {
1120
        $hold->cancel({ cancellation_reason => $cancellation_reason });
1120
        $hold->cancel({ cancellation_reason => $cancellation_reason });
1121
    }
1121
    }
1122
    elsif ( $rank eq "recall" ) {
1123
        if ( !$biblionumber ) {
1124
            $biblionumber = $hold->biblionumber;
1125
        }
1126
        my $biblio = Koha::Biblios->find( $biblionumber );
1127
        if ( !$borrowernumber ) {
1128
            $borrowernumber = $hold->borrowernumber;
1129
        }
1130
        my $patron = Koha::Patrons->find( $borrowernumber );
1131
        if ( $biblio->can_be_recalled({ patron => $patron }) ) {
1132
            my ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
1133
                patron => $patron,
1134
                biblio => $biblio,
1135
                branchcode => $branchcode,
1136
                expirationdate => $date,
1137
                interface => 'intranet',
1138
            });
1139
            $hold->cancel({ cancellation_reason => 'RECALLED' });
1140
        }
1141
    }
1122
    elsif ($hold->found && $hold->priority eq '0' && $date) {
1142
    elsif ($hold->found && $hold->priority eq '0' && $date) {
1123
        logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold )
1143
        logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold )
1124
            if C4::Context->preference('HoldsLog');
1144
            if C4::Context->preference('HoldsLog');
(-)a/Koha/Item.pm (-1 / +3 lines)
Lines 1839-1848 sub can_be_waiting_recall { Link Here
1839
        $branchcode = ( C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ) ? $self->homebranch : $self->holdingbranch;
1839
        $branchcode = ( C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ) ? $self->homebranch : $self->holdingbranch;
1840
    }
1840
    }
1841
1841
1842
    my $maybe_recall = $self->check_recalls;
1843
1842
    # Check the circulation rule for each relevant itemtype for this item
1844
    # Check the circulation rule for each relevant itemtype for this item
1843
    my $rule = Koha::CirculationRules->get_effective_rules({
1845
    my $rule = Koha::CirculationRules->get_effective_rules({
1844
        branchcode => $branchcode,
1846
        branchcode => $branchcode,
1845
        categorycode => undef,
1847
        categorycode => $maybe_recall ? $maybe_recall->patron->categorycode : undef,
1846
        itemtype => $self->effective_itemtype,
1848
        itemtype => $self->effective_itemtype,
1847
        rules => [
1849
        rules => [
1848
            'recalls_allowed',
1850
            'recalls_allowed',
(-)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 / +216 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>Place a recall on [% INCLUDE 'biblio-title.inc' link = 1 %]</h1>
27
48
28
    [% IF Koha.Preference('UseRecalls') %]
49
    [% IF patron %]
29
        [% IF recalls.count %]
50
30
            <form method="post" action="/cgi-bin/koha/recalls/request.pl">
51
        [% IF error %]
31
                <input type="hidden" name="op" value="cancel_multiple_recalls">
52
            <div class="dialog alert">
32
                <input type="checkbox" id="select_all"> <span id="select_all_text">Select all</span>
53
                Unable to place a recall. Check your circulation rules.
33
                [% INCLUDE 'recalls.inc' %]
54
            </div>
55
        [% END %]
56
57
        <fieldset class="rows">
58
            <legend>Recall details</legend>
59
            <form id="recallform" action="/cgi-bin/koha/recalls/request.pl" method="post">
60
                <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
61
62
                <ol>
63
                    <li>
64
                        <label for="borrowernumber">Patron:</label> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% INCLUDE 'patron-title.inc' %]</a>
65
                        <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]">
66
                    </li>
67
68
                    [% UNLESS ( single_branch_mode ) %]<li>
69
                        <label for="pickup">Pick up location:</label>
70
                        <select name="pickup" id="pickup">
71
                            [% FOREACH branch IN branches %]
72
                                [% IF branch.branchcode == patron.branchcode %]
73
                                    <option value="[% branch.branchcode | html %]" selected>[% Branches.GetName( branch.branchcode ) | html %]</option>
74
                                [% ELSE %]
75
                                    <option value="[% branch.branchcode | html %]">[% Branches.GetName( branch.branchcode ) | html %]</option>
76
                                [% END %]
77
                            [% END %]
78
                        </select>
79
                    </li>[% END %]
80
81
                    <li><label for="expirationdate">Recall not needed after:</label> <input type="text" name="expirationdate" id="expirationdate" size="20" class="flatpickr"> <a id="cleartext" style="display:none;">Clear text</a><span id="expiration-hint">[% INCLUDE 'date-format.inc' %]</span></li>
82
                    <li class="level-option" style="display:none;"><label for="bibliolevel">Recall next available item</label> <input type="radio" name="type" id="bibliolevel" value="bibliolevel" checked></li>
83
                    <li class="level-option" style="display:none;"><label for="itemlevel">Recall a specific item</label> <input type="radio" name="type" id="itemlevel" value="itemlevel"></li>
84
85
                    <table id="items">
86
                        <caption>Select a specific item:</caption>
87
                        <tr>
88
                            <th>&nbsp;</th>
89
                            <th>Item type</th>
90
                            <th>Barcode</th>
91
                            [% UNLESS ( single_branch_mode ) %]
92
                                <th>Home library</th>
93
                                <th>Last location</th>
94
                            [% END %]
95
                            <th>Collection</th>
96
                            <th>Call number</th>
97
                            <th>Copy number</th>
98
                            <th>Vol info</th>
99
                            <th>Information</th>
100
                        </tr>
101
                        [% FOREACH item IN items %]<tr>
102
                        <td>
103
                            [% IF item.can_be_recalled( patron => patron ) %]
104
                                <input type="radio" class="itemnumber" name="itemnumber" value="[% item.itemnumber | html %]">
105
                            [% ELSE %]
106
                                <input disabled="disabled" type="radio" class="itemnumber" name="itemnumber" value="[% item.itemnumber | html %]" style="display:none;" />
107
                                <img src="[% interface | html %]/lib/famfamfam/cross.png" alt="Cannot be recalled" title="Cannot be recalled" />
108
                            [% END %]
109
                            </td>
110
                            <td>[% ItemTypes.GetDescription( item.effective_itemtype ) | html %]</td>
111
                            <td>[% item.barcode | html %]</td>
112
                            [% UNLESS ( single_branch_mode ) %]
113
                                <td>[% Branches.GetName( item.homebranch ) | html %]</td>
114
                                <td>[% Branches.GetName( item.holdingbranch) | html %]</td>
115
                            [% END %]
116
                            <td>[% AuthorisedValues.GetByCode( 'CCODE', item.ccode, 1 ) | html %]</td>
117
                            <td>[% item.itemcallnumber | html %]</td>
118
                            <td>[% item.copynumber | html %]</td>
119
                            <td>[% item.enumchron | html %]</td>
120
                            <td>
121
                                [% IF ( item.checkout ) %]
122
                                    <span class="checkedout">Due [% item.checkout.date_due | $KohaDates %]</span>
123
                                [% ELSIF ( item.get_transfer ) %]
124
                                    <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>
125
                                [% END %]
126
                                [% IF ( item.itemlost || item.withdrawn ) %]
127
                                    <span class="lost">Unavailable (lost or missing)</span>
128
                                [% END %]
129
                                [% IF ( item.notforloan ) %]
130
                                    <span class="notforloan">Not for loan ([% item.notforloan | html %])</span>
131
                                [% END %]
132
                                [% hold = item.current_holds.next %]
133
                                [% IF ( item.recall ) %]
134
                                    <span class="waiting">
135
                                    [% IF ( item.recall.waitingdate ) %]
136
                                        Waiting for patron at [% Branches.GetName( item.recall.branchcode ) | html %] since [% item.recall.waitingdate | $KohaDates %].
137
                                    [% ELSIF ( item.recall.itemnumber == item.itemnumber ) %]
138
                                        Recalled by patron expected at [% Branches.GetName( item.recall.branchcode ) | html %] since [% item.recall.recalldate | $KohaDates %].
139
                                    [% END %]
140
                                    </span>
141
                                [% ELSIF ( hold.waitingdate ) %]
142
                                    <span class="waiting">
143
                                        Waiting for patron at [% Branches.GetName( hold.branchcode ) | html %] since [% hold.waitingdate | $KohaDates %].
144
                                    </span>
145
                                [% ELSIF ( hold.borrowernumber == logged_in_user.borrowernumber ) %]
146
                                    <span class="waiting">
147
                                        Patron has already placed a <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% patron.borrowernumber | uri %]#reserves">reserve</a> on this item.
148
                                    </span>
149
                                [% END # / IF ( item.recall or hold ) %]
150
                            </td>
151
                        </tr>[% END %]
152
                    </table>
153
                </fieldset>
34
                <fieldset class="action">
154
                <fieldset class="action">
35
                    <button type="submit" id="cancel_selected" class="btn btn-default btn-sm">Cancel selected recalls</button>
155
                    <input type="hidden" name="op" value="request">
156
                    <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
157
                    [% IF error %]
158
                        <input type="submit" class="btn btn-primary" value="Confirm" disabled="disabled">
159
                    [% ELSE %]
160
                        <input type="submit" class="btn btn-primary" value="Confirm">
161
                    [% END %]
162
                    <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% biblio.biblionumber | uri %]" class="cancel">Cancel</a>
36
                </fieldset>
163
                </fieldset>
37
            </form>
164
            </form>
165
166
    [% ELSE %]
167
168
        [% IF Koha.Preference('RecallsInterface') == 'opac' %]
169
        <div class="dialog alert">
170
            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.
171
        </div>
38
        [% ELSE %]
172
        [% ELSE %]
39
            <div class="dialog message">No recalls have been made.</div>
173
174
        <fieldset>
175
            <h2>Search patrons</h2>
176
            <div id="circ_recalls_select" class="toptabs">
177
                <ul class="nav nav-tabs" role="tablist">
178
                    <li role="presentation" class="active"><a href="#recalls_patronsearch_pane" aria-controls="recalls_patronsearch_pane" role="tab" data-toggle="tab">Patrons</a></li>
179
                </ul>
180
                <div class="tab-content">
181
                    <div id="recalls_patronsearch_pane" role="tabpanel" class="tab-pane active">
182
                        [% PROCESS patron_search_filters_simple %]
183
                        [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %]
184
                    </div>
185
                </div> <!-- /.tab-content -->
186
            </div>
187
        </fieldset>
188
40
        [% END %]
189
        [% END %]
41
    [% ELSE %]
190
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>
191
        <h2>Existing recalls</h2>
192
193
        [% IF Koha.Preference('UseRecalls') %]
194
            [% IF recalls.count %]
195
                <form method="post" action="/cgi-bin/koha/recalls/request.pl">
196
                    <input type="hidden" name="op" value="cancel_multiple_recalls">
197
                    <input type="checkbox" id="select_all"> <span id="select_all_text">Select all</span>
198
                    [% INCLUDE 'recalls.inc' %]
199
                    <fieldset class="action">
200
                        <button type="submit" id="cancel_selected" class="btn btn-default btn-sm">Cancel selected recalls</button>
201
                    </fieldset>
202
                </form>
203
            [% ELSE %]
204
                <div class="dialog message">No recalls have been made.</div>
205
            [% END %]
206
        [% ELSE %]
207
            <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>
208
        [% END %]
209
43
    [% END %]
210
    [% END %]
44
211
45
</main>
212
</main>
Lines 58-63 Link Here
58
    [% Asset.js("js/recalls.js") | $raw %]
225
    [% Asset.js("js/recalls.js") | $raw %]
59
    [% INCLUDE 'datatables.inc' %]
226
    [% INCLUDE 'datatables.inc' %]
60
    [% INCLUDE 'columns_settings.inc' %]
227
    [% INCLUDE 'columns_settings.inc' %]
228
    [% INCLUDE 'calendar.inc' %]
229
    [% SET url_biblio_params = "biblionumber=" _ biblionumbers.join("&amp;biblionumber=") %]
230
    [% 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' %]
231
    <script>
232
        table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
233
        $(document).ready(function(){
234
            [% UNLESS findborrower %]
235
                [% IF ( PatronAutoComplete ) %]
236
                    patron_autocomplete($("#search_patron_filter"), { 'link-to': 'recall', 'url-params': '[% url_biblio_params | url %]' });
237
                [% END %]
238
            [% END %]
239
            $(".level-option").show();
240
            $("#cleartext").show();
241
            $("#items").hide();
242
            $("#expiration-hint").hide();
243
            $("#cleartext").click(function(){
244
                $(this).siblings("input").val("");
245
            });
246
            $("#itemlevel").click(function(){
247
                if ( $("#itemlevel").is(':checked') ){
248
                    $("#items").show();
249
                    $("input:radio[name='itemnumber']:not(:disabled)").first().attr("checked", "checked"); // selects first item in table
250
                }
251
            });
252
            $("#bibliolevel").click(function(){
253
                if ( $("#bibliolevel").is(':checked') ){
254
                    $("#items").hide();
255
                }
256
            });
257
            $("#recalls_patronsearch").on("submit", filter);
258
        });
259
    </script>
61
[% END %]
260
[% END %]
62
261
63
[% INCLUDE 'intranet-bottom.inc' %]
262
[% 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 / +4 lines)
Lines 13-18 function patron_autocomplete(node, options) { Link Here
13
            on_select_callback = options['on-select-callback'];
13
            on_select_callback = options['on-select-callback'];
14
        }
14
        }
15
    }
15
    }
16
            console.log(link_to);
16
    const search_fields = ['me.surname', 'me.firstname', 'me.cardnumber'];
17
    const search_fields = ['me.surname', 'me.firstname', 'me.cardnumber'];
17
    return node.autocomplete({
18
    return node.autocomplete({
18
        source: function( request, response ) {
19
        source: function( request, response ) {
Lines 67-73 function patron_autocomplete(node, options) { Link Here
67
                ? "/cgi-bin/koha/circ/circulation.pl"
68
                ? "/cgi-bin/koha/circ/circulation.pl"
68
                : link_to == 'reserve'
69
                : link_to == 'reserve'
69
                    ? "/cgi-bin/koha/reserve/request.pl"
70
                    ? "/cgi-bin/koha/reserve/request.pl"
70
                    : "/cgi-bin/koha/members/moremember.pl";
71
                    : link_to == 'recall'
72
                        ? "/cgi-bin/koha/recalls/request.pl"
73
                        : "/cgi-bin/koha/members/moremember.pl";
71
            item.link += ( url_params ? '?' + url_params + '&' : "?" ) + 'borrowernumber=' + item.patron_id;
74
            item.link += ( url_params ? '?' + url_params + '&' : "?" ) + 'borrowernumber=' + item.patron_id;
72
        } else {
75
        } else {
73
            item.link = null;
76
            item.link = null;
(-)a/recalls/request.pl (-5 / +102 lines)
Lines 38-63 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 $findborrower = $input->param('findborrower');
43
$findborrower = '' unless defined $findborrower;
44
$findborrower =~ s|,| |g;
45
my $error = $input->param('error');
43
46
44
if ( $op eq 'cancel_multiple_recalls' ) {
47
if ( $op eq 'cancel_multiple_recalls' ) {
45
    foreach my $id ( @recall_ids ) {
48
    foreach my $id ( @recall_ids ) {
46
        Koha::Recalls->find( $id )->set_cancelled;
49
        my $recall = Koha::Recalls->find( $id )->set_cancelled;
50
        $biblionumber = $recall->biblionumber;
47
    }
51
    }
48
    $op = 'list'
49
}
52
}
53
elsif ( $op eq 'patron_select' ) {
54
    if ( $findborrower ) {
55
        my $patron = Koha::Patrons->find( $findborrower );
56
        $biblionumber = $input->param('biblionumber');
57
        $biblio = Koha::Biblios->find( $biblionumber );
58
59
        if ( C4::Context->preference('UseRecalls') and C4::Context->preference('RecallsInterface') ne 'opac' and $patron and $patron->borrowernumber ) {
60
            if ( !$biblio->can_be_recalled({ patron => $patron }) ) {
61
                $error = 1;
62
            }
50
63
51
if ( $op eq 'list' ) {
64
            $template->param(
52
    $recalls = Koha::Recalls->search({ biblio_id => $biblionumber, completed => 0 });
65
                patron => $patron,
66
                error => $error,
67
            );
68
        }
69
    } else {
70
        print $input->redirect("/cgi-bin/koha/recalls/request.pl?biblionumber=$biblionumber");
71
    }
72
}
73
elsif ( $op eq 'request' ) {
74
    my $pickuploc = $input->param('pickup');
75
    my $expdate = $input->param('expirationdate');
76
    my $level = $input->param('type');
77
    my $itemnumber = $input->param('itemnumber');
78
    my $borrowernumber = $input->param('borrowernumber');
79
    $biblionumber = $input->param('biblionumber');
53
    $biblio = Koha::Biblios->find( $biblionumber );
80
    $biblio = Koha::Biblios->find( $biblionumber );
81
82
    if ( C4::Context->preference('UseRecalls') and C4::Context->preference('RecallsInterface') ne 'opac' and $borrowernumber ) {
83
        my $patron = Koha::Patrons->find( $borrowernumber );
84
85
        unless ( $biblio->can_be_recalled({ patron => $patron }) ) { $error = 'unavailable'; }
86
        my $items = Koha::Items->search({ biblionumber => $biblionumber });
87
88
        # check if already recalled
89
        my $recalled = scalar $biblio->recalls;
90
        if ( defined $recalled and $recalled > 0 ) {
91
            my $recalls_per_record = Koha::CirculationRules->get_effective_rule({
92
                categorycode => $patron->categorycode,
93
                branchcode => undef,
94
                itemtype => undef,
95
                rule_name => 'recalls_per_record'
96
            });
97
            if ( defined $recalls_per_record and $recalls_per_record->rule_value and $recalled >= $recalls_per_record->rule_value ){
98
                $error = 'duplicate';
99
            }
100
        }
101
102
        # submitting recall request
103
        if ( defined $error and $error eq 'unavailable' ){
104
            # no items available for recall
105
            print $input->redirect("/cgi-bin/koha/recalls/request.pl?biblionumber=$biblionumber&error=unavailable");
106
107
        } elsif ( !defined $error ){
108
            my ( $recall, $due_interval, $due_date );
109
            if ( $level eq 'itemlevel' and defined $itemnumber ) {
110
                my $item = Koha::Items->find( $itemnumber );
111
                if ( $item->can_be_recalled({ patron => $patron }) ) {
112
                    ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
113
                        patron => $patron,
114
                        biblio => $biblio,
115
                        branchcode => $pickuploc,
116
                        item => $item,
117
                        expirationdate => $expdate,
118
                        interface => 'staff',
119
                    });
120
                } else {
121
                    $error = 'cannot';
122
                }
123
            } else {
124
                if ( $biblio->can_be_recalled({ patron => $patron }) ) {
125
                    ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
126
                        patron => $patron,
127
                        biblio => $biblio,
128
                        branchcode => $pickuploc,
129
                        expirationdate => $expdate,
130
                        interface => 'staff',
131
                    });
132
                } else {
133
                    $error = 'cannot';
134
                }
135
            }
136
            if ( !defined $recall ) {
137
                $error = 'failed';
138
            }
139
        }
140
    }
54
}
141
}
55
142
143
my $recalls = Koha::Recalls->search({ biblio_id => $biblionumber, completed => 0 });
144
my $branches = Koha::Libraries->search;
145
my $single_branch_mode = $branches->count == 1;
146
my $items = Koha::Items->search({ biblionumber => $biblionumber });
147
56
$template->param(
148
$template->param(
57
    recalls     => $recalls,
149
    recalls     => $recalls,
58
    recallsview => 1,
150
    recallsview => 1,
59
    biblio      => $biblio,
151
    biblio      => $biblio,
60
    checkboxes  => 1,
152
    checkboxes  => 1,
153
    findborrower       => $findborrower,
154
    single_branch_mode => $single_branch_mode,
155
    branches    => $branches,
156
    items       => $items,
157
    error       => $error,
61
    C4::Search::enabled_staff_search_views,
158
    C4::Search::enabled_staff_search_views,
62
);
159
);
63
160
(-)a/reserve/modrequest.pl (+11 lines)
Lines 53-58 my @branch = $query->multi_param('pickup'); Link Here
53
my @itemnumber = $query->multi_param('itemnumber');
53
my @itemnumber = $query->multi_param('itemnumber');
54
my @biblionumber = $query->multi_param('biblionumber');
54
my @biblionumber = $query->multi_param('biblionumber');
55
my $count=@rank;
55
my $count=@rank;
56
my $recallerror=0;
56
57
57
@biblionumber = uniq @biblionumber;
58
@biblionumber = uniq @biblionumber;
58
59
Lines 87-92 else { Link Here
87
            $params->{reservedate} = $reservedates[$i] ? dt_from_string($reservedates[$i]) : undef;
88
            $params->{reservedate} = $reservedates[$i] ? dt_from_string($reservedates[$i]) : undef;
88
        }
89
        }
89
90
91
        if ( $rank[$i] eq 'recall' and $recallerror == 0 ) {
92
            my $hold = Koha::Holds->find( $reserve_id[$i] );
93
            if ( !$hold->biblio->can_be_recalled({ patron => $hold->patron }) ) {
94
                $recallerror++;
95
            }
96
        }
97
90
        try {
98
        try {
91
            ModReserve($params);
99
            ModReserve($params);
92
        } catch {
100
        } catch {
Lines 114-118 if ( $from eq 'borrower'){ Link Here
114
} else {
122
} else {
115
     my $url = URI->new("/cgi-bin/koha/reserve/request.pl");
123
     my $url = URI->new("/cgi-bin/koha/reserve/request.pl");
116
     $url->query_form( biblionumber => [@biblionumber]);
124
     $url->query_form( biblionumber => [@biblionumber]);
125
    if ( $recallerror ) {
126
        $url->query_form( recallerror => 1 );
127
    }
117
     print $query->redirect($url);
128
     print $query->redirect($url);
118
}
129
}
(-)a/reserve/request.pl (-1 / +5 lines)
Lines 727-732 $template->param( Link Here
727
    borrowernumber => $borrowernumber_hold,
727
    borrowernumber => $borrowernumber_hold,
728
);
728
);
729
729
730
my $recallerror = $input->param('recallerror');
731
if ( $recallerror ) {
732
    $template->param( recallerror => 1 );
733
}
734
730
# printout the page
735
# printout the page
731
output_html_with_http_headers $input, $cookie, $template->output;
736
output_html_with_http_headers $input, $cookie, $template->output;
732
737
733
- 

Return to bug 31391