X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=shelves.pl;h=fd06a41504402ef87a12f75fc53a64ef63e7b9f5;hb=e339f5d64ba06180925f551da12fd5a8cdffd444;hp=f7e0ca120b45c40e163ffd32bd5cb5d57bc6a30d;hpb=1e67687742e36bbb90746ecdd78a0c6a63aad890;p=koha_fer diff --git a/shelves.pl b/shelves.pl index f7e0ca120b..fd06a41504 100755 --- a/shelves.pl +++ b/shelves.pl @@ -1,5 +1,6 @@ #!/usr/bin/perl #script to provide bookshelf management +# WARNING: This file uses 4-character tabs! # # $Header$ # @@ -29,22 +30,27 @@ use C4::Output; use C4::BookShelves; use C4::Circulation::Circ2; use C4::Auth; +use C4::Interface::CGI::Output; +use HTML::Template; my $env; my $query = new CGI; -my ($loggedinuser, $cookie, $sessionID) = checkauth($query); -print $query->header(-cookie => $cookie); +#print $query->header(-cookie => $cookie); my $headerbackgroundcolor='#663266'; my $circbackgroundcolor='#555555'; my $circbackgroundcolor='#550000'; my $linecolor1='#bbbbbb'; my $linecolor2='#dddddd'; - -print startpage(); -print startmenu('catalogue'); - - -print "

Logged in as: $loggedinuser [Log Out]

\n"; +my ($template, $loggedinuser, $cookie) + = get_template_and_user({template_name => "shelves.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {parameters => 1}, + }); +#print startpage(); +#print startmenu('catalogue'); +#print "

Logged in as: $loggedinuser [Log Out]

\n"; my ($shelflist) = GetShelfList(); @@ -63,75 +69,65 @@ if ($query->param('modifyshelfcontents')) { } SWITCH: { + $template->param({ loggedinuser => $loggedinuser, + viewshelf => $query->param('viewshelf'), + shelves => $query->param('shelves'), + headerbackgroundcolor => $headerbackgroundcolor, + circbackgroundcolor => $circbackgroundcolor }); if ($query->param('viewshelf')) { viewshelf($query->param('viewshelf')); last SWITCH;} if ($query->param('shelves')) { shelves(); last SWITCH;} - print << "EOF"; -
- - -EOF - my $color=''; - foreach (sort keys %$shelflist) { - ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1); - print "\n"; + my $color=''; + my @shelvesloop; + foreach my $element (sort keys %$shelflist) { + my %line; + ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1); + $line{'color'}= $color; + $line{'shelf'}=$element; + $line{'shelfname'}=$shelflist->{$element}->{'shelfname'}; + $line{'shelfbookcount'}=$shelflist->{$element}->{'count'}; + push (@shelvesloop, \%line); } - print "
- - -
- Shelf List -
-
$shelflist->{$_}->{'shelfname'} ($shelflist->{$_}->{'count'} books)
\n"; - print "

Add or Remove Book Shelves\n"; + $template->param(shelvesloop => \@shelvesloop); } +output_html_with_http_headers $query, $cookie, $template->output; sub shelves { if (my $newshelf=$query->param('addshelf')) { my ($status, $string) = AddShelf($env,$newshelf); if ($status) { - print "$string

\n"; + $template->param(status1 => $status, string1 => $string); } } + my @paramsloop; foreach ($query->param()) { - if (/DEL-(\d+)/) { - my $delshelf=$1; - my ($status, $string) = RemoveShelf($env,$delshelf); - if ($status) { - print "$string

\n"; - } - } + my %line; + if (/DEL-(\d+)/) { + my $delshelf=$1; + my ($status, $string) = RemoveShelf($env,$delshelf); + if ($status) { + $line{'status'}=$status; + $line{'string'} = $string; + } + } + #if the shelf is not deleted, %line points on null + push(@paramsloop,\%line); } + $template->param(paramsloop => \@paramsloop); my ($shelflist) = GetShelfList(); - print << "EOF"; -

-Modify Shelf Contents

-

Bookshelves

- -
-
- - - -EOF - my $color=''; my $color=''; - foreach (sort keys %$shelflist) { - ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1); - print "\n"; + my @shelvesloop; + foreach my $element (sort keys %$shelflist) { + my %line; + ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1); + $line{'color'}=$color; + $line{'shelf'}=$element; + $line{'shelfname'}=$shelflist->{$element}->{'shelfname'} ; + $line{'shelfbookcount'}=$shelflist->{$element}->{'count'} ; + push(@shelvesloop, \%line); } - print "
-Select Shelves to Delete -
$shelflist->{$_}->{'shelfname'} ($shelflist->{$_}->{'count'} books)
\n"; - print '

'; - print "

\n"; - print "\n"; - print "\n"; - print "

Add Shelf:

\n"; - print '

'; - print "\n"; - print "

\n"; + $template->param(shelvesloop=>\@shelvesloop); } @@ -140,53 +136,56 @@ sub viewshelf { my $shelfnumber=shift; my ($itemlist) = GetShelfContents($env, $shelfnumber); my $item=''; - print << "EOF"; -
-
- Shelf List

- - -EOF my $color=''; + my @itemsloop; foreach $item (sort {$a->{'barcode'} cmp $b->{'barcode'}} @$itemlist) { - ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1); - print << "EOF"; - - - - - - - - - -EOF + my %line; + ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1); + $line{'color'}=$color; + $line{'itemnumber'}=$item->{'itemnumber'}; + $line{'barcode'}=$item->{'barcode'}; + $line{'title'}=$item->{'title'}; + $line{'author'}=$item->{'author'}; + push(@itemsloop, \%line); } - print << "EOF"; -
- - -
Add a book by barcode:
-
- - -
- Contents of $shelflist->{$shelfnumber}->{'shelfname'} shelf -
-
{'itemnumber'}>$item->{'barcode'}$item->{'title'}$item->{'author'}
-
- - - - -

-EOF + $template->param( itemsloop => \@itemsloop); + $template->param( shelfname => $shelflist->{$shelfnumber}->{'shelfname'}); + $template->param( shelfnumber => $shelfnumber); } - +#print endpage(); +#print endmenu('catalogue'); # # $Log$ +# Revision 1.12 2003/02/05 10:04:14 acli +# Worked around weirdness with HTML::Template; without the {}, it complains +# of being passed an odd number of arguments even though we are not +# +# Revision 1.11 2003/02/05 09:23:03 acli +# Fixed a few minor errors to make it run +# Noted correct tab size +# +# Revision 1.10 2003/02/02 07:18:37 acli +# Moved C4/Charset.pm to C4/Interface/CGI/Output.pm +# +# Create output_html_with_http_headers function to contain the "print $query +# ->header(-type => guesstype...),..." call. This is in preparation for +# non-HTML output (e.g., text/xml) and charset conversion before output in +# the future. +# +# Created C4/Interface/CGI/Template.pm to hold convenience functions specific +# to the CGI interface using HTML::Template +# +# Modified moremembers.pl to make the "sex" field localizable for languages +# where M and F doesn't make sense +# +# Revision 1.9 2002/12/19 18:55:40 hdl +# Templating reservereport et shelves. +# +# Revision 1.9 2002/08/14 18:12:51 hdl +# Templating files +# # Revision 1.8 2002/08/14 18:12:51 tonnesen # Added copyright statement to all .pl and .pm files # @@ -208,5 +207,7 @@ EOF -print endpage(); -print endmenu('catalogue'); + +# Local Variables: +# tab-width: 4 +# End: