| 4207 |
mandeep.dh |
1 |
function addNewRowForItem() {
|
|
|
2 |
$('table#bulk-order-items tbody>tr:first').clone(true).insertAfter($('table#bulk-order-items tbody>tr:last'));
|
|
|
3 |
|
|
|
4 |
var newRow = $('table#bulk-order-items tbody>tr:last');
|
|
|
5 |
|
|
|
6 |
// Enabling the new record added
|
|
|
7 |
$(newRow).find('input').removeAttr('disabled');
|
|
|
8 |
|
|
|
9 |
// Making this row visible
|
|
|
10 |
$(newRow).show();
|
|
|
11 |
}
|
|
|
12 |
|
|
|
13 |
function validateForm() {
|
|
|
14 |
return true;
|
|
|
15 |
}
|
|
|
16 |
|
|
|
17 |
function updateTotalAmount() {
|
|
|
18 |
var totalAmount = 0;
|
|
|
19 |
|
|
|
20 |
$('table#bulk-order-items tbody>tr').each(function(index, element) {
|
|
|
21 |
// Ignoring the first sample row
|
|
|
22 |
if (index == 0) {
|
|
|
23 |
return;
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
var price = $(element).find('input[name="unit_price"]').val();
|
|
|
27 |
var quantity = $(element).find('input[name="quantity"]').val();
|
|
|
28 |
var amount = price * quantity;
|
|
|
29 |
totalAmount += amount;
|
|
|
30 |
var amountInput = $(element).find('div#item-amount');
|
|
|
31 |
$(amountInput).html(amount);
|
|
|
32 |
});
|
|
|
33 |
|
|
|
34 |
$('#bulk-order-total-amount').val(totalAmount);
|
|
|
35 |
}
|
|
|
36 |
|
| 5527 |
anupam.sin |
37 |
function hideShowTin() {
|
|
|
38 |
if($('#orderType').val() == "B2Cbulk") {
|
|
|
39 |
$('#tin').hide();
|
|
|
40 |
}
|
|
|
41 |
else {
|
|
|
42 |
$('#tin').show();
|
|
|
43 |
}
|
|
|
44 |
}
|
|
|
45 |
|
| 4207 |
mandeep.dh |
46 |
function submitBulkOrderForm() {
|
|
|
47 |
if (validateForm()) {
|
|
|
48 |
// index starts from zero, Also we need to ignore first sample row
|
|
|
49 |
$('table#bulk-order-items tbody>tr').each(function(rowIndex, rowElement) {
|
|
|
50 |
// Skipping first sample row
|
|
|
51 |
if (rowIndex != 0) {
|
|
|
52 |
$(rowElement).find('input').each(function(inputIndex, inputElement) {
|
|
|
53 |
if ($(inputElement).attr('name').indexOf('lineItems[') == -1) {
|
|
|
54 |
$(inputElement).attr('name', 'lineItems[' + (rowIndex - 1) + '].' + $(inputElement).attr('name'));
|
|
|
55 |
}
|
|
|
56 |
});
|
|
|
57 |
}
|
|
|
58 |
});
|
|
|
59 |
|
|
|
60 |
$('div#error').empty();
|
|
|
61 |
|
|
|
62 |
$.ajax({
|
|
|
63 |
type : 'POST',
|
|
|
64 |
url : '/Support/bulk-order',
|
|
|
65 |
data : $('form#bulk-order').serialize(),
|
|
|
66 |
success : function(response) {
|
| 23990 |
amit.gupta |
67 |
$('table#bulk-order-items tbody>tr').each(function(rowIndex, rowElement) {
|
|
|
68 |
// Skipping first sample row
|
|
|
69 |
if (rowIndex != 0) {
|
|
|
70 |
$(rowElement).find('input').each(function(inputIndex, inputElement) {
|
|
|
71 |
if ($(inputElement).attr('name').indexOf('.') >= 0) {
|
|
|
72 |
$(inputElement).attr('name', $(inputElement).attr('name').split('.')[1]);
|
|
|
73 |
}
|
|
|
74 |
});
|
|
|
75 |
}
|
|
|
76 |
});
|
| 4207 |
mandeep.dh |
77 |
if ($(response).attr('id') == 'error') {
|
|
|
78 |
$('div#error').html(response);
|
|
|
79 |
}
|
|
|
80 |
else {
|
|
|
81 |
document.write(response);
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
});
|
|
|
85 |
}
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
function updateModelName(trElement, itemId) {
|
|
|
89 |
$.ajax({
|
|
|
90 |
type : 'GET',
|
|
|
91 |
url : '/Support/bulk-order!getModelName',
|
|
|
92 |
data : 'itemId=' + itemId,
|
|
|
93 |
success : function(response) {
|
|
|
94 |
$(trElement).find('div#model_name').html(response);
|
|
|
95 |
}
|
|
|
96 |
});
|
|
|
97 |
}
|
| 24033 |
amit.gupta |
98 |
function updateModelPrice(trElement, itemId) {
|
|
|
99 |
$.ajax({
|
|
|
100 |
type : 'GET',
|
|
|
101 |
url : '/Support/bulk-order!getPartnerPrice',
|
|
|
102 |
data : 'itemId=' + itemId,
|
|
|
103 |
success : function(response) {
|
| 24042 |
amit.gupta |
104 |
$(trElement).find('input[name="unit_price"]').val(response);
|
| 24033 |
amit.gupta |
105 |
}
|
|
|
106 |
});
|
|
|
107 |
}
|