Bug 23991: Move SearchSuggestion to Koha::Suggestions
[srvgit] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-suggestions.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE Branches %]
5 [% USE AuthorisedValues %]
6 [% USE KohaDates %]
7 [% USE AdditionalContents %]
8 [% SET opacsuggestion = AdditionalContents.get( location => "OpacSuggestioninstructions", lang => lang, library => logged_in_user.branchcode || default_branch ) %]
9 [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
10 [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
11 [% INCLUDE 'doc-head-open.inc' %]
12 <title>[% IF ( op_add ) %]Enter a new purchase suggestion[% END %]
13 [% IF ( op_else ) %]Purchase suggestions[% END %] &rsaquo;
14 [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
15 [% INCLUDE 'doc-head-close.inc' %]
16 [% BLOCK cssinclude %][% END %]
17 </head>
18 [% IF ( loggedinusername ) %][% INCLUDE 'bodytag.inc' bodyid='opac-usersuggestions' bodyclass='scrollto' %][% ELSE %][% INCLUDE 'bodytag.inc' bodyid='opac-suggestions' bodyclass='scrollto' %][% END %]
19 [% INCLUDE 'masthead.inc' %]
20
21     <div class="main">
22         <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumbs">
23             <ol class="breadcrumb">
24                 <li class="breadcrumb-item">
25                     <a href="/cgi-bin/koha/opac-main.pl">Home</a>
26                 </li>
27                 <li class="breadcrumb-item">
28                     <a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a>
29                 </li>
30                 <li class="breadcrumb-item active">
31                     <a href="#" aria-current="page">Your purchase suggestions</a>
32                 </li>
33             </ol>
34         </nav> <!-- /#breadcrumbs -->
35
36         <div class="container-fluid">
37             <div class="row">
38                 <div class="col col-lg-2 order-2 order-lg-1">
39                     <div id="navigation">
40                         [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
41                     </div>
42                 </div>
43                 <div class="col-md-12 col-lg-10 order-1">
44
45                     <div id="usersuggestions" class="maincontent">
46                         [% IF ( op_add ) %]
47                             <h1>Your purchase suggestions</h1>
48                             [% IF ( Koha.Preference('MaxTotalSuggestions') != '' && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
49                                     <h2 class="TooManySuggestions">You cannot place any more suggestions</h2>
50                                     <p class="TooManySuggestionsText">You may only add up to [% Koha.Preference('MaxTotalSuggestions') | html %] suggestions in [% Koha.Preference('NumberOfSuggestionDays') | html %] days.</p>
51                             [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
52                                     <h2 class="TooManySuggestions">You cannot place any more suggestions</h2>
53                                     <p class="TooManySuggestionsText">You have reached your limit for suggestions you can place at this time ([% Koha.Preference('MaxOpenSuggestions') | html %]). Once the library has processed those suggestions you will be able to place more.</p>
54                             [% ELSE %]
55
56                             [% IF ( opacsuggestion ) %]
57                                 [% PROCESS koha_news_block news => opacsuggestion %]
58                             [% ELSE %]
59                                 <h2>Enter a new purchase suggestion</h2>
60
61                                 <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion.</p>
62                                 <p>Only certain fields (marked in red) are required, but the more information you enter the easier it will be for the librarians to find the title you're requesting. The "Notes" field can be used to provide any additional information.</p>
63                             [% END %]
64                             [% FOR m IN messages %]
65                                 <div class="alert alert-[% m.type | html %]">
66                                     [% SWITCH m.code %]
67                                     [% CASE 'biblio_exists' %]
68                                         <span>A similar document already exists: <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% m.id | uri %]">[% m.title | html %]</a>. Click on "Confirm your suggestion" to ignore this message.</span>
69                                     [% CASE %]
70                                         <span>[% m.code | html %]</span>
71                                     [% END %]
72                                 </div>
73                             [% END %]
74
75                             <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="add_suggestion_form">
76                                 <fieldset class="rows">
77                                     <ol>
78                                         [% IF Koha.Preference( 'OPACSuggestionAutoFill' ) %]
79                                             <li>
80                                                 <label for="isbn">Standard number (ISBN, ISSN or other):</label>
81                                                 <input type="text" id="isbn" name="isbn" maxlength="80" style="margin-right:10px;margin-top:10px;" size="15"/>
82                                             </li>
83                                         [% END %]
84                                         <li>
85                                             [% IF ( title_required ) %]
86                                                 <label for="title" class="required">Title:</label>
87                                                 <input type="text" id="title" name="title" class="span6" maxlength="255" value="[% title | html %]" required="required" />
88                                                 <div class="required_label required">Required</div>
89                                             [% ELSE %]
90                                                 <label for="title">Title:</label>
91                                                 <input type="text" id="title" name="title" class="span6" maxlength="255" value="[% title | html %]" />
92                                             [% END %]
93                                         </li>
94                                         [% UNLESS ( author_hidden ) %]
95                                             <li>
96                                                     [% IF ( author_required ) %]
97                                                         <label for="author" class="required">Author:</label>
98                                                         <input type="text" id="author" name="author" class="span6" maxlength="80" value="[% author | html %]" required="required" />
99                                                         <div class="required_label required">Required</div>
100                                                     [% ELSE %]
101                                                         <label for="author">Author:</label>
102                                                         <input type="text" id="author" name="author" class="span6" maxlength="80" value="[% author | html %]" />
103                                                     [% END %]
104                                             </li>
105                                         [% END %]
106                                         [% UNLESS ( copyrightdate_hidden )%]
107                                             <li>
108                                                 <div title="Copyright or publication year, for example: 2022">
109                                                     [% IF ( copyrightdate_required ) %]
110                                                         <label for="copyrightdate" class="required">Publication year:</label>
111                                                         <input type="text" id="copyrightdate" name="copyrightdate" pattern="[12]\d{3}" size="10" maxlength="4" value="[% copyrightdate | html %]" required="required" />
112                                                         <div class="required_label required">Required</div>
113                                                     [% ELSE %]
114                                                         <label for="copyrightdate">Publication year:</label>
115                                                         <input type="text" id="copyrightdate" name="copyrightdate" pattern="[12]\d{3}" size="10" maxlength="4" value="[% copyrightdate | html %]" />
116                                                     [% END %]
117                                                     <span class="hint">Copyright or publication year, for example: 2022</span>
118                                                 </div>
119                                             </li>
120                                         [% END %]
121                                         [% UNLESS ( isbn_hidden or Koha.Preference('OPACSuggestionAutoFill') ) %]
122                                             <li>
123                                                 [% IF ( isbn_required ) %]
124                                                     <label for="isbn" class="required">Standard number (ISBN, ISSN or other):</label>
125                                                     <input type="text" id="isbn" name="isbn"  maxlength="80" value="[% isbn | html %]" required="required" />
126                                                     <div class="required_label required">Required</div>
127                                                 [% ELSE %]
128                                                     <label for="isbn">Standard number (ISBN, ISSN or other):</label>
129                                                     <input type="text" id="isbn" name="isbn"  maxlength="80" value="[% isbn | html %]" />
130                                                 [% END %]
131                                             </li>
132                                         [% END %]
133                                         [% UNLESS ( publishercode_hidden ) %]
134                                             <li>
135                                                 [% IF ( publishercode_required ) %]
136                                                     <label for="publishercode" class="required">Publisher:</label>
137                                                     <input type="text" id="publishercode" name="publishercode" class="span6" maxlength="80" value="[% publishercode | html %]" required="required" />
138                                                     <div class="required_label required">Required</div>
139                                                 [% ELSE %]
140                                                     <label for="publishercode">Publisher:</label>
141                                                     <input type="text" id="publishercode" name="publishercode" class="span6" maxlength="80" value="[% publishercode | html %]" />
142                                                 [% END %]
143                                             </li>
144                                         [% END %]
145                                         [% UNLESS ( collectiontitle_hidden ) %]
146                                             <li>
147                                                 [% IF ( collectiontitle_required ) %]
148                                                     <label for="collectiontitle" class="required">Collection title:</label>
149                                                     <input type="text" id="collectiontitle" name="collectiontitle" class="span6" maxlength="80" value="[% collectiontitle | html %]" required="required" />
150                                                     <div class="required_label required">Required</div>
151                                                 [% ELSE %]
152                                                     <label for="collectiontitle">Collection title:</label>
153                                                     <input type="text" id="collectiontitle" name="collectiontitle" class="span6" maxlength="80" value="[% collectiontitle | html %]" />
154                                                 [% END %]
155                                             </li>
156                                         [% END %]
157                                         [% UNLESS ( place_hidden ) %]
158                                             <li>
159                                                 [% IF ( place_required ) %]
160                                                     <label for="place" class="required">Publication place:</label>
161                                                     <input type="text" id="place" name="place" required="required" maxlength="80" value="[% place | html %]" />
162                                                     <div class="required_label required">Required</div>
163                                                 [% ELSE %]
164                                                     <label for="place">Publication place:</label>
165                                                     <input type="text" id="place" name="place"  maxlength="80" value="[% place | html %]" />
166                                                 [% END %]
167                                             </li>
168                                         [% END %]
169                                         [% UNLESS ( quantity_hidden ) %]
170                                             <li id="opac-suggestion-quantity">
171                                                 [% IF ( quantity_required ) %]
172                                                     <label for="quantity" class="required">Quantity:</label>
173                                                     <input type="text" id="quantity" name="quantity" required="required" maxlength="4" size="4" value="[% quantity | html %]" />
174                                                     <div class="required_label required">Required</div>
175                                                 [% ELSE %]
176                                                     <label for="quantity">Quantity:</label>
177                                                     <input type="text" id="quantity" name="quantity"  maxlength="4" size="4" value="[% quantity | html %]" />
178                                                 [% END %]
179                                             </li>
180                                         [% END %]
181                                         [% UNLESS ( itemtype_hidden )%]
182                                             <li>
183                                             [% IF ( itemtype_required ) %]
184                                                 <label for="itemtype" class="required">Item type:</label>
185                                                 [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20, required = 1, blank = 1, default=itemtype %]
186                                                 <div class="required_label required">Required</div>
187                                             [% ELSE %]
188                                                 <label for="itemtype">Item type:</label>
189                                                 [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20, blank = 1, default=itemtype %]
190                                             [% END %]
191                                             </li>
192                                         [% END %]
193                                         [% UNLESS ( branchcode_hidden )%]
194                                             <li>
195                                                 [% IF ( branchcode_required ) %]
196                                                     <label for="branch" class="required">Library:</label>
197                                                     <select name="branchcode" id="branch" required="required">
198                                                         <option value=""></option>
199                                                         [% PROCESS options_for_libraries libraries => Branches.all( selected => logged_in_user.branchcode ) %]
200                                                     </select>
201                                                     <div class="required_label required">Required</div>
202                                                 [% ELSE %]
203                                                     <label for="branch">Library:</label>
204                                                     <select name="branchcode" id="branch">
205                                                         [% PROCESS options_for_libraries libraries => Branches.all( selected => logged_in_user.branchcode ) %]
206                                                     </select>
207                                                 [% END %]
208                                             </li>
209                                         [% END %]
210                                         [% IF ( patron_reason_loop ) %]
211                                         [% UNLESS ( patronreason_hidden )%]
212                                             <li>
213                                                 [% IF ( patronreason_required ) %]
214                                                     <label for="patronreason" class="required">Reason for suggestion: </label>
215                                                     <select name="patronreason" id="patronreason" required="required">
216                                                         <option value="">-- Choose --</option>
217                                                         [% FOREACH patron_reason_loo IN patron_reason_loop %]
218                                                             [% IF patron_reason_loo.authorised_value == patronreason %]
219                                                                 <option value="[% patron_reason_loo.authorised_value | html %]" selected="selected">[% patron_reason_loo.lib | html %]</option>
220                                                             [% ELSE %]
221                                                                 <option value="[% patron_reason_loo.authorised_value | html %]">[% patron_reason_loo.lib | html %]</option>
222                                                             [% END %]
223                                                         [% END %]
224                                                     </select>
225                                                     <div class="required_label required">Required</div>
226                                                 [% ELSE %]
227                                                     <label for="patronreason">Reason for suggestion: </label>
228                                                     <select name="patronreason" id="patronreason">
229                                                         <option value="">-- Choose --</option>
230                                                         [% FOREACH patron_reason_loo IN patron_reason_loop %]
231                                                             [% IF patron_reason_loo.authorised_value == patronreason %]
232                                                                 <option value="[% patron_reason_loo.authorised_value | html %]" selected="selected">[% patron_reason_loo.lib | html %]</option>
233                                                             [% ELSE %]
234                                                                 <option value="[% patron_reason_loo.authorised_value | html %]">[% patron_reason_loo.lib | html %]</option>
235                                                             [% END %]
236                                                         [% END %]
237                                                     </select>
238                                                 [% END %]
239                                             </li>
240                                         [% END %]
241                                         [% END %]
242                                         [% UNLESS ( note_hidden ) %]
243                                             <li>
244                                                 [% IF ( note_required ) %]
245                                                     <label for="note" class="required">Notes:</label>
246                                                     <textarea name="note" id="note" rows="5" cols="40" required="required">[% note | html %]</textarea>
247                                                     <div class="required_label required">Required</div>
248                                                 [% ELSE %]
249                                                     <label for="note">Notes:</label>
250                                                     <textarea name="note" id="note" rows="5" cols="40">[% note | html %]</textarea>
251                                                 [% END %]
252                                             </li>
253                                         [% END %]
254
255                                         <!--  Add a hidden 'negcap' field -->
256                                         <li id="negcap" style="position: absolute; left: -2000px;">
257                                             negcap <input type="text" name="negcap"/>
258                                         </li>
259
260                                     </ol>
261                                 </fieldset>
262                                 <fieldset class="action">
263                                     <input type="hidden" name="suggested_by_anyone" value="[% suggested_by_anyone | html %]" />
264                                     [% IF need_confirm # Confirm that we want a duplicate %]
265                                         <input type="hidden" name="op" value="add_confirm" />
266                                         <input type="submit" class="btn btn-primary" value="Confirm your suggestion" />
267                                     [% ELSIF biblionumber # Create from an existing title %]
268                                         <input type="hidden" name="op" value="add_confirm" />
269                                         <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
270                                         <input type="submit" class="btn btn-primary" value="Submit your suggestion" />
271                                     [% ELSE # Not created from an existing title, search for possible duplicate %]
272                                         <input type="hidden" name="op" value="add_validate" />
273                                         <input type="submit" class="btn btn-primary" value="Submit your suggestion" />
274                                     [% END %]
275                                     <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a>
276                                 </fieldset>
277                             </form>
278                             [% END %]
279                         [% END #  IF op_add %]
280
281                         [% IF ( op_else ) %]
282                             <h1>
283                                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
284                                     <span>Purchase suggestions</span>
285                                 [% ELSE %]
286                                     [% IF ( loggedinusername ) %]
287                                         <span>Your purchase suggestions</span>
288                                     [% ELSE %]
289                                         <span>Purchase suggestions</span>
290                                     [% END %]
291                                 [% END %]
292                             </h1>
293                             [% FOR m IN messages %]
294                                 <div class="alert alert-[% m.type | html %]">
295                                     [% SWITCH m.code %]
296                                     [% CASE 'total_suggestions' %]
297                                         <span>The suggestion has not been added. You have reached your limit for suggestions you can place at this time ([% Koha.Preference('MaxTotalSuggestions') | html %] in [% Koha.Preference('NumberOfSuggestionDays') | html %] days).</span>
298                                     [% CASE 'too_many' %]
299                                         <span>The suggestion has not been added. You have reached your limit for suggestions you can place at this time ([% Koha.Preference('MaxOpenSuggestions') | html %]). Once the library has processed those suggestions you will be able to place more.</span>
300                                     [% CASE 'already_exists' %]
301                                         <span>The suggestion has not been added. A suggestion with this title already exists.</span>
302                                     [% CASE 'success_on_inserted' %]
303                                         <span>Your suggestion has been submitted.</span>
304                                     [% CASE %]
305                                         <span>[% m.code | html %]</span>
306                                     [% END %]
307                                 </div>
308                             [% END %]
309
310                             [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
311
312                             [% IF suggestions.size > 0 OR title_filter %]
313                                 [% SET can_delete_suggestion = 0 %]
314                                 <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" id="search_suggestions_form" method="get">
315                                     <div class="form-row">
316                                         <label for="title_filter">Search for:</label>
317                                         <input type="text" name="title_filter" id="title_filter" value="[% title_filter | html %]" />
318                                         [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
319                                             [% IF loggedinusername %]
320                                                 <div class="col-auto my-1">
321                                                     <label class="sr-only" for="suggested_by_anyone">Suggested by:</label>
322                                                     <select class="form-control form-control-sm" name="suggested_by_anyone" id="suggested_by_anyone">
323                                                         [% IF suggested_by_anyone %]
324                                                             <option value="0">Suggested by me</option>
325                                                             <option value="1" selected="selected">Suggested by anyone</option>
326                                                         [% ELSE %]
327                                                             <option value="0" selected="selected">Suggested by me</option>
328                                                             <option value="1">Suggested by anyone</option>
329                                                         [% END %]
330                                                     </select>
331                                                 </div>
332                                             [% END %]
333                                         [% END %]
334                                         <div class="col-auto my-1">
335                                             <button type="submit" class="btn btn-sm btn-primary">Go</button>
336                                         </div>
337                                     </div>
338                                 </form>
339                             [% END %]
340                             [% IF suggestions.size > 0 %]
341                                 [% SET can_delete_suggestion = 0 %]
342                                 <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="delete_suggestions">
343                                     <input type="hidden" name="op" value="delete_confirm" />
344                                     [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
345                                         <div id="toolbar" class="toolbar clearfix">
346                                         [% IF ( Koha.Preference('MaxTotalSuggestions') != '' && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
347                                                 <p class="TooManySuggestionsText">You may only add up to [% Koha.Preference('MaxTotalSuggestions') | html %] suggestions in [% Koha.Preference('NumberOfSuggestionDays') | html %] days.</p>
348                                         [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
349                                                 <p class="TooManySuggestionsText">You have reached your limit for suggestions you can place at this time ([% Koha.Preference('MaxOpenSuggestions') | html %]).</br>Once the library has processed those suggestions you will be able to place more.</p>
350                                         [% ELSE %]
351                                                 <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>
352                                         [% END %]
353                                         </div>
354                                     [% END %]
355
356                                     [% IF ( loggedinusername ) %]
357                                         <div class="selections-toolbar toolbar">
358                                             <div class="check_control">
359                                                 <span class="checkall"></span> <span class="clearall"></span>
360                                             </div>
361                                             <div class="links">
362                                                 <span class="selections">Select suggestions to: </span>
363                                                 <span id="removeitems">
364                                                     <a href="#" class="btn btn-link removeitems tag_hides disabled"><i class="fa fa-trash" aria-hidden="true"></i> Delete</a>
365                                                 </span>
366                                             </div>
367                                         </div>
368                                     [% END %]
369
370                                     <table id="suggestt" class="table table-bordered table-striped">
371                                         <caption class="sr-only">Your purchase suggestions<caption>
372                                         <thead>
373                                             <tr>
374                                                 [% IF ( loggedinusername ) %]<th>&nbsp;</th>[% END %]
375                                                 <th>Summary</th>
376                                                 <th>Suggested on</th>
377                                                 <th>Note</th>
378                                                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]<th>Suggested for</th>[% END %]
379                                                 [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]<th>Managed by</th>[% END %]
380                                                 <th>Status</th>
381                                             </tr>
382                                         </thead>
383                                         <tbody>
384                                             [% FOREACH suggestion IN suggestions %]
385                                                 <tr>
386                                                     [% IF logged_in_user %]
387                                                         <td class="selectcol">
388                                                             [% IF logged_in_user.borrowernumber == suggestion.suggester.borrowernumber %]
389                                                                 [% SET can_delete_suggestion = 1 %]
390                                                                 <input type="checkbox" class="cb" id="id[% suggestion.suggestionid | html %]" name="delete_field" data-title="[% suggestion.title | html %]" value="[% suggestion.suggestionid | html %]" />
391                                                             [% END %]
392                                                         </td>
393                                                     [% END %]
394                                                     <td>
395                                                         <p>
396                                                             <label for="id[% suggestions_loo.suggestionid | html %]">
397                                                                 [% IF suggestion.biblionumber %]
398                                                                     <strong><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% suggestion.biblionumber | uri %]">[% suggestion.title | html %]</a></strong>
399                                                                 [% ELSE %]
400                                                                     <strong>[% suggestion.title | html %]</strong>
401                                                                 [% END %]
402                                                             </label>
403                                                         </p>
404                                                             <p>[% IF ( suggestion.author ) %][% suggestion.author | html %],[% END %]
405                                                                 [% IF ( suggestion.copyrightdate ) %] - [% suggestion.copyrightdate | html %],[% END %]
406                                                                 [% IF ( suggestion.publishercode ) %] - [% suggestion.publishercode | html %][% END %]
407                                                                 [% IF ( suggestion.place ) %]([% suggestion.place | html %])[% END %]
408                                                                 [% IF ( suggestion.collectiontitle ) %] , [% suggestion.collectiontitle | html %][% END %]
409                                                                 [% IF ( suggestion.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestion.itemtype, 1 ) | html %][% END %]
410                                                         </p>
411                                                     </td>
412                                                     <td>
413                                                         [% IF ( suggestion.suggesteddate ) %][% suggestion.suggesteddate |$KohaDates %][% END %]
414                                                     </td>
415                                                     <td>
416                                                         [% IF ( suggestion.note ) %]
417                                                             <span class="tdlabel">Note: </span>
418                                                             [% suggestion.note | html %]
419                                                         [% END %]
420                                                     </td>
421                                                     [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
422                                                         <td>
423                                                             [% IF suggestion.suggestedby %]
424                                                                 <span class="tdlabel">Suggested for:</span>
425                                                                 [% Branches.GetName(suggestion.suggester.branchcode) | html %]
426                                                             [% END %]
427                                                         </td>
428                                                     [% END %]
429                                                     [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
430                                                     <td>
431                                                         [% IF suggestion.managedby %]
432                                                             <span class="tdlabel">Managed by:</span>
433                                                             [% INCLUDE 'patron-title.inc' patron = suggestion.manager %]
434                                                             [% IF ( suggestion.manageddate ) %] - [% suggestion.manageddate | $KohaDates %][% END %]
435                                                         [% END %]
436                                                     </td>
437                                                     [% END %]
438                                                     <td>
439                                                         <span class="tdlabel">Status:</span>
440                                                         [% IF ( suggestion.STATUS == 'ASKED' ) %]<span>Requested</span>
441                                                         [% ELSIF ( suggestion.STATUS == 'CHECKED' ) %]<span>Checked by the library</span>
442                                                         [% ELSIF ( suggestion.STATUS == 'ACCEPTED' ) %]<span>Accepted by the library</span>
443                                                         [% ELSIF ( suggestion.STATUS == 'ORDERED' ) %]<span>Ordered by the library</span>
444                                                         [% ELSIF ( suggestion.STATUS == 'REJECTED' ) %]<span>Suggestion declined</span>
445                                                         [% ELSIF ( suggestion.STATUS == 'AVAILABLE' ) %]<span>Available in the library</span>
446                                                         [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestion.STATUS, 1 ) | html %] [% END %]
447                                                         [% IF ( suggestion.reason ) %]([% suggestion.reason | html %])[% END %]
448                                                     </td>
449                                                 </tr>
450                                             [% END # / FOREACH suggestions %]
451                                         </tbody>
452                                     </table>
453
454                                     [% IF ( loggedinusername && can_delete_suggestion ) %]
455                                         <fieldset class="action">
456                                             <input type="submit" class="btn btn-danger removeitems" value="Delete selected" />
457                                         </fieldset>
458                                     [% END %]
459                                 </form>
460                             [% ELSE %]
461                                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) %]
462                                     [% IF title_filter %]
463                                         <p>There are no pending purchase suggestions matching your search.</p>
464                                     [% ELSIF loggedinusername AND NOT suggested_by_anyone %]
465                                         <p>You have no pending purchase suggestions. <a href="/cgi-bin/koha/opac-suggestions.pl?suggested_by_anyone=1">View all suggestions</a></p>
466                                     [% ELSE %]
467                                         <p>There are no pending purchase suggestions.</p>
468                                     [% END %]
469                                 [% ELSE %]
470                                     [% IF ( loggedinusername ) %]
471                                         [% IF title_filter %]
472                                             <p>There are no pending purchase suggestions matching your search.</p>
473                                         [% ELSE %]
474                                             <p>You have no pending purchase suggestions.</p>
475                                         [% END %]
476                                     [% ELSE %]
477                                         <p>You are not authorized to see pending purchase suggestions.</p>
478                                     [% END %]
479                                 [% END %]
480                                 [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
481                                     [% IF ( Koha.Preference('MaxTotalSuggestions') != ''  && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
482                                         <p class="TooManySuggestionsText">You may only add up to [% Koha.Preference('MaxTotalSuggestions') | html %] suggestions in [% Koha.Preference('NumberOfSuggestionDays') | html %] days.</p>
483                                     [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != ''  && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
484                                         <p class="TooManySuggestionsText">You have reached your limit for suggestions you can place at this time.</br>Once the library has processed those suggestions you will be able to place more.</p>
485                                     [% ELSE %]
486                                         <p><a class="btn btn-link new" href="/cgi-bin/koha/opac-suggestions.pl?op=add"><i class="fa fa-plus" aria-hidden="true"></i> New purchase suggestion</a></p>
487                                     [% END %]
488                                 [% END %]
489                             [% END # / IF suggestions.size %]
490
491                         [% END # IF op_else %]
492                     </div> <!-- / #usersuggestions -->
493                 </div> <!-- / .col-lg-10 -->
494             </div> <!-- / .row -->
495         </div> <!-- / .container-fluid -->
496     </div> <!-- / .main -->
497
498 [% INCLUDE 'opac-bottom.inc' %]
499 [% BLOCK jsinclude %]
500 [% IF ( Koha.Preference("OPACSuggestionAutoFill") != 'no' ) %]
501     [% Asset.js("js/autofill.js") | $raw %]
502 [% END %]
503 [% INCLUDE 'datatables.inc' %]
504 <script>
505     [% IF ( loggedinusername ) %]
506         function enableCheckboxActions(){
507             // Enable/disable controls if checkboxes are checked
508             var checkedBoxes = $(".cb:checked");
509             if ($(checkedBoxes).size()) {
510               $(".selections").html(_("With selected suggestions: "));
511               $(".selections-toolbar .links a").removeClass("disabled");
512             } else {
513               $(".selections").html(_("Select suggestions to: "));
514               $(".selections-toolbar .links a").addClass("disabled");
515             }
516         }
517     [% END %]
518
519     [% IF Koha.Preference( 'OPACSuggestionAutoFill' ) %]
520     $(function() {
521         $('#isbn').autofill({
522             'volumeInfo.title': {target: 'title', effect: 'flash'},
523             'volumeInfo.authors': {target: 'author', effect: 'flash'},
524             'volumeInfo.publisher': {target: 'publishercode', effect: 'flash'},
525             'volumeInfo.publishedDate': {target: 'copyrightdate', effect: 'flash'},
526             /* google books api seem to only have books, so if we got a result
527              * item, type will be a book, so set to BK (book). */
528             'kind': {target: 'itemtype', handle: function(t,v) { t.val('BK'); },},
529         });
530     });
531     [% END %]
532
533     $(function() {
534         $("#suggestt").dataTable($.extend(true, {}, dataTablesDefaults, {
535             "order": [[ 1, "asc" ]],
536             "autoWidth": false,
537             "columnDefs": [
538               [% IF ( loggedinusername ) %]{ "targets": [ 0 ], "sortable": false, "searchable": false }[% END %]
539             ],
540             "columns": [
541                 [% IF ( loggedinusername ) %]null,[% END %]
542                 { "type": "anti-the" },
543                 null,
544                 null,
545                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]null,[% END %]
546                 [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]null,[% END %]
547                 null
548             ]
549         }));
550         [% IF ( loggedinusername ) %]$("span.clearall").html("<a id=\"CheckNone\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Clear all")+"<\/a>");
551         $("span.checkall").html("<a id=\"CheckAll\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Select all")+"<\/a>");
552         $("#CheckAll").on("click",function(e){
553             e.preventDefault();
554             $(".cb").prop("checked", true);
555             enableCheckboxActions();
556         });
557         $("#CheckNone").on("click",function(e){
558             e.preventDefault();
559             $(".cb").prop("checked", false);
560             enableCheckboxActions();
561         });
562         $(".cb").click(function(){
563           enableCheckboxActions();
564         });
565
566         enableCheckboxActions();
567
568         $(".removeitems").on("click", function(e) {
569             e.preventDefault();
570             var selected_titles = $("input:checked");
571             var title;
572             var yes_label;
573             var no_label;
574             var message = "";
575             if ( selected_titles.size() < 1 ) {
576                 alert(MSG_NO_SUGGESTION_SELECTED);
577                 return false;
578             } else {
579                 if( selected_titles.size() > 1 ){
580                     message = $("<ul></ul>");
581                     title = _("Are you sure you want to delete these suggestions?");
582                     yes_label = _("Yes, delete suggestions");
583                     no_label = _("No, do not delete suggestions");
584                     selected_titles.each(function(){
585                         message.append( "<li>" +  $(this).data("title") + "</li>" );
586                     });
587                 } else {
588                     title = _("Are you sure you want to delete this suggestion?");
589                     yes_label = _("Yes, delete suggestion");
590                     no_label = _("No, do not delete suggestion");
591                     selected_titles.each(function(){
592                         message += $(this).data("title");
593                     });
594                 }
595                 confirmModal( message, title, yes_label, no_label, function( result ){
596                     if( result ){
597                         $("#delete_suggestions").submit();
598                     }
599                 });
600             }
601         });
602         [% END %]
603     });
604 </script>
605 [% END %]