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