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

(-)a/Koha/Acquisition/Bookseller.pm (+29 lines)
Lines 17-22 package Koha::Acquisition::Bookseller; Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Koha::Acquisition::Bookseller::Aliases;
20
use Koha::Acquisition::Bookseller::Contacts;
21
use Koha::Acquisition::Bookseller::Contacts;
21
use Koha::Subscriptions;
22
use Koha::Subscriptions;
22
23
Lines 76-81 sub subscriptions { Link Here
76
    return Koha::Subscriptions->search( { aqbooksellerid => $self->id } );
77
    return Koha::Subscriptions->search( { aqbooksellerid => $self->id } );
77
}
78
}
78
79
80
=head3 aliases
81
82
    my $aliases = $vendor->aliases
83
84
    $vendor->aliases([{ alias => 'one alias'}]);
85
86
=cut
87
88
sub aliases {
89
    my ($self, $aliases) = @_;
90
91
    if ($aliases) {
92
        my $schema = $self->_result->result_source->schema;
93
        $schema->txn_do(
94
            sub {
95
                $self->aliases->delete;
96
                for my $alias (@$aliases) {
97
                    $self->_result->add_to_aqbookseller_aliases($alias);
98
                }
99
            }
100
        );
101
    }
102
103
    my $rs = $self->_result->aqbookseller_aliases;
104
    return Koha::Acquisition::Bookseller::Aliases->_new_from_dbic( $rs );
105
}
106
107
79
=head3 to_api_mapping
108
=head3 to_api_mapping
80
109
81
This method returns the mapping for representing a Koha::Acquisition::Bookseller object
110
This method returns the mapping for representing a Koha::Acquisition::Bookseller object
(-)a/acqui/supplier.pl (+2 lines)
Lines 85-90 if ( $op eq 'display' ) { Link Here
85
        listprice     => $supplier->listprice,
85
        listprice     => $supplier->listprice,
86
        basketcount   => $supplier->baskets->count,
86
        basketcount   => $supplier->baskets->count,
87
        subscriptioncount => $supplier->subscriptions->count,
87
        subscriptioncount => $supplier->subscriptions->count,
88
        vendor        => $supplier,
88
        contracts     => $contracts,
89
        contracts     => $contracts,
89
    );
90
    );
90
} elsif ( $op eq 'delete' ) {
91
} elsif ( $op eq 'delete' ) {
Lines 106-111 if ( $op eq 'display' ) { Link Here
106
        # set active ON by default for supplier add (id empty for add)
107
        # set active ON by default for supplier add (id empty for add)
107
        active     => $supplier ? $supplier->active         : 1,
108
        active     => $supplier ? $supplier->active         : 1,
108
        tax_rate   => $supplier ? $supplier->tax_rate + 0.0 : 0,
109
        tax_rate   => $supplier ? $supplier->tax_rate + 0.0 : 0,
110
        vendor        => $supplier,
109
        gst_values    => \@gst_values,
111
        gst_values    => \@gst_values,
110
        currencies    => Koha::Acquisition::Currencies->search,
112
        currencies    => Koha::Acquisition::Currencies->search,
111
        enter         => 1,
113
        enter         => 1,
(-)a/acqui/updatesupplier.pl (-2 / +6 lines)
Lines 93-98 $data{'tax_rate'} = $input->param('tax_rate'); Link Here
93
$data{'discount'} = $input->param('discount');
93
$data{'discount'} = $input->param('discount');
94
$data{deliverytime} = $input->param('deliverytime');
94
$data{deliverytime} = $input->param('deliverytime');
95
$data{'active'}=$input->param('status');
95
$data{'active'}=$input->param('status');
96
97
my @aliases = $input->multi_param('alias');
96
my @contacts;
98
my @contacts;
97
my %contact_info;
99
my %contact_info;
98
100
Lines 111-125 for my $cnt (0..scalar(@{$contact_info{'id'}})) { Link Here
111
}
113
}
112
114
113
if($data{'name'}) {
115
if($data{'name'}) {
116
    my $bookseller;
114
    if ( $data{id} ) {
117
    if ( $data{id} ) {
115
        # Update
118
        # Update
116
        my $bookseller = Koha::Acquisition::Booksellers->find( $data{id} )->set(\%data)->store;
119
        $bookseller = Koha::Acquisition::Booksellers->find( $data{id} )->set(\%data)->store;
117
        # Delete existing contacts
120
        # Delete existing contacts
118
        $bookseller->contacts->delete;
121
        $bookseller->contacts->delete;
119
    } else {
122
    } else {
120
        # Insert
123
        # Insert
121
        delete $data{id}; # Remove the key if exists
124
        delete $data{id}; # Remove the key if exists
122
        my $bookseller = Koha::Acquisition::Bookseller->new( \%data )->store;
125
        $bookseller = Koha::Acquisition::Bookseller->new( \%data )->store;
123
        $data{id} = $bookseller->id;
126
        $data{id} = $bookseller->id;
124
    }
127
    }
125
    # Insert contacts
128
    # Insert contacts
Lines 127-132 if($data{'name'}) { Link Here
127
        $contact->{booksellerid} = $data{id};
130
        $contact->{booksellerid} = $data{id};
128
        Koha::Acquisition::Bookseller::Contact->new( $contact )->store
131
        Koha::Acquisition::Bookseller::Contact->new( $contact )->store
129
    }
132
    }
133
    $bookseller->aliases([ map { { alias => $_ } } @aliases ]);
130
134
131
    #redirect to booksellers.pl
135
    #redirect to booksellers.pl
132
    print $input->redirect("booksellers.pl?booksellerid=".$data{id});
136
    print $input->redirect("booksellers.pl?booksellerid=".$data{id});
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt (-1 / +46 lines)
Lines 1-4 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE To %]
2
[% USE Asset %]
3
[% USE Asset %]
3
[% USE KohaDates %]
4
[% USE KohaDates %]
4
[% BLOCK edit_contact %]
5
[% BLOCK edit_contact %]
Lines 180-185 Link Here
180
                    <label for="vendor_type">Vendor type: </label>
181
                    <label for="vendor_type">Vendor type: </label>
181
                    [% PROCESS 'av-build-dropbox.inc' name="vendor_type", category="VENDOR_TYPE", default=type, empty=1, size = 20 %]
182
                    [% PROCESS 'av-build-dropbox.inc' name="vendor_type", category="VENDOR_TYPE", default=type, empty=1, size = 20 %]
182
                </li>
183
                </li>
184
                <li>
185
                    <label for="aliases">Aliases: </label>
186
                    <div id="aliases" style="padding-left: 11rem;"></div>
187
                </li>
188
183
            </ol>
189
            </ol>
184
        </fieldset>
190
        </fieldset>
185
        <fieldset class="rows">
191
        <fieldset class="rows">
Lines 318-323 Link Here
318
                    [% IF ( accountnumber ) %]
324
                    [% IF ( accountnumber ) %]
319
                        <p><span class="label">Account number: </span>[% accountnumber | html %]</p>
325
                        <p><span class="label">Account number: </span>[% accountnumber | html %]</p>
320
                    [% END %]
326
                    [% END %]
327
                    [% IF vendor.aliases.count %]
328
                        <p>
329
                            <span class="label">Aliases: </span>
330
                            <ul>
331
                            [% FOR alias IN vendor.aliases %]
332
                                <li>[% alias.alias | html %]</li>
333
                            [% END %]
334
                            </ul>
335
                        </p>
336
                    [% END %]
321
                </div> <!-- /#supplier-company-details -->
337
                </div> <!-- /#supplier-company-details -->
322
338
323
                <div id="supplier-ordering-information" class="page-section">
339
                <div id="supplier-ordering-information" class="page-section">
Lines 448-453 Link Here
448
            ev.preventDefault();
464
            ev.preventDefault();
449
        }
465
        }
450
466
467
        [% IF vendor %]
468
        let aliases = [% To.json(vendor.aliases.unblessed) | $raw %];
469
        [% ELSE %]
470
        let aliases = [];
471
        [% END %]
472
        function remove_alias(i){
473
            aliases.splice(i, 1);
474
            refresh_aliases();
475
        }
476
        function add_alias(){
477
            let alias = $("#new_alias").val();
478
            if ( !alias.length > 0 ) { return }
479
            aliases.push({alias});
480
            refresh_aliases();
481
        }
482
        function refresh_aliases(){
483
            let nodes = $("<div></div>");
484
            aliases.forEach((a, i) => {
485
                let n = $("<div></div>").append(a.alias);
486
                n.append(`<input type="hidden" name="alias" value="${a.alias}">`)
487
                n.append(`<a onclick="remove_alias(${i});"><i class="fa fa-trash" aria-hidden="true"></i></a>`);
488
                nodes.append(n);
489
            });
490
            nodes.append("<input id='new_alias' type='text' />");
491
            nodes.append(`<a onclick="add_alias();"><i class="fa fa-plus" aria-hidden="true"></i></a>`);
492
            $("#aliases").html(nodes.html());
493
        }
494
451
        var Sticky;
495
        var Sticky;
452
496
453
         $(document).ready(function() {
497
         $(document).ready(function() {
Lines 487-492 Link Here
487
                $(this).next('.contact_claimissues_hidden').val($(this).is(':checked') ? '1' : '0');
531
                $(this).next('.contact_claimissues_hidden').val($(this).is(':checked') ? '1' : '0');
488
            });
532
            });
489
533
534
            refresh_aliases();
535
490
            Sticky = $("#toolbar");
536
            Sticky = $("#toolbar");
491
            Sticky.hcSticky({
537
            Sticky.hcSticky({
492
                stickTo: "main",
538
                stickTo: "main",
493
- 

Return to bug 33103