Bug 28569: In opac-suggestions.pl preselect user library
[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 => Branches.GetLoggedInBranchcode ) %]
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 %]
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 %]
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                                         <caption class="sr-only">Your purchase suggestions<caption>
353                                         <thead>
354                                             <tr>
355                                                 [% IF ( loggedinusername ) %]<th>&nbsp;</th>[% END %]
356                                                 <th>Summary</th>
357                                                 <th>Suggested on</th>
358                                                 <th>Note</th>
359                                                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]<th>Suggested for</th>[% END %]
360                                                 [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]<th>Managed by</th>[% END %]
361                                                 <th>Status</th>
362                                             </tr>
363                                         </thead>
364                                         <tbody>
365                                             [% FOREACH suggestions_loo IN suggestions_loop %]
366                                                 <tr>
367                                                     [% IF ( loggedinusername ) %]
368                                                         <td class="selectcol">
369                                                             [% IF ( suggestions_loo.showcheckbox ) %]
370                                                                 [% SET can_delete_suggestion = 1 %]
371                                                                 <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 %]" />
372                                                             [% END %]
373                                                         </td>
374                                                     [% END %]
375                                                     <td>
376                                                         <p>
377                                                             <label for="id[% suggestions_loo.suggestionid | html %]">
378                                                                 [% IF suggestions_loo.biblionumber %]
379                                                                     <strong><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% suggestions_loo.biblionumber | uri %]">[% suggestions_loo.title | html %]</a></strong>
380                                                                 [% ELSE %]
381                                                                     <strong>[% suggestions_loo.title | html %]</strong>
382                                                                 [% END %]
383                                                             </label>
384                                                         </p>
385                                                             <p>[% IF ( suggestions_loo.author ) %][% suggestions_loo.author | html %],[% END %]
386                                                                 [% IF ( suggestions_loo.copyrightdate ) %] - [% suggestions_loo.copyrightdate | html %],[% END %]
387                                                                 [% IF ( suggestions_loo.publishercode ) %] - [% suggestions_loo.publishercode | html %][% END %]
388                                                                 [% IF ( suggestions_loo.place ) %]([% suggestions_loo.place | html %])[% END %]
389                                                                 [% IF ( suggestions_loo.collectiontitle ) %] , [% suggestions_loo.collectiontitle | html %][% END %]
390                                                                 [% IF ( suggestions_loo.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 1 ) | html %][% END %]
391                                                         </p>
392                                                     </td>
393                                                     <td>
394                                                         [% IF ( suggestions_loo.suggesteddate ) %][% suggestions_loo.suggesteddate |$KohaDates %][% END %]
395                                                     </td>
396                                                     <td>
397                                                         [% IF ( suggestions_loo.note ) %]
398                                                             <span class="tdlabel">Note: </span>
399                                                             [% suggestions_loo.note | html %]
400                                                         [% END %]
401                                                     </td>
402                                                     [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
403                                                         <td>
404                                                             [% IF ( suggestions_loo.branchcodesuggestedby ) %]
405                                                                 <span class="tdlabel">Suggested for:</span>
406                                                                 [% suggestions_loo.branchcodesuggestedby | html %]
407                                                             [% END %]
408                                                         </td>
409                                                     [% END %]
410                                                     [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
411                                                     <td>
412                                                         [% IF ( suggestions_loo.surnamemanagedby ) %]
413                                                             <span class="tdlabel">Managed by:</span>
414                                                             [% suggestions_loo.surnamemanagedby | html %]
415                                                             [% IF ( suggestions_loo.firstnamemanagedby ) %]    , [% suggestions_loo.firstnamemanagedby | html %]
416                                                             [% END %]
417                                                         [% END %]
418                                                     </td>
419                                                     [% END %]
420                                                     <td>
421                                                         <span class="tdlabel">Status:</span>
422                                                         [% IF ( suggestions_loo.ASKED ) %]Requested
423                                                         [% ELSIF ( suggestions_loo.CHECKED ) %]Checked by the library
424                                                         [% ELSIF ( suggestions_loo.ACCEPTED ) %]Accepted by the library
425                                                         [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library
426                                                         [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined
427                                                         [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library
428                                                         [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) | html %] [% END %]
429                                                         [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason | html %])[% END %]
430                                                     </td>
431                                                 </tr>
432                                             [% END # / FOREACH suggestions_loo %]
433                                         </tbody>
434                                     </table>
435
436                                     [% IF ( loggedinusername && can_delete_suggestion ) %]
437                                         <fieldset class="action">
438                                             <input type="submit" class="btn btn-danger removeitems" value="Delete selected" />
439                                         </fieldset>
440                                     [% END %]
441                                 </form>
442                             [% ELSE %]
443                                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) %]
444                                     [% IF title_filter %]
445                                         <p>There are no pending purchase suggestions matching your search.</p>
446                                     [% ELSIF loggedinusername AND NOT suggested_by_anyone %]
447                                         <p>You have no pending purchase suggestions. <a href="/cgi-bin/koha/opac-suggestions.pl?suggested_by_anyone=1">View all suggestions</a></p>
448                                     [% ELSE %]
449                                         <p>There are no pending purchase suggestions.</p>
450                                     [% END %]
451                                 [% ELSE %]
452                                     [% IF ( loggedinusername ) %]
453                                         [% IF title_filter %]
454                                             <p>There are no pending purchase suggestions matching your search.</p>
455                                         [% ELSE %]
456                                             <p>You have no pending purchase suggestions.</p>
457                                         [% END %]
458                                     [% ELSE %]
459                                         <p>You are not authorized to see pending purchase suggestions.</p>
460                                     [% END %]
461                                 [% END %]
462                                 [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
463                                     [% IF ( Koha.Preference('MaxTotalSuggestions') != ''  && patrons_total_suggestions_count >= Koha.Preference('MaxTotalSuggestions') ) %]
464                                         <p class="TooManySuggestionsText">You may only add up to [% Koha.Preference('MaxTotalSuggestions') | html %] suggestions in [% Koha.Preference('NumberOfSuggestionDays') | html %] days.</p>
465                                     [% ELSIF ( Koha.Preference('MaxOpenSuggestions') != ''  && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
466                                         <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>
467                                     [% ELSE %]
468                                         <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>
469                                     [% END %]
470                                 [% END %]
471                             [% END # / IF suggestions_loop %]
472
473                         [% END # IF op_else %]
474                     </div> <!-- / #usersuggestions -->
475                 </div> <!-- / .col-lg-10 -->
476             </div> <!-- / .row -->
477         </div> <!-- / .container-fluid -->
478     </div> <!-- / .main -->
479
480 [% INCLUDE 'opac-bottom.inc' %]
481 [% BLOCK jsinclude %]
482 [% INCLUDE 'datatables.inc' %]
483 <script>
484     [% IF ( loggedinusername ) %]
485         function enableCheckboxActions(){
486             // Enable/disable controls if checkboxes are checked
487             var checkedBoxes = $(".cb:checked");
488             if ($(checkedBoxes).size()) {
489               $(".selections").html(_("With selected suggestions: "));
490               $(".selections-toolbar .links a").removeClass("disabled");
491             } else {
492               $(".selections").html(_("Select suggestions to: "));
493               $(".selections-toolbar .links a").addClass("disabled");
494             }
495         }
496     [% END %]
497
498     $(function() {
499         $("#suggestt").dataTable($.extend(true, {}, dataTablesDefaults, {
500             "order": [[ 1, "asc" ]],
501             "autoWidth": false,
502             "columnDefs": [
503               [% IF ( loggedinusername ) %]{ "targets": [ 0 ], "sortable": false, "searchable": false }[% END %]
504             ],
505             "columns": [
506                 [% IF ( loggedinusername ) %]null,[% END %]
507                 { "type": "anti-the" },
508                 null,
509                 null,
510                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]null,[% END %]
511                 [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]null,[% END %]
512                 null
513             ]
514         }));
515         [% IF ( loggedinusername ) %]$("span.clearall").html("<a id=\"CheckNone\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Clear all")+"<\/a>");
516         $("span.checkall").html("<a id=\"CheckAll\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Select all")+"<\/a>");
517         $("#CheckAll").on("click",function(e){
518             e.preventDefault();
519             $(".cb").prop("checked", true);
520             enableCheckboxActions();
521         });
522         $("#CheckNone").on("click",function(e){
523             e.preventDefault();
524             $(".cb").prop("checked", false);
525             enableCheckboxActions();
526         });
527         $(".cb").click(function(){
528           enableCheckboxActions();
529         });
530
531         enableCheckboxActions();
532
533         $(".removeitems").on("click", function(e) {
534             e.preventDefault();
535             var selected_titles = $("input:checked");
536             var title;
537             var yes_label;
538             var no_label;
539             var message = "";
540             if ( selected_titles.size() < 1 ) {
541                 alert(MSG_NO_SUGGESTION_SELECTED);
542                 return false;
543             } else {
544                 if( selected_titles.size() > 1 ){
545                     message = $("<ul></ul>");
546                     title = _("Are you sure you want to delete these suggestions?");
547                     yes_label = _("Yes, delete suggestions");
548                     no_label = _("No, do not delete suggestions");
549                     selected_titles.each(function(){
550                         message.append( "<li>" +  $(this).data("title") + "</li>" );
551                     });
552                 } else {
553                     title = _("Are you sure you want to delete this suggestion?");
554                     yes_label = _("Yes, delete suggestion");
555                     no_label = _("No, do not delete suggestion");
556                     selected_titles.each(function(){
557                         message += $(this).data("title");
558                     });
559                 }
560                 confirmModal( message, title, yes_label, no_label, function( result ){
561                     if( result ){
562                         $("#delete_suggestions").submit();
563                     }
564                 });
565             }
566         });
567         [% END %]
568     });
569 </script>
570 [% END %]