X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=koha-tmpl%2Fintranet-tmpl%2Fprog%2Fen%2Fjs%2Facq.js;h=067cd08642842ccc9417d17c3cb221f6d2653fde;hb=0b21236d2e7690bd3b499634fdb8fede249b4ff2;hp=b137f59cb0fc322adfc487fe9e1d412aa0b55fc1;hpb=7650a34754d5265a749c070228ad04b397d3cf3a;p=koha.git diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js index b137f59cb0..067cd08642 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js @@ -384,7 +384,7 @@ function closeandprint(bg){ if(document.location = '/cgi-bin/koha/acqui/basketgroup.pl?op=closeandprint&basketgroupid=' + bg ){ setTimeout("window.location.reload();",3000); }else{ - alert(_('Error downloading the file')); + alert(_("Error downloading the file")); } } @@ -531,14 +531,7 @@ function log(message) { logLine.appendChild(log.window_.document.createTextNode(message)); log.window_.document.body.appendChild(logLine); } -//======================================================================= - - - function ownerPopup(f) { - window.open("/cgi-bin/koha/admin/aqbudget_owner_search.pl?op=budget",'PatronPopup','width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes'); - } - // //======================================================================= function getElementsByClass( searchClass, domNode, tagName) { if (domNode == null) domNode = document; @@ -646,46 +639,26 @@ function messenger(X,Y,etc){ // FIXME: unused? // NEXT BLOCK IS USED BY NEWORDERBEMPTY -function calcNeworderTotal(){ - //collect values - var f = document.getElementById('Aform'); - var quantity = new Number(f.quantity.value); - var discount = new Number(f.discount.value); - var listinc = new Number (f.listinc.value); - //var currency = f.currency.value; - var applygst = new Number (f.applygst.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 currcode = new String(document.getElementById('currency').value); - var exchangerate = new Number(document.getElementById(currcode).value); - - var gst_on=(!listinc && invoiceingst); - - //do real stuff +function updateCosts(){ + var quantity = new Number($("#quantity").val()); + var discount = new Number($("#discount").val()); + var applygst = new Number ($("#applygst").val()); + var listprice = new Number($("#listprice").val()); + var currcode = new String($("#currency").val()); + var exchangerate = new Number($("#currency_rate_"+currcode).val()); + var gst_on=false; + var rrp = new Number(listprice*exchangerate); - var ecost = new Number(Math.floor(rrp * (100 - discount ))/100); - var GST = new Number(0); - if (gst_on) { - rrp=rrp * (1+f.gstrate.value / 100); - GST=ecost * f.gstrate.value / 100; + var ecost = rrp; + if ( 100-discount != 100 ) { //Prevent rounding issues if no discount + ecost = new Number(Math.floor(rrp * (100 - discount )) / 100); } + var total = new Number( ecost * quantity); + $("#rrp").val(rrp.toFixed(2)); + $("#ecost").val(ecost.toFixed(2)); + $("#total").val(total.toFixed(2)); + $("listprice").val(listprice.toFixed(2)); - var total = new Number( (ecost + GST) * quantity); - - f.rrp.value = rrp.toFixed(2); - -// f.rrp.value = rrp -// f.rrp.value = 'moo' - - f.ecost.value = ecost.toFixed(2); - f.total.value = total.toFixed(2); - f.listprice.value = listprice.toFixed(2); - -// gst-stuff needs verifing, mason. - if (f.GST) { - f.GST.value=GST; - } return true; } @@ -697,7 +670,7 @@ function calcNewsuggTotal(){ // 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 exchangerate = new Number(document.getElementById('currency_rate_'+currcode).value); var total = new Number(quantity*price*exchangerate); @@ -748,7 +721,7 @@ function fetchSortDropbox(f) { for (i=1;i<=2;i++) { - var sort_dropbox = document.getElementById('sort'+i); + var sort_zone = document.getElementById('sort'+i+'_zone'); var url = '../acqui/fetch_sort_dropbox.pl?sort='+i+'&budget_id='+budgetId; var xmlhttp = null; @@ -768,7 +741,13 @@ for (i=1;i<=2;i++) { } }; // rc = eval ( xmlhttp.responseText ); - sort_dropbox.innerHTML = xmlhttp.responseText; + var retRootType = xmlhttp.responseXML.firstChild.nodeName; + var existingInputs = sort_zone.getElementsByTagName('input'); + if (existingInputs.length > 0 && retRootType == 'input') { + // when sort is already an input, do not override to preseve value + return; + } + sort_zone.innerHTML = xmlhttp.responseText; } } @@ -883,61 +862,33 @@ function checkBudgetParent(budgetId, newBudgetParent) { } } - -function addColumn(p_sType, p_aArgs, p_oValue) -{ - var allRows = document.getElementById('plan').rows; - var colnum = p_oValue[0]; - var code = p_oValue[1]; - var colnum = new Number(colnum); - - for (var i=0; i