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