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