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