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