| 34445 |
vikas.jang |
1 |
$(document).on('change', '.catalogId', function () {
|
|
|
2 |
let qty = $(this).find('option:selected').data('qty');
|
|
|
3 |
$('#quantity').val(qty);
|
|
|
4 |
});
|
| 34387 |
vikas.jang |
5 |
|
|
|
6 |
function initializeSelect(selector, type='catalogs') {
|
|
|
7 |
if (type === 'catalogs') {
|
|
|
8 |
$(selector).multiselect('destroy');
|
|
|
9 |
$(selector).multiselect({
|
|
|
10 |
includeSelectAllOption: false,
|
|
|
11 |
multiple: false,
|
|
|
12 |
maxHeight: 200,
|
|
|
13 |
buttonWidth: '100%',
|
|
|
14 |
numberDisplayed: 1,
|
|
|
15 |
nonSelectedText: '-- Select One --',
|
|
|
16 |
nSelectedText: ' - Selected',
|
|
|
17 |
enableFiltering: true,
|
|
|
18 |
enableCaseInsensitiveFiltering: true
|
|
|
19 |
});
|
|
|
20 |
} else {
|
|
|
21 |
$(selector).select2({
|
|
|
22 |
placeholder: "Select or add new",
|
|
|
23 |
tags: true,
|
|
|
24 |
createTag: params => ({ id: params.term, text: params.term, newOption: true }),
|
|
|
25 |
templateResult: data => data.newOption ? $('<span class="new-option">Add: ' + data.text + '</span>') : data.text,
|
|
|
26 |
});
|
|
|
27 |
}
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
function validateRequiredFields(fields) {
|
|
|
31 |
let isValid = true;
|
|
|
32 |
fields.each(function () {
|
|
|
33 |
if (!$(this).val()) {
|
|
|
34 |
isValid = false;
|
|
|
35 |
$(this).addClass('is-invalid');
|
|
|
36 |
} else {
|
|
|
37 |
$(this).removeClass('is-invalid');
|
|
|
38 |
}
|
|
|
39 |
});
|
|
|
40 |
return isValid;
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
$(document).on('click', ".liquidation-list", function () {
|
|
|
44 |
doGetAjaxRequestHandler(context + "/liquidation", (response) => {
|
|
|
45 |
$('#main-content').html(response);
|
| 34405 |
vikas.jang |
46 |
initializeSelect('#catalogId, #status')
|
| 34387 |
vikas.jang |
47 |
$('#liquidation-table').DataTable();
|
|
|
48 |
|
|
|
49 |
});
|
|
|
50 |
});
|
|
|
51 |
|
|
|
52 |
$(document).on('click', ".save-liquidation", function () {
|
|
|
53 |
const params = serializeFormToJson('form#biddingForm');
|
| 34546 |
vikas.jang |
54 |
params.restricted = $('#restricted:checked').length;
|
|
|
55 |
if (!params.catalogId || params.catalogId === "") {
|
|
|
56 |
alert("Please select the catalog");
|
|
|
57 |
return false;
|
|
|
58 |
}
|
|
|
59 |
if (!params.price || params.price === "") {
|
|
|
60 |
alert("Bidding Price can not be empty");
|
|
|
61 |
return false;
|
|
|
62 |
}
|
|
|
63 |
if (!params.startDate || params.startDate === "") {
|
|
|
64 |
alert("Please select the start date");
|
|
|
65 |
return false;
|
|
|
66 |
}
|
|
|
67 |
if (!params.endDate || params.endDate === "") {
|
|
|
68 |
alert("Please select the end date");
|
|
|
69 |
return false;
|
|
|
70 |
}
|
| 34387 |
vikas.jang |
71 |
doAjaxRequestWithJsonHandler(context + "/liquidation", "POST", JSON.stringify(params), (response) => {
|
|
|
72 |
if (response) {
|
|
|
73 |
$('.liquidation-list').trigger('click');
|
|
|
74 |
$('#manageLiquidationModal').modal('hide');
|
|
|
75 |
alert("Saved successfully");
|
|
|
76 |
} else {
|
|
|
77 |
alert("Something went wrong!");
|
|
|
78 |
}
|
|
|
79 |
});
|
|
|
80 |
});
|
|
|
81 |
|
| 34405 |
vikas.jang |
82 |
function editLiquidation(id) {
|
|
|
83 |
doGetAjaxRequestHandler(`${context}/liquidation/${id}`, (response) => {
|
|
|
84 |
if (response.statusCode == 200){
|
|
|
85 |
$('#manageLiquidationModal').modal('show');
|
|
|
86 |
let names = Object.keys(response.response);
|
|
|
87 |
if (names.length){
|
|
|
88 |
names.forEach(name => {
|
| 34445 |
vikas.jang |
89 |
if(name === 'restricted') $(`#${name}`).prop('checked', response.response['restricted']);
|
|
|
90 |
$(`#${name}`).val(response.response[name]);
|
|
|
91 |
if (name === 'catalogId' || name === 'status') $(`#${name}`).multiselect('refresh');
|
| 34405 |
vikas.jang |
92 |
})
|
|
|
93 |
}
|
|
|
94 |
}
|
|
|
95 |
});
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
function deleteLiquidation(id) {
|
| 34387 |
vikas.jang |
99 |
if (confirm("Are you sure you want to delete this record")) {
|
|
|
100 |
if (id > 0) {
|
|
|
101 |
doDeleteAjaxRequestHandler(`${context}/liquidation/${id}`, (response) => {
|
|
|
102 |
if (response) {
|
|
|
103 |
$(this).parent('td').closest('tr').remove();
|
|
|
104 |
$('.liquidation-list').trigger('click');
|
|
|
105 |
alert("Deleted successfully");
|
|
|
106 |
} else {
|
|
|
107 |
alert("Something went wrong!");
|
|
|
108 |
}
|
|
|
109 |
});
|
|
|
110 |
} else {
|
| 34405 |
vikas.jang |
111 |
alert("Liquidation not found");
|
| 34387 |
vikas.jang |
112 |
}
|
|
|
113 |
}
|
| 34445 |
vikas.jang |
114 |
}
|
| 34546 |
vikas.jang |
115 |
|
|
|
116 |
$(document).on('click','.publish-liquidation', function () {
|
|
|
117 |
const mediaId = $('#mediaId').val();
|
|
|
118 |
const liquidationIds = $('.selectLiquidations:checked').map(function() { return $(this).val();}).get().join(',');
|
|
|
119 |
doAjaxRequestWithJsonHandler(context + "/liquidation/publish", "POST", JSON.stringify({'mediaId': mediaId,'liquidationIds':liquidationIds}), (response) => {
|
|
|
120 |
if (response) {
|
|
|
121 |
$('.liquidation-list').trigger('click');
|
|
|
122 |
$('#publishLiquidationModal').modal('hide');
|
|
|
123 |
alert("Published successfully!");
|
|
|
124 |
} else {
|
|
|
125 |
alert("Something went wrong!");
|
|
|
126 |
}
|
|
|
127 |
});
|
|
|
128 |
});
|