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

(-)a/Koha/REST/V1/Items.pm (+60 lines)
Lines 20-25 use Modern::Perl; Link Here
20
use Mojo::Base 'Mojolicious::Controller';
20
use Mojo::Base 'Mojolicious::Controller';
21
21
22
use Koha::Items;
22
use Koha::Items;
23
use Koha::DateUtils qw( dt_from_string output_pref );
24
25
use C4::Letters qw(GetPreparedLetter);
23
26
24
use List::MoreUtils qw( any );
27
use List::MoreUtils qw( any );
25
use Try::Tiny qw( catch try );
28
use Try::Tiny qw( catch try );
Lines 269-272 sub remove_from_bundle { Link Here
269
    );
272
    );
270
}
273
}
271
274
275
=head3 print_slip
276
277
Controller function that handles constructing and returning the contents for a print slip for this item
278
279
=cut
280
281
sub print_slip {
282
    my $c = shift->openapi->valid_input or return;
283
284
    my $item_id = $c->validation->param('item_id');
285
    my $item = Koha::Items->find( $item_id );
286
287
    unless ($item) {
288
        return $c->render(
289
            status  => 404,
290
            openapi => { error => "Item not found" }
291
        );
292
    }
293
294
    my $print_slip_id = $c->validation->param('slip_id');
295
296
    #FIXME: This should come from the session
297
    my $user       = $c->stash('koha.user');
298
    my $branchcode = $user->branchcode;
299
    my $lang       = $user->lang;
300
301
    my $slip = C4::Letters::GetPreparedLetter(
302
        module                 => 'circulation',
303
        letter_code            => $print_slip_id,
304
        branchcode             => $branchcode,
305
        message_transport_type => 'print',
306
        #lang                  => $lang,
307
        tables                 => {
308
            items => $item_id
309
        }
310
    );
311
312
    unless ($slip) {
313
        return $c->render(
314
            status  => 404,
315
            openapi => { error => "Slip not found" }
316
        );
317
    }
318
319
    return $c->render(
320
        status  => 200,
321
        openapi => {
322
            timestamp => output_pref(
323
                { dt => dt_from_string(), dateformat => 'rfc3339' }
324
            ),
325
            slip_id => $print_slip_id,
326
            content => $slip->{content},
327
            title   => $slip->{title}
328
        }
329
    );
330
}
331
272
1;
332
1;
(-)a/api/v1/swagger/definitions/slip.yaml (+18 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  slip_id:
5
    type: string
6
    readOnly: true
7
    description: unique identifier code for the slip template
8
  content:
9
    type: string
10
    description: Raw string content of the generated slip
11
  title:
12
    type: string
13
    description: Raw string title of generated slip
14
  timestamp:
15
    type: string
16
    format: date-time
17
    description: timestamp of date the slip content was generated
18
additionalProperties: false
(-)a/api/v1/swagger/paths/items.yaml (+91 lines)
Lines 316-318 Link Here
316
    x-koha-authorization:
316
    x-koha-authorization:
317
      permissions:
317
      permissions:
318
        reserveforothers: place_holds
318
        reserveforothers: place_holds
319
/items/{item_id}/print_slips/{slip_id}:
320
  get:
321
    x-mojo-to: Items#print_slip
322
    operationId: printSlipItems
323
    tags:
324
      - items
325
    summary: Print slip for item as defined in notices and slips
326
    parameters:
327
      - $ref: ../swagger.yaml#/parameters#/item_id_pp
328
      - name: slip_id
329
        in: path
330
        description: The required slip letter code identifier
331
        required: true
332
        type: string
333
    produces:
334
      - application/json
335
    responses:
336
      "200":
337
        description: A slip object
338
        schema:
339
          $ref: ../swagger.yaml#/definitions#/slip
340
      "401":
341
        description: Authentication required
342
        schema:
343
          $ref: ../swagger.yaml#/definitions#/error
344
      "403":
345
        description: Access forbidden
346
        schema:
347
          $ref: ../swagger.yaml#/definitions#/error
348
      "500":
349
        description: Internal server error
350
        schema:
351
          $ref: ../swagger.yaml#/definitions#/error
352
      "503":
353
        description: Under maintenance
354
        schema:
355
          $ref: ../swagger.yaml#/definitions#/error
356
    x-koha-authorization:
357
      permissions:
358
        catalogue: "1"
359
/public/items/{item_id}/bundled_items:
360
  get:
361
    x-mojo-to: Items#bundled_items
362
    operationId: bundledItemsPublic
363
    tags:
364
      - items
365
    summary: List bundled items
366
    parameters:
367
      - $ref: ../swagger.yaml#/parameters#/item_id_pp
368
      - name: external_id
369
        in: query
370
        description: Search on the item's barcode
371
        required: false
372
        type: string
373
      - $ref: ../swagger.yaml#/parameters#/match
374
      - $ref: ../swagger.yaml#/parameters#/order_by
375
      - $ref: ../swagger.yaml#/parameters#/page
376
      - $ref: ../swagger.yaml#/parameters#/per_page
377
      - $ref: ../swagger.yaml#/parameters#/q_param
378
      - $ref: ../swagger.yaml#/parameters#/q_body
379
      - $ref: ../swagger.yaml#/parameters#/q_header
380
    consumes:
381
      - application/json
382
    produces:
383
      - application/json
384
    responses:
385
      "200":
386
        description: A list of item
387
        schema:
388
          type: array
389
          items:
390
            $ref: ../swagger.yaml#/definitions#/item
391
      "401":
392
        description: Authentication required
393
        schema:
394
          $ref: ../swagger.yaml#/definitions#/error
395
      "403":
396
        description: Access forbidden
397
        schema:
398
          $ref: ../swagger.yaml#/definitions#/error
399
      "500":
400
        description: Internal server error
401
        schema:
402
          $ref: ../swagger.yaml#/definitions#/error
403
      "503":
404
        description: Under maintenance
405
        schema:
406
          $ref: ../swagger.yaml#/definitions#/error
407
    x-koha-embed:
408
      - biblio
409
      - checkout
(-)a/api/v1/swagger/swagger.yaml (-1 / +4 lines)
Lines 60-65 definitions: Link Here
60
    $ref: ./definitions/quote.yaml
60
    $ref: ./definitions/quote.yaml
61
  return_claim:
61
  return_claim:
62
    $ref: ./definitions/return_claim.yaml
62
    $ref: ./definitions/return_claim.yaml
63
  slip:
64
    $ref: ./definitions/slip.yaml
63
  smtp_server:
65
  smtp_server:
64
    $ref: ./definitions/smtp_server.yaml
66
    $ref: ./definitions/smtp_server.yaml
65
  suggestion:
67
  suggestion:
Lines 161-166 paths: Link Here
161
    $ref: ./paths/items.yaml#/~1items~1{item_id}~1bundled_items~1{bundled_item_id}
163
    $ref: ./paths/items.yaml#/~1items~1{item_id}~1bundled_items~1{bundled_item_id}
162
  "/items/{item_id}/pickup_locations":
164
  "/items/{item_id}/pickup_locations":
163
    $ref: "./paths/items.yaml#/~1items~1{item_id}~1pickup_locations"
165
    $ref: "./paths/items.yaml#/~1items~1{item_id}~1pickup_locations"
166
  "/items/{item_id}/print_slips/{slip_id}":
167
    $ref: "./paths/items.yaml#/~1items~1{item_id}~1print_slips~1{slip_id}"
164
  /libraries:
168
  /libraries:
165
    $ref: ./paths/libraries.yaml#/~1libraries
169
    $ref: ./paths/libraries.yaml#/~1libraries
166
  "/libraries/{library_id}":
170
  "/libraries/{library_id}":
167
- 

Return to bug 29566