2 #script to provide bookshelf management
3 # WARNING: This file uses 4-character tabs!
9 # Copyright 2000-2002 Katipo Communications
11 # This file is part of Koha.
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA 02111-1307 USA
31 use C4::Circulation::Circ2;
33 use C4::Interface::CGI::Output;
38 #print $query->header(-cookie => $cookie);
39 my $headerbackgroundcolor='#663266';
40 my $circbackgroundcolor='#555555';
41 my $circbackgroundcolor='#550000';
42 my $linecolor1='#bbbbbb';
43 my $linecolor2='#dddddd';
44 my ($template, $loggedinuser, $cookie)
45 = get_template_and_user({template_name => "shelves.tmpl",
49 flagsrequired => {parameters => 1},
52 #print startmenu('catalogue');
53 #print "<p align=left>Logged in as: $loggedinuser [<a href=/cgi-bin/koha/logout.pl>Log Out</a>]</p>\n";
56 my ($shelflist) = GetShelfList();
58 if ($query->param('modifyshelfcontents')) {
59 my $shelfnumber=$query->param('shelfnumber');
60 my $barcode=$query->param('addbarcode');
61 my ($item) = getiteminformation($env, 0, $barcode);
62 AddToShelf($env, $item->{'itemnumber'}, $shelfnumber);
63 foreach ($query->param) {
66 RemoveFromShelf($env, $itemnumber, $shelfnumber);
72 $template->param({ loggedinuser => $loggedinuser,
73 viewshelf => $query->param('viewshelf'),
74 shelves => $query->param('shelves'),
75 headerbackgroundcolor => $headerbackgroundcolor,
76 circbackgroundcolor => $circbackgroundcolor });
77 if ($query->param('viewshelf')) { viewshelf($query->param('viewshelf')); last SWITCH;}
78 if ($query->param('shelves')) { shelves(); last SWITCH;}
81 foreach my $element (sort keys %$shelflist) {
83 ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
84 $line{'color'}= $color;
85 $line{'shelf'}=$element;
86 $line{'shelfname'}=$shelflist->{$element}->{'shelfname'};
87 $line{'shelfbookcount'}=$shelflist->{$element}->{'count'};
88 push (@shelvesloop, \%line);
90 $template->param(shelvesloop => \@shelvesloop);
93 output_html_with_http_headers $query, $cookie, $template->output;
97 if (my $newshelf=$query->param('addshelf')) {
98 my ($status, $string) = AddShelf($env,$newshelf);
100 $template->param(status1 => $status, string1 => $string);
104 foreach ($query->param()) {
108 my ($status, $string) = RemoveShelf($env,$delshelf);
110 $line{'status'}=$status;
111 $line{'string'} = $string;
114 #if the shelf is not deleted, %line points on null
115 push(@paramsloop,\%line);
117 $template->param(paramsloop => \@paramsloop);
118 my ($shelflist) = GetShelfList();
121 foreach my $element (sort keys %$shelflist) {
123 ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
124 $line{'color'}=$color;
125 $line{'shelf'}=$element;
126 $line{'shelfname'}=$shelflist->{$element}->{'shelfname'} ;
127 $line{'shelfbookcount'}=$shelflist->{$element}->{'count'} ;
128 push(@shelvesloop, \%line);
130 $template->param(shelvesloop=>\@shelvesloop);
136 my $shelfnumber=shift;
137 my ($itemlist) = GetShelfContents($env, $shelfnumber);
141 foreach $item (sort {$a->{'barcode'} cmp $b->{'barcode'}} @$itemlist) {
143 ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
144 $line{'color'}=$color;
145 $line{'itemnumber'}=$item->{'itemnumber'};
146 $line{'barcode'}=$item->{'barcode'};
147 $line{'title'}=$item->{'title'};
148 $line{'author'}=$item->{'author'};
149 push(@itemsloop, \%line);
151 $template->param( itemsloop => \@itemsloop);
152 $template->param( shelfname => $shelflist->{$shelfnumber}->{'shelfname'});
153 $template->param( shelfnumber => $shelfnumber);
157 #print endmenu('catalogue');
161 # Revision 1.12 2003/02/05 10:04:14 acli
162 # Worked around weirdness with HTML::Template; without the {}, it complains
163 # of being passed an odd number of arguments even though we are not
165 # Revision 1.11 2003/02/05 09:23:03 acli
166 # Fixed a few minor errors to make it run
167 # Noted correct tab size
169 # Revision 1.10 2003/02/02 07:18:37 acli
170 # Moved C4/Charset.pm to C4/Interface/CGI/Output.pm
172 # Create output_html_with_http_headers function to contain the "print $query
173 # ->header(-type => guesstype...),..." call. This is in preparation for
174 # non-HTML output (e.g., text/xml) and charset conversion before output in
177 # Created C4/Interface/CGI/Template.pm to hold convenience functions specific
178 # to the CGI interface using HTML::Template
180 # Modified moremembers.pl to make the "sex" field localizable for languages
181 # where M and F doesn't make sense
183 # Revision 1.9 2002/12/19 18:55:40 hdl
184 # Templating reservereport et shelves.
186 # Revision 1.9 2002/08/14 18:12:51 hdl
189 # Revision 1.8 2002/08/14 18:12:51 tonnesen
190 # Added copyright statement to all .pl and .pm files
192 # Revision 1.7 2002/07/05 05:03:37 tonnesen
193 # Minor changes to authentication routines.
195 # Revision 1.5 2002/07/04 19:42:48 tonnesen
198 # Revision 1.4 2002/07/04 19:21:29 tonnesen
199 # Beginning of authentication api. Applied to shelves.pl for now as a test case.
201 # Revision 1.2.2.1 2002/06/26 20:28:15 tonnesen
202 # Some udpates that I made here locally a while ago. Still won't be useful, but
203 # should be functional