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;
37 my ($template, $loggedinuser, $cookie)
38 = get_template_and_user({template_name => "opac-shelves.tmpl",
44 if ($query->param('modifyshelfcontents')) {
45 my $shelfnumber=$query->param('shelfnumber');
46 my $barcode=$query->param('addbarcode');
47 my ($item) = getiteminformation($env, 0, $barcode);
48 if (ShelfPossibleAction($loggedinuser,$shelfnumber,'manage')) {
49 AddToShelf($env, $item->{'itemnumber'}, $shelfnumber);
50 foreach ($query->param) {
53 RemoveFromShelf($env, $itemnumber, $shelfnumber);
58 my ($shelflist) = GetShelfList($loggedinuser,2);
60 $template->param({ loggedinuser => $loggedinuser,
63 if ($query->param('op') eq 'modifsave') {
64 ModifShelf($query->param('shelfnumber'),$query->param('shelfname'),$loggedinuser,$query->param('category'));
67 if ($query->param('op') eq 'modif') {
68 my ($shelfnumber,$shelfname,$owner,$category) = GetShelf($query->param('shelf'));
69 $template->param(edit => 1,
70 shelfnumber => $shelfnumber,
71 shelfname => $shelfname,
72 "category$category" => 1);
73 # editshelf($query->param('shelf'));
76 if ($query->param('viewshelf')) {
77 viewshelf($query->param('viewshelf'));
80 if ($query->param('shelves')) {
86 ($shelflist) = GetShelfList($loggedinuser,2); # rebuild shelflist in case a shelf has been added
90 foreach my $element (sort keys %$shelflist) {
92 ($color eq 0) ? ($color=1) : ($color=0);
93 $line{'color'}= $color;
94 $line{'shelf'}=$element;
95 $line{'shelfname'}=$shelflist->{$element}->{'shelfname'};
96 $line{"category".$shelflist->{$element}->{'category'}} = 1;
97 $line{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
98 $line{'shelfbookcount'}=$shelflist->{$element}->{'count'};
99 $line{'canmanage'} = ShelfPossibleAction($loggedinuser,$element,'manage');
100 $line{'firstname'}=$shelflist->{$element}->{'firstname'} unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
101 $line{'surname'}=$shelflist->{$element}->{'surname'} unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
103 push (@shelvesloop, \%line);
105 $template->param(shelvesloop => \@shelvesloop);
107 output_html_with_http_headers $query, $cookie, $template->output;
110 # my ($shelfnumber) = @_;
111 # my ($shelfnumber,$shelfname,$owner,$category) = GetShelf($shelfnumber);
112 # $template->param(edit => 1,
113 # shelfnumber => $shelfnumber,
114 # shelfname => $shelfname,
115 # "category$category" => 1);
118 if (my $newshelf=$query->param('addshelf')) {
119 my ($status, $string) = AddShelf($env,$newshelf,$query->param('owner'),$query->param('category'));
121 $template->param(status1 => $status, string1 => $string);
125 foreach ($query->param()) {
129 my ($status, $string) = RemoveShelf($env,$delshelf);
131 $line{'status'}=$status;
132 $line{'string'} = $string;
135 #if the shelf is not deleted, %line points on null
136 push(@paramsloop,\%line);
138 $template->param(paramsloop => \@paramsloop);
139 my ($shelflist) = GetShelfList($loggedinuser,2);
142 foreach my $element (sort keys %$shelflist) {
144 ($color eq 0) ? ($color=1) : ($color=0);
145 $line{'color'}=$color;
146 $line{'shelf'}=$element;
147 $line{'shelfname'}=$shelflist->{$element}->{'shelfname'} ;
148 $line{'shelfbookcount'}=$shelflist->{$element}->{'count'} ;
149 push(@shelvesloop, \%line);
151 $template->param(shelvesloop=>\@shelvesloop,
157 my $shelfnumber=shift;
158 #check that the user can view the shelf
159 return unless (ShelfPossibleAction($loggedinuser,$shelfnumber,'view'));
160 my ($itemlist) = GetShelfContents($env, $shelfnumber);
164 foreach $item (sort {$a->{'barcode'} cmp $b->{'barcode'}} @$itemlist) {
166 ($color eq 0) ? ($color=1) : ($color=0);
167 $line{'color'}=$color;
168 $line{'itemnumber'}=$item->{'itemnumber'};
169 $line{'barcode'}=$item->{'barcode'};
170 $line{'title'}=$item->{'title'};
171 $line{'author'}=$item->{'author'};
172 $line{'classification'}=$item->{'classification'};
173 $line{'itemtype'}=$item->{'itemtype'};
174 $line{biblionumber} = $item->{biblionumber};
175 push(@itemsloop, \%line);
177 $template->param( itemsloop => \@itemsloop,
178 shelfname => $shelflist->{$shelfnumber}->{'shelfname'},
179 shelfnumber => $shelfnumber,
180 viewshelf => $query->param('viewshelf'),
181 manageshelf => &ShelfPossibleAction($loggedinuser,$shelfnumber,'manage'),
187 # Revision 1.8 2006/05/21 02:30:17 kados
188 # syncing dev-week and HEAD
190 # Revision 1.7 2005/05/04 09:02:38 tipaul
191 # synch'ing 2.2 and head
193 # Revision 1.3.2.4 2005/03/25 17:04:28 tipaul
194 # adding virtual shelves & suggestions button to the top
196 # Revision 1.3.2.3 2005/01/27 17:18:28 oleonard
197 # Taking table cell background color information out of the script and moving it into the template (requires update to opac-shelves.tmpl)
199 # Revision 1.3.2.2 2005/01/11 20:18:29 oleonard
200 # Adding call number and item type to list of returned variables
202 # Revision 1.3.2.1 2005/01/11 16:33:57 tipaul
203 # fix for http://bugs.koha.org/cgi-bin/bugzilla/show_bug.cgi?id=811 :
204 # The OPAC requires uses to log in to view virtual shelves, and it requires a user
205 # with librarian privileges. Virtual shelves should be viewable by all users,
206 # logged in or not, and editable by all logged-in users in good standing.
208 # Revision 1.3 2005/01/03 11:09:34 tipaul
209 # synch'ing virtual shelves management in opac with the librarian one, that has more features
211 # Revision 1.5 2004/12/16 11:30:57 tipaul
212 # adding bookshelf features :
213 # * create bookshelf on the fly
214 # * modify a bookshelf name & status
216 # Revision 1.4 2004/12/15 17:28:23 tipaul
217 # adding bookshelf features :
218 # * create bookshelf on the fly
219 # * modify a bookshelf (this being not finished, will commit the rest soon)
221 # Revision 1.3 2004/12/02 16:38:50 tipaul
222 # improvement in book shelves
224 # Revision 1.2 2004/11/19 16:31:30 tipaul
225 # bugfix for bookshelves not in official CVS
227 # Revision 1.1.2.1 2004/03/10 15:08:18 tipaul
228 # modifying shelves : introducing category of shelf : private, public, free for all
230 # Revision 1.13 2004/02/11 08:35:31 tipaul
231 # synch'ing 2.0.0 branch and head
233 # Revision 1.12.2.1 2004/02/06 14:22:19 tipaul
234 # fixing bugs in bookshelves management.
236 # Revision 1.12 2003/02/05 10:04:14 acli
237 # Worked around weirdness with HTML::Template; without the {}, it complains
238 # of being passed an odd number of arguments even though we are not
240 # Revision 1.11 2003/02/05 09:23:03 acli
241 # Fixed a few minor errors to make it run
242 # Noted correct tab size
244 # Revision 1.10 2003/02/02 07:18:37 acli
245 # Moved C4/Charset.pm to C4/Interface/CGI/Output.pm
247 # Create output_html_with_http_headers function to contain the "print $query
248 # ->header(-type => guesstype...),..." call. This is in preparation for
249 # non-HTML output (e.g., text/xml) and charset conversion before output in
252 # Created C4/Interface/CGI/Template.pm to hold convenience functions specific
253 # to the CGI interface using HTML::Template
255 # Modified moremembers.pl to make the "sex" field localizable for languages
256 # where M and F doesn't make sense
258 # Revision 1.9 2002/12/19 18:55:40 hdl
259 # Templating reservereport et shelves.
261 # Revision 1.9 2002/08/14 18:12:51 hdl
264 # Revision 1.8 2002/08/14 18:12:51 tonnesen
265 # Added copyright statement to all .pl and .pm files
267 # Revision 1.7 2002/07/05 05:03:37 tonnesen
268 # Minor changes to authentication routines.
270 # Revision 1.5 2002/07/04 19:42:48 tonnesen
273 # Revision 1.4 2002/07/04 19:21:29 tonnesen
274 # Beginning of authentication api. Applied to shelves.pl for now as a test case.
276 # Revision 1.2.2.1 2002/06/26 20:28:15 tonnesen
277 # Some udpates that I made here locally a while ago. Still won't be useful, but
278 # should be functional