Added copyright statement to all .pl and .pm files
[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
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 #
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA  02111-1307 USA
23
24 use strict;
25 use CGI;
26 use C4::Output;
27 use C4::Catalogue;
28 use C4::Biblio;
29 #use Date::Manip;
30
31 my $input = new CGI;
32 #print $input->header;
33 #print startpage();
34 #print startmenu('acquisitions');
35 #print $input->dump;
36 my $existing=$input->param('existing');
37 my $title=$input->param('title');
38 $title=~ s/\'/\\\'/g;
39 my $author=$input->param('author');
40 $author=~ s/\'/\\\'/g;
41 my $copyright=$input->param('copyright');
42 my $isbn=$input->param('ISBN');
43 my $itemtype=$input->param('format');
44 my $ordnum=$input->param('ordnum');
45 my $basketno=$input->param('basket');
46 my $quantity=$input->param('quantity');
47 my $listprice=$input->param('list_price');
48 my $series=$input->param('Series');
49 if ($listprice eq ''){
50   $listprice=0;
51 }
52 my $supplier=$input->param('supplier');
53 my $notes=$input->param('notes');
54 my $bookfund=$input->param('bookfund');
55 my $who=$input->remote_user;
56 my $bibnum;
57 my $bibitemnum;
58 my $rrp=$input->param('rrp');
59 my $ecost=$input->param('ecost');
60 my $gst=$input->param('GST');
61 my $orderexists=$input->param('orderexists');
62
63 #check to see if biblio exists
64 if ($quantity ne '0'){
65
66   if ($existing eq 'no'){
67     #if it doesnt create it
68     $bibnum = &newbiblio({ title     => $title?$title:"",
69                            author    => $author?$author:"",
70                            copyright => $copyright?$copyright:"",
71                                     series => $series?$series:"",
72                                      });
73     $bibitemnum = &newbiblioitem({ biblionumber => $bibnum,
74                                    itemtype     => $itemtype?$itemtype:"",
75                                    isbn        => $isbn?$isbn:""
76                                                    });
77         if ($title) {
78                 newsubtitle($bibnum,$title);
79         }
80 #unuseful (already added 4 line before
81 #     modbiblio({ biblionumber  => $bibnum,
82 #               title         => $title?$title:"",
83 #               author        => $author?$author:"",
84 #               copyrightdate => $copyright?$copyright:"",
85 #               series        => $series?$series:"" });
86   } else {
87     $bibnum=$input->param('biblio');
88     $bibitemnum=$input->param('bibitemnum');
89     my $oldtype=$input->param('oldtype');
90     if ($bibitemnum eq '' || $itemtype ne $oldtype){
91       $bibitemnum= &newbiblioitem({ biblionumber => $bibnum,
92                                                          itemtype => $itemtype?$itemtype:"",
93                                                          isbn => $isbn?$isbn:"" });
94     }
95     &modbiblio({
96         biblionumber  => $bibnum,
97         title         => $title?$title:"",
98         author        => $author?$author:"",
99         copyrightdate => $copyright?$copyright:"",
100         series        => $series?$series:"" });
101   }
102   if ($orderexists ne '') {
103     modorder($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst);
104   }else {
105     neworder($bibnum,$title,$ordnum,$basketno,$quantity,$listprice,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst);
106   }
107 } else {
108   $bibnum=$input->param('biblio');
109   delorder($bibnum,$ordnum);
110 }
111
112 print $input->redirect("newbasket.pl?id=$supplier&basket=$basketno");