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('op') eq 'modifsave') {
70 ModifShelf
($query->param('shelfnumber'),$query->param('shelfname'),$loggedinuser,$query->param('category'));
73 if ($query->param('op') eq 'modif') {
74 my ($shelfnumber,$shelfname,$owner,$category) = GetShelf
($query->param('shelf'));
75 $template->param(edit
=> 1,
76 shelfnumber
=> $shelfnumber,
77 shelfname
=> $shelfname,
78 "category$category" => 1);
79 # editshelf($query->param('shelf'));
82 if ($query->param('viewshelf')) {
83 viewshelf
($query->param('viewshelf'));
86 if ($query->param('shelves')) {
92 ($shelflist) = GetShelfList
($loggedinuser,2); # rebuild shelflist in case a shelf has been added
96 foreach my $element (sort keys %$shelflist) {
98 ($color eq 1) ?
($color=0) : ($color=1);
99 $line{'toggle'}=$color;
100 $line{'shelf'}=$element;
101 $line{'shelfname'}=$shelflist->{$element}->{'shelfname'};
102 $line{"category".$shelflist->{$element}->{'category'}} = 1;
103 $line{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
104 $line{'shelfbookcount'}=$shelflist->{$element}->{'count'};
105 $line{'canmanage'} = ShelfPossibleAction
($loggedinuser,$element,'manage');
106 $line{'firstname'}=$shelflist->{$element}->{'firstname'} unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
107 $line{'surname'}=$shelflist->{$element}->{'surname'} unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
109 push (@shelvesloop, \
%line);
111 $template->param(shelvesloop
=> \
@shelvesloop,
112 intranetcolorstylesheet
=> C4
::Context
->preference("intranetcolorstylesheet"),
113 intranetstylesheet
=> C4
::Context
->preference("intranetstylesheet"),
114 IntranetNav
=> C4
::Context
->preference("IntranetNav"),
117 output_html_with_http_headers
$query, $cookie, $template->output;
120 # my ($shelfnumber) = @_;
121 # my ($shelfnumber,$shelfname,$owner,$category) = GetShelf($shelfnumber);
122 # $template->param(edit => 1,
123 # shelfnumber => $shelfnumber,
124 # shelfname => $shelfname,
125 # "category$category" => 1);
128 if (my $newshelf=$query->param('addshelf')) {
129 my ($status, $string) = AddShelf
($env,$newshelf,$query->param('owner'),$query->param('category'));
131 $template->param(status1
=> $status, string1
=> $string);
135 foreach ($query->param()) {
139 my ($status, $string) = RemoveShelf
($env,$delshelf);
141 $line{'status'}=$status;
142 $line{'string'} = $string;
145 #if the shelf is not deleted, %line points on null
146 push(@paramsloop,\
%line);
148 $template->param(paramsloop
=> \
@paramsloop);
149 my ($shelflist) = GetShelfList
($loggedinuser,2);
152 foreach my $element (sort keys %$shelflist) {
154 ($color eq 1) ?
($color=0) : ($color=1);
155 $line{'toggle'}=$color;
156 $line{'shelf'}=$element;
157 $line{'shelfname'}=$shelflist->{$element}->{'shelfname'} ;
158 $line{'shelfbookcount'}=$shelflist->{$element}->{'count'} ;
159 push(@shelvesloop, \
%line);
161 $template->param(shelvesloop
=>\
@shelvesloop,
167 my $shelfnumber=shift;
168 #check that the user can view the shelf
169 return unless (ShelfPossibleAction
($loggedinuser,$shelfnumber,'view'));
170 my ($itemlist) = GetShelfContents
($env, $shelfnumber);
174 foreach $item (sort {$a->{'barcode'} cmp $b->{'barcode'}} @
$itemlist) {
176 ($color eq 1) ?
($color=0) : ($color=1);
177 $line{'toggle'}=$color;
178 $line{'itemnumber'}=$item->{'itemnumber'};
179 $line{'barcode'}=$item->{'barcode'};
180 $line{'title'}=$item->{'title'};
181 $line{'author'}=$item->{'author'};
182 $line{'publicationyear'}=$item->{'publicationyear'};
183 $line{'itemtype'}=$item->{'itemtype'};
184 $line{biblionumber
} = $item->{biblionumber
};
185 push(@itemsloop, \
%line);
187 $template->param( itemsloop
=> \
@itemsloop,
188 shelfname
=> $shelflist->{$shelfnumber}->{'shelfname'},
189 shelfnumber
=> $shelfnumber,
190 viewshelf
=> $query->param('viewshelf'),
191 manageshelf
=> &ShelfPossibleAction
($loggedinuser,$shelfnumber,'manage'),
197 # Revision 1.5.2.5 2006/02/05 21:59:21 kados
198 # Adds script support for IntranetNav ... see mail to koha-devel for
201 # Revision 1.5.2.4 2006/02/05 21:45:25 kados
202 # Adds support for intranetstylesheet system pref in Koha scripts
204 # Revision 1.5.2.3 2006/02/04 21:26:47 kados
205 # Adds support for intranetcolorstylesheet
207 # Revision 1.5.2.2 2005/04/27 18:15:27 oleonard
208 # Left out some instances in the previous update
210 # Revision 1.5.2.1 2005/04/27 16:55:38 oleonard
211 # Moving alternating row colors to the template, adding publicationyear and itemtype variables
213 # Revision 1.5 2004/12/16 11:30:57 tipaul
214 # adding bookshelf features :
215 # * create bookshelf on the fly
216 # * modify a bookshelf name & status
218 # Revision 1.4 2004/12/15 17:28:23 tipaul
219 # adding bookshelf features :
220 # * create bookshelf on the fly
221 # * modify a bookshelf (this being not finished, will commit the rest soon)
223 # Revision 1.3 2004/12/02 16:38:50 tipaul
224 # improvement in book shelves
226 # Revision 1.2 2004/11/19 16:31:30 tipaul
227 # bugfix for bookshelves not in official CVS
229 # Revision 1.1.2.1 2004/03/10 15:08:18 tipaul
230 # modifying shelves : introducing category of shelf : private, public, free for all
232 # Revision 1.13 2004/02/11 08:35:31 tipaul
233 # synch'ing 2.0.0 branch and head
235 # Revision 1.12.2.1 2004/02/06 14:22:19 tipaul
236 # fixing bugs in bookshelves management.
238 # Revision 1.12 2003/02/05 10:04:14 acli
239 # Worked around weirdness with HTML::Template; without the {}, it complains
240 # of being passed an odd number of arguments even though we are not
242 # Revision 1.11 2003/02/05 09:23:03 acli
243 # Fixed a few minor errors to make it run
244 # Noted correct tab size
246 # Revision 1.10 2003/02/02 07:18:37 acli
247 # Moved C4/Charset.pm to C4/Interface/CGI/Output.pm
249 # Create output_html_with_http_headers function to contain the "print $query
250 # ->header(-type => guesstype...),..." call. This is in preparation for
251 # non-HTML output (e.g., text/xml) and charset conversion before output in
254 # Created C4/Interface/CGI/Template.pm to hold convenience functions specific
255 # to the CGI interface using HTML::Template
257 # Modified moremembers.pl to make the "sex" field localizable for languages
258 # where M and F doesn't make sense
260 # Revision 1.9 2002/12/19 18:55:40 hdl
261 # Templating reservereport et shelves.
263 # Revision 1.9 2002/08/14 18:12:51 hdl
266 # Revision 1.8 2002/08/14 18:12:51 tonnesen
267 # Added copyright statement to all .pl and .pm files
269 # Revision 1.7 2002/07/05 05:03:37 tonnesen
270 # Minor changes to authentication routines.
272 # Revision 1.5 2002/07/04 19:42:48 tonnesen
275 # Revision 1.4 2002/07/04 19:21:29 tonnesen
276 # Beginning of authentication api. Applied to shelves.pl for now as a test case.
278 # Revision 1.2.2.1 2002/06/26 20:28:15 tonnesen
279 # Some udpates that I made here locally a while ago. Still won't be useful, but
280 # should be functional