installer (part 1): started major changes
[koha_fer] / opac / opac-shelves.pl
index 683610c..f62c29c 100755 (executable)
@@ -17,7 +17,6 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id$
 
 =head1 NAME
 
@@ -102,6 +101,14 @@ if ( $query->param('modifyshelfcontents') ) {
     }
 }
 
+       # set the default tab, etc.
+       my $shelf_type = $query->param('display');
+       if ((!$shelf_type) || ($shelf_type eq 'privateshelves'))  {
+               $template->param(showprivateshelves => 1);
+       } elsif ($shelf_type eq 'publicshelves') {
+               $template->param(showpublicshelves => 1);
+       }
+
 # getting the Shelves list
 my $shelflist = GetShelves( $loggedinuser, 2 );
 $template->param( { loggedinuser => $loggedinuser } );
@@ -111,18 +118,19 @@ SWITCH: {
     if ( $op && ( $op eq 'modifsave' ) ) {
         ModShelf(
             $query->param('shelfnumber'), $query->param('shelfname'),
-            $loggedinuser,                $query->param('category')
+            $loggedinuser,                $query->param('category'), $query->param('sortfield')
         );
         last SWITCH;
     }
     if ( $op && ( $op eq 'modif' ) ) {
-        my ( $shelfnumber, $shelfname, $owner, $category ) =
+        my ( $shelfnumber, $shelfname, $owner, $category, $sortfield ) =
           GetShelf( $query->param('shelf') );
         $template->param(
             edit                => 1,
             shelfnumber         => $shelfnumber,
             shelfname           => $shelfname,
-            "category$category" => 1
+            "category$category" => 1,
+                       "sort_$sortfield"       => 1,
         );
 
         #         editshelf($query->param('shelf'));
@@ -133,7 +141,7 @@ SWITCH: {
         my $shelfnumber = $query->param('viewshelf');
         if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
             my $items = GetShelfContents($shelfnumber);
-            $template->param(
+                       $template->param(
                 shelfname   => $shelflist->{$shelfnumber}->{'shelfname'},
                 shelfnumber => $shelfnumber,
                 viewshelf   => $query->param('viewshelf'),
@@ -196,31 +204,46 @@ SWITCH: {
     }
 }
 
-($shelflist) =
-  GetShelves( $loggedinuser, 2 )
-  ;    # rebuild shelflist in case a shelf has been added
+# rebuild shelflist in case a shelf has been added
+($shelflist) = GetShelves( $loggedinuser, 2 ) ;    
 
-my $color = '';
+my $color='';
 my @shelvesloop;
-foreach my $element ( sort keys %$shelflist ) {
-    my %line;
-    ( $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{'shelfvirtualcount'} = $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 );
-    }
+my @shelveslooppriv;
+foreach my $element (sort { lc($shelflist->{$a}->{'shelfname'}) cmp lc($shelflist->{$b}->{'shelfname'}) } keys %$shelflist) {
+               my %line;
+               my %linepriv;
+               ($color eq 0) ? ($color=1) : ($color=0);
+               if ($shelflist->{$element}->{'category'} eq 2) {
+               $line{'color'}= $color;
+               $line{'shelf'}=$element;
+               $line{'shelfname'}=$shelflist->{$element}->{'shelfname'};
+               $line{'sortfield'}=$shelflist->{$element}->{'sortfield'};
+               $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);
+               } elsif ($shelflist->{$element}->{'category'} eq 1) {
+               $linepriv{'color'}= $color;
+                $linepriv{'shelf'}=$element;
+                $linepriv{'shelfname'}=$shelflist->{$element}->{'shelfname'};
+                               $linepriv{'sortfield'}=$shelflist->{$element}->{'sortfield'};
+                $linepriv{"category".$shelflist->{$element}->{'category'}} = 1;
+                $linepriv{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
+                $linepriv{'shelfbookcount'}=$shelflist->{$element}->{'count'};
+                $linepriv{'canmanage'} = ShelfPossibleAction($loggedinuser,$element,'manage');
+                $linepriv{'firstname'}=$shelflist->{$element}->{'firstname'} unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
+                $linepriv{'surname'}=$shelflist->{$element}->{'surname'} unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
+               push (@shelveslooppriv, \%linepriv);
+               }
+}
 
 $template->param(
+       shelveslooppriv => \@shelveslooppriv,
     shelvesloop             => \@shelvesloop,
     "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
 );
@@ -230,7 +253,6 @@ output_html_with_http_headers $query, $cookie, $template->output;
 
 
 #
-# $Log$
 # Revision 1.12  2007/04/24 13:54:29  hdl
 # functions that were in C4::Interface::CGI::Output are now in C4::Output.
 # So this implies quite a change for files.