Initial revision
[wip/koha-chris_n.git] / updateitem.pl
1 #!/usr/bin/perl
2
3 use C4::Database;
4 use CGI;
5 use strict;
6 use C4::Acquisitions;
7 use C4::Output;
8
9 my $input= new CGI;
10 #print $input->header;
11 #print $input->dump;
12
13
14 #my $title=checkinp($input->param('Title'));
15 #my $author=checkinp($input->param('Author'));
16 my $bibnum=checkinp($input->param('bibnum'));
17 my $itemnum=checkinp($input->param('itemnumber'));
18 my $copyright=checkinp($input->param('Copyright'));
19 my $seriestitle=checkinp($input->param('Series'));
20 my $serial=checkinp($input->param('Serial'));
21 my $unititle=checkinp($input->param('Unititle'));
22 my $notes=checkinp($input->param('ItemNotes'));
23
24 #need to do barcode check
25 my $barcode=$input->param('Barcode');
26 #modbiblio($bibnum,$title,$author,$copyright,$seriestitle,$serial,$unititle,$notes);
27
28 my $bibitemnum=checkinp($input->param('bibitemnum'));
29 #my $olditemtype
30 my $itemtype=checkinp($input->param('Item'));
31 my $isbn=checkinp($input->param('ISBN'));
32 my $publishercode=checkinp($input->param('Publisher'));
33 my $publicationdate=checkinp($input->param('Publication'));
34 my $class=checkinp($input->param('Class'));
35 my $homebranch=checkinp($input->param('Home'));
36 my $lost=$input->param('Lost');
37 my $wthdrawn=$input->param('withdrawn');
38 my $classification;
39 my $dewey;
40 my $subclass;
41 if ($itemtype ne 'NF'){
42   $classification=$class;
43 }
44 if ($class =~/[0-9]+/){
45 #   print $class;
46    $dewey= $class;
47    $dewey=~ s/[a-z]+//gi;
48    my @temp;
49    if ($class =~ /\./){
50      @temp=split(/[0-9]+\.[0-9]+/,$class);
51    } else {
52      @temp=split(/[0-9]+/,$class);
53    }
54    $classification=$temp[0];
55    $subclass=$temp[1];
56 #   print $classification,$dewey,$subclass;
57 }else{
58   $dewey='';
59 }
60 my $illus=checkinp($input->param('Illustrations'));
61 my $pages=checkinp($input->param('Pages'));
62 my $volumeddesc=checkinp($input->param('Volume'));
63
64 #have to check how many items are attached to this bibitem, if one, just change it,
65 #if more than one, we must create a new one.
66 #my $number=countitems($bibitemnum);
67 #if ($number > 1){
68 #   print $number;
69   #check if bibitemneeds modifying
70 #  my $needsmod=needsmod($bibitemnum,$itemtype);
71 #  if ($needsmod != 1){
72 #    $bibitemnum=newbiblioitem($bibnum,$itemtype,$volumeddesc,$classification);
73 #  }
74 #} 
75 #modbibitem($bibitemnum,$itemtype,$isbn,$publishercode,$publicationdate,$classification,$dewey,$subclass,$illus,$pages,$volumeddesc);
76 moditem('loan',$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn);
77
78 print $input->redirect("moredetail.pl?type=intra&bib=$bibnum&bi=$bibitemnum");
79 #print $bibitemnum;
80
81 sub checkinp{
82   my ($inp)=@_;
83   $inp=~ s/\'/\\\'/g;
84   $inp=~ s/\"/\\\"/g;
85   return($inp);
86 }