MT 1975 : Adding records to a list, corrected pop-up height
[koha_fer] / suggestion / acceptorreject.pl
index 5100334..d4615a1 100755 (executable)
@@ -65,6 +65,7 @@ op can be :
 =cut
 
 use strict;
+use warnings;
 
 use CGI;
 
@@ -105,7 +106,7 @@ my $suggestions;
 my $branchcode;
 my $userenv = C4::Context->userenv;
 if ($userenv) {
-    unless ($userenv->{flags} == 1){
+    unless ($userenv->{flags} % 2 == 1){
         $branchcode=$userenv->{branch};
     }
 }
@@ -139,12 +140,11 @@ if ( $op eq "aorr_confirm" ) {
     $op = "else";
     if (scalar(@deletelist)>0){  
         my $params = "&delete_field=".join ("&delete_field=",@deletelist);
-        warn $params;    
         print $input->redirect("/cgi-bin/koha/suggestion/acceptorreject.pl?op=delete_confirm$params");
+        exit;
     }  
 }
-
-if ( $op eq "delete_confirm" ) {
+elsif ( $op eq "delete_confirm" ) {
     my @delete_field = $input->param("delete_field");
     foreach my $delete_field (@delete_field) {
         &DelSuggestion( $loggedinuser, $delete_field,"intranet" );
@@ -153,28 +153,57 @@ if ( $op eq "delete_confirm" ) {
 }
 
 my $reasonsloop = GetAuthorisedValues("SUGGEST");
-my $pending_suggestions = &SearchSuggestion( "", "", "", "", 'ASKED', "",$branchcode );
-map{$_->{'reasonsloop'}=$reasonsloop;$_->{'date'}=format_date($_->{'date'})} @$pending_suggestions;
-my $accepted_suggestions = &GetSuggestionByStatus('ACCEPTED',$branchcode);
-map{$_->{'reasonsloop'}=$reasonsloop;$_->{'date'}=format_date($_->{'date'})} @$accepted_suggestions;
-my $rejected_suggestions = &GetSuggestionByStatus('REJECTED',$branchcode);
-map{$_->{'reasonsloop'}=$reasonsloop;$_->{'date'}=format_date($_->{'date'})} @$rejected_suggestions;
+my $pending_suggestions = &SearchSuggestion("", "", "", "", 'ASKED', "", $branchcode);
+map { $_->{'reasonsloop'} = $reasonsloop; $_->{'date'} = format_date($_->{'date'}) } @$pending_suggestions;
+my $accepted_suggestions = &GetSuggestionByStatus('ACCEPTED', $branchcode);
+map { $_->{'reasonsloop'} = $reasonsloop; $_->{'date'} = format_date($_->{'date'}) } @$accepted_suggestions;
+my $rejected_suggestions = &GetSuggestionByStatus('REJECTED', $branchcode);
+map { $_->{'reasonsloop'} = $reasonsloop; $_->{'date'} = format_date($_->{'date'}) } @$rejected_suggestions;
+
+# FIXME: BAD use of map in VOID context.
 
 my @allsuggestions;
-push @allsuggestions,{"suggestiontype"=>"accepted",
-                    'suggestions_loop'=>$accepted_suggestions,    
-                    'reasonsloop' => $reasonsloop};
-push @allsuggestions,{"suggestiontype"=>"pending",
-                     'suggestions_loop'=>$pending_suggestions,
-                    'reasonsloop' => $reasonsloop};
-push @allsuggestions,{"suggestiontype"=>"rejected",
-                     'suggestions_loop'=>$rejected_suggestions,
-                    'reasonsloop' => $reasonsloop};
+push @allsuggestions,
+  { "suggestiontype"   => "accepted",
+    'suggestions_loop' => $accepted_suggestions,
+    'reasonsloop'      => $reasonsloop
+  };
+push @allsuggestions,
+  { "suggestiontype"   => "pending",
+    'suggestions_loop' => $pending_suggestions,
+    'reasonsloop'      => $reasonsloop
+  };
+push @allsuggestions,
+  { "suggestiontype"   => "rejected",
+    'suggestions_loop' => $rejected_suggestions,
+    'reasonsloop'      => $reasonsloop
+  };
+
+$template->param(
+    suggestions => \@allsuggestions,
+    "op_$op"    => 1,
+    dateformat  => C4::Context->preference("dateformat"),
+);
 
+output_html_with_http_headers $input, $cookie, $template->output;
+my @allsuggestions;
+foreach my $status ('ASKED','CHECKED','REJECTED','ACCEPTED'){
+    my $suggestions = &GetSuggestionByStatus( $status, $branchcode );
+    map{
+        $_->{$status}=1 unless ($status eq 'ASKED' ||$status eq 'PENDING');
+        $_->{'reasonsloop'}=$reasonsloop;
+        $_->{'suggestioncreatedon'}=format_date($_->{'suggestioncreatedon'})
+        } @$suggestions;
+    
+    push @allsuggestions,{"suggestiontype"=>($status eq 'ASKED'?"pending":lc $status),
+                        'suggestions_loop'=>$suggestions,
+                        'reasonsloop' => $reasonsloop};
+}
+>>>>>>> suggestions changes (probably useless):suggestion/acceptorreject.pl
 $template->param(
-    suggestions       => \@allsuggestions,
-    "op_$op"                => 1,
-    dateformat    => C4::Context->preference("dateformat"),
+    suggestions => \@allsuggestions,
+    "op_$op"    => 1,
+    dateformat  => C4::Context->preference("dateformat"),
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;