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 372-377 sub article_requests_current { Link Here
372
        {
372
        {
373
            biblionumber => $self->biblionumber(),
373
            biblionumber => $self->biblionumber(),
374
            -or          => [
374
            -or          => [
375
                { status => Koha::ArticleRequest::Status::Requested },
375
                { status => Koha::ArticleRequest::Status::Pending },
376
                { status => Koha::ArticleRequest::Status::Pending },
376
                { status => Koha::ArticleRequest::Status::Processing }
377
                { status => Koha::ArticleRequest::Status::Processing }
377
            ]
378
            ]
(-)a/Koha/Patron.pm (+1 lines)
Lines 993-998 sub article_requests_current { Link Here
993
        {
993
        {
994
            borrowernumber => $self->id(),
994
            borrowernumber => $self->id(),
995
            -or          => [
995
            -or          => [
996
                { status => Koha::ArticleRequest::Status::Requested },
996
                { status => Koha::ArticleRequest::Status::Pending },
997
                { status => Koha::ArticleRequest::Status::Pending },
997
                { status => Koha::ArticleRequest::Status::Processing }
998
                { status => Koha::ArticleRequest::Status::Processing }
998
            ]
999
            ]
(-)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 (-9 / +160 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 97-103 Link Here
97
102
98
    <div class="main container-fluid starthidden">
103
    <div class="main container-fluid starthidden">
99
        <div class="row">
104
        <div class="row">
100
            <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
105
            <div class="col-md-10 col-md-offset-1 col-lg-10 col-lg-offset-1">
101
106
102
                <h1>Article requests</h1>
107
                <h1>Article requests</h1>
103
                [% PROCESS urls_modal %]
108
                [% PROCESS urls_modal %]
Lines 120-125 Link Here
120
125
121
                <div id="article-request-tabs" class="toptabs">
126
                <div id="article-request-tabs" class="toptabs">
122
                    <ul>
127
                    <ul>
128
                        <li>
129
                            <a href="#article-requests-requested">
130
                                New (<span id="ar_requested_count">[% article_requests_requested.count | html %]</span>)
131
                            </a>
132
                        </li>
133
123
                        <li>
134
                        <li>
124
                            <a href="#article-requests-pending">
135
                            <a href="#article-requests-pending">
125
                                Pending (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
136
                                Pending (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
Lines 133-138 Link Here
133
                        </li>
144
                        </li>
134
                    </ul>
145
                    </ul>
135
146
147
                    <div id="article-requests-requested">
148
                        <div class="article-requests-requested_table_controls">
149
                            <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>
150
                            [% PROCESS actions menuid='article-menu-requested' id_arg=0 pull_right='' aria_menu='table_controls' %]
151
                        </div>
152
153
                        <table id="article-requests-requested-table">
154
                            <thead>
155
                                <tr>
156
                                    <th/>
157
                                    <th class="ar-title">Title</th>
158
                                    <th class="ar-request">Requested article</th>
159
                                    <th class="ar-collection">Collection</th>
160
                                    <th class="ar-itemtype">Item type</th>
161
                                    <th class="ar-callnumber">Call number</th>
162
                                    <th class="ar-status">Status</th>
163
                                    <th class="ar-copynumber">Copy number</th>
164
                                    <th class="ar-enumchron">Enumeration</th>
165
                                    <th class="ar-barcode">Barcode</th>
166
                                    <th class="ar-patron">Patron</th>
167
                                    <th class="ar-date">Date</th>
168
                                    <th class="ar-actions noExport">Actions</th>
169
                                </tr>
170
                            </thead>
171
172
                             <tbody>
173
                                [% FOREACH ar IN article_requests_requested %]
174
                                    <tr class="ar-row ar-requested">
175
                                        <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
176
                                        <td class="ar-title">
177
                                            <p>
178
                                                <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
179
                                                    [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
180
                                                </a>
181
                                            </p>
182
183
                                            <p>
184
                                                <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
185
                                                <div class="ar-author">[% ar.biblio.author | html %]</div>
186
                                                <div class="ar-pubdata">
187
                                                    [% ar.biblio.biblioitem.publishercode | html %]
188
189
                                                    [% IF ar.biblio.biblioitem.publicationyear %]
190
                                                        [% ar.biblio.biblioitem.publicationyear | html %]
191
                                                    [% ELSIF ar.biblio.copyrightdate %]
192
                                                        [% ar.biblio.copyrightdate | html %]
193
                                                    [% END %]
194
195
                                                    [% IF ar.biblio.biblioitem.pages %]
196
                                                        : [% ar.biblio.biblioitem.pages | html %]
197
                                                    [% END %]
198
199
                                                    [% r.biblio.biblioitem.size | html %]
200
201
                                                    [% IF ar.biblio.biblioitem.isbn %]
202
                                                        ISBN: [% ar.biblio.biblioitem.isbn | html %]
203
                                                    [% END %]
204
                                                </div>
205
                                            </p>
206
                                        </td>
207
                                        <td class="ar-request">
208
                                            [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title | html %]        </p> [% END %]
209
                                            [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author | html %]       </p> [% END %]
210
                                            [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume | html %]       </p> [% END %]
211
                                            [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue | html %]        </p> [% END %]
212
                                            [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date | html %]         </p> [% END %]
213
                                            [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages | html %]        </p> [% END %]
214
                                            [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters | html %]     </p> [% END %]
215
                                            [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
216
                                        </td>
217
                                        <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
218
                                        <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
219
                                        <td class="ar-callnumber">
220
                                            [% IF ar.item.location %]
221
                                                <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
222
                                            [% END %]
223
224
                                            [% ar.item.itemcallnumber | html %]
225
                                        </td>
226
                                        <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
227
                                        <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
228
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
229
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
230
                                        <td class="ar-patron">
231
                                            <p>
232
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
233
                                                    [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
234
                                                </a>
235
                                            </p>
236
237
                                            <p>[% ar.borrower.phone | html %]</p>
238
                                        </td>
239
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
240
                                        <td class="ar-actions">
241
                                            [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
242
                                        </td>
243
                                    </tr>
244
                                [% END %]
245
                            </tbody>
246
                        </table>
247
                    </div>
248
136
                    <div id="article-requests-pending">
249
                    <div id="article-requests-pending">
137
                        <div class="article-requests-pending_table_controls">
250
                        <div class="article-requests-pending_table_controls">
138
                            <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>
251
                            <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 350-362 Link Here
350
[% MACRO jsinclude BLOCK %]
463
[% MACRO jsinclude BLOCK %]
351
    [% INCLUDE 'datatables.inc' %]
464
    [% INCLUDE 'datatables.inc' %]
352
    <script>
465
    <script>
353
        var active_tab = "#article-requests-pending";
466
        var active_tab = "#article-requests-requested";
354
        var last_cancel_reason, pending_datatable, processing_datatable, active_datatable;
467
        var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable;
355
        $(document).ready(function() {
468
        $(document).ready(function() {
356
            $('#article-request-tabs').tabs({
469
            $('#article-request-tabs').tabs({
357
                activate: function( activate_event, activate_ui ) {
470
                activate: function( activate_event, activate_ui ) {
358
                    active_tab = activate_ui.newPanel.selector;
471
                    active_tab = activate_ui.newPanel.selector;
359
                    if( active_tab == '#article-requests-pending' )
472
                    if( active_tab == '#article-requests-requested' )
473
                        active_datatable = requested_datatable;
474
                    else if( active_tab == '#article-requests-pending' )
360
                        active_datatable = pending_datatable;
475
                        active_datatable = pending_datatable;
361
                    else active_datatable = processing_datatable;
476
                    else active_datatable = processing_datatable;
362
                    activateBatchActions( active_tab );
477
                    activateBatchActions( active_tab );
Lines 380-388 Link Here
380
            });
495
            });
381
            $("a.ar-actions").on('click', function(e) {
496
            $("a.ar-actions").on('click', function(e) {
382
                // Hide menu option ?
497
                // Hide menu option ?
383
                if( $('#article-requests-processing-table').is(":visible") )
498
                if( $('#article-requests-requested-table:visible,#article-requests-pending-table:visible').length )
384
                    $('a.ar-process-request').hide();
499
                    $('a.ar-process-request').show();
385
                else $('a.ar-process-request').show();
500
                else $('a.ar-process-request').hide();
501
502
                if( $('#article-requests-requested-table').is(":visible") )
503
                    $('a.ar-open-request').show();
504
                else $('a.ar-open-request').hide();
386
            });
505
            });
387
506
388
            $('#myModal').on("shown.bs.modal", function () {
507
            $('#myModal').on("shown.bs.modal", function () {
Lines 398-414 Link Here
398
                SaveURLs( $('#myModal textarea').val() );
517
                SaveURLs( $('#myModal textarea').val() );
399
            });
518
            });
400
519
520
            requested_datatable = $("#article-requests-requested-table").DataTable($.extend(true, {}, dataTablesDefaults, {
521
                "aoColumnDefs": [
522
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
523
                ],
524
            }));
525
            
401
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
526
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
402
                "aoColumnDefs": [
527
                "aoColumnDefs": [
403
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
528
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
404
                ],
529
                ],
405
            }));
530
            }));
406
            active_datatable = pending_datatable;
407
            processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
531
            processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
408
                "aoColumnDefs": [
532
                "aoColumnDefs": [
409
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
533
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
410
                ],
534
                ],
411
            }));
535
            }));
536
            active_datatable = requested_datatable;
412
            activateBatchActions( active_tab );
537
            activateBatchActions( active_tab );
413
            $(".starthidden").show();
538
            $(".starthidden").show();
414
        });
539
        });
Lines 468-475 Link Here
468
            });
593
            });
469
        }
594
        }
470
595
596
        function Open( id, a ) {
597
            var table_row = a.closest('tr');
598
            table_row.find('.ar-open-request').remove();
599
            table_row.find('input[type="checkbox"]').prop('checked', false);
600
            a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
601
            $.ajax({
602
                type: "POST",
603
                url: '/cgi-bin/koha/svc/article_request',
604
                data: {
605
                    action: 'open',
606
                    id: id,
607
                },
608
                success: function( data ) {
609
                    $("img.spinner").remove();
610
                    requested_datatable.row( table_row ).remove().draw();
611
                    pending_datatable.row.add( table_row ).draw();
612
                    UpdateTabCounts();
613
                    activateBatchActions( active_tab );
614
                },
615
                dataType: 'json'
616
            });
617
        }
618
471
        function Process( id, a ) {
619
        function Process( id, a ) {
472
            var table_row = a.closest('tr');
620
            var table_row = a.closest('tr');
621
            var table = a.closest('table');
622
            var orig_datatable = table.attr('id')==='article-requests-pending-table'?pending_datatable:requested_datatable;
473
            table_row.find('.ar-process-request').remove();
623
            table_row.find('.ar-process-request').remove();
474
            table_row.find('input[type="checkbox"]').prop('checked', false);
624
            table_row.find('input[type="checkbox"]').prop('checked', false);
475
625
Lines 483-489 Link Here
483
                },
633
                },
484
                success: function( data ) {
634
                success: function( data ) {
485
                    $("img.spinner").remove();
635
                    $("img.spinner").remove();
486
                    pending_datatable.row( table_row ).remove().draw();
636
                    orig_datatable.row( table_row ).remove().draw();
487
                    processing_datatable.row.add( table_row ).draw();
637
                    processing_datatable.row.add( table_row ).draw();
488
                    UpdateTabCounts();
638
                    UpdateTabCounts();
489
                    activateBatchActions( active_tab );
639
                    activateBatchActions( active_tab );
Lines 517-522 Link Here
517
        }
667
        }
518
668
519
        function UpdateTabCounts() {
669
        function UpdateTabCounts() {
670
            $("#ar_requested_count").html( requested_datatable.rows().count() );
520
            $("#ar_pending_count").html( pending_datatable.rows().count() );
671
            $("#ar_pending_count").html( pending_datatable.rows().count() );
521
            $("#ar_processing_count").html( processing_datatable.rows().count() );
672
            $("#ar_processing_count").html( processing_datatable.rows().count() );
522
        }
673
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt (+2 lines)
Lines 282-287 Link Here
282
                                                Pending
282
                                                Pending
283
                                            [% ELSIF ar.status == 'PROCESSING' %]
283
                                            [% ELSIF ar.status == 'PROCESSING' %]
284
                                                Processing
284
                                                Processing
285
                                            [% ELSIF ar.status == 'REQUESTED' %]
286
                                                New
285
                                            [% ELSIF ar.status == 'COMPLETED' %]
287
                                            [% ELSIF ar.status == 'COMPLETED' %]
286
                                                Completed
288
                                                Completed
287
                                            [% ELSIF ar.status == 'CANCELED' %]
289
                                            [% ELSIF ar.status == 'CANCELED' %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+2 lines)
Lines 789-794 Link Here
789
                                                        Pending
789
                                                        Pending
790
                                                    [% ELSIF ar.status == 'PROCESSING' %]
790
                                                    [% ELSIF ar.status == 'PROCESSING' %]
791
                                                        Processing
791
                                                        Processing
792
                                                    [% ELSIF ar.status == 'REQUESTED' %]
793
                                                        New
792
                                                    [% ELSIF ar.status == 'COMPLETED' %]
794
                                                    [% ELSIF ar.status == 'COMPLETED' %]
793
                                                        Completed
795
                                                        Completed
794
                                                    [% ELSIF ar.status == 'CANCELED' %]
796
                                                    [% 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