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

(-)a/C4/Suggestions.pm (-151 lines)
Lines 43-49 our @EXPORT = qw( Link Here
43
  ModStatus
43
  ModStatus
44
  ModSuggestion
44
  ModSuggestion
45
  NewSuggestion
45
  NewSuggestion
46
  SearchSuggestion
47
  DelSuggestionsOlderThan
46
  DelSuggestionsOlderThan
48
  GetUnprocessedSuggestions
47
  GetUnprocessedSuggestions
49
  MarcRecordFromNewSuggestion
48
  MarcRecordFromNewSuggestion
Lines 74-229 Suggestions done by other borrowers can be seen when not "AVAILABLE" Link Here
74
73
75
=head1 FUNCTIONS
74
=head1 FUNCTIONS
76
75
77
=head2 SearchSuggestion
78
79
(\@array) = &SearchSuggestion($suggestionhashref_to_search)
80
81
searches for a suggestion
82
83
return :
84
C<\@array> : the aqorders found. Array of hash.
85
Note the status is stored twice :
86
* in the status field
87
* as parameter ( for example ASKED => 1, or REJECTED => 1) . This is for template & translation purposes.
88
89
=cut
90
91
sub SearchSuggestion {
92
    my ($suggestion) = @_;
93
    my $dbh = C4::Context->dbh;
94
    my @sql_params;
95
    my @query = (
96
        q{
97
        SELECT suggestions.*,
98
            U1.branchcode       AS branchcodesuggestedby,
99
            B1.branchname       AS branchnamesuggestedby,
100
            U1.surname          AS surnamesuggestedby,
101
            U1.firstname        AS firstnamesuggestedby,
102
            U1.cardnumber       AS cardnumbersuggestedby,
103
            U1.email            AS emailsuggestedby,
104
            U1.borrowernumber   AS borrnumsuggestedby,
105
            U1.categorycode     AS categorycodesuggestedby,
106
            C1.description      AS categorydescriptionsuggestedby,
107
            U2.surname          AS surnamemanagedby,
108
            U2.firstname        AS firstnamemanagedby,
109
            B2.branchname       AS branchnamesuggestedby,
110
            U2.email            AS emailmanagedby,
111
            U2.branchcode       AS branchcodemanagedby,
112
            U2.borrowernumber   AS borrnummanagedby,
113
            U3.surname          AS surnamelastmodificationby,
114
            U3.firstname        AS firstnamelastmodificationby,
115
            BU.budget_name      AS budget_name
116
        FROM suggestions
117
            LEFT JOIN borrowers     AS U1 ON suggestedby=U1.borrowernumber
118
            LEFT JOIN branches      AS B1 ON B1.branchcode=U1.branchcode
119
            LEFT JOIN categories    AS C1 ON C1.categorycode=U1.categorycode
120
            LEFT JOIN borrowers     AS U2 ON managedby=U2.borrowernumber
121
            LEFT JOIN branches      AS B2 ON B2.branchcode=U2.branchcode
122
            LEFT JOIN categories    AS C2 ON C2.categorycode=U2.categorycode
123
            LEFT JOIN borrowers     AS U3 ON lastmodificationby=U3.borrowernumber
124
            LEFT JOIN aqbudgets     AS BU ON budgetid=BU.budget_id
125
        WHERE 1=1
126
    }
127
    );
128
129
    # filter on biblio informations
130
    foreach my $field (
131
        qw( title author isbn publishercode copyrightdate collectiontitle ))
132
    {
133
        if ( $suggestion->{$field} ) {
134
            push @sql_params, '%' . $suggestion->{$field} . '%';
135
            push @query,      qq{ AND suggestions.$field LIKE ? };
136
        }
137
    }
138
139
    # filter on user branch
140
    if (   C4::Context->preference('IndependentBranches')
141
        && !C4::Context->IsSuperLibrarian() )
142
    {
143
        # If IndependentBranches is set and the logged in user is not superlibrarian
144
        # Then we want to filter by the user's library (i.e. cannot see suggestions from other libraries)
145
        my $userenv = C4::Context->userenv;
146
        if ($userenv) {
147
            {
148
                push @sql_params, $$userenv{branch};
149
                push @query,      q{
150
                    AND (suggestions.branchcode=? OR suggestions.branchcode='')
151
                };
152
            }
153
        }
154
    }
155
    elsif (defined $suggestion->{branchcode}
156
        && $suggestion->{branchcode}
157
        && $suggestion->{branchcode} ne '__ANY__' )
158
    {
159
        # If IndependentBranches is not set OR the logged in user is not superlibrarian
160
        # AND the branchcode filter is passed and not '__ANY__'
161
        # Then we want to filter using this parameter
162
        push @sql_params, $suggestion->{branchcode};
163
        push @query,      qq{ AND suggestions.branchcode=? };
164
    }
165
166
    # filter on nillable fields
167
    foreach my $field (
168
        qw( STATUS itemtype suggestedby managedby acceptedby budgetid biblionumber )
169
      )
170
    {
171
        if ( exists $suggestion->{$field}
172
                and defined $suggestion->{$field}
173
                and $suggestion->{$field} ne '__ANY__'
174
                and (
175
                    $suggestion->{$field} ne q||
176
                        or $field eq 'STATUS'
177
                )
178
        ) {
179
            if ( $suggestion->{$field} eq '__NONE__' ) {
180
                push @query, qq{ AND (suggestions.$field = '' OR suggestions.$field IS NULL) };
181
            }
182
            else {
183
                push @sql_params, $suggestion->{$field};
184
                push @query, qq{ AND suggestions.$field = ? };
185
            }
186
        }
187
    }
188
189
    # filter on date fields
190
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
191
    foreach my $field (qw( suggesteddate manageddate accepteddate )) {
192
        my $from = $field . "_from";
193
        my $to   = $field . "_to";
194
        my $from_dt;
195
        $from_dt = eval { dt_from_string( $suggestion->{$from} ) } if ( $suggestion->{$from} );
196
        my $to_dt;
197
        $to_dt = eval { dt_from_string( $suggestion->{$to} ) } if ( $suggestion->{$to} );
198
        if ( $from_dt ) {
199
            push @query, qq{ AND suggestions.$field >= ?};
200
            push @sql_params, $dtf->format_date($from_dt);
201
        }
202
        if ( $to_dt ) {
203
            push @query, qq{ AND suggestions.$field <= ?};
204
            push @sql_params, $dtf->format_date($to_dt);
205
        }
206
    }
207
208
    # By default do not search for archived suggestions
209
    unless ( exists $suggestion->{archived} && $suggestion->{archived} ) {
210
        push @query, q{ AND suggestions.archived = 0 };
211
    }
212
213
    $debug && warn "@query";
214
    my $sth = $dbh->prepare("@query");
215
    $sth->execute(@sql_params);
216
    my @results;
217
218
    # add status as field
219
    while ( my $data = $sth->fetchrow_hashref ) {
220
        $data->{ $data->{STATUS} } = 1;
221
        push( @results, $data );
222
    }
223
224
    return ( \@results );
225
}
226
227
=head2 GetSuggestion
76
=head2 GetSuggestion
228
77
229
\%sth = &GetSuggestion($suggestionid)
78
\%sth = &GetSuggestion($suggestionid)
(-)a/Koha/Suggestions.pm (+21 lines)
Lines 33-38 Koha::Suggestions - Koha Suggestion object set class Link Here
33
33
34
=head1 API
34
=head1 API
35
35
36
=cut
37
38
sub search_limited {
39
    my ( $self, $params, $attributes ) = @_;
40
41
    $attributes //= {};
42
    # filter on user branch
43
    if (   C4::Context->preference('IndependentBranches')
44
        && !C4::Context->IsSuperLibrarian() )
45
    {
46
        # If IndependentBranches is set and the logged in user is not superlibrarian
47
        # Then we want to filter by the user's library (i.e. cannot see suggestions from other libraries)
48
        my $userenv = C4::Context->userenv;
49
        if ( $userenv ) {
50
            $params->{branchcode} = { -or => [ $userenv->{branch}, '' ] };
51
        }
52
    }
53
54
    return $self->search($params, $attributes);
55
}
56
36
=head2 Class Methods
57
=head2 Class Methods
37
58
38
=cut
59
=cut
(-)a/acqui/newordersuggestion.pl (-9 / +9 lines)
Lines 98-103 use C4::Biblio; Link Here
98
use C4::Budgets;
98
use C4::Budgets;
99
99
100
use Koha::Acquisition::Booksellers;
100
use Koha::Acquisition::Booksellers;
101
use Koha::Suggestions;
101
102
102
my $input = CGI->new;
103
my $input = CGI->new;
103
104
Lines 128-150 if ( $op eq 'connectDuplicate' ) { Link Here
128
    ConnectSuggestionAndBiblio( $suggestionid, $duplicateNumber );
129
    ConnectSuggestionAndBiblio( $suggestionid, $duplicateNumber );
129
}
130
}
130
131
131
# getting all suggestions.
132
my $suggestions = Koha::Suggestions->search_limited(
132
my $suggestions_loop = SearchSuggestion(
133
    {
133
    {
134
        author        => $author,
134
        ( $author        ? ( author        => $author )        : () ),
135
        title         => $title,
135
        ( $title         ? ( title         => $title )         : () ),
136
        publishercode => $publishercode,
136
        ( $publishercode ? ( publishercode => $publishercode ) : () ),
137
        STATUS        => 'ACCEPTED'
137
        STATUS => 'ACCEPTED'
138
    }
138
    },
139
    { prefetch => ['managedby', 'suggestedby'] },
139
);
140
);
140
141
141
my $vendor = Koha::Acquisition::Booksellers->find( $booksellerid );
142
my $vendor = Koha::Acquisition::Booksellers->find( $booksellerid );
142
$template->param(
143
$template->param(
143
    suggestions_loop        => $suggestions_loop,
144
    suggestions             => $suggestions,
144
    basketno                => $basketno,
145
    basketno                => $basketno,
145
    booksellerid              => $booksellerid,
146
    booksellerid              => $booksellerid,
146
    name                    => $vendor->name,
147
    name                    => $vendor->name,
147
    loggedinuser            => $borrowernumber,
148
    "op_$op"                => 1,
148
    "op_$op"                => 1,
149
);
149
);
150
150
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersuggestion.tt (-27 / +23 lines)
Lines 21-27 Link Here
21
            <main>
21
            <main>
22
22
23
<h1>Suggestions</h1>
23
<h1>Suggestions</h1>
24
    [% IF ( suggestions_loop ) %]
24
    [% IF suggestions.count %]
25
    <a href="#" id="show_only_mine">Show only mine</a> | <a href="#" id="show_all">Show all suggestions</a>
25
    <a href="#" id="show_only_mine">Show only mine</a> | <a href="#" id="show_all">Show all suggestions</a>
26
    <table id="suggestionst">
26
    <table id="suggestionst">
27
        <thead>
27
        <thead>
Lines 39-87 Link Here
39
        </tr>
39
        </tr>
40
        </thead>
40
        </thead>
41
        <tbody>
41
        <tbody>
42
        [% FOREACH suggestions_loo IN suggestions_loop %]
42
        [% FOREACH suggestion IN suggestions %]
43
            <tr>
43
            <tr>
44
                <td>[% suggestions_loo.managedby | html %]</td>
44
                <td>[% suggestion.managedby | html %]</td>
45
                <td>
45
                <td>
46
                    <p>[% suggestions_loo.title | html %] - [% suggestions_loo.author | html %]</p>
46
                    <p>[% suggestion.title | html %] - [% suggestion.author | html %]</p>
47
                    <p>
47
                    <p>
48
                        [% IF ( suggestions_loo.copyrightdate ) %]&copy; [% suggestions_loo.copyrightdate | html %] [% END %]
48
                        [% IF ( suggestion.copyrightdate ) %]&copy; [% suggestion.copyrightdate | html %] [% END %]
49
                        [% IF ( suggestions_loo.volumedesc ) %]volume: <em>[% suggestions_loo.volumedesc | html %]</em> [% END %]
49
                        [% IF ( suggestion.volumedesc ) %]volume: <em>[% suggestion.volumedesc | html %]</em> [% END %]
50
                        [% IF ( suggestions_loo.isbn ) %]ISBN: <em>[% suggestions_loo.isbn | html %]</em> [% END %]
50
                        [% IF ( suggestion.isbn ) %]ISBN: <em>[% suggestion.isbn | html %]</em> [% END %]
51
                        [% IF ( suggestions_loo.publishercode ) %]<br />published by: [% suggestions_loo.publishercode | html %] [% END %]
51
                        [% IF ( suggestion.publishercode ) %]<br />published by: [% suggestion.publishercode | html %] [% END %]
52
                        [% IF ( suggestions_loo.publicationyear ) %] in <em>[% suggestions_loo.publicationyear | html %]</em> [% END %]
52
                        [% IF ( suggestion.publicationyear ) %] in <em>[% suggestion.publicationyear | html %]</em> [% END %]
53
                        [% IF ( suggestions_loo.place ) %] in <em>[% suggestions_loo.place | html %]</em> [% END %]
53
                        [% IF ( suggestion.place ) %] in <em>[% suggestion.place | html %]</em> [% END %]
54
                        [% IF ( suggestions_loo.note ) %]<p><em>([% suggestions_loo.note | html %])</em></p> [% END %]
54
                        [% IF ( suggestion.note ) %]<p><em>([% suggestion.note | html %])</em></p> [% END %]
55
                    </p>
55
                    </p>
56
                </td>
56
                </td>
57
                <td>[% INCLUDE 'patron-title.inc' patron => suggestion.suggester %]</td>
58
                <td>[% INCLUDE 'patron-title.inc' patron => suggestion.manager %]</td>
57
                <td>
59
                <td>
58
                    [% suggestions_loo.surnamesuggestedby | html %][% IF ( suggestions_loo.firstnamesuggestedby ) %],[% END %] [% suggestions_loo.firstnamesuggestedby | html %]
60
                    [% Branches.GetName(suggestion.branchcode) | html %]
59
                </td>
61
                </td>
60
                <td>
62
                <td>
61
                    [% suggestions_loo.surnamemanagedby | html %][% IF ( suggestions_loo.firstnamemanagedby ) %],[% END %] [% suggestions_loo.firstnamemanagedby | html %]
63
                    [% suggestion.fund.budget_name | html %]
62
                </td>
64
                </td>
63
                <td>
65
                <td>
64
                    [% Branches.GetName(suggestions_loo.branchcode) | html %]
66
                    [% suggestion.price | $Price %]
65
                </td>
67
                </td>
66
                <td>
68
                <td>
67
                    [% suggestions_loo.budget_name | html %]
69
                    [% IF (suggestion.quantity > 0) %]
68
                </td>
70
                        [% suggestion.quantity | html %]
69
                <td>
70
                    [% suggestions_loo.price | $Price %]
71
                </td>
72
                <td>
73
                    [% IF (suggestions_loo.quantity > 0) %]
74
                        [% suggestions_loo.quantity | html %]
75
                    [% END %]
71
                    [% END %]
76
                </td>
72
                </td>
77
                <td>
73
                <td>
78
                    [% suggestions_loo.total | $Price %]
74
                    [% suggestion.total | $Price %]
79
                </td>
75
                </td>
80
                <td class="actions">
76
                <td class="actions">
81
                    [% IF ( suggestions_loo.biblionumber ) %]
77
                    [% IF ( suggestion.biblionumber ) %]
82
                        <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>
78
                        <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>
83
                    [% ELSE %]
79
                    [% ELSE %]
84
                        <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>
80
                        <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>
85
                    [% END %]
81
                    [% END %]
86
                </td>
82
                </td>
87
            </tr>
83
            </tr>
Lines 116-122 Link Here
116
        }));
112
        }));
117
        $("#show_only_mine").on('click', function(e){
113
        $("#show_only_mine").on('click', function(e){
118
            e.preventDefault();
114
            e.preventDefault();
119
            suggestionst.fnFilter('^[% loggedinuser | html %]$', 0, true);
115
            suggestionst.fnFilter('^[% logged_in_user.borrowernumber | html %]$', 0, true);
120
        });
116
        });
121
        $("#show_all").on('click', function(e){
117
        $("#show_all").on('click', function(e){
122
            e.preventDefault();
118
            e.preventDefault();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/purchase-suggestions.tt (-8 / +2 lines)
Lines 32-38 Link Here
32
                    <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>
32
                    <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>
33
                </div>
33
                </div>
34
34
35
                [% IF suggestions %]
35
                [% IF suggestions.count %]
36
                  <table id="suggestions">
36
                  <table id="suggestions">
37
                    <thead>
37
                    <thead>
38
                        <tr>
38
                        <tr>
Lines 69-81 Link Here
69
                                </td>
69
                                </td>
70
                                <td>[% s.note | html %]
70
                                <td>[% s.note | html %]
71
                                <td>
71
                                <td>
72
                                    [% IF ( s.surnamemanagedby ) %]
72
                                    [% INCLUDE 'patron-title.inc' patron => s.manager %]
73
                                        [% s.surnamemanagedby | html %]
74
                                        [% IF ( s.firstnamemanagedby ) %],[% END %]
75
                                        [% s.firstnamemanagedby | html %]
76
                                    [% ELSE %]
77
                                        &nbsp;
78
                                    [% END %]
79
                                </td>
73
                                </td>
80
                                <td data-order="[% s.manageddate | html %]">
74
                                <td data-order="[% s.manageddate | html %]">
81
                                    [% s.manageddate | $KohaDates %]
75
                                    [% s.manageddate | $KohaDates %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-54 / +57 lines)
Lines 672-678 Link Here
672
                                    No name
672
                                    No name
673
                                [% END %]
673
                                [% END %]
674
                            [% END %]
674
                            [% END %]
675
                            ([% suggestion.suggestions_loop.size | html %])</a></li>
675
                            ([% suggestion.suggestions.count| html %])</a></li>
676
676
677
                        [% END # /FOREACH suggestion %]
677
                        [% END # /FOREACH suggestion %]
678
                    </ul> <!-- /.ui-tabs-nav -->
678
                    </ul> <!-- /.ui-tabs-nav -->
Lines 682-688 Link Here
682
                <div id="[% suggestion.suggestiontype | html %]">
682
                <div id="[% suggestion.suggestiontype | html %]">
683
                    <form class="update_suggestions" name="f" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl#[% suggestion.suggestiontype| uri %]">
683
                    <form class="update_suggestions" name="f" method="post" action="/cgi-bin/koha/suggestion/suggestion.pl#[% suggestion.suggestiontype| uri %]">
684
684
685
                        [% IF ( suggestion.suggestions_loop ) %]
685
                        [% IF suggestion.suggestions.count %]
686
                            <p>
686
                            <p>
687
                                <a class="checkall" href="#">Check all</a> | <a class="uncheckall" href="#">Uncheck all</a>
687
                                <a class="checkall" href="#">Check all</a> | <a class="uncheckall" href="#">Uncheck all</a>
688
                            </p>
688
                            </p>
Lines 705-814 Link Here
705
                                    </tr>
705
                                    </tr>
706
                                </thead>
706
                                </thead>
707
                                <tbody>
707
                                <tbody>
708
                                    [% FOREACH suggestions_loo IN suggestion.suggestions_loop %]
708
                                    [% FOREACH s IN suggestion.suggestions %]
709
                                        <tr>
709
                                        <tr>
710
                                            <td>
710
                                            <td>
711
                                                <input type="checkbox" name="suggestionid" value="[% suggestions_loo.suggestionid | html %]" />
711
                                                <input type="checkbox" name="suggestionid" value="[% s.suggestionid | html %]" />
712
                                            </td>
712
                                            </td>
713
                                            <td>
713
                                            <td>
714
                                                <a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid | uri %]&amp;op=show" title="suggestion" >
714
                                                <a href="suggestion.pl?suggestionid=[% s.suggestionid | uri %]&amp;op=show" title="suggestion" >
715
                                                    [% suggestions_loo.title | html %][% IF ( suggestions_loo.author ) %], by [% suggestions_loo.author | html %][% END %]
715
                                                    [% s.title | html %][% IF ( s.author ) %], by [% s.author | html %][% END %]
716
                                                </a>
716
                                                </a>
717
                                                <br />
717
                                                <br />
718
                                                [% IF ( suggestions_loo.copyrightdate ) %]
718
                                                [% IF ( s.copyrightdate ) %]
719
                                                    &copy; <span class="suggestion_copyrightdate">[% suggestions_loo.copyrightdate | html %]</span>
719
                                                    &copy; <span class="suggestion_copyrightdate">[% s.copyrightdate | html %]</span>
720
                                                [% END %]
720
                                                [% END %]
721
                                                [% IF ( suggestions_loo.volumedesc ) %]
721
                                                [% IF ( s.volumedesc ) %]
722
                                                    ; <span class="suggestion_volume">Volume:<em>[% suggestions_loo.volumedesc | html %]</em></span>
722
                                                    ; <span class="suggestion_volume">Volume:<em>[% s.volumedesc | html %]</em></span>
723
                                                [% END %]
723
                                                [% END %]
724
                                                [% IF ( suggestions_loo.isbn ) %]
724
                                                [% IF ( s.isbn ) %]
725
                                                    ; <span class="suggestion_isbn">ISBN: <em>[% suggestions_loo.isbn | html %]</em></span>
725
                                                    ; <span class="suggestion_isbn">ISBN: <em>[% s.isbn | html %]</em></span>
726
                                                [% END %]
726
                                                [% END %]
727
                                                [% IF ( suggestions_loo.publishercode ) %]
727
                                                [% IF ( s.publishercode ) %]
728
                                                    ; <span class="suggestion_publishercode">Published by [% suggestions_loo.publishercode | html %]</span>
728
                                                    ; <span class="suggestion_publishercode">Published by [% s.publishercode | html %]</span>
729
                                                [% END %]
729
                                                [% END %]
730
                                                [% IF ( suggestions_loo.publicationyear ) %]
730
                                                [% IF ( s.publicationyear ) %]
731
                                                    in <span class="suggestion_publicationyear"><em>[% suggestions_loo.publicationyear | html %]</em></span>
731
                                                    in <span class="suggestion_publicationyear"><em>[% s.publicationyear | html %]</em></span>
732
                                                [% END %]
732
                                                [% END %]
733
                                                [% IF ( suggestions_loo.place ) %]
733
                                                [% IF ( s.place ) %]
734
                                                    in <span class="suggestion_place"><em>[% suggestions_loo.place | html %]</em></span>
734
                                                    in <span class="suggestion_place"><em>[% s.place | html %]</em></span>
735
                                                [% END %]
735
                                                [% END %]
736
                                                [% IF ( suggestions_loo.collectiontitle ) %]
736
                                                [% IF ( s.collectiontitle ) %]
737
                                                    ; <span class="suggestion_collectiontitle">[% suggestions_loo.collectiontitle | html %]</span>
737
                                                    ; <span class="suggestion_collectiontitle">[% s.collectiontitle | html %]</span>
738
                                                [% END %]
738
                                                [% END %]
739
                                                [% IF ( suggestions_loo.itemtype ) %]
739
                                                [% IF ( s.itemtype ) %]
740
                                                    ; <span class="suggestion_itype">[% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 0 ) | html %]</span>
740
                                                    ; <span class="suggestion_itype">[% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', s.itemtype, 0 ) | html %]</span>
741
                                                [% END %]
741
                                                [% END %]
742
                                                <br />
742
                                                <br />
743
                                                [% IF ( suggestions_loo.note ) %]
743
                                                [% IF ( s.note ) %]
744
                                                    <div class="suggestion_note"><i class="fa fa-comment"></i> [% suggestions_loo.note | html %]</div>
744
                                                    <div class="suggestion_note"><i class="fa fa-comment"></i> [% s.note | html %]</div>
745
                                                [% END %]
745
                                                [% END %]
746
                                                [% IF suggestions_loo.archived %]
746
                                                [% IF s.archived %]
747
                                                    <br /><i class="fa fa-archive"></i> Archived
747
                                                    <br /><i class="fa fa-archive"></i> Archived
748
                                                [% END %]
748
                                                [% END %]
749
                                            </td>
749
                                            </td>
750
                                            <td>
750
                                            <td>
751
                                                <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>
751
                                                [% SET suggester = s.suggester %]
752
                                                <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>
752
                                            </td>
753
                                            </td>
753
                                            <td data-order="[% suggestions_loo.suggesteddate | html %]">
754
                                            <td data-order="[% s.suggesteddate | html %]">
754
                                                [% IF ( suggestions_loo.suggesteddate ) %][% suggestions_loo.suggesteddate | $KohaDates %][% END %]
755
                                                [% IF ( s.suggesteddate ) %][% s.suggesteddate | $KohaDates %][% END %]
755
                                            </td>
756
                                            </td>
756
                                            <td>
757
                                            <td>
757
                                                <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>
758
                                                [% SET manager = s.manager %]
759
                                                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% manager.borrowernumber | uri %]">[% manager.surname | html %][% IF manager.firstname %], [% manager.firstname | html %][% END %]</a>
758
                                            </td>
760
                                            </td>
759
                                            <td data-order="[% suggestions_loo.manageddate | html %]">
761
                                            <td data-order="[% s.manageddate | html %]">
760
                                                [% IF ( suggestions_loo.manageddate ) %][% suggestions_loo.manageddate | $KohaDates %][% END %]
762
                                                [% IF ( s.manageddate ) %][% s.manageddate | $KohaDates %][% END %]
761
                                            </td>
763
                                            </td>
762
                                            <td>
764
                                            <td>
763
                                                <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>
765
                                                [% SET last_modifier = s.last_modifier %]
766
                                                <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>
764
                                            </td>
767
                                            </td>
765
                                            <td data-order="[% suggestions_loo.lastmodificationdate | html %]">
768
                                            <td data-order="[% s.lastmodificationdate | html %]">
766
                                                [% IF ( suggestions_loo.lastmodificationdate ) %][% suggestions_loo.lastmodificationdate | $KohaDates %][% END %]
769
                                                [% IF ( s.lastmodificationdate ) %][% s.lastmodificationdate | $KohaDates %][% END %]
767
                                            </td>
770
                                            </td>
768
                                            <td>
771
                                            <td>
769
                                                [% Branches.GetName( suggestions_loo.branchcode ) | html %]
772
                                                [% Branches.GetName( s.branchcode ) | html %]
770
                                            </td>
773
                                            </td>
771
                                            <td>
774
                                            <td>
772
                                                [% suggestions_loo.budget_name | html %]
775
                                                [% s.fund.budget_name | html %]
773
                                            </td>
776
                                            </td>
774
                                            <td>
777
                                            <td>
775
                                                [% IF ( suggestions_loo.ASKED ) %]
778
                                                [% IF s.STATUS == 'ASKED' %]
776
                                                    Pending
779
                                                    Pending
777
                                                [% ELSIF ( suggestions_loo.ACCEPTED ) %]
780
                                                [% ELSIF s.STATUS == 'ACCEPTED' %]
778
                                                    Accepted
781
                                                    Accepted
779
                                                [% ELSIF ( suggestions_loo.ORDERED ) %]
782
                                                [% ELSIF s.STATUS == 'ORDERED' %]
780
                                                    Ordered
783
                                                    Ordered
781
                                                [% ELSIF ( suggestions_loo.REJECTED ) %]
784
                                                [% ELSIF s.STATUS == 'REJECTED' %]
782
                                                    Rejected
785
                                                    Rejected
783
                                                [% ELSIF ( suggestions_loo.CHECKED ) %]
786
                                                [% ELSIF s.STATUS == 'CHECKED' %]
784
                                                    Checked
787
                                                    Checked
785
                                                [% ELSIF ( suggestions_loo.AVAILABLE ) %]
788
                                                [% ELSIF s.STATUS == 'AVAILABLE' %]
786
                                                    Available
789
                                                    Available
787
                                                [% ELSIF AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) %]
790
                                                [% ELSIF AuthorisedValues.GetByCode( 'SUGGEST_STATUS', s.STATUS ) %]
788
                                                    [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS ) | html %]
791
                                                    [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', s.STATUS ) | html %]
789
                                                [% ELSE %]
792
                                                [% ELSE %]
790
                                                    Status unknown
793
                                                    Status unknown
791
                                                [% END %]
794
                                                [% END %]
792
795
793
                                                [% IF ( suggestions_loo.reason ) %]
796
                                                [% IF ( s.reason ) %]
794
                                                    <br />([% suggestions_loo.reason | html %])
797
                                                    <br />([% s.reason | html %])
795
                                                [% END %]
798
                                                [% END %]
796
                                            </td>
799
                                            </td>
797
                                            <td class="actions">
800
                                            <td class="actions">
798
                                                <div class="btn-group dropup">
801
                                                <div class="btn-group dropup">
799
                                                    <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>
802
                                                    <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>
800
                                                    <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="more_actions_[% suggestions_loo.suggestionid | html %]">
803
                                                    <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="more_actions_[% s.suggestionid | html %]">
801
                                                        <li><a class="deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a></li>
804
                                                        <li><a class="deletesuggestion" href="suggestion.pl?op=delete&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-trash"></i> Delete</a></li>
802
                                                        [% UNLESS suggestions_loo.archived %]
805
                                                        [% UNLESS s.archived %]
803
                                                            <li><a class="archivesuggestion" href="suggestion.pl?op=archive&amp;suggestionid=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-archive"></i> Archive</a></li>
806
                                                            <li><a class="archivesuggestion" href="suggestion.pl?op=archive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Archive</a></li>
804
                                                        [% ELSE %]
807
                                                        [% ELSE %]
805
                                                            <li><a class="unarchivesuggestion" href="suggestion.pl?op=unarchive&amp;suggestionid=[% suggestions_loo.suggestionid | html %]"><i class="fa fa-archive"></i> Unarchive</a></li>
808
                                                            <li><a class="unarchivesuggestion" href="suggestion.pl?op=unarchive&amp;suggestionid=[% s.suggestionid | html %]"><i class="fa fa-archive"></i> Unarchive</a></li>
806
                                                        [% END %]
809
                                                        [% END %]
807
                                                    </ul>
810
                                                    </ul>
808
                                                </div>
811
                                                </div>
809
                                            </td>
812
                                            </td>
810
                                        </tr>
813
                                        </tr>
811
                                    [% END # /FOREACH suggestions_loo %]
814
                                    [% END # /FOREACH s %]
812
                                </tbody>
815
                                </tbody>
813
                            </table> <!-- /#table_[% loop.count | html %] -->
816
                            </table> <!-- /#table_[% loop.count | html %] -->
814
817
Lines 1268-1274 Link Here
1268
1271
1269
                columns_settings = [% TablesSettings.GetColumns( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %]
1272
                columns_settings = [% TablesSettings.GetColumns( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %]
1270
                [% FOREACH suggestion IN suggestions %]
1273
                [% FOREACH suggestion IN suggestions %]
1271
                    [% IF ( suggestion.suggestions_loop ) %]
1274
                    [% IF suggestion.suggestions.count %]
1272
                        KohaTable("table_[% loop.count| html %]", {
1275
                        KohaTable("table_[% loop.count| html %]", {
1273
                            "sorting": [[ 3, "asc" ]],
1276
                            "sorting": [[ 3, "asc" ]],
1274
                            "autoWidth": false,
1277
                            "autoWidth": false,
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-33 / +33 lines)
Lines 289-295 Link Here
289
289
290
                            [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
290
                            [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
291
291
292
                            [% IF suggestions_loop OR title_filter %]
292
                            [% IF suggestions.count OR title_filter %]
293
                                [% SET can_delete_suggestion = 0 %]
293
                                <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" id="search_suggestions_form" method="get">
294
                                <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" id="search_suggestions_form" method="get">
294
                                    <div class="form-row">
295
                                    <div class="form-row">
295
                                        <label for="title_filter">Search for:</label>
296
                                        <label for="title_filter">Search for:</label>
Lines 359-432 Link Here
359
                                            </tr>
360
                                            </tr>
360
                                        </thead>
361
                                        </thead>
361
                                        <tbody>
362
                                        <tbody>
362
                                            [% FOREACH suggestions_loo IN suggestions_loop %]
363
                                            [% FOREACH suggestion IN suggestions %]
363
                                                <tr>
364
                                                <tr>
364
                                                    [% IF ( loggedinusername ) %]
365
                                                    [% IF logged_in_user %]
365
                                                        <td class="selectcol">
366
                                                        <td class="selectcol">
366
                                                            [% IF ( suggestions_loo.showcheckbox ) %]
367
                                                            [% IF logged_in_user.borrowernumber == suggestion.suggester.borrowernumber %]
367
                                                                [% SET can_delete_suggestion = 1 %]
368
                                                                [% SET can_delete_suggestion = 1 %]
368
                                                                <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 %]" />
369
                                                                <input type="checkbox" class="cb" id="id[% suggestion.suggestionid | html %]" name="delete_field" data-title="[% suggestion.title | html %]" value="[% suggestion.suggestionid | html %]" />
369
                                                            [% END %]
370
                                                            [% END %]
370
                                                        </td>
371
                                                        </td>
371
                                                    [% END %]
372
                                                    [% END %]
372
                                                    <td>
373
                                                    <td>
373
                                                        <p>
374
                                                        <p>
374
                                                            <label for="id[% suggestions_loo.suggestionid | html %]">
375
                                                            <label for="id[% suggestions_loo.suggestionid | html %]">
375
                                                                [% IF suggestions_loo.biblionumber %]
376
                                                                [% IF suggestion.biblionumber %]
376
                                                                    <strong><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% suggestions_loo.biblionumber | uri %]">[% suggestions_loo.title | html %]</a></strong>
377
                                                                    <strong><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% suggestion.biblionumber | uri %]">[% suggestion.title | html %]</a></strong>
377
                                                                [% ELSE %]
378
                                                                [% ELSE %]
378
                                                                    <strong>[% suggestions_loo.title | html %]</strong>
379
                                                                    <strong>[% suggestion.title | html %]</strong>
379
                                                                [% END %]
380
                                                                [% END %]
380
                                                            </label>
381
                                                            </label>
381
                                                        </p>
382
                                                        </p>
382
                                                            <p>[% IF ( suggestions_loo.author ) %][% suggestions_loo.author | html %],[% END %]
383
                                                            <p>[% IF ( suggestion.author ) %][% suggestion.author | html %],[% END %]
383
                                                                [% IF ( suggestions_loo.copyrightdate ) %] - [% suggestions_loo.copyrightdate | html %],[% END %]
384
                                                                [% IF ( suggestion.copyrightdate ) %] - [% suggestion.copyrightdate | html %],[% END %]
384
                                                                [% IF ( suggestions_loo.publishercode ) %] - [% suggestions_loo.publishercode | html %][% END %]
385
                                                                [% IF ( suggestion.publishercode ) %] - [% suggestion.publishercode | html %][% END %]
385
                                                                [% IF ( suggestions_loo.place ) %]([% suggestions_loo.place | html %])[% END %]
386
                                                                [% IF ( suggestion.place ) %]([% suggestion.place | html %])[% END %]
386
                                                                [% IF ( suggestions_loo.collectiontitle ) %] , [% suggestions_loo.collectiontitle | html %][% END %]
387
                                                                [% IF ( suggestion.collectiontitle ) %] , [% suggestion.collectiontitle | html %][% END %]
387
                                                                [% IF ( suggestions_loo.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 1 ) | html %][% END %]
388
                                                                [% IF ( suggestion.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestion.itemtype, 1 ) | html %][% END %]
388
                                                        </p>
389
                                                        </p>
389
                                                    </td>
390
                                                    </td>
390
                                                    <td>
391
                                                    <td>
391
                                                        [% IF ( suggestions_loo.suggesteddate ) %][% suggestions_loo.suggesteddate |$KohaDates %][% END %]
392
                                                        [% IF ( suggestion.suggesteddate ) %][% suggestion.suggesteddate |$KohaDates %][% END %]
392
                                                    </td>
393
                                                    </td>
393
                                                    <td>
394
                                                    <td>
394
                                                        [% IF ( suggestions_loo.note ) %]
395
                                                        [% IF ( suggestion.note ) %]
395
                                                            <span class="tdlabel">Note: </span>
396
                                                            <span class="tdlabel">Note: </span>
396
                                                            [% suggestions_loo.note | html %]
397
                                                            [% suggestion.note | html %]
397
                                                        [% END %]
398
                                                        [% END %]
398
                                                    </td>
399
                                                    </td>
399
                                                    [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
400
                                                    [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
400
                                                        <td>
401
                                                        <td>
401
                                                            [% IF ( suggestions_loo.branchcodesuggestedby ) %]
402
                                                            [% IF suggestion.suggestedby %]
402
                                                                <span class="tdlabel">Suggested for:</span>
403
                                                                <span class="tdlabel">Suggested for:</span>
403
                                                                [% suggestions_loo.branchcodesuggestedby | html %]
404
                                                                [% Branches.GetName(suggestion.suggester.branchcode) | html %]
404
                                                            [% END %]
405
                                                            [% END %]
405
                                                        </td>
406
                                                        </td>
406
                                                    [% END %]
407
                                                    [% END %]
407
                                                    [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
408
                                                    [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
408
                                                    <td>
409
                                                    <td>
409
                                                        [% IF ( suggestions_loo.surnamemanagedby ) %]
410
                                                        [% IF suggestion.managedby %]
410
                                                            <span class="tdlabel">Managed by:</span>
411
                                                            <span class="tdlabel">Managed by:</span>
411
                                                            [% suggestions_loo.surnamemanagedby | html %]
412
                                                            [% INCLUDE 'patron-title.inc' patron = suggestion.manager %]
412
                                                            [% IF ( suggestions_loo.firstnamemanagedby ) %]    , [% suggestions_loo.firstnamemanagedby | html %]
413
                                                            [% IF ( suggestion.manageddate ) %] - [% suggestion.manageddate | $KohaDates %][% END %]
413
                                                            [% END %]
414
                                                        [% END %]
414
                                                        [% END %]
415
                                                    </td>
415
                                                    </td>
416
                                                    [% END %]
416
                                                    [% END %]
417
                                                    <td>
417
                                                    <td>
418
                                                        <span class="tdlabel">Status:</span>
418
                                                        <span class="tdlabel">Status:</span>
419
                                                        [% IF ( suggestions_loo.ASKED ) %]Requested
419
                                                        [% IF ( suggestion.STATUS == 'ASKED' ) %]Requested
420
                                                        [% ELSIF ( suggestions_loo.CHECKED ) %]Checked by the library
420
                                                        [% ELSIF ( suggestion.STATUS == 'CHECKED' ) %]Checked by the library
421
                                                        [% ELSIF ( suggestions_loo.ACCEPTED ) %]Accepted by the library
421
                                                        [% ELSIF ( suggestion.STATUS == 'ACCEPTED' ) %]Accepted by the library
422
                                                        [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library
422
                                                        [% ELSIF ( suggestion.STATUS == 'ORDERED' ) %]Ordered by the library
423
                                                        [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined
423
                                                        [% ELSIF ( suggestion.STATUS == 'REJECTED' ) %]Suggestion declined
424
                                                        [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library
424
                                                        [% ELSIF ( suggestion.STATUS == 'AVAILABLE' ) %]Available in the library
425
                                                        [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) | html %] [% END %]
425
                                                        [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.STATUS, 1 ) | html %] [% END %]
426
                                                        [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason | html %])[% END %]
426
                                                        [% IF ( suggestion.reason ) %]([% suggestion.reason | html %])[% END %]
427
                                                    </td>
427
                                                    </td>
428
                                                </tr>
428
                                                </tr>
429
                                            [% END # / FOREACH suggestions_loo %]
429
                                            [% END # / FOREACH suggestions %]
430
                                        </tbody>
430
                                        </tbody>
431
                                    </table>
431
                                    </table>
432
432
Lines 465-471 Link Here
465
                                        <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>
465
                                        <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>
466
                                    [% END %]
466
                                    [% END %]
467
                                [% END %]
467
                                [% END %]
468
                            [% END # / IF suggestions_loop %]
468
                            [% END # / IF suggestions.count %]
469
469
470
                        [% END # IF op_else %]
470
                        [% END # IF op_else %]
471
                    </div> <!-- / #usersuggestions -->
471
                    </div> <!-- / #usersuggestions -->
(-)a/members/deletemem.pl (-6 / +2 lines)
Lines 31-40 use C4::Context; Link Here
31
use C4::Output;
31
use C4::Output;
32
use C4::Auth;
32
use C4::Auth;
33
use C4::Members;
33
use C4::Members;
34
use C4::Suggestions qw( SearchSuggestion );
35
use Koha::Patrons;
34
use Koha::Patrons;
36
use Koha::Token;
35
use Koha::Token;
37
use Koha::Patron::Categories;
36
use Koha::Patron::Categories;
37
use Koha::Suggestions;
38
38
39
my $input = CGI->new;
39
my $input = CGI->new;
40
40
Lines 100-110 my $countholds = $dbh->selectrow_array("SELECT COUNT(*) FROM reserves WHERE borr Link Here
100
100
101
# Add warning if patron has pending suggestions
101
# Add warning if patron has pending suggestions
102
$template->param(
102
$template->param(
103
    pending_suggestions => scalar @{
103
    pending_suggestions => Koha::Suggestions->search({ suggestedby => $member, STATUS => 'ASKED' })->count,
104
    C4::Suggestions::SearchSuggestion(
105
            { suggestedby => $member, STATUS => 'ASKED' }
106
        )
107
    }
108
);
104
);
109
105
110
$template->param(
106
$template->param(
(-)a/members/purchase-suggestions.pl (-3 / +2 lines)
Lines 23-31 use CGI qw ( -utf8 ); Link Here
23
use C4::Auth;
23
use C4::Auth;
24
use C4::Context;
24
use C4::Context;
25
use C4::Output;
25
use C4::Output;
26
use C4::Members;
27
use C4::Suggestions;
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 50-56 $template->param( Link Here
50
    suggestionsview  => 1,
49
    suggestionsview  => 1,
51
);
50
);
52
51
53
my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } );
52
my $suggestions = Koha::Suggestions->search_limited( { suggestedby => $borrowernumber }, { prefetch => 'managedby' } );
54
53
55
$template->param( suggestions => $suggestions );
54
$template->param( suggestions => $suggestions );
56
55
(-)a/opac/opac-suggestions.pl (-46 / +28 lines)
Lines 38-44 use Koha::DateUtils; Link Here
38
my $input           = CGI->new;
38
my $input           = CGI->new;
39
my $op              = $input->param('op') || 'else';
39
my $op              = $input->param('op') || 'else';
40
my $biblionumber    = $input->param('biblionumber');
40
my $biblionumber    = $input->param('biblionumber');
41
my $suggestion      = $input->Vars;
42
my $negcaptcha      = $input->param('negcap');
41
my $negcaptcha      = $input->param('negcap');
43
my $suggested_by_anyone = $input->param('suggested_by_anyone') || 0;
42
my $suggested_by_anyone = $input->param('suggested_by_anyone') || 0;
44
my $title_filter    = $input->param('title_filter');
43
my $title_filter    = $input->param('title_filter');
Lines 80-120 else { Link Here
80
    );
79
    );
81
}
80
}
82
81
83
# don't pass 'negcap' column to DB, else DBI::Class will error
82
my $suggested_by;
84
# DBIx::Class::Row::store_column(): No such column 'negcap' on Koha::Schema::Result::Suggestion at  Koha/C4/Suggestions.pm
85
delete $suggestion->{negcap};
86
delete $suggestion->{$_} foreach qw<op suggested_by_anyone confirm>;
87
88
if ( $op eq 'else' ) {
83
if ( $op eq 'else' ) {
89
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
84
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
90
        if ( $borrowernumber ) {
85
        if ( $borrowernumber ) {
91
            # A logged in user is able to see suggestions from others
86
            # A logged in user is able to see suggestions from others
92
            $suggestion->{suggestedby} = $suggested_by_anyone
87
            $suggested_by = $suggested_by_anyone
93
                ? undef
88
                ? undef
94
                : $borrowernumber;
89
                : $borrowernumber;
95
        }
90
        }
96
        else {
91
        # else: Non logged in user is able to see all suggestions
97
            # Non logged in user is able to see all suggestions
98
            $suggestion->{suggestedby} = undef;
99
        }
100
    }
92
    }
101
    else {
93
    else {
102
        if ( $borrowernumber ) {
94
        if ( $borrowernumber ) {
103
            $suggestion->{suggestedby} = $borrowernumber;
95
            $suggested_by = $borrowernumber;
104
        }
96
        }
105
        else {
97
        else {
106
            $suggestion->{suggestedby} = -1;
98
            $suggested_by = -1;
107
        }
99
        }
108
    }
100
    }
109
} else {
101
} else {
110
    if ( $borrowernumber ) {
102
    if ( $borrowernumber ) {
111
        $suggestion->{suggestedby} = $borrowernumber;
103
        $suggested_by = $borrowernumber;
112
    }
104
    }
113
    else {
105
    else {
114
        $suggestion->{suggestedby} = C4::Context->preference("AnonymousPatron");
106
        $suggested_by = C4::Context->preference("AnonymousPatron");
115
    }
107
    }
116
}
108
}
117
109
110
my @suggestion_fields =
111
  qw( title author copyrightdate isbn publishercode collectiontitle place quantity itemtype patronreason note );
112
my $suggestion = {
113
    map {
114
        # Keep parameters that are not an empty string
115
        my $p = $input->param($_);
116
        ( defined $p && $p ne '' ? ( $_ => $p ) : () )
117
    } @suggestion_fields
118
};
119
$suggestion->{suggestedby} = $borrowernumber;
120
118
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
121
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
119
    $op = 'add_confirm';
122
    $op = 'add_confirm';
120
    my $biblio = MarcRecordFromNewSuggestion($suggestion);
123
    my $biblio = MarcRecordFromNewSuggestion($suggestion);
Lines 140-146 if ( $borrowernumber ){ Link Here
140
}
143
}
141
144
142
if ( $op eq "add_confirm" ) {
145
if ( $op eq "add_confirm" ) {
143
    my $suggestions_loop = &SearchSuggestion($suggestion);
146
    my $suggestions = Koha::Suggestions->search($suggestion);
144
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && $patrons_total_suggestions_count >= C4::Context->preference("MaxTotalSuggestions") )
147
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && $patrons_total_suggestions_count >= C4::Context->preference("MaxTotalSuggestions") )
145
    {
148
    {
146
        push @messages, { type => 'error', code => 'total_suggestions' };
149
        push @messages, { type => 'error', code => 'total_suggestions' };
Lines 149-163 if ( $op eq "add_confirm" ) { Link Here
149
    {
152
    {
150
        push @messages, { type => 'error', code => 'too_many' };
153
        push @messages, { type => 'error', code => 'too_many' };
151
    }
154
    }
152
    elsif ( @$suggestions_loop >= 1 ) {
155
    elsif ( $suggestions->count >= 1 ) {
153
156
154
        #some suggestion are answering the request Donot Add
157
        #some suggestion are answering the request Donot Add
155
        for my $suggestion (@$suggestions_loop) {
158
        while ( my $suggestion = $suggestions->next ) {
156
            push @messages,
159
            push @messages,
157
              {
160
              {
158
                type => 'error',
161
                type => 'error',
159
                code => 'already_exists',
162
                code => 'already_exists',
160
                id   => $suggestion->{suggestionid}
163
                id   => $suggestion->suggestionid
161
              };
164
              };
162
            last;
165
            last;
163
        }
166
        }
Lines 177-200 if ( $op eq "add_confirm" ) { Link Here
177
        $patrons_pending_suggestions_count++;
180
        $patrons_pending_suggestions_count++;
178
        $patrons_total_suggestions_count++;
181
        $patrons_total_suggestions_count++;
179
182
180
        # delete empty fields, to avoid filter in "SearchSuggestion"
181
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
182
            delete $suggestion->{$field}; #clear search filters (except borrower related) to show all suggestions after placing a new one
183
        }
184
        $suggestions_loop = &SearchSuggestion($suggestion);
185
186
        push @messages, { type => 'info', code => 'success_on_inserted' };
183
        push @messages, { type => 'info', code => 'success_on_inserted' };
187
184
188
    }
185
    }
189
    $op = 'else';
186
    $op = 'else';
190
}
187
}
191
188
192
my $suggestions_loop = &SearchSuggestion(
189
my $suggestions = Koha::Suggestions->search_limited(
193
    {
190
    {
194
        suggestedby => $suggestion->{suggestedby},
191
        $suggestion->{suggestedby}
192
        ? ( suggestedby => $suggestion->{suggestedby} )
193
        : (),
195
        title       => $title_filter,
194
        title       => $title_filter,
196
    }
195
    }
197
);
196
);
197
198
if ( $op eq "delete_confirm" ) {
198
if ( $op eq "delete_confirm" ) {
199
    my @delete_field = $input->multi_param("delete_field");
199
    my @delete_field = $input->multi_param("delete_field");
200
    foreach my $delete_field (@delete_field) {
200
    foreach my $delete_field (@delete_field) {
Lines 205-228 if ( $op eq "delete_confirm" ) { Link Here
205
    exit;
205
    exit;
206
}
206
}
207
207
208
map{
209
    my $s = $_;
210
    my $library = Koha::Libraries->find($s->{branchcodesuggestedby});
211
    $library ? $s->{branchcodesuggestedby} = $library->branchname : ()
212
} @$suggestions_loop;
213
214
foreach my $suggestion(@$suggestions_loop) {
215
    if($suggestion->{'suggestedby'} == $borrowernumber) {
216
        $suggestion->{'showcheckbox'} = $borrowernumber;
217
    } else {
218
        $suggestion->{'showcheckbox'} = 0;
219
    }
220
    if($suggestion->{'patronreason'}){
221
        my $av = Koha::AuthorisedValues->search({ category => 'OPAC_SUG', authorised_value => $suggestion->{patronreason} });
222
        $suggestion->{'patronreason'} = $av->count ? $av->next->opac_description : '';
223
    }
224
}
225
226
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG", "opac");
208
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG", "opac");
227
209
228
my @mandatoryfields;
210
my @mandatoryfields;
Lines 260-266 my @unwantedfields; Link Here
260
242
261
$template->param(
243
$template->param(
262
    %$suggestion,
244
    %$suggestion,
263
    suggestions_loop      => $suggestions_loop,
245
    suggestions           => $suggestions,
264
    patron_reason_loop    => $patron_reason_loop,
246
    patron_reason_loop    => $patron_reason_loop,
265
    "op_$op"              => 1,
247
    "op_$op"              => 1,
266
    $op                   => 1,
248
    $op                   => 1,
(-)a/suggestion/suggestion.pl (-15 / +38 lines)
Lines 93-99 my $displayby = $input->param('displayby') || ''; Link Here
93
my $tabcode         = $input->param('tabcode');
93
my $tabcode         = $input->param('tabcode');
94
my $save_confirmed  = $input->param('save_confirmed') || 0;
94
my $save_confirmed  = $input->param('save_confirmed') || 0;
95
my $notify          = $input->param('notify');
95
my $notify          = $input->param('notify');
96
my $filter_archived = $input->param('filter_archived');
96
my $filter_archived = $input->param('filter_archived') || 0;
97
97
98
my $reasonsloop     = GetAuthorisedValues("SUGGEST");
98
my $reasonsloop     = GetAuthorisedValues("SUGGEST");
99
99
Lines 110-115 delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode notif Link Here
110
foreach (keys %$suggestion_ref){
110
foreach (keys %$suggestion_ref){
111
    delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' ));
111
    delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' ));
112
}
112
}
113
delete $suggestion_only->{branchcode} if $suggestion_only->{branchcode} eq '__ANY__';
114
delete $suggestion_only->{budgetid}   if $suggestion_only->{budgetid}   eq '__ANY__';
115
while ( my ( $k, $v ) = each %$suggestion_only ) {
116
    delete $suggestion_only->{$k} if $v eq '';
117
}
118
113
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user(
119
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user(
114
        {
120
        {
115
            template_name   => "suggestion/suggestion.tt",
121
            template_name   => "suggestion/suggestion.tt",
Lines 215-227 if ( $op =~ /save/i ) { Link Here
215
            }
221
            }
216
        } else {
222
        } else {
217
            ###FIXME:Search here if suggestion already exists.
223
            ###FIXME:Search here if suggestion already exists.
218
            my $suggestions_loop =
224
            my $suggestions= Koha::Suggestions->search_limited( $suggestion_only );
219
                SearchSuggestion( $suggestion_only );
225
            if ( $suggestions->count ) {
220
            if (@$suggestions_loop>=1){
221
                #some suggestion are answering the request Donot Add
226
                #some suggestion are answering the request Donot Add
222
                my @messages;
227
                my @messages;
223
                for my $suggestion ( @$suggestions_loop ) {
228
                while ( my $suggestion = $suggestions->next ) {
224
                    push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
229
                    push @messages, { type => 'error', code => 'already_exists', id => $suggestion->suggestionid };
225
                }
230
                }
226
                $template->param( messages => \@messages );
231
                $template->param( messages => \@messages );
227
            }
232
            }
Lines 370-389 if ($op=~/else/) { Link Here
370
        next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue ) and ($displayby ne 'branchcode' && $branchfilter ne '__ANY__' );
375
        next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue ) and ($displayby ne 'branchcode' && $branchfilter ne '__ANY__' );
371
        $$suggestion_ref{$displayby} = $criteriumvalue;
376
        $$suggestion_ref{$displayby} = $criteriumvalue;
372
377
373
        my $suggestions = &SearchSuggestion({ %$suggestion_ref, archived => $filter_archived });
378
        # filter on date fields
374
        foreach my $suggestion (@$suggestions) {
379
        foreach my $field (qw( suggesteddate manageddate accepteddate )) {
375
            if ($suggestion->{budgetid}){
380
            my $from = $field . "_from";
376
                my $bud = GetBudget( $suggestion->{budgetid} );
381
            my $to   = $field . "_to";
377
                $suggestion->{budget_name} = $bud->{budget_name} if $bud;
382
            my $from_dt =
383
              $suggestion_ref->{$from}
384
              ? eval { dt_from_string( $suggestion_ref->{$from} ) }
385
              : undef;
386
            my $to_dt =
387
              $suggestion_ref->{$to}
388
              ? eval { dt_from_string( $suggestion_ref->{$to} ) }
389
              : undef;
390
391
            if ( $from_dt || $to_dt ) {
392
                my $dtf = Koha::Database->new->schema->storage->datetime_parser;
393
                my @conditions;
394
                if ( $from_dt && $to_dt ) {
395
                    $suggestion_ref->{$field} = { -between => [ $from_dt, $to_dt ] };
396
                } elsif ( $from_dt ) {
397
                    $suggestion_ref->{$field} = { '>=' => $from_dt };
398
                } elsif ( $to_dt ) {
399
                    $suggestion_ref->{$field} = { '<=' => $to_dt };
400
                }
378
            }
401
            }
379
        }
402
        }
403
        my $suggestions = Koha::Suggestions->search_limited( { %$suggestion_ref, archived => $filter_archived } );
404
380
        push @allsuggestions,{
405
        push @allsuggestions,{
381
                            "suggestiontype"=>$criteriumvalue||"suggest",
406
                            "suggestiontype"=>$criteriumvalue||"suggest",
382
                            "suggestiontypelabel"=>GetCriteriumDesc($criteriumvalue,$displayby)||"",
407
                            "suggestiontypelabel"=>GetCriteriumDesc($criteriumvalue,$displayby)||"",
383
                            "suggestionscount"=>scalar(@$suggestions),             
408
                            'suggestions'     => $suggestions,
384
                            'suggestions_loop'=>$suggestions,
385
                            'reasonsloop'     => $reasonsloop,
409
                            'reasonsloop'     => $reasonsloop,
386
                            } if @$suggestions;
410
                            } if $suggestions->count;
387
411
388
        delete $$suggestion_ref{$displayby} unless $definedvalue;
412
        delete $$suggestion_ref{$displayby} unless $definedvalue;
389
    }
413
    }
390
- 

Return to bug 23991