Template for 135a field plugin
[koha.git] / bookshelves / shelves.pl
index dab9bb2..7d1e519 100755 (executable)
@@ -66,8 +66,27 @@ $template->param({   loggedinuser => $loggedinuser,
                                        headerbackgroundcolor => $headerbackgroundcolor,
                                        circbackgroundcolor => $circbackgroundcolor });
 SWITCH: {
-       if ($query->param('viewshelf')) {  viewshelf($query->param('viewshelf')); last SWITCH;}
-       if ($query->param('shelves')) {  shelves(); last SWITCH;}
+       if ($query->param('op') eq 'modifsave') {
+               ModifShelf($query->param('shelfnumber'),$query->param('shelfname'),$loggedinuser,$query->param('category'));
+               last SWITCH;
+       }
+       if ($query->param('op') eq 'modif') {
+               my ($shelfnumber,$shelfname,$owner,$category) = GetShelf($query->param('shelf'));
+               $template->param(edit => 1,
+                                               shelfnumber => $shelfnumber,
+                                               shelfname => $shelfname,
+                                               "category$category" => 1);
+#              editshelf($query->param('shelf'));
+               last SWITCH;
+       }
+       if ($query->param('viewshelf')) {
+               viewshelf($query->param('viewshelf'));
+               last SWITCH;
+       }
+       if ($query->param('shelves')) {
+               shelves();
+               last SWITCH;
+       }
 }
 
 ($shelflist) = GetShelfList($loggedinuser,2); # rebuild shelflist in case a shelf has been added
@@ -76,19 +95,31 @@ my $color='';
 my @shelvesloop;
 foreach my $element (sort keys %$shelflist) {
                my %line;
-               ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
-               $line{'color'}= $color;
+               ($color eq 1) ? ($color=0) : ($color=1);
+               $line{'toggle'}=$color;
                $line{'shelf'}=$element;
                $line{'shelfname'}=$shelflist->{$element}->{'shelfname'};
+               $line{"category".$shelflist->{$element}->{'category'}} = 1;
+               $line{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
                $line{'shelfbookcount'}=$shelflist->{$element}->{'count'};
                $line{'canmanage'} = ShelfPossibleAction($loggedinuser,$element,'manage');
+               $line{'firstname'}=$shelflist->{$element}->{'firstname'} unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
+               $line{'surname'}=$shelflist->{$element}->{'surname'} unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
 ;
                push (@shelvesloop, \%line);
-}
+               }
 $template->param(shelvesloop => \@shelvesloop);
 
 output_html_with_http_headers $query, $cookie, $template->output;
 
+# sub editshelf {
+#      my ($shelfnumber) = @_;
+#      my ($shelfnumber,$shelfname,$owner,$category) = GetShelf($shelfnumber);
+#      $template->param(edit => 1,
+#                                      shelfnumber => $shelfnumber,
+#                                      shelfname => $shelfname,
+#                                      "category$category" => 1);
+# }
 sub shelves {
        if (my $newshelf=$query->param('addshelf')) {
                my ($status, $string) = AddShelf($env,$newshelf,$query->param('owner'),$query->param('category'));
@@ -116,8 +147,8 @@ sub shelves {
        my @shelvesloop;
        foreach my $element (sort keys %$shelflist) {
                my %line;
-               ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
-               $line{'color'}=$color;
+               ($color eq 1) ? ($color=0) : ($color=1);
+               $line{'toggle'}=$color;
                $line{'shelf'}=$element;
                $line{'shelfname'}=$shelflist->{$element}->{'shelfname'} ;
                $line{'shelfbookcount'}=$shelflist->{$element}->{'count'} ;
@@ -138,12 +169,15 @@ sub viewshelf {
        my @itemsloop;
        foreach $item (sort {$a->{'barcode'} cmp $b->{'barcode'}} @$itemlist) {
                my %line;
-               ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
-               $line{'color'}=$color;
+               ($color eq 1) ? ($color=0) : ($color=1);
+               $line{'toggle'}=$color;
                $line{'itemnumber'}=$item->{'itemnumber'};
                $line{'barcode'}=$item->{'barcode'};
                $line{'title'}=$item->{'title'};
                $line{'author'}=$item->{'author'};
+               $line{'publicationyear'}=$item->{'publicationyear'};
+               $line{'itemtype'}=$item->{'itemtype'};
+               $line{biblionumber} = $item->{biblionumber};
                push(@itemsloop, \%line);
        }
        $template->param(       itemsloop => \@itemsloop,
@@ -156,6 +190,25 @@ sub viewshelf {
 
 #
 # $Log$
+# Revision 1.7  2005/04/27 18:16:19  oleonard
+# Left out some instances in the previous update
+#
+# Revision 1.6  2005/04/27 17:17:41  oleonard
+# Moving alternating row colors to the template, adding publicationyear and itemtype variables
+#
+# Revision 1.5  2004/12/16 11:30:57  tipaul
+# adding bookshelf features :
+# * create bookshelf on the fly
+# * modify a bookshelf name & status
+#
+# Revision 1.4  2004/12/15 17:28:23  tipaul
+# adding bookshelf features :
+# * create bookshelf on the fly
+# * modify a bookshelf (this being not finished, will commit the rest soon)
+#
+# Revision 1.3  2004/12/02 16:38:50  tipaul
+# improvement in book shelves
+#
 # Revision 1.2  2004/11/19 16:31:30  tipaul
 # bugfix for bookshelves not in official CVS
 #