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