Bug 16157: Move the selected flag from GetAuthorisedValues to the templates
[srvgit] / koha-tmpl / intranet-tmpl / prog / en / modules / suggestion / suggestion.tt
index bfe0198..95c7c7f 100644 (file)
@@ -1,6 +1,7 @@
 [% USE Branches %]
 [% USE AuthorisedValues %]
 [% USE KohaDates %]
+[% USE Price %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Acquisitions  &rsaquo;
     [% IF ( op_save ) %]
@@ -46,11 +47,8 @@ $(document).ready(function() {
     $('#suggestiontabs').tabs({
         // Correct table sizing for tables hidden in tabs
         // http://www.datatables.net/examples/api/tabs_and_scrolling.html
-        "show": function(event, ui) {
-            var oTable = $('div.dataTables_wrapper>table', ui.panel).dataTable();
-            if ( oTable.length > 0 ) {
-                oTable.fnAdjustColumnSizing();
-            }
+        "activate": function(event, ui) {
+            $( $.fn.dataTable.tables( true ) ).DataTable().columns.adjust();
         }
     });
     $(".sorted").dataTable($.extend(true, {}, dataTablesDefaults, {
@@ -200,8 +198,8 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
     <div class="yui-b">
 
     <div id="toolbar" class="btn-toolbar">
-        <a class="btn btn-small" id="editsuggestion" href="suggestion.pl?op=edit&amp;suggestionid=[% suggestionid %]"><i class="icon-pencil"></i> Edit</a>
-        <a class="btn btn-small" id="deletesuggestion" href="suggestion.pl?op=delete&amp;edit_field=[% suggestionid %]"><i class="icon-remove"></i> Delete</a>
+        <a class="btn btn-small" id="editsuggestion" href="suggestion.pl?op=edit&amp;suggestionid=[% suggestionid %]"><i class="fa fa-pencil"></i> Edit</a>
+        <a class="btn btn-small" id="deletesuggestion" href="suggestion.pl?op=delete&amp;edit_field=[% suggestionid %]"><i class="fa fa-remove"></i> Delete</a>
     </div>
 
     <fieldset class="rows">
@@ -215,14 +213,12 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
         <li><span class="label">Publication place:</span>[% place |html %]</li>
         <li><span class="label">Collection title:</span>[% collectiontitle |html %]</li>
         <li><span class="label">Document type:</span>
-            [% FOREACH itemtypeloo IN itemtypeloop %]
-                [% IF ( itemtypeloo.selected ) %][% itemtypeloo.description %][% END %]
-            [% END %]
+            [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', itemtype, 0 ) %]
         </li>
         [% IF ( patron_reason_loop ) %]
           <li><span class="label">Reason for suggestion: </span>
             [% FOREACH patron_reason_loo IN patron_reason_loop %]
-              [% IF ( patron_reason_loo.selected ) %][% patron_reason_loo.lib %][% END %]
+              [% IF patron_reason_loo.authorised_value == patronreason %][% patron_reason_loo.lib %][% END %]
             [% END %]
           </li>
         [% END %]
@@ -294,10 +290,10 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
           <span class="label">Currency:</span>[% currency %]
         </li>
         <li>
-          <span class="label">Price:</span>[% price %]
+          <span class="label">Price:</span>[% price | $Price %]
         </li>
         <li>
-          <span class="label">Total</span>[% total %]
+          <span class="label">Total</span>[% total | $Price %]
         </li>
       </ol>
     </fieldset>
@@ -331,23 +327,30 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
             <input type="text" id="title" name="title" size="80" maxlength="255" value="[% title |html %]" required="required" class="required" />
             <span class="required">Required</span>
         </li>
-        <li><label for="author">Author:</label><input type="text" id="author" name="author" size="50" maxlength="80" value="[% author %]"/></li>
-        <li><label for="copyrightdate">Copyright date:</label><input type="text" id="copyrightdate" name="copyrightdate" size="4" maxlength="4" value="[% copyrightdate %]" /></li>
-        <li><label for="isbn">ISBN or ISSN or other standard number:</label><input type="text" id="isbn" name="isbn" size="50" maxlength="80" value="[% isbn %]"/></li>
-        <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" size="50" maxlength="80" value="[% publishercode %]"/></li>
-        <li><label for="place">Publication place:</label><input type="text" id="place" name="place" size="50" maxlength="80" value="[% place %]"/></li>
-        <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" value="[% collectiontitle %]"/></li>
+        <li><label for="author">Author:</label><input type="text" id="author" name="author" size="50" maxlength="80" value="[% author | html %]"/></li>
+        <li><label for="copyrightdate">Copyright date:</label><input type="text" id="copyrightdate" name="copyrightdate" size="4" maxlength="4" value="[% copyrightdate | html %]" /></li>
+        <li><label for="isbn">ISBN or ISSN or other standard number:</label><input type="text" id="isbn" name="isbn" size="50" maxlength="80" value="[% isbn | html %]"/></li>
+        <li><label for="publishercode">Publisher:</label><input type="text" id="publishercode" name="publishercode" size="50" maxlength="80" value="[% publishercode | html %]"/></li>
+        <li><label for="place">Publication place:</label><input type="text" id="place" name="place" size="50" maxlength="80" value="[% place | html %]"/></li>
+        <li><label for="collectiontitle">Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" size="50" maxlength="80" value="[% collectiontitle | html %]"/></li>
         <li><label for="itemtype">Document type:</label>
-            <select id="itemtype" name="itemtype" >
-            [% FOREACH itemtypeloo IN itemtypeloop %]
-                [% IF ( itemtypeloo.selected ) %]<option selected="selected" value="[% itemtypeloo.itemtype %]">[% ELSE %]<option value="[% itemtypeloo.itemtype %]">[% END %]
-                [% itemtypeloo.description %]</option>
-            [% END %]
-            </select>
+            [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20, default=itemtype %]
         </li>
-        [% IF ( patron_reason_loop ) %]<li><label for="patronreason">Reason for suggestion: </label><select name="patronreason" id="patronreason"><option value=""> -- Choose -- </option>[% FOREACH patron_reason_loo IN patron_reason_loop %]
-                [% IF ( patron_reason_loo.selected ) %]<option value="[% patron_reason_loo.authorised_value %]" selected="selected">[% patron_reason_loo.lib %]</option>[% ELSE %]<option value="[% patron_reason_loo.authorised_value %]">[% patron_reason_loo.lib %]</option>[% END %]
-           [% END %]</select></li>[% END %]
+        [% IF patron_reason_loop %]
+            <li>
+                <label for="patronreason">Reason for suggestion: </label>
+                <select name="patronreason" id="patronreason">
+                    <option value=""> -- Choose -- </option>
+                    [% FOREACH patron_reason_loo IN patron_reason_loop %]
+                        [% IF patron_reason_loo.authorised_value == patronreason %]
+                            <option value="[% patron_reason_loo.authorised_value %]" selected="selected">[% patron_reason_loo.lib %]</option>
+                        [% ELSE %]
+                            <option value="[% patron_reason_loo.authorised_value %]">[% patron_reason_loo.lib %]</option>
+                        [% END %]
+                    [% END %]
+                </select>
+            </li>
+        [% END %]
         <li><label for="note">Notes:</label><textarea name="note" id="note" rows="5" cols="40">[% note %]</textarea></li>
         </ol>
     </fieldset>
@@ -418,7 +421,7 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
     <fieldset class="rows"> <legend>Acquisition information</legend><ol>
         <li><label for="branchcode">Library:</label>
             <select name="branchcode" id="branchcode">
-                <option value="__ANY__">Any</option>[% FOREACH branchloo IN branchloop %]
+                <option value="">Any</option>[% FOREACH branchloo IN branchloop %]
                 [% IF ( branchloo.selected ) %]<option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]<option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %][% END %]
             </select>
         </li>
@@ -429,16 +432,25 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
             </select>
                </li><li><label for="quantity">Copies:</label>
                        <input type="text" size="10" id="quantity" name="quantity" value="[% quantity %]" onchange="calcNewsuggTotal();" />
-                </li><li><label for="currency">Currency:</label>
-                       [% FOREACH loop_currenc IN loop_currency %]
-                    <input type="hidden" value="[% loop_currenc.rate %]" id="currency_rate_[% loop_currenc.currcode %]" name="currency_rate_[% loop_currenc.currcode %]" />
-                           <input type="hidden" id="[% loop_currenc.currcode %]" name="[% loop_currenc.currcode %]" value="[% loop_currenc.rate %]" />
-                       [% END %]
-            <select name="currency" id="currency" onchange="calcNewsuggTotal();">
-                [% FOREACH loop_currenc IN loop_currency %]
-                [% IF ( loop_currenc.selected ) %]<option value="[% loop_currenc.currcode %]" selected="selected">[% loop_currenc.currcode %]</option>[% ELSE %]<option value="[% loop_currenc.currcode %]">[% loop_currenc.currcode %]</option>[% END %][% END %]
-            </select>
-                </li><li><label for="price">Price:</label>
+                </li>
+                <li>
+                    <label for="currency">Currency:</label>
+                    [% FOREACH c IN currencies %]
+                        <input type="hidden" value="[% c.rate %]" id="currency_rate_[% c.currency %]" name="currency_rate_[% c.currency %]" />
+                        <input type="hidden" id="[% c.currency %]" name="[% c.currency %]" value="[% c.rate %]" />
+                    [% END %]
+
+                    <select name="currency" id="currency" onchange="calcNewsuggTotal();">
+                        [% FOREACH c IN currencies %]
+                            [% IF suggestionid and suggestion.currency == c.currency or not suggestionid and c.active %]
+                                <option value="[% c.currency %]" selected="selected">[% c.currency %]</option>
+                            [% ELSIF not c.archived %]
+                                <option value="[% c.currency %]">[% c.currency %]</option>
+                            [% END %]
+                        [% END %]
+                    </select>
+                </li>
+                <li><label for="price">Price:</label>
                        <input type="text" size="20" name="price" id="price" value="[% price %]" onchange="calcNewsuggTotal();" />
                 </li><li><label for="total">Total: </label>
                        <input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total %]"/>
@@ -451,11 +463,23 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
 
 [% IF ( op_else ) %]
 <div id="toolbar" class="btn-toolbar">
-    <a class="btn btn-small" id="newsuggestion" href="suggestion.pl?op=add"><i class="icon-plus"></i> New purchase suggestion</a>
+    <a class="btn btn-small" id="newsuggestion" href="suggestion.pl?op=add"><i class="fa fa-plus"></i> New purchase suggestion</a>
 </div>
 
 <h1>Suggestions management</h1>
 
+
+[% FOR m IN messages %]
+    <div class="dialog [% m.type %]">
+        [% SWITCH m.code %]
+        [% CASE 'already_exists' %]
+            The suggestion has not been added. A suggestion with this title already exists (<a href='/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% m.id %]&op=show'>suggestion #[% m.id %]</a>)
+        [% CASE %]
+            [% m.code %]
+        [% END %]
+    </div>
+[% END %]
+
 [% UNLESS ( notabs ) %]
     <div id="suggestiontabs" class="toptabs">
     <ul class="ui-tabs-nav">
@@ -492,6 +516,7 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
     <table id="[% suggestion.suggestiontype %]t" class="sorted">
         <thead>
             <tr><th>&nbsp;</th>
+            <th>No.</th>
             <th class="anti-the">Suggestion</th>
             <th>Suggested by - on</th>
             <th>Managed by - on</th>
@@ -501,21 +526,24 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
     </thead>
         <tbody>
             [% FOREACH suggestions_loo IN suggestion.suggestions_loop %]
-            [% IF ( suggestions_loo.even ) %]<tr class="highlight">[% ELSE %]<tr>[% END %]
+                <tr>
                 <td>
                     <input type="checkbox" name="edit_field" value="[% suggestions_loo.suggestionid %]" />
                 </td>
                 <td>
+                    [% suggestions_loo.suggestionid %]
+                </td>
+                <td>
                     <a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid %]&amp;op=show" title="suggestion" >
                         [% suggestions_loo.title |html %][% IF ( suggestions_loo.author ) %], by [% suggestions_loo.author %][% END %]</a>
                     [<a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid %]&amp;op=edit" title="suggestion" >edit</a>]
                     <br />
                     [% IF ( suggestions_loo.copyrightdate ) %]&copy; [% suggestions_loo.copyrightdate |html %] [% END %]
                         [% IF ( suggestions_loo.volumedesc ) %]; Volume:<i>[% suggestions_loo.volumedesc |html %]</i> [% END %]
-                        [% IF ( suggestions_loo.isbn ) %]; ISBN:<i>[% suggestions_loo.isbn |html %]</i> [% END %][% IF ( suggestions_loo.publishercode ) %]; Published by [% suggestions_loo.publishercode |html %] [% END %][% IF ( suggestions_loo.publicationyear ) %] in <i>[% suggestions_loo.publicationyear |html %]</i> [% END %][% IF ( suggestions_loo.place ) %] in <i>[% suggestions_loo.place |html %]</i> [% END %][% IF ( suggestions_loo.collectiontitle ) %]; [% suggestions_loo.collectiontitle |html %] [% END %][% IF ( suggestions_loo.itemtype ) %]; [% suggestions_loo.itemtype |html %] [% END %]<br />[% IF ( suggestions_loo.note ) %]<span class="note">[% suggestions_loo.note |html%]</span>[% END %]
+                        [% IF ( suggestions_loo.isbn ) %]; ISBN:<i>[% suggestions_loo.isbn |html %]</i> [% END %][% IF ( suggestions_loo.publishercode ) %]; Published by [% suggestions_loo.publishercode |html %] [% END %][% IF ( suggestions_loo.publicationyear ) %] in <i>[% suggestions_loo.publicationyear |html %]</i> [% END %][% IF ( suggestions_loo.place ) %] in <i>[% suggestions_loo.place |html %]</i> [% END %][% IF ( suggestions_loo.collectiontitle ) %]; [% suggestions_loo.collectiontitle |html %] [% END %][% IF ( suggestions_loo.itemtype ) %]; [% AuthorisedValues.GetByCode( 'SUGGEST_FORMAT', suggestions_loo.itemtype, 0 ) %] [% END %]<br />[% IF ( suggestions_loo.note ) %]<span class="note">[% suggestions_loo.note |html%]</span>[% END %]
                 </td>
                 <td>
-                    [% IF ( suggestions_loo.emailsuggestedby ) %]<a href="mailto:[% suggestions_loo.emailsuggestedby %]">[% END %][% suggestions_loo.surnamesuggestedby %][% IF ( suggestions_loo.firstnamesuggestedby ) %], [% suggestions_loo.firstnamesuggestedby %][% END %] [% IF ( suggestions_loo.emailsuggestedby ) %]</a>[% END %]
+                    [% IF ( suggestions_loo.emailsuggestedby ) %]<a href="mailto:[% suggestions_loo.emailsuggestedby %]">[% END %][% suggestions_loo.surnamesuggestedby %][% IF ( suggestions_loo.firstnamesuggestedby ) %], [% suggestions_loo.firstnamesuggestedby %][% END %] [% IF (suggestions_loo.cardnumbersuggestedby ) %]([% suggestions_loo.cardnumbersuggestedby %])[% END %] [% IF ( suggestions_loo.emailsuggestedby ) %]</a>[% END %]
                     [% IF ( suggestions_loo.suggesteddate ) %] - [% suggestions_loo.suggesteddate | $KohaDates %][% END %]
                 </td>
                 <td>
@@ -658,11 +686,11 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
 
                                <fieldset class="brief"><h4 class="local_collapse"><a href="#">Bibliographic information</a></h4>
                    <ol> <li><label for="title"> Title:</label><input type="text" id="title" name="title" value="[% title |html %]" /></li>
-                    <li><label for="author"> Author:</label><input type="text" id="author" name="author" value="[% author %]" /></li>
-                    <li><label for="isbn"> ISBN:</label><input type="text" id="isbn"  name="isbn" value="[% isbn %]" /></li>
-                    <li><label for="publishercode"> Publisher:</label><input type="text" id="publishercode" name="publishercode" value="[% publishercode %]" /></li>
-                    <li><label for="copyrightdate_filter"> Copyright date:</label><input type="text" id="copyrightdate_filter" name="copyrightdate" value="[% copyrightdate %]" /></li>
-                    <li><label for="collectiontitle"> Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" value="[% collectiontitle %]" /></li><li><input type="submit" value="Go" /></li></ol>
+                    <li><label for="author"> Author:</label><input type="text" id="author" name="author" value="[% author | html %]" /></li>
+                    <li><label for="isbn"> ISBN:</label><input type="text" id="isbn"  name="isbn" value="[% isbn | html %]" /></li>
+                    <li><label for="publishercode"> Publisher:</label><input type="text" id="publishercode" name="publishercode" value="[% publishercode | html %]" /></li>
+                    <li><label for="copyrightdate_filter"> Copyright date:</label><input type="text" id="copyrightdate_filter" name="copyrightdate" value="[% copyrightdate | html %]" /></li>
+                    <li><label for="collectiontitle"> Collection title:</label><input type="text" id="collectiontitle" name="collectiontitle" value="[% collectiontitle | html %]" /></li><li><input type="submit" value="Go" /></li></ol>
                 </fieldset>
                                 <fieldset class="brief"><h4 class="local_collapse"><a href="#">Suggestion information</a></h4>
                     <ol>
@@ -743,7 +771,14 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
 
                                <fieldset class="brief"><h4 class="local_collapse"><a href="#">Acquisition information</a></h4>
                     <ol><li><label for="budgetid"> Book fund:</label>
-                    <select name="budgetid" id="budgetid"><option value="">Any</option>[% FOREACH budgetid_loo IN budgetid_loop %]
+                    <select name="budgetid" id="budgetid">
+                      <option value="__ANY__">Any</option>
+                      [% IF budgetid == '__NONE__' %]
+                          <option value="__NONE__" selected="selected">None</option>
+                      [% ELSE %]
+                          <option value="__NONE__">None</option>
+                      [% END %]
+                    [% FOREACH budgetid_loo IN budgetid_loop %]
                         [% IF ( budgetid_loo.selected ) %] <option value="[% budgetid_loo.code %]" selected="selected">[% budgetid_loo.desc %]</option>[% ELSE %]<option value="[% budgetid_loo.code %]">[% budgetid_loo.desc %]</option>[% END %]
                         [% END %]
                     </select></li>