X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=suggestion%2Fsuggestion.pl;h=fd9a9c2a3df0fa77f4f5fe62ae5e2bb852932fbe;hb=e36db6c247e9b4a30ba3a1ddde9c31ebb4090e7f;hp=6bf188f365e65b9cd13e010068c058906c91fc14;hpb=612b12f41ba59a6508fcbf306be66455a6f0012b;p=koha.git diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 6bf188f365..fd9a9c2a3d 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -58,6 +58,9 @@ sub Init{ sub GetCriteriumDesc{ my ($criteriumvalue,$displayby)=@_; + unless ( grep { /$criteriumvalue/ } qw(ASKED ACCEPTED REJECTED CHECKED) ) { + return GetAuthorisedValueByCode('SUGGEST_STATUS', $criteriumvalue ) || "Unknown"; + } return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))) if ($displayby =~/status/i); return (GetBranchName($criteriumvalue)) if ($displayby =~/branchcode/); return (GetSupportName($criteriumvalue)) if ($displayby =~/itemtype/); @@ -82,7 +85,6 @@ my $returnsuggestedby = $input->param('returnsuggestedby'); my $returnsuggested = $input->param('returnsuggested'); my $managedby = $input->param('managedby'); my $displayby = $input->param('displayby') || ''; -my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : ''; my $tabcode = $input->param('tabcode'); # filter informations which are not suggestion related. @@ -190,12 +192,24 @@ if ($op=~/else/) { $displayby||="STATUS"; delete $$suggestion_ref{'branchcode'} if($displayby eq "branchcode"); + # distinct values of display by my $criteria_list=GetDistinctValues("suggestions.".$displayby); + my (@criteria_dv, $criteria_has_empty); + foreach (@$criteria_list) { + if ($_->{value}) { + push @criteria_dv, $_->{value}; + } else { + $criteria_has_empty = 1; + } + } + # agregate null and empty values under empty value + push @criteria_dv, '' if $criteria_has_empty; + my @allsuggestions; my $reasonsloop = GetAuthorisedValues("SUGGEST"); - foreach my $criteriumvalue ( map { $$_{'value'} } @$criteria_list ) { + foreach my $criteriumvalue ( @criteria_dv ) { # By default, display suggestions from current working branch - if(not defined $branchfilter) { + unless ( exists $$suggestion_ref{'branchcode'} ) { $$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; } my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne ""; @@ -209,20 +223,13 @@ if ($op=~/else/) { my $bud = GetBudget( $suggestion->{budgetid} ); $suggestion->{budget_name} = $bud->{budget_name} if $bud; } - foreach my $date qw(suggesteddate manageddate accepteddate) { - if ($suggestion->{$date} and $suggestion->{$date} ne "0000-00-00" && $suggestion->{$date} ne "" ) { + foreach my $date (qw(suggesteddate manageddate accepteddate)) { + if ($suggestion->{$date} and $suggestion->{$date} ne "0000-00-00") { $suggestion->{$date} = format_date( $suggestion->{$date} ); } else { $suggestion->{$date} = ""; } } - foreach my $date ( qw(suggesteddate manageddate accepteddate) ){ - if ($suggestion->{$date} ne "0000-00-00" && $suggestion->{$date} ne "" ){ - $suggestion->{$date}=format_date($suggestion->{$date}) ; - } else { - $suggestion->{$date}="" ; - } - } } push @allsuggestions,{ "suggestiontype"=>$criteriumvalue||"suggest", @@ -259,7 +266,6 @@ foreach my $element ( qw(managedby suggestedby acceptedby) ) { $template->param( %$suggestion_ref, "op_$op" => 1, - dateformat => C4::Context->preference("dateformat"), "op" =>$op, ); @@ -272,7 +278,8 @@ if(defined($returnsuggested) and $returnsuggested ne "noone") ## Initializing selection lists #branch display management -my $onlymine=C4::Context->preference('IndependantBranches') && +my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : ''; +my $onlymine=C4::Context->preference('IndependentBranches') && C4::Context->userenv && C4::Context->userenv->{flags}!=1 && C4::Context->userenv->{branch}; @@ -363,18 +370,23 @@ $template->param( total => sprintf("%.2f", $$suggestion_ref{'total'}||0), ); +# lists of distinct values (without empty) for filters my %hashlists; foreach my $field ( qw(managedby acceptedby suggestedby budgetid) ) { my $values_list; $values_list = GetDistinctValues( "suggestions." . $field ); my @codes_list = map { { 'code' => $$_{'value'}, - 'desc' => GetCriteriumDesc( $$_{'value'}, $field ), + 'desc' => GetCriteriumDesc( $$_{'value'}, $field ) || $$_{'value'}, 'selected' => ($$suggestion_ref{$field}) ? $$_{'value'} eq $$suggestion_ref{$field} : 0, } + } grep { + $$_{'value'} } @$values_list; $hashlists{ lc($field) . "_loop" } = \@codes_list; } $template->param(%hashlists); -$template->param(DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),); +$template->param( + SuggestionStatuses => GetAuthorisedValues('SUGGEST_STATUS'), +); output_html_with_http_headers $input, $cookie, $template->output;