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 473-478 paths: Link Here
473
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password~1expiration_date"
473
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password~1expiration_date"
474
  "/patrons/{patron_id}/recalls":
474
  "/patrons/{patron_id}/recalls":
475
    $ref: "./paths/patrons_recalls.yaml#/~1patrons~1{patron_id}~1recalls"
475
    $ref: "./paths/patrons_recalls.yaml#/~1patrons~1{patron_id}~1recalls"
476
  "/patrons/{patron_id}/ill/requests":
477
    $ref: "./paths/patrons.yaml#/~1patrons~1{patron_id}~1ill~1requests"
476
  /patron_categories:
478
  /patron_categories:
477
    $ref: ./paths/patron_categories.yaml#/~1patron_categories
479
    $ref: ./paths/patron_categories.yaml#/~1patron_categories
478
  /preservation/config:
480
  /preservation/config:
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc (+1 lines)
Lines 80-84 Link Here
80
[% Asset.css("lib/fontawesome/css/fontawesome.min.css") | $raw %]
80
[% Asset.css("lib/fontawesome/css/fontawesome.min.css") | $raw %]
81
[% Asset.css("lib/fontawesome/css/brands.min.css") | $raw %]
81
[% Asset.css("lib/fontawesome/css/brands.min.css") | $raw %]
82
[% Asset.css("lib/fontawesome/css/solid.min.css") | $raw %]
82
[% Asset.css("lib/fontawesome/css/solid.min.css") | $raw %]
83
[% Asset.css("lib/datatables/datatables.min.css") | $raw %]
83
[% PROCESS 'html_helpers.inc' %]
84
[% PROCESS 'html_helpers.inc' %]
84
[% KohaPlugins.get_plugins_opac_head | $raw %]
85
[% KohaPlugins.get_plugins_opac_head | $raw %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt (-26 / +122 lines)
Lines 152-180 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>
161
                                                [% IF request.metadata.Author %][% request.metadata.Author | html %][% ELSE %]<span>N/A</span>[% END %]
162
                                            </td>
163
                                            <td>
164
                                                [% IF request.metadata.Title %][% request.metadata.Title | html %][% ELSE %]<span>N/A</span>[% END %]
165
                                            </td>
166
                                            <td>[% request.backend | html %]</td>
167
                                            <td>
168
                                                [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %]
169
                                            </td>
170
                                            <td>[% request.status_alias ? request.statusalias.lib_opac : request.capabilities.$status.name | html %]</td>
171
                                            <td data-order="[% request.placed | html %]">[% request.placed | $KohaDates %]</td>
172
                                            <td data-order="[% request.updated | html %]">[% request.updated | $KohaDates %]</td>
173
                                            <td>
174
                                                <a href="/cgi-bin/koha/opac-illrequests.pl?op=view&amp;illrequest_id=[% request.id | uri %]" class="btn btn-primary btn-sm">View</a>
175
                                            </td>
176
                                        </tr>
177
                                    [% END %]
178
                                </tbody>
155
                                </tbody>
179
                            </table>
156
                            </table>
180
                        [% ELSIF op == 'view' %]
157
                        [% ELSIF op == 'view' %]
Lines 340-350 Link Here
340
[% BLOCK jsinclude %]
317
[% BLOCK jsinclude %]
341
    [% INCLUDE 'datatables.inc' %]
318
    [% INCLUDE 'datatables.inc' %]
342
    <script>
319
    <script>
320
        function display_extended_attribute(row, type) {
321
            var arr = $.grep(row.extended_attributes, ( x => x.type === type ));
322
            if (arr.length > 0) {
323
                return escape_str(arr[0].value);
324
            }
325
326
            return '';
327
        }
328
329
        function display_request_status(row) {
330
            let status       = row._strings.status.str;
331
            let status_alias = row._strings.status_av ?
332
                                    row._strings.status_av.str ?
333
                                        row._strings.status_av.str :
334
                                    row._strings.status_av.code :
335
                               null;
336
337
            let status_label = status + (status_alias ? " <i><strong>"+status_alias+"</strong></i>" : "");
338
339
            return status_label;
340
        }
343
        $("#illrequestlist").dataTable($.extend(true, {}, dataTablesDefaults, {
341
        $("#illrequestlist").dataTable($.extend(true, {}, dataTablesDefaults, {
344
            "columnDefs": [
342
            columns: [
345
                { "targets": [ -1 ], "sortable": false, "searchable": false }
343
                {
344
                    data: 'ill_request_id',
345
                    sortable: true,
346
                    render: (data, type, row, meta) => {
347
                        return data;
348
                    },
349
                },
350
                {
351
                    data: 'author',
352
                    sortable: false,
353
                    render: (data, type, row, meta) => {
354
                        return display_extended_attribute(row, 'author');
355
                    },
356
                },
357
                {
358
                    data: 'title',
359
                    sortable: false,
360
                    render: (data, type, row, meta) => {
361
                        return display_extended_attribute(row, 'title');
362
                    },
363
                },
364
                {
365
                    data: 'ill_backend_id',
366
                    sortable: true,
367
                    render: (data, type, row, meta) => {
368
                        return escape_str(data);
369
                    },
370
                },
371
                {
372
                    data: 'type',
373
                    sortable: false,
374
                    render: (data, type, row, meta) => {
375
                        return display_extended_attribute(row, 'type');
376
                    },
377
                },
378
                {
379
                    data: 'status',
380
                    sortable: true,
381
                    render: (data, type, row, meta) => {
382
                        return display_request_status(row);
383
                    },
384
                },
385
                {
386
                    data: 'requested_date',
387
                    sortable: true,
388
                    render: (data, type, row, meta) => {
389
                        return $date(data);
390
                    },
391
                },
392
                {
393
                    data: 'timestamp',
394
                    sortable: true,
395
                    render: (data, type, row, meta) => {
396
                        return $date(data);
397
                    },
398
                },
399
                {
400
                    data: '',
401
                    sortable: false,
402
                    render: (data, type, row, meta) => {
403
                        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>`;
404
                    },
405
                }
346
            ],
406
            ],
347
            "order": [[ 3, "desc" ]],
407
            "order": [[ 0, "desc" ]],
408
            "dom": '<"dt-info"i><"top pager"<"table_entries"lp>>tr<"bottom pager"ip>',
409
            "paging": true,
410
            "serverSide": true,
411
            "ajax": {
412
                "cache": true,
413
                "url": '/api/v1/patrons/[% logged_in_user.borrowernumber %]/ill/requests',
414
                'beforeSend': function (xhr, settings) {
415
                    this._xhr = xhr;
416
                    xhr.setRequestHeader('x-koha-embed', '+strings,extended_attributes');
417
                },
418
                "data": (data, settings) => {
419
                    const order = data.order[0];
420
                    const order_by = (order.dir == 'asc' ? '+' : '-') + 'me.' + data.columns[order.column].data;
421
                    const page = Math.floor(data.start / data.length) + 1;
422
                    return {
423
                        _page: page,
424
                        _per_page: data.length,
425
                        _order_by: order_by,
426
                    };
427
                },
428
                'dataFilter': function (data, type) {
429
                    const json = {data: JSON.parse(data)};
430
                    if (total = this._xhr.getResponseHeader('x-total-count')) {
431
                        json.recordsTotal = total;
432
                        json.recordsFiltered = total;
433
                    }
434
                    if (total = this._xhr.getResponseHeader('x-base-total-count')) {
435
                        json.recordsTotal = total;
436
                    }
437
                    if (draw = this._xhr.getResponseHeader('x-koha-request-id')) {
438
                        json.draw = draw;
439
                    }
440
441
                    return JSON.stringify(json);
442
                },
443
            },
348
        }));
444
        }));
349
        $("#backend-dropdown-options").removeClass("nojs");
445
        $("#backend-dropdown-options").removeClass("nojs");
350
        [% IF services_json.length > 0 %]
446
        [% IF services_json.length > 0 %]
(-)a/opac/opac-illrequests.pl (-8 lines)
Lines 80-99 if ( ( $op eq 'cud-create' || $op eq 'cancreq' || $op eq 'cud-update' ) && !$can Link Here
80
}
80
}
81
81
82
if ( $op eq 'list' ) {
82
if ( $op eq 'list' ) {
83
84
    my $requests = Koha::ILL::Requests->search(
85
        { borrowernumber => $loggedinuser }
86
    );
87
    $template->param(
83
    $template->param(
88
        requests => $requests,
89
        backends => $backends
84
        backends => $backends
90
    );
85
    );
91
92
} elsif ( $op eq 'view') {
86
} elsif ( $op eq 'view') {
93
    $template->param(
87
    $template->param(
94
        request => $request
88
        request => $request
95
    );
89
    );
96
97
} elsif ( $op eq 'cud-update') {
90
} elsif ( $op eq 'cud-update') {
98
    $request->notesopac($params->{notesopac})->store;
91
    $request->notesopac($params->{notesopac})->store;
99
    # Send a notice to staff alerting them of the update
92
    # Send a notice to staff alerting them of the update
100
- 

Return to bug 39600