X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=suggestion%2Fsuggestion.pl;h=046e347d1437ade834494f47b727bd893320be73;hb=a063067b91f3d08e7e58fdc9d059fcaee4ab4225;hp=b4f4d37a7ed64f252f1dccc649e28aa973e97a60;hpb=fe487576683a804c5d2ee901d62b9f1172cb1454;p=srvgit diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index b4f4d37a7e..046e347d14 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,7 +59,13 @@ sub Init{ sub GetCriteriumDesc{ my ($criteriumvalue,$displayby)=@_; - return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))) if ($displayby =~/status/i); + if ($displayby =~ /status/i) { + if ( grep { /^($criteriumvalue)$/ } qw(ASKED ACCEPTED REJECTED CHECKED ORDERED AVAILABLE) ) { + return ($criteriumvalue eq 'ASKED'?"Pending":ucfirst(lc( $criteriumvalue))); + } else { + return GetAuthorisedValueByCode('SUGGEST_STATUS', $criteriumvalue) || $criteriumvalue; + } + } return (GetBranchName($criteriumvalue)) if ($displayby =~/branchcode/); return (GetSupportName($criteriumvalue)) if ($displayby =~/itemtype/); if ($displayby =~/suggestedby/||$displayby =~/managedby/||$displayby =~/acceptedby/){ @@ -74,6 +81,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'); @@ -93,18 +101,21 @@ foreach (keys %$suggestion_ref){ } my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user( { - template_name => "suggestion/suggestion.tmpl", + template_name => "suggestion/suggestion.tt", query => $input, type => "intranet", flagsrequired => { catalogue => 1 }, } ); +$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}; @@ -119,7 +130,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 @@ -129,6 +140,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 @@ -151,26 +167,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' ); @@ -268,7 +297,7 @@ $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"); } #################### @@ -276,10 +305,11 @@ if(defined($returnsuggested) and $returnsuggested ne "noone") #branch display management my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : ''; -my $onlymine=C4::Context->preference('IndependantBranches') && - C4::Context->userenv && - C4::Context->userenv->{flags}!=1 && - C4::Context->userenv->{branch}; +my $onlymine = + C4::Context->preference('IndependentBranches') + && C4::Context->userenv + && !C4::Context->IsSuperLibrarian() + && C4::Context->userenv->{branch}; my $branches = GetBranches($onlymine); my @branchloop; @@ -356,15 +386,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 +410,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') // undef), + SuggestionStatuses => GetAuthorisedValues('SUGGEST_STATUS'), +); output_html_with_http_headers $input, $cookie, $template->output;