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