4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
27 this script is used to script to provide bookshelf management
33 =item C<modifyshelfcontents>
35 if this script has to modify the shelve content.
39 to know on which shelve this script has to work.
46 * modifsave to save change on the shelves
47 * modif to change the template to allow to modify the shelves.
51 to load the template with 'viewshelves param' which allow to read the shelves information.
55 if equals to 1. then call the function shelves which add
60 if the param shelves = 1 then addshelf must be equals to the name of the shelf to add.
75 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
77 template_name => "bookshelves/shelves.tmpl",
81 flagsrequired => { catalogue => 1 },
85 if ( $query->param('modifyshelfcontents') ) {
86 my $shelfnumber = $query->param('viewshelf');
87 my $barcode = $query->param('addbarcode');
88 my ($item) = GetItem( 0, $barcode );
89 if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ) ) {
90 AddToShelf( $item->{'itemnumber'}, $shelfnumber );
91 foreach ( $query->param ) {
94 DelFromShelf( $itemnumber, $shelfnumber );
100 # getting the Shelves list
101 my $shelflist = GetShelves( $loggedinuser, 2 );
102 $template->param( { loggedinuser => $loggedinuser } );
103 my $op = $query->param('op');
106 if ( $op && ( $op eq 'modifsave' ) ) {
108 $query->param('shelfnumber'), $query->param('shelfname'),
109 $loggedinuser, $query->param('category')
113 if ( $op && ( $op eq 'modif' ) ) {
114 my ( $shelfnumber, $shelfname, $owner, $category ) =
115 GetShelf( $query->param('shelf') );
118 shelfnumber => $shelfnumber,
119 shelfname => $shelfname,
120 "category$category" => 1
123 # editshelf($query->param('shelf'));
126 if ( $query->param('viewshelf') ) {
127 #check that the user can view the shelf
128 my $shelfnumber = $query->param('viewshelf');
129 if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
130 my $items = GetShelfContents($shelfnumber);
132 shelfname => $shelflist->{$shelfnumber}->{'shelfname'},
133 shelfnumber => $shelfnumber,
134 viewshelf => $query->param('viewshelf'),
135 manageshelf => &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ),
141 if ( $query->param('shelves') ) {
142 if ( my $newshelf = $query->param('addshelf') ) {
143 my $shelfnumber = AddShelf(
145 $query->param('owner'),
146 $query->param('category')
149 if ( $shelfnumber == -1 ) { #shelf already exists.
152 shelfnumber => $shelfnumber,
159 foreach ( $query->param() ) {
163 my ( $status, $count ) = DelShelf($delshelf);
165 $line{'status'} = $status;
166 $line{'count'} = $count;
170 #if the shelf is not deleted, %line points on null
171 push( @paramsloop, \%line );
173 $template->param( paramsloop => \@paramsloop );
174 my ($shelflist) = GetShelves( $loggedinuser, 2 );
177 foreach my $element ( sort keys %$shelflist ) {
179 ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
180 $line{'toggle'} = $color;
181 $line{'shelf'} = $element;
182 $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
183 $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
184 push( @shelvesloop, \%line );
187 shelvesloop => \@shelvesloop,
195 GetShelves( $loggedinuser, 2 )
196 ; # rebuild shelflist in case a shelf has been added
200 my $numberCanManage = 0;
202 foreach my $element ( sort keys %$shelflist ) {
204 ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
205 $line{'toggle'} = $color;
206 $line{'shelf'} = $element;
207 $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
208 $line{ "category" . $shelflist->{$element}->{'category'} } = 1;
209 $line{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
210 $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
211 $line{'canmanage'} = ShelfPossibleAction( $loggedinuser, $element, 'manage' );
212 $line{'firstname'} = $shelflist->{$element}->{'firstname'}
213 unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
214 $line{'surname'} = $shelflist->{$element}->{'surname'}
215 unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
217 $numberCanManage++ if $line{'canmanage'};
219 push( @shelvesloop, \%line );
223 shelvesloop => \@shelvesloop,
224 numberCanManage => $numberCanManage,
227 output_html_with_http_headers $query, $cookie, $template->output;
230 my $innertemplate = shift;
231 if ( my $newshelf = $query->param('addshelf') ) {
232 my $shelfnumber = AddShelf(
234 $query->param('owner'),
235 $query->param('category')
238 if ( $shelfnumber == -1 ) { #shelf already exists.
241 shelfnumber => $shelfnumber,
248 foreach ( $query->param() ) {
252 my ( $status, $count ) = DelShelf($delshelf);
254 $line{'status'} = $status;
255 $line{'count'} = $count;
259 #if the shelf is not deleted, %line points on null
260 push( @paramsloop, \%line );
262 $innertemplate->param( paramsloop => \@paramsloop );
263 my ($shelflist) = GetShelves( $loggedinuser, 2 );
266 foreach my $element ( sort keys %$shelflist ) {
268 ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
269 $line{'toggle'} = $color;
270 $line{'shelf'} = $element;
271 $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
272 $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
273 push( @shelvesloop, \%line );
275 $innertemplate->param(
276 shelvesloop => \@shelvesloop,
283 # Revision 1.13 2007/04/24 13:54:29 hdl
284 # functions that were in C4::Interface::CGI::Output are now in C4::Output.
285 # So this implies quite a change for files.
286 # Sorry about conflicts which will be caused.
287 # directory Interface::CGI should now be dropped.
288 # I noticed that many scripts (reports ones, but also some circ/stats.pl or opac-topissues) still use Date::Manip.
290 # Revision 1.12 2007/04/04 16:46:22 tipaul
291 # HUGE COMMIT : code cleaning circulation.
293 # some stuff to do, i'll write a mail on koha-devel NOW !
295 # Revision 1.11 2007/03/09 14:32:26 tipaul
296 # rel_3_0 moved to HEAD
298 # Revision 1.9.2.9 2007/02/05 15:54:30 toins
299 # don't display "remove selected shelves" if the user logged has no shelf.
301 # Revision 1.9.2.8 2006/12/15 17:36:57 toins
302 # - some change on the html param.
303 # - Writing directly the code of a sub called only once.
304 # - adding syspref: BiblioDefaultView.
306 # Revision 1.9.2.7 2006/12/14 17:22:55 toins
307 # bookshelves work perfectly with mod_perl and are cleaned.
309 # Revision 1.9.2.6 2006/12/13 10:06:05 toins
310 # fix a mod_perl specific bug.
312 # Revision 1.9.2.5 2006/12/11 17:10:06 toins
313 # fixing some bugs on bookshelves.
315 # Revision 1.9.2.4 2006/11/30 18:23:51 toins
316 # theses scripts don't need to use C4::Search.
318 # Revision 1.9.2.3 2006/10/30 09:50:45 tipaul
319 # better perl writting
321 # Revision 1.9.2.2 2006/10/17 07:59:35 toins