View | Details | Raw Unified | Return to bug 28844
Collapse All | Expand All

(-)a/C4/Suggestions.pm (-28 lines)
Lines 36-42 our @EXPORT = qw( Link Here
36
  GetSuggestion
36
  GetSuggestion
37
  GetSuggestionByStatus
37
  GetSuggestionByStatus
38
  GetSuggestionFromBiblionumber
38
  GetSuggestionFromBiblionumber
39
  GetSuggestionInfoFromBiblionumber
40
  GetSuggestionInfo
39
  GetSuggestionInfo
41
  ModStatus
40
  ModStatus
42
  ModSuggestion
41
  ModSuggestion
Lines 119-151 sub GetSuggestionFromBiblionumber { Link Here
119
    return $suggestionid;
118
    return $suggestionid;
120
}
119
}
121
120
122
=head2 GetSuggestionInfoFromBiblionumber
123
124
Get a suggestion and borrower's informations from it's biblionumber.
125
126
return :
127
all informations (suggestion and borrower) of the suggestion which is related to the biblionumber given.
128
129
=cut
130
131
sub GetSuggestionInfoFromBiblionumber {
132
    my ($biblionumber) = @_;
133
    my $query = q{
134
        SELECT suggestions.*,
135
            U1.surname          AS surnamesuggestedby,
136
            U1.firstname        AS firstnamesuggestedby,
137
            U1.borrowernumber   AS borrnumsuggestedby
138
        FROM suggestions
139
            LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
140
        WHERE biblionumber=?
141
        LIMIT 1
142
    };
143
    my $dbh = C4::Context->dbh;
144
    my $sth = $dbh->prepare($query);
145
    $sth->execute($biblionumber);
146
    return $sth->fetchrow_hashref;
147
}
148
149
=head2 GetSuggestionInfo
121
=head2 GetSuggestionInfo
150
122
151
Get a suggestion and borrower's informations from it's suggestionid
123
Get a suggestion and borrower's informations from it's suggestionid
(-)a/t/db_dependent/Suggestions.t (-18 / +2 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use DateTime::Duration;
20
use DateTime::Duration;
21
use Test::More tests => 91;
21
use Test::More tests => 79;
22
use Test::Warn;
22
use Test::Warn;
23
23
24
use t::lib::Mocks;
24
use t::lib::Mocks;
Lines 34-40 use Koha::Patrons; Link Here
34
use Koha::Suggestions;
34
use Koha::Suggestions;
35
35
36
BEGIN {
36
BEGIN {
37
    use_ok('C4::Suggestions', qw( GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
37
    use_ok('C4::Suggestions', qw( GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
38
}
38
}
39
39
40
my $schema  = Koha::Database->new->schema;
40
my $schema  = Koha::Database->new->schema;
Lines 292-312 is( GetSuggestionFromBiblionumber(2), undef, 'GetSuggestionFromBiblionumber with Link Here
292
is( GetSuggestionFromBiblionumber($biblio_1->biblionumber), $my_suggestionid, 'GetSuggestionFromBiblionumber functions correctly' );
292
is( GetSuggestionFromBiblionumber($biblio_1->biblionumber), $my_suggestionid, 'GetSuggestionFromBiblionumber functions correctly' );
293
293
294
294
295
is( GetSuggestionInfoFromBiblionumber(), undef, 'GetSuggestionInfoFromBiblionumber without the biblio number returns undef' );
296
is( GetSuggestionInfoFromBiblionumber(2), undef, 'GetSuggestionInfoFromBiblionumber with an invalid biblio number returns undef' );
297
$suggestion = GetSuggestionInfoFromBiblionumber($biblio_1->biblionumber);
298
is( $suggestion->{suggestionid}, $my_suggestionid, 'GetSuggestionInfoFromBiblionumber returns the suggestion id correctly' );
299
is( $suggestion->{title}, $mod_suggestion1->{title}, 'GetSuggestionInfoFromBiblionumber returns the title correctly' );
300
is( $suggestion->{author}, $mod_suggestion1->{author}, 'GetSuggestionInfoFromBiblionumber returns the author correctly' );
301
is( $suggestion->{publishercode}, $mod_suggestion1->{publishercode}, 'GetSuggestionInfoFromBiblionumber returns the publisher code correctly' );
302
is( $suggestion->{suggestedby}, $my_suggestion->{suggestedby}, 'GetSuggestionInfoFromBiblionumber returns the borrower number correctly' );
303
is( $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, 'GetSuggestionInfoFromBiblionumber returns the biblio number correctly' );
304
is( $suggestion->{STATUS}, $mod_suggestion3->{STATUS}, 'GetSuggestionInfoFromBiblionumber returns the status correctly' );
305
is( $suggestion->{surnamesuggestedby}, $member->{surname}, 'GetSuggestionInfoFromBiblionumber returns the surname correctly' );
306
is( $suggestion->{firstnamesuggestedby}, $member->{firstname}, 'GetSuggestionInfoFromBiblionumber returns the firstname correctly' );
307
is( $suggestion->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, 'GetSuggestionInfoFromBiblionumeber returns the borrower number correctly' );
308
309
310
my $suggestions = GetSuggestionByStatus();
295
my $suggestions = GetSuggestionByStatus();
311
is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' );
296
is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' );
312
$suggestions = GetSuggestionByStatus('CHECKED');
297
$suggestions = GetSuggestionByStatus('CHECKED');
313
- 

Return to bug 28844