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

(-)a/Koha/ArticleRequest.pm (-2 / +15 lines)
Lines 39-44 Koha::ArticleRequest - Koha Article Request Object class Link Here
39
39
40
=cut
40
=cut
41
41
42
=head3 request
43
44
=cut
45
46
sub request {
47
    my ($self) = @_;
48
49
    $self->status(Koha::ArticleRequest::Status::Requested);
50
    $self->SUPER::store();
51
    $self->notify();
52
    return $self;
53
}
54
42
=head3 open
55
=head3 open
43
56
44
=cut
57
=cut
Lines 105-111 sub notify { Link Here
105
    if (
118
    if (
106
        my $letter = C4::Letters::GetPreparedLetter(
119
        my $letter = C4::Letters::GetPreparedLetter(
107
            module                 => 'circulation',
120
            module                 => 'circulation',
108
            letter_code            => "AR_$status", # AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED
121
            letter_code            => "AR_$status", # AR_REQUESTED, AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED
109
            message_transport_type => 'email',
122
            message_transport_type => 'email',
110
            lang                   => $self->borrower->lang,
123
            lang                   => $self->borrower->lang,
111
            tables                 => {
124
            tables                 => {
Lines 198-204 sub store { Link Here
198
        return $self->SUPER::store;
211
        return $self->SUPER::store;
199
    } else {
212
    } else {
200
        $self->created_on( dt_from_string() );
213
        $self->created_on( dt_from_string() );
201
        return $self->open;
214
        return $self->request;
202
    }
215
    }
203
}
216
}
204
217
(-)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 60-65 sub search_limited { Link Here
60
    return $self->search( $params, $attributes );
60
    return $self->search( $params, $attributes );
61
}
61
}
62
62
63
=head3 requested
64
65
=cut
66
67
sub requested {
68
    my ( $self, $branchcode ) = @_;
69
    my $params = { status => Koha::ArticleRequest::Status::Requested };
70
    $params->{'me.branchcode'} = $branchcode if $branchcode;
71
    return Koha::ArticleRequests->search_limited($params);
72
}
73
63
=head3 pending
74
=head3 pending
64
75
65
=cut
76
=cut
(-)a/Koha/Biblio.pm (+1 lines)
Lines 370-375 sub article_requests_current { Link Here
370
        {
370
        {
371
            biblionumber => $self->biblionumber(),
371
            biblionumber => $self->biblionumber(),
372
            -or          => [
372
            -or          => [
373
                { status => Koha::ArticleRequest::Status::Requested },
373
                { status => Koha::ArticleRequest::Status::Pending },
374
                { status => Koha::ArticleRequest::Status::Pending },
374
                { status => Koha::ArticleRequest::Status::Processing }
375
                { status => Koha::ArticleRequest::Status::Processing }
375
            ]
376
            ]
(-)a/Koha/Patron.pm (+1 lines)
Lines 992-997 sub article_requests_current { Link Here
992
        {
992
        {
993
            borrowernumber => $self->id(),
993
            borrowernumber => $self->id(),
994
            -or          => [
994
            -or          => [
995
                { status => Koha::ArticleRequest::Status::Requested },
995
                { status => Koha::ArticleRequest::Status::Pending },
996
                { status => Koha::ArticleRequest::Status::Pending },
996
                { status => Koha::ArticleRequest::Status::Processing }
997
                { status => Koha::ArticleRequest::Status::Processing }
997
            ]
998
            ]
(-)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 / +164 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-set-pending-request" href="#" onclick="HandleMulti( SetPending, [% 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-format">Format</th>
167
                                    <th class="ar-urls">URLs</th>
168
                                    <th class="ar-patron">Patron</th>
169
                                    <th class="ar-date">Date</th>
170
                                    <th class="ar-actions noExport">Actions</th>
171
                                </tr>
172
                            </thead>
173
174
                             <tbody>
175
                                [% FOREACH ar IN article_requests_requested %]
176
                                    <tr class="ar-row ar-requested">
177
                                        <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
178
                                        <td class="ar-title">
179
                                            <p>
180
                                                <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
181
                                                    [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
182
                                                </a>
183
                                            </p>
184
185
                                            <p>
186
                                                <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
187
                                                <div class="ar-author">[% ar.biblio.author | html %]</div>
188
                                                <div class="ar-pubdata">
189
                                                    [% ar.biblio.biblioitem.publishercode | html %]
190
191
                                                    [% IF ar.biblio.biblioitem.publicationyear %]
192
                                                        [% ar.biblio.biblioitem.publicationyear | html %]
193
                                                    [% ELSIF ar.biblio.copyrightdate %]
194
                                                        [% ar.biblio.copyrightdate | html %]
195
                                                    [% END %]
196
197
                                                    [% IF ar.biblio.biblioitem.pages %]
198
                                                        : [% ar.biblio.biblioitem.pages | html %]
199
                                                    [% END %]
200
201
                                                    [% r.biblio.biblioitem.size | html %]
202
203
                                                    [% IF ar.biblio.biblioitem.isbn %]
204
                                                        ISBN: [% ar.biblio.biblioitem.isbn | html %]
205
                                                    [% END %]
206
                                                </div>
207
                                            </p>
208
                                        </td>
209
                                        <td class="ar-request">
210
                                            [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title | html %]        </p> [% END %]
211
                                            [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author | html %]       </p> [% END %]
212
                                            [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume | html %]       </p> [% END %]
213
                                            [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue | html %]        </p> [% END %]
214
                                            [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date | html %]         </p> [% END %]
215
                                            [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages | html %]        </p> [% END %]
216
                                            [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters | html %]     </p> [% END %]
217
                                            [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
218
                                        </td>
219
                                        <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
220
                                        <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
221
                                        <td class="ar-callnumber">
222
                                            [% IF ar.item.location %]
223
                                                <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
224
                                            [% END %]
225
226
                                            [% ar.item.itemcallnumber | html %]
227
                                        </td>
228
                                        <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
229
                                        <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
230
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
231
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
232
                                        <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
233
                                        <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id | html %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id | html %]" style="display:none;">[% ar.urls | url %]</span>[% END %]</td>
234
                                        <td class="ar-patron">
235
                                            <p>
236
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
237
                                                    [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
238
                                                </a>
239
                                            </p>
240
241
                                            <p>[% ar.borrower.phone | html %]</p>
242
                                        </td>
243
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
244
                                        <td class="ar-actions">
245
                                            [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
246
                                        </td>
247
                                    </tr>
248
                                [% END %]
249
                            </tbody>
250
                        </table>
251
                    </div>
252
136
                    <div id="article-requests-pending">
253
                    <div id="article-requests-pending">
137
                        <div class="article-requests-pending_table_controls">
254
                        <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>
255
                            <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 %]
467
[% MACRO jsinclude BLOCK %]
351
    [% INCLUDE 'datatables.inc' %]
468
    [% INCLUDE 'datatables.inc' %]
352
    <script>
469
    <script>
353
        var active_tab = "#article-requests-pending";
470
        var active_tab = "#article-requests-requested";
354
        var last_cancel_reason, pending_datatable, processing_datatable, active_datatable;
471
        var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable;
355
        $(document).ready(function() {
472
        $(document).ready(function() {
356
            $('#article-request-tabs').tabs({
473
            $('#article-request-tabs').tabs({
357
                activate: function( activate_event, activate_ui ) {
474
                activate: function( activate_event, activate_ui ) {
358
                    active_tab = activate_ui.newPanel.selector;
475
                    active_tab = activate_ui.newPanel.selector;
359
                    if( active_tab == '#article-requests-pending' )
476
                    if( active_tab == '#article-requests-requested' )
477
                        active_datatable = requested_datatable;
478
                    else if( active_tab == '#article-requests-pending' )
360
                        active_datatable = pending_datatable;
479
                        active_datatable = pending_datatable;
361
                    else active_datatable = processing_datatable;
480
                    else active_datatable = processing_datatable;
362
                    activateBatchActions( active_tab );
481
                    activateBatchActions( active_tab );
Lines 380-388 Link Here
380
            });
499
            });
381
            $("a.ar-actions").on('click', function(e) {
500
            $("a.ar-actions").on('click', function(e) {
382
                // Hide menu option ?
501
                // Hide menu option ?
383
                if( $('#article-requests-processing-table').is(":visible") )
502
                if( $('#article-requests-requested-table:visible,#article-requests-pending-table:visible').length )
384
                    $('a.ar-process-request').hide();
503
                    $('a.ar-process-request').show();
385
                else $('a.ar-process-request').show();
504
                else $('a.ar-process-request').hide();
505
506
                if( $('#article-requests-requested-table').is(":visible") )
507
                    $('a.ar-set-pending-request').show();
508
                else $('a.ar-set-pending-request').hide();
386
            });
509
            });
387
510
388
            $('#myModal').on("shown.bs.modal", function () {
511
            $('#myModal').on("shown.bs.modal", function () {
Lines 398-414 Link Here
398
                SaveURLs( $('#myModal textarea').val() );
521
                SaveURLs( $('#myModal textarea').val() );
399
            });
522
            });
400
523
524
            requested_datatable = $("#article-requests-requested-table").DataTable($.extend(true, {}, dataTablesDefaults, {
525
                "aoColumnDefs": [
526
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
527
                ],
528
            }));
529
401
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
530
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
402
                "aoColumnDefs": [
531
                "aoColumnDefs": [
403
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
532
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
404
                ],
533
                ],
405
            }));
534
            }));
406
            active_datatable = pending_datatable;
407
            processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
535
            processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
408
                "aoColumnDefs": [
536
                "aoColumnDefs": [
409
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
537
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
410
                ],
538
                ],
411
            }));
539
            }));
540
            active_datatable = requested_datatable;
412
            activateBatchActions( active_tab );
541
            activateBatchActions( active_tab );
413
            $(".starthidden").show();
542
            $(".starthidden").show();
414
        });
543
        });
Lines 468-475 Link Here
468
            });
597
            });
469
        }
598
        }
470
599
600
        function SetPending( id, a ) {
601
            var table_row = a.closest('tr');
602
            table_row.find('.ar-set-pending-request').remove();
603
            table_row.find('input[type="checkbox"]').prop('checked', false);
604
            a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
605
            $.ajax({
606
                type: "POST",
607
                url: '/cgi-bin/koha/svc/article_request',
608
                data: {
609
                    action: 'open',
610
                    id: id,
611
                },
612
                success: function( data ) {
613
                    $("img.spinner").remove();
614
                    requested_datatable.row( table_row ).remove().draw();
615
                    pending_datatable.row.add( table_row ).draw();
616
                    UpdateTabCounts();
617
                    activateBatchActions( active_tab );
618
                },
619
                dataType: 'json'
620
            });
621
        }
622
471
        function Process( id, a ) {
623
        function Process( id, a ) {
472
            var table_row = a.closest('tr');
624
            var table_row = a.closest('tr');
625
            var table = a.closest('table');
626
            var orig_datatable = table.attr('id')==='article-requests-pending-table'?pending_datatable:requested_datatable;
473
            table_row.find('.ar-process-request').remove();
627
            table_row.find('.ar-process-request').remove();
474
            table_row.find('input[type="checkbox"]').prop('checked', false);
628
            table_row.find('input[type="checkbox"]').prop('checked', false);
475
629
Lines 483-489 Link Here
483
                },
637
                },
484
                success: function( data ) {
638
                success: function( data ) {
485
                    $("img.spinner").remove();
639
                    $("img.spinner").remove();
486
                    pending_datatable.row( table_row ).remove().draw();
640
                    orig_datatable.row( table_row ).remove().draw();
487
                    processing_datatable.row.add( table_row ).draw();
641
                    processing_datatable.row.add( table_row ).draw();
488
                    UpdateTabCounts();
642
                    UpdateTabCounts();
489
                    activateBatchActions( active_tab );
643
                    activateBatchActions( active_tab );
Lines 517-522 Link Here
517
        }
671
        }
518
672
519
        function UpdateTabCounts() {
673
        function UpdateTabCounts() {
674
            $("#ar_requested_count").html( requested_datatable.rows().count() );
520
            $("#ar_pending_count").html( pending_datatable.rows().count() );
675
            $("#ar_pending_count").html( pending_datatable.rows().count() );
521
            $("#ar_processing_count").html( processing_datatable.rows().count() );
676
            $("#ar_processing_count").html( processing_datatable.rows().count() );
522
        }
677
        }
(-)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