MT2582: Fix user deletion without permission
[koha.git] / acqui / updatesupplier.pl
blobe324a2915cfa21a0e3aa52ea543aa44c243ebf68
1 #!/usr/bin/perl
3 #script to show suppliers and orders
4 #written by chris@katipo.co.nz 23/2/2000
7 # Copyright 2000-2002 Katipo Communications
8 # Copyright 2008-2009 BibLibre SARL
10 # This file is part of Koha.
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.
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.
21 # You should have received a copy of the GNU General Public License along
22 # with Koha; if not, write to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 =head1 NAME
26 updatesupplier.pl
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.
32 =head1 CGI PARAMETERS
34 =over 4
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.
44 =back
46 =cut
47 use strict;
48 #use warnings; FIXME - Bug 2505
49 use C4::Context;
50 use C4::Auth;
51 use C4::Bookseller;
52 use C4::Biblio;
53 use C4::Output;
54 use CGI;
56 my $input=new CGI;
57 my ($template, $loggedinuser, $cookie) = get_template_and_user(
58 { template_name => "",
59 query => $input,
60 type => "intranet",
61 authnotrequired => 0,
62 flagsrequired => { acquisition => 'vendors_manage' },
63 debug => 1,
67 #print $input->header();
68 my $supplier=$input->param('supplier');
69 #print startpage;
70 my %data;
71 $data{'id'}=$input->param('id');
73 $data{'name'}=$input->param('company');
74 $data{'postal'}=$input->param('company_postal');
75 my $address=$input->param('physical');
76 my @addresses=split('\n',$address);
77 $data{'address1'}=$addresses[0];
78 $data{'address2'}=$addresses[1];
79 $data{'address3'}=$addresses[2];
80 $data{'address4'}=$addresses[3];
81 $data{'phone'}=$input->param('company_phone');
82 $data{'fax'}=$input->param('company_fax');
83 $data{'url'}=$input->param('website');
84 $data{'contact'}=$input->param('company_contact_name');
85 $data{'contpos'}=$input->param('company_contact_position');
86 $data{'contphone'}=$input->param('contact_phone');
87 $data{'contaltphone'}=$input->param('contact_phone_2');
88 $data{'contfax'}=$input->param('contact_fax');
89 $data{'contemail'}=$input->param('company_email');
90 $data{'contnotes'}=$input->param('contact_notes');
91 # warn "".$data{'contnotes'};
92 $data{'notes'}=$input->param('notes');
93 $data{'active'}=$input->param('status');
94 $data{'specialty'}=$input->param('publishers_imprints');
95 $data{'listprice'}=$input->param('list_currency');
96 $data{'invoiceprice'}=$input->param('invoice_currency');
97 $data{'gstreg'}=$input->param('gst');
98 $data{'listincgst'}=$input->param('list_gst');
99 $data{'invoiceincgst'}=$input->param('invoice_gst');
100 #have to transform this into fraction so it's easier to use
101 $data{'gstrate'}=$input->param('gstrate')/100;
102 $data{'discount'}=$input->param('discount');
103 $data{'active'}=$input->param('status');
104 if($data{'name'}) {
105 if ($data{'id'}){
106 ModBookseller(\%data);
107 } else {
108 $data{id}=AddBookseller(\%data);
110 #redirect to booksellers.pl
111 print $input->redirect("booksellers.pl?id=".$data{id});
112 } else {
113 print $input->redirect("supplier.pl?op=enter"); # fail silently.