Bug fixes to get the new acqui.simple system working.
[koha.git] / acqui.simple / additem.pl
1 #!/usr/bin/perl
2
3 use CGI;
4 use strict;
5 use C4::Acquisitions;
6 use C4::Output;
7
8 my $input = new CGI;
9 my $biblioitemnum = $input->param('biblioitemnum');
10 my $maxbarcode;
11 my $isbn;
12 my $count;
13 my @results;
14
15 if (! $biblioitemnum) {
16     print $input->redirect('addbooks.pl');
17 } else {
18
19     ($count, @results) = &getbiblioitem($biblioitemnum);
20     
21     if (! $count) {
22         print $input->redirect('addbooks.pl');
23     } else {
24         $isbn       = $results[0]->{'isbn'};
25         $maxbarcode = $results[0]->{'biblionumber'};
26   
27         print $input->header;
28         print startpage();
29         print startmenu('acquisitions');
30     
31         ($count, @results) = &getitemsbybiblioitem($biblioitemnum);
32
33         if ($count) {
34             print << "EOF";
35 <center>
36 <p>
37 <table border=1 bgcolor=#dddddd>
38 <tr>
39 <th colspan=4>Existing Items with ISBN $isbn</th>
40 </tr>
41 <tr>
42 <th>Barcode</th><th>Title</th><th>Author</th><th>Notes</th></tr>
43 EOF
44
45             for (my $i = 0; $i < $count; $i++) {
46                 print << "EOF";
47 <tr>
48 <td align=center>$results[$i]->{'barcode'}</td>
49 <td><u>$results[$i]->{'title'}</u></td>
50 <td>$results[$i]->{'author'}</td>
51 <td>$results[$i]->{'itemnotes'}</td>
52 </tr>
53 EOF
54         } # for
55
56             print << "EOF";
57 </table>
58 </center>
59 EOF
60         } # if
61
62         print << "EOF";
63 <center>
64 <h2>Section Three: Specific Item Information</h2>
65 <form action="saveitem.pl" method="post">
66 <input type="hidden" name="biblioitemnum" value="$biblioitemnum">
67 <table>
68 <tr>
69 <td align="right">BARCODE:</td>
70 <td><input name="barcode" size="10" value="$maxbarcode" /></td>
71 <td align="right">Home Branch:</td>
72 <td><select name="homebranch"><option value="STWE">Stewart Elementary<option value="MEZ">Meziadin Elementary</select></td>
73 </tr>
74 <tr>
75 <td align="right">Replacement Price:</td>
76 <td colspan="3"><input name="replacementprice" size="10"></td>
77 </tr>
78 <tr valign="top">
79 <td align="right">Notes:</td>
80 <td colspan="3"><textarea name="notes" rows="4" cols="40" wrap="physical"></textarea></td>
81 </tr>
82 </table>
83 <input type="submit" value="Add Item" />
84 </form>
85 </center>
86 EOF
87     
88         print endmenu();
89         print endpage();
90     } # if
91 } # if