# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-use C4::Acquisition;
+=head1 NAME
+updatesupplier.pl
+
+=head1 DESCRIPTION
+this script allow to update or create (if id == 0)
+a supplier. This script is called from acqui/supplier.pl.
+
+=head1 CGI PARAMETERS
+
+=over 4
+
+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.
+
+=back
+
+=cut
+
+use C4::Bookseller;
use C4::Biblio;
use C4::Output;
use CGI;
$data{'id'}=$input->param('id');
$data{'name'}=$input->param('company');
-$data{'name'}=~ s/\'/\\\'/g;
$data{'postal'}=$input->param('company_postal');
my $address=$input->param('physical');
my @addresses=split('\n',$address);
$data{'contaltphone'}=$input->param('contact_phone_2');
$data{'contfax'}=$input->param('contact_fax');
$data{'contemail'}=$input->param('company_email');
-$data{'contnotes'}=$input->param('notes');
+$data{'contnotes'}=$input->param('contact_notes');
+# warn "".$data{'contnotes'};
+$data{'notes'}=$input->param('notes');
$data{'active'}=$input->param('status');
$data{'specialty'}=$input->param('publishers_imprints');
$data{'listprice'}=$input->param('list_currency');
$data{'listincgst'}=$input->param('list_gst');
$data{'invoiceincgst'}=$input->param('invoice_gst');
$data{'discount'}=$input->param('discount');
-my $id=$input->param('id');
-if ($data{'id'} != 0){
- updatesup(\%data);
+if($data{'name'}) {
+ if ($data{'id'}){
+ ModBookseller(\%data);
+ } else {
+ $data{id}=AddBookseller(\%data);
+ }
+#redirect to booksellers.pl
+print $input->redirect("booksellers.pl?id=".$data{id});
} else {
- $id=insertsup(\%data);
+print $input->redirect("supplier.pl?op=enter"); # fail silently.
}
-#print startmenu('acquisitions');
-#my ($count,@suppliers)=bookseller($supplier);
-
-#print $input->dump;
-
-
-#print endmenu('acquisitions');
-
-#print endpage;
-
-print $input->redirect("order.pl?supplier=$id");