View | Details | Raw Unified | Return to bug 4437
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/acq.js (-229 / +233 lines)
Lines 1-37 Link Here
1
/* global confirmDelete */
1
/* global confirmDelete */
2
/* exported uncheckbox isNotNull isNull isNum log calcTotalRow autoFillRow messenger updateCosts calcNewsuggTotal getAuthValueDropbox totalExceedsBudget budgetExceedsParent checkBudgetParent hideColumn showColumn showAllColumns hideAllColumns */
2
/* exported uncheckbox isNotNull isNull isNum log calcTotalRow autoFillRow messenger updateCosts calcNewsuggTotal totalExceedsBudget budgetExceedsParent checkBudgetParent hideColumn showColumn showAllColumns hideAllColumns */
3
3
4
//=======================================================================
4
//=======================================================================
5
//input validation:
5
//input validation:
6
// acqui/uncertainprice.tmpl uses this
6
// acqui/uncertainprice.tmpl uses this
7
function uncheckbox(form, field) {
7
function uncheckbox(form, field) {
8
    var price = new Number(form.elements['price' + field].value);
8
    var price = new Number(form.elements["price" + field].value);
9
    var tmpprice = "";
9
    var tmpprice = "";
10
    var errmsg = __("ERROR: Price is not a valid number, please check the price and try again!");
10
    var errmsg = __(
11
        "ERROR: Price is not a valid number, please check the price and try again!"
12
    );
11
    if (isNaN(price)) {
13
    if (isNaN(price)) {
12
        alert(errmsg);
14
        alert(errmsg);
13
        for(var i=0; i<form.elements['price' + field].value.length; ++i) {
15
        for (var i = 0; i < form.elements["price" + field].value.length; ++i) {
14
            price = new Number(form.elements['price' + field].value[i]);
16
            price = new Number(form.elements["price" + field].value[i]);
15
            if(! isNaN(price) || form.elements['price' + field].value[i] == ".") {
17
            if (
16
                tmpprice += form.elements['price' + field].value[i];
18
                !isNaN(price) ||
19
                form.elements["price" + field].value[i] == "."
20
            ) {
21
                tmpprice += form.elements["price" + field].value[i];
17
            }
22
            }
18
        }
23
        }
19
        form.elements['price' + field].value = tmpprice;
24
        form.elements["price" + field].value = tmpprice;
20
        return false;
25
        return false;
21
    }
26
    }
22
    form.elements['uncertainprice' + field].checked = false;
27
    form.elements["uncertainprice" + field].checked = false;
23
    return true;
28
    return true;
24
}
29
}
25
30
26
// returns false if value is empty
31
// returns false if value is empty
27
function isNotNull(f,noalert) {
32
function isNotNull(f, noalert) {
28
    if (f.value.length ==0) {
33
    if (f.value.length == 0) {
29
        return false;
34
        return false;
30
    }
35
    }
31
    return true;
36
    return true;
32
}
37
}
33
38
34
function isNull(f,noalert) {
39
function isNull(f, noalert) {
35
    if (f.value.length > 0) {
40
    if (f.value.length > 0) {
36
        return false;
41
        return false;
37
    }
42
    }
Lines 39-68 function isNull(f,noalert) { Link Here
39
}
44
}
40
45
41
//Function returns false if v is not a number (if maybenull is 0, it also returns an error if the number is 0)
46
//Function returns false if v is not a number (if maybenull is 0, it also returns an error if the number is 0)
42
function isNum(v,maybenull) {
47
function isNum(v, maybenull) {
43
    var n = new Number(v.value);
48
    var n = new Number(v.value);
44
    if (isNaN(n)) {
49
    if (isNaN(n)) {
45
        return false;
50
        return false;
46
    }
51
    }
47
    if (maybenull==0 && v.value=='') {
52
    if (maybenull == 0 && v.value == "") {
48
53
        return false;
49
50
    return false;
51
    }
54
    }
52
    return true;
55
    return true;
53
}
56
}
54
57
55
56
//a logging function (a bit buggy, might open millions of log pages when initializing, but works fine after...
58
//a logging function (a bit buggy, might open millions of log pages when initializing, but works fine after...
57
function log(message) {
59
function log(message) {
58
    if (!log.window_ || log.window_.closed) {
60
    if (!log.window_ || log.window_.closed) {
59
        var win = window.open("", null, "width=400,height=200," +
61
        var win = window.open(
60
                            "scrollbars=yes,resizable=yes,status=no," +
62
            "",
61
                            "location=no,menubar=no,toolbar=no");
63
            null,
64
            "width=400,height=200," +
65
            "scrollbars=yes,resizable=yes,status=no," +
66
            "location=no,menubar=no,toolbar=no"
67
        );
62
        if (!win) return;
68
        if (!win) return;
63
        var doc = win.document;
69
        var doc = win.document;
64
        doc.write("<html><head><title>Debug Log</title></head>" +
70
        doc.write(
65
                "<body></body></html>");
71
            "<html><head><title>Debug Log</title></head>" +
72
            "<body></body></html>"
73
        );
66
        doc.close();
74
        doc.close();
67
        log.window_ = win;
75
        log.window_ = win;
68
    }
76
    }
Lines 72-198 function log(message) { Link Here
72
}
80
}
73
81
74
//=======================================================================
82
//=======================================================================
75
function getElementsByClass( searchClass, domNode, tagName) {
83
function getElementsByClass(searchClass, domNode, tagName) {
76
    if (domNode == null) domNode = document;
84
    if (domNode == null) domNode = document;
77
    if (tagName == null) tagName = '*';
85
    if (tagName == null) tagName = "*";
78
    var el = new Array();
86
    var el = new Array();
79
    var tags = domNode.getElementsByTagName(tagName);
87
    var tags = domNode.getElementsByTagName(tagName);
80
    var tcl = " "+searchClass+" ";
88
    var tcl = " " + searchClass + " ";
81
    for(i=0,j=0; i<tags.length; i++) {
89
    for (i = 0, j = 0; i < tags.length; i++) {
82
        var test = " " + tags[i].className + " ";
90
        var test = " " + tags[i].className + " ";
83
        if (test.indexOf(tcl) != -1)
91
        if (test.indexOf(tcl) != -1) el[j++] = tags[i];
84
            el[j++] = tags[i];
85
    }
92
    }
86
    return el;
93
    return el;
87
}
94
}
88
95
89
90
function calcTotalRow(cell) {
96
function calcTotalRow(cell) {
91
92
    var string = cell.name;
97
    var string = cell.name;
93
    var pos = string.indexOf(",", 0);
98
    var pos = string.indexOf(",", 0);
94
    var bud_id = string.substring(0, pos);
99
    var bud_id = string.substring(0, pos);
95
    var val1 =    cell.value;
100
    var val1 = cell.value;
96
    var remainingTotal =   document.getElementById("budget_est_"+bud_id);
101
    var remainingTotal = document.getElementById("budget_est_" + bud_id);
97
    var remainingNew =0;
102
    var remainingNew = 0;
98
    var budgetTotal  =  document.getElementById("budget_tot_"+bud_id ).textContent;
103
    var budgetTotal = document.getElementById(
99
    var arr =  getElementsByClass(cell.className);
104
        "budget_tot_" + bud_id
100
105
    ).textContent;
101
    budgetTotal   =  budgetTotal.replace(/\,/, "");
106
    var arr = getElementsByClass(cell.className);
102
107
103
//percent strip and convert
108
    budgetTotal = budgetTotal.replace(/\,/, "");
104
    if ( val1.match(/\%/) )   {
109
110
    //percent strip and convert
111
    if (val1.match(/\%/)) {
105
        val1 = val1.replace(/\%/, "");
112
        val1 = val1.replace(/\%/, "");
106
        cell.value =    (val1 / 100) *  Math.abs(budgetTotal ) ;
113
        cell.value = (val1 / 100) * Math.abs(budgetTotal);
107
    }
114
    }
108
115
109
    for ( var i=0, len=arr.length; i<len; ++i ){
116
    for (var i = 0, len = arr.length; i < len; ++i) {
110
        remainingNew   +=   Math.abs(arr[i].value);
117
        remainingNew += Math.abs(arr[i].value);
111
    }
118
    }
112
119
113
    var cc = new Number(cell.value);
120
    var cc = new Number(cell.value);
114
    cell.value =  cc.toFixed(2); // TIDYME...
121
    cell.value = cc.toFixed(2); // TIDYME...
115
    remainingNew    =    Math.abs( budgetTotal  ) -  remainingNew   ;
122
    remainingNew = Math.abs(budgetTotal) - remainingNew;
116
123
117
    if ( remainingNew  == 0)  {
124
    if (remainingNew == 0) {
118
        remainingTotal.style.color = 'black';
125
        remainingTotal.style.color = "black";
119
    }
126
    } else if (remainingNew > 0) {
120
    else if ( remainingNew   > 0   )       {
127
        remainingTotal.style.color = "green";
121
        remainingTotal.style.color = 'green';
128
    } else {
122
    } else  {    // if its negative, make it red..
129
        // if its negative, make it red..
123
        remainingTotal.style.color = 'red';
130
        remainingTotal.style.color = "red";
124
    }
131
    }
125
132
126
    remainingTotal.textContent  = remainingNew.toFixed(2) ;
133
    remainingTotal.textContent = remainingNew.toFixed(2);
127
}
134
}
128
135
129
function autoFillRow(bud_id) {
136
function autoFillRow(bud_id) {
130
137
    var remainingTotal = document.getElementById("budget_est_" + bud_id);
131
    var remainingTotal =   document.getElementById("budget_est_"+bud_id);
138
    var remainingNew = new Number();
132
    var remainingNew = new Number;
139
    var budgetTotal = document.getElementById(
133
    var budgetTotal  =  document.getElementById("budget_tot_"+bud_id ).textContent;
140
        "budget_tot_" + bud_id
134
    var arr =  getElementsByClass("plan_entry_" + bud_id);
141
    ).textContent;
135
142
    var arr = getElementsByClass("plan_entry_" + bud_id);
136
    budgetTotal   =  budgetTotal.replace(/\,/, "");
143
137
    var qty = new Number;
144
    budgetTotal = budgetTotal.replace(/\,/, "");
138
// get the totals
145
    var qty = new Number();
146
    // get the totals
139
    var novalueArr = new Array();
147
    var novalueArr = new Array();
140
    for ( var i=0, len=arr.length; i<len; ++i ) {
148
    for (var i = 0, len = arr.length; i < len; ++i) {
141
        remainingNew   +=   Math.abs (arr[i].value );
149
        remainingNew += Math.abs(arr[i].value);
142
150
143
        if ( arr[i].value == 0 ) {
151
        if (arr[i].value == 0) {
144
	    novalueArr[qty] = arr[i];
152
            novalueArr[qty] = arr[i];
145
            qty += 1;
153
            qty += 1;
146
        }
154
        }
147
    }
155
    }
148
156
149
    remainingNew    =    Math.abs( budgetTotal) -  remainingNew   ;
157
    remainingNew = Math.abs(budgetTotal) - remainingNew;
150
    var newCell = new Number (remainingNew / qty);
158
    var newCell = new Number(remainingNew / qty);
151
    var rest = new Number (remainingNew - (newCell.toFixed(2) * (novalueArr.length - 1)));
159
    var rest = new Number(
160
        remainingNew - newCell.toFixed(2) * (novalueArr.length - 1)
161
    );
152
162
153
    for (var i = 0; i<novalueArr.length; ++i) {
163
    for (var i = 0; i < novalueArr.length; ++i) {
154
         if (i == novalueArr.length - 1) {
164
        if (i == novalueArr.length - 1) {
155
             novalueArr[i].value = rest.toFixed(2);
165
            novalueArr[i].value = rest.toFixed(2);
156
         }else {
166
        } else {
157
             novalueArr[i].value = newCell.toFixed(2);
167
            novalueArr[i].value = newCell.toFixed(2);
158
        }
168
        }
159
    }
169
    }
160
170
161
    remainingTotal.textContent = '0.00' ;
171
    remainingTotal.textContent = "0.00";
162
    remainingTotal.style.color = 'black';
172
    remainingTotal.style.color = "black";
163
}
173
}
164
174
165
175
function messenger(X, Y, etc) {
166
function messenger(X,Y,etc){    // FIXME: unused?
176
    // FIXME: unused?
167
    win=window.open("","mess","height="+X+",width="+Y+",screenX=150,screenY=0");
177
    win = window.open(
178
        "",
179
        "mess",
180
        "height=" + X + ",width=" + Y + ",screenX=150,screenY=0"
181
    );
168
    win.focus();
182
    win.focus();
169
    win.document.close();
183
    win.document.close();
170
    win.document.write("<body link='#333333' bgcolor='#ffffff' text='#000000'><font size='2'><p><br />");
184
    win.document.write(
185
        "<body link='#333333' bgcolor='#ffffff' text='#000000'><font size='2'><p><br />"
186
    );
171
    win.document.write(etc);
187
    win.document.write(etc);
172
    win.document.write("<center><form><input type=button onclick='self.close()' value='Close'></form></center>");
188
    win.document.write(
189
        "<center><form><input type=button onclick='self.close()' value='Close'></form></center>"
190
    );
173
    win.document.write("</font></body></html>");
191
    win.document.write("</font></body></html>");
174
}
192
}
175
193
176
177
//=======================================================================
194
//=======================================================================
178
195
179
//  NEXT BLOCK IS USED BY NEWORDERBEMPTY
196
//  NEXT BLOCK IS USED BY NEWORDERBEMPTY
180
197
181
function updateCosts(){
198
function updateCosts() {
182
    var quantity = new Number($("#quantity").val());
199
    var quantity = new Number($("#quantity").val());
183
    var discount = new Number($("#discount").val());
200
    var discount = new Number($("#discount").val());
184
    var listprice   =  new Number($("#listprice").val());
201
    var listprice = new Number($("#listprice").val());
185
    var currcode = new String($("#currency").val());
202
    var currcode = new String($("#currency").val());
186
    var exchangerate =  new Number($("#currency_rate_"+currcode).val());
203
    var exchangerate = new Number($("#currency_rate_" + currcode).val());
187
    var gst_on=false;
204
    var gst_on = false;
188
205
189
    var rrp   = new Number(listprice*exchangerate);
206
    var rrp = new Number(listprice * exchangerate);
190
    var rep   = new Number(listprice*exchangerate);
207
    var rep = new Number(listprice * exchangerate);
191
    var ecost = rrp;
208
    var ecost = rrp;
192
    if ( 100-discount != 100 ) { //Prevent rounding issues if no discount
209
    if (100 - discount != 100) {
193
        ecost = new Number(Math.floor(rrp * (100 - discount )) / 100);
210
        //Prevent rounding issues if no discount
211
        ecost = new Number(Math.floor(rrp * (100 - discount)) / 100);
194
    }
212
    }
195
    var total =  new Number( ecost * quantity);
213
    var total = new Number(ecost * quantity);
196
    $("#rrp").val(rrp.toFixed(2));
214
    $("#rrp").val(rrp.toFixed(2));
197
    $("#replacementprice").val(rep.toFixed(2));
215
    $("#replacementprice").val(rep.toFixed(2));
198
    $("#ecost").val(ecost.toFixed(2));
216
    $("#ecost").val(ecost.toFixed(2));
Lines 204-391 function updateCosts(){ Link Here
204
222
205
// Calculates total amount in a suggestion
223
// Calculates total amount in a suggestion
206
224
207
function calcNewsuggTotal(){
225
function calcNewsuggTotal() {
208
    //collect values
226
    //collect values
209
    var quantity = Number(document.getElementById('quantity').value);
227
    var quantity = Number(document.getElementById("quantity").value);
210
    var currcode = String(document.getElementById('currency').value);
228
    var currcode = String(document.getElementById("currency").value);
211
    var price   =  Number(document.getElementById('price').value);
229
    var price = Number(document.getElementById("price").value);
212
    var exchangerate =  Number(document.getElementById('currency_rate_'+currcode).value);
230
    var exchangerate = Number(
231
        document.getElementById("currency_rate_" + currcode).value
232
    );
213
233
214
    var total =  Number(quantity*price*exchangerate);
234
    var total = Number(quantity * price * exchangerate);
215
235
216
    document.getElementById('total').value = total.toFixed(2);
236
    document.getElementById("total").value = total.toFixed(2);
217
    document.getElementById('price').value =  price.toFixed(2);
237
    document.getElementById("price").value = price.toFixed(2);
218
    return true;
238
    return true;
219
}
239
}
220
240
221
function getAuthValueDropbox( name, cat, destination, selected ) {
222
    if ( typeof(selected) == 'undefined' ) {
223
        selected = "";
224
    }
225
    if (cat == null || cat == "") {
226
        $(destination).replaceWith(' <input type="text" name="' + name + '" value="' + selected + '" />' );
227
        return;
228
    }
229
    $.ajax({
230
        url: "/cgi-bin/koha/acqui/ajax-getauthvaluedropbox.pl",
231
        data: {
232
            name: name,
233
            category: cat,
234
            default: selected
235
        },
236
        async: false,
237
        success: function(data){
238
            if(data === "0"){
239
                $(destination).replaceWith(' <input type="text" name="' + name + '" value="' + selected + '" />' );
240
            }else{
241
                $(destination).replaceWith(data);
242
            }
243
        }
244
    });
245
}
246
247
//USED BY NEWORDEREMPTY.PL
241
//USED BY NEWORDEREMPTY.PL
248
function totalExceedsBudget(budgetId, total) {
242
function totalExceedsBudget(budgetId, total) {
243
    var url =
244
        "../acqui/check_budget_total.pl?budget_id=" +
245
        budgetId +
246
        "&total=" +
247
        total;
249
248
250
    var xmlhttp = null;
249
    $.ajax({
251
    xmlhttp = new XMLHttpRequest();
250
        url: url,
252
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
251
        type: "GET",
253
        xmlhttp.overrideMimeType('text/xml');
252
        async: false,
254
    }
253
        dataType: "text",
255
254
        success: function(response) {
256
    var url = '../acqui/check_budget_total.pl?budget_id=' + budgetId + "&total=" + total;
255
            var actTotal = eval(response);
257
    xmlhttp.open('GET', url, false);
256
            if (Math.abs(actTotal) < Math.abs(total)) {
258
    xmlhttp.send(null);
257
                // if budget is too low :(
259
258
                return true;
260
    xmlhttp.onreadystatechange = function() {
261
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
262
263
            actTotal = eval ( xmlhttp.responseText );
264
265
            if (  Math.abs(actTotal) < Math.abs(total)  ) {
266
            // if budget is to low :(
267
                return true ;
268
            } else {
259
            } else {
269
                return false;
260
                return false;
270
            }
261
            }
271
        }
262
        },
272
    }
263
    });
273
}
264
}
274
265
275
276
//USED BY AQBUDGETS.TMPL
266
//USED BY AQBUDGETS.TMPL
277
function budgetExceedsParent(budgetTotal, budgetId, newBudgetParent, periodID) {
267
function budgetExceedsParent(budgetTotal, budgetId, newBudgetParent, periodID) {
278
268
    var url =
279
269
        "../admin/check_parent_total.pl?total=" +
280
    var xmlhttp = null;
270
        budgetTotal +
281
    xmlhttp = new XMLHttpRequest();
271
        "&period_id=" +
282
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
272
        periodID;
283
        xmlhttp.overrideMimeType('text/xml');
273
274
    if (budgetId) {
275
        url += "&budget_id=" + budgetId;
276
    }
277
    if (newBudgetParent) {
278
        url += "&parent_id=" + newBudgetParent;
284
    }
279
    }
285
280
286
// make the call... yawn
281
    var result;
287
//    var url = '../admin/check_parent_total.pl?budget_id=' + budgetId +   '&parent_id=' + newBudgetParent  + "&total=" + budgetTotal + "&period_id="+ periodID   ;
288
289
290
    var url = '../admin/check_parent_total.pl?total=' + budgetTotal + "&period_id="+ periodID   ;
291
292
if (budgetId ) { url +=  '&budget_id=' + budgetId };
293
if ( newBudgetParent  ) { url +=  '&parent_id=' + newBudgetParent};
294
295
296
    xmlhttp.open('GET', url, false);
297
    xmlhttp.send(null);
298
299
    xmlhttp.onreadystatechange = function() {
300
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
301
    // stupid JS...
302
        } else {
303
    // wait for the call to complete
304
        }
305
    };
306
282
307
    var result = eval ( xmlhttp.responseText );
283
    $.ajax({
284
        url: url,
285
        type: "GET",
286
        async: false,
287
        dataType: "text",
288
        success: function(response) {
289
            result = eval(response);
290
        },
291
        error: function(error) {
292
            console.error(error);
293
            throw error;
294
        },
295
    });
308
296
309
    if (result == '1') {
297
    if (result == "1") {
310
            return "- " + __("Fund amount exceeds parent allocation") + "\n";
298
        return "- " + __("Fund amount exceeds parent allocation") + "\n";
311
    } else if (result == '2') {
299
    } else if (result == "2") {
312
            return "- " + __("Fund amount exceeds period allocation") + "\n";
300
        return "- " + __("Fund amount exceeds period allocation") + "\n";
313
    } else  {
301
    } else {
314
            return false;
302
        return false;
315
    }
303
    }
316
}
304
}
317
305
318
319
320
321
//USED BY AQBUDGETS.TMPL
306
//USED BY AQBUDGETS.TMPL
322
function checkBudgetParent(budgetId, newBudgetParent) {
307
function checkBudgetParent(budgetId, newBudgetParent) {
323
    var xmlhttp = null;
308
    var url =
324
    xmlhttp = new XMLHttpRequest();
309
        "../admin/check_budget_parent.pl?budget_id=" +
325
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
310
        budgetId +
326
        xmlhttp.overrideMimeType('text/xml');
311
        "&new_parent=" +
327
    }
312
        newBudgetParent;
328
313
    var result;
329
    var url = '../admin/check_budget_parent.pl?budget_id=' + budgetId + '&new_parent=' + newBudgetParent;
330
    xmlhttp.open('GET', url, false);
331
    xmlhttp.send(null);
332
314
333
    xmlhttp.onreadystatechange = function() {
315
    $.ajax({
334
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
316
        url: url,
335
    // do something with the results
317
        type: "GET",
336
        } else {
318
        async: false,
337
    // wait for the call to complete
319
        dataType: "text",
338
        }
320
        success: function(response) {
339
    };
321
            result = eval(response);
340
322
        },
341
    var result = eval ( xmlhttp.responseText );
323
        error: function(error) {
324
            console.error(error);
325
            throw error;
326
        },
327
    });
342
328
343
    if (result == '1') {
329
    if (result == "1") {
344
            return "- " + __("New budget-parent is beneath budget") + "\n";
330
        return "- " + __("New budget-parent is beneath budget") + "\n";
345
//     } else if (result == '2') {
346
//            return "- New budget-parent has insufficent funds\n";
347
//     } else  {
348
//              return false;
349
    }
331
    }
350
}
332
}
351
333
352
function hideColumn(num) {
334
function hideColumn(num) {
353
    $("#hideall,#showall").prop("checked", false).parent().removeClass("selected");
335
    $("#hideall,#showall")
354
    $("#"+num).parent().removeClass("selected");
336
        .prop("checked", false)
355
    var hide = Number(num.replace("col","")) + 2;
337
        .parent()
338
        .removeClass("selected");
339
    $("#" + num)
340
        .parent()
341
        .removeClass("selected");
342
    var hide = Number(num.replace("col", "")) + 2;
356
    // hide header and cells matching the index
343
    // hide header and cells matching the index
357
    $("#plan td:nth-child("+hide+"),#plan th:nth-child("+hide+")").toggle();
344
    $(
345
        "#plan td:nth-child(" + hide + "),#plan th:nth-child(" + hide + ")"
346
    ).toggle();
358
}
347
}
359
348
360
function showColumn(num){
349
function showColumn(num) {
361
    $("#hideall").prop("checked", false).parent().removeClass("selected");
350
    $("#hideall").prop("checked", false).parent().removeClass("selected");
362
    $("#"+num).parent().addClass("selected");
351
    $("#" + num)
352
        .parent()
353
        .addClass("selected");
363
    // set the index of the table column to hide
354
    // set the index of the table column to hide
364
    show = Number(num.replace("col","")) + 2;
355
    show = Number(num.replace("col", "")) + 2;
365
    // hide header and cells matching the index
356
    // hide header and cells matching the index
366
    $("#plan td:nth-child("+show+"),#plan th:nth-child("+show+")").toggle();
357
    $(
358
        "#plan td:nth-child(" + show + "),#plan th:nth-child(" + show + ")"
359
    ).toggle();
367
}
360
}
368
361
369
function showAllColumns(){
362
function showAllColumns() {
370
    $("#selections").find("input:checkbox").each(function () {
363
    $("#selections")
371
        $(this).prop("checked", true);
364
        .find("input:checkbox")
372
    });
365
        .each(function() {
366
            $(this).prop("checked", true);
367
        });
373
    $("#selections span").addClass("selected");
368
    $("#selections span").addClass("selected");
374
    $("#plan td:nth-child(2),#plan tr th:nth-child(2)").nextAll().show();
369
    $("#plan td:nth-child(2),#plan tr th:nth-child(2)").nextAll().show();
375
    $("#hideall").prop("checked", false).parent().removeClass("selected");
370
    $("#hideall").prop("checked", false).parent().removeClass("selected");
376
}
371
}
377
function hideAllColumns(){
372
function hideAllColumns() {
378
    var allCols = $("#plan th").length;
373
    var allCols = $("#plan th").length;
379
    $("#selections").find("input:checkbox").each(function () {
374
    $("#selections")
380
        $(this).prop("checked", false);
375
        .find("input:checkbox")
381
    });
376
        .each(function() {
377
            $(this).prop("checked", false);
378
        });
382
    $("#selections span").removeClass("selected");
379
    $("#selections span").removeClass("selected");
383
    $("#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
380
    $("#plan td:nth-child(2),#plan th:nth-child(2)")
381
        .nextUntil(
382
            "th:nth-child(" +
383
            (allCols - 1) +
384
            "),td:nth-child(" +
385
            (allCols - 1) +
386
            ")"
387
        )
388
        .hide(); // hide all but the last two columns
384
    $("#hideall").prop("checked", true).parent().addClass("selected");
389
    $("#hideall").prop("checked", true).parent().addClass("selected");
385
}
390
}
386
391
387
$(document).ready(function(){
392
$(document).ready(function() {
388
    $("#deletesupplier").on("click", function(){
393
    $("#deletesupplier").on("click", function() {
389
        confirmDelete(__("Are you sure you want to delete this vendor?") );
394
        confirmDelete(__("Are you sure you want to delete this vendor?"));
390
    });
395
    });
391
});
396
});
392
- 

Return to bug 4437