Merge remote branch 'kc/new/bug_5446' into kcmaster
[koha_fer] / koha-tmpl / intranet-tmpl / prog / en / js / acq.js
index 8bbbdcf..326062d 100644 (file)
@@ -55,99 +55,6 @@ function isNum(v,maybenull) {
     return true;
 }
 
-// this function checks if date is like DD/MM/YYYY
-function CheckDate(field) {
-    var d = field.value;
-    if (d!="") {
-        var amin = 1900;
-        var amax = 2100;
-        var date = d.split("/");
-        var ok=1;
-        var msg;
-        if ( (date.length < 2) && (ok==1) ) {
-            msg = _("Separator must be /");
-                alert(msg); ok=0; field.focus();
-                return false;
-        }
-        var dd   = date[0];
-        var mm   = date[1];
-        var yyyy = date[2];
-        // checking days
-        if ( ((isNaN(dd))||(dd<1)||(dd>31)) && (ok==1) ) {
-            msg = _("day not correct.");
-            alert(msg); ok=0; field.focus();
-            return false;
-        }
-        // checking months
-        if ( ((isNaN(mm))||(mm<1)||(mm>12)) && (ok==1) ) {
-            msg = _("month not correct.");
-            alert(msg); ok=0; field.focus();
-            return false;
-        }
-        // checking years
-        if ( ((isNaN(yyyy))||(yyyy<amin)||(yyyy>amax)) && (ok==1) ) {
-            msg = _("years not correct.");
-            alert(msg); ok=0; field.focus();
-            return false;
-        }
-        // check day/month combination
-        if ((mm==4 || mm==6 || mm==9 || mm==11) && dd==31) {
-            msg = _("Invalid Day/Month combination. Please ensure that    you have a valid day/month combination.");
-            alert(msg); ok=0; field.focus();
-            return false;
-        }
-        // check for february 29th
-        if (mm == 2) {
-            var isleap = (yyyy % 4 == 0 && (yyyy % 100 != 0 || yyyy %    400 == 0));
-            if (dd>29 || (dd==29 && !isleap)) {
-                msg = _("Invalid Day. This year is not a leap year.       Please enter a value less than 29 for the day.");
-                alert(msg); ok=0; field.focus();
-                return false
-            }
-        }
-    }
-    return true;
-}
-
-// Checks wether start date is greater than end date
-function CompareDate(startdate, enddate) {
-    startdate=startdate.split("/");
-    syear = startdate[2];
-    smonth = startdate[1];
-    sday = startdate[0];
-    enddate=enddate.split("/");
-    eyear = enddate[2];
-    emonth = enddate[1];
-    eday = enddate[0];
-
-    var sdate = new Date(syear,smonth-1,sday);
-    var edate = new Date(eyear,emonth-1,eday);
-    if (sdate > edate) {
-        msg = _("Start date after end date, please check the dates!");
-        alert(msg); ok=0; field.focus();
-        return false;
-    }
-    return true;
-}
-
-// checks wether end date is before today, returns false if it is
-function CheckEndDate(enddate) {
-    enddate=enddate.split("/");
-    eyear = enddate[2];
-    emonth = enddate[1];
-    eday = enddate[0];
-    var edate = new Date(eyear,emonth-1,eday);
-    var today = new Date( );
-    if (today > edate) {
-        msg = _("End date before today, Invalid end date!");
-        alert(msg); ok=0; field.focus();
-        return false;
-    }
-    return true;
-}
-
-
-
 //=======================================================================
 
 //=======================================================================
@@ -652,7 +559,7 @@ function calcTotalRow(cell) {
 
     var bud_id =  cell.className;
     var val1 =    cell.value;
-    var remainingTotal =   document.getElementById("budget_est_"+bud_id) ;
+    var remainingTotal =   document.getElementById("budget_est_"+bud_id).textContent;
     var remainingNew =0;
     var budgetTotal  =  document.getElementById("budget_tot_"+bud_id ).textContent;
     var arr =  getElementsByClass(bud_id);
@@ -687,10 +594,10 @@ function calcTotalRow(cell) {
 
 function autoFillRow(bud_id) {
 
-    var remainingTotal =   document.getElementById("budget_est_"+bud_id) ;
+    var remainingTotal =   document.getElementById("budget_est_"+bud_id).textContent;
     var remainingNew = new Number;
     var budgetTotal  =  document.getElementById("budget_tot_"+bud_id ).textContent;
-    var arr =  getElementsByClass(bud_id);
+    var arr =  getElementsByClass("plan_entry_" + bud_id);
 
     budgetTotal   =  budgetTotal.replace(/\,/, "");
     var qty = new Number;
@@ -740,7 +647,7 @@ function calcNeworderTotal(){
     var listinc  = new Number (f.listinc.value);
     var currency = f.currency.value;
     var applygst = new Number (f.applygst.value);
-    var list_price   =  new Number(f.listprice.value);
+    var listprice   =  new Number(f.listprice.value);
     var invoiceingst =  new Number (f.invoiceincgst.value);
     var exchangerate =  new Number(f.elements[currency].value);      //get exchange rate
     var gst_on=(!listinc && invoiceingst);
@@ -763,7 +670,7 @@ function calcNeworderTotal(){
 
     f.ecost.value = ecost.toFixed(2);
     f.total.value = total.toFixed(2);
-    f.listprice.value =  list_price.toFixed(2);
+    f.listprice.value =  listprice.toFixed(2);
 
 //  gst-stuff needs verifing, mason.
     if (f.GST) {
@@ -772,6 +679,24 @@ function calcNeworderTotal(){
     return true;
 }
 
+// Calculates total amount in a suggestion
+
+function calcNewsuggTotal(){
+    //collect values
+    var quantity = new Number(document.getElementById('quantity').value);
+//    var currency = f.currency.value;
+    var currcode = new String(document.getElementById('currency').value);
+    var price   =  new Number(document.getElementById('price').value);
+    var exchangerate =  new Number(document.getElementById(currcode).value);
+
+    var total =  new Number(quantity*price*exchangerate);
+
+    document.getElementById('total').value = total.toFixed(2);
+    document.getElementById('price').value =  listprice.toFixed(2);
+    return true;
+}
+
+
 // ----------------------------------------
 //USED BY NEWORDEREMPTY.PL
 /*