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 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 / +159 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 73-79 Link Here
73
78
74
    <div class="main container-fluid starthidden">
79
    <div class="main container-fluid starthidden">
75
        <div class="row">
80
        <div class="row">
76
            <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
81
            <div class="col-md-10 col-md-offset-1 col-lg-10 col-lg-offset-1">
77
82
78
                <h1>Article requests</h1>
83
                <h1>Article requests</h1>
79
84
Lines 95-100 Link Here
95
100
96
                <div id="article-request-tabs" class="toptabs">
101
                <div id="article-request-tabs" class="toptabs">
97
                    <ul>
102
                    <ul>
103
                        <li>
104
                            <a href="#article-requests-requested">
105
                                New (<span id="ar_requested_count">[% article_requests_requested.count | html %]</span>)
106
                            </a>
107
                        </li>
108
98
                        <li>
109
                        <li>
99
                            <a href="#article-requests-pending">
110
                            <a href="#article-requests-pending">
100
                                Pending (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
111
                                Pending (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
Lines 108-113 Link Here
108
                        </li>
119
                        </li>
109
                    </ul>
120
                    </ul>
110
121
122
                    <div id="article-requests-requested">
123
                        <div class="article-requests-requested_table_controls">
124
                            <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>
125
                            [% PROCESS actions menuid='article-menu-requested' id_arg=0 pull_right='' aria_menu='table_controls' %]
126
                        </div>
127
128
                        <table id="article-requests-requested-table">
129
                            <thead>
130
                                <tr>
131
                                    <th/>
132
                                    <th class="ar-title">Title</th>
133
                                    <th class="ar-request">Requested article</th>
134
                                    <th class="ar-collection">Collection</th>
135
                                    <th class="ar-itemtype">Item type</th>
136
                                    <th class="ar-callnumber">Call number</th>
137
                                    <th class="ar-status">Status</th>
138
                                    <th class="ar-copynumber">Copy number</th>
139
                                    <th class="ar-enumchron">Enumeration</th>
140
                                    <th class="ar-barcode">Barcode</th>
141
                                    <th class="ar-patron">Patron</th>
142
                                    <th class="ar-date">Date</th>
143
                                    <th class="ar-actions noExport">Actions</th>
144
                                </tr>
145
                            </thead>
146
147
                             <tbody>
148
                                [% FOREACH ar IN article_requests_requested %]
149
                                    <tr class="ar-row ar-requested">
150
                                        <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
151
                                        <td class="ar-title">
152
                                            <p>
153
                                                <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
154
                                                    [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
155
                                                </a>
156
                                            </p>
157
158
                                            <p>
159
                                                <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
160
                                                <div class="ar-author">[% ar.biblio.author | html %]</div>
161
                                                <div class="ar-pubdata">
162
                                                    [% ar.biblio.biblioitem.publishercode | html %]
163
164
                                                    [% IF ar.biblio.biblioitem.publicationyear %]
165
                                                        [% ar.biblio.biblioitem.publicationyear | html %]
166
                                                    [% ELSIF ar.biblio.copyrightdate %]
167
                                                        [% ar.biblio.copyrightdate | html %]
168
                                                    [% END %]
169
170
                                                    [% IF ar.biblio.biblioitem.pages %]
171
                                                        : [% ar.biblio.biblioitem.pages | html %]
172
                                                    [% END %]
173
174
                                                    [% r.biblio.biblioitem.size | html %]
175
176
                                                    [% IF ar.biblio.biblioitem.isbn %]
177
                                                        ISBN: [% ar.biblio.biblioitem.isbn | html %]
178
                                                    [% END %]
179
                                                </div>
180
                                            </p>
181
                                        </td>
182
                                        <td class="ar-request">
183
                                            [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title | html %]        </p> [% END %]
184
                                            [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author | html %]       </p> [% END %]
185
                                            [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume | html %]       </p> [% END %]
186
                                            [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue | html %]        </p> [% END %]
187
                                            [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date | html %]         </p> [% END %]
188
                                            [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages | html %]        </p> [% END %]
189
                                            [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters | html %]     </p> [% END %]
190
                                            [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
191
                                        </td>
192
                                        <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
193
                                        <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
194
                                        <td class="ar-callnumber">
195
                                            [% IF ar.item.location %]
196
                                                <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
197
                                            [% END %]
198
199
                                            [% ar.item.itemcallnumber | html %]
200
                                        </td>
201
                                        <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
202
                                        <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
203
                                        <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
204
                                        <td class="ar-barcode">[% ar.item.barcode | html %]</td>
205
                                        <td class="ar-patron">
206
                                            <p>
207
                                                <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
208
                                                    [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
209
                                                </a>
210
                                            </p>
211
212
                                            <p>[% ar.borrower.phone | html %]</p>
213
                                        </td>
214
                                        <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
215
                                        <td class="ar-actions">
216
                                            [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
217
                                        </td>
218
                                    </tr>
219
                                [% END %]
220
                            </tbody>
221
                        </table>
222
                    </div>
223
111
                    <div id="article-requests-pending">
224
                    <div id="article-requests-pending">
112
                        <div class="article-requests-pending_table_controls">
225
                        <div class="article-requests-pending_table_controls">
113
                            <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>
226
                            <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 317-329 Link Here
317
[% MACRO jsinclude BLOCK %]
430
[% MACRO jsinclude BLOCK %]
318
    [% INCLUDE 'datatables.inc' %]
431
    [% INCLUDE 'datatables.inc' %]
319
    <script>
432
    <script>
320
        var active_tab = "#article-requests-pending";
433
        var active_tab = "#article-requests-requested";
321
        var last_cancel_reason, pending_datatable, processing_datatable, active_datatable;
434
        var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable;
322
        $(document).ready(function() {
435
        $(document).ready(function() {
323
            $('#article-request-tabs').tabs({
436
            $('#article-request-tabs').tabs({
324
                activate: function( activate_event, activate_ui ) {
437
                activate: function( activate_event, activate_ui ) {
325
                    active_tab = activate_ui.newPanel.selector;
438
                    active_tab = activate_ui.newPanel.selector;
326
                    if( active_tab == '#article-requests-pending' )
439
                    if( active_tab == '#article-requests-requested' )
440
                        active_datatable = requested_datatable;
441
                    else if( active_tab == '#article-requests-pending' )
327
                        active_datatable = pending_datatable;
442
                        active_datatable = pending_datatable;
328
                    else active_datatable = processing_datatable;
443
                    else active_datatable = processing_datatable;
329
                    activateBatchActions( active_tab );
444
                    activateBatchActions( active_tab );
Lines 347-368 Link Here
347
            });
462
            });
348
            $("a.ar-actions").on('click', function(e) {
463
            $("a.ar-actions").on('click', function(e) {
349
                // Hide menu option ?
464
                // Hide menu option ?
350
                if( $('#article-requests-processing-table').is(":visible") )
465
                if( $('#article-requests-requested-table:visible,#article-requests-pending-table:visible').length )
351
                    $('a.ar-process-request').hide();
466
                    $('a.ar-process-request').show();
352
                else $('a.ar-process-request').show();
467
                else $('a.ar-process-request').hide();
468
469
                if( $('#article-requests-requested-table').is(":visible") )
470
                    $('a.ar-open-request').show();
471
                else $('a.ar-open-request').hide();
353
            });
472
            });
354
473
474
            requested_datatable = $("#article-requests-requested-table").DataTable($.extend(true, {}, dataTablesDefaults, {
475
                "aoColumnDefs": [
476
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
477
                ],
478
            }));
355
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
479
            pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
356
                "aoColumnDefs": [
480
                "aoColumnDefs": [
357
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
481
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
358
                ],
482
                ],
359
            }));
483
            }));
360
            active_datatable = pending_datatable;
361
            processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
484
            processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
362
                "aoColumnDefs": [
485
                "aoColumnDefs": [
363
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
486
                    { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
364
                ],
487
                ],
365
            }));
488
            }));
489
            active_datatable = requested_datatable;
366
            activateBatchActions( active_tab );
490
            activateBatchActions( active_tab );
367
            $(".starthidden").show();
491
            $(".starthidden").show();
368
        });
492
        });
Lines 422-429 Link Here
422
            });
546
            });
423
        }
547
        }
424
548
549
        function Open( id, a ) {
550
            var table_row = a.closest('tr');
551
            table_row.find('.ar-open-request').remove();
552
            table_row.find('input[type="checkbox"]').prop('checked', false);
553
            a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
554
            $.ajax({
555
                type: "POST",
556
                url: '/cgi-bin/koha/svc/article_request',
557
                data: {
558
                    action: 'open',
559
                    id: id,
560
                },
561
                success: function( data ) {
562
                    $("img.spinner").remove();
563
                    requested_datatable.row( table_row ).remove().draw();
564
                    pending_datatable.row.add( table_row ).draw();
565
                    UpdateTabCounts();
566
                    activateBatchActions( active_tab );
567
                },
568
                dataType: 'json'
569
            });
570
        }
571
425
        function Process( id, a ) {
572
        function Process( id, a ) {
426
            var table_row = a.closest('tr');
573
            var table_row = a.closest('tr');
574
            var table = a.closest('table');
575
            var orig_datatable = table.attr('id')==='article-requests-pending-table'?pending_datatable:requested_datatable;
427
            table_row.find('.ar-process-request').remove();
576
            table_row.find('.ar-process-request').remove();
428
            table_row.find('input[type="checkbox"]').prop('checked', false);
577
            table_row.find('input[type="checkbox"]').prop('checked', false);
429
578
Lines 437-443 Link Here
437
                },
586
                },
438
                success: function( data ) {
587
                success: function( data ) {
439
                    $("img.spinner").remove();
588
                    $("img.spinner").remove();
440
                    pending_datatable.row( table_row ).remove().draw();
589
                    orig_datatable.row( table_row ).remove().draw();
441
                    processing_datatable.row.add( table_row ).draw();
590
                    processing_datatable.row.add( table_row ).draw();
442
                    UpdateTabCounts();
591
                    UpdateTabCounts();
443
                    activateBatchActions( active_tab );
592
                    activateBatchActions( active_tab );
Lines 465-470 Link Here
465
        }
614
        }
466
615
467
        function UpdateTabCounts() {
616
        function UpdateTabCounts() {
617
            $("#ar_requested_count").html( requested_datatable.rows().count() );
468
            $("#ar_pending_count").html( pending_datatable.rows().count() );
618
            $("#ar_pending_count").html( pending_datatable.rows().count() );
469
            $("#ar_processing_count").html( processing_datatable.rows().count() );
619
            $("#ar_processing_count").html( processing_datatable.rows().count() );
470
        }
620
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt (+2 lines)
Lines 272-277 Link Here
272
                                                Pending
272
                                                Pending
273
                                            [% ELSIF ar.status == 'PROCESSING' %]
273
                                            [% ELSIF ar.status == 'PROCESSING' %]
274
                                                Processing
274
                                                Processing
275
                                            [% ELSIF ar.status == 'REQUESTED' %]
276
                                                New
275
                                            [% ELSIF ar.status == 'COMPLETED' %]
277
                                            [% ELSIF ar.status == 'COMPLETED' %]
276
                                                Completed
278
                                                Completed
277
                                            [% ELSIF ar.status == 'CANCELED' %]
279
                                            [% ELSIF ar.status == 'CANCELED' %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+2 lines)
Lines 778-783 Link Here
778
                                                        Pending
778
                                                        Pending
779
                                                    [% ELSIF ar.status == 'PROCESSING' %]
779
                                                    [% ELSIF ar.status == 'PROCESSING' %]
780
                                                        Processing
780
                                                        Processing
781
                                                    [% ELSIF ar.status == 'REQUESTED' %]
782
                                                        New
781
                                                    [% ELSIF ar.status == 'COMPLETED' %]
783
                                                    [% ELSIF ar.status == 'COMPLETED' %]
782
                                                        Completed
784
                                                        Completed
783
                                                    [% ELSIF ar.status == 'CANCELED' %]
785
                                                    [% 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