2 #script to provide bookshelf management
3 # WARNING: This file uses 4-character tabs!
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
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
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.
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
29 use C4::Circulation::Circ2;
31 use C4::Interface::CGI::Output;
36 my $headerbackgroundcolor='#663266';
37 my $circbackgroundcolor='#555555';
38 my $circbackgroundcolor='#550000';
39 my $linecolor1='#bbbbbb';
40 my $linecolor2='#dddddd';
41 my ($template, $loggedinuser, $cookie)
42 = get_template_and_user({template_name => "bookshelves/shelves.tmpl",
46 flagsrequired => {catalogue => 1},
49 if ($query->param('modifyshelfcontents')) {
50 my $shelfnumber=$query->param('shelfnumber');
51 my $barcode=$query->param('addbarcode');
52 my ($item) = getiteminformation($env, 0, $barcode);
53 if (ShelfPossibleAction($loggedinuser,$shelfnumber,'manage')) {
54 AddToShelf($env, $item->{'itemnumber'}, $shelfnumber);
55 foreach ($query->param) {
58 RemoveFromShelf($env, $itemnumber, $shelfnumber);
63 my ($shelflist) = GetShelfList($loggedinuser,2);
65 $template->param({ loggedinuser => $loggedinuser,
66 headerbackgroundcolor => $headerbackgroundcolor,
67 circbackgroundcolor => $circbackgroundcolor });
69 if ($query->param('viewshelf')) { viewshelf($query->param('viewshelf')); last SWITCH;}
70 if ($query->param('shelves')) { shelves(); last SWITCH;}
73 ($shelflist) = GetShelfList($loggedinuser,2); # rebuild shelflist in case a shelf has been added
77 foreach my $element (sort keys %$shelflist) {
79 ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
80 $line{'color'}= $color;
81 $line{'shelf'}=$element;
82 $line{'shelfname'}=$shelflist->{$element}->{'shelfname'};
83 $line{'shelfbookcount'}=$shelflist->{$element}->{'count'};
84 $line{'canmanage'} = ShelfPossibleAction($loggedinuser,$element,'manage');
86 push (@shelvesloop, \%line);
88 $template->param(shelvesloop => \@shelvesloop);
90 output_html_with_http_headers $query, $cookie, $template->output;
93 if (my $newshelf=$query->param('addshelf')) {
94 my ($status, $string) = AddShelf($env,$newshelf,$query->param('owner'),$query->param('category'));
96 $template->param(status1 => $status, string1 => $string);
100 foreach ($query->param()) {
104 my ($status, $string) = RemoveShelf($env,$delshelf);
106 $line{'status'}=$status;
107 $line{'string'} = $string;
110 #if the shelf is not deleted, %line points on null
111 push(@paramsloop,\%line);
113 $template->param(paramsloop => \@paramsloop);
114 my ($shelflist) = GetShelfList($loggedinuser,2);
117 foreach my $element (sort keys %$shelflist) {
119 ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
120 $line{'color'}=$color;
121 $line{'shelf'}=$element;
122 $line{'shelfname'}=$shelflist->{$element}->{'shelfname'} ;
123 $line{'shelfbookcount'}=$shelflist->{$element}->{'count'} ;
124 push(@shelvesloop, \%line);
126 $template->param(shelvesloop=>\@shelvesloop,
132 my $shelfnumber=shift;
133 #check that the user can view the shelf
134 return unless (ShelfPossibleAction($loggedinuser,$shelfnumber,'view'));
135 my ($itemlist) = GetShelfContents($env, $shelfnumber);
139 foreach $item (sort {$a->{'barcode'} cmp $b->{'barcode'}} @$itemlist) {
141 ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
142 $line{'color'}=$color;
143 $line{'itemnumber'}=$item->{'itemnumber'};
144 $line{'barcode'}=$item->{'barcode'};
145 $line{'title'}=$item->{'title'};
146 $line{'author'}=$item->{'author'};
147 $line{biblionumber} = $item->{biblionumber};
148 push(@itemsloop, \%line);
150 $template->param( itemsloop => \@itemsloop,
151 shelfname => $shelflist->{$shelfnumber}->{'shelfname'},
152 shelfnumber => $shelfnumber,
153 viewshelf => $query->param('viewshelf'),
154 manageshelf => &ShelfPossibleAction($loggedinuser,$shelfnumber,'manage'),
160 # Revision 1.3 2004/12/02 16:38:50 tipaul
161 # improvement in book shelves
163 # Revision 1.2 2004/11/19 16:31:30 tipaul
164 # bugfix for bookshelves not in official CVS
166 # Revision 1.1.2.1 2004/03/10 15:08:18 tipaul
167 # modifying shelves : introducing category of shelf : private, public, free for all
169 # Revision 1.13 2004/02/11 08:35:31 tipaul
170 # synch'ing 2.0.0 branch and head
172 # Revision 1.12.2.1 2004/02/06 14:22:19 tipaul
173 # fixing bugs in bookshelves management.
175 # Revision 1.12 2003/02/05 10:04:14 acli
176 # Worked around weirdness with HTML::Template; without the {}, it complains
177 # of being passed an odd number of arguments even though we are not
179 # Revision 1.11 2003/02/05 09:23:03 acli
180 # Fixed a few minor errors to make it run
181 # Noted correct tab size
183 # Revision 1.10 2003/02/02 07:18:37 acli
184 # Moved C4/Charset.pm to C4/Interface/CGI/Output.pm
186 # Create output_html_with_http_headers function to contain the "print $query
187 # ->header(-type => guesstype...),..." call. This is in preparation for
188 # non-HTML output (e.g., text/xml) and charset conversion before output in
191 # Created C4/Interface/CGI/Template.pm to hold convenience functions specific
192 # to the CGI interface using HTML::Template
194 # Modified moremembers.pl to make the "sex" field localizable for languages
195 # where M and F doesn't make sense
197 # Revision 1.9 2002/12/19 18:55:40 hdl
198 # Templating reservereport et shelves.
200 # Revision 1.9 2002/08/14 18:12:51 hdl
203 # Revision 1.8 2002/08/14 18:12:51 tonnesen
204 # Added copyright statement to all .pl and .pm files
206 # Revision 1.7 2002/07/05 05:03:37 tonnesen
207 # Minor changes to authentication routines.
209 # Revision 1.5 2002/07/04 19:42:48 tonnesen
212 # Revision 1.4 2002/07/04 19:21:29 tonnesen
213 # Beginning of authentication api. Applied to shelves.pl for now as a test case.
215 # Revision 1.2.2.1 2002/06/26 20:28:15 tonnesen
216 # Some udpates that I made here locally a while ago. Still won't be useful, but
217 # should be functional