Bug 13618: Add html filters to all the variables
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-suggestions.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE Branches %]
5 [% USE AuthorisedValues %]
6 [% USE KohaDates %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo;
9 [% IF ( op_add ) %]Enter a new purchase suggestion[% END %]
10 [% IF ( op_else ) %]Purchase Suggestions[% END %]</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% BLOCK cssinclude %][% END %]
13 </head>
14 [% IF ( loggedinusername ) %][% INCLUDE 'bodytag.inc' bodyid='opac-usersuggestions' bodyclass='scrollto' %][% ELSE %][% INCLUDE 'bodytag.inc' bodyid='opac-suggestions' bodyclass='scrollto' %][% END %]
15 [% INCLUDE 'masthead.inc' %]
16
17     <div class="main">
18         <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>
23
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('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
35                                     <h1 class="TooManySuggestions">You cannot place any more suggestions</h1>
36                                     <h2 class="TooManySuggestionsText">You have reached your limit of 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>
37                             [% ELSE %]
38                             <h1>Enter a new purchase suggestion</h1>
39
40                             <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion.</p>
41                             <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>
42
43                             <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="add_suggestion_form">
44                                 <fieldset class="rows">
45                                     <ol>
46                                         <li><label for="title">Title:</label><input type="text" id="title" name="title" class="span6" maxlength="255" /></li>
47                                         <li><label for="author">Author:</label><input type="text" id="author" name="author" class="span6" maxlength="80" /></li>
48                                         <li>
49                                             <div title="Copyright or publication year, for example: 2016">
50                                             <label for="copyrightdate">Copyright date:</label><input type="text" id="copyrightdate" name="copyrightdate" pattern="[12]\d{3}" size="4" maxlength="4" />
51                                             </div>
52                                         </li>
53                                         <li><label for="isbn">Standard number (ISBN, ISSN or other):</label><input type="text" id="isbn" name="isbn"  maxlength="80" /></li>
54                                         <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" class="span6" maxlength="80" /></li>
55                                         <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" class="span6" maxlength="80" /></li>
56                                         <li><label for="place">Publication place:</label><input type="text" id="place" name="place"  maxlength="80" /></li>
57                                         <li id="opac-suggestion-quantity"><label for="quantity">Quantity:</label><input type="text" id="quantity" name="quantity"  maxlength="4" size="4" /></li>
58                                         <li><label for="itemtype">Item type:</label>
59                                             [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20 %]
60                                         </li>
61                                         [% IF branchcode %]
62                                             <li><label for="branch">Library:</label>
63                                                 <select name="branchcode" id="branch">
64                                                     [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
65                                                 </select>
66                                             </li>
67                                         [% END %]
68                                         [% IF ( patron_reason_loop ) %]
69                                             <li>
70                                                 <label for="patronreason">Reason for suggestion: </label>
71                                                 <select name="patronreason" id="patronreason">
72                                                     <option value="">-- Choose --</option>
73                                                     [% FOREACH patron_reason_loo IN patron_reason_loop %]
74                                                         <option value="[% patron_reason_loo.authorised_value | html %]">[% patron_reason_loo.lib | html %]</option>
75                                                     [% END %]
76                                                 </select>
77                                             </li>
78                                         [% END %]
79                                         <li>
80                                             <label for="note">Notes:</label>
81                                             <textarea name="note" id="note" rows="5" cols="40"></textarea>
82                                         </li>
83
84                                         <!--  Add a hidden 'negcap' field -->
85                                         <li id="negcap" style="position: absolute; left: -2000px;">
86                                             negcap <input type="text" name="negcap"/>
87                                         </li>
88
89                                     </ol>
90                                 </fieldset>
91                                 <fieldset class="action">
92                                     <input type="hidden" name="suggested_by_anyone" value="[% suggested_by_anyone | html %]" />
93                                     <input type="hidden" name="op" value="add_confirm" />
94                                     <input type="submit" class="btn" value="Submit your suggestion" /> <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a>
95                                 </fieldset>
96                             </form>
97                             [% END %]
98                         [% END #  IF op_add %]
99
100                         [% IF ( op_else ) %]
101                             <h1>
102                                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
103                                     Purchase suggestions
104                                 [% ELSE %]
105                                     [% IF ( loggedinusername ) %]
106                                         Your purchase suggestions
107                                     [% ELSE %]
108                                         Purchase suggestions
109                                     [% END %]
110                                 [% END %]
111                             </h1>
112                             [% FOR m IN messages %]
113                                 <div class="alert alert-[% m.type | html %]">
114                                     [% SWITCH m.code %]
115                                     [% CASE 'too_many' %]
116                                         The suggestion has not been added. You have reached your limit of 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.
117                                     [% CASE 'already_exists' %]
118                                         The suggestion has not been added. A suggestion with this title already exists.
119                                     [% CASE 'success_on_inserted' %]
120                                         Your suggestion has been submitted.
121                                     [% CASE %]
122                                         [% m.code | html %]
123                                     [% END %]
124                                 </div>
125                             [% END %]
126
127                             [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
128
129                             [% IF ( suggestions_loop ) %]
130                                 <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" method="get">
131                                     <fieldset>
132                                         <label for="title">Search for:</label>
133                                         <input type="text" name="title" id="title" value="[% title | html %]" />
134                                         [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
135                                             [% IF loggedinusername %]
136                                                 <label for="suggested_by_anyone">Suggested by:</label>
137                                                 <div class="input-append">
138                                                     <select name="suggested_by_anyone" id="suggested_by_anyone">
139                                                         [% IF suggested_by_anyone %]
140                                                             <option value="0">Me</option>
141                                                             <option value="1" selected="selected">Anyone</option>
142                                                         [% ELSE %]
143                                                             <option value="0" selected="selected">Me</option>
144                                                             <option value="1">Anyone</option>
145                                                         [% END %]
146                                                     </select>
147                                                     <button type="submit" class="btn">Go</button>
148                                                 </div>
149                                             [% END %]
150                                         [% END %]
151                                     </fieldset>
152                                 </form>
153                                 <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="myform">
154                                     <input type="hidden" name="op" value="delete_confirm" />
155                                     [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
156                                         <div id="toolbar" class="toolbar clearfix">
157                                         [% IF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
158                                                 <p class="TooManySuggestionsText">You have reached your limit of 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>
159                                         [% ELSE %]
160                                                 <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
161                                         [% END %]
162                                         </div>
163                                     [% END %]
164
165                                     [% IF ( loggedinusername ) %]
166                                         <div id="selections-toolbar" class="toolbar">
167                                               <span class="checkall"></span> <span class="clearall"></span> <span class="sep">|</span>
168                                               <span class="links"><span id="selections">Select suggestions to: </span>
169                                               <span id="removeitems"></span>
170                                         </div>
171                                     [% END %]
172
173                                     <table id="suggestt" class="checkboxed table table-bordered table-striped">
174                                         <thead>
175                                             <tr>
176                                                 [% IF ( loggedinusername ) %]<th>&nbsp;</th>[% END %]
177                                                 <th>Summary</th>
178                                                 <th>Suggested on</th>
179                                                 <th>Note</th>
180                                                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]<th>Suggested for</th>[% END %]
181                                                 [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]<th>Managed by</th>[% END %]
182                                                 <th>Status</th>
183                                             </tr>
184                                         </thead>
185                                         <tbody>
186                                             [% FOREACH suggestions_loo IN suggestions_loop %]
187                                                 <tr>
188                                                     [% IF ( loggedinusername ) %]
189                                                         <td>
190                                                             [% IF ( suggestions_loo.showcheckbox ) %]
191                                                                 <input type="checkbox" class="cb" name="delete_field" value="[% suggestions_loo.suggestionid | html %]" />
192                                                             [% END %]
193                                                         </td>
194                                                     [% END %]
195                                                     <td>
196                                                         <p><strong>[% suggestions_loo.title | html %]</strong></p>
197                                                             <p>[% IF ( suggestions_loo.author ) %][% suggestions_loo.author | html %],[% END %]
198                                                                 [% IF ( suggestions_loo.copyrightdate ) %] - [% suggestions_loo.copyrightdate | html %],[% END %]
199                                                                 [% IF ( suggestions_loo.publishercode ) %] - [% suggestions_loo.publishercode | html %][% END %]
200                                                                 [% IF ( suggestions_loo.place ) %]([% suggestions_loo.place | html %])[% END %]
201                                                                 [% IF ( suggestions_loo.collectiontitle ) %] , [% suggestions_loo.collectiontitle | html %][% END %]
202                                                                 [% IF ( suggestions_loo.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 1 ) | html %][% END %]
203                                                         </p>
204                                                     </td>
205                                                     <td>
206                                                         [% IF ( suggestions_loo.suggesteddate ) %][% suggestions_loo.suggesteddate |$KohaDates %][% END %]
207                                                     </td>
208                                                     <td>
209                                                         [% IF ( suggestions_loo.note ) %]
210                                                             <span class="tdlabel">Note: </span>
211                                                             [% suggestions_loo.note | html %]
212                                                         [% END %]
213                                                     </td>
214                                                     [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
215                                                         <td>
216                                                             [% IF ( suggestions_loo.branchcodesuggestedby ) %]
217                                                                 <span class="tdlabel">Suggested for:</span>
218                                                                 [% suggestions_loo.branchcodesuggestedby | html %]
219                                                             [% END %]
220                                                         </td>
221                                                     [% END %]
222                                                     [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
223                                                     <td>
224                                                         [% IF ( suggestions_loo.surnamemanagedby ) %]
225                                                             <span class="tdlabel">Managed by:</span>
226                                                             [% suggestions_loo.surnamemanagedby | html %]
227                                                             [% IF ( suggestions_loo.firstnamemanagedby ) %]    , [% suggestions_loo.firstnamemanagedby | html %]
228                                                             [% END %]
229                                                         [% END %]
230                                                     </td>
231                                                     [% END %]
232                                                     <td>
233                                                         <span class="tdlabel">Status:</span>
234                                                         [% IF ( suggestions_loo.ASKED ) %]Requested
235                                                         [% ELSIF ( suggestions_loo.CHECKED ) %]Checked by the library
236                                                         [% ELSIF ( suggestions_loo.ACCEPTED ) %]Accepted by the library
237                                                         [% ELSIF ( suggestions_loo.ORDERED ) %]Ordered by the library
238                                                         [% ELSIF ( suggestions_loo.REJECTED ) %]Suggestion declined
239                                                         [% ELSIF ( suggestions_loo.AVAILABLE ) %]Available in the library
240                                                         [% ELSE %] [% AuthorisedValues.GetByCode( 'SUGGEST_STATUS', suggestions_loo.STATUS, 1 ) | html %] [% END %]
241                                                         [% IF ( suggestions_loo.reason ) %]([% suggestions_loo.reason | html %])[% END %]
242                                                     </td>
243                                                 </tr>
244                                             [% END # / FOREACH suggestions_loo %]
245                                         </tbody>
246                                     </table>
247
248                                     [% IF ( loggedinusername ) %]
249                                         <fieldset class="action">
250                                             <input type="submit" class="btn btn-danger" value="Delete selected" />
251                                         </fieldset>
252                                     [% END %]
253                                 </form>
254                             [% ELSE %]
255                                 [% UNLESS Koha.Preference( 'OPACViewOthersSuggestions' ) or loggedinusername %]
256                                     <p>You are not authorized to see pending purchase suggestions.</p>
257                                 [% ELSE %]
258                                     <p>There are no pending purchase suggestions.</p>
259                                 [% END %]
260                                 [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
261                                     [% IF ( Koha.Preference('MaxOpenSuggestions') != ''  && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
262                                         <p class="TooManySuggestionsText">You have reached your limit of suggestions you can place at this time.</br>Once the library has processed those suggestions you will be able to place more.</p>
263                                     [% ELSE %]
264                                         <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
265                                     [% END %]
266                                 [% END %]
267                             [% END # / IF suggestions_loop %]
268
269                         [% END # IF op_else %]
270                     </div> <!-- / #usersuggestions -->
271                 </div> <!-- / .span10 -->
272             </div> <!-- / .row-fluid -->
273         </div> <!-- / .container-fluid -->
274     </div> <!-- / .main -->
275
276 [% INCLUDE 'opac-bottom.inc' %]
277 [% BLOCK jsinclude %]
278 [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
279 [% INCLUDE 'datatables.inc' %]
280 <script>
281     //<![CDATA[
282     [% IF ( loggedinusername ) %]
283         function enableCheckboxActions(){
284             // Enable/disable controls if checkboxes are checked
285             var checkedBoxes = $(".checkboxed input:checkbox:checked");
286             if ($(checkedBoxes).size()) {
287               $("#selections").html(_("With selected suggestions: "));
288               $("#selections-toolbar .links a").removeClass("disabled");
289             } else {
290               $("#selections").html(_("Select suggestions to: "));
291               $("#selections-toolbar .links a").addClass("disabled");
292             }
293         }
294     [% END %]
295
296     $(function() {
297         $("#suggestt").dataTable($.extend(true, {}, dataTablesDefaults, {
298             "order": [[ 1, "asc" ]],
299             "columnDefs": [
300               [% IF ( loggedinusername ) %]{ "targets": [ 0 ], "sortable": false, "searchable": false }[% END %]
301             ],
302             "columns": [
303                 [% IF ( loggedinusername ) %]null,[% END %]
304                 { "type": "anti-the" },
305                 null,
306                 null,
307                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]null,[% END %]
308                 [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]null,[% END %]
309                 null
310             ]
311         }));
312         [% IF ( loggedinusername ) %]$("span.clearall").html("<a id=\"CheckNone\" href=\"#\">"+_("Clear all")+"<\/a>");
313         $("span.checkall").html("<a id=\"CheckAll\" href=\"#\">"+_("Select all")+"<\/a>");
314         $("#CheckAll").click(function(){
315             $(".checkboxed").checkCheckboxes();
316             enableCheckboxActions();
317             return false;
318         });
319         $("#CheckNone").click(function(){
320             $(".checkboxed").unCheckCheckboxes();
321             enableCheckboxActions();
322             return false;
323         });
324         $(".cb").click(function(){
325           enableCheckboxActions();
326         });
327         $("#removeitems").html("<a href=\"#\" class=\"removeitems tag_hides disabled\">"+_("Delete")+"</a>")
328         .click(function(e){
329           e.preventDefault();
330           $("#myform").submit();
331           return false;
332         });
333         enableCheckboxActions();
334         $("#myform").on('submit', function() {
335           if ( $("input:checked").size() < 1 ) {
336             alert(MSG_NO_SUGGESTION_SELECTED);
337             return false;
338           }
339           return true;
340         });
341         [% END %]
342         [% IF ( op_add && mandatoryfields ) %]
343         {
344             var FldsRequired = [[% mandatoryfields | html %]];
345             for (var i = 0; i < FldsRequired.length; i++) {
346                 var rq_input = $('#' + FldsRequired[i]);
347                 if (rq_input.length != 1) continue;
348                 $(rq_input).attr("required", "required");
349                 var rq_label = $("label[for=" + rq_input.attr("id") + "]");
350                 if (rq_label.length != 1) continue;
351                 $(rq_label).addClass('required');
352             }
353         }
354         [% END %]
355     });
356 //]]>
357 </script>
358 [% END %]