Bug 25033: Remove CountSuggestion
Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
b73bf7374c
commit
cae9035cf7
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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' );
|
||||
|
|
|
|||
Loading…
Reference in New Issue