Bug 10475 - Item form in acquisition not hiding subfields properly
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / neworderempty.tt
index 96c6fb6..bbcd4e8 100644 (file)
@@ -6,6 +6,7 @@
 <script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
 [% INCLUDE 'additem.js.inc' %]
 <script type="text/javascript" src="[% themelang %]/js/additem.js"></script>
+<script type="text/javascript" src="[% themelang %]/js/prevent_submit.js"></script>
 <script type="text/javascript">
 //<![CDATA[
 actTotal = "";
@@ -90,7 +91,7 @@ function Check(ff) {
 
     [% IF (AcqCreateItemOrdering) %]
         if(check_additem('[% UniqueItemFields %]') == false) {
-            alert(_('Duplicate values detected. Please correct the errors and resubmit.') );
+            alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
             if(tobedeleted) {
                 $(lastitemblock).appendTo('#outeritemblock');
             }
@@ -111,6 +112,7 @@ $(document).ready(function()
 
         //We apply the fonction only for modify option
         [% IF ( quantityrec ) %]
+        [% IF ( acqcreate ) %]
         $('#quantity').blur(function() 
         {
             // if user decreases the quantity
@@ -125,10 +127,12 @@ $(document).ready(function()
                 alert(_("You can't add a new item, please create a new order line"));
                 // and we replace the original value
                 $(this).val([% quantityrec %])
+                updateCosts(); // blur is invoked after change which updated values
                 return false;
             }
         });
         [% END %]
+        [% END %]
         
         //keep a copy of all budgets before removing the inactives
         disabledBudgetsCopy = $('#budget_id').html();
@@ -146,7 +150,7 @@ $(document).ready(function()
 //]]>
 </script>
 </head>
-<body id="acq_neworderempty" class="acq" onload="updateCosts()">
+<body id="acq_neworderempty" class="acq">
 
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'acquisitions-search.inc' %]
@@ -224,18 +228,20 @@ $(document).ready(function()
         <input type="hidden" name="basketno" value="[% basketno %]" />
         <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
         <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
-        <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
         <input type="hidden" name="listinc" id="listinc" value="[% listincgst %]" />
         <input type="hidden" name="applygst" id="applygst" value="[% gstreg %]" />
         <input type="hidden" name="invoiceincgst" id="invoiceincgst" value="[% invoiceincgst %]" />
         <input type="hidden" name="suggestionid" value="[% suggestionid %]" />
         <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
-        <input type="hidden" name="currency_rate" id="currency_rate" value="[% currency_rate %]" />
+
+        [% FOREACH loop_currencie IN loop_currencies %]
+            <input type="hidden" id="currency_rate_[% loop_currencie.currcode %]"  name="[% loop_currencie.currcode %]" value="[% loop_currencie.rate %]" />
+        [% END %]
 
         <ol><li>
             [% IF ( biblionumber ) %]
             <span class="label">Title</span>
-                <input type="hidden" size="50" name="title" value="[% title |html %]" /> <span class="title">[% title |html %]</span>
+                <input type="hidden" name="title" value="[% title |html %]" /> <span class="title">[% title |html %]</span>
             [% ELSE %]
             <label for="entertitle" class="required">Title: </label>
                 <input type="text" id="entertitle" size="50" name="title" value="[% title |html %]" />
@@ -244,7 +250,7 @@ $(document).ready(function()
         <li>
             [% IF ( biblionumber ) %]
             <span class="label">Author: </span>
-                <input type="hidden" size="50" name="author" id="author" value="[% author %]" />[% author %]
+                <input type="hidden" name="author" id="author" value="[% author %]" />[% author %]
             [% ELSE %]
             <label for="author">Author: </label>
                 <input type="text" size="50" name="author" id="author" value="[% author %]" />
@@ -253,7 +259,7 @@ $(document).ready(function()
         <li>
             [% IF ( biblionumber ) %]
             <span class="label">Publisher: </span>
-                <input type="hidden" size="50" name="publishercode" id="publishercode" value="[% publishercode %]" />[% publishercode %]
+                <input type="hidden" name="publishercode" id="publishercode" value="[% publishercode %]" />[% publishercode %]
             [% ELSE %]
             <label for="publishercode"> Publisher: </label>
                 <input type="text" size="50" name="publishercode" id="publishercode" value="[% publishercode %]" />
@@ -262,7 +268,7 @@ $(document).ready(function()
         <li>
             [% IF ( biblionumber ) %]
             <span class="label">Edition: </span>
-                <input type="hidden" size="20" name="editionstatement" id="editionstatement" value="[% editionstatement %]" />[% editionstatement %]
+                <input type="hidden" name="editionstatement" id="editionstatement" value="[% editionstatement %]" />[% editionstatement %]
 
             [% ELSE %]
             <label for="editionstatement">Edition: </label>
@@ -272,7 +278,7 @@ $(document).ready(function()
         <li>
             [% IF ( biblionumber ) %]
             <span class="label">Publication year: </span>
-                <input type="hidden" size="10" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />[% publicationyear %]
+                <input type="hidden" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />[% publicationyear %]
             [% ELSE %]
             <label for="publicationyear">Publication year: </label>
                 <input type="text" size="10" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />
@@ -281,7 +287,7 @@ $(document).ready(function()
         <li>
             [% IF ( biblionumber ) %]
             <span class="label">ISBN: </span>
-                <input type="hidden" size="50" name="isbn" id="ISBN" value="[% isbn %]" />[% isbn %]
+                <input type="hidden" name="isbn" id="ISBN" value="[% isbn %]" />[% isbn %]
             [% ELSE %]
             <label for="ISBN">ISBN: </label>
                 <input type="text" size="50" name="isbn" id="ISBN" value="[% isbn %]" />
@@ -291,7 +297,7 @@ $(document).ready(function()
         <li>
             [% IF ( biblionumber ) %]
             <span class="label">EAN: </span>
-                <input type="hidden" size="20" name="ean" id="EAN" value="[% ean %]" />[% ean %]
+                <input type="hidden" name="ean" id="EAN" value="[% ean %]" />[% ean %]
             [% ELSE %]
             <label for="EAN">EAN: </label>
                 <input type="text" size="20" name="ean" id="EAN" value="[% ean %]" />
@@ -301,12 +307,11 @@ $(document).ready(function()
         <li>
             [% IF ( biblionumber ) %]
             <span class="label">Series: </span>
-                <input type="hidden" size="50" name="series" id="series" value="[% seriestitle %]" />[% seriestitle %]
+                <input type="hidden" name="series" id="series" value="[% seriestitle %]" />[% seriestitle %]
             [% ELSE %]
             <label for="series">Series: </label>
                 <input type="text" size="50" name="series" id="series" value="[% seriestitle %]" />
             [% END %]
-        </li>
         </li>
             [% UNLESS ( biblionumber ) %]
             [% IF ( itemtypeloop ) %]
@@ -339,46 +344,48 @@ $(document).ready(function()
         </fieldset>
     [% END %]
 
-    [% IF (AcqCreateItemOrdering) %]
-
-    <div id="items_list" style="display:none">
-        <p><b>Items list</b></p>
-        <div style="width:100%;overflow:auto;">
-            <table>
-                <thead>
-                    <tr>
-                        <th>&nbsp;</th>
-                        <th>&nbsp;</th>
-                        <th>Barcode</th>
-                        <th>Home branch</th>
-                        <th>Holding branch</th>
-                        <th>Not for loan</th>
-                        <th>Restricted</th>
-                        <th>Location</th>
-                        <th>Call number</th>
-                        <th>Copy number</th>
-                        <th>Stock number</th>
-                        <th>Collection code</th>
-                        <th>Item type</th>
-                        <th>Materials</th>
-                        <th>Notes</th>
-                    </tr>
-                </thead>
-                <tbody>
-                </tbody>
-            </table>
-        </div>
-    </div>
-
-    <fieldset class="rows" id="itemfieldset">
-        <legend>Item</legend>
-        [% IF ( NoACQframework ) %]
-            <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
-        [% END %]
-
-        <div id="outeritemblock"></div>
-
-    </fieldset>
+    [% UNLESS subscriptionid %][% # it is a suggestion, we have not items %]
+      [% IF (AcqCreateItemOrdering) %]
+
+      <div id="items_list" style="display:none">
+          <p><b>Items list</b></p>
+          <div style="width:100%;overflow:auto;">
+              <table>
+                  <thead>
+                      <tr>
+                          <th>&nbsp;</th>
+                          <th>&nbsp;</th>
+                          <th>Barcode</th>
+                          <th>Home library</th>
+                          <th>Holding library</th>
+                          <th>Not for loan</th>
+                          <th>Restricted</th>
+                          <th>Location</th>
+                          <th>Call number</th>
+                          <th>Copy number</th>
+                          <th>Stock number</th>
+                          <th>Collection code</th>
+                          <th>Item type</th>
+                          <th>Materials</th>
+                          <th>Notes</th>
+                      </tr>
+                  </thead>
+                  <tbody>
+                  </tbody>
+              </table>
+          </div>
+      </div>
+
+      <fieldset class="rows" id="itemfieldset">
+          <legend>Item</legend>
+          [% IF ( NoACQframework ) %]
+              <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
+          [% END %]
+
+          <div id="outeritemblock"></div>
+
+      </fieldset>
+      [% END %][%# UNLESS subscriptionid %]
     [% END %][%# IF (AcqCreateItemOrdering) %]
     <fieldset class="rows">
         <legend>Accounting Details</legend>
@@ -386,13 +393,21 @@ $(document).ready(function()
             <li>
                 [% IF ( close ) %]
             <span class="label required">Quantity: </span>
-                    <input type="hidden" size="20" name="quantity" value="[% quantity %]" />[% quantity %]
+                    <input type="hidden" name="quantity" value="[% quantity %]" />[% quantity %]
                 [% ELSE %]
                     <label class="required" for="quantity">Quantity: </label>
                     [% IF (AcqCreateItemOrdering) %]
-                        <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" />
+                        [% IF subscriptionid %]
+                            <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" />
+                        [% ELSE %]
+                            <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" />
+                        [% END %]
                     [% ELSE %]
-                        <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="updateCosts();" />
+                        [% IF subscriptionid %]
+                            <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" />
+                        [% ELSE %]
+                            <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="updateCosts();" />
+                        [% END %]
                     [% END %]
                 [% END %]
                 <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
@@ -401,7 +416,7 @@ $(document).ready(function()
             <li>
                 [% IF ( close ) %]
             <span class="label required">Fund: </span>
-                    <input type="hidden" size="20" name="budget_id" id="budget_id" value="[% budget_id %]" />[% Budget_name %]
+                    <input type="hidden" name="budget_id" id="budget_id" value="[% budget_id %]" />[% Budget_name %]
                 [% ELSE %]
                 <label class="required" for="budget_id">Fund: </label>
                 <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
@@ -423,7 +438,7 @@ $(document).ready(function()
                <li>
                 [% IF ( close ) %]
                        <span class="label">Currency: </span>
-                       <input type="hidden" size="10" name="currency" id="currency" value="[% currency %]" />[% currency %]
+            <input type="hidden" name="currency" id="currency" value="[% currency %]" />[% currency %]
                 [% ELSE %]
                        <label for="currency">Currency:</label>
                        <select name="currency" id="currency" onchange="updateCosts();">
@@ -435,7 +450,7 @@ $(document).ready(function()
             <li>
                 [% IF ( close ) %]
                     <span class="label">Vendor price: </span>
-                    <input type="hidden" size="20" name="listprice" id="listprice" value="[% listprice %]" />[% listprice %]
+                    <input type="hidden" name="listprice" id="listprice" value="[% listprice %]" />[% listprice %]
                 [% ELSE %]
                 <label for="listprice">Vendor price: </label>
                     <input type="text" size="20" name="listprice" id="listprice" value="[% listprice %]" onchange="updateCosts()" />
@@ -451,23 +466,27 @@ $(document).ready(function()
                 [% END %]
             </li>
             [% END %]
-            <li>
-                [% IF ( close ) %]
-                    <span class="label">Tax rate: </span>
-                    <input type="hidden" size="20" name="gstrate" id="gstrate" value="[% gstrate %]" />[% gstrate %]%
-                [% ELSE %]
-                    <label for="gst">Tax rate: </label>
-                    <select name="gstrate" id="gstrate" onchange="updateCosts();">
-                    [% FOREACH gst IN gst_values %]
-                      [% IF ( gst.option == gstrate ) %]
-                        <option value="[% gst.option %]" selected="selected">[% gst.option * 100 | format("%.1f") %]%</option>
-                      [% ELSE %]
-                        <option value="[% gst.option %]">[% gst.option * 100 | format("%.1f") %]%</option>
-                      [% END %]
+            [% IF ( gst_values ) %]
+                <li>
+                    [% IF ( close ) %]
+                        <span class="label">Tax rate: </span>
+                        <input type="hidden" name="gstrate" id="gstrate" value="[% gstrate %]" />[% gstrate %]%
+                    [% ELSE %]
+                        <label for="gstrate">Tax rate: </label>
+                        <select name="gstrate" id="gstrate" onchange="updateCosts();">
+                        [% FOREACH gst IN gst_values %]
+                          [% IF ( gst.option == gstrate ) %]
+                            <option value="[% gst.option %]" selected="selected">[% gst.option * 100 | format("%.1f") %]%</option>
+                          [% ELSE %]
+                            <option value="[% gst.option %]">[% gst.option * 100 | format("%.1f") %]%</option>
+                          [% END %]
+                        [% END %]
+                        </select>
                     [% END %]
-                    </select>
-                [% END %]
-            </li>
+                [% ELSE %]
+                    <input type="hidden" name="gstrate" value="0" />
+                </li>
+            [% END %]
             <li>
                 <label for="discount">Discount: </label>
                 [% IF ( close ) %]
@@ -487,7 +506,7 @@ $(document).ready(function()
             <li>
                 [% IF ( close ) %]
                     <span class="label">Replacement cost: </span>
-                    <input type="hidden" size="20" name="rrp" id="rrp" value="[% rrp %]" />[% rrp %]
+                    <input type="hidden" name="rrp" id="rrp" value="[% rrp %]" />[% rrp %]
                 [% ELSE %]
                     <label for="rrp">Replacement cost: </label>
                     <input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /> (adjusted for [% cur_active %])
@@ -522,7 +541,7 @@ $(document).ready(function()
             </li>
             <li>
                 <label for="notes">Notes: </label>
-                <textarea id="notes" cols="30" rows="3" name="notes" >[% notes %]</textarea>
+                <textarea id="notes" cols="30" rows="3" name="notes" >[% IF ( notes ) %][% notes %][% END %]</textarea>
             </li>
             <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
                 <label for="sort1">Statistic 1: </label>
@@ -560,14 +579,19 @@ $(document).ready(function()
                 [% END %]
                 </span>
             </li>
-</ol>
+        </ol>
     </fieldset>
     <fieldset class="action">
+        <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
         <input type="submit" value="Save" />
         [% IF (suggestionid) %]
             <a class="cancel" href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Cancel</a>
         [% ELSE %]
-            <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
+            [% IF subscriptionid %]
+                <a class="cancel" href="/cgi-bin/koha/acqui/newordersubscription.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Cancel</a>
+            [% ELSE %]
+                <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
+            [% END %]
         [% END %]
     </fieldset>
 </form>