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

(-)a/C4/Suggestions.pm (-21 lines)
Lines 23-29 use base 'Exporter'; Link Here
23
23
24
BEGIN {
24
BEGIN {
25
    our @EXPORT = qw(
25
    our @EXPORT = qw(
26
        ConnectSuggestionAndBiblio
27
        DelSuggestion
26
        DelSuggestion
28
        GetSuggestion
27
        GetSuggestion
29
        ModStatus
28
        ModStatus
Lines 151-176 sub ModSuggestion { Link Here
151
    return 1;    # No useful if the exception is raised earlier
150
    return 1;    # No useful if the exception is raised earlier
152
}
151
}
153
152
154
=head2 ConnectSuggestionAndBiblio
155
156
&ConnectSuggestionAndBiblio($ordernumber,$biblionumber)
157
158
connect a suggestion to an existing biblio
159
160
=cut
161
162
sub ConnectSuggestionAndBiblio {
163
    my ( $suggestionid, $biblionumber ) = @_;
164
    my $dbh   = C4::Context->dbh;
165
    my $query = q{
166
        UPDATE suggestions
167
        SET    biblionumber=?
168
        WHERE  suggestionid=?
169
    };
170
    my $sth = $dbh->prepare($query);
171
    $sth->execute( $biblionumber, $suggestionid );
172
}
173
174
=head2 DelSuggestion
153
=head2 DelSuggestion
175
154
176
&DelSuggestion($borrowernumber,$ordernumber)
155
&DelSuggestion($borrowernumber,$ordernumber)
(-)a/acqui/newordersuggestion.pl (-11 / +2 lines)
Lines 77-88 the id of the suggestion to select. Link Here
77
77
78
=item op
78
=item op
79
79
80
can be equal to
80
The operation to perform
81
    * connectDuplicate :
82
        then call to the function : ConnectSuggestionAndBiblio.
83
        i.e set the biblionumber of this suggestion.
84
    * else :
85
        is the default value.
86
81
87
=back
82
=back
88
83
Lines 93-99 use Modern::Perl; Link Here
93
use CGI             qw ( -utf8 );
88
use CGI             qw ( -utf8 );
94
use C4::Auth        qw( get_template_and_user );
89
use C4::Auth        qw( get_template_and_user );
95
use C4::Output      qw( output_html_with_http_headers );
90
use C4::Output      qw( output_html_with_http_headers );
96
use C4::Suggestions qw( ConnectSuggestionAndBiblio ModSuggestion );
91
use C4::Suggestions qw( ModSuggestion );
97
use C4::Budgets;
92
use C4::Budgets;
98
93
99
use Koha::Acquisition::Booksellers;
94
use Koha::Acquisition::Booksellers;
Lines 125-134 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
125
    }
120
    }
126
);
121
);
127
122
128
if ( $op eq 'connectDuplicate' ) {
129
    ConnectSuggestionAndBiblio( $suggestionid, $duplicateNumber );
130
}
131
132
if ( $op eq 'cud-link_order' and $link_order ) {
123
if ( $op eq 'cud-link_order' and $link_order ) {
133
    my $order = Koha::Acquisition::Orders->find($link_order);
124
    my $order = Koha::Acquisition::Orders->find($link_order);
134
125
(-)a/t/db_dependent/Suggestions.t (-13 / +2 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 => 53;
22
use Test::More tests => 50;
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-325 $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' );
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);
318
is(
319
    $suggestion->biblionumber, $biblio_2->biblionumber,
320
    'ConnectSuggestionAndBiblio updates the biblio number correctly'
321
);
322
323
my $del_suggestion = {
313
my $del_suggestion = {
324
    title       => 'my deleted title',
314
    title       => 'my deleted title',
325
    STATUS      => 'CHECKED',
315
    STATUS      => 'CHECKED',
326
- 

Return to bug 39726