Long is the road to MARC..
[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::Catalogue;
10 use C4::Biblio;
11 #use Date::Manip;
12
13 my $input = new CGI;
14 #print $input->header;
15 #print startpage();
16 #print startmenu('acquisitions');
17 #print $input->dump;
18 my $existing=$input->param('existing');
19 my $title=$input->param('title');
20 $title=~ s/\'/\\\'/g;
21 my $author=$input->param('author');
22 $author=~ s/\'/\\\'/g;
23 my $copyright=$input->param('copyright');
24 my $isbn=$input->param('ISBN');
25 my $itemtype=$input->param('format');
26 my $ordnum=$input->param('ordnum');
27 my $basketno=$input->param('basket');
28 my $quantity=$input->param('quantity');
29 my $listprice=$input->param('list_price');
30 my $series=$input->param('Series');
31 if ($listprice eq ''){
32   $listprice=0;
33 }
34 my $supplier=$input->param('supplier');
35 my $notes=$input->param('notes');
36 my $bookfund=$input->param('bookfund');
37 my $who=$input->remote_user;
38 my $bibnum;
39 my $bibitemnum;
40 my $rrp=$input->param('rrp');
41 my $ecost=$input->param('ecost');
42 my $gst=$input->param('GST');
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?$title:"",
51                            author    => $author?$author:"",
52                            copyright => $copyright?$copyright:"",
53                                     series => $series?$series:"",
54                                      });
55     $bibitemnum = &newbiblioitem({ biblionumber => $bibnum,
56                                    itemtype     => $itemtype?$itemtype:"",
57                                    isbn        => $isbn?$isbn:""
58                                                    });
59         if ($title) {
60                 newsubtitle($bibnum,$title);
61         }
62 #unuseful (already added 4 line before
63 #     modbiblio({ biblionumber  => $bibnum,
64 #               title         => $title?$title:"",
65 #               author        => $author?$author:"",
66 #               copyrightdate => $copyright?$copyright:"",
67 #               series        => $series?$series:"" });
68   } else {
69     $bibnum=$input->param('biblio');
70     $bibitemnum=$input->param('bibitemnum');
71     my $oldtype=$input->param('oldtype');
72     if ($bibitemnum eq '' || $itemtype ne $oldtype){
73       $bibitemnum= &newbiblioitem({ biblionumber => $bibnum,
74                                                          itemtype => $itemtype?$itemtype:"",
75                                                          isbn => $isbn?$isbn:"" });
76     }
77     &modbiblio({
78         biblionumber  => $bibnum,
79         title         => $title?$title:"",
80         author        => $author?$author:"",
81         copyrightdate => $copyright?$copyright:"",
82         series        => $series?$series:"" });
83   }
84   if ($orderexists ne '') {
85     modorder($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst);
86   }else {
87     neworder($bibnum,$title,$ordnum,$basketno,$quantity,$listprice,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst);
88   }
89 } else {
90   $bibnum=$input->param('biblio');
91   delorder($bibnum,$ordnum);
92 }
93
94 print $input->redirect("newbasket.pl?id=$supplier&basket=$basketno");