Update to catalogue to allow change of biblio abstracts.
[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
11 my $input = new CGI;
12 my $existing=$input->param('existing');
13 my $title=$input->param('title');
14 $title=~ s/\'/\\\'/g;
15 my $author=$input->param('author');
16 $author=~ s/\'/\\\'/g;
17 my $copyright=$input->param('copyright');
18 my $isbn=$input->param('ISBN');
19 my $itemtype=$input->param('format');
20 my $ordnum=$input->param('ordnum');
21 my $basketno=$input->param('basket');
22 my $quantity=$input->param('quantity');
23 my $listprice=$input->param('list_price');
24 my $series=$input->param('Series');
25 if ($listprice eq ''){
26   $listprice=0;
27 }
28 my $supplier=$input->param('supplier');
29 my $notes=$input->param('notes');
30 my $bookfund=$input->param('bookfund');
31 my $who=$input->remote_user;
32 my $bibnum;
33 my $bibitemnum;
34 my $rrp=$input->param('rrp');
35 my $ecost=$input->param('ecost');
36 my $gst=$input->param('GST');
37 my $orderexists=$input->param('orderexists');
38
39 #check to see if biblio exists
40 if ($quantity ne '0'){
41
42   if ($existing eq 'no'){
43     #if it doesnt create it
44     $bibnum = &newbiblio({ title     => $title?$title:"",
45                            author    => $author?$author:"",
46                            copyright => $copyright?$copyright:"" });
47     $bibitemnum = &newbiblioitem({ biblionumber => $bibnum,
48                                    itemtype     => $itemtype?$itemtype:"",
49                                    isben        => $isbn?$isbn:"" });
50     newsubtitle($bibnum);
51     modbiblio({ biblionumber  => $bibnum,
52                 title         => $title?$title:"",
53                 author        => $author?$author:"",
54                 copyrightdate => $copyright?$copyright:"",
55                 series        => $series?$series:"" });
56   } else {
57     $bibnum=$input->param('biblio');
58     $bibitemnum=$input->param('bibitemnum');
59     my $oldtype=$input->param('oldtype');
60     if ($bibitemnum eq '' || $itemtype ne $oldtype){
61       $bibitemnum=newbiblioitem($bibnum,$itemtype,$isbn);
62     }
63     modbiblio({ biblionumber  => $bibnum,
64                 title         => $title?$title:"",
65                 author        => $author?$author:"",
66                 copyrightdate => $copyright?$copyright:"",
67                 series        => $series?$series:"" });
68   }
69   if ($orderexists ne '') {
70     modorder($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst);
71   }else {
72     neworder($bibnum,$title,$ordnum,$basketno,$quantity,$listprice,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst);
73   }
74 } else {
75   $bibnum=$input->param('biblio');
76   delorder($bibnum,$ordnum);
77 }
78
79 print $input->redirect("newbasket.pl?id=$supplier&basket=$basketno");