Bug 4212: Adds license statement to opac-search.pl
[koha.git] / acqui / updatesupplier.pl
1 #!/usr/bin/perl
2
3 #script to show suppliers and orders
4 #written by chris@katipo.co.nz 23/2/2000
5
6
7 # Copyright 2000-2002 Katipo Communications
8 # Copyright 2008-2009 BibLibre SARL
9 #
10 # This file is part of Koha.
11 #
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
16 #
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA  02111-1307 USA
24
25 =head1 NAME
26 updatesupplier.pl
27
28 =head1 DESCRIPTION
29 this script allow to update or create (if id == 0)
30 a supplier. This script is called from acqui/supplier.pl.
31
32 =head1 CGI PARAMETERS
33
34 =over 4
35
36 All informations regarding this supplier are listed on input parameter.
37 Here is the list :
38 supplier, id, company, company_postal, physical, company_phone,
39 physical, company_phone, company_fax, website, company_contact_name,
40 company_contact_position, contact_phone, contact_phone_2, contact_fax,
41 company_email, contact_notes, notes, status, publishers_imprints,
42 list_currency, gst, list_gst, invoice_gst, discount, gstrate.
43
44 =back
45
46 =cut
47 use C4::Context;
48 use C4::Auth;
49 use C4::Bookseller;
50 use C4::Biblio;
51 use C4::Output;
52 use CGI;
53 use strict;
54
55 my $input=new CGI;
56 my ($template, $loggedinuser, $cookie) = get_template_and_user(
57         {   template_name   => "",
58                 query           => $input,
59                 type            => "intranet",
60                 authnotrequired => 0,
61                 flagsrequired   => { acquisition => 'vendors_manage' },
62                 debug           => 1,
63         }
64 );
65
66 #print $input->header();
67 my $supplier=$input->param('supplier');
68 #print startpage;
69 my %data;
70 $data{'id'}=$input->param('id');
71
72 $data{'name'}=$input->param('company');
73 $data{'postal'}=$input->param('company_postal');
74 my $address=$input->param('physical');
75 my @addresses=split('\n',$address);
76 $data{'address1'}=$addresses[0];
77 $data{'address2'}=$addresses[1];
78 $data{'address3'}=$addresses[2];
79 $data{'address4'}=$addresses[3];
80 $data{'phone'}=$input->param('company_phone');
81 $data{'fax'}=$input->param('company_fax');
82 $data{'url'}=$input->param('website');
83 $data{'contact'}=$input->param('company_contact_name');
84 $data{'contpos'}=$input->param('company_contact_position');
85 $data{'contphone'}=$input->param('contact_phone');
86 $data{'contaltphone'}=$input->param('contact_phone_2');
87 $data{'contfax'}=$input->param('contact_fax');
88 $data{'contemail'}=$input->param('company_email');
89 $data{'contnotes'}=$input->param('contact_notes');
90 # warn "".$data{'contnotes'};
91 $data{'notes'}=$input->param('notes');
92 $data{'active'}=$input->param('status');
93 $data{'specialty'}=$input->param('publishers_imprints');
94 $data{'listprice'}=$input->param('list_currency');
95 $data{'invoiceprice'}=$input->param('invoice_currency');
96 $data{'gstreg'}=$input->param('gst');
97 $data{'listincgst'}=$input->param('list_gst');
98 $data{'invoiceincgst'}=$input->param('invoice_gst');
99 #have to transform this into fraction so it's easier to use
100 $data{'gstrate'}=$input->param('gstrate')/100;
101 $data{'discount'}=$input->param('discount');
102 $data{'active'}=$input->param('status');
103 if($data{'name'}) {
104         if ($data{'id'}){
105             ModBookseller(\%data);
106         } else {
107             $data{id}=AddBookseller(\%data);
108         }
109 #redirect to booksellers.pl
110 print $input->redirect("booksellers.pl?id=".$data{id});
111 } else {
112 print $input->redirect("supplier.pl?op=enter"); # fail silently.
113 }