updated release notes for 3.14.0 beta
[koha.git] / serials / serials-search.pl
index ac5d0d3..552500e 100755 (executable)
@@ -46,6 +46,8 @@ my $biblionumber  = $query->param('biblionumber') || '';
 my $branch        = $query->param('branch_filter') || '';
 my $routing       = $query->param('routing') || C4::Context->preference("RoutingSerials");
 my $searched      = $query->param('searched') || 0;
+my @subscriptionids = $query ->param('subscriptionid');
+my $op            = $query->param('op');
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -58,6 +60,16 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
+if ( $op and $op eq "close" ) {
+    for my $subscriptionid ( @subscriptionids ) {
+        C4::Serials::CloseSubscription( $subscriptionid );
+    }
+} elsif ( $op and $op eq "reopen" ) {
+    for my $subscriptionid ( @subscriptionids ) {
+        C4::Serials::ReopenSubscription( $subscriptionid );
+    }
+}
+
 my @subscriptions;
 if ($searched){
     @subscriptions = SearchSubscriptions(
@@ -81,11 +93,22 @@ if ($routing) {
     }
 }
 
+my (@openedsubscriptions, @closedsubscriptions);
+for my $sub ( @subscriptions ) {
+    unless ( $sub->{closed} ) {
+        push @openedsubscriptions, $sub
+            unless $sub->{cannotdisplay};
+    } else {
+        push @closedsubscriptions, $sub
+            unless $sub->{cannotdisplay};
+    }
+}
+
 my $branches = GetBranches();
 my @branches_loop;
 foreach (sort keys %$branches){
     my $selected = 0;
-    $selected = 1 if( $branch eq $_ );
+    $selected = 1 if( defined $branch and $branch eq $_ );
     push @branches_loop, {
         branchcode  => $_,
         branchname  => $branches->{$_}->{'branchname'},
@@ -94,7 +117,9 @@ foreach (sort keys %$branches){
 }
 
 $template->param(
-    subscriptions => \@subscriptions,
+    openedsubscriptions => \@openedsubscriptions,
+    closedsubscriptions => \@closedsubscriptions,
+    total         => @openedsubscriptions + @closedsubscriptions,
     title_filter  => $title,
     ISSN_filter   => $ISSN,
     EAN_filter    => $EAN,