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

(-)a/Koha/Acquisition/Bookseller.pm (+28 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Koha::Acquisition::Bookseller::Aliases;
20
use Koha::Acquisition::Bookseller::Aliases;
21
use Koha::Acquisition::Bookseller::Contacts;
21
use Koha::Acquisition::Bookseller::Contacts;
22
use Koha::Acquisition::Bookseller::Interfaces;
22
use Koha::Subscriptions;
23
use Koha::Subscriptions;
23
24
24
use base qw( Koha::Object );
25
use base qw( Koha::Object );
Lines 104-109 sub aliases { Link Here
104
    return Koha::Acquisition::Bookseller::Aliases->_new_from_dbic( $rs );
105
    return Koha::Acquisition::Bookseller::Aliases->_new_from_dbic( $rs );
105
}
106
}
106
107
108
=head3 interfaces
109
110
    my $interfaces = $vendor->interfaces
111
112
    $vendor->interfaces(\@interfaces);
113
114
=cut
115
116
sub interfaces {
117
    my ($self, $interfaces) = @_;
118
119
    if ($interfaces) {
120
        my $schema = $self->_result->result_source->schema;
121
        $schema->txn_do(
122
            sub {
123
                $self->interfaces->delete;
124
                for my $interface (@$interfaces) {
125
                    $self->_result->add_to_aqbookseller_interfaces($interface);
126
                }
127
            }
128
        );
129
    }
130
131
    my $rs = $self->_result->aqbookseller_interfaces;
132
    return Koha::Acquisition::Bookseller::Interfaces->_new_from_dbic( $rs );
133
}
134
107
135
108
=head3 to_api_mapping
136
=head3 to_api_mapping
109
137
(-)a/acqui/updatesupplier.pl (+16 lines)
Lines 47-52 contact_serialsprimary. Link Here
47
=cut
47
=cut
48
48
49
use Modern::Perl;
49
use Modern::Perl;
50
use List::MoreUtils qw( any );
50
use C4::Context;
51
use C4::Context;
51
use C4::Auth qw( checkauth );
52
use C4::Auth qw( checkauth );
52
53
Lines 130-137 if($data{'name'}) { Link Here
130
        $contact->{booksellerid} = $data{id};
131
        $contact->{booksellerid} = $data{id};
131
        Koha::Acquisition::Bookseller::Contact->new( $contact )->store
132
        Koha::Acquisition::Bookseller::Contact->new( $contact )->store
132
    }
133
    }
134
135
    # Insert aliases
133
    $bookseller->aliases([ map { { alias => $_ } } @aliases ]);
136
    $bookseller->aliases([ map { { alias => $_ } } @aliases ]);
134
137
138
    # Insert interfaces
139
    my @interface_counters = $input->multi_param('interface_counter');
140
    my @interfaces;
141
    for my $counter ( @interface_counters ) {
142
        my $interface = {};
143
        for my $attr (qw(name type uri login password account_email notes)){
144
            my $v = $input->param("interface_${attr}_${counter}");
145
            $interface->{$attr} = $v;
146
        }
147
        push @interfaces, $interface if any { defined && length } values %$interface;
148
    }
149
    $bookseller->interfaces(\@interfaces);
150
135
    #redirect to booksellers.pl
151
    #redirect to booksellers.pl
136
    print $input->redirect("booksellers.pl?booksellerid=".$data{id});
152
    print $input->redirect("booksellers.pl?booksellerid=".$data{id});
137
} else {
153
} else {
(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (-1 / +2 lines)
Lines 2569-2575 td.bundle { Link Here
2569
    margin: 0 0 8px 8px;
2569
    margin: 0 0 8px 8px;
2570
}
2570
}
2571
2571
2572
#contact-template {
2572
#contact-template,
2573
#interface-template {
2573
    display: none;
2574
    display: none;
2574
}
2575
}
2575
2576
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt (-2 / +86 lines)
Lines 185-191 Link Here
185
                    <label for="aliases">Aliases: </label>
185
                    <label for="aliases">Aliases: </label>
186
                    <div id="aliases" style="padding-left: 11rem;"></div>
186
                    <div id="aliases" style="padding-left: 11rem;"></div>
187
                </li>
187
                </li>
188
189
            </ol>
188
            </ol>
190
        </fieldset>
189
        </fieldset>
191
        <fieldset class="rows">
190
        <fieldset class="rows">
Lines 203-208 Link Here
203
            <button id="add-contact" class="btn btn-default"><i class="fa fa-plus"></i> Add another contact</button>
202
            <button id="add-contact" class="btn btn-default"><i class="fa fa-plus"></i> Add another contact</button>
204
        </fieldset>
203
        </fieldset>
205
204
205
        <fieldset class="rows">
206
            <legend>Interfaces</legend>
207
            <div id="interfaces"></div>
208
        </fieldset>
209
206
        <fieldset class="rows">
210
        <fieldset class="rows">
207
            <legend>Ordering information</legend>
211
            <legend>Ordering information</legend>
208
            <ol><li><label for="activestatus">Vendor is:</label>
212
            <ol><li><label for="activestatus">Vendor is:</label>
Lines 355-360 Link Here
355
                        <p><strong>Notes: </strong>[% notes | html %]</p>
359
                        <p><strong>Notes: </strong>[% notes | html %]</p>
356
                    [% END %]
360
                    [% END %]
357
                </div> <!-- #supplier-ordering-information -->
361
                </div> <!-- #supplier-ordering-information -->
362
363
                [% IF vendor.interfaces.count %]
364
                <div id="supplier-interfaces" class="page-section">
365
                    <h2>Interfaces</h2>
366
367
                    [% FOR interface IN vendor.interfaces %]
368
                        <fieldset class="rows">
369
                            <legend>[% interface.name | html %]</legend>
370
                            <ul>
371
                                <li>
372
                                    <li>Type: [% interface.type | html %]</li>
373
                                    <li>URI: [% interface.uri | html %]</li>
374
                                    <li>Login: [% interface.login | html %]</li>
375
                                    <li>Password: [% interface.password | html %]</li>
376
                                    <li>Account email: [% interface.account_email | html %]</li>
377
                                    <li>Notes : [% interface.notes | html %]</li>
378
                                </li>
379
                            </ul>
380
                        </fieldset>
381
                    [% END %]
382
                </div>
383
                [% END %]
384
358
            </div> <!-- /.col-sm-6 -->
385
            </div> <!-- /.col-sm-6 -->
359
386
360
            <div class="col-sm-6">
387
            <div class="col-sm-6">
Lines 492-497 Link Here
492
            $("#aliases").html(nodes.html());
519
            $("#aliases").html(nodes.html());
493
        }
520
        }
494
521
522
        [% IF vendor %]
523
        let interfaces = [% To.json(vendor.interfaces.unblessed) | $raw %];
524
        [% ELSE %]
525
        let interfaces = [];
526
        [% END %]
527
        function serialize_interface_form(){
528
            interfaces = [];
529
            $("#interfaces > fieldset.supplier-interface > ol.interface-form").each( (index, interface_form )=> {
530
                let interface = {};
531
                $(interface_form).find('input,textarea').serializeArray().map(attr => {
532
                    let name = attr.name.replace(/interface_([\w_]+)_\d+/, "$1");
533
                    interface[name] = attr.value
534
                })
535
                interfaces.push(interface);
536
            });
537
            return interfaces;
538
        }
539
        function remove_interface(i){
540
            interfaces = serialize_interface_form();
541
            interfaces.splice(i, 1);
542
            refresh_interfaces();
543
        }
544
        function add_interface(){
545
            interfaces = serialize_interface_form();
546
            interfaces.push({
547
                type: "",
548
                name: "",
549
                uri: "",
550
                login: "",
551
                password: "",
552
                account_email: "",
553
                notes: "",
554
            });
555
            refresh_interfaces();
556
        }
557
        function refresh_interfaces(){
558
            let nodes = $("<div id='interfaces'></div>");
559
            interfaces.forEach((interface, i) => {
560
                let n = $("<fieldset class='supplier-interface'></fieldset>");
561
                n.append("<legend>" + _("Interface details") + "</legend>");
562
                n.append(`<input type="hidden" name="interface_counter" value="${i}" />`);
563
                let ol = $('<ol class="interface-form"></ol>');
564
                ol.append(`<li><label for="interface_name_${i}">` + _("Name: ") + `</label><input type="text" size="40" id="interface_name_${i}" name="interface_name_${i}" value="${interface.name}" /></li>`);
565
                ol.append(`<li><label for="interface_type_${i}">` + _("Type: ") + `</label><input type="text" size="40" id="interface_type_${i}" name="interface_type_${i}" value="${interface.type}" /></li>`);
566
                ol.append(`<li><label for="interface_uri_${i}">` + _("URI: ") + `</label><input type="text" size="40" id="interface_uri_${i}" name="interface_uri_${i}" value="${interface.uri}" /></li>`);
567
                ol.append(`<li><label for="interface_login_${i}">` + _("Login: ") + `</label><input type="text" size="40" id="interface_login_${i}" name="interface_login_${i}" value="${interface.login}" /></li>`);
568
                ol.append(`<li><label for="interface_password_${i}">` + _("Password: ") + `</label><input type="text" size="40" id="interface_password_${i}" name="interface_password_${i}" value="${interface.password}" /></li>`);
569
                ol.append(`<li><label for="interface_account_email_${i}">` + _("Account email: ") + `</label><input type="text" size="40" id="interface_account_email_${i}" name="interface_account_email_${i}" value="${interface.account_email}" /></li>`);
570
                ol.append(`<li><label for="interface_notes_${i}">` + _("Notes: ") + `</label><textarea cols="40" rows="3" id="interface_notes_${i}" name="interface_notes_${i}">${interface.notes}</textarea></li>`);
571
                ol.append(`<li><button class="btn btn-default" onclick="remove_interface(${i});"><i class="fa fa-trash"></i> Delete interface</li>`);
572
                n.append(ol);
573
                nodes.append(n);
574
            });
575
            nodes.append(`<button onclick="add_interface();" class="btn btn-default"><i class="fa fa-plus"></i> ` + _("Add another interface") + '</button>')
576
            $("#interfaces").replaceWith(nodes);
577
        }
578
495
        var Sticky;
579
        var Sticky;
496
580
497
         $(document).ready(function() {
581
         $(document).ready(function() {
Lines 532-537 Link Here
532
            });
616
            });
533
617
534
            refresh_aliases();
618
            refresh_aliases();
619
            refresh_interfaces();
535
620
536
            Sticky = $("#toolbar");
621
            Sticky = $("#toolbar");
537
            Sticky.hcSticky({
622
            Sticky.hcSticky({
538
- 

Return to bug 33104