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

(-)a/Koha/ILL/Backend/Standard.pm (+1215 lines)
Line 0 Link Here
1
package Koha::ILL::Backend::Standard;
2
3
# Copyright PTFS Europe 2023
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use DateTime;
22
use File::Basename qw( dirname );
23
use C4::Installer;
24
25
use Koha::ILL::Requests;
26
use Koha::ILL::Request::Attribute;
27
use C4::Biblio  qw( AddBiblio );
28
use C4::Charset qw( MarcToUTF8Record );
29
30
=head1 NAME
31
32
Koha::ILL::Backend::Standard - Koha ILL Backend: Standard
33
34
=head1 SYNOPSIS
35
36
Koha ILL implementation for the "Standard" backend .
37
38
=head1 DESCRIPTION
39
40
=head2 Overview
41
42
We will be providing the Abstract interface which requires we implement the
43
following methods:
44
- create        -> initial placement of the request for an ILL order
45
- confirm       -> confirm placement of the ILL order (No-op in Standard)
46
- cancel        -> request an already 'confirm'ed ILL order be cancelled
47
- status_graph  -> return a hashref of additional statuses
48
- name          -> return the name of this backend
49
- metadata      -> return mapping of fields from requestattributes
50
51
=head2 On the Standard backend
52
53
The Standard backend is a simple backend that is supposed to act as a
54
fallback.  It provides the end user with some mandatory fields in a form as
55
well as the option to enter additional fields with arbitrary names & values.
56
57
=head1 API
58
59
=head2 Class Methods
60
61
=cut
62
63
=head3 new
64
65
my $backend = Koha::ILL::Backend::Standard->new;
66
67
=cut
68
69
sub new {
70
71
    # -> instantiate the backend
72
    my ( $class, $other ) = @_;
73
    my $framework =
74
        defined $other->{config}->{configuration}->{raw_config}->{framework}
75
        ? $other->{config}->{configuration}->{raw_config}->{framework}
76
        : 'FA';
77
    my $self = { framework => $framework };
78
    bless( $self, $class );
79
    return $self;
80
}
81
82
=head3 name
83
84
Return the name of this backend.
85
86
=cut
87
88
sub name {
89
    return "Standard";
90
}
91
92
=head3 capabilities
93
94
    $capability = $backend->capabilities($name);
95
96
Return the sub implementing a capability selected by NAME, or 0 if that
97
capability is not implemented.
98
99
=cut
100
101
sub capabilities {
102
    my ( $self, $name ) = @_;
103
    my ($query) = @_;
104
    my $capabilities = {
105
106
        # Get the requested partner email address(es)
107
        get_requested_partners => sub { _get_requested_partners(@_); },
108
109
        # Set the requested partner email address(es)
110
        set_requested_partners => sub { _set_requested_partners(@_); },
111
112
        # Migrate
113
        migrate => sub { $self->migrate(@_); },
114
115
        # Return whether we can create the request
116
        # i.e. the create form has been submitted
117
        can_create_request => sub { _can_create_request(@_) },
118
119
        # This is required for compatibility
120
        # with Koha versions prior to bug 33716
121
        should_display_availability => sub { _can_create_request(@_) },
122
123
        # View and manage a request
124
        illview => sub { illview(@_); },
125
126
        provides_batch_requests => sub { return 1; },
127
128
        # We can create ILL requests with data passed from the API
129
        create_api => sub { $self->create_api(@_) }
130
    };
131
    return $capabilities->{$name};
132
}
133
134
=head3 metadata
135
136
Return a hashref containing canonical values from the key/value
137
illrequestattributes store. We may want to ignore certain values
138
that we do not consider to be metadata
139
140
=cut
141
142
sub metadata {
143
    my ( $self, $request ) = @_;
144
    my $attrs       = $request->illrequestattributes;
145
    my $metadata    = {};
146
    my @ignore      = ( 'requested_partners', 'type', 'type_disclaimer_value', 'type_disclaimer_date' );
147
    my $core_fields = _get_core_fields();
148
    while ( my $attr = $attrs->next ) {
149
        my $type = $attr->type;
150
        if ( !grep { $_ eq $type } @ignore ) {
151
            my $name;
152
            $name = $core_fields->{$type} || ucfirst($type);
153
            $metadata->{$name} = $attr->value;
154
        }
155
    }
156
    return $metadata;
157
}
158
159
=head3 status_graph
160
161
This backend provides no additional actions on top of the core_status_graph.
162
163
=cut
164
165
sub status_graph {
166
    return {
167
        MIG => {
168
            prev_actions   => [ 'NEW', 'REQ', 'GENREQ', 'REQREV', 'QUEUED', 'CANCREQ', ],
169
            id             => 'MIG',
170
            name           => 'Switched provider',
171
            ui_method_name => 'Switch provider',
172
            method         => 'migrate',
173
            next_actions   => [],
174
            ui_method_icon => 'fa-search',
175
        },
176
        EDITITEM => {
177
            prev_actions   => ['NEW'],
178
            id             => 'EDITITEM',
179
            name           => 'Edited item metadata',
180
            ui_method_name => 'Edit item metadata',
181
            method         => 'edititem',
182
            next_actions   => [],
183
            ui_method_icon => 'fa-edit',
184
        },
185
186
    };
187
}
188
189
=head3 create
190
191
  my $response = $backend->create({ params => $params });
192
193
We just want to generate a form that allows the end-user to associate key
194
value pairs in the database.
195
196
=cut
197
198
sub create {
199
    my ( $self, $params ) = @_;
200
    my $other       = $params->{other};
201
    my $stage       = $other->{stage};
202
    my $core_fields = _get_core_string();
203
    if ( !$stage || $stage eq 'init' ) {
204
205
        # First thing we want to do, is check if we're receiving
206
        # an OpenURL and transform it into something we can
207
        # understand
208
        if ( $other->{openurl} ) {
209
210
            # We only want to transform once
211
            delete $other->{openurl};
212
            $params = _openurl_to_ill($params);
213
        }
214
215
        # We simply need our template .INC to produce a form.
216
        return {
217
            cwd     => dirname(__FILE__),
218
            error   => 0,
219
            status  => '',
220
            message => '',
221
            method  => 'create',
222
            stage   => 'form',
223
            value   => $params,
224
            core    => $core_fields
225
        };
226
    } elsif ( $stage eq 'form' ) {
227
228
        # We may be recieving a submitted form due to an additional
229
        # custom field being added or deleted, or the material type
230
        # having been changed, so check for these things
231
        if ( !_can_create_request($other) ) {
232
            if ( defined $other->{'add_new_custom'} ) {
233
                my ( $custom_keys, $custom_vals ) =
234
                    _get_custom( $other->{'custom_key'}, $other->{'custom_value'} );
235
                push @{$custom_keys}, '---';
236
                push @{$custom_vals}, '---';
237
                $other->{'custom_key'}   = join "\0", @{$custom_keys};
238
                $other->{'custom_value'} = join "\0", @{$custom_vals};
239
            } elsif ( defined $other->{'custom_delete'} ) {
240
                my $delete_idx = $other->{'custom_delete'};
241
                my ( $custom_keys, $custom_vals ) =
242
                    _get_custom( $other->{'custom_key'}, $other->{'custom_value'} );
243
                splice @{$custom_keys}, $delete_idx, 1;
244
                splice @{$custom_vals}, $delete_idx, 1;
245
                $other->{'custom_key'}   = join "\0", @{$custom_keys};
246
                $other->{'custom_value'} = join "\0", @{$custom_vals};
247
            } elsif ( defined $other->{'change_type'} ) {
248
249
                # We may be receiving a submitted form due to the user having
250
                # changed request material type, so we just need to go straight
251
                # back to the form, the type has been changed in the params
252
                delete $other->{'change_type'};
253
            }
254
            return {
255
                cwd     => dirname(__FILE__),
256
                status  => "",
257
                message => "",
258
                error   => 0,
259
                value   => $params,
260
                method  => "create",
261
                stage   => "form",
262
                core    => $core_fields
263
            };
264
        }
265
266
        # Received completed details of form.  Validate and create request.
267
        ## Validate
268
        my ( $brw_count, $brw ) =
269
            _validate_borrower( $other->{'cardnumber'} );
270
        my $result = {
271
            cwd     => dirname(__FILE__),
272
            status  => "",
273
            message => "",
274
            error   => 1,
275
            value   => {},
276
            method  => "create",
277
            stage   => "form",
278
            core    => $core_fields
279
        };
280
        my $failed = 0;
281
        if ( !$other->{'type'} ) {
282
            $result->{status} = "missing_type";
283
            $result->{value}  = $params;
284
            $failed           = 1;
285
        } elsif ( !$other->{'branchcode'} ) {
286
            $result->{status} = "missing_branch";
287
            $result->{value}  = $params;
288
            $failed           = 1;
289
        } elsif ( !Koha::Libraries->find( $other->{'branchcode'} ) ) {
290
            $result->{status} = "invalid_branch";
291
            $result->{value}  = $params;
292
            $failed           = 1;
293
        } elsif ( $brw_count == 0 ) {
294
            $result->{status} = "invalid_borrower";
295
            $result->{value}  = $params;
296
            $failed           = 1;
297
        } elsif ( $brw_count > 1 ) {
298
299
            # We must select a specific borrower out of our options.
300
            $params->{brw}   = $brw;
301
            $result->{value} = $params;
302
            $result->{stage} = "borrowers";
303
            $result->{error} = 0;
304
            $failed          = 1;
305
        }
306
        return $result if $failed;
307
308
        $self->add_request( { request => $params->{request}, other => $other } );
309
310
        my $request_details = _get_request_details( $params, $other );
311
312
        ## -> create response.
313
        return {
314
            cwd     => dirname(__FILE__),
315
            error   => 0,
316
            status  => '',
317
            message => '',
318
            method  => 'create',
319
            stage   => 'commit',
320
            next    => 'illview',
321
            value   => $request_details,
322
            core    => $core_fields
323
        };
324
    } else {
325
326
        # Invalid stage, return error.
327
        return {
328
            cwd     => dirname(__FILE__),
329
            error   => 1,
330
            status  => 'unknown_stage',
331
            message => '',
332
            method  => 'create',
333
            stage   => $params->{stage},
334
            value   => {},
335
        };
336
    }
337
}
338
339
=head3 edititem
340
341
=cut
342
343
sub edititem {
344
    my ( $self, $params ) = @_;
345
346
    my $core        = _get_core_fields();
347
    my $core_fields = _get_core_string();
348
349
    # Don't allow editing of submitted requests
350
    return { method => 'illlist' } if $params->{request}->status ne 'NEW';
351
352
    my $other = $params->{other};
353
    my $stage = $other->{stage};
354
    if ( !$stage || $stage eq 'init' ) {
355
356
        my $attrs = $params->{request}->illrequestattributes->unblessed;
357
358
        # We need to identify which parameters are custom, and pass them
359
        # to the template in a predefined form
360
        my $custom_keys = [];
361
        my $custom_vals = [];
362
        foreach my $attr ( @{$attrs} ) {
363
            if ( !$core->{ $attr->{type} } ) {
364
                push @{$custom_keys}, $attr->{type};
365
                push @{$custom_vals}, $attr->{value};
366
            } else {
367
                $other->{ $attr->{type} } = $attr->{value};
368
            }
369
        }
370
        $other->{'custom_key'}   = join "\0", @{$custom_keys};
371
        $other->{'custom_value'} = join "\0", @{$custom_vals};
372
373
        # Pass everything back to the template
374
        return {
375
            cwd     => dirname(__FILE__),
376
            error   => 0,
377
            status  => '',
378
            message => '',
379
            method  => 'edititem',
380
            stage   => 'form',
381
            value   => $params,
382
            core    => $core_fields
383
        };
384
    } elsif ( $stage eq 'form' ) {
385
386
        # We may be recieving a submitted form due to an additional
387
        # custom field being added or deleted, or the material type
388
        # having been changed, so check for these things
389
        if (   defined $other->{'add_new_custom'}
390
            || defined $other->{'custom_delete'}
391
            || defined $other->{'change_type'} )
392
        {
393
            if ( defined $other->{'add_new_custom'} ) {
394
                my ( $custom_keys, $custom_vals ) =
395
                    _get_custom( $other->{'custom_key'}, $other->{'custom_value'} );
396
                push @{$custom_keys}, '---';
397
                push @{$custom_vals}, '---';
398
                $other->{'custom_key'}   = join "\0", @{$custom_keys};
399
                $other->{'custom_value'} = join "\0", @{$custom_vals};
400
            } elsif ( defined $other->{'custom_delete'} ) {
401
                my $delete_idx = $other->{'custom_delete'};
402
                my ( $custom_keys, $custom_vals ) =
403
                    _get_custom( $other->{'custom_key'}, $other->{'custom_value'} );
404
                splice @{$custom_keys}, $delete_idx, 1;
405
                splice @{$custom_vals}, $delete_idx, 1;
406
                $other->{'custom_key'}   = join "\0", @{$custom_keys};
407
                $other->{'custom_value'} = join "\0", @{$custom_vals};
408
            } elsif ( defined $other->{'change_type'} ) {
409
410
                # We may be receiving a submitted form due to the user having
411
                # changed request material type, so we just need to go straight
412
                # back to the form, the type has been changed in the params
413
                delete $other->{'change_type'};
414
            }
415
            return {
416
                cwd     => dirname(__FILE__),
417
                status  => "",
418
                message => "",
419
                error   => 0,
420
                value   => $params,
421
                method  => "edititem",
422
                stage   => "form",
423
                core    => $core_fields
424
            };
425
        }
426
427
        # We don't want the request ID param getting any further
428
        delete $other->{illrequest_id};
429
430
        my $result = {
431
            cwd     => dirname(__FILE__),
432
            status  => "",
433
            message => "",
434
            error   => 1,
435
            value   => {},
436
            method  => "edititem",
437
            stage   => "form",
438
            core    => $core_fields
439
        };
440
441
        # Received completed details of form.  Validate and create request.
442
        ## Validate
443
        my $failed = 0;
444
        if ( !$other->{'type'} ) {
445
            $result->{status} = "missing_type";
446
            $result->{value}  = $params;
447
            $failed           = 1;
448
        }
449
        return $result if $failed;
450
451
        ## Update request
452
453
        # ...Update Illrequest
454
        my $request = $params->{request};
455
        $request->updated( DateTime->now );
456
        $request->store;
457
458
        # ...Populate Illrequestattributes
459
        # generate $request_details
460
        my $request_details = _get_request_details( $params, $other );
461
462
        # We do this with a 'dump all and repopulate approach' inside
463
        # a transaction, easier than catering for create, update & delete
464
        my $dbh    = C4::Context->dbh;
465
        my $schema = Koha::Database->new->schema;
466
        $schema->txn_do(
467
            sub {
468
                # Delete all existing attributes for this request
469
                $dbh->do(
470
                    q|
471
                    DELETE FROM illrequestattributes WHERE illrequest_id=?
472
                |, undef, $request->id
473
                );
474
475
                # Insert all current attributes for this request
476
                foreach my $attr ( keys %{$request_details} ) {
477
                    my $value = $request_details->{$attr};
478
                    if ( $value && length $value > 0 ) {
479
                        if ( column_exists( 'illrequestattributes', 'backend' ) ) {
480
                            my @bind = ( $request->id, 'Standard', $attr, $value, 0 );
481
                            $dbh->do(
482
                                q|
483
                                INSERT INTO illrequestattributes
484
                                (illrequest_id, backend, type, value, readonly) VALUES
485
                                (?, ?, ?, ?, ?)
486
                            |, undef, @bind
487
                            );
488
                        } else {
489
                            my @bind = ( $request->id, $attr, $value, 0 );
490
                            $dbh->do(
491
                                q|
492
                                INSERT INTO illrequestattributes
493
                                (illrequest_id, type, value, readonly) VALUES
494
                                (?, ?, ?, ?)
495
                            |, undef, @bind
496
                            );
497
                        }
498
                    }
499
                }
500
            }
501
        );
502
503
        ## -> create response.
504
        return {
505
            error   => 0,
506
            status  => '',
507
            message => '',
508
            method  => 'create',
509
            stage   => 'commit',
510
            next    => 'illview',
511
            value   => $request_details,
512
            core    => $core_fields
513
        };
514
    } else {
515
516
        # Invalid stage, return error.
517
        return {
518
            error   => 1,
519
            status  => 'unknown_stage',
520
            message => '',
521
            method  => 'create',
522
            stage   => $params->{stage},
523
            value   => {},
524
        };
525
    }
526
}
527
528
=head3 confirm
529
530
  my $response = $backend->confirm({ params => $params });
531
532
Confirm the placement of the previously "selected" request (by using the
533
'create' method).
534
535
In the Standard backend we only want to display a bit of text to let staff
536
confirm that they have taken the steps they need to take to "confirm" the
537
request.
538
539
=cut
540
541
sub confirm {
542
    my ( $self, $params ) = @_;
543
    my $stage = $params->{other}->{stage};
544
    if ( !$stage || $stage eq 'init' ) {
545
546
        # We simply need our template .INC to produce a text block.
547
        return {
548
            method => 'confirm',
549
            stage  => 'confirm',
550
            value  => $params,
551
        };
552
    } elsif ( $stage eq 'confirm' ) {
553
        my $request = $params->{request};
554
        $request->orderid( $request->illrequest_id );
555
        $request->status("REQ");
556
        $request->store;
557
558
        # ...then return our result:
559
        return {
560
            method => 'confirm',
561
            stage  => 'commit',
562
            next   => 'illview',
563
            value  => {},
564
        };
565
    } else {
566
567
        # Invalid stage, return error.
568
        return {
569
            error   => 1,
570
            status  => 'unknown_stage',
571
            message => '',
572
            method  => 'confirm',
573
            stage   => $params->{stage},
574
            value   => {},
575
        };
576
    }
577
}
578
579
=head3 cancel
580
581
  my $response = $backend->cancel({ params => $params });
582
583
We will attempt to cancel a request that was confirmed.
584
585
In the Standard backend this simply means displaying text to the librarian
586
asking them to confirm they have taken all steps needed to cancel a confirmed
587
request.
588
589
=cut
590
591
sub cancel {
592
    my ( $self, $params ) = @_;
593
    my $stage = $params->{other}->{stage};
594
    if ( !$stage || $stage eq 'init' ) {
595
596
        # We simply need our template .INC to produce a text block.
597
        return {
598
            method => 'cancel',
599
            stage  => 'confirm',
600
            value  => $params,
601
        };
602
    } elsif ( $stage eq 'confirm' ) {
603
        $params->{request}->status("REQREV");
604
        $params->{request}->orderid(undef);
605
        $params->{request}->store;
606
        return {
607
            method => 'cancel',
608
            stage  => 'commit',
609
            next   => 'illview',
610
            value  => $params,
611
        };
612
    } else {
613
614
        # Invalid stage, return error.
615
        return {
616
            error   => 1,
617
            status  => 'unknown_stage',
618
            message => '',
619
            method  => 'cancel',
620
            stage   => $params->{stage},
621
            value   => {},
622
        };
623
    }
624
}
625
626
=head3 migrate
627
628
Migrate a request into or out of this backend.
629
630
=cut
631
632
sub migrate {
633
    my ( $self, $params ) = @_;
634
    my $other = $params->{other};
635
636
    my $stage = $other->{stage};
637
    my $step  = $other->{step};
638
639
    my $core_fields = _get_core_string();
640
641
    # We may be recieving a submitted form due to an additional
642
    # custom field being added or deleted, or the material type
643
    # having been changed, so check for these things
644
    if (   defined $other->{'add_new_custom'}
645
        || defined $other->{'custom_delete'}
646
        || defined $other->{'change_type'} )
647
    {
648
        if ( defined $other->{'add_new_custom'} ) {
649
            my ( $custom_keys, $custom_vals ) =
650
                _get_custom( $other->{'custom_key'}, $other->{'custom_value'} );
651
            push @{$custom_keys}, '---';
652
            push @{$custom_vals}, '---';
653
            $other->{'custom_key'}   = join "\0", @{$custom_keys};
654
            $other->{'custom_value'} = join "\0", @{$custom_vals};
655
        } elsif ( defined $other->{'custom_delete'} ) {
656
            my $delete_idx = $other->{'custom_delete'};
657
            my ( $custom_keys, $custom_vals ) =
658
                _get_custom( $other->{'custom_key'}, $other->{'custom_value'} );
659
            splice @{$custom_keys}, $delete_idx, 1;
660
            splice @{$custom_vals}, $delete_idx, 1;
661
            $other->{'custom_key'}   = join "\0", @{$custom_keys};
662
            $other->{'custom_value'} = join "\0", @{$custom_vals};
663
        } elsif ( defined $other->{'change_type'} ) {
664
665
            # We may be receiving a submitted form due to the user having
666
            # changed request material type, so we just need to go straight
667
            # back to the form, the type has been changed in the params
668
            delete $other->{'change_type'};
669
        }
670
        return {
671
            cwd     => dirname(__FILE__),
672
            status  => "",
673
            message => "",
674
            error   => 0,
675
            value   => $params,
676
            method  => "create",
677
            stage   => "form",
678
            core    => $core_fields
679
        };
680
    }
681
682
    # Recieve a new request from another backend and suppliment it with
683
    # anything we require specifically for this backend.
684
    if ( !$stage || $stage eq 'immigrate' ) {
685
        my $original_request = Koha::ILL::Requests->find( $other->{illrequest_id} );
686
        my $new_request      = $params->{request};
687
        $new_request->borrowernumber( $original_request->borrowernumber );
688
        $new_request->branchcode( $original_request->branchcode );
689
        $new_request->status('NEW');
690
        $new_request->backend( $self->name );
691
        $new_request->placed( DateTime->now );
692
        $new_request->updated( DateTime->now );
693
        $new_request->store;
694
695
        my @default_attributes = (qw/title type author year volume isbn issn article_title article_author pages/);
696
        my $original_attributes =
697
            $original_request->illrequestattributes->search( { type => { '-in' => \@default_attributes } } );
698
699
        my $request_details =
700
            { map { $_->type => $_->value } ( $original_attributes->as_list ) };
701
        $request_details->{migrated_from} = $original_request->illrequest_id;
702
        while ( my ( $type, $value ) = each %{$request_details} ) {
703
            Koha::ILL::Request::Attribute->new(
704
                {
705
                    illrequest_id => $new_request->illrequest_id,
706
                    column_exists( 'illrequestattributes', 'backend' ) ? ( backend => "Standard" ) : (),
707
                    type  => $type,
708
                    value => $value,
709
                }
710
            )->store;
711
        }
712
713
        return {
714
            error   => 0,
715
            status  => '',
716
            message => '',
717
            method  => 'migrate',
718
            stage   => 'commit',
719
            next    => 'emigrate',
720
            value   => $params,
721
            core    => $core_fields
722
        };
723
    }
724
725
    # Cleanup any outstanding work, close the request.
726
    elsif ( $stage eq 'emigrate' ) {
727
        my $new_request = $params->{request};
728
        my $from_id     = $new_request->illrequestattributes->find( { type => 'migrated_from' } )->value;
729
        my $request     = Koha::ILL::Requests->find($from_id);
730
731
        # Just cancel the original request now it's been migrated away
732
        $request->status("REQREV");
733
        $request->orderid(undef);
734
        $request->store;
735
736
        return {
737
            error   => 0,
738
            status  => '',
739
            message => '',
740
            method  => 'migrate',
741
            stage   => 'commit',
742
            next    => 'illview',
743
            value   => $params,
744
            core    => $core_fields
745
        };
746
    }
747
}
748
749
=head3 illview
750
751
   View and manage an ILL request
752
753
=cut
754
755
sub illview {
756
    my ( $self, $params ) = @_;
757
758
    return { method => "illview" };
759
}
760
761
## Helpers
762
763
=head3 _get_requested_partners
764
765
=cut
766
767
sub _get_requested_partners {
768
769
    # Take a request and retrieve an Illrequestattribute with
770
    # the type 'requested_partners'.
771
    my ($args) = @_;
772
    my $where = {
773
        illrequest_id => $args->{request}->id,
774
        type          => 'requested_partners'
775
    };
776
    my $res = Koha::ILL::Request::Attributes->find($where);
777
    return ($res) ? $res->value : undef;
778
}
779
780
=head3 _set_requested_partners
781
782
=cut
783
784
sub _set_requested_partners {
785
786
    # Take a request and set an Illrequestattribute on it
787
    # detailing the email address(es) of the requested
788
    # partner(s). We replace any existing value since, by
789
    # the time we get to this stage, any previous request
790
    # from partners would have had to be cancelled
791
    my ($args) = @_;
792
    my $where = {
793
        illrequest_id => $args->{request}->id,
794
        type          => 'requested_partners'
795
    };
796
    Koha::ILL::Request::Attributes->search($where)->delete();
797
    Koha::ILL::Request::Attributes->new(
798
        {
799
            illrequest_id => $args->{request}->id,
800
            column_exists( 'illrequestattributes', 'backend' ) ? ( backend => "Standard" ) : (),
801
            type  => 'requested_partners',
802
            value => $args->{to}
803
        }
804
    )->store;
805
}
806
807
=head3 _validate_borrower
808
809
=cut
810
811
sub _validate_borrower {
812
813
    # Perform cardnumber search.  If no results, perform surname search.
814
    # Return ( 0, undef ), ( 1, $brw ) or ( n, $brws )
815
    my ($input) = @_;
816
    my $patrons = Koha::Patrons->new;
817
    my ( $count, $brw );
818
    my $query = { cardnumber => $input };
819
820
    my $brws = $patrons->search($query);
821
    $count = $brws->count;
822
    my @criteria = qw/ surname userid firstname end /;
823
    while ( $count == 0 ) {
824
        my $criterium = shift @criteria;
825
        return ( 0, undef ) if ( "end" eq $criterium );
826
        $brws  = $patrons->search( { $criterium => $input } );
827
        $count = $brws->count;
828
    }
829
    if ( $count == 1 ) {
830
        $brw = $brws->next;
831
    } else {
832
        $brw = $brws;    # found multiple results
833
    }
834
    return ( $count, $brw );
835
}
836
837
=head3 _get_custom
838
839
=cut
840
841
sub _get_custom {
842
843
    # Take an string of custom keys and an string
844
    # of custom values, both delimited by \0 (by CGI)
845
    # and return an arrayref of each
846
    my ( $keys, $values ) = @_;
847
    my @k = defined $keys   ? split( "\0", $keys )   : ();
848
    my @v = defined $values ? split( "\0", $values ) : ();
849
    return ( \@k, \@v );
850
}
851
852
=head3 _prepare_custom
853
854
=cut
855
856
sub _prepare_custom {
857
858
    # Take an arrayref of custom keys and an arrayref
859
    # of custom values, return a hashref of them
860
    my ( $keys, $values ) = @_;
861
    my %out = ();
862
    if ($keys) {
863
        my @k = split( "\0", $keys );
864
        my @v = split( "\0", $values );
865
        %out = map { $k[$_] => $v[$_] } 0 .. $#k;
866
    }
867
    return \%out;
868
}
869
870
=head3 _get_request_details
871
872
    my $request_details = _get_request_details($params, $other);
873
874
Return the illrequestattributes for a given request
875
876
=cut
877
878
sub _get_request_details {
879
    my ( $params, $other ) = @_;
880
881
    # Get custom key / values we've been passed
882
    # Prepare them for addition into the Illrequestattribute object
883
    my $custom =
884
        _prepare_custom( $other->{'custom_key'}, $other->{'custom_value'} );
885
886
    my $return = {%$custom};
887
    my $core   = _get_core_fields();
888
    foreach my $key ( keys %{$core} ) {
889
        $return->{$key} = $params->{other}->{$key};
890
    }
891
892
    return $return;
893
}
894
895
=head3 _get_core_string
896
897
Return a comma delimited, quoted, string of core field keys
898
899
=cut
900
901
sub _get_core_string {
902
    my $core = _get_core_fields();
903
    return join( ",", map { '"' . $_ . '"' } keys %{$core} );
904
}
905
906
=head3 _get_core_fields
907
908
Return a hashref of core fields
909
910
=cut
911
912
sub _get_core_fields {
913
    return {
914
        article_author  => 'Article author',
915
        article_title   => 'Article title',
916
        associated_id   => 'Associated ID',
917
        author          => 'Author',
918
        chapter_author  => 'Chapter author',
919
        chapter         => 'Chapter',
920
        conference_date => 'Conference date',
921
        doi             => 'DOI',
922
        editor          => 'Editor',
923
        institution     => 'Institution',
924
        isbn            => 'ISBN',
925
        issn            => 'ISSN',
926
        issue           => 'Issue',
927
        item_date       => 'Date',
928
        pages           => 'Pages',
929
        pagination      => 'Pagination',
930
        paper_author    => 'Paper author',
931
        paper_title     => 'Paper title',
932
        part_edition    => 'Part / Edition',
933
        publication     => 'Publication',
934
        published_date  => 'Publication date',
935
        published_place => 'Place of publication',
936
        publisher       => 'Publisher',
937
        sponsor         => 'Sponsor',
938
        title           => 'Title',
939
        type            => 'Type',
940
        venue           => 'Venue',
941
        volume          => 'Volume',
942
        year            => 'Year'
943
    };
944
}
945
946
=head3 add_request
947
948
Add an ILL request
949
950
=cut
951
952
sub add_request {
953
954
    my ( $self, $params ) = @_;
955
956
    # ...Populate Illrequestattributes
957
    # generate $request_details
958
    my $request_details = _get_request_details( $params, $params->{other} );
959
960
    my ( $brw_count, $brw ) =
961
        _validate_borrower( $params->{other}->{'cardnumber'} );
962
963
    ## Create request
964
965
    # Create bib record
966
    my $biblionumber = $self->_standard_request2biblio($request_details);
967
968
    # ...Populate Illrequest
969
    my $request = $params->{request};
970
    $request->biblio_id($biblionumber) unless $biblionumber == 0;
971
    $request->borrowernumber( $brw->borrowernumber );
972
    $request->branchcode( $params->{other}->{branchcode} );
973
    $request->status('NEW');
974
    $request->backend( $params->{other}->{backend} );
975
    $request->placed( DateTime->now );
976
    $request->updated( DateTime->now );
977
    $request->batch_id(
978
        $params->{other}->{ill_batch_id} ? $params->{other}->{ill_batch_id} : $params->{other}->{batch_id} )
979
        if column_exists( 'illrequests', 'batch_id' );
980
    $request->store;
981
982
    while ( my ( $type, $value ) = each %{$request_details} ) {
983
        if ( $value && length $value > 0 ) {
984
            Koha::ILL::Request::Attribute->new(
985
                {
986
                    illrequest_id => $request->illrequest_id,
987
                    column_exists( 'illrequestattributes', 'backend' ) ? ( backend => "Standard" ) : (),
988
                    type     => $type,
989
                    value    => $value,
990
                    readonly => 0
991
                }
992
            )->store;
993
        }
994
    }
995
996
    return $request;
997
}
998
999
=head3 _openurl_to_ill
1000
1001
Take a hashref of OpenURL parameters and return
1002
those same parameters but transformed to the ILL
1003
schema
1004
1005
=cut
1006
1007
sub _openurl_to_ill {
1008
    my ($params) = @_;
1009
1010
    # Parameters to not place in our custom
1011
    # parameters arrays
1012
    my $ignore = {
1013
        openurl            => 1,
1014
        backend            => 1,
1015
        method             => 1,
1016
        opac               => 1,
1017
        cardnumber         => 1,
1018
        branchcode         => 1,
1019
        userid             => 1,
1020
        password           => 1,
1021
        koha_login_context => 1,
1022
        stage              => 1
1023
    };
1024
1025
    my $transform_metadata = {
1026
        genre   => 'type',
1027
        content => 'type',
1028
        format  => 'type',
1029
        atitle  => 'article_title',
1030
        aulast  => 'author',
1031
        author  => 'author',
1032
        date    => 'year',
1033
        issue   => 'issue',
1034
        volume  => 'volume',
1035
        isbn    => 'isbn',
1036
        issn    => 'issn',
1037
        rft_id  => 'doi',
1038
        year    => 'year',
1039
        title   => 'title',
1040
        author  => 'author',
1041
        aulast  => 'article_author',
1042
        pages   => 'pages',
1043
        ctitle  => 'chapter',
1044
        clast   => 'chapter_author'
1045
    };
1046
1047
    my $transform_value = {
1048
        type => {
1049
            fulltext   => 'article',
1050
            selectedft => 'article',
1051
            print      => 'book',
1052
            ebook      => 'book',
1053
            journal    => 'journal'
1054
        }
1055
    };
1056
1057
    my $return       = {};
1058
    my $custom_key   = [];
1059
    my $custom_value = [];
1060
1061
    # First make sure our keys are correct
1062
    foreach my $meta_key ( keys %{ $params->{other} } ) {
1063
1064
        # If we are transforming this property...
1065
        if ( exists $transform_metadata->{$meta_key} ) {
1066
1067
            # ...do it
1068
            $return->{ $transform_metadata->{$meta_key} } = $params->{other}->{$meta_key};
1069
        } else {
1070
1071
            # Otherwise, pass it through untransformed and maybe move it
1072
            # to our custom parameters array
1073
            if ( !exists $ignore->{$meta_key} ) {
1074
                push @{$custom_key},   $meta_key;
1075
                push @{$custom_value}, $params->{other}->{$meta_key};
1076
            } else {
1077
                $return->{$meta_key} = $params->{other}->{$meta_key};
1078
            }
1079
        }
1080
    }
1081
1082
    # Now check our values are correct
1083
    foreach my $val_key ( keys %{$return} ) {
1084
        my $value = $return->{$val_key};
1085
        if ( exists $transform_value->{$val_key} && exists $transform_value->{$val_key}->{$value} ) {
1086
            $return->{$val_key} = $transform_value->{$val_key}->{$value};
1087
        }
1088
    }
1089
    if ( scalar @{$custom_key} > 0 ) {
1090
        $return->{custom_key}   = join( "\0", @{$custom_key} );
1091
        $return->{custom_value} = join( "\0", @{$custom_value} );
1092
    }
1093
    $params->{other}         = $return;
1094
    $params->{custom_keys}   = $custom_key;
1095
    $params->{custom_values} = $custom_value;
1096
    return $params;
1097
1098
}
1099
1100
=head3 create_api
1101
1102
Create a local submission from data supplied via an
1103
API call
1104
1105
=cut
1106
1107
sub create_api {
1108
    my ( $self, $body, $request ) = @_;
1109
1110
    my $patron = Koha::Patrons->find( $body->{borrowernumber} );
1111
1112
    $body->{cardnumber} = $patron->cardnumber;
1113
1114
    foreach my $attr ( @{ $body->{extended_attributes} } ) {
1115
        $body->{ $attr->{type} } = $attr->{value};
1116
    }
1117
1118
    $body->{type} = $body->{'isbn'} ? 'book' : 'article';
1119
1120
    my $submission = $self->add_request( { request => $request, other => $body } );
1121
1122
    return $submission;
1123
}
1124
1125
=head3 _can_create_request
1126
1127
Given the parameters we've been passed, should we create the request
1128
1129
=cut
1130
1131
sub _can_create_request {
1132
    my ($params) = @_;
1133
    return (   defined $params->{'stage'}
1134
            && $params->{'stage'} eq 'form'
1135
            && !defined $params->{'add_new_custom'}
1136
            && !defined $params->{'custom_delete'}
1137
            && !defined $params->{'change_type'} ) ? 1 : 0;
1138
}
1139
1140
=head3 _standard_request2biblio
1141
1142
Given supplied metadata from a Standard request, create a basic biblio
1143
record and return its ID
1144
1145
=cut
1146
1147
sub _standard_request2biblio {
1148
    my ( $self, $metadata ) = @_;
1149
1150
    # We only want to create biblios for books
1151
    return 0 unless $metadata->{type} eq 'book';
1152
1153
    # We're going to try and populate author, title & ISBN
1154
    my $author = $metadata->{author} if $metadata->{author};
1155
    my $title  = $metadata->{title}  if $metadata->{title};
1156
    my $isbn   = $metadata->{isbn}   if $metadata->{isbn};
1157
1158
    # Create the MARC::Record object and populate
1159
    my $record = MARC::Record->new();
1160
1161
    # Fix character set where appropriate
1162
    my $marcflavour = C4::Context->preference('marcflavour') || 'MARC21';
1163
    if ( $record->encoding() eq 'MARC-8' ) {
1164
        ($record) = MarcToUTF8Record( $record, $marcflavour );
1165
    }
1166
1167
    if ($isbn) {
1168
        my $marc_isbn = MARC::Field->new( '020', '', '', a => $isbn );
1169
        $record->append_fields($marc_isbn);
1170
    }
1171
    if ($author) {
1172
        my $marc_author = MARC::Field->new( '100', '1', '', a => $author );
1173
        $record->append_fields($marc_author);
1174
    }
1175
    if ($title) {
1176
        my $marc_title = MARC::Field->new( '245', '0', '0', a => $title );
1177
        $record->append_fields($marc_title);
1178
    }
1179
1180
    # Suppress the record
1181
    _set_suppression($record);
1182
1183
    # Create a biblio record
1184
    my ( $biblionumber, $biblioitemnumber ) =
1185
        AddBiblio( $record, $self->{framework} );
1186
1187
    return $biblionumber;
1188
}
1189
1190
=head3 _set_suppression
1191
1192
    _set_suppression($record);
1193
1194
Take a MARC::Record object and set it to be suppressed
1195
1196
=cut
1197
1198
sub _set_suppression {
1199
    my ($record) = @_;
1200
1201
    my $new942 = MARC::Field->new( '942', '', '', n => '1' );
1202
    $record->append_fields($new942);
1203
1204
    return 1;
1205
}
1206
1207
=head1 AUTHORS
1208
1209
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
1210
Martin Renvoize <martin.renvoize@ptfs-europe.com>
1211
Andrew Isherwood <andrew.isherwood@ptfs-europe.com>
1212
1213
=cut
1214
1215
1;
(-)a/Koha/ILL/Backend/intra-includes/cancel.inc (+17 lines)
Line 0 Link Here
1
[% IF whole.error %]
2
<p>Unhandled error</p>
3
[% END %]
4
5
[% IF whole.stage == "confirm" %]
6
<h2>Cancel manual request</h2>
7
<p>Proceeding with this action will set this request to 'Cancelled'.</p>
8
<p>This means that actions have been taken to cancel this request at the source with whom the request was placed.</p>
9
<p>If you can confirm this has been done, please proceed.</p>
10
<p>
11
  [% base_url = "/cgi-bin/koha/ill/ill-requests.pl" %]
12
  [% proceed_url = base_url _ "?method=cancel&stage=confirm" _
13
                   "&illrequest_id=" _ request.illrequest_id %]
14
  <a class="btn btn-sm btn-default" href="[% proceed_url %]">Revert request</a>
15
  <a class="btn btn-sm btn-default cancel" href="[% base_url %]">Cancel</a>
16
</p>
17
[% END %]
(-)a/Koha/ILL/Backend/intra-includes/confirm.inc (+19 lines)
Line 0 Link Here
1
[% IF whole.error %]
2
<p>Unhandled error</p>
3
[% END %]
4
5
[% IF whole.stage == "confirm" %]
6
<h2>Confirm manual request</h2>
7
<p>Proceeding with this action will set this request to 'Requested'.</p>
8
<p>This means that actions have been taken to request this request from a source.</p>
9
<p>If you can confirm this has been done, please proceed.</p>
10
<p>
11
  [% base_url = "/cgi-bin/koha/ill/ill-requests.pl" %]
12
  [% proceed_url = base_url _ "?method=confirm&stage=confirm" _
13
                   "&illrequest_id=" _ request.illrequest_id %]
14
  <a class="btn btn-sm btn-default" href="[% proceed_url %]">Confirm request</a>
15
  <a class="btn btn-sm btn-default cancel" href="[% base_url %]">Cancel</a>
16
</p>
17
[% ELSE %]
18
<p>Unknown stage.  This should not have happened.
19
[% END %]
(-)a/Koha/ILL/Backend/intra-includes/create.inc (+203 lines)
Line 0 Link Here
1
[% SET koha_version = Koha.Version %]
2
[% IF whole.error %]
3
[% IF whole.status == 'missing_identifier' %]
4
<p><em>Please Note:</em> Mandatory field Identifier is missing.</p>
5
[% ELSIF whole.status == 'missing_branch' %]
6
<p><em>Please Note:</em> Branch is a mandatory field.</p>
7
[% ELSIF whole.status == 'invalid_borrower' %]
8
<p><em>Please Note:</em> The borrower details you entered are invalid.</p>
9
[% ELSIF whole.status == 'invalid_branch' %]
10
<p><em>Please Note:</em> The branch you chose is invalid.</p>
11
[% ELSE %]
12
<p>Unhandled error</p>
13
[% END %]
14
[% END %]
15
16
[% IF whole.stage == "form" %]
17
<h2>Create a manual ILL request</h2>
18
<form id="create_form" method="POST" action=[% here %]>
19
  <fieldset class="rows">
20
    <legend>General details</legend>
21
    <ol id="general-standard-fields">
22
      <li>
23
        <label class="required" for="type">Type:</label>
24
        <select name="type" id="type">
25
          <option value=""/>
26
          [% IF whole.value.other.type.lower == "book" %]
27
          <option value="book" selected="selected">Book</option>
28
          [% ELSE %]
29
          <option value="book">Book</option>
30
          [% END %]
31
          [% IF whole.value.other.type.lower == "chapter" %]
32
          <option value="chapter" selected="selected">Chapter</option>
33
          [% ELSE %]
34
          <option value="chapter">Chapter</option>
35
          [% END %]
36
          [% IF whole.value.other.type.lower == "journal" %]
37
          <option value="journal" selected="selected">Journal</option>
38
          [% ELSE %]
39
          <option value="journal">Journal</option>
40
          [% END %]
41
          [% IF whole.value.other.type.lower == "article" %]
42
          <option value="article" selected="selected">Journal article</option>
43
          [% ELSE %]
44
          <option value="article">Journal article</option>
45
          [% END %]
46
          [% IF whole.value.other.type.lower == "thesis" %]
47
          <option value="thesis" selected="selected">Thesis</option>
48
          [% ELSE %]
49
          <option value="thesis">Thesis</option>
50
          [% END %]
51
          [% IF whole.value.other.type.lower == "conference" %]
52
          <option value="conference" selected="selected">Conference</option>
53
          [% ELSE %]
54
          <option value="conference">Conference</option>
55
          [% END %]
56
          [% IF whole.value.other.type.lower == "dvd" %]
57
          <option value="dvd" selected="selected">DVD</option>
58
          [% ELSE %]
59
          <option value="dvd">DVD</option>
60
          [% END %]
61
          [% IF whole.value.other.type.lower == "other" %]
62
          <option value="other" selected="selected">Other</option>
63
          [% ELSE %]
64
          <option value="other">Other</option>
65
          [% END %]
66
          [% IF whole.value.other.type.lower == "resource" %]
67
          <option value="resource" selected="selected">Generic resource</option>
68
          [% ELSE %]
69
          <option value="resource">Generic resource</option>
70
          [% END %]
71
        </select>
72
      </li>
73
    </ol>
74
  </fieldset>
75
  [% cwd = whole.cwd %]
76
  [% type = whole.value.other.type %]
77
  [% IF type %]
78
      [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %]
79
  [% END %]
80
  [% INCLUDE "${cwd}/shared-includes/custom_fields.inc" %]
81
  <fieldset class="rows">
82
    <legend>Patron options</legend>
83
    <ol>
84
      <li>
85
        <label class="required" for="cardnumber">
86
          Card number, username or surname:
87
        </label>
88
        <input type="text" name="cardnumber" id="cardnumber" autocomplete="off"
89
               type="text" value="" />
90
      </li>
91
      <li>
92
        <label class="required" for="branchcode">Destination library:</label>
93
        <select id="branchcode" name="branchcode">
94
          <option value="" />
95
          [% FOREACH branch IN branches %]
96
            <option value="[% branch.branchcode %]">
97
              [% branch.branchname %]
98
            </option>
99
          [% END %]
100
        </select>
101
      </li>
102
    </ol>
103
  </fieldset>
104
  <fieldset class="action">
105
    <input id="ill-submit" type="submit" value="Create" disabled />
106
    <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl">Cancel</a>
107
  </fieldset>
108
  <input type="hidden" name="method" value="create" />
109
  <input type="hidden" name="stage" value="form" />
110
  <input type="hidden" name="backend" value="Standard" />
111
</form>
112
[% BLOCK backend_jsinclude %]
113
<script type="text/javascript">
114
    // <![CDATA[]
115
    [% INCLUDE "${cwd}/shared-includes/shared.js" %]
116
    // Require a username and branch selection
117
    document.addEventListener('DOMContentLoaded', function(){
118
        $('#create_form #cardnumber, #create_form #branchcode').change(function() {
119
            var comp = ['#cardnumber','#branchcode'].filter(function(id) {
120
                return $(id).val().length > 0;
121
            });
122
            $('#ill-submit').attr('disabled', comp.length < 2);
123
        });
124
      /* Maintain patron autocomplete compatibility across versions */
125
      [% IF koha_version.major <= 22 && koha_version.minor < 11 %]
126
      $('#create_form #cardnumber').autocomplete({
127
          source: "/cgi-bin/koha/circ/ysearch.pl",
128
          minLength: 3,
129
          select: function( event, ui ) {
130
              var field = ui.item.cardnumber;
131
              $('#create_form #cardnumber').val(field)
132
              return false;
133
          }
134
      })
135
      .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
136
          return $( "<li></li>" )
137
          .data( "ui-autocomplete-item", item )
138
          .append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
139
          .appendTo( ul );
140
      };
141
      [% ELSE %]
142
      patron_autocomplete(
143
        $('#create_form #cardnumber'),
144
        {
145
          'on-select-callback': function( event, ui ) {
146
            $("#create_form #cardnumber").val( ui.item.cardnumber );
147
            return false;
148
          }
149
        }
150
      );
151
      [% END %]
152
    });
153
    // ]]>
154
</script>
155
[% END %]
156
157
[% ELSIF whole.stage == "borrowers" %]
158
<!-- We need to clarify the borrower that has been requested. -->
159
<h2>Borrower selection</h2>
160
<form method="POST" action=[% here %]>
161
  [% FOREACH prop IN whole.value.other.keys %]
162
    [% IF prop != 'custom_key' &&  prop != 'custom_value' && prop != 'cardnumber' %]
163
    <input type="hidden" name="[% prop %]" value="[% whole.value.other.$prop %]">
164
    [% END %]
165
  [% END %]
166
  [% keys = whole.value.other.custom_key.split('\0') %]
167
  [% values = whole.value.other.custom_value.split('\0') %]
168
  [% i = 0 %]
169
  [% FOREACH key IN keys %]
170
    <input type="hidden" name="custom_key" value="[% key %]">
171
    <input type="hidden" name="custom_value" value="[% values.$i %]">
172
  [% i = i + 1 %]
173
  [% END %]
174
  <fieldset class="rows">
175
    <legend>Available borrowers for surname [% surname %]</legend>
176
    [% FOREACH opt IN whole.value %]
177
    [% IF opt.key == "brw" %]
178
    <ol>
179
      <li>
180
        <label class="required" for="brw">Borrower</label>
181
        <select name="cardnumber" id="cardnumber">
182
          <option value=""></option>
183
          [% FOREACH brw IN opt.value %]
184
          <option value="[% brw.cardnumber %]">
185
            [% brw.firstname %] [% brw.surname %] ([% brw.cardnumber %])
186
          </option>
187
          [% END %]
188
        </select>
189
      </li>
190
    </ol>
191
    [% END %]
192
    [% END %]
193
  </fieldset>
194
  <fieldset class="action">
195
    <input type="submit" value="Select"/>
196
    <a class="cancel" href=[% parent %]>Cancel</a>
197
  </fieldset>
198
</form>
199
200
[% ELSE %]
201
<p>Unknown stage.  This should not have happened.
202
203
[% END %]
(-)a/Koha/ILL/Backend/intra-includes/edititem.inc (+88 lines)
Line 0 Link Here
1
[% IF whole.error %]
2
[% IF whole.status == 'missing_type' %]
3
<p><em>Please Note:</em> Mandatory field Type is missing.</p>
4
[% ELSE %]
5
<p>Unhandled error</p>
6
[% END %]
7
[% END %]
8
9
<h2>Edit a manual ILL request</h2>
10
<form id="standard_edit_form" method="POST" action=[% here %]>
11
  <fieldset class="rows">
12
    <legend>General details</legend>
13
    <ol id="general-standard-fields">
14
      <li>
15
        <label class="required" for="type">Type:</label>
16
        <select name="type" id="type">
17
          <option value=""/>
18
          [% IF whole.value.other.type.lower == "book" %]
19
          <option value="book" selected="selected">Book</option>
20
          [% ELSE %]
21
          <option value="book">Book</option>
22
          [% END %]
23
          [% IF whole.value.other.type.lower == "chapter" %]
24
          <option value="chapter" selected="selected">Chapter</option>
25
          [% ELSE %]
26
          <option value="chapter">Chapter</option>
27
          [% END %]
28
          [% IF whole.value.other.type.lower == "journal" %]
29
          <option value="journal" selected="selected">Journal</option>
30
          [% ELSE %]
31
          <option value="journal">Journal</option>
32
          [% END %]
33
          [% IF whole.value.other.type.lower == "article" %]
34
          <option value="article" selected="selected">Journal article</option>
35
          [% ELSE %]
36
          <option value="article">Journal article</option>
37
          [% END %]
38
          [% IF whole.value.other.type.lower == "thesis" %]
39
          <option value="thesis" selected="selected">Thesis</option>
40
          [% ELSE %]
41
          <option value="thesis">Thesis</option>
42
          [% END %]
43
          [% IF whole.value.other.type.lower == "conference" %]
44
          <option value="conference" selected="selected">Conference</option>
45
          [% ELSE %]
46
          <option value="conference">Conference</option>
47
          [% END %]
48
          [% IF whole.value.other.type.lower == "dvd" %]
49
          <option value="dvd" selected="selected">DVD</option>
50
          [% ELSE %]
51
          <option value="dvd">DVD</option>
52
          [% END %]
53
          [% IF whole.value.other.type.lower == "other" %]
54
          <option value="other" selected="selected">Other</option>
55
          [% ELSE %]
56
          <option value="other">Other</option>
57
          [% END %]
58
          [% IF whole.value.other.type.lower == "resource" %]
59
          <option value="resource" selected="selected">Generic resource</option>
60
          [% ELSE %]
61
          <option value="resource">Generic resource</option>
62
          [% END %]
63
        </select>
64
      </li>
65
    </ol>
66
  </fieldset>
67
  [% cwd = whole.cwd %]
68
  [% type = whole.value.other.type %]
69
  [% IF type %]
70
      [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %]
71
  [% END %]
72
  [% INCLUDE "${cwd}/shared-includes/custom_fields.inc" %]
73
  <fieldset class="action">
74
    <input id="ill-submit" type="submit" value="Update"/>
75
    <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl">Cancel</a>
76
  </fieldset>
77
  <input type="hidden" name="illrequest_id" value="[% whole.value.other.illrequest_id %]" />
78
  <input type="hidden" name="method" value="edititem" />
79
  <input type="hidden" name="stage" value="form" />
80
  <input type="hidden" name="backend" value="Standard" />
81
</form>
82
[% BLOCK backend_jsinclude %]
83
<script type="text/javascript">
84
    // <![CDATA[]
85
    [% INCLUDE "${cwd}/shared-includes/shared.js" %]
86
    // ]]>
87
</script>
88
[% END %]
(-)a/Koha/ILL/Backend/intra-includes/migrate.inc (+119 lines)
Line 0 Link Here
1
[% IF whole.error %]
2
[% IF whole.status == 'missing_identifier' %]
3
<p><em>Please Note:</em> Mandatory field Identifier is missing.</p>
4
[% ELSIF whole.status == 'missing_branch' %]
5
<p><em>Please Note:</em> Branch is a mandatory field.</p>
6
[% ELSIF whole.status == 'invalid_borrower' %]
7
<p><em>Please Note:</em> The borrower details you entered are invalid.</p>
8
[% ELSIF whole.status == 'invalid_branch' %]
9
<p><em>Please Note:</em> The branch you chose is invalid.</p>
10
[% ELSE %]
11
<p>Unhandled error</p>
12
[% END %]
13
[% END %]
14
15
[% IF whole.stage == "form" %]
16
<h2>Migrating an ILL request</h2>
17
<form id="standard_migrate_form" method="POST" action=[% here %]>
18
  <fieldset class="rows">
19
    <legend>General details</legend>
20
    <ol id="general-standard-fields">
21
      <li>
22
        <label class="required" for="type">Type:</label>
23
        <select name="type" id="type">
24
          <option value=""/>
25
          [% IF whole.value.other.type.lower == "book" %]
26
          <option value="book" selected="selected">Book</option>
27
          [% ELSE %]
28
          <option value="book">Book</option>
29
          [% END %]
30
          [% IF whole.value.other.type.lower == "chapter" %]
31
          <option value="chapter" selected="selected">Chapter</option>
32
          [% ELSE %]
33
          <option value="chapter">Chapter</option>
34
          [% END %]
35
          [% IF whole.value.other.type.lower == "journal" %]
36
          <option value="journal" selected="selected">Journal</option>
37
          [% ELSE %]
38
          <option value="journal">Journal</option>
39
          [% END %]
40
          [% IF whole.value.other.type.lower == "article" %]
41
          <option value="article" selected="selected">Journal article</option>
42
          [% ELSE %]
43
          <option value="article">Journal article</option>
44
          [% END %]
45
          [% IF whole.value.other.type.lower == "thesis" %]
46
          <option value="thesis" selected="selected">Thesis</option>
47
          [% ELSE %]
48
          <option value="thesis">Thesis</option>
49
          [% END %]
50
          [% IF whole.value.other.type.lower == "conference" %]
51
          <option value="conference" selected="selected">Conference</option>
52
          [% ELSE %]
53
          <option value="conference">Conference</option>
54
          [% END %]
55
          [% IF whole.value.other.type.lower == "dvd" %]
56
          <option value="dvd" selected="selected">DVD/option>
57
          [% ELSE %]
58
          <option value="dvd">DVD</option>
59
          [% END %]
60
          [% IF whole.value.other.type.lower == "other" %]
61
          <option value="other" selected="selected">Other</option>
62
          [% ELSE %]
63
          <option value="other">Other</option>
64
          [% END %]
65
          [% IF whole.value.other.type.lower == "resource" %]
66
          <option value="resource" selected="selected">Generic resource</option>
67
          [% ELSE %]
68
          <option value="resource">Generic resource</option>
69
          [% END %]
70
        </select>
71
      </li>
72
    </ol>
73
  </fieldset>
74
  [% cwd = whole.cwd %]
75
  [% type = whole.value.other.type %]
76
  [% IF type %]
77
      [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %]
78
  [% END %]
79
  [% INCLUDE "${cwd}/shared-includes/custom_fields.inc" %]
80
  <fieldset class="rows">
81
    <legend>Patron options</legend>
82
    <ol>
83
      <li>
84
        <label class="required" for="cardnumber">
85
          Card number or surname:
86
        </label>
87
        <input type="text" name="cardnumber" id="cardnumber"
88
               type="text" value="" />
89
      </li>
90
      <li>
91
        <label class="required" for="branchcode">Destination library:</label>
92
        <select id="branchcode" name="branchcode">
93
          <option value="" />
94
          [% FOREACH branch IN branches %]
95
            <option value="[% branch.branchcode %]">
96
              [% branch.branchname %]
97
            </option>
98
          [% END %]
99
        </select>
100
      </li>
101
    </ol>
102
  </fieldset>
103
  <fieldset class="action">
104
    <input id="ill-submit" type="submit" value="Migrate"/>
105
    <a class="cancel" href="/cgi-bin/koha/ill/ill-requests.pl">Cancel</a>
106
  </fieldset>
107
</form>
108
[% BLOCK backend_jsinclude %]
109
<script type="text/javascript">
110
    // <![CDATA[]
111
    [% INCLUDE "${cwd}/shared-includes/shared.js" %]
112
    // ]]>
113
</script>
114
[% END %]
115
116
[% ELSE %]
117
<p>Unknown stage.  This should not have happened.
118
119
[% END %]
(-)a/Koha/ILL/Backend/opac-includes/create.inc (+122 lines)
Line 0 Link Here
1
[% IF whole.error %]
2
[% IF whole.status == 'missing_identifier' %]
3
<p><em>Please Note:</em> Mandatory field Identifier is missing.</p>
4
[% ELSIF whole.status == 'missing_branch' %]
5
<p><em>Please Note:</em> Branch is a mandatory field.</p>
6
[% ELSIF whole.status == 'invalid_borrower' %]
7
<p><em>Please Note:</em> The borrower details you entered are invalid.</p>
8
[% ELSIF whole.status == 'invalid_branch' %]
9
<p><em>Please Note:</em> The branch you chose is invalid.</p>
10
[% ELSE %]
11
<p>Unhandled error</p>
12
[% END %]
13
[% END %]
14
15
[% IF whole.stage == "form" %]
16
<h2>Create a manual ILL request</h2>
17
<form id="create_form" method="POST" action=[% here %]>
18
  <fieldset class="rows">
19
    <legend>General details</legend>
20
    <ol id="general-standard-fields">
21
      <li>
22
        <label class="required" for="type">Type:</label>
23
        <select name="type" id="type">
24
          <option value=""/>
25
          [% IF whole.value.other.type.lower == "book" %]
26
          <option value="book" selected="selected">Book</option>
27
          [% ELSE %]
28
          <option value="book">Book</option>
29
          [% END %]
30
          [% IF whole.value.other.type.lower == "chapter" %]
31
          <option value="chapter" selected="selected">Chapter</option>
32
          [% ELSE %]
33
          <option value="chapter">Chapter</option>
34
          [% END %]
35
          [% IF whole.value.other.type.lower == "journal" %]
36
          <option value="journal" selected="selected">Journal</option>
37
          [% ELSE %]
38
          <option value="journal">Journal</option>
39
          [% END %]
40
          [% IF whole.value.other.type.lower == "article" %]
41
          <option value="article" selected="selected">Journal article</option>
42
          [% ELSE %]
43
          <option value="article">Journal article</option>
44
          [% END %]
45
          [% IF whole.value.other.type.lower == "thesis" %]
46
          <option value="thesis" selected="selected">Thesis</option>
47
          [% ELSE %]
48
          <option value="thesis">Thesis</option>
49
          [% END %]
50
          [% IF whole.value.other.type.lower == "conference" %]
51
          <option value="conference" selected="selected">Conference</option>
52
          [% ELSE %]
53
          <option value="conference">Conference</option>
54
          [% END %]
55
          [% IF whole.value.other.type.lower == "dvd" %]
56
          <option value="dvd" selected="selected">DVD</option>
57
          [% ELSE %]
58
          <option value="dvd">DVD</option>
59
          [% END %]
60
          [% IF whole.value.other.type.lower == "other" %]
61
          <option value="other" selected="selected">Other</option>
62
          [% ELSE %]
63
          <option value="other">Other</option>
64
          [% END %]
65
          [% IF whole.value.other.type.lower == "resource" %]
66
          <option value="resource" selected="selected">Generic resource</option>
67
          [% ELSE %]
68
          <option value="resource">Generic resource</option>
69
          [% END %]
70
        </select>
71
      </li>
72
    </ol>
73
  </fieldset>
74
  [% cwd = whole.cwd %]
75
  [% type = whole.value.other.type %]
76
  [% IF type %]
77
      [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %]
78
  [% END %]
79
  [% INCLUDE "${cwd}/shared-includes/custom_fields.inc" %]
80
  <fieldset class="rows">
81
    <legend>Patron options</legend>
82
    <ol>
83
      <li>
84
        <label class="required" for="branchcode">Destination library:</label>
85
        <select id="branchcode" name="branchcode">
86
          <option value="" />
87
          [% FOREACH branch IN branches %]
88
            [% IF whole.value.other.branchcode && branch.branchcode == whole.value.other.branchcode %]
89
            <option value="[% branch.branchcode %]" selected>
90
              [% branch.branchname %]
91
            </option>
92
            [% ELSE %]
93
            <option value="[% branch.branchcode %]">
94
              [% branch.branchname %]
95
            </option>
96
            [% END %]
97
          [% END %]
98
        </select>
99
      </li>
100
    </ol>
101
  </fieldset>
102
103
  <fieldset class="action">
104
    <input id="ill-submit" class="btn btn-default" type="submit" value="Create"/>
105
    <a class="cancel" href="/cgi-bin/koha/opac-illrequests.pl">Cancel</a>
106
  </fieldset>
107
  <input type="hidden" name="method" value="create" />
108
  <input type="hidden" name="stage" value="form" />
109
  <input type="hidden" name="backend" value="Standard" />
110
</form>
111
112
[% ELSE %]
113
<p>Unknown stage.  This should not have happened.
114
115
[% END %]
116
[% BLOCK backend_jsinclude %]
117
<script type="text/javascript">
118
    // <![CDATA[]
119
    [% INCLUDE "${cwd}/shared-includes/shared.js" %]
120
    // ]]>
121
</script>
122
[% END %]
(-)a/Koha/ILL/Backend/shared-includes/custom_fields.inc (+22 lines)
Line 0 Link Here
1
<fieldset class="rows">
2
    <legend>Custom fields</legend>
3
    <ol id="standard-fields">
4
        [% keys = whole.value.other.custom_key.split('\0') %]
5
        [% values = whole.value.other.custom_value.split('\0') %]
6
        [% i = 0 %]
7
        [% FOREACH key IN keys %]
8
            <li class="form-horizontal">
9
                <input type="text" class="custom-name" name="custom_key" value="[% key %]"><input type="text" name="custom_value" id="custom-value" value="[% values.$i %]">
10
                <button value="[% i %]" name="custom_delete" type="submit" class="btn btn-danger btn-sm delete-new-field">
11
                    <span class="fa fa-delete"></span>Delete
12
                </button></li>
13
            </li>
14
            [% i = i + 1 %]
15
        [% END %]
16
    </ol>
17
    <div id="custom-warning" style="display:none;margin:1em;" class="error required"></div>
18
        <button type="button" id="add-new-fields" class="btn btn-default">
19
        <span class="fa fa-plus"></span>
20
        Add new field
21
    </button>
22
</fieldset>
(-)a/Koha/ILL/Backend/shared-includes/forms/article.inc (+50 lines)
Line 0 Link Here
1
<fieldset id="journal-standard-fieldset" class="rows">
2
    <legend>Journal details</legend>
3
    <ol id="journal-standard-fields">
4
        <li>
5
            <label for="title">Title:</label>
6
            <input type="text" name="title" id="title" value="[% whole.value.other.title %]" />
7
        </li>
8
        <li>
9
            <label for="volume">Volume:</label>
10
            <input type="text" name="volume" id="volume" value="[% whole.value.other.volume %]" />
11
        </li>
12
        <li>
13
            <label for="issue">Issue number:</label>
14
            <input type="text" name="issue" id="issue" value="[% whole.value.other.issue %]" />
15
        </li>
16
        <li>
17
            <label for="year">Year:</label>
18
            <input type="text" name="year" id="year" value="[% whole.value.other.year %]" />
19
        </li>
20
        <li>
21
            <label for="issn">ISSN:</label>
22
            <input type="text" name="issn" id="issn" value="[% whole.value.other.issn %]" />
23
        </li>
24
    </ol>
25
</fieldset>
26
<fieldset id="article-standard-fieldset" class="rows">
27
    <legend>Article details</legend>
28
    <ol id="article-standard-fields">
29
        <li>
30
            <label for="article_title">Article title:</label>
31
            <input type="text" name="article_title" id="article_title" value="[% whole.value.other.article_title %]" />
32
        </li>
33
        <li>
34
            <label for="article_author">Article author:</label>
35
            <input type="text" name="article_author" id="article_author" value="[% whole.value.other.article_author %]" />
36
        </li>
37
        <li>
38
            <label for="published_date">Publication date:</label>
39
            <input type="text" name="published_date" id="published_date" value="[% whole.value.other.published_date %]" />
40
        </li>
41
        <li>
42
            <label for="pages">Pages:</label>
43
            <input type="text" name="pages" id="pages" value="[% whole.value.other.pages %]" />
44
        </li>
45
        <li>
46
            <label for="doi">DOI:</label>
47
            <input type="text" name="doi" id="doi" value="[% whole.value.other.doi %]" />
48
        </li>
49
    </ol>
50
</fieldset>
(-)a/Koha/ILL/Backend/shared-includes/forms/book.inc (+45 lines)
Line 0 Link Here
1
<fieldset id="book-standard-fieldset" class="rows">
2
    <legend>Book details</legend>
3
    <ol id="publication-standard-fields">
4
        <li>
5
            <label for="title">Title:</label>
6
            <input type="text" name="title" id="title" value="[% whole.value.other.title %]" />
7
        </li>
8
        <li>
9
            <label for="author">Author:</label>
10
            <input type="text" name="author" id="author" value="[% whole.value.other.author %]" />
11
        </li>
12
        <li>
13
            <label for="editor">Editor:</label>
14
            <input type="text" name="editor" id="editor" value="[% whole.value.other.editor %]" />
15
        </li>
16
        <li>
17
            <label for="publisher">Publisher:</label>
18
            <input type="text" name="publisher" id="publisher" value="[% whole.value.other.publisher %]" />
19
        </li>
20
        <li>
21
            <label for="published_place">Place of publication:</label>
22
            <input type="text" name="published_place" id="published_place" value="[% whole.value.other.published_place %]" />
23
        </li>
24
        <li>
25
            <label for="year">Year:</label>
26
            <input type="text" name="year" id="year" value="[% whole.value.other.year %]" />
27
        </li>
28
        <li>
29
            <label for="part_edition">Part / Edition:</label>
30
            <input type="text" name="part_edition" id="part_edition" value="[% whole.value.other.part_edition %]" />
31
        </li>
32
        <li>
33
            <label for="volume">Volume:</label>
34
            <input type="text" name="volume" id="volume" value="[% whole.value.other.volume %]" />
35
        </li>
36
        <li>
37
            <label for="isbn">ISBN:</label>
38
            <input type="text" name="isbn" id="isbn" value="[% whole.value.other.isbn %]" />
39
        </li>
40
        <li>
41
            <label for="doi">DOI:</label>
42
            <input type="text" name="doi" id="doi" value="[% whole.value.other.doi %]" />
43
        </li>
44
    </ol>
45
</fieldset>
(-)a/Koha/ILL/Backend/shared-includes/forms/chapter.inc (+62 lines)
Line 0 Link Here
1
<fieldset id="book-standard-fieldset" class="rows">
2
    <legend>Book details</legend>
3
    <ol id="publication-standard-fields">
4
        <li>
5
            <label for="title">Title:</label>
6
            <input type="text" name="title" id="title" value="[% whole.value.other.title %]" />
7
        </li>
8
        <li>
9
            <label for="author">Author:</label>
10
            <input type="text" name="author" id="author" value="[% whole.value.other.author %]" />
11
        </li>
12
        <li>
13
            <label for="editor">Editor:</label>
14
            <input type="text" name="editor" id="editor" value="[% whole.value.other.editor %]" />
15
        </li>
16
        <li>
17
            <label for="publisher">Publisher:</label>
18
            <input type="text" name="publisher" id="publisher" value="[% whole.value.other.publisher %]" />
19
        </li>
20
        <li>
21
            <label for="published_place">Place of publication:</label>
22
            <input type="text" name="published_place" id="published_place" value="[% whole.value.other.published_place %]" />
23
        </li>
24
        <li>
25
            <label for="year">Year:</label>
26
            <input type="text" name="year" id="year" value="[% whole.value.other.year %]" />
27
        </li>
28
        <li>
29
            <label for="part_edition">Part / Edition:</label>
30
            <input type="text" name="part_edition" id="part_edition" value="[% whole.value.other.part_edition %]" />
31
        </li>
32
        <li>
33
            <label for="volume">Volume:</label>
34
            <input type="text" name="volume" id="volume" value="[% whole.value.other.volume %]" />
35
        </li>
36
        <li>
37
            <label for="isbn">ISBN:</label>
38
            <input type="text" name="isbn" id="isbn" value="[% whole.value.other.isbn %]" />
39
        </li>
40
        <li>
41
            <label for="doi">DOI:</label>
42
            <input type="text" name="doi" id="doi" value="[% whole.value.other.doi %]" />
43
        </li>
44
    </ol>
45
</fieldset>
46
<fieldset id="chapter-standard-fieldset" class="rows">
47
    <legend>Chapter details</legend>
48
    <ol id="chapter-standard-fields">
49
        <li>
50
            <label for="chapter_author">Author:</label>
51
            <input type="text" name="chapter_author" id="chapter_author" value="[% whole.value.other.chapter_author %]" />
52
        </li>
53
        <li>
54
            <label for="chapter">Chapter:</label>
55
            <input type="text" name="chapter" id="chapter" value="[% whole.value.other.chapter %]" />
56
        </li>
57
        <li>
58
            <label for="pages">Pages:</label>
59
            <input type="text" name="pages" id="pages" value="[% whole.value.other.pages %]" />
60
        </li>
61
    </ol>
62
</fieldset>
(-)a/Koha/ILL/Backend/shared-includes/forms/conference.inc (+49 lines)
Line 0 Link Here
1
<fieldset id="conference-standard-fieldset" class="rows">
2
    <legend>Conference details</legend>
3
    <ol id="conference-standard-fields">
4
        <li>
5
            <label for="title">Conference title:</label>
6
            <input type="text" name="title" id="title" value="[% whole.value.other.title %]" />
7
        </li>
8
        <li>
9
            <label for="publication">Publication:</label>
10
            <input type="text" name="publication" id="publication" value="[% whole.value.other.publication %]" />
11
        </li>
12
        <li>
13
            <label for="conference_date">Conference date:</label>
14
            <input type="text" name="conference_date" id="conference_date" value="[% whole.value.other.conference_date %]" />
15
        </li>
16
        <li>
17
            <label for="venue">Venue:</label>
18
            <input type="text" name="venue" id="venue" value="[% whole.value.other.venue %]" />
19
        </li>
20
        <li>
21
            <label for="sponsor">Sponsor:</label>
22
            <input type="text" name="sponsor" id="sponsor" value="[% whole.value.other.sponsor %]" />
23
        </li>
24
        <li>
25
            <label for="volume">Volume:</label>
26
            <input type="text" name="volume" id="volume" value="[% whole.value.other.volume %]" />
27
        </li>
28
        <li>
29
            <label for="isbn">ISBN:</label>
30
            <input type="text" name="isbn" id="isbn" value="[% whole.value.other.isbn %]" />
31
        </li>
32
        <li>
33
            <label for="issn">ISSN:</label>
34
            <input type="text" name="issn" id="issn" value="[% whole.value.other.issn %]" />
35
        </li>
36
        <li>
37
            <label for="part_edition">Part:</label>
38
            <input type="text" name="part_edition" id="part_edition" value="[% whole.value.other.part_edition %]" />
39
        </li>
40
        <li>
41
            <label for="paper_title">Paper title:</label>
42
            <input type="text" name="paper_title" id="paper_title" value="[% whole.value.other.paper_title %]" />
43
        </li>
44
        <li>
45
            <label for="paper_author">Paper author:</label>
46
            <input type="text" name="paper_author" id="paper_author" value="[% whole.value.other.paper_author %]" />
47
        </li>
48
    </ol>
49
</fieldset>
(-)a/Koha/ILL/Backend/shared-includes/forms/journal.inc (+29 lines)
Line 0 Link Here
1
<fieldset id="journal-standard-fieldset" class="rows">
2
    <legend>Journal details</legend>
3
    <ol id="journal-standard-fields">
4
        <li>
5
            <label for="title">Title:</label>
6
            <input type="text" name="title" id="title" value="[% whole.value.other.title %]" />
7
        </li>
8
        <li>
9
            <label for="volume">Volume:</label>
10
            <input type="text" name="volume" id="volume" value="[% whole.value.other.volume %]" />
11
        </li>
12
        <li>
13
            <label for="issue">Issue number:</label>
14
            <input type="text" name="issue" id="issue" value="[% whole.value.other.issue %]" />
15
        </li>
16
        <li>
17
            <label for="year">Year:</label>
18
            <input type="text" name="year" id="year" value="[% whole.value.other.year %]" />
19
        </li>
20
        <li>
21
            <label for="issn">ISSN:</label>
22
            <input type="text" name="issn" id="issn" value="[% whole.value.other.issn %]" />
23
        </li>
24
        <li>
25
            <label for="doi">DOI:</label>
26
            <input type="text" name="doi" id="doi" value="[% whole.value.other.doi %]" />
27
        </li>
28
    </ol>
29
</fieldset>
(-)a/Koha/ILL/Backend/shared-includes/forms/resource.inc (+53 lines)
Line 0 Link Here
1
<fieldset id="resource-standard-fieldset" class="rows">
2
    <legend>Generic resource details</legend>
3
    <ol id="resource-standard-fields">
4
        <li>
5
            <label for="title">Title:</label>
6
            <input type="text" name="title" value="[% whole.value.other.title %]" />
7
        </li>
8
        <li>
9
            <label for="author">Author:</label>
10
            <input type="text" name="author" id="author" value="[% whole.value.other.author %]" />
11
        </li>
12
        <li>
13
            <label for="editor">Editor:</label>
14
            <input type="text" name="editor" id="editor" value="[% whole.value.other.editor %]" />
15
        </li>
16
        <li>
17
            <label for="publisher">Publisher:</label>
18
            <input type="text" name="publisher" id="publisher" value="[% whole.value.other.publisher %]" />
19
        </li>
20
        <li>
21
            <label for="published_place">Place of publication:</label>
22
            <input type="text" name="published_place" id="published_place" value="[% whole.value.other.published_place %]" />
23
        </li>
24
        <li>
25
            <label for="year">Year:</label>
26
            <input type="text" name="year" id="year" value="[% whole.value.other.year %]" />
27
        </li>
28
        <li>
29
            <label for="part_edition">Part / Edition:</label>
30
            <input type="text" name="part_edition" id="part_edition" value="[% whole.value.other.part_edition %]" />
31
        </li>
32
        <li>
33
            <label for="volume">Volume:</label>
34
            <input type="text" name="volume" id="volume" value="[% whole.value.other.volume %]" />
35
        </li>
36
        <li>
37
            <label for="pages">Pages:</label>
38
            <input type="text" name="pages" id="pages" value="[% whole.value.other.pages %]" />
39
        </li>
40
        <li>
41
            <label for="isbn">ISBN:</label>
42
            <input type="text" name="isbn" id="isbn" value="[% whole.value.other.isbn %]" />
43
        </li>
44
        <li>
45
            <label for "issn">ISSN:</label>
46
            <input type="text" name="issn" id="issn" value="[% whole.value.other.issn %]" />
47
        </li>
48
        <li>
49
            <label for="doi">DOI:</label>
50
            <input type="text" name="doi" id="doi" value="[% whole.value.other.doi %]" />
51
        </li>
52
    </ol>
53
</fieldset>
(-)a/Koha/ILL/Backend/shared-includes/forms/thesis.inc (+25 lines)
Line 0 Link Here
1
<fieldset id="thesis-standard-fieldset" class="rows">
2
    <legend>Thesis details</legend>
3
    <ol id="thesis-standard-fields">
4
        <li>
5
            <label for="title">Title:</label>
6
            <input type="text" name="title" id="title" value="[% whole.value.other.title %]" />
7
        </li>
8
        <li>
9
            <label for="author">Author:</label>
10
            <input type="text" name="author" id="author" value="[% whole.value.other.author %]" />
11
        </li>
12
        <li>
13
            <label for="institution">Institution:</label>
14
            <input type="text" name="institution" id="institution" value="[% whole.value.other.institution %]" />
15
        </li>
16
        <li>
17
            <label for="published_date">Publication date:</label>
18
            <input type="text" name="published_date" id="published_date" value="[% whole.value.other.published_date %]" />
19
        </li>
20
        <li>
21
            <label for="doi">DOI:</label>
22
            <input type="text" name="doi" id="doi" value="[% whole.value.other.doi %]" />
23
        </li>
24
    </ol>
25
</fieldset>
(-)a/Koha/ILL/Backend/shared-includes/shared.js (-1 / +38 lines)
Line 0 Link Here
0
- 
1
var core = [ [% whole.core %] ];
2
document.addEventListener('DOMContentLoaded', function() {
3
    $('#add-new-fields').click(function(e) {
4
        e.preventDefault();
5
        var row = '<li class="form-horizontal">' +
6
            '<input type="text" class="custom-name" name="custom_key">' +
7
            '<input type="text" id="custom-value" name="custom_value"> '+
8
            '<button type="button" class="btn btn-danger btn-sm ' +
9
            'delete-new-field">' +
10
            '<span class="fa fa-delete">' +
11
            '</span>Delete</button></li>';
12
        $('#standard-fields').append(row);
13
    });
14
    $('#standard-fields').on('click', '.delete-new-field',
15
        function(event) {
16
            event.preventDefault();
17
            $(event.target).parent().remove();
18
        }
19
    );
20
    $('#type').change(function() {
21
        $('#create_form').prepend(
22
            '<input type="hidden" name="change_type" value="1" />'
23
        );
24
        $('#create_form').submit();
25
    });
26
    $('#standard-fields').on('keyup', '.custom-name', function() {
27
        var val = $(this).val();
28
        if (core.indexOf(val.toLowerCase()) > -1) {
29
            $('#custom-warning').text(_('The name "' + val + '" is not permitted')).show();
30
            $('#ill-submit').attr('disabled', true);
31
            $('#add-new-fields').attr('disabled', true);
32
        } else {
33
            $('#custom-warning').hide();
34
            $('#ill-submit').attr('disabled', false);
35
            $('#add-new-fields').attr('disabled', false);
36
        }
37
    });
38
});

Return to bug 35570