Acquisitions::newbiblioitem updated to be usable for new acqui.simple
[wip/koha-chris_n.git] / acqui / addorder.pl
1 #!/usr/bin/perl
2
3 #script to add an order into the system
4 #written 29/2/00 by chris@katipo.co.nz
5
6 use strict;
7 use CGI;
8 use C4::Output;
9 use C4::Acquisitions;
10 #use Date::Manip;
11
12 my $input = new CGI;
13 #print $input->header;
14 #print startpage();
15 #print startmenu('acquisitions');
16 #print $input->dump;
17 my $existing=$input->param('existing');
18 my $title=$input->param('title');
19 $title=~ s/\'/\\\'/g;
20 my $author=$input->param('author');
21 $author=~ s/\'/\\\'/g;
22 my $copyright=$input->param('copyright');
23 my $isbn=$input->param('ISBN');
24 my $itemtype=$input->param('format');
25 my $ordnum=$input->param('ordnum');
26 my $basketno=$input->param('basket');
27 my $quantity=$input->param('quantity');
28 my $listprice=$input->param('list_price');
29 my $series=$input->param('Series');
30 if ($listprice eq ''){
31   $listprice=0;
32 }
33 my $supplier=$input->param('supplier');
34 my $notes=$input->param('notes');
35 my $bookfund=$input->param('bookfund');
36 my $who=$input->remote_user;
37 my $bibnum;
38 my $bibitemnum;
39 my $rrp=$input->param('rrp');
40 my $ecost=$input->param('ecost');
41 my $gst=$input->param('GST');
42 #check to see if orderexists
43 my $orderexists=$input->param('orderexists');
44
45 #check to see if biblio exists
46 if ($quantity ne '0'){
47
48   if ($existing eq 'no'){
49     #if it doesnt create it
50     $bibnum = &newbiblio({ title     => $title,
51                            author    =>$author,
52                            copyright => $copyright });
53     $bibitemnum = &newbiblioitem({ biblionumber => $bibnum,
54                                    itemtype     => $itemtype,
55                                    isben        => $isbn });
56     newsubtitle($bibnum);
57     modbiblio($bibnum,$title,$author,$copyright,$series);
58   } else {
59     $bibnum=$input->param('biblio');
60     $bibitemnum=$input->param('bibitemnum');
61     my $oldtype=$input->param('oldtype');
62     if ($bibitemnum eq '' || $itemtype ne $oldtype){
63       $bibitemnum=newbiblioitem($bibnum,$itemtype,$isbn);
64     }
65     modbiblio($bibnum,$title,$author,$copyright,$series);
66   }
67   if ($orderexists ne ''){
68     modorder($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst);
69   }else {
70     neworder($bibnum,$title,$ordnum,$basketno,$quantity,$listprice,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst);
71   }
72 } else {
73   #print $input->header;
74   #print "del";
75   $bibnum=$input->param('biblio');
76   delorder($bibnum,$ordnum);
77 }
78
79 print $input->redirect("newbasket.pl?id=$supplier&basket=$basketno");
80 #print $input->dump;
81 #print endmenu('acquisitions');
82 #print endpage();