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

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

Return to bug 35717