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 146-168 Link Here
146
                                    </tr>
146
                                    </tr>
147
                                </thead>
147
                                </thead>
148
                                <tbody>
148
                                <tbody>
149
                                    [% FOREACH request IN requests %]
150
                                        [% status = request.status | html %]
151
                                        [% type = request.get_type %]
152
                                        <tr>
153
                                            <td>[% request.id | html %]</td>
154
                                            <td> [% IF request.metadata.Author %][% request.metadata.Author | html %][% ELSE %]<span>N/A</span>[% END %] </td>
155
                                            <td> [% IF request.metadata.Title %][% request.metadata.Title | html %][% ELSE %]<span>N/A</span>[% END %] </td>
156
                                            <td>[% request.backend | html %]</td>
157
                                            <td> [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %] </td>
158
                                            <td>[% request.status_alias ? request.statusalias.lib_opac : request.capabilities.$status.name | html %]</td>
159
                                            <td data-order="[% request.placed | html %]">[% request.placed | $KohaDates %]</td>
160
                                            <td data-order="[% request.updated | html %]">[% request.updated | $KohaDates %]</td>
161
                                            <td>
162
                                                <a href="/cgi-bin/koha/opac-illrequests.pl?op=view&amp;illrequest_id=[% request.id | uri %]" class="btn btn-primary btn-sm">View</a>
163
                                            </td>
164
                                        </tr>
165
                                    [% END %]
166
                                </tbody>
149
                                </tbody>
167
                            </table>
150
                            </table>
168
                        [% ELSIF op == 'view' %]
151
                        [% ELSIF op == 'view' %]
Lines 334-343 Link Here
334
[% BLOCK jsinclude %]
317
[% BLOCK jsinclude %]
335
    [% INCLUDE 'datatables.inc' %]
318
    [% INCLUDE 'datatables.inc' %]
336
    <script>
319
    <script>
337
        $("#illrequestlist").kohaTable({
320
        function display_extended_attribute(row, type) {
338
            columnDefs: [{ targets: [-1], orderable: false, searchable: false }],
321
            var arr = $.grep(row.extended_attributes, ( x => x.type === type ));
339
            order: [[3, "desc"]],
322
            if (arr.length > 0) {
340
        });
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
        }
341
        $("#illrequestlist").dataTable($.extend(true, {}, dataTablesDefaults, {
342
            columns: [
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
                }
406
            ],
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
            },
444
        }));
341
        $("#backend-dropdown-options").removeClass("nojs");
445
        $("#backend-dropdown-options").removeClass("nojs");
342
        [% IF services_json.length > 0 %]
446
        [% IF services_json.length > 0 %]
343
            var services = [% services_json | $raw %];
447
            var services = [% services_json | $raw %];
(-)a/opac/opac-illrequests.pl (-10 / +1 lines)
Lines 83-101 if ( ( $op eq 'cud-create' || $op eq 'cancreq' || $op eq 'cud-update' ) && !$can Link Here
83
}
83
}
84
84
85
if ( $op eq 'list' ) {
85
if ( $op eq 'list' ) {
86
86
    $template->param( backends => $backends );
87
    my $requests = Koha::ILL::Requests->search( { borrowernumber => $loggedinuser } );
88
    $template->param(
89
        requests => $requests,
90
        backends => $backends
91
    );
92
93
} elsif ( $op eq 'view' ) {
87
} elsif ( $op eq 'view' ) {
94
    $template->param( request => $request );
88
    $template->param( request => $request );
95
96
} elsif ( $op eq 'cud-update' ) {
89
} elsif ( $op eq 'cud-update' ) {
97
    $request->notesopac( $params->{notesopac} )->store;
90
    $request->notesopac( $params->{notesopac} )->store;
98
99
    # Send a notice to staff alerting them of the update
91
    # Send a notice to staff alerting them of the update
100
    $request->send_staff_notice('ILL_REQUEST_MODIFIED');
92
    $request->send_staff_notice('ILL_REQUEST_MODIFIED');
101
    print $query->redirect(
93
    print $query->redirect(
102
- 

Return to bug 39600