Bug 12904: Force browser to load new javascript files after upgrade
[koha_ffzg] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-suggestions.tt
index 46d0031..5906c83 100644 (file)
@@ -1,8 +1,11 @@
 [% USE Koha %]
+[% USE Branches %]
 [% USE AuthorisedValues %]
-[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog ›
+[% USE KohaDates %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo;
 [% IF ( op_add ) %]Enter a new purchase suggestion[% END %]
-[% IF ( op_else ) %]Purchase Suggestions[% END %]
+[% IF ( op_else ) %]Purchase Suggestions[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 [% BLOCK cssinclude %][% END %]
 </head>
@@ -12,7 +15,7 @@
     <div class="main">
         <ul class="breadcrumb">
             <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
-            <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>
+            <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>
             <li><a href="#">Your purchase suggestions</a></li>
         </ul>
 
                 <div class="span10">
                     <div id="usersuggestions" class="maincontent">
                         [% IF ( op_add ) %]
+                            [% IF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
+                                    <h1 class="TooManySuggestions">You cannot place any more suggestions</h1>
+                                    <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>
+                            [% ELSE %]
                             <h1>Enter a new purchase suggestion</h1>
 
-                            <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion</p>
-                            <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>
+                            <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion.</p>
+                            <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>
 
-                            <form action="/cgi-bin/koha/opac-suggestions.pl" method="post">
+                            <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="add_suggestion_form">
                                 <fieldset class="rows">
                                     <ol>
-                                        <li><label class="required" for="title">Title:</label><input type="text" id="title" name="title" class="span6" maxlength="255" /></li>
+                                        <li><label for="title">Title:</label><input type="text" id="title" name="title" class="span6" maxlength="255" /></li>
                                         <li><label for="author">Author:</label><input type="text" id="author" name="author" class="span6" maxlength="80" /></li>
-                                        <li><label for="copyrightdate">Copyright date:</label><input type="text" id="copyrightdate" name="copyrightdate" size="4" maxlength="4" /></li>
+                                        <li>
+                                            <div title="Copyright or publication year, for example: 2016">
+                                            <label for="copyrightdate">Copyright date:</label><input type="text" id="copyrightdate" name="copyrightdate" pattern="[12]\d{3}" size="4" maxlength="4" />
+                                            </div>
+                                        </li>
                                         <li><label for="isbn">Standard number (ISBN, ISSN or other):</label><input type="text" id="isbn" name="isbn"  maxlength="80" /></li>
                                         <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" class="span6" maxlength="80" /></li>
                                         <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" class="span6" maxlength="80" /></li>
                                         <li><label for="place">Publication place:</label><input type="text" id="place" name="place"  maxlength="80" /></li>
+                                        <li id="opac-suggestion-quantity"><label for="quantity">Quantity:</label><input type="text" id="quantity" name="quantity"  maxlength="4" size="4" /></li>
                                         <li><label for="itemtype">Item type:</label>
-                                            <select name="itemtype" id="itemtype">
-                                                <option value="">Default</option>
-                                                [% FOREACH itemtypeloo IN itemtypeloop %]
-                                                    [% IF ( itemtypeloo.selected ) %]
-                                                        <option value="[% itemtypeloo.itemtype %]" selected="selected">
-                                                    [% ELSE %]
-                                                        <option value="[% itemtypeloo.itemtype %]">
-                                                    [% END %]
-                                                            [% itemtypeloo.description %]
-                                                        </option>
-                                                [% END %]
-                                            </select>
+                                            [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20 %]
                                         </li>
-                                        [% IF ( branchloop ) %]
+                                        [% IF branchcode %]
                                             <li><label for="branch">Library:</label>
                                                 <select name="branchcode" id="branch">
-                                                    [% FOREACH branchloo IN branchloop %]
-                                                        [% IF ( branchloo.selected ) %]
-                                                            <option value="[% branchloo.branchcode %]" selected="selected">[% branchloo.branchname %]</option>
-                                                        [% ELSE %]
-                                                            <option value="[% branchloo.branchcode %]">[% branchloo.branchname %]</option>
-                                                        [% END %]
-                                                    [% END %]
+                                                    [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
                                                 </select>
                                             </li>
                                         [% END %]
                                     </ol>
                                 </fieldset>
                                 <fieldset class="action">
-                                    <input type="hidden" name="suggestedby" value="[% suggestedbyme %]" />
+                                    <input type="hidden" name="suggested_by_anyone" value="[% suggested_by_anyone %]" />
                                     <input type="hidden" name="op" value="add_confirm" />
-                                    <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>
+                                    <input type="submit" class="btn" value="Submit your suggestion" /> <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a>
                                 </fieldset>
                             </form>
+                            [% END %]
                         [% END #  IF op_add %]
 
                         [% IF ( op_else ) %]
                                     [% END %]
                                 [% END %]
                             </h1>
+                            [% FOR m IN messages %]
+                                <div class="alert alert-[% m.type %]">
+                                    [% SWITCH m.code %]
+                                    [% CASE 'too_many' %]
+                                        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.
+                                    [% CASE 'already_exists' %]
+                                        The suggestion has not been added. A suggestion with this title already exists.
+                                    [% CASE 'success_on_inserted' %]
+                                        Your suggestion has been submitted.
+                                    [% CASE %]
+                                        [% m.code %]
+                                    [% END %]
+                                </div>
+                            [% END %]
 
                             [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
-                            [% IF ( submitted ) %]<div class="alert alert-info">Your suggestion has been submitted.</div>[% END %]
 
                             [% IF ( suggestions_loop ) %]
-                                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
-                                    <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" method="get">
-                                        <fieldset>
-                                            <label for="title">Search for:</label>
-                                            <input type="text" name="title" id="title" value="[% title |html %]" />
-                                            <label for="suggestedby">Suggested by:</label>
-                                            <div class="input-append">
-                                                <select name="suggestedby" id="suggestedby">
-                                                    <option value="0">Anyone</option>
-                                                    <option value="1">Me</option>
-                                                </select>
-                                                <button type="submit" class="btn">Go</button>
-                                            </div>
-                                        </fieldset>
-                                    </form>
-                                [% END %]
+                                <form action="/cgi-bin/koha/opac-suggestions.pl" class="form-inline" method="get">
+                                    <fieldset>
+                                        <label for="title">Search for:</label>
+                                        <input type="text" name="title" id="title" value="[% title |html %]" />
+                                        [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
+                                            [% IF loggedinusername %]
+                                                <label for="suggested_by_anyone">Suggested by:</label>
+                                                <div class="input-append">
+                                                    <select name="suggested_by_anyone" id="suggested_by_anyone">
+                                                        [% IF suggested_by_anyone %]
+                                                            <option value="0">Me</option>
+                                                            <option value="1" selected="selected">Anyone</option>
+                                                        [% ELSE %]
+                                                            <option value="0" selected="selected">Me</option>
+                                                            <option value="1">Anyone</option>
+                                                        [% END %]
+                                                    </select>
+                                                    <button type="submit" class="btn">Go</button>
+                                                </div>
+                                            [% END %]
+                                        [% END %]
+                                    </fieldset>
+                                </form>
                                 <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="myform">
                                     <input type="hidden" name="op" value="delete_confirm" />
-                                    <div id="toolbar" class="toolbar clearfix">
-                                        [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
-                                            <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
+                                    [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
+                                        <div id="toolbar" class="toolbar clearfix">
+                                        [% IF ( Koha.Preference('MaxOpenSuggestions') != '' && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
+                                                <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>
+                                        [% ELSE %]
+                                                <a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a>
                                         [% END %]
-                                    </div>
+                                        </div>
+                                    [% END %]
 
                                     [% IF ( loggedinusername ) %]
                                         <div id="selections-toolbar" class="toolbar">
                                             <tr>
                                                 [% IF ( loggedinusername ) %]<th>&nbsp;</th>[% END %]
                                                 <th>Summary</th>
+                                                <th>Suggested on</th>
                                                 <th>Note</th>
                                                 [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]<th>Suggested for</th>[% END %]
                                                 [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]<th>Managed by</th>[% END %]
                                                                 [% IF ( suggestions_loo.publishercode ) %] - [% suggestions_loo.publishercode |html %][% END %]
                                                                 [% IF ( suggestions_loo.place ) %]([% suggestions_loo.place |html %])[% END %]
                                                                 [% IF ( suggestions_loo.collectiontitle ) %] , [% suggestions_loo.collectiontitle |html %][% END %]
-                                                                [% IF ( suggestions_loo.itemtype ) %] - [% suggestions_loo.itemtype %][% END %]
+                                                                [% IF ( suggestions_loo.itemtype ) %] - [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 1 ) %][% END %]
                                                         </p>
                                                     </td>
                                                     <td>
+                                                        [% IF ( suggestions_loo.suggesteddate ) %][% suggestions_loo.suggesteddate |$KohaDates %][% END %]
+                                                    </td>
+                                                    <td>
                                                         [% IF ( suggestions_loo.note ) %]
                                                             <span class="tdlabel">Note: </span>
                                                             [% suggestions_loo.note |html %]
                                     [% END %]
                                 </form>
                             [% ELSE %]
-                                <p>There are no pending purchase suggestions.</p>
+                                [% UNLESS Koha.Preference( 'OPACViewOthersSuggestions' ) or loggedinusername %]
+                                    <p>You are not authorized to see pending purchase suggestions.</p>
+                                [% ELSE %]
+                                    <p>There are no pending purchase suggestions.</p>
+                                [% END %]
                                 [% IF ( loggedinusername || ( Koha.Preference( 'AnonSuggestions' ) == 1 ) ) %]
-                                    <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
+                                    [% IF ( Koha.Preference('MaxOpenSuggestions') != ''  && patrons_pending_suggestions_count >= Koha.Preference('MaxOpenSuggestions') ) %]
+                                        <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>
+                                    [% ELSE %]
+                                        <p><a class="new" href="/cgi-bin/koha/opac-suggestions.pl?op=add">New purchase suggestion</a></p>
+                                    [% END %]
                                 [% END %]
                             [% END # / IF suggestions_loop %]
 
 
 [% INCLUDE 'opac-bottom.inc' %]
 [% BLOCK jsinclude %]
-<script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
+<script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.checkboxes.min_[% KOHA_VERSION %].js"></script>
 [% INCLUDE 'datatables.inc' %]
 <script type="text/javascript">
     //<![CDATA[
                 [% IF ( loggedinusername ) %]null,[% END %]
                 { "sType": "anti-the" },
                 null,
-                [% IF ( OPACViewOthersSuggestions ) %]null,[% END %]
+                null,
+                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]null,[% END %]
                 [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]null,[% END %]
                 null
             ]
           return true;
         });
         [% END %]
-    });
-
-    function Check(f) {
-        var _alertString="";
-        var alertString2;
-
-        if(f.title.value.length ==0){
-            _alertString += _("- You must enter a Title") + "\n";
-        }
-
-        if (_alertString.length==0) {
-            f.submit();
-        } else {
-            alertString2 = _("Form not submitted because of the following problem(s)");
-            alertString2 += "\n------------------------------------------------------------------------------------\n\n";
-            alertString2 += _alertString;
-            alert(alertString2);
+        [% IF ( op_add && mandatoryfields ) %]
+        {
+            var FldsRequired = [[% mandatoryfields %]];
+            for (var i = 0; i < FldsRequired.length; i++) {
+                var rq_input = $('#' + FldsRequired[i]);
+                if (rq_input.length != 1) continue;
+                $(rq_input).attr("required", "required");
+                var rq_label = $("label[for=" + rq_input.attr("id") + "]");
+                if (rq_label.length != 1) continue;
+                $(rq_label).addClass('required');
+            }
         }
-    }
+        [% END %]
+    });
 //]]>
 </script>
 [% END %]