From cae9035cf7f056dc91c89af0af6689a25339b8e2 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 1 Apr 2020 12:46:17 +0000 Subject: [PATCH] Bug 25033: Remove CountSuggestion Signed-off-by: Owen Leonard Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- C4/Suggestions.pm | 56 ------------------------------------ t/db_dependent/Suggestions.t | 12 -------- 2 files changed, 68 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 2b6c0b303a..11cbf96fb7 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -34,7 +34,6 @@ use base qw(Exporter); our @EXPORT = qw( ConnectSuggestionAndBiblio - CountSuggestion DelSuggestion GetSuggestion GetSuggestionByStatus @@ -386,61 +385,6 @@ sub GetSuggestionByStatus { return $results; } -=head2 CountSuggestion - -&CountSuggestion($status) - -Count the number of aqorders with the status given on input argument. -the arg status can be : - -=over 2 - -=item * ASKED : asked by the user, not dealed by the librarian - -=item * ACCEPTED : accepted by the librarian, but not yet ordered - -=item * REJECTED : rejected by the librarian (definitive status) - -=item * ORDERED : ordered by the librarian (acquisition module) - -=back - -return : -the number of suggestion with this status. - -=cut - -sub CountSuggestion { - my ($status) = @_; - my $dbh = C4::Context->dbh; - my $sth; - my $userenv = C4::Context->userenv; - if ( C4::Context->preference("IndependentBranches") - && !C4::Context->IsSuperLibrarian() ) - { - my $query = q{ - SELECT count(*) - FROM suggestions - LEFT JOIN borrowers ON borrowers.borrowernumber=suggestions.suggestedby - WHERE STATUS=? - AND (suggestions.branchcode='' OR suggestions.branchcode=?) - }; - $sth = $dbh->prepare($query); - $sth->execute( $status, $userenv->{branch} ); - } - else { - my $query = q{ - SELECT count(*) - FROM suggestions - WHERE STATUS=? - }; - $sth = $dbh->prepare($query); - $sth->execute($status); - } - my ($result) = $sth->fetchrow; - return $result; -} - =head2 NewSuggestion diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t index 435771ff22..ea8d191839 100644 --- a/t/db_dependent/Suggestions.t +++ b/t/db_dependent/Suggestions.t @@ -159,12 +159,6 @@ my $my_suggestion_without_suggestedby = { quantity => '', # Insert an empty string into int to catch strict SQL modes errors }; -is( CountSuggestion(), 0, 'CountSuggestion without the status returns 0' ); -is( CountSuggestion('ASKED'), 0, 'CountSuggestion returns the correct number of suggestions' ); -is( CountSuggestion('CHECKED'), 0, 'CountSuggestion returns the correct number of suggestions' ); -is( CountSuggestion('ACCEPTED'), 0, 'CountSuggestion returns the correct number of suggestions' ); -is( CountSuggestion('REJECTED'), 0, 'CountSuggestion returns the correct number of suggestions' ); - my $my_suggestionid = NewSuggestion($my_suggestion); isnt( $my_suggestionid, 0, 'NewSuggestion returns an not null id' ); my $my_suggestionid_with_budget = NewSuggestion($my_suggestion_with_budget); @@ -181,9 +175,6 @@ is( $suggestion->{managedby}, undef, 'NewSuggestion stores empty string as undef is( $suggestion->{manageddate}, undef, 'NewSuggestion stores empty string as undef for date' ); is( $suggestion->{budgetid}, undef, 'NewSuggestion should set budgetid to NULL if not given' ); -is( CountSuggestion('ASKED'), 2, 'CountSuggestion returns the correct number of suggestions' ); - - is( ModSuggestion(), undef, 'ModSuggestion without the suggestion returns undef' ); my $mod_suggestion1 = { title => 'my modified title', @@ -239,7 +230,6 @@ $messages = C4::Letters::GetQueuedMessages({ }); is( @$messages, 1, 'ModSuggestion sends an email if the status is updated' ); is ($messages->[0]->{message_transport_type}, 'email', 'When FallbackToSMSIfNoEmail syspref is disabled the suggestion message_transport_type is always email'); -is( CountSuggestion('CHECKED'), 1, 'CountSuggestion returns the correct number of suggestions' ); #Check the message_transport_type when the 'FallbackToSMSIfNoEmail' syspref is enabled and the borrower has a smsalertnumber and no email t::lib::Mocks::mock_preference( 'FallbackToSMSIfNoEmail', 1 ); @@ -413,8 +403,6 @@ my $del_suggestion = { }; my $del_suggestionid = NewSuggestion($del_suggestion); -is( CountSuggestion('CHECKED'), 3, 'CountSuggestion returns the correct number of suggestions' ); - is( DelSuggestion(), '0E0', 'DelSuggestion without arguments returns 0E0' ); is( DelSuggestion($borrowernumber), '', 'DelSuggestion without the suggestion id returns an empty string' ); is( DelSuggestion(undef, $my_suggestionid), '', 'DelSuggestion with an invalid borrower number returns an empty string' ); -- 2.39.5