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 2589-2595 td.bundle { Link Here
2589
    margin: 0 0 8px 8px;
2589
    margin: 0 0 8px 8px;
2590
}
2590
}
2591
2591
2592
#contact-template {
2592
#contact-template,
2593
#interface-template {
2593
    display: none;
2594
    display: none;
2594
}
2595
}
2595
2596
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt (-2 / +86 lines)
Lines 186-192 Link Here
186
                    <label for="aliases">Aliases: </label>
186
                    <label for="aliases">Aliases: </label>
187
                    <div id="aliases" style="padding-left: 11rem;"></div>
187
                    <div id="aliases" style="padding-left: 11rem;"></div>
188
                </li>
188
                </li>
189
190
            </ol>
189
            </ol>
191
        </fieldset>
190
        </fieldset>
192
        <fieldset class="rows">
191
        <fieldset class="rows">
Lines 204-209 Link Here
204
            <button id="add-contact" class="btn btn-default"><i class="fa fa-plus"></i> Add another contact</button>
203
            <button id="add-contact" class="btn btn-default"><i class="fa fa-plus"></i> Add another contact</button>
205
        </fieldset>
204
        </fieldset>
206
205
206
        <fieldset class="rows">
207
            <legend>Interfaces</legend>
208
            <div id="interfaces"></div>
209
        </fieldset>
210
207
        <fieldset class="rows">
211
        <fieldset class="rows">
208
            <legend>Ordering information</legend>
212
            <legend>Ordering information</legend>
209
            <ol><li><label for="activestatus">Vendor is:</label>
213
            <ol><li><label for="activestatus">Vendor is:</label>
Lines 359-364 Link Here
359
                        <p><strong>Notes: </strong>[% notes | html %]</p>
363
                        <p><strong>Notes: </strong>[% notes | html %]</p>
360
                    [% END %]
364
                    [% END %]
361
                </div> <!-- #supplier-ordering-information -->
365
                </div> <!-- #supplier-ordering-information -->
366
367
                [% IF vendor.interfaces.count %]
368
                <div id="supplier-interfaces" class="page-section">
369
                    <h2>Interfaces</h2>
370
371
                    [% FOR interface IN vendor.interfaces %]
372
                        <fieldset class="rows">
373
                            <legend>[% interface.name | html %]</legend>
374
                            <ul>
375
                                <li>
376
                                    <li>Type: [% interface.type | html %]</li>
377
                                    <li>URI: [% interface.uri | html %]</li>
378
                                    <li>Login: [% interface.login | html %]</li>
379
                                    <li>Password: [% interface.password | html %]</li>
380
                                    <li>Account email: [% interface.account_email | html %]</li>
381
                                    <li>Notes : [% interface.notes | html %]</li>
382
                                </li>
383
                            </ul>
384
                        </fieldset>
385
                    [% END %]
386
                </div>
387
                [% END %]
388
362
            </div> <!-- /.col-sm-6 -->
389
            </div> <!-- /.col-sm-6 -->
363
390
364
            <div class="col-sm-6">
391
            <div class="col-sm-6">
Lines 511-516 Link Here
511
            $("#aliases").html(nodes.html());
538
            $("#aliases").html(nodes.html());
512
        }
539
        }
513
540
541
        [% IF vendor %]
542
        let interfaces = [% To.json(vendor.interfaces.unblessed) | $raw %];
543
        [% ELSE %]
544
        let interfaces = [];
545
        [% END %]
546
        function serialize_interface_form(){
547
            interfaces = [];
548
            $("#interfaces > fieldset.supplier-interface > ol.interface-form").each( (index, interface_form )=> {
549
                let interface = {};
550
                $(interface_form).find('input,textarea').serializeArray().map(attr => {
551
                    let name = attr.name.replace(/interface_([\w_]+)_\d+/, "$1");
552
                    interface[name] = attr.value
553
                })
554
                interfaces.push(interface);
555
            });
556
            return interfaces;
557
        }
558
        function remove_interface(i){
559
            interfaces = serialize_interface_form();
560
            interfaces.splice(i, 1);
561
            refresh_interfaces();
562
        }
563
        function add_interface(){
564
            interfaces = serialize_interface_form();
565
            interfaces.push({
566
                type: "",
567
                name: "",
568
                uri: "",
569
                login: "",
570
                password: "",
571
                account_email: "",
572
                notes: "",
573
            });
574
            refresh_interfaces();
575
        }
576
        function refresh_interfaces(){
577
            let nodes = $("<div id='interfaces'></div>");
578
            interfaces.forEach((interface, i) => {
579
                let n = $("<fieldset class='supplier-interface'></fieldset>");
580
                n.append("<legend>" + _("Interface details") + "</legend>");
581
                n.append(`<input type="hidden" name="interface_counter" value="${i}" />`);
582
                let ol = $('<ol class="interface-form"></ol>');
583
                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>`);
584
                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>`);
585
                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>`);
586
                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>`);
587
                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>`);
588
                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>`);
589
                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>`);
590
                ol.append(`<li><button class="btn btn-default" onclick="remove_interface(${i});"><i class="fa fa-trash"></i> Delete interface</li>`);
591
                n.append(ol);
592
                nodes.append(n);
593
            });
594
            nodes.append(`<button onclick="add_interface();" class="btn btn-default"><i class="fa fa-plus"></i> ` + _("Add another interface") + '</button>')
595
            $("#interfaces").replaceWith(nodes);
596
        }
597
514
        var Sticky;
598
        var Sticky;
515
599
516
         $(document).ready(function() {
600
         $(document).ready(function() {
Lines 551-556 Link Here
551
            });
635
            });
552
636
553
            refresh_aliases();
637
            refresh_aliases();
638
            refresh_interfaces();
554
639
555
            Sticky = $("#toolbar");
640
            Sticky = $("#toolbar");
556
            Sticky.hcSticky({
641
            Sticky.hcSticky({
557
- 

Return to bug 33104