Bug 10475 - Item form in acquisition not hiding subfields properly
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / neworderempty.tt
index 8a1534a..bbcd4e8 100644 (file)
@@ -6,25 +6,8 @@
 <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">
-var nav = window.Event ? true : false;
-if (nav) {
-    window.captureEvents(Event.KEYDOWN);
-    window.onkeydown = NetscapeEventHandler_KeyDown;
-} else {
-    document.onkeydown = IEEventHandler_KeyDown;
-}
-
-function NetscapeEventHandler_KeyDown(e) {
-    if (e.which == 13 && e.target.type != 'textarea' && e.target.type != 'submit') { return false; }
-    return true;
-}
-
-function IEEventHandler_KeyDown() {
-    if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit')
-        return false;
-    return true;
-}
 //<![CDATA[
 actTotal = "";
 
@@ -129,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
@@ -148,6 +132,7 @@ $(document).ready(function()
             }
         });
         [% END %]
+        [% END %]
         
         //keep a copy of all budgets before removing the inactives
         disabledBudgetsCopy = $('#budget_id').html();
@@ -243,7 +228,6 @@ $(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 %]" />
@@ -257,7 +241,7 @@ $(document).ready(function()
         <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 %]" />
@@ -266,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 %]" />
@@ -275,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 %]" />
@@ -284,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>
@@ -294,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 %]" />
@@ -303,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 %]" />
@@ -313,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 %]" />
@@ -323,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 ) %]
@@ -361,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 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>
+    [% 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>
@@ -408,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 -->
@@ -423,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">
@@ -445,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();">
@@ -457,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()" />
@@ -477,9 +470,9 @@ $(document).ready(function()
                 <li>
                     [% IF ( close ) %]
                         <span class="label">Tax rate: </span>
-                        <input type="hidden" size="20" name="gstrate" id="gstrate" value="[% gstrate %]" />[% gstrate %]%
+                        <input type="hidden" name="gstrate" id="gstrate" value="[% gstrate %]" />[% gstrate %]%
                     [% ELSE %]
-                        <label for="gst">Tax rate: </label>
+                        <label for="gstrate">Tax rate: </label>
                         <select name="gstrate" id="gstrate" onchange="updateCosts();">
                         [% FOREACH gst IN gst_values %]
                           [% IF ( gst.option == gstrate ) %]
@@ -513,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 %])
@@ -586,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>