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