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

(-)a/C4/Suggestions.pm (-150 lines)
Lines 41-47 our @EXPORT = qw( Link Here
41
  ModStatus
41
  ModStatus
42
  ModSuggestion
42
  ModSuggestion
43
  NewSuggestion
43
  NewSuggestion
44
  SearchSuggestion
45
  DelSuggestionsOlderThan
44
  DelSuggestionsOlderThan
46
  GetUnprocessedSuggestions
45
  GetUnprocessedSuggestions
47
  MarcRecordFromNewSuggestion
46
  MarcRecordFromNewSuggestion
Lines 72-226 Suggestions done by other borrowers can be seen when not "AVAILABLE" Link Here
72
71
73
=head1 FUNCTIONS
72
=head1 FUNCTIONS
74
73
75
=head2 SearchSuggestion
76
77
(\@array) = &SearchSuggestion($suggestionhashref_to_search)
78
79
searches for a suggestion
80
81
return :
82
C<\@array> : the aqorders found. Array of hash.
83
Note the status is stored twice :
84
* in the status field
85
* as parameter ( for example ASKED => 1, or REJECTED => 1) . This is for template & translation purposes.
86
87
=cut
88
89
sub SearchSuggestion {
90
    my ($suggestion) = @_;
91
    my $dbh = C4::Context->dbh;
92
    my @sql_params;
93
    my @query = (
94
        q{
95
        SELECT suggestions.*,
96
            U1.branchcode       AS branchcodesuggestedby,
97
            B1.branchname       AS branchnamesuggestedby,
98
            U1.surname          AS surnamesuggestedby,
99
            U1.firstname        AS firstnamesuggestedby,
100
            U1.cardnumber       AS cardnumbersuggestedby,
101
            U1.email            AS emailsuggestedby,
102
            U1.borrowernumber   AS borrnumsuggestedby,
103
            U1.categorycode     AS categorycodesuggestedby,
104
            C1.description      AS categorydescriptionsuggestedby,
105
            U2.surname          AS surnamemanagedby,
106
            U2.firstname        AS firstnamemanagedby,
107
            B2.branchname       AS branchnamesuggestedby,
108
            U2.email            AS emailmanagedby,
109
            U2.branchcode       AS branchcodemanagedby,
110
            U2.borrowernumber   AS borrnummanagedby,
111
            U3.surname          AS surnamelastmodificationby,
112
            U3.firstname        AS firstnamelastmodificationby,
113
            BU.budget_name      AS budget_name
114
        FROM suggestions
115
            LEFT JOIN borrowers     AS U1 ON suggestedby=U1.borrowernumber
116
            LEFT JOIN branches      AS B1 ON B1.branchcode=U1.branchcode
117
            LEFT JOIN categories    AS C1 ON C1.categorycode=U1.categorycode
118
            LEFT JOIN borrowers     AS U2 ON managedby=U2.borrowernumber
119
            LEFT JOIN branches      AS B2 ON B2.branchcode=U2.branchcode
120
            LEFT JOIN categories    AS C2 ON C2.categorycode=U2.categorycode
121
            LEFT JOIN borrowers     AS U3 ON lastmodificationby=U3.borrowernumber
122
            LEFT JOIN aqbudgets     AS BU ON budgetid=BU.budget_id
123
        WHERE 1=1
124
    }
125
    );
126
127
    # filter on biblio informations
128
    foreach my $field (
129
        qw( title author isbn publishercode copyrightdate collectiontitle ))
130
    {
131
        if ( $suggestion->{$field} ) {
132
            push @sql_params, '%' . $suggestion->{$field} . '%';
133
            push @query,      qq{ AND suggestions.$field LIKE ? };
134
        }
135
    }
136
137
    # filter on user branch
138
    if (   C4::Context->preference('IndependentBranches')
139
        && !C4::Context->IsSuperLibrarian() )
140
    {
141
        # If IndependentBranches is set and the logged in user is not superlibrarian
142
        # Then we want to filter by the user's library (i.e. cannot see suggestions from other libraries)
143
        my $userenv = C4::Context->userenv;
144
        if ($userenv) {
145
            {
146
                push @sql_params, $$userenv{branch};
147
                push @query,      q{
148
                    AND (suggestions.branchcode=? OR suggestions.branchcode='')
149
                };
150
            }
151
        }
152
    }
153
    elsif (defined $suggestion->{branchcode}
154
        && $suggestion->{branchcode}
155
        && $suggestion->{branchcode} ne '__ANY__' )
156
    {
157
        # If IndependentBranches is not set OR the logged in user is not superlibrarian
158
        # AND the branchcode filter is passed and not '__ANY__'
159
        # Then we want to filter using this parameter
160
        push @sql_params, $suggestion->{branchcode};
161
        push @query,      qq{ AND suggestions.branchcode=? };
162
    }
163
164
    # filter on nillable fields
165
    foreach my $field (
166
        qw( STATUS itemtype suggestedby managedby acceptedby budgetid biblionumber )
167
      )
168
    {
169
        if ( exists $suggestion->{$field}
170
                and defined $suggestion->{$field}
171
                and $suggestion->{$field} ne '__ANY__'
172
                and (
173
                    $suggestion->{$field} ne q||
174
                        or $field eq 'STATUS'
175
                )
176
        ) {
177
            if ( $suggestion->{$field} eq '__NONE__' ) {
178
                push @query, qq{ AND (suggestions.$field = '' OR suggestions.$field IS NULL) };
179
            }
180
            else {
181
                push @sql_params, $suggestion->{$field};
182
                push @query, qq{ AND suggestions.$field = ? };
183
            }
184
        }
185
    }
186
187
    # filter on date fields
188
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
189
    foreach my $field (qw( suggesteddate manageddate accepteddate )) {
190
        my $from = $field . "_from";
191
        my $to   = $field . "_to";
192
        my $from_dt;
193
        $from_dt = eval { dt_from_string( $suggestion->{$from} ) } if ( $suggestion->{$from} );
194
        my $to_dt;
195
        $to_dt = eval { dt_from_string( $suggestion->{$to} ) } if ( $suggestion->{$to} );
196
        if ( $from_dt ) {
197
            push @query, qq{ AND suggestions.$field >= ?};
198
            push @sql_params, $dtf->format_date($from_dt);
199
        }
200
        if ( $to_dt ) {
201
            push @query, qq{ AND suggestions.$field <= ?};
202
            push @sql_params, $dtf->format_date($to_dt);
203
        }
204
    }
205
206
    # By default do not search for archived suggestions
207
    unless ( exists $suggestion->{archived} && $suggestion->{archived} ) {
208
        push @query, q{ AND suggestions.archived = 0 };
209
    }
210
211
    my $sth = $dbh->prepare("@query");
212
    $sth->execute(@sql_params);
213
    my @results;
214
215
    # add status as field
216
    while ( my $data = $sth->fetchrow_hashref ) {
217
        $data->{ $data->{STATUS} } = 1;
218
        push( @results, $data );
219
    }
220
221
    return ( \@results );
222
}
223
224
=head2 GetSuggestion
74
=head2 GetSuggestion
225
75
226
\%sth = &GetSuggestion($suggestionid)
76
\%sth = &GetSuggestion($suggestionid)
(-)a/acqui/newordersuggestion.pl (-11 / +11 lines)
Lines 93-102 use Modern::Perl; Link Here
93
use CGI qw ( -utf8 );
93
use CGI qw ( -utf8 );
94
use C4::Auth qw( get_template_and_user );
94
use C4::Auth qw( get_template_and_user );
95
use C4::Output qw( output_html_with_http_headers );
95
use C4::Output qw( output_html_with_http_headers );
96
use C4::Suggestions qw( ConnectSuggestionAndBiblio SearchSuggestion );
96
use C4::Suggestions qw( ConnectSuggestionAndBiblio );
97
use C4::Budgets;
97
use C4::Budgets;
98
98
99
use Koha::Acquisition::Booksellers;
99
use Koha::Acquisition::Booksellers;
100
use Koha::Suggestions;
100
101
101
my $input = CGI->new;
102
my $input = CGI->new;
102
103
Lines 127-149 if ( $op eq 'connectDuplicate' ) { Link Here
127
    ConnectSuggestionAndBiblio( $suggestionid, $duplicateNumber );
128
    ConnectSuggestionAndBiblio( $suggestionid, $duplicateNumber );
128
}
129
}
129
130
130
# getting all suggestions.
131
my $suggestions = [ Koha::Suggestions->search_limited(
131
my $suggestions_loop = SearchSuggestion(
132
    {
132
    {
133
        author        => $author,
133
        ( $author        ? ( author        => $author )        : () ),
134
        title         => $title,
134
        ( $title         ? ( title         => $title )         : () ),
135
        publishercode => $publishercode,
135
        ( $publishercode ? ( publishercode => $publishercode ) : () ),
136
        STATUS        => 'ACCEPTED'
136
        STATUS => 'ACCEPTED'
137
    }
137
    },
138
);
138
    { prefetch => ['managedby', 'suggestedby'] },
139
)->as_list ];
139
140
140
my $vendor = Koha::Acquisition::Booksellers->find( $booksellerid );
141
my $vendor = Koha::Acquisition::Booksellers->find( $booksellerid );
141
$template->param(
142
$template->param(
142
    suggestions_loop        => $suggestions_loop,
143
    suggestions             => $suggestions,
143
    basketno                => $basketno,
144
    basketno                => $basketno,
144
    booksellerid              => $booksellerid,
145
    booksellerid              => $booksellerid,
145
    name                    => $vendor->name,
146
    name                    => $vendor->name,
146
    loggedinuser            => $borrowernumber,
147
    "op_$op"                => 1,
147
    "op_$op"                => 1,
148
);
148
);
149
149
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt (-27 / +23 lines)
Lines 41-47 Link Here
41
            <main>
41
            <main>
42
42
43
<h1>Suggestions</h1>
43
<h1>Suggestions</h1>
44
    [% IF ( suggestions_loop ) %]
44
    [% IF suggestions.size %]
45
    <a href="#" id="show_only_mine">Show only mine</a> | <a href="#" id="show_all">Show all suggestions</a>
45
    <a href="#" id="show_only_mine">Show only mine</a> | <a href="#" id="show_all">Show all suggestions</a>
46
    <table id="suggestionst">
46
    <table id="suggestionst">
47
        <thead>
47
        <thead>
Lines 59-107 Link Here
59
        </tr>
59
        </tr>
60
        </thead>
60
        </thead>
61
        <tbody>
61
        <tbody>
62
        [% FOREACH suggestions_loo IN suggestions_loop %]
62
        [% FOREACH suggestion IN suggestions %]
63
            <tr>
63
            <tr>
64
                <td>[% suggestions_loo.managedby | html %]</td>
64
                <td>[% suggestion.managedby | html %]</td>
65
                <td>
65
                <td>
66
                    <p>[% suggestions_loo.title | html %] - [% suggestions_loo.author | html %]</p>
66
                    <p>[% suggestion.title | html %] - [% suggestion.author | html %]</p>
67
                    <p>
67
                    <p>
68
                        [% IF ( suggestions_loo.copyrightdate ) %]&copy; [% suggestions_loo.copyrightdate | html %] [% END %]
68
                        [% IF ( suggestion.copyrightdate ) %]&copy; [% suggestion.copyrightdate | html %] [% END %]
69
                        [% IF ( suggestions_loo.volumedesc ) %]volume: <em>[% suggestions_loo.volumedesc | html %]</em> [% END %]
69
                        [% IF ( suggestion.volumedesc ) %]volume: <em>[% suggestion.volumedesc | html %]</em> [% END %]
70
                        [% IF ( suggestions_loo.isbn ) %]ISBN: <em>[% suggestions_loo.isbn | html %]</em> [% END %]
70
                        [% IF ( suggestion.isbn ) %]ISBN: <em>[% suggestion.isbn | html %]</em> [% END %]
71
                        [% IF ( suggestions_loo.publishercode ) %]<br />published by: [% suggestions_loo.publishercode | html %] [% END %]
71
                        [% IF ( suggestion.publishercode ) %]<br />published by: [% suggestion.publishercode | html %] [% END %]
72
                        [% IF ( suggestions_loo.publicationyear ) %] in <em>[% suggestions_loo.publicationyear | html %]</em> [% END %]
72
                        [% IF ( suggestion.publicationyear ) %] in <em>[% suggestion.publicationyear | html %]</em> [% END %]
73
                        [% IF ( suggestions_loo.place ) %] in <em>[% suggestions_loo.place | html %]</em> [% END %]
73
                        [% IF ( suggestion.place ) %] in <em>[% suggestion.place | html %]</em> [% END %]
74
                        [% IF ( suggestions_loo.note ) %]<p><em>([% suggestions_loo.note | html %])</em></p> [% END %]
74
                        [% IF ( suggestion.note ) %]<p><em>([% suggestion.note | html %])</em></p> [% END %]
75
                    </p>
75
                    </p>
76
                </td>
76
                </td>
77
                <td>[% INCLUDE 'patron-title.inc' patron => suggestion.suggester %]</td>
78
                <td>[% INCLUDE 'patron-title.inc' patron => suggestion.manager %]</td>
77
                <td>
79
                <td>
78
                    [% suggestions_loo.surnamesuggestedby | html %][% IF ( suggestions_loo.firstnamesuggestedby ) %],[% END %] [% suggestions_loo.firstnamesuggestedby | html %]
80
                    [% Branches.GetName(suggestion.branchcode) | html %]
79
                </td>
81
                </td>
80
                <td>
82
                <td>
81
                    [% suggestions_loo.surnamemanagedby | html %][% IF ( suggestions_loo.firstnamemanagedby ) %],[% END %] [% suggestions_loo.firstnamemanagedby | html %]
83
                    [% suggestion.fund.budget_name | html %]
82
                </td>
84
                </td>
83
                <td>
85
                <td>
84
                    [% Branches.GetName(suggestions_loo.branchcode) | html %]
86
                    [% suggestion.price | $Price %]
85
                </td>
87
                </td>
86
                <td>
88
                <td>
87
                    [% suggestions_loo.budget_name | html %]
89
                    [% IF (suggestion.quantity > 0) %]
88
                </td>
90
                        [% suggestion.quantity | html %]
89
                <td>
90
                    [% suggestions_loo.price | $Price %]
91
                </td>
92
                <td>
93
                    [% IF (suggestions_loo.quantity > 0) %]
94
                        [% suggestions_loo.quantity | html %]
95
                    [% END %]
91
                    [% END %]
96
                </td>
92
                </td>
97
                <td>
93
                <td>
98
                    [% suggestions_loo.total | $Price %]
94
                    [% suggestion.total | $Price %]
99
                </td>
95
                </td>
100
                <td class="actions">
96
                <td class="actions">
101
                    [% IF ( suggestions_loo.biblionumber ) %]
97
                    [% IF ( suggestion.biblionumber ) %]
102
                        <a href="neworderempty.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]&amp;suggestionid=[% suggestions_loo.suggestionid | uri %]&amp;biblio=[% suggestions_loo.biblionumber | uri %]" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> [% tp('verb', 'Order') | html %]</a>
98
                        <a href="neworderempty.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]&amp;suggestionid=[% suggestion.suggestionid | uri %]&amp;biblio=[% suggestion.biblionumber | uri %]" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> [% tp('verb', 'Order') | html %]</a>
103
                    [% ELSE %]
99
                    [% ELSE %]
104
                        <a href="neworderempty.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]&amp;suggestionid=[% suggestions_loo.suggestionid | uri %]" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> [% tp('verb', 'Order') | html %]</a>
100
                        <a href="neworderempty.pl?booksellerid=[% booksellerid | uri %]&amp;basketno=[% basketno | uri %]&amp;suggestionid=[% suggestion.suggestionid | uri %]" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> [% tp('verb', 'Order') | html %]</a>
105
                    [% END %]
101
                    [% END %]
106
                </td>
102
                </td>
107
            </tr>
103
            </tr>
Lines 136-142 Link Here
136
        }));
132
        }));
137
        $("#show_only_mine").on('click', function(e){
133
        $("#show_only_mine").on('click', function(e){
138
            e.preventDefault();
134
            e.preventDefault();
139
            suggestionst.fnFilter('^[% loggedinuser | html %]$', 0, true);
135
            suggestionst.fnFilter('^[% logged_in_user.borrowernumber | html %]$', 0, true);
140
        });
136
        });
141
        $("#show_all").on('click', function(e){
137
        $("#show_all").on('click', function(e){
142
            e.preventDefault();
138
            e.preventDefault();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt (-8 / +2 lines)
Lines 42-48 Link Here
42
                    <a class="btn btn-default" id="newsuggestion" href="/cgi-bin/koha/suggestion/suggestion.pl?op=add&amp;suggestedby=[% patron.borrowernumber | html %]&amp;redirect=purchase_suggestions&amp;borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> New purchase suggestion</a>
42
                    <a class="btn btn-default" id="newsuggestion" href="/cgi-bin/koha/suggestion/suggestion.pl?op=add&amp;suggestedby=[% patron.borrowernumber | html %]&amp;redirect=purchase_suggestions&amp;borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-plus"></i> New purchase suggestion</a>
43
                </div>
43
                </div>
44
44
45
                [% IF suggestions %]
45
                [% IF suggestions.size %]
46
                  <table id="suggestions">
46
                  <table id="suggestions">
47
                    <thead>
47
                    <thead>
48
                        <tr>
48
                        <tr>
Lines 79-91 Link Here
79
                                </td>
79
                                </td>
80
                                <td>[% s.note | html %]
80
                                <td>[% s.note | html %]
81
                                <td>
81
                                <td>
82
                                    [% IF ( s.surnamemanagedby ) %]
82
                                    [% INCLUDE 'patron-title.inc' patron => s.manager %]
83
                                        [% s.surnamemanagedby | html %]
84
                                        [% IF ( s.firstnamemanagedby ) %],[% END %]
85
                                        [% s.firstnamemanagedby | html %]
86
                                    [% ELSE %]
87
                                        &nbsp;
88
                                    [% END %]
89
                                </td>
83
                                </td>
90
                                <td data-order="[% s.manageddate | html %]">
84
                                <td data-order="[% s.manageddate | html %]">
91
                                    [% s.manageddate | $KohaDates %]
85
                                    [% s.manageddate | $KohaDates %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-71 / +65 lines)
Lines 707-725 Link Here
707
                                    <span>No name</span>
707
                                    <span>No name</span>
708
                                [% END %]
708
                                [% END %]
709
                            [% END %]
709
                            [% END %]
710
                            ([% suggestion.suggestions_loop.size | html %])
710
                            ([% suggestion.suggestions.size| html %])
711
                            </a>
711
                            </a></li>
712
                            </li>
712
713
                        [% END # /FOREACH suggestion %]
713
                        [% END # /FOREACH suggestion %]
714
                    </ul> <!-- /.ui-tabs-nav -->
714
                    </ul> <!-- /.ui-tabs-nav -->
715
                    <div class="tab-content">
715
                    <div class="tab-content">
716
            [% END # /UNLESS notabs %]
716
            [% END # /UNLESS notabs %]
717
717
718
                [% FOREACH suggestion IN suggestions %]
718
                [% FOREACH suggestion IN suggestions %]
719
                    <div id="[% suggestion.suggestiontype | html %]" role="tabpanel" class="tab-pane">
719
                    <div id="[% suggestion.suggestiontype | html %]">
720
                        <form class="update_suggestions" name="f" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl#[% suggestion.suggestiontype| uri %]">
720
                        <form class="update_suggestions" name="f" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl#[% suggestion.suggestiontype| uri %]">
721
721
722
                            [% IF ( suggestion.suggestions_loop ) %]
722
                            [% IF suggestion.suggestions.size %]
723
                                <p>
723
                                <p>
724
                                    <a class="checkall" href="#">Check all</a> | <a class="uncheckall" href="#">Uncheck all</a>
724
                                    <a class="checkall" href="#">Check all</a> | <a class="uncheckall" href="#">Uncheck all</a>
725
                                </p>
725
                                </p>
Lines 744-857 Link Here
744
                                        </tr>
744
                                        </tr>
745
                                    </thead>
745
                                    </thead>
746
                                    <tbody>
746
                                    <tbody>
747
                                        [% FOREACH suggestions_loo IN suggestion.suggestions_loop %]
747
                                        [% FOREACH s IN suggestion.suggestions %]
748
                                            <tr>
748
                                            <tr>
749
                                                <td>
749
                                                <td>
750
                                                    <input type="checkbox" name="suggestionid" value="[% suggestions_loo.suggestionid | html %]" />
750
                                                    <input type="checkbox" name="suggestionid" value="[% s.suggestionid | html %]" />
751
                                                </td>
751
                                                </td>
752
                                                <td>
752
                                                <td>
753
                                                    <a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | uri %]&amp;op=show" title="suggestion" >
753
                                                    <a href="suggestion.pl?suggestionid=[% s.suggestionid | uri %]&amp;op=show" title="suggestion" >
754
                                                        [% suggestions_loo.title | html %][% IF ( suggestions_loo.author ) %], by [% suggestions_loo.author | html %][% END %]
754
                                                        [% s.title | html %][% IF ( s.author ) %], by [% s.author | html %][% END %]
755
                                                    </a>
755
                                                    </a>
756
                                                    <br />
756
                                                    <br />
757
                                                    [% IF ( suggestions_loo.copyrightdate ) %]
757
                                                    [% IF ( s.copyrightdate ) %]
758
                                                        &copy; <span class="suggestion_copyrightdate">[% suggestions_loo.copyrightdate | html %]</span>
758
                                                        &copy; <span class="suggestion_copyrightdate">[% s.copyrightdate | html %]</span>
759
                                                    [% END %]
759
                                                    [% END %]
760
                                                    [% IF ( suggestions_loo.volumedesc ) %]
760
                                                    [% IF ( s.volumedesc ) %]
761
                                                        ; <span class="suggestion_volume">Volume:<em>[% suggestions_loo.volumedesc | html %]</em></span>
761
                                                        ; <span class="suggestion_volume">Volume:<em>[% s.volumedesc | html %]</em></span>
762
                                                    [% END %]
762
                                                    [% END %]
763
                                                    [% IF ( suggestions_loo.isbn ) %]
763
                                                    [% IF ( s.isbn ) %]
764
                                                        ; <span class="suggestion_isbn">ISBN: <em>[% suggestions_loo.isbn | html %]</em></span>
764
                                                        ; <span class="suggestion_isbn">ISBN: <em>[% s.isbn | html %]</em></span>
765
                                                    [% END %]
765
                                                    [% END %]
766
                                                    [% IF ( suggestions_loo.publishercode ) %]
766
                                                    [% IF ( s.publishercode ) %]
767
                                                        ; <span class="suggestion_publishercode">Published by [% suggestions_loo.publishercode | html %]</span>
767
                                                        ; <span class="suggestion_publishercode">Published by [% s.publishercode | html %]</span>
768
                                                    [% END %]
768
                                                    [% END %]
769
                                                    [% IF ( suggestions_loo.publicationyear ) %]
769
                                                    [% IF ( s.publicationyear ) %]
770
                                                        in <span class="suggestion_publicationyear"><em>[% suggestions_loo.publicationyear | html %]</em></span>
770
                                                        in <span class="suggestion_publicationyear"><em>[% s.publicationyear | html %]</em></span>
771
                                                    [% END %]
771
                                                    [% END %]
772
                                                    [% IF ( suggestions_loo.place ) %]
772
                                                    [% IF ( s.place ) %]
773
                                                        in <span class="suggestion_place"><em>[% suggestions_loo.place | html %]</em></span>
773
                                                        in <span class="suggestion_place"><em>[% s.place | html %]</em></span>
774
                                                    [% END %]
774
                                                    [% END %]
775
                                                    [% IF ( suggestions_loo.collectiontitle ) %]
775
                                                    [% IF ( s.collectiontitle ) %]
776
                                                        ; <span class="suggestion_collectiontitle">[% suggestions_loo.collectiontitle | html %]</span>
776
                                                        ; <span class="suggestion_collectiontitle">[% s.collectiontitle | html %]</span>
777
                                                    [% END %]
777
                                                    [% END %]
778
                                                    [% IF ( suggestions_loo.itemtype ) %]
778
                                                    [% IF ( s.itemtype ) %]
779
                                                        ; <span class="suggestion_itype">[% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 0 ) | html %]</span>
779
                                                        ; <span class="suggestion_itype">[% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', s.itemtype, 0 ) | html %]</span>
780
                                                    [% END %]
780
                                                    [% END %]
781
                                                    <br />
781
                                                    <br />
782
                                                    [% IF ( suggestions_loo.note ) %]
782
                                                    [% IF ( s.note ) %]
783
                                                        <div class="suggestion_note"><i class="fa fa-comment"></i> [% suggestions_loo.note | html %]</div>
783
                                                        <div class="suggestion_note"><i class="fa fa-comment"></i> [% s.note | html %]</div>
784
                                                    [% END %]
784
                                                    [% END %]
785
                                                    [% IF suggestions_loo.archived %]
785
                                                    [% IF s.archived %]
786
                                                        <br /><i class="fa fa-archive"></i> Archived
786
                                                        <br /><i class="fa fa-archive"></i> Archived
787
                                                    [% END %]
787
                                                    [% END %]
788
                                                </td>
788
                                                </td>
789
                                                <td>
789
                                                <td>
790
                                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestions_loo.suggestedby | uri %]">[% suggestions_loo.surnamesuggestedby | html %][% IF ( suggestions_loo.firstnamesuggestedby ) %], [% suggestions_loo.firstnamesuggestedby | html %][% END %] [% IF (suggestions_loo.cardnumbersuggestedby ) %]([% suggestions_loo.cardnumbersuggestedby | html %])[% END %]</a>
790
                                                    [% SET suggester = s.suggester %]
791
                                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggester.borrowernumber | uri %]">[% suggester.surname | html %][% IF suggester.firstname %], [% suggester.firstname | html %][% END %] [% IF suggester.cardnumber %]([% suggester.cardnumber | html %])[% END %]</a>
791
                                                </td>
792
                                                </td>
792
                                                <td data-order="[% suggestions_loo.suggesteddate | html %]">
793
                                                <td data-order="[% s.suggesteddate | html %]">
793
                                                    [% IF ( suggestions_loo.suggesteddate ) %][% suggestions_loo.suggesteddate | $KohaDates %][% END %]
794
                                                    [% IF ( s.suggesteddate ) %][% s.suggesteddate | $KohaDates %][% END %]
794
                                                </td>
795
                                                </td>
795
                                                <td>[% AuthorisedValues.GetByCode( 'OPAC_SUG', suggestions_loo.patronreason ) | html %]</td>
796
                                                <td>[% AuthorisedValues.GetByCode( 'OPAC_SUG', s.patronreason ) | html %]</td>
796
                                                <td>
797
                                                <td>
797
                                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestions_loo.managedby | uri %]">[% suggestions_loo.surnamemanagedby | html %][% IF ( suggestions_loo.firstnamemanagedby ) %], [% suggestions_loo.firstnamemanagedby | html %][% END %]</a>
798
                                                    [% SET manager = s.manager %]
799
                                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% manager.borrowernumber | uri %]">[% manager.surname | html %][% IF manager.firstname %], [% manager.firstname | html %][% END %]</a>
798
                                                </td>
800
                                                </td>
799
                                                <td data-order="[% suggestions_loo.manageddate | html %]">
801
                                                <td data-order="[% s.manageddate | html %]">
800
                                                    [% IF ( suggestions_loo.manageddate ) %][% suggestions_loo.manageddate | $KohaDates %][% END %]
802
                                                    [% IF ( s.manageddate ) %][% s.manageddate | $KohaDates %][% END %]
801
                                                </td>
803
                                                </td>
802
                                                <td>
804
                                                <td>
803
                                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestions_loo.lastmodificationby | uri %]">[% suggestions_loo.surnamelastmodificationby | html %][% IF ( suggestions_loo.firstnamelastmodificationby ) %], [% suggestions_loo.firstnamelastmodificationby | html %][% END %]</a>
805
                                                    [% SET last_modifier = s.last_modifier %]
806
                                                    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% last_modifier.borrowernumber | uri %]">[% last_modifier.surname | html %][% IF last_modifier.firstname %], [% last_modifier.firstname | html %][% END %]</a>
804
                                                </td>
807
                                                </td>
805
                                                <td data-order="[% suggestions_loo.lastmodificationdate | html %]">
808
                                                <td data-order="[% s.lastmodificationdate | html %]">
806
                                                    [% IF ( suggestions_loo.lastmodificationdate ) %][% suggestions_loo.lastmodificationdate | $KohaDates %][% END %]
809
                                                    [% IF ( s.lastmodificationdate ) %][% s.lastmodificationdate | $KohaDates %][% END %]
807
                                                </td>
810
                                                </td>
808
                                                <td>
811
                                                <td>
809
                                                    [% suggestions_loo.date | $KohaDates %]
812
                                                    [% s.lastmodificationdate | $KohaDates %]
810
                                                </td>
813
                                                </td>
811
                                                <td>
814
                                                <td>
812
                                                    [% Branches.GetName( suggestions_loo.branchcode ) | html %]
815
                                                    [% Branches.GetName( s.branchcode ) | html %]
813
                                                </td>
816
                                                </td>
814
                                                <td>
817
                                                <td>
815
                                                    [% suggestions_loo.budget_name | html %]
818
                                                    [% s.fund.budget_name | html %]
816
                                                </td>
819
                                                </td>
817
                                                <td>
820
                                                <td>
818
                                                    [% IF ( suggestions_loo.ASKED ) %]
821
                                                    [% IF s.STATUS == 'ASKED' %]
819
                                                        Pending
822
                                                        Pending
820
                                                    [% ELSIF ( suggestions_loo.ACCEPTED ) %]
823
                                                    [% ELSIF s.STATUS == 'ACCEPTED' %]
821
                                                        Accepted
824
                                                        Accepted
822
                                                    [% ELSIF ( suggestions_loo.ORDERED ) %]
825
                                                    [% ELSIF s.STATUS == 'ORDERED' %]
823
                                                        Ordered
826
                                                        Ordered
824
                                                    [% ELSIF ( suggestions_loo.REJECTED ) %]
827
                                                    [% ELSIF s.STATUS == 'REJECTED' %]
825
                                                        Rejected
828
                                                        Rejected
826
                                                    [% ELSIF ( suggestions_loo.CHECKED ) %]
829
                                                    [% ELSIF s.STATUS == 'CHECKED' %]
827
                                                        Checked
830
                                                        Checked
828
                                                    [% ELSIF ( suggestions_loo.AVAILABLE ) %]
831
                                                    [% ELSIF s.STATUS == 'AVAILABLE' %]
829
                                                        Available
832
                                                        Available
830
                                                    [% ELSIF AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %]
833
                                                    [% ELSIF AuthorisedValues.GetByCode( 'SUGGEST_STATUS', s.STATUS ) %]
831
                                                        [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) | html %]
834
                                                        [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', s.STATUS ) | html %]
832
                                                    [% ELSE %]
835
                                                    [% ELSE %]
833
                                                        Status unknown
836
                                                        Status unknown
834
                                                    [% END %]
837
                                                    [% END %]
835
838
836
                                                    [% IF ( suggestions_loo.reason ) %]
839
                                                    [% IF ( s.reason ) %]
837
                                                        <br />([% suggestions_loo.reason | html %])
840
                                                        <br />([% s.reason | html %])
838
                                                    [% END %]
841
                                                    [% END %]
839
                                                </td>
842
                                                </td>
840
                                                <td class="actions">
843
                                                <td class="actions">
841
                                                    <div class="btn-group dropup">
844
                                                    <div class="btn-group dropup">
842
                                                        <a class="btn btn-default btn-xs" role="button" href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | html %]&amp;op=edit"><i class="fa fa-pencil"></i> Edit</a><a class="btn btn-default btn-xs dropdown-toggle" id="more_actions_[% suggestions_loo.suggestionid | html %]" role="button" data-toggle="dropdown" href="#"><b class="caret"></b></a>
845
                                                        <a class="btn btn-default btn-xs" role="button" href="suggestion.pl?suggestionid=[% s.suggestionid | html %]&amp;op=edit"><i class="fa fa-pencil"></i> Edit</a><a class="btn btn-default btn-xs dropdown-toggle" id="more_actions_[% s.suggestionid | html %]" role="button" data-toggle="dropdown" href="#"><b class="caret"></b></a>
843
                                                        <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="more_actions_[% suggestions_loo.suggestionid | html %]">
846
                                                        <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="more_actions_[% s.suggestionid | html %]">
844
                                                            <li><a class="deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a></li>
847
                                                            <li><a class="deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a></li>
845
                                                            [% UNLESS suggestions_loo.archived %]
848
                                                            [% UNLESS s.archived %]
846
                                                                <li><a class="archivesuggestion" href="suggestion.pl?op=archive&amp;suggestionid=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-archive"></i> Archive</a></li>
849
                                                                <li><a class="archivesuggestion" href="suggestion.pl?op=archive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Archive</a></li>
847
                                                            [% ELSE %]
850
                                                            [% ELSE %]
848
                                                                <li><a class="unarchivesuggestion" href="suggestion.pl?op=unarchive&amp;suggestionid=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-archive"></i> Unarchive</a></li>
851
                                                                <li><a class="unarchivesuggestion" href="suggestion.pl?op=unarchive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Unarchive</a></li>
849
                                                            [% END %]
852
                                                            [% END %]
850
                                                        </ul>
853
                                                        </ul>
851
                                                    </div>
854
                                                    </div>
852
                                                </td>
855
                                                </td>
853
                                            </tr>
856
                                            </tr>
854
                                        [% END # /FOREACH suggestions_loo %]
857
                                        [% END # /FOREACH s %]
855
                                    </tbody>
858
                                    </tbody>
856
                                </table> <!-- /#table_[% loop.count | html %] -->
859
                                </table> <!-- /#table_[% loop.count | html %] -->
857
860
Lines 960-975 Link Here
960
                                            </fieldset>
963
                                            </fieldset>
961
                                        </fieldset>
964
                                        </fieldset>
962
                                    </div> <!-- /.col-sm-2 -->
965
                                    </div> <!-- /.col-sm-2 -->
963
                                    <div class="col-sm-2">
964
                                        <fieldset>
965
                                            <span class="label">Archive selected</span>
966
                                            <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
967
                                            <input type="hidden" name="filter_archived" value="[% filter_archived | html %]" />
968
                                            <fieldset class="action">
969
                                                <button type="submit" class="btn btn-default btn-xs" value="archive">Archive</button>
970
                                            </fieldset>
971
                                        </fieldset>
972
                                    </div> <!-- /.col-sm-2 -->
973
                                </div> <!-- /.row -->
966
                                </div> <!-- /.row -->
974
967
975
                            [% ELSE %]
968
                            [% ELSE %]
Lines 1067-1075 Link Here
1067
                                        <li>
1060
                                        <li>
1068
                                            <label for="archived" style="display: inline;">Include archived:</label>
1061
                                            <label for="archived" style="display: inline;">Include archived:</label>
1069
                                            [% IF filter_archived %]
1062
                                            [% IF filter_archived %]
1070
                                                <input type="checkbox" id="archived" name="filter_archived" checked="checked" title="Include archived suggestions in the search" />
1063
                                                <input type="checkbox" id="archived" value="1" name="filter_archived" checked="checked" title="Include archived suggestions in the search" />
1071
                                            [% ELSE %]
1064
                                            [% ELSE %]
1072
                                                <input type="checkbox" id="archived" name="filter_archived" title="Include archived suggestions in the search" />
1065
                                                <input type="checkbox" id="archived" value="1" name="filter_archived" title="Include archived suggestions in the search" />
1073
                                            [% END %]
1066
                                            [% END %]
1074
                                        </li>
1067
                                        </li>
1075
                                        <li>
1068
                                        <li>
Lines 1321-1329 Link Here
1321
                if( $("#suggestiontabs .tab-pane.active").length < 1 ){
1314
                if( $("#suggestiontabs .tab-pane.active").length < 1 ){
1322
                    $("#suggestiontabs a:first").tab("show");
1315
                    $("#suggestiontabs a:first").tab("show");
1323
                }
1316
                }
1317
1324
                table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %]
1318
                table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %]
1325
                [% FOREACH suggestion IN suggestions %]
1319
                [% FOREACH suggestion IN suggestions %]
1326
                    [% IF ( suggestion.suggestions_loop ) %]
1320
                    [% IF suggestion.suggestions.size %]
1327
                        KohaTable("table_[% loop.count| html %]", {
1321
                        KohaTable("table_[% loop.count| html %]", {
1328
                            "sorting": [[ 3, "asc" ]],
1322
                            "sorting": [[ 3, "asc" ]],
1329
                            "autoWidth": false,
1323
                            "autoWidth": false,
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-34 / +34 lines)
Lines 309-315 Link Here
309
309
310
                            [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
310
                            [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
311
311
312
                            [% IF suggestions_loop OR title_filter %]
312
                            [% IF suggestions.size > 0 OR title_filter %]
313
                                [% SET can_delete_suggestion = 0 %]
313
                                <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" id="search_suggestions_form" method="get">
314
                                <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" id="search_suggestions_form" method="get">
314
                                    <div class="form-row">
315
                                    <div class="form-row">
315
                                        <label for="title_filter">Search for:</label>
316
                                        <label for="title_filter">Search for:</label>
Lines 336-342 Link Here
336
                                    </div>
337
                                    </div>
337
                                </form>
338
                                </form>
338
                            [% END %]
339
                            [% END %]
339
                            [% IF suggestions_loop %]
340
                            [% IF suggestions.size > 0 %]
340
                                [% SET can_delete_suggestion = 0 %]
341
                                [% SET can_delete_suggestion = 0 %]
341
                                <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="delete_suggestions">
342
                                <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="delete_suggestions">
342
                                    <input type="hidden" name="op" value="delete_confirm" />
343
                                    <input type="hidden" name="op" value="delete_confirm" />
Lines 380-453 Link Here
380
                                            </tr>
381
                                            </tr>
381
                                        </thead>
382
                                        </thead>
382
                                        <tbody>
383
                                        <tbody>
383
                                            [% FOREACH suggestions_loo IN suggestions_loop %]
384
                                            [% FOREACH suggestion IN suggestions %]
384
                                                <tr>
385
                                                <tr>
385
                                                    [% IF ( loggedinusername ) %]
386
                                                    [% IF logged_in_user %]
386
                                                        <td class="selectcol">
387
                                                        <td class="selectcol">
387
                                                            [% IF ( suggestions_loo.showcheckbox ) %]
388
                                                            [% IF logged_in_user.borrowernumber == suggestion.suggester.borrowernumber %]
388
                                                                [% SET can_delete_suggestion = 1 %]
389
                                                                [% SET can_delete_suggestion = 1 %]
389
                                                                <input type="checkbox" class="cb" id="id[% suggestions_loo.suggestionid | html %]" name="delete_field" data-title="[% suggestions_loo.title | html %]" value="[% suggestions_loo.suggestionid | html %]" />
390
                                                                <input type="checkbox" class="cb" id="id[% suggestion.suggestionid | html %]" name="delete_field" data-title="[% suggestion.title | html %]" value="[% suggestion.suggestionid | html %]" />
390
                                                            [% END %]
391
                                                            [% END %]
391
                                                        </td>
392
                                                        </td>
392
                                                    [% END %]
393
                                                    [% END %]
393
                                                    <td>
394
                                                    <td>
394
                                                        <p>
395
                                                        <p>
395
                                                            <label for="id[% suggestions_loo.suggestionid | html %]">
396
                                                            <label for="id[% suggestions_loo.suggestionid | html %]">
396
                                                                [% IF suggestions_loo.biblionumber %]
397
                                                                [% IF suggestion.biblionumber %]
397
                                                                    <strong><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% suggestions_loo.biblionumber | uri %]">[% suggestions_loo.title | html %]</a></strong>
398
                                                                    <strong><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% suggestion.biblionumber | uri %]">[% suggestion.title | html %]</a></strong>
398
                                                                [% ELSE %]
399
                                                                [% ELSE %]
399
                                                                    <strong>[% suggestions_loo.title | html %]</strong>
400
                                                                    <strong>[% suggestion.title | html %]</strong>
400
                                                                [% END %]
401
                                                                [% END %]
401
                                                            </label>
402
                                                            </label>
402
                                                        </p>
403
                                                        </p>
403
                                                            <p>[% IF ( suggestions_loo.author ) %][% suggestions_loo.author | html %],[% END %]
404
                                                            <p>[% IF ( suggestion.author ) %][% suggestion.author | html %],[% END %]
404
                                                                [% IF ( suggestions_loo.copyrightdate ) %] - [% suggestions_loo.copyrightdate | html %],[% END %]
405
                                                                [% IF ( suggestion.copyrightdate ) %] - [% suggestion.copyrightdate | html %],[% END %]
405
                                                                [% IF ( suggestions_loo.publishercode ) %] - [% suggestions_loo.publishercode | html %][% END %]
406
                                                                [% IF ( suggestion.publishercode ) %] - [% suggestion.publishercode | html %][% END %]
406
                                                                [% IF ( suggestions_loo.place ) %]([% suggestions_loo.place | html %])[% END %]
407
                                                                [% IF ( suggestion.place ) %]([% suggestion.place | html %])[% END %]
407
                                                                [% IF ( suggestions_loo.collectiontitle ) %] , [% suggestions_loo.collectiontitle | html %][% END %]
408
                                                                [% IF ( suggestion.collectiontitle ) %] , [% suggestion.collectiontitle | html %][% END %]
408
                                                                [% IF ( suggestions_loo.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 1 ) | html %][% END %]
409
                                                                [% IF ( suggestion.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestion.itemtype, 1 ) | html %][% END %]
409
                                                        </p>
410
                                                        </p>
410
                                                    </td>
411
                                                    </td>
411
                                                    <td>
412
                                                    <td>
412
                                                        [% IF ( suggestions_loo.suggesteddate ) %][% suggestions_loo.suggesteddate |$KohaDates %][% END %]
413
                                                        [% IF ( suggestion.suggesteddate ) %][% suggestion.suggesteddate |$KohaDates %][% END %]
413
                                                    </td>
414
                                                    </td>
414
                                                    <td>
415
                                                    <td>
415
                                                        [% IF ( suggestions_loo.note ) %]
416
                                                        [% IF ( suggestion.note ) %]
416
                                                            <span class="tdlabel">Note: </span>
417
                                                            <span class="tdlabel">Note: </span>
417
                                                            [% suggestions_loo.note | html %]
418
                                                            [% suggestion.note | html %]
418
                                                        [% END %]
419
                                                        [% END %]
419
                                                    </td>
420
                                                    </td>
420
                                                    [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
421
                                                    [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
421
                                                        <td>
422
                                                        <td>
422
                                                            [% IF ( suggestions_loo.branchcodesuggestedby ) %]
423
                                                            [% IF suggestion.suggestedby %]
423
                                                                <span class="tdlabel">Suggested for:</span>
424
                                                                <span class="tdlabel">Suggested for:</span>
424
                                                                [% suggestions_loo.branchcodesuggestedby | html %]
425
                                                                [% Branches.GetName(suggestion.suggester.branchcode) | html %]
425
                                                            [% END %]
426
                                                            [% END %]
426
                                                        </td>
427
                                                        </td>
427
                                                    [% END %]
428
                                                    [% END %]
428
                                                    [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
429
                                                    [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
429
                                                    <td>
430
                                                    <td>
430
                                                        [% IF ( suggestions_loo.surnamemanagedby ) %]
431
                                                        [% IF suggestion.managedby %]
431
                                                            <span class="tdlabel">Managed by:</span>
432
                                                            <span class="tdlabel">Managed by:</span>
432
                                                            [% suggestions_loo.surnamemanagedby | html %]
433
                                                            [% INCLUDE 'patron-title.inc' patron = suggestion.manager %]
433
                                                            [% IF ( suggestions_loo.firstnamemanagedby ) %]    , [% suggestions_loo.firstnamemanagedby | html %]
434
                                                            [% IF ( suggestion.manageddate ) %] - [% suggestion.manageddate | $KohaDates %][% END %]
434
                                                            [% END %]
435
                                                        [% END %]
435
                                                        [% END %]
436
                                                    </td>
436
                                                    </td>
437
                                                    [% END %]
437
                                                    [% END %]
438
                                                    <td>
438
                                                    <td>
439
                                                        <span class="tdlabel">Status:</span>
439
                                                        <span class="tdlabel">Status:</span>
440
                                                        [% IF ( suggestions_loo.ASKED ) %]Requested
440
                                                        [% IF ( suggestion.STATUS == 'ASKED' ) %]Requested
441
                                                        [% ELSIF ( suggestions_loo.CHECKED ) %]Checked by the library
441
                                                        [% ELSIF ( suggestion.STATUS == 'CHECKED' ) %]Checked by the library
442
                                                        [% ELSIF ( suggestions_loo.ACCEPTED ) %]Accepted by the library
442
                                                        [% ELSIF ( suggestion.STATUS == 'ACCEPTED' ) %]Accepted by the library
443
                                                        [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library
443
                                                        [% ELSIF ( suggestion.STATUS == 'ORDERED' ) %]Ordered by the library
444
                                                        [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined
444
                                                        [% ELSIF ( suggestion.STATUS == 'REJECTED' ) %]Suggestion declined
445
                                                        [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library
445
                                                        [% ELSIF ( suggestion.STATUS == 'AVAILABLE' ) %]Available in the library
446
                                                        [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) | html %] [% END %]
446
                                                        [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.STATUS, 1 ) | html %] [% END %]
447
                                                        [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason | html %])[% END %]
447
                                                        [% IF ( suggestion.reason ) %]([% suggestion.reason | html %])[% END %]
448
                                                    </td>
448
                                                    </td>
449
                                                </tr>
449
                                                </tr>
450
                                            [% END # / FOREACH suggestions_loo %]
450
                                            [% END # / FOREACH suggestions %]
451
                                        </tbody>
451
                                        </tbody>
452
                                    </table>
452
                                    </table>
453
453
Lines 486-492 Link Here
486
                                        <p><a class="btn btn-link new" href="/cgi-bin/koha/opac-suggestions.pl?op=add"><i class="fa fa-plus" aria-hidden="true"></i> New purchase suggestion</a></p>
486
                                        <p><a class="btn btn-link new" href="/cgi-bin/koha/opac-suggestions.pl?op=add"><i class="fa fa-plus" aria-hidden="true"></i> New purchase suggestion</a></p>
487
                                    [% END %]
487
                                    [% END %]
488
                                [% END %]
488
                                [% END %]
489
                            [% END # / IF suggestions_loop %]
489
                            [% END # / IF suggestions.size %]
490
490
491
                        [% END # IF op_else %]
491
                        [% END # IF op_else %]
492
                    </div> <!-- / #usersuggestions -->
492
                    </div> <!-- / #usersuggestions -->
(-)a/members/deletemem.pl (-6 / +2 lines)
Lines 30-39 use Try::Tiny qw( catch try ); Link Here
30
use C4::Context;
30
use C4::Context;
31
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
31
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
32
use C4::Auth qw( get_template_and_user );
32
use C4::Auth qw( get_template_and_user );
33
use C4::Suggestions;
34
use Koha::Patrons;
33
use Koha::Patrons;
35
use Koha::Token;
34
use Koha::Token;
36
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
36
use Koha::Suggestions;
37
37
38
my $input = CGI->new;
38
my $input = CGI->new;
39
39
Lines 99-109 my $countholds = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE borr Link Here
99
99
100
# Add warning if patron has pending suggestions
100
# Add warning if patron has pending suggestions
101
$template->param(
101
$template->param(
102
    pending_suggestions => scalar @{
102
    pending_suggestions => Koha::Suggestions->search({ suggestedby => $member, STATUS => 'ASKED' })->count,
103
    C4::Suggestions::SearchSuggestion(
104
            { suggestedby => $member, STATUS => 'ASKED' }
105
        )
106
    }
107
);
103
);
108
104
109
$template->param(
105
$template->param(
(-)a/members/purchase-suggestions.pl (-3 / +5 lines)
Lines 23-31 use CGI qw ( -utf8 ); Link Here
23
use C4::Auth qw( get_template_and_user );
23
use C4::Auth qw( get_template_and_user );
24
use C4::Context;
24
use C4::Context;
25
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
25
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
26
use C4::Members;
27
use C4::Suggestions qw( SearchSuggestion );
28
use Koha::Patrons;
26
use Koha::Patrons;
27
use Koha::Suggestions;
29
28
30
my $input = CGI->new;
29
my $input = CGI->new;
31
30
Lines 49-55 $template->param( Link Here
49
    suggestionsview  => 1,
48
    suggestionsview  => 1,
50
);
49
);
51
50
52
my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } );
51
my $suggestions = [
52
    Koha::Suggestions->search_limited( { suggestedby => $borrowernumber },
53
        { prefetch => 'managedby' } )->as_list
54
];
53
55
54
$template->param( suggestions => $suggestions );
56
$template->param( suggestions => $suggestions );
55
57
(-)a/opac/opac-suggestions.pl (-43 / +30 lines)
Lines 28-34 use C4::Suggestions qw( Link Here
28
    DelSuggestion
28
    DelSuggestion
29
    MarcRecordFromNewSuggestion
29
    MarcRecordFromNewSuggestion
30
    NewSuggestion
30
    NewSuggestion
31
    SearchSuggestion
32
);
31
);
33
use C4::Koha qw( GetAuthorisedValues );
32
use C4::Koha qw( GetAuthorisedValues );
34
use C4::Scrubber;
33
use C4::Scrubber;
Lines 100-135 else { Link Here
100
    );
99
    );
101
}
100
}
102
101
102
my $suggested_by;
103
if ( $op eq 'else' ) {
103
if ( $op eq 'else' ) {
104
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
104
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
105
        if ( $borrowernumber ) {
105
        if ( $borrowernumber ) {
106
            # A logged in user is able to see suggestions from others
106
            # A logged in user is able to see suggestions from others
107
            $suggestion->{suggestedby} = $suggested_by_anyone
107
            $suggested_by = $suggested_by_anyone
108
                ? undef
108
                ? undef
109
                : $borrowernumber;
109
                : $borrowernumber;
110
        }
110
        }
111
        else {
111
        # else: Non logged in user is able to see all suggestions
112
            # Non logged in user is able to see all suggestions
113
            $suggestion->{suggestedby} = undef;
114
        }
115
    }
112
    }
116
    else {
113
    else {
117
        if ( $borrowernumber ) {
114
        if ( $borrowernumber ) {
118
            $suggestion->{suggestedby} = $borrowernumber;
115
            $suggested_by = $borrowernumber;
119
        }
116
        }
120
        else {
117
        else {
121
            $suggestion->{suggestedby} = -1;
118
            $suggested_by = -1;
122
        }
119
        }
123
    }
120
    }
124
} else {
121
} else {
125
    if ( $borrowernumber ) {
122
    if ( $borrowernumber ) {
126
        $suggestion->{suggestedby} = $borrowernumber;
123
        $suggested_by = $borrowernumber;
127
    }
124
    }
128
    else {
125
    else {
129
        $suggestion->{suggestedby} = C4::Context->preference("AnonymousPatron");
126
        $suggested_by = C4::Context->preference("AnonymousPatron");
130
    }
127
    }
131
}
128
}
132
129
130
$suggestion = {
131
    map {
132
        my $p = $suggestion->{$_};
133
        # Keep parameters that are not an empty string
134
        ( defined $p && $p ne '' ? ( $_ => $p ) : () )
135
    } keys %$suggestion
136
};
137
$suggestion->{suggestedby} = $borrowernumber;
138
133
if ( $op eq "add_validate" && not $biblionumber ) { # If we are creating the suggestion from an existing record we do not want to search for duplicates
139
if ( $op eq "add_validate" && not $biblionumber ) { # If we are creating the suggestion from an existing record we do not want to search for duplicates
134
    $op = 'add_confirm';
140
    $op = 'add_confirm';
135
    my $biblio = MarcRecordFromNewSuggestion($suggestion);
141
    my $biblio = MarcRecordFromNewSuggestion($suggestion);
Lines 155-161 if ( $borrowernumber ){ Link Here
155
}
161
}
156
162
157
if ( $op eq "add_confirm" ) {
163
if ( $op eq "add_confirm" ) {
158
    my $suggestions_loop = &SearchSuggestion($suggestion);
164
    my $suggestions = Koha::Suggestions->search($suggestion);
159
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && $patrons_total_suggestions_count >= C4::Context->preference("MaxTotalSuggestions") )
165
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && $patrons_total_suggestions_count >= C4::Context->preference("MaxTotalSuggestions") )
160
    {
166
    {
161
        push @messages, { type => 'error', code => 'total_suggestions' };
167
        push @messages, { type => 'error', code => 'total_suggestions' };
Lines 164-178 if ( $op eq "add_confirm" ) { Link Here
164
    {
170
    {
165
        push @messages, { type => 'error', code => 'too_many' };
171
        push @messages, { type => 'error', code => 'too_many' };
166
    }
172
    }
167
    elsif ( @$suggestions_loop >= 1 ) {
173
    elsif ( $suggestions->count >= 1 ) {
168
174
169
        #some suggestion are answering the request Donot Add
175
        #some suggestion are answering the request Donot Add
170
        for my $s (@$suggestions_loop) {
176
        while ( my $suggestion = $suggestions->next ) {
171
            push @messages,
177
            push @messages,
172
              {
178
              {
173
                type => 'error',
179
                type => 'error',
174
                code => 'already_exists',
180
                code => 'already_exists',
175
                id   => $s->{suggestionid}
181
                id   => $suggestion->suggestionid
176
              };
182
              };
177
            last;
183
            last;
178
        }
184
        }
Lines 197-220 if ( $op eq "add_confirm" ) { Link Here
197
        $patrons_pending_suggestions_count++;
203
        $patrons_pending_suggestions_count++;
198
        $patrons_total_suggestions_count++;
204
        $patrons_total_suggestions_count++;
199
205
200
        # delete empty fields, to avoid filter in "SearchSuggestion"
201
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
202
            delete $suggestion->{$field}; #clear search filters (except borrower related) to show all suggestions after placing a new one
203
        }
204
        $suggestions_loop = &SearchSuggestion($suggestion);
205
206
        push @messages, { type => 'info', code => 'success_on_inserted' };
206
        push @messages, { type => 'info', code => 'success_on_inserted' };
207
207
208
    }
208
    }
209
    $op = 'else';
209
    $op = 'else';
210
}
210
}
211
211
212
my $suggestions_loop = &SearchSuggestion(
212
my $suggestions = [ Koha::Suggestions->search_limited(
213
    {
213
    {
214
        suggestedby => $suggestion->{suggestedby},
214
        $suggestion->{suggestedby}
215
        title       => $title_filter,
215
        ? ( suggestedby => $suggestion->{suggestedby} )
216
        : (),
217
        $title_filter
218
        ? ( title       => $title_filter )
219
        : (),
216
    }
220
    }
217
);
221
)->as_list ];
222
218
if ( $op eq "delete_confirm" ) {
223
if ( $op eq "delete_confirm" ) {
219
    my @delete_field = $input->multi_param("delete_field");
224
    my @delete_field = $input->multi_param("delete_field");
220
    foreach my $delete_field (@delete_field) {
225
    foreach my $delete_field (@delete_field) {
Lines 225-248 if ( $op eq "delete_confirm" ) { Link Here
225
    exit;
230
    exit;
226
}
231
}
227
232
228
map{
229
    my $s = $_;
230
    my $library = Koha::Libraries->find($s->{branchcodesuggestedby});
231
    $library ? $s->{branchcodesuggestedby} = $library->branchname : ()
232
} @$suggestions_loop;
233
234
foreach my $suggestion(@$suggestions_loop) {
235
    if($suggestion->{'suggestedby'} == $borrowernumber) {
236
        $suggestion->{'showcheckbox'} = $borrowernumber;
237
    } else {
238
        $suggestion->{'showcheckbox'} = 0;
239
    }
240
    if($suggestion->{'patronreason'}){
241
        my $av = Koha::AuthorisedValues->search({ category => 'OPAC_SUG', authorised_value => $suggestion->{patronreason} });
242
        $suggestion->{'patronreason'} = $av->count ? $av->next->opac_description : '';
243
    }
244
}
245
246
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG", "opac");
233
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG", "opac");
247
234
248
my @mandatoryfields;
235
my @mandatoryfields;
Lines 279-285 my @unwantedfields; Link Here
279
266
280
$template->param(
267
$template->param(
281
    %$suggestion,
268
    %$suggestion,
282
    suggestions_loop      => $suggestions_loop,
269
    suggestions           => $suggestions,
283
    patron_reason_loop    => $patron_reason_loop,
270
    patron_reason_loop    => $patron_reason_loop,
284
    "op_$op"              => 1,
271
    "op_$op"              => 1,
285
    $op                   => 1,
272
    $op                   => 1,
(-)a/suggestion/suggestion.pl (-22 / +61 lines)
Lines 92-98 my $displayby = $input->param('displayby') || ''; Link Here
92
my $tabcode         = $input->param('tabcode');
92
my $tabcode         = $input->param('tabcode');
93
my $save_confirmed  = $input->param('save_confirmed') || 0;
93
my $save_confirmed  = $input->param('save_confirmed') || 0;
94
my $notify          = $input->param('notify');
94
my $notify          = $input->param('notify');
95
my $filter_archived = $input->param('filter_archived');
95
my $filter_archived = $input->param('filter_archived') || 0;
96
96
97
my $reasonsloop     = GetAuthorisedValues("SUGGEST");
97
my $reasonsloop     = GetAuthorisedValues("SUGGEST");
98
98
Lines 109-114 delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode notif Link Here
109
foreach (keys %$suggestion_ref){
109
foreach (keys %$suggestion_ref){
110
    delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' ));
110
    delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' ));
111
}
111
}
112
delete $suggestion_only->{branchcode} if $suggestion_only->{branchcode} eq '__ANY__';
113
delete $suggestion_only->{budgetid}   if $suggestion_only->{budgetid}   eq '__ANY__';
114
while ( my ( $k, $v ) = each %$suggestion_only ) {
115
    delete $suggestion_only->{$k} if $v eq '';
116
}
117
112
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user(
118
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user(
113
        {
119
        {
114
            template_name   => "suggestion/suggestion.tt",
120
            template_name   => "suggestion/suggestion.tt",
Lines 213-225 if ( $op =~ /save/i ) { Link Here
213
            }
219
            }
214
        } else {
220
        } else {
215
            ###FIXME:Search here if suggestion already exists.
221
            ###FIXME:Search here if suggestion already exists.
216
            my $suggestions_loop =
222
            my $suggestions= Koha::Suggestions->search_limited( $suggestion_only );
217
                SearchSuggestion( $suggestion_only );
223
            if ( $suggestions->count ) {
218
            if (@$suggestions_loop>=1){
219
                #some suggestion are answering the request Donot Add
224
                #some suggestion are answering the request Donot Add
220
                my @messages;
225
                my @messages;
221
                for my $suggestion ( @$suggestions_loop ) {
226
                while ( my $suggestion = $suggestions->next ) {
222
                    push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
227
                    push @messages, { type => 'error', code => 'already_exists', id => $suggestion->suggestionid };
223
                }
228
                }
224
                $template->param( messages => \@messages );
229
                $template->param( messages => \@messages );
225
            }
230
            }
Lines 362-392 if ($op=~/else/) { Link Here
362
        unshift @criteria_dv, 'ASKED';
367
        unshift @criteria_dv, 'ASKED';
363
    }
368
    }
364
369
370
    unless ( exists $suggestion_ref->{branchcode} ) {
371
        $suggestion_ref->{branchcode} = C4::Context->userenv->{'branch'};
372
    }
373
365
    my @allsuggestions;
374
    my @allsuggestions;
366
    foreach my $criteriumvalue ( @criteria_dv ) {
375
    foreach my $criteriumvalue ( @criteria_dv ) {
376
        my $search_params = {%$suggestion_ref};
367
        # By default, display suggestions from current working branch
377
        # By default, display suggestions from current working branch
368
        unless ( exists $$suggestion_ref{'branchcode'} ) {
369
            $$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'};
370
        }
371
        my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne "";
378
        my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne "";
372
379
373
        next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue ) and ($displayby ne 'branchcode' && $branchfilter ne '__ANY__' );
380
        next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue ) and ($displayby ne 'branchcode' && $branchfilter ne '__ANY__' );
374
        $$suggestion_ref{$displayby} = $criteriumvalue;
375
381
376
        my $suggestions = &SearchSuggestion({ %$suggestion_ref, archived => $filter_archived });
382
        $search_params->{$displayby} = $criteriumvalue;
377
        foreach my $suggestion (@$suggestions) {
383
378
            if ($suggestion->{budgetid}){
384
        # filter on date fields
379
                my $bud = GetBudget( $suggestion->{budgetid} );
385
        foreach my $field (qw( suggesteddate manageddate accepteddate )) {
380
                $suggestion->{budget_name} = $bud->{budget_name} if $bud;
386
            my $from = $field . "_from";
387
            my $to   = $field . "_to";
388
            my $from_dt =
389
              $suggestion_ref->{$from}
390
              ? eval { dt_from_string( $suggestion_ref->{$from} ) }
391
              : undef;
392
            my $to_dt =
393
              $suggestion_ref->{$to}
394
              ? eval { dt_from_string( $suggestion_ref->{$to} ) }
395
              : undef;
396
397
            if ( $from_dt || $to_dt ) {
398
                my $dtf = Koha::Database->new->schema->storage->datetime_parser;
399
                if ( $from_dt && $to_dt ) {
400
                    $search_params->{$field} = { -between => [ $from_dt, $to_dt ] };
401
                } elsif ( $from_dt ) {
402
                    $search_params->{$field} = { '>=' => $from_dt };
403
                } elsif ( $to_dt ) {
404
                    $search_params->{$field} = { '<=' => $to_dt };
405
                }
381
            }
406
            }
382
        }
407
        }
383
        push @allsuggestions,{
408
        if ( $search_params->{budgetid} && $search_params->{budgetid} eq '__NONE__' ) {
384
                            "suggestiontype"=>$criteriumvalue||"suggest",
409
            $search_params->{budgetid} = [undef, '' ];
385
                            "suggestiontypelabel"=>GetCriteriumDesc($criteriumvalue,$displayby)||"",
410
        }
386
                            "suggestionscount"=>scalar(@$suggestions),             
411
        for my $f (qw (branchcode budgetid)) {
387
                            'suggestions_loop'=>$suggestions,
412
            delete $search_params->{$f}
388
                            'reasonsloop'     => $reasonsloop,
413
              if $search_params->{$f} eq '__ANY__'
389
                            } if @$suggestions;
414
              || $search_params->{$f} eq '';
415
        }
416
417
        my @suggestions =
418
          Koha::Suggestions->search_limited(
419
            { %$search_params, archived => $filter_archived } )->as_list;
420
421
        push @allsuggestions,
422
          {
423
            "suggestiontype"      => $criteriumvalue || "suggest",
424
            "suggestiontypelabel" => GetCriteriumDesc( $criteriumvalue, $displayby ) || "",
425
            'suggestions'         => \@suggestions,
426
            'reasonsloop'         => $reasonsloop,
427
          }
428
          if scalar @suggestions > 0;
390
429
391
        delete $$suggestion_ref{$displayby} unless $definedvalue;
430
        delete $$suggestion_ref{$displayby} unless $definedvalue;
392
    }
431
    }
(-)a/t/db_dependent/Suggestions.t (-70 / +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 => 106;
21
use Test::More tests => 90;
22
use Test::Warn;
22
use Test::Warn;
23
23
24
use t::lib::Mocks;
24
use t::lib::Mocks;
Lines 34-40 use Koha::Patrons; Link Here
34
use Koha::Suggestions;
34
use Koha::Suggestions;
35
35
36
BEGIN {
36
BEGIN {
37
    use_ok('C4::Suggestions', qw( NewSuggestion GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio SearchSuggestion DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
37
    use_ok('C4::Suggestions', qw( NewSuggestion GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
38
}
38
}
39
39
40
my $schema  = Koha::Database->new->schema;
40
my $schema  = Koha::Database->new->schema;
Lines 329-401 is( $connect_suggestion_and_biblio, '1', 'ConnectSuggestionAndBiblio returns 1' Link Here
329
$suggestion = GetSuggestion($my_suggestionid);
329
$suggestion = GetSuggestion($my_suggestionid);
330
is( $suggestion->{biblionumber}, $biblio_2->biblionumber, 'ConnectSuggestionAndBiblio updates the biblio number correctly' );
330
is( $suggestion->{biblionumber}, $biblio_2->biblionumber, 'ConnectSuggestionAndBiblio updates the biblio number correctly' );
331
331
332
my $search_suggestion = SearchSuggestion();
333
is( @$search_suggestion, 3, 'SearchSuggestion without arguments returns all suggestions' );
334
335
$search_suggestion = SearchSuggestion({
336
    title => $mod_suggestion1->{title},
337
});
338
is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' );
339
$search_suggestion = SearchSuggestion({
340
    title => 'another title',
341
});
342
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
343
344
$search_suggestion = SearchSuggestion({
345
    author => $mod_suggestion1->{author},
346
});
347
is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' );
348
$search_suggestion = SearchSuggestion({
349
    author => 'another author',
350
});
351
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
352
353
$search_suggestion = SearchSuggestion({
354
    publishercode => $mod_suggestion1->{publishercode},
355
});
356
is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' );
357
$search_suggestion = SearchSuggestion({
358
    publishercode => 'another publishercode',
359
});
360
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
361
362
$search_suggestion = SearchSuggestion({
363
    STATUS => $mod_suggestion3->{STATUS},
364
});
365
is( @$search_suggestion, 2, 'SearchSuggestion returns the correct number of suggestions' );
366
367
$search_suggestion = SearchSuggestion({
368
    STATUS => q||
369
});
370
is( @$search_suggestion, 0, 'SearchSuggestion should not return all suggestions if we want the suggestions with a STATUS=""' );
371
$search_suggestion = SearchSuggestion({
372
    STATUS => 'REJECTED',
373
});
374
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
375
376
$search_suggestion = SearchSuggestion({
377
    budgetid => '',
378
});
379
is( @$search_suggestion, 3, 'SearchSuggestion (budgetid = "") returns the correct number of suggestions' );
380
$search_suggestion = SearchSuggestion({
381
    budgetid => $budget_id,
382
});
383
is( @$search_suggestion, 2, 'SearchSuggestion (budgetid = $budgetid) returns the correct number of suggestions' );
384
$search_suggestion = SearchSuggestion({
385
    budgetid => '__NONE__',
386
});
387
is( @$search_suggestion, 1, 'SearchSuggestion (budgetid = "__NONE__") returns the correct number of suggestions' );
388
$search_suggestion = SearchSuggestion({
389
    budgetid => '__ANY__',
390
});
391
is( @$search_suggestion, 3, 'SearchSuggestion (budgetid = "__ANY__") returns the correct number of suggestions' );
392
393
$search_suggestion = SearchSuggestion({ budgetid => $budget_id });
394
is( @$search_suggestion[0]->{budget_name}, GetBudget($budget_id)->{budget_name}, 'SearchSuggestion returns the correct budget name');
395
$search_suggestion = SearchSuggestion({ budgetid => "__NONE__" });
396
is( @$search_suggestion[0]->{budget_name}, undef, 'SearchSuggestion returns the correct budget name');
397
398
399
my $del_suggestion = {
332
my $del_suggestion = {
400
    title => 'my deleted title',
333
    title => 'my deleted title',
401
    STATUS => 'CHECKED',
334
    STATUS => 'CHECKED',
402
- 

Return to bug 23991