X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=acqui%2Fsupplier.pl;h=40235dfacd1fdac63d82ef4f085179cfb5191cb6;hb=f1b6feb20f19492f4848c939566472f33bd621c9;hp=d37bd72f3cfcab1fcf2cb99f60f3b9f49eb35583;hpb=20d9ed618fbe3cdcb9c04444a1f8a584b0364069;p=koha.git diff --git a/acqui/supplier.pl b/acqui/supplier.pl index d37bd72f3c..40235dfacd 100755 --- a/acqui/supplier.pl +++ b/acqui/supplier.pl @@ -40,19 +40,17 @@ To know the bookseller this script has to display details. =cut -use strict; -use warnings; +use Modern::Perl; use C4::Auth; use C4::Contract; use C4::Biblio; use C4::Output; use CGI qw ( -utf8 ); -use C4::Bookseller qw( DelBookseller ); -use C4::Bookseller::Contact; use C4::Budgets; -use Koha::Acquisition::Bookseller; +use Koha::Acquisition::Bookseller::Contacts; +use Koha::Acquisition::Booksellers; use Koha::Acquisition::Currencies; my $query = CGI->new; @@ -67,33 +65,36 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); my $booksellerid = $query->param('booksellerid'); -my $supplier = {}; +my $supplier; if ($booksellerid) { - $supplier = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid }); - foreach ( keys %{$supplier} ) { - $template->{'VARS'}->{$_} = $supplier->{$_}; + $supplier = Koha::Acquisition::Booksellers->find( $booksellerid ); + my $supplier_hashref = $supplier->unblessed; + foreach ( keys %{$supplier_hashref} ) { + $template->{'VARS'}->{$_} = $supplier->$_; } + $template->{VARS}->{contacts} = $supplier->contacts if $supplier->contacts->count; $template->{'VARS'}->{'booksellerid'} = $booksellerid; } -$template->{'VARS'}->{'contacts'} = C4::Bookseller::Contact->new() unless $template->{'VARS'}->{'contacts'}; + +$template->{VARS}->{contacts} ||= Koha::Acquisition::Bookseller::Contact->new; if ( $op eq 'display' ) { my $contracts = GetContracts( { booksellerid => $booksellerid } ); $template->param( - active => $supplier->{'active'}, - tax_rate => $supplier->{'tax_rate'} + 0.0, - invoiceprice => $supplier->{'invoiceprice'}, - listprice => $supplier->{'listprice'}, - basketcount => $supplier->{'basketcount'}, - subscriptioncount => $supplier->{'subscriptioncount'}, + active => $supplier->active, + tax_rate => $supplier->tax_rate + 0.0, + invoiceprice => $supplier->invoiceprice, + listprice => $supplier->listprice, + basketcount => $supplier->baskets->count, + subscriptioncount => $supplier->subscriptions->count, contracts => $contracts, ); } elsif ( $op eq 'delete' ) { # no further message needed for the user # the DELETE button only appears in the template if basketcount == 0 - if ( $supplier->{'basketcount'} == 0 ) { - DelBookseller($booksellerid); + if ( $supplier->baskets->count == 0 ) { + Koha::Acquisition::Booksellers->find($booksellerid)->delete; } print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl'); exit; @@ -107,8 +108,8 @@ if ( $op eq 'display' ) { $template->param( # set active ON by default for supplier add (id empty for add) - active => $booksellerid ? $supplier->{'active'} : 1, - tax_rate => $supplier->{tax_rate} ? $supplier->{'tax_rate'}+0.0 : 0, + active => $supplier ? $supplier->active : 1, + tax_rate => $supplier ? $supplier->tax_rate + 0.0 : 0, gst_values => \@gst_values, currencies => \@currencies, enter => 1,