| 30485 |
tejbeer |
1 |
$(document).ready(function() {
|
|
|
2 |
$(document).on('change', 'select.criteria-brands', function() {
|
| 27875 |
amit.gupta |
3 |
changed = true;
|
|
|
4 |
});
|
| 30485 |
tejbeer |
5 |
$(document).on('click', ".scheme_offer", function() {
|
|
|
6 |
loadOffer("main-content");
|
|
|
7 |
});
|
|
|
8 |
$(document).on('click', '#yearmonth-submit', function() {
|
|
|
9 |
let yearMonth = $("#yearmonth").val();
|
|
|
10 |
loadOfferHistory('#main-content', yearMonth);
|
| 27875 |
amit.gupta |
11 |
|
| 30485 |
tejbeer |
12 |
});
|
| 27875 |
amit.gupta |
13 |
|
| 30485 |
tejbeer |
14 |
$(document).on('click', 'a.mk_partner_view', function() {
|
|
|
15 |
let $offerTr = $(this).closest('tr');
|
|
|
16 |
let offerId = $offerTr.data('offerid');
|
|
|
17 |
if (typeof (offerId) == "undefined") {
|
|
|
18 |
offerId = $(this).closest('th').data('offerid');
|
|
|
19 |
let idx = $(this).closest('th').data('idx');
|
|
|
20 |
priceCircularTable.order([[parseInt(idx), 'desc']]).draw();
|
|
|
21 |
}
|
|
|
22 |
doGetAjaxRequestHandler(`${context}/getOfferMargins?offerId=${offerId}`, function(data) {
|
|
|
23 |
$('#offerDescription .modal-content').html(data);
|
|
|
24 |
$("#offerDescription").modal('show');
|
|
|
25 |
});
|
|
|
26 |
});
|
|
|
27 |
|
|
|
28 |
$(document).on('click', 'a.mk_offer_detail', function() {
|
|
|
29 |
let $offerTr = $(this).closest('tr');
|
|
|
30 |
let offerId = $offerTr.data('offerid');
|
|
|
31 |
doGetAjaxRequestHandler(`${context}\getOfferMargins?offerId=${offerId}`, function(data) {
|
|
|
32 |
$('#offerDescription .modal-content').html(data);
|
|
|
33 |
$("#offerDescription").modal('show');
|
|
|
34 |
});
|
|
|
35 |
});
|
|
|
36 |
$(document).on('click', 'a.offer_history', function() {
|
|
|
37 |
let dt = new Date();
|
|
|
38 |
loadOfferHistory('#main-content', new Date().toISOString().slice(0, 7));
|
|
|
39 |
});
|
|
|
40 |
$(document).on('click', 'input.create-offer', function() {
|
|
|
41 |
console.log("Click called");
|
|
|
42 |
createOfferNew();
|
|
|
43 |
});
|
|
|
44 |
|
| 30651 |
amit.gupta |
45 |
$(document).on('click', 'a.process_offer', function () {
|
| 30485 |
tejbeer |
46 |
let $offerTr = $(this).closest('tr');
|
|
|
47 |
let offerId = $offerTr.data('offerid');
|
| 30651 |
amit.gupta |
48 |
if (confirm("Are your sure you want to process?")) {
|
|
|
49 |
doGetAjaxRequestHandler(`${context}/offer/process/${offerId}`, function () {
|
|
|
50 |
alert("Offer Processed successfully");
|
|
|
51 |
});
|
|
|
52 |
}
|
| 30485 |
tejbeer |
53 |
});
|
|
|
54 |
|
|
|
55 |
$(document).on('change', 'input[name=schemeType]', function() {
|
| 31190 |
amit.gupta |
56 |
if ($('input[name=schemeType]').val() == 'ACTIVATION') {
|
| 27875 |
amit.gupta |
57 |
$("div.activation-brands").show();
|
|
|
58 |
} else {
|
|
|
59 |
$("div.activation-brands").hide();
|
|
|
60 |
}
|
| 30485 |
tejbeer |
61 |
});
|
|
|
62 |
$(document).on('change', 'input[name^=amountType]', function() {
|
|
|
63 |
let holder1 = "Qty";
|
| 27875 |
amit.gupta |
64 |
let holder2 = "pc(s) onwards, ";
|
| 30485 |
tejbeer |
65 |
let holder3 = "% of value";
|
|
|
66 |
if ($(this).val() == "FIXED") {
|
|
|
67 |
holder3 = "per pc";
|
|
|
68 |
} else if ($(this).val() == "SLAB_FIXED") {
|
|
|
69 |
holder3 = "";
|
|
|
70 |
}
|
|
|
71 |
let slabHtml = `<div class="input-group slab">
|
| 27875 |
amit.gupta |
72 |
<span class="input-group-addon">${holder1}</span>
|
|
|
73 |
<input type="text" class="slabOnwardsAmount form-control" value="0"/>
|
|
|
74 |
<span class="input-group-addon">${holder2}</span>
|
|
|
75 |
<input type="text" class="form-control payoutValue" value="0"/>
|
|
|
76 |
<span class="input-group-addon">${holder3}</span>
|
|
|
77 |
</div>`;
|
| 30485 |
tejbeer |
78 |
$(this).closest('.itemcriteriapayout').find('div.slab-container').html(slabHtml.repeat(9));
|
|
|
79 |
//targetSlabTemplate = $('div.targetslabs').get(0).outerHTML;
|
|
|
80 |
});
|
| 27875 |
amit.gupta |
81 |
});
|
|
|
82 |
function changeTargetType() {
|
|
|
83 |
let holder1 = "Rs.";
|
|
|
84 |
let holder2 = "onwards,";
|
| 27895 |
amit.gupta |
85 |
if ($(this).val() == "QUANTITY") {
|
|
|
86 |
holder1 = "Qty";
|
|
|
87 |
holder2 = "pc(s) onwards, ";
|
|
|
88 |
}
|
|
|
89 |
let targetHtml = `<span class="input-group-addon">${holder1}</span>
|
|
|
90 |
<input type="text" style="width:100px" class="form-control payoutTarget" value="0">
|
|
|
91 |
<span class="input-group-addon">${holder2}</span>
|
|
|
92 |
<input type="text" class="form-control targetDescription" placeholder="Description">`;
|
|
|
93 |
$('div.targetContainer').html(targetHtml);
|
|
|
94 |
}
|
|
|
95 |
function changePayoutType() {
|
|
|
96 |
let holder1 = "Rs.";
|
|
|
97 |
let holder2 = "onwards,";
|
| 27875 |
amit.gupta |
98 |
let holder3 = "% of value";
|
|
|
99 |
$allSlabContainers = $('div.slab-container');
|
| 30485 |
tejbeer |
100 |
$('div.slab-payout input:radio[value="PERCENTAGE"]').prop('checked', true);
|
|
|
101 |
if ($(this).val() == "QUANTITY") {
|
|
|
102 |
holder1 = "Qty";
|
|
|
103 |
holder2 = "pc(s) onwards, ";
|
|
|
104 |
$('div.slab-payout input:radio[value!="PERCENTAGE"]').prop('checked', false).prop('disabled', false);
|
|
|
105 |
} else {
|
|
|
106 |
$('div.slab-payout input:radio[value!="PERCENTAGE"]').prop('checked', false).prop('disabled', true);
|
|
|
107 |
}
|
|
|
108 |
let slabHtml = `<div class="input-group slab">
|
| 27875 |
amit.gupta |
109 |
<span class="input-group-addon">${holder1}</span>
|
|
|
110 |
<input type="text" class="slabOnwardsAmount form-control" value="0"/>
|
|
|
111 |
<span class="input-group-addon">${holder2}</span>
|
|
|
112 |
<input type="text" class="form-control payoutValue" value="0"/>
|
|
|
113 |
<span class="input-group-addon">${holder3}</span>
|
|
|
114 |
</div>`;
|
| 30485 |
tejbeer |
115 |
$allSlabContainers.html(slabHtml.repeat(9));
|
| 27875 |
amit.gupta |
116 |
}
|
| 30485 |
tejbeer |
117 |
$(document).on('click', 'a.mk_offer_active', function() {
|
| 29915 |
amit.gupta |
118 |
$clicked = $(this);
|
|
|
119 |
let offerId = $clicked.closest('tr').data("offerid");
|
| 30485 |
tejbeer |
120 |
if (confirm(`Are you sure want to activate ${offerId}?`)) {
|
|
|
121 |
doGetAjaxRequestHandler(`${context}/offer/active/${offerId}`, function(response) {
|
| 29915 |
amit.gupta |
122 |
alert("Offer is now active");
|
|
|
123 |
$clicked.closest("li").html(`<a class="mk_offer_inactive" href="javascript:void(0)">Mark Inactive</a>`);
|
| 30485 |
tejbeer |
124 |
});
|
|
|
125 |
}
|
| 27875 |
amit.gupta |
126 |
});
|
| 30485 |
tejbeer |
127 |
$(document).on('click', 'a.mk_offer_inactive', function() {
|
| 29915 |
amit.gupta |
128 |
$clicked = $(this);
|
|
|
129 |
let offerId = $clicked.closest('tr').data("offerid");
|
| 30485 |
tejbeer |
130 |
if (confirm(`Are you sure want to activate ${offerId}?`)) {
|
|
|
131 |
doGetAjaxRequestHandler(`${context}/offer/active/${offerId}?active=false`, function(response) {
|
| 29915 |
amit.gupta |
132 |
alert("Offer is now inactive");
|
|
|
133 |
$clicked.closest("li").html(`<a class="mk_offer_active" href="javascript:void(0)">Mark Active</a>`);
|
| 30485 |
tejbeer |
134 |
});
|
|
|
135 |
}
|
| 29907 |
amit.gupta |
136 |
});
|
| 30485 |
tejbeer |
137 |
$(document).on('click', 'button.slab-add', function() {
|
| 27875 |
amit.gupta |
138 |
newTargetSlab = $(targetSlabTemplate);
|
| 30485 |
tejbeer |
139 |
$('div.targetslabscontainer').append(newTargetSlab);
|
| 27875 |
amit.gupta |
140 |
newTargetSlab.find("select.criteria-brands").toggle().next().remove();
|
| 30485 |
tejbeer |
141 |
newTargetSlab.find("select.criteria-brands").chosen({ no_results_text: "Oops, nothing found!" });
|
| 27875 |
amit.gupta |
142 |
});
|
| 30485 |
tejbeer |
143 |
$(document).on('click', 'button.slab-remove', function() {
|
| 27875 |
amit.gupta |
144 |
targetSlabContainer = $('div.targetslabscontainer');
|
| 30485 |
tejbeer |
145 |
if (targetSlabContainer.find(".targetslabs").length > 1) {
|
| 27875 |
amit.gupta |
146 |
targetSlabContainer.find(".targetslabs:last").remove();
|
|
|
147 |
} else {
|
|
|
148 |
alert("Cant remove single Slab");
|
|
|
149 |
}
|
|
|
150 |
});
|
| 30485 |
tejbeer |
151 |
$(document).on('click', 'button.slab-copy', function() {
|
| 27875 |
amit.gupta |
152 |
newTargetSlab = $('div.targetslabs').eq(0).clone().appendTo('div.targetslabscontainer');
|
| 27975 |
amit.gupta |
153 |
catalogIdSelectContainers = $('div.targetslabs').eq(0).find('select.criteria-catalogids');
|
|
|
154 |
newCatalogIdSelectContainers = newTargetSlab.find('select.criteria-catalogids');
|
| 30485 |
tejbeer |
155 |
for (let i = 0; i < 9; i++) {
|
| 27975 |
amit.gupta |
156 |
let selectContainer = catalogIdSelectContainers.get(i);
|
|
|
157 |
let newSelectContainer = newCatalogIdSelectContainers.get(i);
|
| 30485 |
tejbeer |
158 |
for (let j = 0; j < selectContainer.options.length; j++) {
|
| 27975 |
amit.gupta |
159 |
newSelectContainer.options[j].selected = selectContainer.options[j].selected;
|
|
|
160 |
}
|
|
|
161 |
newSelectContainer.closest('span').replaceWith(newSelectContainer);
|
|
|
162 |
$(newSelectContainer).multiselect({
|
| 30485 |
tejbeer |
163 |
includeSelectAllOption: true,
|
|
|
164 |
maxHeight: 400,
|
|
|
165 |
buttonWidth: '240px',
|
|
|
166 |
numberDisplayed: 1,
|
|
|
167 |
nonSelectedText: 'Items',
|
|
|
168 |
nSelectedText: ' - Items Selected',
|
|
|
169 |
allSelectedText: 'All Items Selected',
|
|
|
170 |
enableFiltering: true,
|
|
|
171 |
enableCaseInsensitiveFiltering: true,
|
| 27975 |
amit.gupta |
172 |
});
|
|
|
173 |
}
|
| 27875 |
amit.gupta |
174 |
selectContainers = newTargetSlab.find("select.criteria-brands");
|
| 30485 |
tejbeer |
175 |
selectContainers.each((y, x) => {
|
| 27875 |
amit.gupta |
176 |
$next = $(x).toggle().next();
|
| 30485 |
tejbeer |
177 |
$next.find("a.search-choice-close").each(function(index, ele) {
|
|
|
178 |
x.options[$(ele).data('option-array-index') + 0].selected = true;
|
| 27875 |
amit.gupta |
179 |
});
|
|
|
180 |
$next.remove();
|
|
|
181 |
});
|
| 30485 |
tejbeer |
182 |
newTargetSlab.find("select.criteria-brands").chosen({ no_results_text: "Oops, nothing found!" });
|
| 27875 |
amit.gupta |
183 |
//createSlabFrom(currentHtml);
|
|
|
184 |
});
|
|
|
185 |
|
| 30485 |
tejbeer |
186 |
$(document).on('click', 'select.criteria-catalogids+div > button', function() {
|
|
|
187 |
if (changed) {
|
| 27916 |
amit.gupta |
188 |
let brands = $(this).closest('.item-criteria').find('select').val();
|
| 30753 |
amit.gupta |
189 |
let led = $(this).closest('.item-criteria').find('input[name=led]').is(":checked");
|
| 33320 |
amit.gupta |
190 |
let tablet = $(this).closest('.item-criteria').find('input[name=tablet]').is(":checked");
|
| 27916 |
amit.gupta |
191 |
$brandsContainer = $(this);
|
| 30753 |
amit.gupta |
192 |
let categoryId = 3;
|
|
|
193 |
if (led) {
|
|
|
194 |
categoryId = 14202;
|
|
|
195 |
}
|
| 33320 |
amit.gupta |
196 |
if(tablet) {
|
|
|
197 |
categoryId = 10010;
|
|
|
198 |
}
|
| 30753 |
amit.gupta |
199 |
var url = `${context}/entity?brands=${brands.join(",")}&categoryId=${categoryId}&limit=0`;
|
| 27875 |
amit.gupta |
200 |
$select = $brandsContainer.closest('.item-criteria').find('.criteria-catalogids');
|
|
|
201 |
$select.html('');
|
| 30485 |
tejbeer |
202 |
if (brands.length > 0) {
|
| 30753 |
amit.gupta |
203 |
doGetAjaxRequestHandler(url, function (response) {
|
| 27875 |
amit.gupta |
204 |
data = JSON.parse(response);
|
| 30485 |
tejbeer |
205 |
for (i = 0; i < data.length; i++) {
|
| 27875 |
amit.gupta |
206 |
$select.append(`<option value="${data[i].catalogId_i}">${data[i].title_s}</option>`);
|
|
|
207 |
}
|
|
|
208 |
$select.multiselect('rebuild');
|
|
|
209 |
});
|
|
|
210 |
} else {
|
|
|
211 |
$select.html('');
|
|
|
212 |
$select.multiselect('rebuild');
|
|
|
213 |
}
|
|
|
214 |
changed = !changed;
|
|
|
215 |
}
|
|
|
216 |
});
|
|
|
217 |
|
| 30485 |
tejbeer |
218 |
var ckEditor;
|
|
|
219 |
|
| 27875 |
amit.gupta |
220 |
function createOfferNew() {
|
| 30485 |
tejbeer |
221 |
let validated = true;
|
| 30599 |
amit.gupta |
222 |
let rangePicker = getDatesFromPicker('input[name="dateRange"]');
|
| 30485 |
tejbeer |
223 |
let createOfferRequest = {};
|
|
|
224 |
createOfferRequest['name'] = $("#offer_name").val();
|
| 30599 |
amit.gupta |
225 |
createOfferRequest['startDate'] = rangePicker.startDate;
|
|
|
226 |
createOfferRequest['endDate'] = rangePicker.endDate;
|
| 30485 |
tejbeer |
227 |
createOfferRequest['offerNotes'] = $("#offer_notes").val();
|
|
|
228 |
createOfferRequest['baseCriteria'] = $("input[name=base_criteria]").is(":checked");
|
|
|
229 |
createOfferRequest['terms'] = ckEditor.getData() //$("#offer_terms").val();
|
|
|
230 |
createOfferRequest['targetType'] = $("input[name=targetType]:checked").val();
|
|
|
231 |
createOfferRequest['payoutType'] = $("input[name=payoutType]:checked").val();
|
| 31227 |
amit.gupta |
232 |
createOfferRequest['schemeType'] = $("select[name=schemeType]").val();
|
| 31190 |
amit.gupta |
233 |
createOfferRequest['booster'] = false;
|
|
|
234 |
createOfferRequest['activationBrands'] = null;
|
| 32065 |
amit.gupta |
235 |
createOfferRequest['discount'] = $("input[name=discount]").is(':checked');
|
| 30485 |
tejbeer |
236 |
if (createOfferRequest['schemeType'] == 'ACTIVATION') {
|
|
|
237 |
createOfferRequest['activationBrands'] = $("div.activation-brands select").val().join(",") || null;
|
| 31190 |
amit.gupta |
238 |
} else if (createOfferRequest['schemeType'] == 'SELLINBOOSTER') {
|
|
|
239 |
createOfferRequest['schemeType'] = 'SELLIN';
|
|
|
240 |
createOfferRequest['booster'] = true;
|
| 30485 |
tejbeer |
241 |
}
|
|
|
242 |
createOfferRequest['sellinPercentage'] = $("#sellinPercentage").val();
|
|
|
243 |
createOfferRequest['brandShareTerms'] = $('#brandShare').val();
|
|
|
244 |
createOfferRequest['partnerCriteria'] = {};
|
|
|
245 |
createOfferRequest['partnerCriteria']['fofoIds'] = ($("#partners").val() || []).map(Number);
|
| 30723 |
amit.gupta |
246 |
createOfferRequest['partnerCriteria']['excludeFofoIds'] = [];
|
|
|
247 |
let excludeFofoIdChecked = $('input.excludeFofoId').is(':checked');
|
|
|
248 |
if (excludeFofoIdChecked) {
|
|
|
249 |
createOfferRequest['partnerCriteria']['excludeFofoIds'] = createOfferRequest['partnerCriteria']['fofoIds'];
|
|
|
250 |
createOfferRequest['partnerCriteria']['fofoIds'] = [];
|
|
|
251 |
}
|
| 30485 |
tejbeer |
252 |
createOfferRequest['partnerCriteria']['partnerTypes'] = ($("select.criteria-partner-type").val() || []);
|
|
|
253 |
createOfferRequest['partnerCriteria']['regionIds'] = ($("select.criteria-warehouseregion").val() || []).map(Number);
|
| 27875 |
amit.gupta |
254 |
|
| 30485 |
tejbeer |
255 |
createOfferRequest['itemCriteria'] = itemCriteria($('div.itemCriteria'));
|
|
|
256 |
let targetSlabs = [];
|
| 30723 |
amit.gupta |
257 |
$('div.targetslabs').each(function (index, ele) {
|
| 30485 |
tejbeer |
258 |
let $targetSlab = $(ele);
|
|
|
259 |
let targetOnwardsValue = $targetSlab.find('.payoutTarget').val();
|
|
|
260 |
let targetDescription = $targetSlab.find('.targetDescription').val();
|
|
|
261 |
let itemCriteriaPayouts = [];
|
|
|
262 |
if (isNaN(targetOnwardsValue) || targetOnwardsValue < 0) {
|
|
|
263 |
validated = false;
|
|
|
264 |
alert(`Invalid Number - ${targetOnwardsValue}`);
|
|
|
265 |
} else {
|
|
|
266 |
if (index == 0 || targetOnwardsValue > 0) {
|
|
|
267 |
let $itemCriteriaPayoutContainers = $targetSlab.find('.itemcriteriapayout');
|
|
|
268 |
$itemCriteriaPayoutContainers.each(function(index, itemCriteriaPayoutContainer) {
|
|
|
269 |
let $itemCriteriaPayoutContainer = $(itemCriteriaPayoutContainer);
|
|
|
270 |
let amountType = $itemCriteriaPayoutContainer.find('input[name^=amountType]:checked').val();
|
| 32979 |
amit.gupta |
271 |
let startDate = $itemCriteriaPayoutContainer.find('input.startDate').val();
|
|
|
272 |
let endDate = $itemCriteriaPayoutContainer.find('input.endDate').val();
|
|
|
273 |
if((startDate=="" && endDate!="") && (startDate!="" && endDate=="")) {
|
|
|
274 |
alert("Criteria specific date is required");
|
|
|
275 |
return false;
|
|
|
276 |
}
|
| 30485 |
tejbeer |
277 |
let payoutSlabs = [];
|
|
|
278 |
let itemCriteria1 = itemCriteria($itemCriteriaPayoutContainer);
|
|
|
279 |
let $payoutSlabContainers = $itemCriteriaPayoutContainer.find('.slab');
|
|
|
280 |
let itemCriteriaChanged = itemCriteria1['smartPhone'] || itemCriteria1['featuredPhone']
|
|
|
281 |
|| itemCriteria1['catalogIds'].length > 0 || itemCriteria1['brands'].length > 0
|
|
|
282 |
|| itemCriteria1['excludeCatalogIds'].length > 0
|
|
|
283 |
|| itemCriteria1['startPrice'] > 0 || itemCriteria1['endPrice'] > itemCriteria1['startPrice'] > 0;
|
|
|
284 |
if (itemCriteriaChanged || index == 0) {
|
|
|
285 |
$payoutSlabContainers.each(function(slabContainerIndex, slabContainer) {
|
|
|
286 |
let $slab = $(slabContainer);
|
|
|
287 |
|
|
|
288 |
let slabOnwardsAmount = $slab.find('.slabOnwardsAmount').val();
|
|
|
289 |
if (isNaN(slabOnwardsAmount) || slabOnwardsAmount < 0) {
|
|
|
290 |
validated = false;
|
|
|
291 |
alert(`Invalid Payout Slab Amount - ${slabOnwardsAmount}`);
|
|
|
292 |
} else {
|
|
|
293 |
if (slabContainerIndex == 0 || slabOnwardsAmount > 0) {
|
|
|
294 |
let payoutAmount = $slab.find('.payoutValue').val();
|
|
|
295 |
if (isNaN(payoutAmount) || payoutAmount <= 0) {
|
|
|
296 |
validated = false;
|
|
|
297 |
alert(`Invalid Payout Slab Amount - ${slabOnwardsAmount}`);
|
|
|
298 |
}
|
|
|
299 |
let payoutSlab = {
|
|
|
300 |
onwardsAmount: Number(slabOnwardsAmount),
|
|
|
301 |
payoutAmount: Number(payoutAmount)
|
|
|
302 |
}
|
|
|
303 |
payoutSlabs.push(payoutSlab);
|
|
|
304 |
}
|
|
|
305 |
}
|
|
|
306 |
});
|
|
|
307 |
let itemCriteriaPayout = {
|
|
|
308 |
itemCriteria: itemCriteria1,
|
|
|
309 |
payoutSlabs: payoutSlabs,
|
| 32979 |
amit.gupta |
310 |
amountType: amountType,
|
|
|
311 |
startDate: jsonStartDate(startDate),
|
|
|
312 |
endDate: jsonEndDate(endDate)
|
| 30485 |
tejbeer |
313 |
};
|
|
|
314 |
itemCriteriaPayouts.push(itemCriteriaPayout);
|
|
|
315 |
}
|
|
|
316 |
});
|
|
|
317 |
targetSlabs.push({
|
|
|
318 |
onwardsAmount: targetOnwardsValue,
|
|
|
319 |
targetDescription: targetDescription,
|
|
|
320 |
itemCriteriaPayouts: itemCriteriaPayouts
|
|
|
321 |
});
|
|
|
322 |
}
|
|
|
323 |
}
|
|
|
324 |
});
|
|
|
325 |
createOfferRequest['targetSlabs'] = targetSlabs;
|
|
|
326 |
if (validated && confirm("Confirm creating scheme offer")) {
|
|
|
327 |
console.log("Validated");
|
|
|
328 |
console.log(createOfferRequest);
|
|
|
329 |
doPostAjaxRequestWithJsonHandler(`${context}/createOffer`, JSON.stringify(createOfferRequest), function(response) {
|
|
|
330 |
alert("Offer created successfully");
|
|
|
331 |
let dt = new Date();
|
|
|
332 |
loadOfferHistory('#main-content', new Date().toISOString().slice(0, 7));
|
|
|
333 |
});
|
|
|
334 |
} else {
|
|
|
335 |
console.log("Invalid Offer");
|
|
|
336 |
}
|
| 27875 |
amit.gupta |
337 |
}
|
|
|
338 |
|
|
|
339 |
function itemCriteria($container) {
|
| 28018 |
amit.gupta |
340 |
let smartPhone = $container.find("input[name=smartphone]").is(":checked");
|
|
|
341 |
let featuredPhone = $container.find("input[name=featuredphone]").is(":checked");
|
| 30753 |
amit.gupta |
342 |
let led = $container.find("input[name=led]").is(":checked");
|
| 30485 |
tejbeer |
343 |
let catalogIds = $container.find('.criteria-catalogids').val() || [];
|
|
|
344 |
let excludeCatalogIds = [];
|
|
|
345 |
let excludeChecked = $container.find('input.exclude').is(':checked');
|
|
|
346 |
if (excludeChecked) {
|
|
|
347 |
excludeCatalogIds = catalogIds;
|
|
|
348 |
catalogIds = [];
|
|
|
349 |
}
|
|
|
350 |
let brands = $container.find('.criteria-brands').val() || [];
|
|
|
351 |
return {
|
|
|
352 |
startPrice: Number($container.find('.startValue').val()),
|
|
|
353 |
endPrice: Number($container.find('.endValue').val()),
|
|
|
354 |
catalogIds: catalogIds.map(Number),
|
|
|
355 |
excludeCatalogIds: excludeCatalogIds.map(Number),
|
|
|
356 |
brands: brands,
|
|
|
357 |
smartPhone: smartPhone,
|
| 30753 |
amit.gupta |
358 |
featuredPhone: featuredPhone,
|
|
|
359 |
led: led
|
| 30485 |
tejbeer |
360 |
};
|
| 27875 |
amit.gupta |
361 |
}
|
|
|
362 |
|
|
|
363 |
function loadOffer(domId) {
|
| 30485 |
tejbeer |
364 |
console.log(domId);
|
|
|
365 |
doGetAjaxRequestHandler(context + "/getCreateOffer", function(response) {
|
|
|
366 |
$('#' + domId).html(response);
|
|
|
367 |
|
|
|
368 |
DecoupledEditor
|
|
|
369 |
.create(document.querySelector('#offer_terms'))
|
|
|
370 |
|
|
|
371 |
|
|
|
372 |
|
|
|
373 |
.then(newEditor => {
|
|
|
374 |
const toolbarContainer = document.querySelector('#toolbar-container');
|
|
|
375 |
|
|
|
376 |
toolbarContainer.appendChild(newEditor.ui.view.toolbar.element);
|
|
|
377 |
|
|
|
378 |
ckEditor = newEditor
|
|
|
379 |
})
|
|
|
380 |
.catch(error => {
|
|
|
381 |
console.error(error);
|
|
|
382 |
});
|
|
|
383 |
|
|
|
384 |
});
|
| 27875 |
amit.gupta |
385 |
}
|
|
|
386 |
function loadOfferHistory(domId, yearMonth) {
|
| 30485 |
tejbeer |
387 |
doGetAjaxRequestHandler(`${context}/offerHistory?yearMonth=${yearMonth}`, function(response) {
|
|
|
388 |
$(domId).html(response);
|
|
|
389 |
$(domId).find("#yearmonth").val(yearMonth);
|
|
|
390 |
});
|
| 27875 |
amit.gupta |
391 |
}
|
|
|
392 |
|