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

(-)a/C4/Suggestions.pm (-21 lines)
Lines 32-38 use C4::Log qw(logaction); Link Here
32
use base qw(Exporter);
32
use base qw(Exporter);
33
33
34
our @EXPORT = qw(
34
our @EXPORT = qw(
35
    ConnectSuggestionAndBiblio
36
    DelSuggestion
35
    DelSuggestion
37
    ModStatus
36
    ModStatus
38
    ModSuggestion
37
    ModSuggestion
Lines 137-162 sub ModSuggestion { Link Here
137
    return 1;    # No useful if the exception is raised earlier
136
    return 1;    # No useful if the exception is raised earlier
138
}
137
}
139
138
140
=head2 ConnectSuggestionAndBiblio
141
142
&ConnectSuggestionAndBiblio($ordernumber,$biblionumber)
143
144
connect a suggestion to an existing biblio
145
146
=cut
147
148
sub ConnectSuggestionAndBiblio {
149
    my ( $suggestionid, $biblionumber ) = @_;
150
    my $dbh   = C4::Context->dbh;
151
    my $query = q{
152
        UPDATE suggestions
153
        SET    biblionumber=?
154
        WHERE  suggestionid=?
155
    };
156
    my $sth = $dbh->prepare($query);
157
    $sth->execute( $biblionumber, $suggestionid );
158
}
159
160
=head2 DelSuggestion
139
=head2 DelSuggestion
161
140
162
&DelSuggestion($borrowernumber,$ordernumber)
141
&DelSuggestion($borrowernumber,$ordernumber)
(-)a/acqui/newordersuggestion.pl (-4 / +3 lines)
Lines 81-90 the id of the suggestion to select. Link Here
81
81
82
use Modern::Perl;
82
use Modern::Perl;
83
83
84
use CGI             qw ( -utf8 );
84
use CGI        qw ( -utf8 );
85
use C4::Auth        qw( get_template_and_user );
85
use C4::Auth   qw( get_template_and_user );
86
use C4::Output      qw( output_html_with_http_headers );
86
use C4::Output qw( output_html_with_http_headers );
87
use C4::Suggestions qw( ConnectSuggestionAndBiblio );
88
use C4::Budgets;
87
use C4::Budgets;
89
88
90
use Koha::Acquisition::Booksellers;
89
use Koha::Acquisition::Booksellers;
(-)a/t/db_dependent/Suggestions.t (-12 / +3 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use DateTime::Duration;
20
use DateTime::Duration;
21
use Test::NoWarnings;
21
use Test::NoWarnings;
22
use Test::More tests => 55;
22
use Test::More tests => 52;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use t::lib::Mocks;
25
use t::lib::Mocks;
Lines 38-44 use Koha::Suggestions; Link Here
38
BEGIN {
38
BEGIN {
39
    use_ok(
39
    use_ok(
40
        'C4::Suggestions',
40
        'C4::Suggestions',
41
        qw( ModSuggestion ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
41
        qw( ModSuggestion DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
42
    );
42
    );
43
}
43
}
44
44
Lines 310-324 $messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber2 Link Here
310
310
311
is( scalar(@$messages), 1, 'No new letter should have been generated if the update raised an error' );
311
is( scalar(@$messages), 1, 'No new letter should have been generated if the update raised an error' );
312
312
313
is( ConnectSuggestionAndBiblio(), '0E0', 'ConnectSuggestionAndBiblio without arguments returns 0E0' );
313
my $biblio_2 = $builder->build_object( { class => 'Koha::Biblios' } );
314
my $biblio_2                      = $builder->build_object( { class => 'Koha::Biblios' } );
315
my $connect_suggestion_and_biblio = ConnectSuggestionAndBiblio( $my_suggestionid, $biblio_2->biblionumber );
316
is( $connect_suggestion_and_biblio, '1', 'ConnectSuggestionAndBiblio returns 1' );
317
$suggestion = Koha::Suggestions->find($my_suggestionid)->unblessed();
318
is(
319
    $suggestion->{biblionumber}, $biblio_2->biblionumber,
320
    'ConnectSuggestionAndBiblio updates the biblio number correctly'
321
);
322
314
323
my $del_suggestion = {
315
my $del_suggestion = {
324
    title       => 'my deleted title',
316
    title       => 'my deleted title',
325
- 

Return to bug 39726