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

(-)a/Koha/ArticleRequest.pm (-2 / +15 lines)
Lines 40-45 Koha::ArticleRequest - Koha Article Request Object class Link Here
40
40
41
=cut
41
=cut
42
42
43
=head3 request
44
45
=cut
46
47
sub request {
48
    my ($self) = @_;
49
50
    $self->status(Koha::ArticleRequest::Status::Requested);
51
    $self->SUPER::store();
52
    $self->notify();
53
    return $self;
54
}
55
43
=head3 open
56
=head3 open
44
57
45
=cut
58
=cut
Lines 106-112 sub notify { Link Here
106
    if (
119
    if (
107
        my $letter = C4::Letters::GetPreparedLetter(
120
        my $letter = C4::Letters::GetPreparedLetter(
108
            module                 => 'circulation',
121
            module                 => 'circulation',
109
            letter_code            => "AR_$status", # AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED
122
            letter_code            => "AR_$status", # AR_REQUESTED, AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED
110
            message_transport_type => 'email',
123
            message_transport_type => 'email',
111
            lang                   => $self->borrower->lang,
124
            lang                   => $self->borrower->lang,
112
            tables                 => {
125
            tables                 => {
Lines 199-205 sub store { Link Here
199
        return $self->SUPER::store;
212
        return $self->SUPER::store;
200
    } else {
213
    } else {
201
        $self->created_on( dt_from_string() );
214
        $self->created_on( dt_from_string() );
202
        return $self->open;
215
        return $self->request;
203
    }
216
    }
204
}
217
}
205
218
(-)a/Koha/ArticleRequest/Status.pm (-5 / +16 lines)
Lines 19-24 package Koha::ArticleRequest::Status; Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
=head1 AUTHOR
23
24
Kyle M Hall <kyle@bywatersolutions.com>
25
26
=cut
27
28
=head2 Requested
29
30
    returns constant string 'REQUESTED'
31
32
=cut
33
34
sub Requested {
35
    return 'REQUESTED';
36
}
37
22
sub Pending {
38
sub Pending {
23
    return 'PENDING';
39
    return 'PENDING';
24
}
40
}
Lines 35-44 sub Canceled { Link Here
35
    return 'CANCELED';
51
    return 'CANCELED';
36
}
52
}
37
53
38
=head1 AUTHOR
39
40
Kyle M Hall <kyle@bywatersolutions.com>
41
42
=cut
43
54
44
1;
55
1;
(-)a/Koha/ArticleRequests.pm (+11 lines)
Lines 61-66 sub search_limited { Link Here
61
    return $self->search( $params, $attributes );
61
    return $self->search( $params, $attributes );
62
}
62
}
63
63
64
=head3 requested
65
66
=cut
67
68
sub requested {
69
    my ( $self, $branchcode ) = @_;
70
    my $params = { status => Koha::ArticleRequest::Status::Requested };
71
    $params->{'me.branchcode'} = $branchcode if $branchcode;
72
    return Koha::ArticleRequests->search_limited($params);
73
}
74
64
=head3 pending
75
=head3 pending
65
76
66
=cut
77
=cut
(-)a/Koha/Biblio.pm (+1 lines)
Lines 368-373 sub article_requests_current { Link Here
368
        {
368
        {
369
            biblionumber => $self->biblionumber(),
369
            biblionumber => $self->biblionumber(),
370
            -or          => [
370
            -or          => [
371
                { status => Koha::ArticleRequest::Status::Requested },
371
                { status => Koha::ArticleRequest::Status::Pending },
372
                { status => Koha::ArticleRequest::Status::Pending },
372
                { status => Koha::ArticleRequest::Status::Processing }
373
                { status => Koha::ArticleRequest::Status::Processing }
373
            ]
374
            ]
(-)a/Koha/Patron.pm (+1 lines)
Lines 983-988 sub article_requests_current { Link Here
983
        {
983
        {
984
            borrowernumber => $self->id(),
984
            borrowernumber => $self->id(),
985
            -or          => [
985
            -or          => [
986
                { status => Koha::ArticleRequest::Status::Requested },
986
                { status => Koha::ArticleRequest::Status::Pending },
987
                { status => Koha::ArticleRequest::Status::Pending },
987
                { status => Koha::ArticleRequest::Status::Processing }
988
                { status => Koha::ArticleRequest::Status::Processing }
988
            ]
989
            ]
(-)a/Koha/Template/Plugin/Biblio.pm (+1 lines)
Lines 44-49 sub ArticleRequestsActiveCount { Link Here
44
            biblionumber => $biblionumber,
44
            biblionumber => $biblionumber,
45
            status       => [
45
            status       => [
46
                -or => [
46
                -or => [
47
                    status => Koha::ArticleRequest::Status::Requested,
47
                    status => Koha::ArticleRequest::Status::Pending,
48
                    status => Koha::ArticleRequest::Status::Pending,
48
                    status => Koha::ArticleRequest::Status::Processing
49
                    status => Koha::ArticleRequest::Status::Processing
49
                ]
50
                ]
(-)a/circ/article-requests.pl (+1 lines)
Lines 39-44 my $branchcode = defined( $query->param('branchcode') ) ? $query->param('branchc Link Here
39
39
40
$template->param(
40
$template->param(
41
    branchcode                  => $branchcode,
41
    branchcode                  => $branchcode,
42
    article_requests_requested  => scalar Koha::ArticleRequests->requested($branchcode),
42
    article_requests_pending    => scalar Koha::ArticleRequests->pending($branchcode),
43
    article_requests_pending    => scalar Koha::ArticleRequests->pending($branchcode),
43
    article_requests_processing => scalar Koha::ArticleRequests->processing($branchcode),
44
    article_requests_processing => scalar Koha::ArticleRequests->processing($branchcode),
44
);
45
);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt (-7 / +155 lines)
Lines 19-24 Link Here
19
19
20
        <ul class="dropdown-menu [% pull_right | html %]" role="menu" aria-labelledby="[% aria_menu | html %]">
20
        <ul class="dropdown-menu [% pull_right | html %]" role="menu" aria-labelledby="[% aria_menu | html %]">
21
            <li>
21
            <li>
22
                <a class="ar-open-request" href="#" onclick="HandleMulti( Open, [% id_arg | html %], $(this) ); return false;">
23
                    <i class="fa fa-bars"></i>
24
                    Set request as pending
25
                </a>
26
22
                <a class="ar-process-request" href="#" onclick="HandleMulti( Process, [% id_arg | html %], $(this) ); return false;">
27
                <a class="ar-process-request" href="#" onclick="HandleMulti( Process, [% id_arg | html %], $(this) ); return false;">
23
                    <i class="fa fa-cog"></i>
28
                    <i class="fa fa-cog"></i>
24
                    Process request
29
                    Process request
Lines 88-93 Link Here
88
93
89
                <div id="article-request-tabs" class="toptabs">
94
                <div id="article-request-tabs" class="toptabs">
90
                    <ul>
95
                    <ul>
96
                        <li>
97
                            <a href="#article-requests-requested">
98
                                Requested (<span id="ar_requested_count">[% article_requests_requested.count | html %]</span>)
99
                            </a>
100
                        </li>
101
91
                        <li>
102
                        <li>
92
                            <a href="#article-requests-pending">
103
                            <a href="#article-requests-pending">
93
                                Pending (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
104
                                Pending (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
Lines 101-106 Link Here
101
                        </li>
112
                        </li>
102
                    </ul>
113
                    </ul>
103
114
115
                    <div id="article-requests-requested">
116
                        <div class="article-requests-requested_table_controls">
117
                            <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
118
                            [% PROCESS actions menuid='article-menu-requested' id_arg=0 pull_right='' aria_menu='table_controls' %]
119
                        </div>
120
121
                        <table id="article-requests-requested-table">
122
                            <thead>
123
                                <tr>
124
                                    <th/>
125
                                    <th class="ar-title">Title</th>
126
                                    <th class="ar-request">Requested article</th>
127
                                    <th class="ar-collection">Collection</th>
128
                                    <th class="ar-itemtype">Item type</th>
129
                                    <th class="ar-callnumber">Call number</th>
130
                                    <th class="ar-status">Status</th>
131
                                    <th class="ar-copynumber">Copy number</th>
132
                                    <th class="ar-enumchron">Enumeration</th>
133
                                    <th class="ar-barcode">Barcode</th>
134
                                    <th class="ar-patron">Patron</th>
135
                                    <th class="ar-date">Date</th>
136
                                    <th class="ar-actions noExport">Actions</th>
137
                                </tr>
138
                            </thead>
139
140
                             <tbody>
141
                                [% FOREACH ar IN article_requests_requested %]
142
                                    <tr class="ar-row ar-requested">
143
                                        <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
144
                                        <td class="ar-title">
145
                                            <p>
146
                                                <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
147
                                                    [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
148
                                                </a>
149
                                            </p>
150
151
                                            <p>
152
                                                <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
153
                                                <div class="ar-author">[% ar.biblio.author | html %]</div>
154
                                                <div class="ar-pubdata">
155
                                                    [% ar.biblio.biblioitem.publishercode | html %]
156
157
                                                    [% IF ar.biblio.biblioitem.publicationyear %]
158
                                                        [% ar.biblio.biblioitem.publicationyear | html %]
159
                                                    [% ELSIF ar.biblio.copyrightdate %]
160
                                                        [% ar.biblio.copyrightdate | html %]
161
                                                    [% END %]
162
163
                                                    [% IF ar.biblio.biblioitem.pages %]
164
                                                        : [% ar.biblio.biblioitem.pages | html %]
165
                                                    [% END %]
166
167
                                                    [% r.biblio.biblioitem.size | html %]
168
169
                                                    [% IF ar.biblio.biblioitem.isbn %]
170
                                                        ISBN: [% ar.biblio.biblioitem.isbn | html %]
171
                                                    [% END %]
172
                                                </div>
173
                                            </p>
174
                                        </td>
175
                                        <td class="ar-request">
176
                                            [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title | html %]        </p> [% END %]
177
                                            [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author | html %]       </p> [% END %]
178
                                            [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume | html %]       </p> [% END %]
179
                                            [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue | html %]        </p> [% END %]
180
                                            [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date | html %]         </p> [% END %]
181
                                            [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages | html %]        </p> [% END %]
182
                                            [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters | html %]     </p> [% END %]
183
                                            [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
184
                                        </td>
185
                                        <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
186
                                        <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
187
                                        <td class="ar-callnumber">
188
                                            [% IF ar.item.location %]
189
                                                <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
190
                                            [% END %]
191
192
                                            [% ar.item.itemcallnumber | html %]
193
                                        </td>
194
                                        <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
195
                                        <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
196
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
197
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
198
                                        <td class="ar-patron">
199
                                            <p>
200
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
201
                                                    [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
202
                                                </a>
203
                                            </p>
204
205
                                            <p>[% ar.borrower.phone | html %]</p>
206
                                        </td>
207
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
208
                                        <td class="ar-actions">
209
                                            [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
210
                                        </td>
211
                                    </tr>
212
                                [% END %]
213
                            </tbody>
214
                        </table>
215
                    </div>
216
104
                    <div id="article-requests-pending">
217
                    <div id="article-requests-pending">
105
                        <div class="article-requests-pending_table_controls">
218
                        <div class="article-requests-pending_table_controls">
106
                            <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
219
                            <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
Lines 310-322 Link Here
310
[% MACRO jsinclude BLOCK %]
423
[% MACRO jsinclude BLOCK %]
311
    [% INCLUDE 'datatables.inc' %]
424
    [% INCLUDE 'datatables.inc' %]
312
    <script>
425
    <script>
313
        var active_tab = "#article-requests-pending";
426
        var active_tab = "#article-requests-requested";
314
        var last_cancel_reason, pending_datatable, processing_datatable, active_datatable;
427
        var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable;
315
        $(document).ready(function() {
428
        $(document).ready(function() {
316
            $('#article-request-tabs').tabs({
429
            $('#article-request-tabs').tabs({
317
                activate: function( activate_event, activate_ui ) {
430
                activate: function( activate_event, activate_ui ) {
318
                    active_tab = activate_ui.newPanel.selector;
431
                    active_tab = activate_ui.newPanel.selector;
319
                    if( active_tab == '#article-requests-pending' )
432
                    if( active_tab == '#article-requests-requested' )
433
                        active_datatable = requested_datatable;
434
                    else if( active_tab == '#article-requests-pending' )
320
                        active_datatable = pending_datatable;
435
                        active_datatable = pending_datatable;
321
                    else active_datatable = processing_datatable;
436
                    else active_datatable = processing_datatable;
322
                    activateBatchActions( active_tab );
437
                    activateBatchActions( active_tab );
Lines 340-361 Link Here
340
            });
455
            });
341
            $("a.ar-actions").on('click', function(e) {
456
            $("a.ar-actions").on('click', function(e) {
342
                // Hide menu option ?
457
                // Hide menu option ?
343
                if( $('#article-requests-processing-table').is(":visible") )
458
                if( $('#article-requests-pending-table').is(":visible") )
344
                    $('a.ar-process-request').hide();
459
                    $('a.ar-process-request').show();
345
                else $('a.ar-process-request').show();
460
                else $('a.ar-process-request').hide();
461
462
                if( $('#article-requests-requested-table').is(":visible") )
463
                    $('a.ar-open-request').show();
464
                else $('a.ar-open-request').hide();
346
            });
465
            });
347
466
467
            requested_datatable = $("#article-requests-requested-table").DataTable($.extend(true, {}, dataTablesDefaults, {
468
                "aoColumnDefs": [
469
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
470
                ],
471
            }));
348
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
472
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
349
                "aoColumnDefs": [
473
                "aoColumnDefs": [
350
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
474
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
351
                ],
475
                ],
352
            }));
476
            }));
353
            active_datatable = pending_datatable;
354
            processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
477
            processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
355
                "aoColumnDefs": [
478
                "aoColumnDefs": [
356
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
479
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
357
                ],
480
                ],
358
            }));
481
            }));
482
            active_datatable = requested_datatable;
359
            activateBatchActions( active_tab );
483
            activateBatchActions( active_tab );
360
            $(".starthidden").show();
484
            $(".starthidden").show();
361
        });
485
        });
Lines 415-420 Link Here
415
            });
539
            });
416
        }
540
        }
417
541
542
        function Open( id, a ) {
543
            var table_row = a.closest('tr');
544
            table_row.find('.ar-open-request').remove();
545
            table_row.find('input[type="checkbox"]').prop('checked', false);
546
            a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
547
            $.ajax({
548
                type: "POST",
549
                url: '/cgi-bin/koha/svc/article_request',
550
                data: {
551
                    action: 'open',
552
                    id: id,
553
                },
554
                success: function( data ) {
555
                    $("img.spinner").remove();
556
                    requested_datatable.row( table_row ).remove().draw();
557
                    pending_datatable.row.add( table_row ).draw();
558
                    UpdateTabCounts();
559
                    activateBatchActions( active_tab );
560
                },
561
                dataType: 'json'
562
            });
563
        }
564
418
        function Process( id, a ) {
565
        function Process( id, a ) {
419
            var table_row = a.closest('tr');
566
            var table_row = a.closest('tr');
420
            table_row.find('.ar-process-request').remove();
567
            table_row.find('.ar-process-request').remove();
Lines 458-463 Link Here
458
        }
605
        }
459
606
460
        function UpdateTabCounts() {
607
        function UpdateTabCounts() {
608
            $("#ar_requested_count").html( requested_datatable.rows().count() );
461
            $("#ar_pending_count").html( pending_datatable.rows().count() );
609
            $("#ar_pending_count").html( pending_datatable.rows().count() );
462
            $("#ar_processing_count").html( processing_datatable.rows().count() );
610
            $("#ar_processing_count").html( processing_datatable.rows().count() );
463
        }
611
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt (+2 lines)
Lines 260-265 Link Here
260
                                                Pending
260
                                                Pending
261
                                            [% ELSIF ar.status == 'PROCESSING' %]
261
                                            [% ELSIF ar.status == 'PROCESSING' %]
262
                                                Processing
262
                                                Processing
263
                                            [% ELSIF ar.status == 'REQUESTED' %]
264
                                                Requested
263
                                            [% ELSIF ar.status == 'COMPLETED' %]
265
                                            [% ELSIF ar.status == 'COMPLETED' %]
264
                                                Completed
266
                                                Completed
265
                                            [% ELSIF ar.status == 'CANCELED' %]
267
                                            [% ELSIF ar.status == 'CANCELED' %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+2 lines)
Lines 782-787 Link Here
782
                                                        Pending
782
                                                        Pending
783
                                                    [% ELSIF ar.status == 'PROCESSING' %]
783
                                                    [% ELSIF ar.status == 'PROCESSING' %]
784
                                                        Processing
784
                                                        Processing
785
                                                    [% ELSIF ar.status == 'REQUESTED' %]
786
                                                        Requested
785
                                                    [% ELSIF ar.status == 'COMPLETED' %]
787
                                                    [% ELSIF ar.status == 'COMPLETED' %]
786
                                                        Completed
788
                                                        Completed
787
                                                    [% ELSIF ar.status == 'CANCELED' %]
789
                                                    [% ELSIF ar.status == 'CANCELED' %]
(-)a/svc/article_request (-1 / +3 lines)
Lines 50-55 if ($ar) { Link Here
50
    elsif ( $action eq 'process' ) {
50
    elsif ( $action eq 'process' ) {
51
        $ar = $ar->process();
51
        $ar = $ar->process();
52
    }
52
    }
53
    elsif ( $action eq 'open' ) {
54
        $ar = $ar->open();
55
    }
53
    elsif ( $action eq 'complete' ) {
56
    elsif ( $action eq 'complete' ) {
54
        $ar = $ar->complete();
57
        $ar = $ar->complete();
55
    }
58
    }
56
- 

Return to bug 27944