X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=suggestion%2Fsuggestion.pl;h=c0327ad3314e6a48dcbf2edacd069f0c35593b3a;hb=1d276d58099fa60666bccc13c7b9d839946946c1;hp=717d5dfd6b40d1082378bcb3b7a9b5f98e2324fe;hpb=5167c32060609a08e73413986f94994bb10c3e9a;p=koha_fer diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 717d5dfd6b..c0327ad331 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/); @@ -74,6 +77,7 @@ sub GetCriteriumDesc{ } my $input = CGI->new; +my $redirect = $input->param('redirect'); my $suggestedbyme = (defined $input->param('suggestedbyme')? $input->param('suggestedbyme'):1); my $op = $input->param('op')||'else'; my @editsuggestions = $input->param('edit_field'); @@ -82,7 +86,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. @@ -101,11 +104,14 @@ my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user( } ); +$borrowernumber = $input->param('borrowernumber') if ( $input->param('borrowernumber') ); +$template->param('borrowernumber' => $borrowernumber); + ######################################### ## Operations ## if ( $op =~ /save/i ) { - if ( $$suggestion_ref{"STATUS"} ) { + if ( $$suggestion_ref{"STATUS"} ) { if ( my $tmpstatus = lc( $$suggestion_ref{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) { $$suggestion_ref{ lc( $$suggestion_ref{"STATUS"}) . "date" } = C4::Dates->today; $$suggestion_ref{ lc( $$suggestion_ref{"STATUS"}) . "by" } = C4::Context->userenv->{number}; @@ -120,7 +126,7 @@ if ( $op =~ /save/i ) { my $suggestions_loop = SearchSuggestion( $suggestion_ref ); if (@$suggestions_loop>=1){ - #some suggestion are answering the request Donot Add + #some suggestion are answering the request Donot Add } else { ## Adding some informations related to suggestion @@ -130,6 +136,11 @@ if ( $op =~ /save/i ) { } map{delete $$suggestion_ref{$_}} keys %$suggestion_ref; $op = 'else'; + + if( $redirect eq 'purchase_suggestions' ) { + print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber"); + } + } elsif ($op=~/add/) { #Adds suggestion @@ -152,20 +163,20 @@ elsif ($op eq "change" ) { $$suggestion_ref{"rejecteddate"}=C4::Dates->today; $$suggestion_ref{"rejectedby"}=C4::Context->userenv->{number}; } - if ($$suggestion_ref{"STATUS"}){ - $$suggestion_ref{"manageddate"}=C4::Dates->today; - $$suggestion_ref{"managedby"}=C4::Context->userenv->{number}; - } - if ( my $reason = $$suggestion_ref{"reason$tabcode"}){ - if ( $reason eq "other" ) { - $reason = $$suggestion_ref{"other_reason$tabcode"}; - } - $$suggestion_ref{'reason'}=$reason; - } - delete $$suggestion_ref{$_} foreach ("reason$tabcode", "other_reason$tabcode"); - foreach (keys %$suggestion_ref){ - delete $$suggestion_ref{$_} unless ($$suggestion_ref{$_}); - } + if ($$suggestion_ref{"STATUS"}){ + $$suggestion_ref{"manageddate"}=C4::Dates->today; + $$suggestion_ref{"managedby"}=C4::Context->userenv->{number}; + } + if ( my $reason = $$suggestion_ref{"reason$tabcode"}){ + if ( $reason eq "other" ) { + $reason = $$suggestion_ref{"other_reason$tabcode"}; + } + $$suggestion_ref{'reason'}=$reason; + } + delete $$suggestion_ref{$_} foreach ("reason$tabcode", "other_reason$tabcode"); + foreach (keys %$suggestion_ref){ + delete $$suggestion_ref{$_} unless ($$suggestion_ref{$_}); + } foreach my $suggestionid (@editsuggestions) { next unless $suggestionid; $$suggestion_ref{'suggestionid'}=$suggestionid; @@ -207,7 +218,7 @@ if ($op=~/else/) { my $reasonsloop = GetAuthorisedValues("SUGGEST"); 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 ""; @@ -264,23 +275,24 @@ foreach my $element ( qw(managedby suggestedby acceptedby) ) { $template->param( %$suggestion_ref, "op_$op" => 1, - dateformat => C4::Context->preference("dateformat"), "op" =>$op, ); if(defined($returnsuggested) and $returnsuggested ne "noone") { - print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=".$returnsuggested."#suggestions"); + print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=".$returnsuggested."#suggestions"); } #################### ## Initializing selection lists #branch display management -my $onlymine=C4::Context->preference('IndependantBranches') && - C4::Context->userenv && - C4::Context->userenv->{flags}!=1 && - C4::Context->userenv->{branch}; +my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : ''; +my $onlymine = + C4::Context->preference('IndependentBranches') + && C4::Context->userenv + && !C4::Context->IsSuperLibrarian() + && C4::Context->userenv->{branch}; my $branches = GetBranches($onlymine); my @branchloop; @@ -357,15 +369,13 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { my %line; $line{currcode} = $rates[$i]->{'currency'}; $line{rate} = $rates[$i]->{'rate'}; - $line{selected} = 1 if ($line{'currcode'} eq $selected_currency); + $line{selected} = 1 if ($line{'currcode'} eq $selected_currency); push @loop_currency, \%line; } - -$template->param(loop_currency => \@loop_currency); - $template->param( - price => sprintf("%.2f", $$suggestion_ref{'price'}||0), - total => sprintf("%.2f", $$suggestion_ref{'total'}||0), + loop_currency => \@loop_currency, + price => sprintf("%.2f", $$suggestion_ref{'price'}||0), + total => sprintf("%.2f", $$suggestion_ref{'total'}||0), ); # lists of distinct values (without empty) for filters @@ -383,6 +393,10 @@ foreach my $field ( qw(managedby acceptedby suggestedby budgetid) ) { } @$values_list; $hashlists{ lc($field) . "_loop" } = \@codes_list; } -$template->param(%hashlists); -$template->param(DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),); + +$template->param( + %hashlists, + borrowernumber => $input->param('borrowernumber'), + SuggestionStatuses => GetAuthorisedValues('SUGGEST_STATUS'), +); output_html_with_http_headers $input, $cookie, $template->output;