X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=acqui%2Fupdatesupplier.pl;h=04f4b5fbbf42bdb989603dab84dfc836325b99a9;hb=20d9ed618fbe3cdcb9c04444a1f8a584b0364069;hp=3dc69641a51c7cb8ae42896b0d25dbf222b1863a;hpb=60186fa42fa0742eb3e8484f1fd4b16e04d32ae1;p=koha.git diff --git a/acqui/updatesupplier.pl b/acqui/updatesupplier.pl index 3dc69641a5..04f4b5fbbf 100755 --- a/acqui/updatesupplier.pl +++ b/acqui/updatesupplier.pl @@ -9,18 +9,18 @@ # # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . =head1 NAME @@ -37,33 +37,30 @@ All informations regarding this supplier are listed on input parameter. Here is the list : supplier, id, company, company_postal, physical, company_phone, -physical, company_phone, company_fax, website, company_contact_name, -company_contact_position, contact_phone, contact_phone_2, contact_fax, -company_email, contact_notes, notes, status, publishers_imprints, -list_currency, gst, list_gst, invoice_gst, discount, gstrate. +physical, company_phone, company_fax, website, company_email, notes, +status, publishers_imprints, list_currency, gst, list_gst, invoice_gst, +discount, tax_rate, contact_name, contact_position, contact_phone, +contact_altphone, contact_fax, contact_email, contact_notes, +contact_claimacquisition, contact_claimissues, contact_acqprimary, +contact_serialsprimary. =cut use strict; -#use warnings; FIXME - Bug 2505 +use warnings; +use List::Util; use C4::Context; use C4::Auth; use C4::Bookseller qw( ModBookseller AddBookseller ); +use C4::Bookseller::Contact; use C4::Biblio; use C4::Output; -use CGI; +use CGI qw ( -utf8 ); my $input=new CGI; -my ($template, $loggedinuser, $cookie) = get_template_and_user( - { template_name => "", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => { acquisition => 'vendors_manage' }, - debug => 1, - } -); + +checkauth( $input, 0, { acquisition => 'vendors_manage' }, 'intranet' ); #print $input->header(); my $booksellerid=$input->param('booksellerid'); @@ -83,13 +80,6 @@ $data{'phone'}=$input->param('company_phone'); $data{'accountnumber'}=$input->param('accountnumber'); $data{'fax'}=$input->param('company_fax'); $data{'url'}=$input->param('website'); -$data{'contact'}=$input->param('company_contact_name'); -$data{'contpos'}=$input->param('company_contact_position'); -$data{'contphone'}=$input->param('contact_phone'); -$data{'contaltphone'}=$input->param('contact_phone_2'); -$data{'contfax'}=$input->param('contact_fax'); -$data{'contemail'}=$input->param('company_email'); -$data{'contnotes'}=$input->param('contact_notes'); # warn "".$data{'contnotes'}; $data{'notes'}=$input->param('notes'); $data{'active'}=$input->param('status'); @@ -100,23 +90,35 @@ $data{'gstreg'}=$input->param('gst'); $data{'listincgst'}=$input->param('list_gst'); $data{'invoiceincgst'}=$input->param('invoice_gst'); #have to transform this into fraction so it's easier to use -my $gstrate = $input->param('gstrate'); -if ($gstrate eq '') { - $data{'gstrate'} = undef; -} else { - $data{'gstrate'} = $input->param('gstrate')/100; -} -$data{'discount'}=$input->param('discount'); +$data{'tax_rate'} = $input->param('tax_rate'); +$data{'discount'} = $input->param('discount'); $data{deliverytime} = $input->param('deliverytime'); $data{'active'}=$input->param('status'); +my @contacts; +my %contact_info; + +foreach (qw(id name position phone altphone fax email notes orderacquisition claimacquisition claimissues acqprimary serialsprimary)) { + $contact_info{$_} = [ $input->param('contact_' . $_) ]; +} + +for my $cnt (0..scalar(@{$contact_info{'id'}})) { + my %contact; + my $real_contact; + foreach (qw(id name position phone altphone fax email notes orderacquisition claimacquisition claimissues acqprimary serialsprimary)) { + $contact{$_} = $contact_info{$_}->[$cnt]; + $real_contact = 1 if $contact{$_}; + } + push @contacts, C4::Bookseller::Contact->new(\%contact) if $real_contact; +} + if($data{'name'}) { if ($data{'id'}){ - ModBookseller(\%data); + ModBookseller(\%data, \@contacts); } else { - $data{id}=AddBookseller(\%data); + $data{id}=AddBookseller(\%data, \@contacts); } -#redirect to booksellers.pl -print $input->redirect("booksellers.pl?booksellerid=".$data{id}); + #redirect to booksellers.pl + print $input->redirect("booksellers.pl?booksellerid=".$data{id}); } else { -print $input->redirect("supplier.pl?op=enter"); # fail silently. + print $input->redirect("supplier.pl?op=enter"); # fail silently. }