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

(-)a/C4/Suggestions.pm (-150 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-228 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
    foreach my $field (qw( suggesteddate manageddate accepteddate )) {
191
        my $from = $field . "_from";
192
        my $to   = $field . "_to";
193
        my $from_dt;
194
        $from_dt = eval { dt_from_string( $suggestion->{$from} ) } if ( $suggestion->{$from} );
195
        my $from_sql = '0000-00-00';
196
        $from_sql = output_pref({ dt => $from_dt, dateformat => 'iso', dateonly => 1 })
197
            if ($from_dt);
198
        $debug && warn "SQL for start date ($field): $from_sql";
199
        if ( $suggestion->{$from} || $suggestion->{$to} ) {
200
            push @query, qq{ AND suggestions.$field BETWEEN ? AND ? };
201
            push @sql_params, $from_sql;
202
            push @sql_params,
203
              output_pref({ dt => dt_from_string( $suggestion->{$to} ), dateformat => 'iso', dateonly => 1 }) || output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
204
        }
205
    }
206
207
    # By default do not search for archived suggestions
208
    unless ( exists $suggestion->{archived} && $suggestion->{archived} ) {
209
        push @query, q{ AND suggestions.archived = 0 };
210
    }
211
212
    $debug && warn "@query";
213
    my $sth = $dbh->prepare("@query");
214
    $sth->execute(@sql_params);
215
    my @results;
216
217
    # add status as field
218
    while ( my $data = $sth->fetchrow_hashref ) {
219
        $data->{ $data->{STATUS} } = 1;
220
        push( @results, $data );
221
    }
222
223
    return ( \@results );
224
}
225
226
=head2 GetSuggestion
76
=head2 GetSuggestion
227
77
228
\%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": [[ 1, "asc" ]],
1276
                            "sorting": [[ 1, "asc" ]],
1274
                            "autoWidth": false,
1277
                            "autoWidth": false,
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-33 / +32 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 ) %]
292
                            [% IF suggestions.count %]
293
                                [% SET can_delete_suggestion = 0 %]
293
                                [% SET can_delete_suggestion = 0 %]
294
                                <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">
295
                                    <div class="form-row">
295
                                    <div class="form-row">
Lines 355-428 Link Here
355
                                            </tr>
355
                                            </tr>
356
                                        </thead>
356
                                        </thead>
357
                                        <tbody>
357
                                        <tbody>
358
                                            [% FOREACH suggestions_loo IN suggestions_loop %]
358
                                            [% FOREACH suggestion IN suggestions %]
359
                                                <tr>
359
                                                <tr>
360
                                                    [% IF ( loggedinusername ) %]
360
                                                    [% IF logged_in_user %]
361
                                                        <td class="selectcol">
361
                                                        <td class="selectcol">
362
                                                            [% IF ( suggestions_loo.showcheckbox ) %]
362
                                                            [% IF logged_in_user.borrowernumber == suggestion.suggester.borrowernumber %]
363
                                                                [% SET can_delete_suggestion = 1 %]
363
                                                                [% SET can_delete_suggestion = 1 %]
364
                                                                <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 %]" />
364
                                                                <input type="checkbox" class="cb" id="id[% suggestion.suggestionid | html %]" name="delete_field" data-title="[% suggestion.title | html %]" value="[% suggestion.suggestionid | html %]" />
365
                                                            [% END %]
365
                                                            [% END %]
366
                                                        </td>
366
                                                        </td>
367
                                                    [% END %]
367
                                                    [% END %]
368
                                                    <td>
368
                                                    <td>
369
                                                        <p>
369
                                                        <p>
370
                                                            <label for="id[% suggestions_loo.suggestionid | html %]">
370
                                                            <label for="id[% suggestions_loo.suggestionid | html %]">
371
                                                                [% IF suggestions_loo.biblionumber %]
371
                                                                [% IF suggestion.biblionumber %]
372
                                                                    <strong><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% suggestions_loo.biblionumber | uri %]">[% suggestions_loo.title | html %]</a></strong>
372
                                                                    <strong><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% suggestion.biblionumber | uri %]">[% suggestion.title | html %]</a></strong>
373
                                                                [% ELSE %]
373
                                                                [% ELSE %]
374
                                                                    <strong>[% suggestions_loo.title | html %]</strong>
374
                                                                    <strong>[% suggestion.title | html %]</strong>
375
                                                                [% END %]
375
                                                                [% END %]
376
                                                            </label>
376
                                                            </label>
377
                                                        </p>
377
                                                        </p>
378
                                                            <p>[% IF ( suggestions_loo.author ) %][% suggestions_loo.author | html %],[% END %]
378
                                                            <p>[% IF ( suggestion.author ) %][% suggestion.author | html %],[% END %]
379
                                                                [% IF ( suggestions_loo.copyrightdate ) %] - [% suggestions_loo.copyrightdate | html %],[% END %]
379
                                                                [% IF ( suggestion.copyrightdate ) %] - [% suggestion.copyrightdate | html %],[% END %]
380
                                                                [% IF ( suggestions_loo.publishercode ) %] - [% suggestions_loo.publishercode | html %][% END %]
380
                                                                [% IF ( suggestion.publishercode ) %] - [% suggestion.publishercode | html %][% END %]
381
                                                                [% IF ( suggestions_loo.place ) %]([% suggestions_loo.place | html %])[% END %]
381
                                                                [% IF ( suggestion.place ) %]([% suggestion.place | html %])[% END %]
382
                                                                [% IF ( suggestions_loo.collectiontitle ) %] , [% suggestions_loo.collectiontitle | html %][% END %]
382
                                                                [% IF ( suggestion.collectiontitle ) %] , [% suggestion.collectiontitle | html %][% END %]
383
                                                                [% IF ( suggestions_loo.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 1 ) | html %][% END %]
383
                                                                [% IF ( suggestion.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestion.itemtype, 1 ) | html %][% END %]
384
                                                        </p>
384
                                                        </p>
385
                                                    </td>
385
                                                    </td>
386
                                                    <td>
386
                                                    <td>
387
                                                        [% IF ( suggestions_loo.suggesteddate ) %][% suggestions_loo.suggesteddate |$KohaDates %][% END %]
387
                                                        [% IF ( suggestion.suggesteddate ) %][% suggestion.suggesteddate |$KohaDates %][% END %]
388
                                                    </td>
388
                                                    </td>
389
                                                    <td>
389
                                                    <td>
390
                                                        [% IF ( suggestions_loo.note ) %]
390
                                                        [% IF ( suggestion.note ) %]
391
                                                            <span class="tdlabel">Note: </span>
391
                                                            <span class="tdlabel">Note: </span>
392
                                                            [% suggestions_loo.note | html %]
392
                                                            [% suggestion.note | html %]
393
                                                        [% END %]
393
                                                        [% END %]
394
                                                    </td>
394
                                                    </td>
395
                                                    [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
395
                                                    [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
396
                                                        <td>
396
                                                        <td>
397
                                                            [% IF ( suggestions_loo.branchcodesuggestedby ) %]
397
                                                            [% IF suggestion.suggestedby %]
398
                                                                <span class="tdlabel">Suggested for:</span>
398
                                                                <span class="tdlabel">Suggested for:</span>
399
                                                                [% suggestions_loo.branchcodesuggestedby | html %]
399
                                                                [% Branches.GetName(suggestion.suggester.branchcode) | html %]
400
                                                            [% END %]
400
                                                            [% END %]
401
                                                        </td>
401
                                                        </td>
402
                                                    [% END %]
402
                                                    [% END %]
403
                                                    [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
403
                                                    [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
404
                                                    <td>
404
                                                    <td>
405
                                                        [% IF ( suggestions_loo.surnamemanagedby ) %]
405
                                                        [% IF suggestion.managedby %]
406
                                                            <span class="tdlabel">Managed by:</span>
406
                                                            <span class="tdlabel">Managed by:</span>
407
                                                            [% suggestions_loo.surnamemanagedby | html %]
407
                                                            [% INCLUDE 'patron-title.inc' patron = suggestion.manager %]
408
                                                            [% IF ( suggestions_loo.firstnamemanagedby ) %]    , [% suggestions_loo.firstnamemanagedby | html %]
408
                                                            [% IF ( suggestion.manageddate ) %] - [% suggestion.manageddate | $KohaDates %][% END %]
409
                                                            [% END %]
410
                                                        [% END %]
409
                                                        [% END %]
411
                                                    </td>
410
                                                    </td>
412
                                                    [% END %]
411
                                                    [% END %]
413
                                                    <td>
412
                                                    <td>
414
                                                        <span class="tdlabel">Status:</span>
413
                                                        <span class="tdlabel">Status:</span>
415
                                                        [% IF ( suggestions_loo.ASKED ) %]Requested
414
                                                        [% IF ( suggestion.STATUS == 'ASKED' ) %]Requested
416
                                                        [% ELSIF ( suggestions_loo.CHECKED ) %]Checked by the library
415
                                                        [% ELSIF ( suggestion.STATUS == 'CHECKED' ) %]Checked by the library
417
                                                        [% ELSIF ( suggestions_loo.ACCEPTED ) %]Accepted by the library
416
                                                        [% ELSIF ( suggestion.STATUS == 'ACCEPTED' ) %]Accepted by the library
418
                                                        [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library
417
                                                        [% ELSIF ( suggestion.STATUS == 'ORDERED' ) %]Ordered by the library
419
                                                        [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined
418
                                                        [% ELSIF ( suggestion.STATUS == 'REJECTED' ) %]Suggestion declined
420
                                                        [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library
419
                                                        [% ELSIF ( suggestion.STATUS == 'AVAILABLE' ) %]Available in the library
421
                                                        [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) | html %] [% END %]
420
                                                        [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.STATUS, 1 ) | html %] [% END %]
422
                                                        [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason | html %])[% END %]
421
                                                        [% IF ( suggestion.reason ) %]([% suggestion.reason | html %])[% END %]
423
                                                    </td>
422
                                                    </td>
424
                                                </tr>
423
                                                </tr>
425
                                            [% END # / FOREACH suggestions_loo %]
424
                                            [% END # / FOREACH suggestions %]
426
                                        </tbody>
425
                                        </tbody>
427
                                    </table>
426
                                    </table>
428
427
Lines 459-465 Link Here
459
                                        <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>
458
                                        <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>
460
                                    [% END %]
459
                                    [% END %]
461
                                [% END %]
460
                                [% END %]
462
                            [% END # / IF suggestions_loop %]
461
                            [% END # / IF suggestions.count %]
463
462
464
                        [% END # IF op_else %]
463
                        [% END # IF op_else %]
465
                    </div> <!-- / #usersuggestions -->
464
                    </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 (-45 / +31 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 $need_confirm    = 0;
43
my $need_confirm    = 0;
Lines 79-119 else { Link Here
79
    );
78
    );
80
}
79
}
81
80
82
# don't pass 'negcap' column to DB, else DBI::Class will error
81
my $suggested_by;
83
# DBIx::Class::Row::store_column(): No such column 'negcap' on Koha::Schema::Result::Suggestion at  Koha/C4/Suggestions.pm
84
delete $suggestion->{negcap};
85
delete $suggestion->{$_} foreach qw<op suggested_by_anyone confirm>;
86
87
if ( $op eq 'else' ) {
82
if ( $op eq 'else' ) {
88
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
83
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
89
        if ( $borrowernumber ) {
84
        if ( $borrowernumber ) {
90
            # A logged in user is able to see suggestions from others
85
            # A logged in user is able to see suggestions from others
91
            $suggestion->{suggestedby} = $suggested_by_anyone
86
            $suggested_by = $suggested_by_anyone
92
                ? undef
87
                ? undef
93
                : $borrowernumber;
88
                : $borrowernumber;
94
        }
89
        }
95
        else {
90
        # else: Non logged in user is able to see all suggestions
96
            # Non logged in user is able to see all suggestions
97
            $suggestion->{suggestedby} = undef;
98
        }
99
    }
91
    }
100
    else {
92
    else {
101
        if ( $borrowernumber ) {
93
        if ( $borrowernumber ) {
102
            $suggestion->{suggestedby} = $borrowernumber;
94
            $suggested_by = $borrowernumber;
103
        }
95
        }
104
        else {
96
        else {
105
            $suggestion->{suggestedby} = -1;
97
            $suggested_by = -1;
106
        }
98
        }
107
    }
99
    }
108
} else {
100
} else {
109
    if ( $borrowernumber ) {
101
    if ( $borrowernumber ) {
110
        $suggestion->{suggestedby} = $borrowernumber;
102
        $suggested_by = $borrowernumber;
111
    }
103
    }
112
    else {
104
    else {
113
        $suggestion->{suggestedby} = C4::Context->preference("AnonymousPatron");
105
        $suggested_by = C4::Context->preference("AnonymousPatron");
114
    }
106
    }
115
}
107
}
116
108
109
my @suggestion_fields =
110
  qw( title author copyrightdate isbn publishercode collectiontitle place quantity itemtype patronreason note );
111
my $suggestion = {
112
    map {
113
        # Keep parameters that are not an empty string
114
        my $p = $input->param($_);
115
        ( defined $p && $p ne '' ? ( $_ => $p ) : () )
116
    } @suggestion_fields
117
};
118
$suggestion->{suggestedby} = $borrowernumber;
119
117
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
120
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
118
    $op = 'add_confirm';
121
    $op = 'add_confirm';
119
    my $biblio = MarcRecordFromNewSuggestion($suggestion);
122
    my $biblio = MarcRecordFromNewSuggestion($suggestion);
Lines 139-145 if ( $borrowernumber ){ Link Here
139
}
142
}
140
143
141
if ( $op eq "add_confirm" ) {
144
if ( $op eq "add_confirm" ) {
142
    my $suggestions_loop = &SearchSuggestion($suggestion);
145
    my $suggestions = Koha::Suggestions->search($suggestion);
143
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && $patrons_total_suggestions_count >= C4::Context->preference("MaxTotalSuggestions") )
146
    if ( C4::Context->preference("MaxTotalSuggestions") ne '' && $patrons_total_suggestions_count >= C4::Context->preference("MaxTotalSuggestions") )
144
    {
147
    {
145
        push @messages, { type => 'error', code => 'total_suggestions' };
148
        push @messages, { type => 'error', code => 'total_suggestions' };
Lines 148-162 if ( $op eq "add_confirm" ) { Link Here
148
    {
151
    {
149
        push @messages, { type => 'error', code => 'too_many' };
152
        push @messages, { type => 'error', code => 'too_many' };
150
    }
153
    }
151
    elsif ( @$suggestions_loop >= 1 ) {
154
    elsif ( $suggestions->count >= 1 ) {
152
155
153
        #some suggestion are answering the request Donot Add
156
        #some suggestion are answering the request Donot Add
154
        for my $suggestion (@$suggestions_loop) {
157
        while ( my $suggestion = $suggestions->next ) {
155
            push @messages,
158
            push @messages,
156
              {
159
              {
157
                type => 'error',
160
                type => 'error',
158
                code => 'already_exists',
161
                code => 'already_exists',
159
                id   => $suggestion->{suggestionid}
162
                id   => $suggestion->suggestionid
160
              };
163
              };
161
            last;
164
            last;
162
        }
165
        }
Lines 176-194 if ( $op eq "add_confirm" ) { Link Here
176
        $patrons_pending_suggestions_count++;
179
        $patrons_pending_suggestions_count++;
177
        $patrons_total_suggestions_count++;
180
        $patrons_total_suggestions_count++;
178
181
179
        # delete empty fields, to avoid filter in "SearchSuggestion"
180
        foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
181
            delete $suggestion->{$field}; #clear search filters (except borrower related) to show all suggestions after placing a new one
182
        }
183
        $suggestions_loop = &SearchSuggestion($suggestion);
184
185
        push @messages, { type => 'info', code => 'success_on_inserted' };
182
        push @messages, { type => 'info', code => 'success_on_inserted' };
186
183
187
    }
184
    }
188
    $op = 'else';
185
    $op = 'else';
189
}
186
}
190
187
191
my $suggestions_loop = &SearchSuggestion({suggestedby => $suggestion->{suggestedby}});
188
my $suggestions = Koha::Suggestions->search_limited(
189
    {
190
        $suggestion->{suggestedby}
191
        ? ( suggestedby => $suggestion->{suggestedby} )
192
        : ()
193
    }
194
);
195
192
if ( $op eq "delete_confirm" ) {
196
if ( $op eq "delete_confirm" ) {
193
    my @delete_field = $input->multi_param("delete_field");
197
    my @delete_field = $input->multi_param("delete_field");
194
    foreach my $delete_field (@delete_field) {
198
    foreach my $delete_field (@delete_field) {
Lines 199-222 if ( $op eq "delete_confirm" ) { Link Here
199
    exit;
203
    exit;
200
}
204
}
201
205
202
map{
203
    my $s = $_;
204
    my $library = Koha::Libraries->find($s->{branchcodesuggestedby});
205
    $library ? $s->{branchcodesuggestedby} = $library->branchname : ()
206
} @$suggestions_loop;
207
208
foreach my $suggestion(@$suggestions_loop) {
209
    if($suggestion->{'suggestedby'} == $borrowernumber) {
210
        $suggestion->{'showcheckbox'} = $borrowernumber;
211
    } else {
212
        $suggestion->{'showcheckbox'} = 0;
213
    }
214
    if($suggestion->{'patronreason'}){
215
        my $av = Koha::AuthorisedValues->search({ category => 'OPAC_SUG', authorised_value => $suggestion->{patronreason} });
216
        $suggestion->{'patronreason'} = $av->count ? $av->next->opac_description : '';
217
    }
218
}
219
220
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG", "opac");
206
my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG", "opac");
221
207
222
my @mandatoryfields;
208
my @mandatoryfields;
Lines 254-260 my @unwantedfields; Link Here
254
240
255
$template->param(
241
$template->param(
256
    %$suggestion,
242
    %$suggestion,
257
    suggestions_loop      => $suggestions_loop,
243
    suggestions           => $suggestions,
258
    patron_reason_loop    => $patron_reason_loop,
244
    patron_reason_loop    => $patron_reason_loop,
259
    "op_$op"              => 1,
245
    "op_$op"              => 1,
260
    $op                   => 1,
246
    $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