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

(-)a/Koha/REST/V1/ILL/Requests.pm (+25 lines)
Lines 58-63 sub list { Link Here
58
    };
58
    };
59
}
59
}
60
60
61
sub patron_list {
62
    my $c = shift->openapi->valid_input or return;
63
    my $user = $c->stash('koha.user');
64
65
    if ($user->borrowernumber != $c->param('patron_id') and !$user->is_superlibrarian) {
66
        return $c->render(
67
            status => 403,
68
            openapi => { error => "Cannot lookup ILL requests for other users" }
69
        );
70
    }
71
72
    return try {
73
        my $reqs = $c->objects->search(Koha::ILL::Requests->search(
74
            { borrowernumber => $c->param('patron_id') }
75
        ));
76
77
        return $c->render(
78
            status  => 200,
79
            openapi => $reqs,
80
        );
81
    } catch {
82
        $c->unhandled_exception($_);
83
    };
84
}
85
61
=head3 add
86
=head3 add
62
87
63
Adds a new ILL request
88
Adds a new ILL request
(-)a/api/v1/swagger/paths/patrons.yaml (+66 lines)
Lines 662-664 Link Here
662
    x-koha-authorization:
662
    x-koha-authorization:
663
      permissions:
663
      permissions:
664
        borrowers: delete_borrowers
664
        borrowers: delete_borrowers
665
"/patrons/{patron_id}/ill/requests":
666
  get:
667
    x-mojo-to: ILL::Requests#patron_list
668
    operationId: getPatronIllRequests
669
    tags:
670
      - patrons
671
      - ill_requests
672
    summary: Get patron's ILL requests
673
    parameters:
674
      - $ref: "../swagger.yaml#/parameters/patron_id_pp"
675
      - $ref: "../swagger.yaml#/parameters/page"
676
      - $ref: "../swagger.yaml#/parameters/per_page"
677
      - $ref: "../swagger.yaml#/parameters/match"
678
      - $ref: "../swagger.yaml#/parameters/order_by"
679
      - $ref: "../swagger.yaml#/parameters/q_param"
680
      - $ref: "../swagger.yaml#/parameters/q_body"
681
      - $ref: "../swagger.yaml#/parameters/request_id_header"
682
      - name: x-koha-embed
683
        in: header
684
        required: false
685
        description: Embed list sent as a request header
686
        type: array
687
        items:
688
          type: string
689
          enum:
690
            - +strings
691
            - extended_attributes
692
        collectionFormat: csv
693
    produces:
694
      - application/json
695
    responses:
696
      "200":
697
        description: A list of parton's ILL requests
698
        schema:
699
          type: array
700
          items:
701
            $ref: "../swagger.yaml#/definitions/ill_request"
702
      "400":
703
        description: Bad request
704
        schema:
705
          $ref: "../swagger.yaml#/definitions/error"
706
      "401":
707
        description: Authentication required
708
        schema:
709
          $ref: "../swagger.yaml#/definitions/error"
710
      "403":
711
        description: Access forbidden
712
        schema:
713
          $ref: "../swagger.yaml#/definitions/error"
714
      "404":
715
        description: Patron not found
716
        schema:
717
          $ref: "../swagger.yaml#/definitions/error"
718
      "500":
719
        description: |
720
          Internal server error. Possible `error_code` attribute values:
721
722
          * `internal_server_error`
723
        schema:
724
          $ref: "../swagger.yaml#/definitions/error"
725
      "503":
726
        description: Under maintenance
727
        schema:
728
          $ref: "../swagger.yaml#/definitions/error"
729
    x-koha-authorization:
730
      permissions: {}
(-)a/api/v1/swagger/swagger.yaml (+2 lines)
Lines 477-482 paths: Link Here
477
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password~1expiration_date"
477
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password~1expiration_date"
478
  "/patrons/{patron_id}/recalls":
478
  "/patrons/{patron_id}/recalls":
479
    $ref: "./paths/patrons_recalls.yaml#/~1patrons~1{patron_id}~1recalls"
479
    $ref: "./paths/patrons_recalls.yaml#/~1patrons~1{patron_id}~1recalls"
480
  "/patrons/{patron_id}/ill/requests":
481
    $ref: "./paths/patrons.yaml#/~1patrons~1{patron_id}~1ill~1requests"
480
  /patron_categories:
482
  /patron_categories:
481
    $ref: ./paths/patron_categories.yaml#/~1patron_categories
483
    $ref: ./paths/patron_categories.yaml#/~1patron_categories
482
  /preservation/config:
484
  /preservation/config:
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc (+1 lines)
Lines 87-91 Link Here
87
[% Asset.css("lib/fontawesome/css/fontawesome.min.css") | $raw %]
87
[% Asset.css("lib/fontawesome/css/fontawesome.min.css") | $raw %]
88
[% Asset.css("lib/fontawesome/css/brands.min.css") | $raw %]
88
[% Asset.css("lib/fontawesome/css/brands.min.css") | $raw %]
89
[% Asset.css("lib/fontawesome/css/solid.min.css") | $raw %]
89
[% Asset.css("lib/fontawesome/css/solid.min.css") | $raw %]
90
[% Asset.css("lib/datatables/datatables.min.css") | $raw %]
90
[% PROCESS 'html_helpers.inc' %]
91
[% PROCESS 'html_helpers.inc' %]
91
[% KohaPlugins.get_plugins_opac_head | $raw %]
92
[% KohaPlugins.get_plugins_opac_head | $raw %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt (-21 / +125 lines)
Lines 152-174 Link Here
152
                                    </tr>
152
                                    </tr>
153
                                </thead>
153
                                </thead>
154
                                <tbody>
154
                                <tbody>
155
                                    [% FOREACH request IN requests %]
156
                                        [% status = request.status | html %]
157
                                        [% type = request.get_type %]
158
                                        <tr>
159
                                            <td>[% request.id | html %]</td>
160
                                            <td> [% IF request.metadata.Author %][% request.metadata.Author | html %][% ELSE %]<span>N/A</span>[% END %] </td>
161
                                            <td> [% IF request.metadata.Title %][% request.metadata.Title | html %][% ELSE %]<span>N/A</span>[% END %] </td>
162
                                            <td>[% request.backend | html %]</td>
163
                                            <td> [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %] </td>
164
                                            <td>[% request.status_alias ? request.statusalias.lib_opac : request.capabilities.$status.name | html %]</td>
165
                                            <td data-order="[% request.placed | html %]">[% request.placed | $KohaDates %]</td>
166
                                            <td data-order="[% request.updated | html %]">[% request.updated | $KohaDates %]</td>
167
                                            <td>
168
                                                <a href="/cgi-bin/koha/opac-illrequests.pl?op=view&amp;illrequest_id=[% request.id | uri %]" class="btn btn-primary btn-sm">View</a>
169
                                            </td>
170
                                        </tr>
171
                                    [% END %]
172
                                </tbody>
155
                                </tbody>
173
                            </table>
156
                            </table>
174
                        [% ELSIF op == 'view' %]
157
                        [% ELSIF op == 'view' %]
Lines 411-420 Link Here
411
[% BLOCK jsinclude %]
394
[% BLOCK jsinclude %]
412
    [% INCLUDE 'datatables.inc' %]
395
    [% INCLUDE 'datatables.inc' %]
413
    <script>
396
    <script>
414
        $("#illrequestlist").kohaTable({
397
        function display_extended_attribute(row, type) {
415
            columnDefs: [{ targets: [-1], orderable: false, searchable: false }],
398
            var arr = $.grep(row.extended_attributes, ( x => x.type === type ));
416
            order: [[3, "desc"]],
399
            if (arr.length > 0) {
417
        });
400
                return escape_str(arr[0].value);
401
            }
402
403
            return '';
404
        }
405
406
        function display_request_status(row) {
407
            let status       = row._strings.status.str;
408
            let status_alias = row._strings.status_av ?
409
                                    row._strings.status_av.str ?
410
                                        row._strings.status_av.str :
411
                                    row._strings.status_av.code :
412
                               null;
413
414
            let status_label = status + (status_alias ? " <i><strong>"+status_alias+"</strong></i>" : "");
415
416
            return status_label;
417
        }
418
        $("#illrequestlist").dataTable($.extend(true, {}, dataTablesDefaults, {
419
            columns: [
420
                {
421
                    data: 'ill_request_id',
422
                    sortable: true,
423
                    render: (data, type, row, meta) => {
424
                        return data;
425
                    },
426
                },
427
                {
428
                    data: 'author',
429
                    sortable: false,
430
                    render: (data, type, row, meta) => {
431
                        return display_extended_attribute(row, 'author');
432
                    },
433
                },
434
                {
435
                    data: 'title',
436
                    sortable: false,
437
                    render: (data, type, row, meta) => {
438
                        return display_extended_attribute(row, 'title');
439
                    },
440
                },
441
                {
442
                    data: 'ill_backend_id',
443
                    sortable: true,
444
                    render: (data, type, row, meta) => {
445
                        return escape_str(data);
446
                    },
447
                },
448
                {
449
                    data: 'type',
450
                    sortable: false,
451
                    render: (data, type, row, meta) => {
452
                        return display_extended_attribute(row, 'type');
453
                    },
454
                },
455
                {
456
                    data: 'status',
457
                    sortable: true,
458
                    render: (data, type, row, meta) => {
459
                        return display_request_status(row);
460
                    },
461
                },
462
                {
463
                    data: 'requested_date',
464
                    sortable: true,
465
                    render: (data, type, row, meta) => {
466
                        return $date(data);
467
                    },
468
                },
469
                {
470
                    data: 'timestamp',
471
                    sortable: true,
472
                    render: (data, type, row, meta) => {
473
                        return $date(data);
474
                    },
475
                },
476
                {
477
                    data: '',
478
                    sortable: false,
479
                    render: (data, type, row, meta) => {
480
                        return `<a href="/cgi-bin/koha/opac-illrequests.pl?op=view&amp;illrequest_id=${row.ill_request_id}" class="btn btn-primary btn-sm">View</a>`;
481
                    },
482
                }
483
            ],
484
            "order": [[ 0, "desc" ]],
485
            "dom": '<"dt-info"i><"top pager"<"table_entries"lp>>tr<"bottom pager"ip>',
486
            "paging": true,
487
            "serverSide": true,
488
            "ajax": {
489
                "cache": true,
490
                "url": '/api/v1/patrons/[% logged_in_user.borrowernumber %]/ill/requests',
491
                'beforeSend': function (xhr, settings) {
492
                    this._xhr = xhr;
493
                    xhr.setRequestHeader('x-koha-embed', '+strings,extended_attributes');
494
                },
495
                "data": (data, settings) => {
496
                    const order = data.order[0];
497
                    const order_by = (order.dir == 'asc' ? '+' : '-') + 'me.' + data.columns[order.column].data;
498
                    const page = Math.floor(data.start / data.length) + 1;
499
                    return {
500
                        _page: page,
501
                        _per_page: data.length,
502
                        _order_by: order_by,
503
                    };
504
                },
505
                'dataFilter': function (data, type) {
506
                    const json = {data: JSON.parse(data)};
507
                    if (total = this._xhr.getResponseHeader('x-total-count')) {
508
                        json.recordsTotal = total;
509
                        json.recordsFiltered = total;
510
                    }
511
                    if (total = this._xhr.getResponseHeader('x-base-total-count')) {
512
                        json.recordsTotal = total;
513
                    }
514
                    if (draw = this._xhr.getResponseHeader('x-koha-request-id')) {
515
                        json.draw = draw;
516
                    }
517
518
                    return JSON.stringify(json);
519
                },
520
            },
521
        }));
418
        $("#backend-dropdown-options").removeClass("nojs");
522
        $("#backend-dropdown-options").removeClass("nojs");
419
        [% IF services_json.length > 0 %]
523
        [% IF services_json.length > 0 %]
420
            var services = [% services_json | $raw %];
524
            var services = [% services_json | $raw %];
(-)a/opac/opac-illrequests.pl (-10 / +1 lines)
Lines 95-113 if ( ( $op eq 'cud-create' || $op eq 'cancreq' || $op eq 'cud-update' ) && !$can Link Here
95
}
95
}
96
96
97
if ( $op eq 'list' ) {
97
if ( $op eq 'list' ) {
98
98
    $template->param( backends => $backends );
99
    my $requests = Koha::ILL::Requests->search( { borrowernumber => $loggedinuser } );
100
    $template->param(
101
        requests => $requests,
102
        backends => $backends
103
    );
104
105
} elsif ( $op eq 'view' ) {
99
} elsif ( $op eq 'view' ) {
106
    $template->param( request => $request );
100
    $template->param( request => $request );
107
108
} elsif ( $op eq 'cud-update' ) {
101
} elsif ( $op eq 'cud-update' ) {
109
    $request->notesopac( $params->{notesopac} )->store;
102
    $request->notesopac( $params->{notesopac} )->store;
110
111
    # Send a notice to staff alerting them of the update
103
    # Send a notice to staff alerting them of the update
112
    $request->send_staff_notice('ILL_REQUEST_MODIFIED');
104
    $request->send_staff_notice('ILL_REQUEST_MODIFIED');
113
    print $query->redirect(
105
    print $query->redirect(
114
- 

Return to bug 39600