Bug 10475 - Item form in acquisition not hiding subfields properly
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / neworderempty.tt
index e6464f2..bbcd4e8 100644 (file)
@@ -1,14 +1,32 @@
+[% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Acquisitions &rsaquo; Basket [% basketno %] &rsaquo; [% IF ( ordernumber ) %]Modify order details (line #[% ordernumber %])[% ELSE %]New order[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 
 <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 = "";
 
 function Check(ff) {
+    [% IF (AcqCreateItemOrdering) %]
+        // Remove last itemblock if it is not in items_list
+        var lastitemblock = $("#outeritemblock > div:last");
+        var tobedeleted = true;
+        var listitems = $("#items_list tr");
+        $(listitems).each(function(){
+            if($(this).attr('idblock') == $(lastitemblock).attr('id')){
+                tobedeleted = false;
+            }
+        });
+        if(tobedeleted){
+            $(lastitemblock).remove();
+        }
+    [% END %]
+
     var ok=0;
     var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
 
@@ -24,7 +42,7 @@ function Check(ff) {
                                        _alertString += "\n- "+ _("You must select a budget");
     }
 
-    if (!(isNum(ff.quantity,0))){
+    if (!(isNum(ff.quantity,0)) || ff.quantity.value == 0){
         ok=1;
                     _alertString += "\n- " + _("Quantity must be greater than '0'");
     }
@@ -46,16 +64,12 @@ function Check(ff) {
     }
 
     if ( ff.field_value ) {
-        var barcodes = [];
         var empty_item_mandatory = 0;
         for (i = 0; i < ff.field_value.length; i++) {
             //alert("i = " + i + " => " + ff.kohafield[i] );
             if (ff.field_value[i].value.length == 0 && ff.mandatory[i].value == 1) {
                 empty_item_mandatory++;
             }
-            if(ff.subfield[i].value === '[% barcode_subfield %]' && ff.field_value[i].value.length != 0) {
-                barcodes.push(ff.field_value[i].value);
-            }
         }
         if (empty_item_mandatory > 0) {
             ok = 1;
@@ -63,58 +77,42 @@ function Check(ff) {
                 "\n- " + empty_item_mandatory + _(" item mandatory fields empty");
         }
 
-        if(barcodes.length > 0) {
-            // Check for duplicate barcodes in the form
-            barcodes = barcodes.sort();
-            for(var i=0; i<barcodes.length-1; i++) {
-                if(barcodes[i] == barcodes[i+1]) {
-                    ok = 1;
-                    _alertString += "\n- " + _("The barcode ") + barcodes[i] + _(" is used more than once in the form. Every barcode must be unique");
-                }
-            }
-
-            // Check for duplicate barcodes in the database via an ajax call
-            $.ajax({
-                url: "/cgi-bin/koha/acqui/check_duplicate_barcode_ajax.pl",
-                async:false,
-                method: "post",
-                data: {barcodes : barcodes},
-                dataType: 'json',
-
-                error: function(xhr) {
-                    alert("Error: \n" + xhr.responseText);
-                },
-                success: function(json) {
-                    switch(json.status) {
-                        case 'UNAUTHORIZED':
-                            ok = 1;
-                            _alertString += "\n- " + _("Error: Duplicate barcode verification failed. Insufficient user permissions.");
-                            break;
-                        case 'DUPLICATES':
-                            ok = 1;
-                            $.each(json.barcodes, function(index, barcode) {
-                                _alertString += "\n- " + _("The barcode ") + barcode + _(" already exists in the database");
-                            });
-                            break;
-                    }
-                },
-            });
-        }
     }
 
     if (ok) {
         alert(_alertString);
+        [% IF (AcqCreateItemOrdering) %]
+            if(tobedeleted) {
+                $(lastitemblock).appendTo('#outeritemblock');
+            }
+        [% END %]
         return false;
     }
 
-    ff.submit();
-
+    [% IF (AcqCreateItemOrdering) %]
+        if(check_additem('[% UniqueItemFields %]') == false) {
+            alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
+            if(tobedeleted) {
+                $(lastitemblock).appendTo('#outeritemblock');
+            }
+            return false;
+        }
+    [% END %]
 }
 
 $(document).ready(function() 
     {
+        [% IF (AcqCreateItemOrdering) %]
+            cloneItemBlock(0, '[% UniqueItemFields %]');
+        [% END %]
+
+        $("#quantity").change(function() {
+            updateCosts();
+        });
+
         //We apply the fonction only for modify option
         [% IF ( quantityrec ) %]
+        [% IF ( acqcreate ) %]
         $('#quantity').blur(function() 
         {
             // if user decreases the quantity
@@ -129,25 +127,30 @@ $(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();
+        $('#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();
             }
         });
     });
 //]]>
 </script>
 </head>
-<body>
+<body id="acq_neworderempty" class="acq">
 
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'acquisitions-search.inc' %]
@@ -168,11 +171,13 @@ $(document).ready(function()
     [% END %]
 </h2>
 
+<div class="error" style="display:none"></div>
+
 [% IF ( basketno ) %]
     <div id="acqui_basket_summary"  class="yui-g">
-       <fieldset class="rows">
+    <fieldset class="rows">
         <legend>Basket details</legend>
-               <ol>
+        <ol>
         [% IF ( basketnote ) %]<li><span class="label">Internal note:</span> [% basketnote %]</li>[% END %]
         [% IF ( basketbooksellernote ) %]<li><span class="label">Vendor note:</span> [% basketbooksellernote %]</li>[% END %]
         [% IF ( basketcontractno ) %]
@@ -180,10 +185,10 @@ $(document).ready(function()
             <li><span class="label">Contract name:</span> <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno %]">[% basketcontractname %]</a></li>
         [% END %]
         [% IF ( authorisedbyname ) %]<li><span class="label">Managed by:</span>  [% authorisedbyname %]</li>[% END %]
-        [% IF ( creationdate ) %]<li><span class="label">Open on:</span>  [% creationdate %]</li>[% END %]
+        [% IF ( creationdate ) %]<li><span class="label">Open on:</span>  [% creationdate | $KohaDates %]</li>[% END %]
         [% IF ( closedate ) %]
         <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="post">
-        <li><span class="label">Closed on:</span>  [% closedate %]</li>
+        <li><span class="label">Closed on:</span>  [% closedate | $KohaDates %]</li>
         [% IF ( basketgroups ) %]
             <li>Basketgroup: <select id="basketgroupid" name="basketgroupid">
                 [% FOREACH basketgroup IN basketgroups %]
@@ -198,16 +203,16 @@ $(document).ready(function()
                 <input type="hidden" value="mod_basket" name="op" />
                 <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
             </li>
-               <fieldset class="action"><input type="submit" value="Change basketgroup" /></fieldset>
-        </form>
+            <fieldset class="action"><input type="submit" value="Change basketgroup" /></fieldset>
         [% END %]
+        </form>
         [% END %]
-                       </ol>
-</fieldset>
+        </ol>
+    </fieldset>
     </div>
 [% END %]
 
-<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform">
+<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);">
 
 <fieldset class="rows">
         <legend>
@@ -223,23 +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="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>
-                <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 %]" />
@@ -248,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 %]" />
@@ -257,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 %]" />
@@ -266,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>
@@ -276,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 %]" />
@@ -285,21 +287,31 @@ $(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 %]" />
             [% END %]
         </li>
+        [% IF (UNIMARC) %]
+        <li>
+            [% IF ( biblionumber ) %]
+            <span class="label">EAN: </span>
+                <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 %]" />
+            [% END %]
+        </li>
+        [% END %]
         <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 ) %]
@@ -332,54 +344,70 @@ $(document).ready(function()
         </fieldset>
     [% END %]
 
-    [% IF ( items ) %]
-    <fieldset class="rows">
-        <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 %]
-
-        [% FOREACH item IN items %]
-        <div id="outeritemblock">
-        <div id="itemblock">
-            <ol>[% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];">
-                <div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]">
-
-                    <label>[% iteminformatio.subfield %] - [% IF ( iteminformatio.mandatory ) %]<b>[% END %][% iteminformatio.marc_lib %][% IF ( iteminformatio.mandatory ) %] *</b>[% END %]</label>
-                    [% iteminformatio.marc_value %]
-                    <input type="hidden" name="itemid" value="1" />
-                    <input type="hidden" name="kohafield" value="[% iteminformatio.kohafield %]" />
-                    <input type="hidden" name="tag" value="[% iteminformatio.tag %]" />
-                    <input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" />
-                    <input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" />
-                    [% IF ( iteminformatio.ITEM_SUBFIELDS_ARE_NOT_REPEATABLE ) %]
-                        <span class="buttonPlus" onclick="CloneSubfield('subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]')">+</span>
-                    [% END %]
-
-                </div></li>
-            [% END %]
-            </ol>
-            <a class="addItem" onclick="cloneItemBlock('itemblock[% item.itemBlockIndex %]')">Add</a>
-            <a class="delItem" style="display:none;" onclick="deleteItemBlock('itemblock[% item.itemBlockIndex %]')">Delete</a>
-        </div><!-- /iteminformation -->
-        </div>
-
-        [% END %] <!-- /items -->
-    </fieldset>
-    [% END %] <!-- items -->
+    [% 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>
         <ol>
             <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 ( items ) %]
-                        <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" onchange="calcNeworderTotal();" />
+                    <label class="required" for="quantity">Quantity: </label>
+                    [% IF (AcqCreateItemOrdering) %]
+                        [% 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="calcNeworderTotal();" />
+                        [% 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 -->
@@ -388,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">
@@ -398,7 +426,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 %]
@@ -410,10 +438,10 @@ $(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="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>
@@ -421,11 +449,11 @@ $(document).ready(function()
                 </li>
             <li>
                 [% IF ( close ) %]
-            <span class="label">Vendor price: </span>
-                    <input type="hidden" size="20" name="listprice" id="listprice" value="[% listprice %]" />[% listprice %]
+                    <span class="label">Vendor price: </span>
+                    <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="calcNeworderTotal()" />
+                    <input type="text" size="20" name="listprice" id="listprice" value="[% listprice %]" onchange="updateCosts()" />
                 [% END %]
             </li>
             [% UNLESS ( close ) %]
@@ -438,62 +466,86 @@ $(document).ready(function()
                 [% END %]
             </li>
             [% END %]
-                       <li>
+            [% 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 %]
+                [% 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" 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>
                 <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>
-
+                <span id="sort1_zone">
                 [% IF CGIsort1 %]
                     <select id="sort1" size="1" name="sort1">
                     [% FOREACH sort_opt IN CGIsort1 %]
@@ -505,13 +557,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 %]
@@ -525,11 +577,22 @@ $(document).ready(function()
                 [% ELSE %]
                     <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
                 [% END %]
+                </span>
             </li>
-</ol>
+        </ol>
     </fieldset>
     <fieldset class="action">
-        <input type="button" value="Save" onclick="Check(this.form)" /> [% 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>[% END %]
+        <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 %]
+            [% 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>
 </div>