X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;ds=sidebyside;f=suggestion%2Fsuggestion.pl;h=949cca30ffe13ba34d6ff650b777717b61a1aae2;hb=2b8b5ae225af6119e41e2112f9a8573b4170b927;hp=7fa301e99e6436d05317737d2ce543417c0f5a7e;hpb=a469663d7b0993894582759235c2475f662c8da4;p=koha_fer diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 7fa301e99e..949cca30ff 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -31,6 +31,7 @@ use C4::Search; use C4::Dates qw(format_date); use C4::Members; use C4::Debug; +use URI::Escape; sub Init{ my $suggestion= shift @_; @@ -58,6 +59,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 +78,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 +87,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 +105,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 +127,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 +137,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,26 +164,39 @@ 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; &ModSuggestion($suggestion_ref); } - $op = 'else'; + my $params = ''; + foreach my $key ( + qw( + displayby branchcode title author isbn publishercode copyrightdate + collectiontitle suggestedby suggesteddate_from suggesteddate_to + manageddate_from manageddate_to accepteddate_from + accepteddate_to budgetid + ) + ) + { + $params .= $key . '=' . uri_escape($input->param($key)) . '&' + if defined($input->param($key)); + } + print $input->redirect("/cgi-bin/koha/suggestion/suggestion.pl?$params"); }elsif ($op eq "delete" ) { foreach my $delete_field (@editsuggestions) { &DelSuggestion( $borrowernumber, $delete_field,'intranet' ); @@ -207,7 +232,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 ""; @@ -269,17 +294,19 @@ $template->param( 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; @@ -356,15 +383,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 @@ -382,5 +407,10 @@ foreach my $field ( qw(managedby acceptedby suggestedby budgetid) ) { } @$values_list; $hashlists{ lc($field) . "_loop" } = \@codes_list; } -$template->param(%hashlists); + +$template->param( + %hashlists, + borrowernumber => $input->param('borrowernumber'), + SuggestionStatuses => GetAuthorisedValues('SUGGEST_STATUS'), +); output_html_with_http_headers $input, $cookie, $template->output;