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

(-)a/C4/Suggestions.pm (-28 lines)
Lines 35-41 our @EXPORT = qw( Link Here
35
    ConnectSuggestionAndBiblio
35
    ConnectSuggestionAndBiblio
36
    DelSuggestion
36
    DelSuggestion
37
    GetSuggestionByStatus
37
    GetSuggestionByStatus
38
    GetSuggestionInfo
39
    ModStatus
38
    ModStatus
40
    ModSuggestion
39
    ModSuggestion
41
    DelSuggestionsOlderThan
40
    DelSuggestionsOlderThan
Lines 68-100 Suggestions done by other borrowers can be seen when not "AVAILABLE" Link Here
68
67
69
=head1 FUNCTIONS
68
=head1 FUNCTIONS
70
69
71
=head2 GetSuggestionInfo
72
73
Get a suggestion and borrower's informations from it's suggestionid
74
75
return :
76
all informations (suggestion and borrower) of the suggestion which is related to the suggestionid given.
77
78
=cut
79
80
sub GetSuggestionInfo {
81
    my ($suggestionid) = @_;
82
    my $query = q{
83
        SELECT suggestions.*,
84
            U1.surname          AS surnamesuggestedby,
85
            U1.firstname        AS firstnamesuggestedby,
86
            U1.borrowernumber   AS borrnumsuggestedby
87
        FROM suggestions
88
            LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
89
        WHERE suggestionid=?
90
        LIMIT 1
91
    };
92
    my $dbh = C4::Context->dbh;
93
    my $sth = $dbh->prepare($query);
94
    $sth->execute($suggestionid);
95
    return $sth->fetchrow_hashref;
96
}
97
98
=head2 GetSuggestionByStatus
70
=head2 GetSuggestionByStatus
99
71
100
$aqorders = &GetSuggestionByStatus($status,[$branchcode])
72
$aqorders = &GetSuggestionByStatus($status,[$branchcode])
(-)a/acqui/basket.pl (-3 / +2 lines)
Lines 26-34 use C4::Output qw( output_html_with_http_headers output_and_exit ); Link Here
26
use CGI        qw ( -utf8 );
26
use CGI        qw ( -utf8 );
27
use C4::Acquisition
27
use C4::Acquisition
28
    qw( GetBasket CanUserManageBasket GetBasketAsCSV NewBasket NewBasketgroup ModBasket ReopenBasket ModBasketUsers GetBasketgroup GetBasketgroups GetBasketUsers GetOrders GetOrder get_rounded_price );
28
    qw( GetBasket CanUserManageBasket GetBasketAsCSV NewBasket NewBasketgroup ModBasket ReopenBasket ModBasketUsers GetBasketgroup GetBasketgroups GetBasketUsers GetOrders GetOrder get_rounded_price );
29
use C4::Budgets     qw( GetBudgetHierarchy GetBudget CanUserUseBudget );
29
use C4::Budgets  qw( GetBudgetHierarchy GetBudget CanUserUseBudget );
30
use C4::Contract    qw( GetContract );
30
use C4::Contract qw( GetContract );
31
use C4::Suggestions qw( GetSuggestionInfo );
32
use Koha::Biblios;
31
use Koha::Biblios;
33
use Koha::Acquisition::Baskets;
32
use Koha::Acquisition::Baskets;
34
use Koha::Acquisition::Booksellers;
33
use Koha::Acquisition::Booksellers;
(-)a/acqui/neworderempty.pl (-5 / +4 lines)
Lines 72-78 use C4::Budgets qw( GetBudget GetBudgetHierarchy CanUserUseBudget ); Link Here
72
72
73
use C4::Acquisition qw( GetOrder GetBasket FillWithDefaultValues GetOrderUsers );
73
use C4::Acquisition qw( GetOrder GetBasket FillWithDefaultValues GetOrderUsers );
74
use C4::Contract    qw( GetContract );
74
use C4::Contract    qw( GetContract );
75
use C4::Suggestions qw( GetSuggestionInfo );
76
use C4::Biblio      qw(
75
use C4::Biblio      qw(
77
    AddBiblio
76
    AddBiblio
78
    GetBiblioData
77
    GetBiblioData
Lines 323-329 if ( not $ordernumber or $biblionumber ) { Link Here
323
$template->param( catalog_details => \@catalog_details, );
322
$template->param( catalog_details => \@catalog_details, );
324
323
325
my $suggestion;
324
my $suggestion;
326
$suggestion = GetSuggestionInfo($suggestionid) if $suggestionid;
325
$suggestion = Koha::Suggestions->find($suggestionid);
327
326
328
my $active_currency = Koha::Acquisition::Currencies->get_active;
327
my $active_currency = Koha::Acquisition::Currencies->get_active;
329
328
Lines 461-469 $template->param( Link Here
461
    closedate            => $basket->{'closedate'},
460
    closedate            => $basket->{'closedate'},
462
461
463
    # order details
462
    # order details
464
    suggestionid         => $suggestion->{suggestionid},
463
    suggestionid         => $suggestion->suggestionid,
465
    surnamesuggestedby   => $suggestion->{surnamesuggestedby},
464
    surnamesuggestedby   => $suggestion->suggester->{surname},
466
    firstnamesuggestedby => $suggestion->{firstnamesuggestedby},
465
    firstnamesuggestedby => $suggestion->suggester->{firstname},
467
    biblionumber         => $biblionumber,
466
    biblionumber         => $biblionumber,
468
    uncertainprice       => $data->{'uncertainprice'},
467
    uncertainprice       => $data->{'uncertainprice'},
469
    discount_2dp         => sprintf( "%.2f", $bookseller->discount ),      # for display
468
    discount_2dp         => sprintf( "%.2f", $bookseller->discount ),      # for display
(-)a/t/db_dependent/Suggestions.t (-28 / +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 => 80;
22
use Test::More tests => 69;
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 GetSuggestionInfo GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
41
        qw( ModSuggestion GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
42
    );
42
    );
43
}
43
}
44
44
Lines 310-340 $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( GetSuggestionInfo(), undef, 'GetSuggestionInfo without the suggestion id returns undef' );
314
$suggestion = GetSuggestionInfo($my_suggestionid);
315
is( $suggestion->{suggestionid}, $my_suggestionid,           'GetSuggestionInfo returns the suggestion id correctly' );
316
is( $suggestion->{title},        $mod_suggestion1->{title},  'GetSuggestionInfo returns the title correctly' );
317
is( $suggestion->{author},       $mod_suggestion1->{author}, 'GetSuggestionInfo returns the author correctly' );
318
is(
319
    $suggestion->{publishercode}, $mod_suggestion1->{publishercode},
320
    'GetSuggestionInfo returns the publisher code correctly'
321
);
322
is(
323
    $suggestion->{suggestedby}, $my_suggestion->{suggestedby},
324
    'GetSuggestionInfo returns the borrower number correctly'
325
);
326
is(
327
    $suggestion->{biblionumber}, $my_suggestion->{biblionumber},
328
    'GetSuggestionInfo returns the biblio number correctly'
329
);
330
is( $suggestion->{STATUS},             $mod_suggestion3->{STATUS}, 'GetSuggestionInfo returns the status correctly' );
331
is( $suggestion->{surnamesuggestedby}, $member->{surname},         'GetSuggestionInfo returns the surname correctly' );
332
is( $suggestion->{firstnamesuggestedby}, $member->{firstname}, 'GetSuggestionInfo returns the firstname correctly' );
333
is(
334
    $suggestion->{borrnumsuggestedby}, $my_suggestion->{suggestedby},
335
    'GetSuggestionInfo returns the borrower number correctly'
336
);
337
338
my $suggestions = GetSuggestionByStatus();
313
my $suggestions = GetSuggestionByStatus();
339
is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' );
314
is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' );
340
$suggestions = GetSuggestionByStatus('CHECKED');
315
$suggestions = GetSuggestionByStatus('CHECKED');
341
- 

Return to bug 39724