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