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 ($template, $loggedinuser, $cookie)
37 = get_template_and_user({template_name => "opac-shelves.tmpl",
41 flagsrequired => {catalogue => 1},
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,
61 LibraryName => C4::Context->preference("LibraryName"),
64 if ($query->param('viewshelf')) { viewshelf($query->param('viewshelf')); last SWITCH;}
65 if ($query->param('shelves')) { shelves(); last SWITCH;}
68 ($shelflist) = GetShelfList($loggedinuser,2); # rebuild shelflist in case a shelf has been added
72 foreach my $element (sort keys %$shelflist) {
74 $line{'color'}= 1 if ($color eq 1);
76 $line{'shelf'}=$element;
77 $line{'shelfname'}=$shelflist->{$element}->{'shelfname'};
78 $line{'shelfbookcount'}=$shelflist->{$element}->{'count'};
79 $line{'canmanage'} = ShelfPossibleAction($loggedinuser,$element,'manage');
81 push (@shelvesloop, \%line);
83 $template->param(shelvesloop => \@shelvesloop);
85 output_html_with_http_headers $query, $cookie, $template->output;
88 if (my $newshelf=$query->param('addshelf')) {
89 my ($status, $string) = AddShelf($env,$newshelf,$query->param('owner'),$query->param('category'));
91 $template->param(status1 => $status, string1 => $string);
95 foreach ($query->param()) {
99 my ($status, $string) = RemoveShelf($env,$delshelf);
101 $line{'status'}=$status;
102 $line{'string'} = $string;
105 #if the shelf is not deleted, %line points on null
106 push(@paramsloop,\%line);
108 $template->param(paramsloop => \@paramsloop);
109 my ($shelflist) = GetShelfList($loggedinuser,2);
112 foreach my $element (sort keys %$shelflist) {
114 $line{'color'}=1 if ($color eq 1);
116 $line{'shelf'}=$element;
117 $line{'shelfname'}=$shelflist->{$element}->{'shelfname'} ;
118 $line{'shelfbookcount'}=$shelflist->{$element}->{'count'} ;
119 push(@shelvesloop, \%line);
121 $template->param(shelvesloop=>\@shelvesloop,
127 my $shelfnumber=shift;
128 #check that the user can view the shelf
129 return unless (ShelfPossibleAction($loggedinuser,$shelfnumber,'view'));
130 my ($itemlist) = GetShelfContents($env, $shelfnumber);
134 foreach $item (sort {$a->{'barcode'} cmp $b->{'barcode'}} @$itemlist) {
136 $line{'color'}=1 if ($color eq 1);
138 $line{'itemnumber'}=$item->{'itemnumber'};
139 $line{'barcode'}=$item->{'barcode'};
140 $line{'title'}=$item->{'title'};
141 $line{'author'}=$item->{'author'};
142 $line{'biblionumber'} = $item->{'biblionumber'};
143 push(@itemsloop, \%line);
145 $template->param( itemsloop => \@itemsloop,
146 shelfname => $shelflist->{$shelfnumber}->{'shelfname'},
147 shelfnumber => $shelfnumber,
148 viewshelf => $query->param('viewshelf'),
149 manageshelf => &ShelfPossibleAction($loggedinuser,$shelfnumber,'manage'),
155 # Revision 1.1 2004/03/15 15:02:19 tipaul
156 # adding virtual shelves to opac
158 # Revision 1.1.2.1 2004/03/10 15:08:18 tipaul
159 # modifying shelves : introducing category of shelf : private, public, free for all
161 # Revision 1.13 2004/02/11 08:35:31 tipaul
162 # synch'ing 2.0.0 branch and head
164 # Revision 1.12.2.1 2004/02/06 14:22:19 tipaul
165 # fixing bugs in bookshelves management.
167 # Revision 1.12 2003/02/05 10:04:14 acli
168 # Worked around weirdness with HTML::Template; without the {}, it complains
169 # of being passed an odd number of arguments even though we are not
171 # Revision 1.11 2003/02/05 09:23:03 acli
172 # Fixed a few minor errors to make it run
173 # Noted correct tab size
175 # Revision 1.10 2003/02/02 07:18:37 acli
176 # Moved C4/Charset.pm to C4/Interface/CGI/Output.pm
178 # Create output_html_with_http_headers function to contain the "print $query
179 # ->header(-type => guesstype...),..." call. This is in preparation for
180 # non-HTML output (e.g., text/xml) and charset conversion before output in
183 # Created C4/Interface/CGI/Template.pm to hold convenience functions specific
184 # to the CGI interface using HTML::Template
186 # Modified moremembers.pl to make the "sex" field localizable for languages
187 # where M and F doesn't make sense
189 # Revision 1.9 2002/12/19 18:55:40 hdl
190 # Templating reservereport et shelves.
192 # Revision 1.9 2002/08/14 18:12:51 hdl
195 # Revision 1.8 2002/08/14 18:12:51 tonnesen
196 # Added copyright statement to all .pl and .pm files
198 # Revision 1.7 2002/07/05 05:03:37 tonnesen
199 # Minor changes to authentication routines.
201 # Revision 1.5 2002/07/04 19:42:48 tonnesen
204 # Revision 1.4 2002/07/04 19:21:29 tonnesen
205 # Beginning of authentication api. Applied to shelves.pl for now as a test case.
207 # Revision 1.2.2.1 2002/06/26 20:28:15 tonnesen
208 # Some udpates that I made here locally a while ago. Still won't be useful, but
209 # should be functional