Merge branch 'bug_9766' into 3.14-master
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / js / acq.js
index d67b05b..067cd08 100644 (file)
@@ -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"));
        }
 }
 
@@ -644,7 +644,8 @@ function updateCosts(){
     var discount = new Number($("#discount").val());
     var applygst = new Number ($("#applygst").val());
     var listprice   =  new Number($("#listprice").val());
-    var exchangerate =  new Number($("#currency_rate").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);
@@ -669,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);
 
@@ -861,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<allRows.length; i++) {
-            var allCells  = allRows[i].cells;
-            allCells[colnum+1].style.display="table-cell";
-    }
-
-// make a menuitem object
-    var hids = document.getElementsByName("hide_cols")
-    for (var i=0; i<hids.length; i++) {
-        if (hids[i].value == code) {
-            var x =  hids[i];
-            x.parentNode.removeChild(x)    // sigh...
-            break;
-        }
-    }
+function hideColumn(num) {
+    $("#hideall,#showall").removeAttr("checked").parent().removeClass("selected");
+    $("#"+num).parent().removeClass("selected");
+    var hide = Number(num.replace("col","")) + 2;
+    // hide header and cells matching the index
+    $("#plan td:nth-child("+hide+"),#plan th:nth-child("+hide+")").toggle();
 }
 
-
-function delColumn(n, code)
-{
-    var allRows = document.getElementById('plan').rows;
-
-// find index
-    var index;
-    var nn  = new Number(n);
-    var code   = code ;
-    for (var i=0; i<allRows.length; i++) {
-        var allCells  = allRows[i].cells;
-        allCells[nn+1].style.display="none";
-    }
-
-    var r = 0;
-    var hids = document.getElementsByName("hide_cols")
-    for (var i=0; i<hids.length; i++) {
-        if (hids[i].value == code) {
-            r = 1;
-            break;
-        }
-    }
-
-    if (r == 0 ) {
-        // add hide_col to form
-        var el = document.createElement("input");
-        el.setAttribute("type", 'hidden' );
-        el.setAttribute("value", code);
-        el.setAttribute("name", 'hide_cols');
-        document.getElementById("hide_div").appendChild(el);
-    }
+function showColumn(num){
+    $("#hideall").removeAttr("checked").parent().removeClass("selected");
+    $("#"+num).parent().addClass("selected");
+    // set the index of the table column to hide
+    show = Number(num.replace("col","")) + 2;
+    // hide header and cells matching the index
+    $("#plan td:nth-child("+show+"),#plan th:nth-child("+show+")").toggle();
 }
 
-
+function showAllColumns(){
+    $("#selections").checkCheckboxes();
+    $("#selections span").addClass("selected");
+    $("#plan td:nth-child(2),#plan tr th:nth-child(2)").nextAll().show();
+    $("#hideall").removeAttr("checked").parent().removeClass("selected");
+}
+function hideAllColumns(){
+    var allCols = $("#plan th").length;
+    $("#selections").unCheckCheckboxes();
+    $("#selections span").removeClass("selected");
+    $("#plan td:nth-child(2),#plan th:nth-child(2)").nextUntil("th:nth-child("+(allCols-1)+"),td:nth-child("+(allCols-1)+")").hide(); // hide all but the last two columns
+    $("#hideall").attr("checked","checked").parent().addClass("selected");
+}
\ No newline at end of file