Bug 9268 - Scanning in barcode or ISBN in Acquisitions -> new order submits the form...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / neworderempty.tt
index 566318f..536d439 100644 (file)
@@ -7,6 +7,24 @@
 [% INCLUDE 'additem.js.inc' %]
 <script type="text/javascript" src="[% themelang %]/js/additem.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 = "";
 
@@ -90,7 +108,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');
             }
@@ -106,7 +124,7 @@ $(document).ready(function()
         [% END %]
 
         $("#quantity").change(function() {
-            calcNeworderTotal();
+            updateCosts();
         });
 
         //We apply the fonction only for modify option
@@ -125,18 +143,22 @@ $(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 %]
         
+        //keep a copy of all budgets before removing the inactives
+        disabledBudgetsCopy = $('#budget_id').html();
+        $('#budget_id .b_inactive').remove();
+
         $('#showallbudgets').click(function() {
-            if ( $('#budget_id .b_inactive').is(":visible") )
-            {
-            $('#budget_id .b_inactive').hide();
+            if ($(this).is(":checked")) {
+                $('#budget_id').html(disabledBudgetsCopy); //Puts back all the funds
             }
             else {
-            $('#budget_id .b_inactive').show();
+                $('#budget_id .b_inactive').remove();
             }
         });
     });
@@ -222,18 +244,16 @@ $(document).ready(function()
         <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="discount" value="[% discount %]" />
-        <input type="hidden" name="listinc" value="[% listincgst %]" />
-<!--        <input type="hidden" name="currency" value="[% currency %]" />-->
-        <input type="hidden" name="applygst" value="[% gstreg %]" />
-        <input type="hidden" name="invoiceincgst" value="[% invoiceincgst %]" />
-        <input type="hidden" name="gstrate" value="[% gstrate %]" />
+        <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 %]" />
 
         [% FOREACH loop_currencie IN loop_currencies %]
-            <input type="hidden" id="[% loop_currencie.currcode %]"  name="[% loop_currencie.currcode %]" value="[% loop_currencie.rate %]" />
+            <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>
@@ -352,8 +372,8 @@ $(document).ready(function()
                         <th>&nbsp;</th>
                         <th>&nbsp;</th>
                         <th>Barcode</th>
-                        <th>Home branch</th>
-                        <th>Holding branch</th>
+                        <th>Home library</th>
+                        <th>Holding library</th>
                         <th>Not for loan</th>
                         <th>Restricted</th>
                         <th>Location</th>
@@ -394,7 +414,7 @@ $(document).ready(function()
                     [% IF (AcqCreateItemOrdering) %]
                         <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" />
                     [% ELSE %]
-                        <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" />
+                        <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="updateCosts();" />
                     [% END %]
                 [% END %]
                 <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
@@ -413,7 +433,7 @@ $(document).ready(function()
                         <option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
                     [% ELSE %]
                         [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id %]">[% budget_loo.b_txt %]</option>
-                        [% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive" style="display : none;">[% budget_loo.b_txt %]</option>    
+                        [% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive">[% budget_loo.b_txt %]</option>
                         [% END %]
                     [% END %]
                 [% END %]
@@ -428,7 +448,7 @@ $(document).ready(function()
                        <input type="hidden" size="10" name="currency" id="currency" value="[% currency %]" />[% currency %]
                 [% ELSE %]
                        <label for="currency">Currency:</label>
-                       <select name="currency" id="currency" onchange="calcNeworderTotal();">
+                       <select name="currency" id="currency" onchange="updateCosts();">
                        [% FOREACH loop_currencie IN loop_currencies %]
                        [% IF ( loop_currencie.selected ) %]<option value="[% loop_currencie.currcode %]" selected="selected">[% loop_currencie.currcode %]</option>[% ELSE %]<option value="[% loop_currencie.currcode %]">[% loop_currencie.currcode %]</option>[% END %][% END %]
                        </select>
@@ -436,11 +456,11 @@ $(document).ready(function()
                 </li>
             <li>
                 [% IF ( close ) %]
-            <span class="label">Vendor price: </span>
+                    <span class="label">Vendor price: </span>
                     <input type="hidden" size="20" 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="calcNeworderTotal()" />
+                    <input type="text" size="20" name="listprice" id="listprice" value="[% listprice %]" onchange="updateCosts()" />
                 [% END %]
             </li>
             [% UNLESS ( close ) %]
@@ -453,53 +473,77 @@ $(document).ready(function()
                 [% END %]
             </li>
             [% END %]
-                       <li>
+            [% IF ( gst_values ) %]
+                <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 %]
+                        [% END %]
+                        </select>
+                    [% END %]
+                [% ELSE %]
+                    <input type="hidden" name="gstrate" value="0" />
+                </li>
+            [% END %]
+            <li>
+                <label for="discount">Discount: </label>
                 [% IF ( close ) %]
-            <span class="label">Replacement cost: </span>
-                    <input type="hidden" size="20" name="rrp" id="rrp" value="[% rrp %]" />[% rrp %]
+                    [% IF ( orderdiscount ) %]
+                        <input type="hidden" name="discount" id="discount" value="[% orderdiscount %]" />[% orderdiscount_2dp %]%
+                    [% ELSE %]
+                        <input type="hidden" name="discount" id="discount" value="[% discount %]" />[% discount_2dp %]%
+                    [% END %]
                 [% ELSE %]
-                <label for="rrp">Replacement cost: </label>
-                    <input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /> (adjusted for [% cur_active %])
+                    [% IF ( orderdiscount ) %]
+                        <input type="text" size="6" name="discount" id="discount" value="[% orderdiscount %]" onchange="updateCosts();" />%
+                    [% ELSE %]
+                        <input type="text" size="6" name="discount" id="discount" value="[% discount %]" onchange="updateCosts();" />%
+                    [% END %]
                 [% END %]
             </li>
             <li>
                 [% IF ( close ) %]
-            <label for="ecost">Budgeted cost: </label>
-                    <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" readonly="readonly"  />
+                    <span class="label">Replacement cost: </span>
+                    <input type="hidden" size="20" name="rrp" id="rrp" value="[% rrp %]" />[% rrp %]
                 [% ELSE %]
-                <label for="ecost">Budgeted cost: </label>
-                    <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" />
+                    <label for="rrp">Replacement cost: </label>
+                    <input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /> (adjusted for [% cur_active %])
                 [% END %]
-                [% IF ( discount_2dp ) %]  (adjusted for [% discount_2dp %]% discount)  [% END %]
-
             </li>
-            [% IF ( GST ) %]
             <li>
                 [% IF ( close ) %]
-            <label for="GST">Budgeted GST: </label>
-                <input type="text" id="" size="20" name="gst" value="" id="GST" readonly="readonly" />
+                    <label for="ecost">Budgeted cost: </label>
+                    <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" readonly="readonly"  />
                 [% ELSE %]
-                <label for="GST">Budgeted GST: </label>
-                <input type="text" size="20" name="gst" id="GST" value="" />
+                    <label for="ecost">Budgeted cost: </label>
+                    <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" />
                 [% END %]
             </li>
-            [% END %]
             <li>
                 [% IF ( close ) %]
-            <label for="total">Total: </label>
-                <input type="text" id="total" size="20" name="total" value="[% total %]" readonly="readonly" />
+                    <label for="total">Total: </label>
+                    <input type="text" id="total" size="20" name="total" value="[% total %]" readonly="readonly" />
                 [% ELSE %]
-                <label for="total">Total: </label>
-                <input type="text" id="total" size="20" name="total" value="[% total %]" /> (budgeted cost * quantity)
+                    <label for="total">Total: </label>
+                    <input type="text" id="total" size="20" name="total" value="[% total %]" /> (budgeted cost * quantity)
                 [% END %]
             </li>
             <li>
                 [% IF ( close ) %]
-            <label for="cost">Actual cost: </label>
-                <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" readonly="readonly" />
+                    <label for="unitprice">Actual cost: </label>
+                    <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" readonly="readonly" />
                 [% ELSE %]
-                <label for="cost">Actual cost: </label>
-                <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" />
+                    <label for="unitprice">Actual cost: </label>
+                    <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" />
                 [% END %]
             </li>
             <li>
@@ -508,7 +552,7 @@ $(document).ready(function()
             </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>
-
+                <span id="sort1_zone">
                 [% IF CGIsort1 %]
                     <select id="sort1" size="1" name="sort1">
                     [% FOREACH sort_opt IN CGIsort1 %]
@@ -520,13 +564,13 @@ $(document).ready(function()
                     [% END %]
                     </select>
                 [% ELSE %]
-
                     <input type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
                 [% END %]
+                </span>
             </li>
             <li>
                 <label for="sort2">Statistic 2: </label>
-
+                <span id="sort2_zone">
                 [% IF CGIsort2 %]
                     <select id="sort2" size="1" name="sort2">
                     [% FOREACH sort_opt IN CGIsort2 %]
@@ -540,6 +584,7 @@ $(document).ready(function()
                 [% ELSE %]
                     <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
                 [% END %]
+                </span>
             </li>
 </ol>
     </fieldset>