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

(-)a/C4/Suggestions.pm (-8 / +9 lines)
Lines 158-173 sub SearchSuggestion { Link Here
158
        qw( STATUS itemtype suggestedby managedby acceptedby budgetid biblionumber )
158
        qw( STATUS itemtype suggestedby managedby acceptedby budgetid biblionumber )
159
      )
159
      )
160
    {
160
    {
161
        if ( exists $suggestion->{$field} ) {
161
        if ( exists $suggestion->{$field}
162
            if ( defined $suggestion->{$field} and $suggestion->{$field} ne '' )
162
                and defined $suggestion->{$field}
163
            {
163
                and $suggestion->{$field} ne '__ANY__'
164
                push @sql_params, $suggestion->{$field};
164
                and $suggestion->{$field} ne q||
165
                push @query,      qq{ AND suggestions.$field=? };
165
        ) {
166
            if ( $suggestion->{$field} eq '__NONE__' ) {
167
                push @query, qq{ AND (suggestions.$field = '' OR suggestions.$field IS NULL) };
166
            }
168
            }
167
            else {
169
            else {
168
                push @query, qq{
170
                push @sql_params, $suggestion->{$field};
169
                    AND (suggestions.$field='' OR suggestions.$field IS NULL)
171
                push @query, qq{ AND suggestions.$field = ? };
170
                };
171
            }
172
            }
172
        }
173
        }
173
    }
174
    }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-1 / +8 lines)
Lines 743-749 h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o Link Here
743
743
744
				<fieldset class="brief"><h4 class="local_collapse"><a href="#">Acquisition information</a></h4>
744
				<fieldset class="brief"><h4 class="local_collapse"><a href="#">Acquisition information</a></h4>
745
                    <ol><li><label for="budgetid"> Book fund:</label>
745
                    <ol><li><label for="budgetid"> Book fund:</label>
746
                    <select name="budgetid" id="budgetid"><option value="">Any</option>[% FOREACH budgetid_loo IN budgetid_loop %]
746
                    <select name="budgetid" id="budgetid">
747
                      <option value="__ANY__">Any</option>
748
                      [% IF budgetid == '__NONE__' %]
749
                          <option value="__NONE__" selected="selected">None</option>
750
                      [% ELSE %]
751
                          <option value="__NONE__">None</option>
752
                      [% END %]
753
                    [% FOREACH budgetid_loo IN budgetid_loop %]
747
                        [% IF ( budgetid_loo.selected ) %] <option value="[% budgetid_loo.code %]" selected="selected">[% budgetid_loo.desc %]</option>[% ELSE %]<option value="[% budgetid_loo.code %]">[% budgetid_loo.desc %]</option>[% END %]
754
                        [% IF ( budgetid_loo.selected ) %] <option value="[% budgetid_loo.code %]" selected="selected">[% budgetid_loo.desc %]</option>[% ELSE %]<option value="[% budgetid_loo.code %]">[% budgetid_loo.desc %]</option>[% END %]
748
                        [% END %]
755
                        [% END %]
749
                    </select></li>
756
                    </select></li>
(-)a/t/db_dependent/Suggestions.t (-6 / +51 lines)
Lines 20-29 use Modern::Perl; Link Here
20
use C4::Context;
20
use C4::Context;
21
use C4::Members;
21
use C4::Members;
22
use C4::Letters;
22
use C4::Letters;
23
use C4::Budgets;
23
24
24
use Koha::DateUtils qw( dt_from_string );
25
use Koha::DateUtils qw( dt_from_string );
25
26
26
use Test::More tests => 97;
27
use Test::More tests => 101;
27
use Test::Warn;
28
use Test::Warn;
28
29
29
BEGIN {
30
BEGIN {
Lines 65-70 my $my_suggestion = { Link Here
65
    note          => 'my note',
66
    note          => 'my note',
66
};
67
};
67
68
69
my $budgetperiod_id = AddBudgetPeriod({
70
    budget_period_startdate   => '2008-01-01',
71
    budget_period_enddate     => '2008-12-31',
72
    budget_period_description => 'MAPERI',
73
    budget_period_active      => 1,
74
});
75
76
my $budget_id = AddBudget({
77
    budget_code      => 'ABCD',
78
    budget_amount    => '123.132000',
79
    budget_name      => 'ABCD',
80
    budget_notes     => 'This is a note',
81
    budget_period_id => $budgetperiod_id,
82
});
83
my $my_suggestion_with_budget = {
84
    title         => 'my title 2',
85
    author        => 'my author 2',
86
    publishercode => 'my publishercode 2',
87
    suggestedby   => $borrowernumber,
88
    biblionumber  => $biblionumber1,
89
    managedby     => '',
90
    manageddate   => '',
91
    accepteddate  => dt_from_string,
92
    note          => 'my note',
93
    budgetid      => $budget_id,
94
};
95
68
96
69
is( CountSuggestion(), 0, 'CountSuggestion without the status returns 0' );
97
is( CountSuggestion(), 0, 'CountSuggestion without the status returns 0' );
70
is( CountSuggestion('ASKED'), 0, 'CountSuggestion returns the correct number of suggestions' );
98
is( CountSuggestion('ASKED'), 0, 'CountSuggestion returns the correct number of suggestions' );
Lines 74-79 is( CountSuggestion('REJECTED'), 0, 'CountSuggestion returns the correct number Link Here
74
102
75
my $my_suggestionid = NewSuggestion($my_suggestion);
103
my $my_suggestionid = NewSuggestion($my_suggestion);
76
isnt( $my_suggestionid, 0, 'NewSuggestion returns an not null id' );
104
isnt( $my_suggestionid, 0, 'NewSuggestion returns an not null id' );
105
my $my_suggestionid_with_budget = NewSuggestion($my_suggestion_with_budget);
77
106
78
is( GetSuggestion(), undef, 'GetSuggestion without the suggestion id returns undef' );
107
is( GetSuggestion(), undef, 'GetSuggestion without the suggestion id returns undef' );
79
my $suggestion = GetSuggestion($my_suggestionid);
108
my $suggestion = GetSuggestion($my_suggestionid);
Lines 85-91 is( $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, 'NewSuggestion Link Here
85
is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' );
114
is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' );
86
is( $suggestion->{managedby}, undef, 'NewSuggestion stores empty string as undef for non existent foreign key (integer)' );
115
is( $suggestion->{managedby}, undef, 'NewSuggestion stores empty string as undef for non existent foreign key (integer)' );
87
is( $suggestion->{manageddate}, undef, 'NewSuggestion stores empty string as undef for date' );
116
is( $suggestion->{manageddate}, undef, 'NewSuggestion stores empty string as undef for date' );
88
is( CountSuggestion('ASKED'), 1, 'CountSuggestion returns the correct number of suggestions' );
117
is( CountSuggestion('ASKED'), 2, 'CountSuggestion returns the correct number of suggestions' );
89
118
90
119
91
is( ModSuggestion(), undef, 'ModSuggestion without the suggestion returns undef' );
120
is( ModSuggestion(), undef, 'ModSuggestion without the suggestion returns undef' );
Lines 201-209 is( $connect_suggestion_and_biblio, '1', 'ConnectSuggestionAndBiblio returns 1' Link Here
201
$suggestion = GetSuggestion($my_suggestionid);
230
$suggestion = GetSuggestion($my_suggestionid);
202
is( $suggestion->{biblionumber}, $biblionumber2, 'ConnectSuggestionAndBiblio updates the biblio number correctly' );
231
is( $suggestion->{biblionumber}, $biblionumber2, 'ConnectSuggestionAndBiblio updates the biblio number correctly' );
203
232
204
205
my $search_suggestion = SearchSuggestion();
233
my $search_suggestion = SearchSuggestion();
206
is( @$search_suggestion, 1, 'SearchSuggestion without arguments returns all suggestions' );
234
is( @$search_suggestion, 2, 'SearchSuggestion without arguments returns all suggestions' );
207
235
208
$search_suggestion = SearchSuggestion({
236
$search_suggestion = SearchSuggestion({
209
    title => $mod_suggestion1->{title},
237
    title => $mod_suggestion1->{title},
Lines 224-230 $search_suggestion = SearchSuggestion({ Link Here
224
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
252
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
225
253
226
$search_suggestion = SearchSuggestion({
254
$search_suggestion = SearchSuggestion({
227
    publishercode => $mod_suggestion3->{publishercode},
255
    publishercode => $mod_suggestion1->{publishercode},
228
});
256
});
229
is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' );
257
is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' );
230
$search_suggestion = SearchSuggestion({
258
$search_suggestion = SearchSuggestion({
Lines 241-246 $search_suggestion = SearchSuggestion({ Link Here
241
});
269
});
242
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
270
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
243
271
272
$search_suggestion = SearchSuggestion({
273
    budgetid => '',
274
});
275
is( @$search_suggestion, 2, 'SearchSuggestion (budgetid = "") returns the correct number of suggestions' );
276
$search_suggestion = SearchSuggestion({
277
    budgetid => $budget_id,
278
});
279
is( @$search_suggestion, 1, 'SearchSuggestion (budgetid = $budgetid) returns the correct number of suggestions' );
280
$search_suggestion = SearchSuggestion({
281
    budgetid => '__NONE__',
282
});
283
is( @$search_suggestion, 1, 'SearchSuggestion (budgetid = "__NONE__") returns the correct number of suggestions' );
284
$search_suggestion = SearchSuggestion({
285
    budgetid => '__ANY__',
286
});
287
is( @$search_suggestion, 2, 'SearchSuggestion (budgetid = "__ANY__") returns the correct number of suggestions' );
244
288
245
my $del_suggestion = {
289
my $del_suggestion = {
246
    title => 'my deleted title',
290
    title => 'my deleted title',
Lines 273-275 is(@$itemtypes2, 8, "Purchase suggestion itemtypes collected, default AdvancedSe Link Here
273
is_deeply($itemtypes1, $itemtypes2, 'same set of purchase suggestion formats retrieved');
317
is_deeply($itemtypes1, $itemtypes2, 'same set of purchase suggestion formats retrieved');
274
318
275
$dbh->rollback;
319
$dbh->rollback;
276
- 
320
321
done_testing;

Return to bug 13378