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
[% USE AuthorisedValues %]
5
[% USE AuthorisedValues %]
Lines 181-186 Link Here
181
                    <label for="vendor_type">Vendor type: </label>
182
                    <label for="vendor_type">Vendor type: </label>
182
                    [% PROCESS 'av-build-dropbox.inc' name="vendor_type", category="VENDOR_TYPE", default=type, empty=1, size = 20 %]
183
                    [% PROCESS 'av-build-dropbox.inc' name="vendor_type", category="VENDOR_TYPE", default=type, empty=1, size = 20 %]
183
                </li>
184
                </li>
185
                <li>
186
                    <label for="aliases">Aliases: </label>
187
                    <div id="aliases" style="padding-left: 11rem;"></div>
188
                </li>
189
184
            </ol>
190
            </ol>
185
        </fieldset>
191
        </fieldset>
186
        <fieldset class="rows">
192
        <fieldset class="rows">
Lines 322-327 Link Here
322
                    [% IF ( accountnumber ) %]
328
                    [% IF ( accountnumber ) %]
323
                        <p><span class="label">Account number: </span>[% accountnumber | html %]</p>
329
                        <p><span class="label">Account number: </span>[% accountnumber | html %]</p>
324
                    [% END %]
330
                    [% END %]
331
                    [% IF vendor.aliases.count %]
332
                        <p>
333
                            <span class="label">Aliases: </span>
334
                            <ul>
335
                            [% FOR alias IN vendor.aliases %]
336
                                <li>[% alias.alias | html %]</li>
337
                            [% END %]
338
                            </ul>
339
                        </p>
340
                    [% END %]
325
                </div> <!-- /#supplier-company-details -->
341
                </div> <!-- /#supplier-company-details -->
326
342
327
                <div id="supplier-ordering-information" class="page-section">
343
                <div id="supplier-ordering-information" class="page-section">
Lines 452-457 Link Here
452
            ev.preventDefault();
468
            ev.preventDefault();
453
        }
469
        }
454
470
471
        [% IF vendor %]
472
        let aliases = [% To.json(vendor.aliases.unblessed) | $raw %];
473
        [% ELSE %]
474
        let aliases = [];
475
        [% END %]
476
        function remove_alias(i){
477
            aliases.splice(i, 1);
478
            refresh_aliases();
479
        }
480
        function add_alias(){
481
            let alias = $("#new_alias").val();
482
            if ( !alias.length > 0 ) { return }
483
            aliases.push({alias});
484
            refresh_aliases();
485
        }
486
        function refresh_aliases(){
487
            let nodes = $("<div></div>");
488
            aliases.forEach((a, i) => {
489
                let n = $("<div></div>").append(a.alias);
490
                n.append(`<input type="hidden" name="alias" value="${a.alias}">`)
491
                n.append(`<a onclick="remove_alias(${i});"><i class="fa fa-trash" aria-hidden="true"></i></a>`);
492
                nodes.append(n);
493
            });
494
            nodes.append("<input id='new_alias' type='text' />");
495
            nodes.append(`<a onclick="add_alias();"><i class="fa fa-plus" aria-hidden="true"></i></a>`);
496
            $("#aliases").html(nodes.html());
497
        }
498
455
        var Sticky;
499
        var Sticky;
456
500
457
         $(document).ready(function() {
501
         $(document).ready(function() {
Lines 491-496 Link Here
491
                $(this).next('.contact_claimissues_hidden').val($(this).is(':checked') ? '1' : '0');
535
                $(this).next('.contact_claimissues_hidden').val($(this).is(':checked') ? '1' : '0');
492
            });
536
            });
493
537
538
            refresh_aliases();
539
494
            Sticky = $("#toolbar");
540
            Sticky = $("#toolbar");
495
            Sticky.hcSticky({
541
            Sticky.hcSticky({
496
                stickTo: "main",
542
                stickTo: "main",
497
- 

Return to bug 33103