Replaced expressions of the form "$x = $x <op> $y" with "$x <op>= $y".
[koha.git] / shelves.pl
1 #!/usr/bin/perl
2 #script to provide bookshelf management
3 #
4 # $Header$
5 #
6
7
8 # Copyright 2000-2002 Katipo Communications
9 #
10 # This file is part of Koha.
11 #
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
16 #
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA  02111-1307 USA
24
25 use strict;
26 use C4::Search;
27 use CGI;
28 use C4::Output;
29 use C4::BookShelves;
30 use C4::Circulation::Circ2;
31 use C4::Auth;
32
33 my $env;
34 my $query = new CGI;
35 my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
36 print $query->header(-cookie => $cookie);
37 my $headerbackgroundcolor='#663266';
38 my $circbackgroundcolor='#555555';
39 my $circbackgroundcolor='#550000';
40 my $linecolor1='#bbbbbb';
41 my $linecolor2='#dddddd';
42
43 print startpage();
44 print startmenu('catalogue');
45
46
47 print "<p align=left>Logged in as: $loggedinuser [<a href=/cgi-bin/koha/logout.pl>Log Out</a>]</p>\n";
48
49
50 my ($shelflist) = GetShelfList();
51
52 if ($query->param('modifyshelfcontents')) {
53     my $shelfnumber=$query->param('shelfnumber');
54     my $barcode=$query->param('addbarcode');
55     my ($item) = getiteminformation($env, 0, $barcode);
56     AddToShelf($env, $item->{'itemnumber'}, $shelfnumber);
57     foreach ($query->param) {
58         if (/REM-(\d*)/) {
59             my $itemnumber=$1;
60             RemoveFromShelf($env, $itemnumber, $shelfnumber);
61         }
62     }
63 }
64
65 SWITCH: {
66     if ($query->param('viewshelf')) {  viewshelf($query->param('viewshelf')); last SWITCH;}
67     if ($query->param('shelves')) {  shelves(); last SWITCH;}
68     print << "EOF";
69     <center>
70     <table border=0 cellpadding=4 cellspacing=0>
71     <tr><td bgcolor=$headerbackgroundcolor>
72     <table border=0 cellpadding=5 cellspacing=0 width=100%>
73     <tr><th bgcolor=$headerbackgroundcolor>
74     <font color=white>Shelf List</font>
75     </th></tr>
76     </table>
77     </td></tr>
78 EOF
79     my $color='';
80     foreach (sort keys %$shelflist) {
81         ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
82         print "<tr><td bgcolor=$color><a href=shelves.pl?viewshelf=$_>$shelflist->{$_}->{'shelfname'} ($shelflist->{$_}->{'count'} books)</a></td></tr>\n";
83     }
84     print "</table>\n";
85     print "<P><a href=shelves.pl?shelves=1>Add or Remove Book Shelves</a>\n";
86 }
87
88
89
90 sub shelves {
91     if (my $newshelf=$query->param('addshelf')) {
92         my ($status, $string) = AddShelf($env,$newshelf);
93         if ($status) {
94             print "<font color=red>$string</font><p>\n";
95         }
96     }
97     foreach ($query->param()) {
98         if (/DEL-(\d+)/) {
99             my $delshelf=$1;
100             my ($status, $string) = RemoveShelf($env,$delshelf);
101             if ($status) {
102                 print "<font color=red>$string</font><p>\n";
103             }
104         }
105     }
106     my ($shelflist) = GetShelfList();
107     print << "EOF";
108 <center>
109 <a href=shelves.pl>Modify Shelf Contents</a><p>
110 <h1>Bookshelves</h1>
111 <table border=0 cellpadding=7>
112 <tr><td align=center>
113 <form method=post>
114 <input type=hidden name=shelves value=1>
115 <table border=0 cellpadding=0 cellspacing=0>
116 <tr><th bgcolor=$headerbackgroundcolor>
117 <font color=white>Select Shelves to Delete</font>
118 </th></tr>
119 EOF
120     my $color='';
121     my $color='';
122     foreach (sort keys %$shelflist) {
123         ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
124         print "<tr><td bgcolor=$color><input type=checkbox name=DEL-$_> $shelflist->{$_}->{'shelfname'} ($shelflist->{$_}->{'count'} books)</td></tr>\n";
125     }
126     print "</table>\n";
127     print '<p><input type=submit value="Delete Shelves"><p>';
128     print "</td><td align=center valign=top>\n";
129     print "<form method=post>\n";
130     print "<input type=hidden name=shelves value=1>\n";
131     print "<p>Add Shelf: <input name=addshelf size=25><p>\n";
132     print '<p><input type=submit value="Add New Shelf"><p>';
133     print "</form>\n";
134     print "</td></tr></table>\n";
135 }
136
137
138
139 sub viewshelf {
140     my $shelfnumber=shift;
141     my ($itemlist) = GetShelfContents($env, $shelfnumber);
142     my $item='';
143     print << "EOF";
144     <center>
145     <form>
146     <a href=shelves.pl>Shelf List</a><p>
147     <table border=0 cellpadding=0 cellspacing=0>
148     <tr><td colspan=7>
149     <table>
150     <tr><td>Add a book by barcode:</td><td><input name=addbarcode></td></tr>
151     </table>
152     <br>
153     <table border=0 cellpadding=5 cellspacing=0 width=100%>
154     <tr><th bgcolor=$headerbackgroundcolor>
155     <font color=white>Contents of $shelflist->{$shelfnumber}->{'shelfname'} shelf</font>
156     </th></tr>
157     </table>
158     </td></tr>
159 EOF
160     my $color='';
161     foreach $item (sort {$a->{'barcode'} cmp $b->{'barcode'}} @$itemlist) {
162         ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
163         print << "EOF";
164         <tr>
165         <td bgcolor=$color><input type=checkbox name=REM-$item->{'itemnumber'}></td>
166         <td bgcolor=$color width=10 align=center><img src=/images/blankdot.gif></td>
167         <td bgcolor=$color>$item->{'barcode'}</td>
168         <td bgcolor=$color width=10 align=center><img src=/images/blankdot.gif></td>
169         <td bgcolor=$color>$item->{'title'}</td>
170         <td bgcolor=$color width=10 align=center><img src=/images/blankdot.gif></td>
171         <td bgcolor=$color>$item->{'author'}</td>
172         </tr>
173 EOF
174     }
175     print << "EOF";
176     </table>
177     <br>
178     <input type=hidden name=shelfnumber value=$shelfnumber>
179     <input type=hidden name=modifyshelfcontents value=1>
180     <input type=hidden name=viewshelf value=$shelfnumber>
181     <input type=submit value="Remove Selected Items">
182     </form>
183 EOF
184 }
185
186
187
188 #
189 # $Log$
190 # Revision 1.8  2002/08/14 18:12:51  tonnesen
191 # Added copyright statement to all .pl and .pm files
192 #
193 # Revision 1.7  2002/07/05 05:03:37  tonnesen
194 # Minor changes to authentication routines.
195 #
196 # Revision 1.5  2002/07/04 19:42:48  tonnesen
197 # Minor changes
198 #
199 # Revision 1.4  2002/07/04 19:21:29  tonnesen
200 # Beginning of authentication api.  Applied to shelves.pl for now as a test case.
201 #
202 # Revision 1.2.2.1  2002/06/26 20:28:15  tonnesen
203 # Some udpates that I made here locally a while ago.  Still won't be useful, but
204 # should be functional
205 #
206 #
207 #
208
209
210
211 print endpage();
212 print endmenu('catalogue');