Subversion Repositories SmartDukaan

Rev

Rev 35497 | Rev 35745 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33660 amit.gupta 1
$(document).ready(function () {
2
    $(document).on('change', 'select.criteria-brands', function () {
3
        changed = true;
4
    });
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
 
33660 amit.gupta 12
    });
27875 amit.gupta 13
 
33660 amit.gupta 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
    });
30485 tejbeer 27
 
33660 amit.gupta 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
    });
30485 tejbeer 44
 
33660 amit.gupta 45
    $(document).on('click', 'a.process_offer', function () {
46
        let $offerTr = $(this).closest('tr');
47
        let offerId = $offerTr.data('offerid');
48
        $clicked = $(this);
49
        if (confirm("Are your sure you want to process?")) {
50
            $clicked.hide();
51
            doGetAjaxRequestHandler(`${context}/offer/process/${offerId}`, function () {
52
                alert("Offer Processed successfully");
53
                $clicked.show();
54
            });
55
        }
56
    });
30485 tejbeer 57
 
33660 amit.gupta 58
    $(document).on('change', 'input[name=schemeType]', function () {
59
        if ($('input[name=schemeType]').val() == 'ACTIVATION') {
60
            $("div.activation-brands").show();
61
        } else {
62
            $("div.activation-brands").hide();
63
        }
64
    });
65
    $(document).on('change', 'input[name^=amountType]', function () {
66
        let holder1 = "Qty";
67
        let holder2 = "pc(s) onwards, ";
68
        let holder3 = "% of value";
69
        if ($(this).val() == "FIXED") {
70
            holder3 = "per pc";
71
        } else if ($(this).val() == "SLAB_FIXED") {
72
            holder3 = "";
73
        }
74
        let slabHtml = `<div class="input-group slab">
27875 amit.gupta 75
        	<span class="input-group-addon">${holder1}</span>
76
        	<input  type="text" class="slabOnwardsAmount form-control"  value="0"/>
77
        	<span class="input-group-addon">${holder2}</span>
78
        	<input type="text" class="form-control payoutValue"  value="0"/>
79
        	<span class="input-group-addon">${holder3}</span>
80
        	</div>`;
35219 amit 81
        $(this).closest('.itemcriteriapayout').find('div.slab-container').html(slabHtml.repeat(15));
33660 amit.gupta 82
        //targetSlabTemplate = $('div.targetslabs').get(0).outerHTML;
83
    });
27875 amit.gupta 84
});
33660 amit.gupta 85
 
27875 amit.gupta 86
function changeTargetType() {
33660 amit.gupta 87
    let holder1 = "Rs.";
88
    let holder2 = "onwards,";
89
    if ($(this).val() == "QUANTITY") {
90
        holder1 = "Qty";
91
        holder2 = "pc(s) onwards, ";
92
    }
93
    let targetHtml = `<span class="input-group-addon">${holder1}</span>
27895 amit.gupta 94
                                    <input type="text" style="width:100px" class="form-control payoutTarget" value="0">
95
                                    <span class="input-group-addon">${holder2}</span>
96
                                    <input type="text" class="form-control targetDescription" placeholder="Description">`;
33660 amit.gupta 97
    $('div.targetContainer').html(targetHtml);
27895 amit.gupta 98
}
33660 amit.gupta 99
 
27895 amit.gupta 100
function changePayoutType() {
33660 amit.gupta 101
    let holder1 = "Rs.";
102
    let holder2 = "onwards,";
103
    let holder3 = "% of value";
104
    $allSlabContainers = $('div.slab-container');
105
    $('div.slab-payout input:radio[value="PERCENTAGE"]').prop('checked', true);
106
    if ($(this).val() == "QUANTITY") {
107
        holder1 = "Qty";
108
        holder2 = "pc(s) onwards, ";
109
        $('div.slab-payout input:radio[value!="PERCENTAGE"]').prop('checked', false).prop('disabled', false);
110
    } else {
111
        $('div.slab-payout input:radio[value!="PERCENTAGE"]').prop('checked', false).prop('disabled', true);
112
    }
113
    let slabHtml = `<div class="input-group slab">
27875 amit.gupta 114
    	<span class="input-group-addon">${holder1}</span>
115
    	<input  type="text" class="slabOnwardsAmount form-control"  value="0"/>
116
    	<span class="input-group-addon">${holder2}</span>
117
    	<input type="text" class="form-control payoutValue"  value="0"/>
118
    	<span class="input-group-addon">${holder3}</span>
119
    	</div>`;
35218 amit 120
    $allSlabContainers.html(slabHtml.repeat(15));
27875 amit.gupta 121
}
33660 amit.gupta 122
 
123
$(document).on('click', 'a.mk_offer_active', function () {
124
    $clicked = $(this);
125
    let offerId = $clicked.closest('tr').data("offerid");
126
    if (confirm(`Are you sure want to activate ${offerId}?`)) {
127
        doGetAjaxRequestHandler(`${context}/offer/active/${offerId}`, function (response) {
128
            alert("Offer is now active");
129
            $clicked.closest("li").html(`<a class="mk_offer_inactive" href="javascript:void(0)">Mark Inactive</a>`);
130
        });
131
    }
27875 amit.gupta 132
});
33660 amit.gupta 133
$(document).on('click', 'a.mk_offer_inactive', function () {
134
    $clicked = $(this);
135
    let offerId = $clicked.closest('tr').data("offerid");
136
    if (confirm(`Are you sure want to activate ${offerId}?`)) {
137
        doGetAjaxRequestHandler(`${context}/offer/active/${offerId}?active=false`, function (response) {
138
            alert("Offer is now inactive");
139
            $clicked.closest("li").html(`<a class="mk_offer_active" href="javascript:void(0)">Mark Active</a>`);
140
        });
141
    }
29907 amit.gupta 142
});
33660 amit.gupta 143
$(document).on('click', 'button.slab-add', function () {
144
    newTargetSlab = $(targetSlabTemplate);
145
    $('div.targetslabscontainer').append(newTargetSlab);
146
    newTargetSlab.find("select.criteria-brands").toggle().next().remove();
147
    newTargetSlab.find("select.criteria-brands").chosen({no_results_text: "Oops, nothing found!"});
27875 amit.gupta 148
});
33660 amit.gupta 149
$(document).on('click', 'button.slab-remove', function () {
150
    targetSlabContainer = $('div.targetslabscontainer');
151
    if (targetSlabContainer.find(".targetslabs").length > 1) {
152
        targetSlabContainer.find(".targetslabs:last").remove();
153
    } else {
154
        alert("Cant remove single Slab");
155
    }
27875 amit.gupta 156
});
33660 amit.gupta 157
$(document).on('click', 'button.slab-copy', function () {
158
    newTargetSlab = $('div.targetslabs').eq(0).clone().appendTo('div.targetslabscontainer');
159
    catalogIdSelectContainers = $('div.targetslabs').eq(0).find('select.criteria-catalogids');
160
    newCatalogIdSelectContainers = newTargetSlab.find('select.criteria-catalogids');
35219 amit 161
    for (let i = 0; i < 15; i++) {
33660 amit.gupta 162
        let selectContainer = catalogIdSelectContainers.get(i);
163
        let newSelectContainer = newCatalogIdSelectContainers.get(i);
164
        for (let j = 0; j < selectContainer.options.length; j++) {
165
            newSelectContainer.options[j].selected = selectContainer.options[j].selected;
166
        }
167
        newSelectContainer.closest('span').replaceWith(newSelectContainer);
168
        $(newSelectContainer).multiselect({
169
            includeSelectAllOption: true,
170
            maxHeight: 400,
171
            buttonWidth: '240px',
172
            numberDisplayed: 1,
173
            nonSelectedText: 'Items',
174
            nSelectedText: ' - Items Selected',
175
            allSelectedText: 'All Items Selected',
176
            enableFiltering: true,
177
            enableCaseInsensitiveFiltering: true,
178
        });
179
    }
180
    selectContainers = newTargetSlab.find("select.criteria-brands");
181
    selectContainers.each((y, x) => {
182
        $next = $(x).toggle().next();
183
        $next.find("a.search-choice-close").each(function (index, ele) {
184
            x.options[$(ele).data('option-array-index') + 0].selected = true;
185
        });
186
        $next.remove();
187
    });
188
    newTargetSlab.find("select.criteria-brands").chosen({no_results_text: "Oops, nothing found!"});
189
    //createSlabFrom(currentHtml);
27875 amit.gupta 190
});
191
 
34210 tejus.loha 192
$(document).on('click', '.scheme_block_imeis_panel', function () {
193
    reloadBlockImeiPanel();
194
    $('div.modal-backdrop.fade').remove();
195
 
196
 
197
});
198
 
199
$(document).on('click', '.eligible_offer_imeis_panel', function () {
34216 tejus.loha 200
    doGetAjaxRequestHandler(`${context}/offerEligibleImeis/panel`, function (response) {
34210 tejus.loha 201
        $('#main-content').html(response);
202
    });
203
    $('div.modal-backdrop.fade').remove();
204
 
205
 
206
});
207
 
208
 
209
$(document).on('click', '#submit_scheme_block_imeis', function () {
210
    let blockImei = $('#block_imei_scheme').val();
211
    console.log("blockImei - ", blockImei);
212
    if (!blockImei) {
213
        alert("Please enter Imei");
214
        return;
215
    }
216
 
217
    let url = `${context}/createBlockImei?imeiNumbers=${blockImei}`;
218
    if (confirm('Are you sure to block all enter Imei numbers')) {
219
        doPostAjaxRequestHandler(url, function (response) {
220
            if (response) {
221
                alert("Imei blocked successfully");
222
                reloadBlockImeiList();
223
            }
224
        });
225
    } else {
226
        return;
227
    }
228
 
229
});
230
$(document).on('click', '#submit_offer_eligible_imeis', function () {
34216 tejus.loha 231
    let eligibleImeis = $('#offer_eligible_imeis').val();
34210 tejus.loha 232
    let offerId = $('#offerId').val();
34216 tejus.loha 233
    console.log("Eligible Imeeis - ", eligibleImeis);
34210 tejus.loha 234
    console.log("offer id - ", offerId);
235
    if (!offerId) {
236
        alert("Please enter Offer Id");
237
        return;
238
    }
34216 tejus.loha 239
    if (!eligibleImeis) {
240
        alert("Please enter Imei");
241
        return;
242
    }
243
 
244
    let url = `${context}/offerEligibleImeis/create?imeis=${eligibleImeis}&offerId=${offerId}`;
245
    if (confirm('Are you sure to submit')) {
34210 tejus.loha 246
        doPostAjaxRequestHandler(url, function (response) {
247
            if (response) {
248
                reloadOfferEligibleImeisList();
249
                alert("submited successfully");
250
            }
251
        });
252
    } else {
253
        return;
254
    }
255
});
256
 
257
 
258
$(document).on('click', '.scheme_imei_block_unblock_button', function () {
259
    let blockedImeiId = $(this).val();
260
    if (confirm("Are you sure to change status")) {
261
        doPutAjaxRequestHandler(`${context}/blockUnblockImei?id=${blockedImeiId}`, function (response) {
262
            reloadBlockImeiList();
263
        });
264
    } else {
265
        return;
266
    }
267
});
268
 
269
$(document).on('click', '.offer_eligible_imeis_EligibilityChange_button', function () {
270
    let blockedImeiId = $(this).val();
271
    if (confirm("Are you sure to change status")) {
34216 tejus.loha 272
        doPutAjaxRequestHandler(`${context}/offerEligibleImeis/changeStatus?id=${blockedImeiId}`, function (response) {
34210 tejus.loha 273
            reloadOfferEligibleImeisList();
274
            alert("Status changed successfully");
275
        });
276
    } else {
277
        return;
278
    }
279
});
280
 
281
$(document).on('click', '.scheme_blocked_imei_remove_button', function () {
282
    let blockedImeiId = $(this).val();
283
    if (confirm("Are you sure to remove")) {
284
        doDeleteAjaxRequestHandler(`${context}/removeBlockedImei?id=${blockedImeiId}`, function (response) {
285
            if (response) {
286
                reloadBlockImeiList();
287
            }
288
        });
289
    } else {
290
        return;
291
    }
292
 
293
 
294
});
295
$(document).on('click', '.offer_eligible_imei_remove_button', function () {
296
    let offerId = $(this).val();
297
    if (confirm("Are you sure to remove")) {
34216 tejus.loha 298
        doDeleteAjaxRequestHandler(`${context}/offerEligibleImeis/deleteByOfferId?offerId=${offerId}`, function (response) {
34210 tejus.loha 299
            if (response) {
300
                reloadOfferEligibleImeisList();
301
                alert("Removed successfully");
302
            }
303
        });
304
    } else {
305
        return;
306
    }
307
});
308
 
309
function reloadBlockImeiPanel() {
310
    doGetAjaxRequestHandler(`${context}/blockImeiPanel`, function (response) {
311
        $('#main-content').html(response);
312
    });
313
    // $('div.modal-backdrop.fade').remove();
314
}
315
function reloadBlockImeiOfferPanel() {
316
    doGetAjaxRequestHandler(`${context}/blockImeiOfferPanel`, function (response) {
317
        $('#main-content').html(response);
318
    });
319
    $('div.modal-backdrop.fade').remove();
320
}
321
 
322
function reloadBlockImeiList() {
323
    doGetAjaxRequestHandler(`${context}/blockImeiList`, function (response) {
324
        $('#scheme_blocked_imeis_div').empty();
325
        $('#scheme_blocked_imeis_div').html(response);
326
    });
327
}
328
 
329
function reloadOfferEligibleImeisList() {
34216 tejus.loha 330
    doGetAjaxRequestHandler(`${context}/offerEligibleImeis/allList`, function (response) {
34210 tejus.loha 331
        $('#offer_eligible_imeis_div').empty();
332
        $('#offer_eligible_imeis_div').html(response);
333
 
334
    });
335
}
336
 
33660 amit.gupta 337
$(document).on('click', 'select.criteria-catalogids+div > button', function () {
338
    if (changed) {
339
        let brands = $(this).closest('.item-criteria').find('select').val();
340
        let led = $(this).closest('.item-criteria').find('input[name=led]').is(":checked");
341
        let tablet = $(this).closest('.item-criteria').find('input[name=tablet]').is(":checked");
342
        let smartWatch = $(this).closest('.item-criteria').find('input[name=smartwatch]').is(":checked");
35497 ranu 343
        let openBoxLapTops = $(this).closest('.item-criteria').find('input[name=openboxlaptops]').is(":checked");
33660 amit.gupta 344
        $brandsContainer = $(this);
345
        let categoryId = 3;
346
        if (led) {
347
            categoryId = 14202;
348
        }
349
        if (tablet) {
350
            categoryId = 10010;
351
        }
352
        if (smartWatch) {
353
            categoryId = 6;
354
        }
35497 ranu 355
 
356
        if (openBoxLapTops) {
35498 ranu 357
            categoryId = 6;
35497 ranu 358
        }
33660 amit.gupta 359
        var url = `${context}/entity?brands=${brands.join(",")}&categoryId=${categoryId}&limit=0`;
360
        $select = $brandsContainer.closest('.item-criteria').find('.criteria-catalogids');
361
        $select.html('');
362
        if (brands.length > 0) {
363
            doGetAjaxRequestHandler(url, function (response) {
364
                data = JSON.parse(response);
365
                for (i = 0; i < data.length; i++) {
366
                    $select.append(`<option value="${data[i].catalogId_i}">${data[i].title_s}</option>`);
367
                }
368
                $select.multiselect('rebuild');
369
            });
370
        } else {
371
            $select.html('');
372
            $select.multiselect('rebuild');
373
        }
374
        changed = !changed;
375
    }
27875 amit.gupta 376
});
377
 
30485 tejbeer 378
var ckEditor;
379
 
27875 amit.gupta 380
function createOfferNew() {
33660 amit.gupta 381
    let validated = true;
382
    let rangePicker = getDatesFromPicker('input[name="dateRange"]');
383
    let createOfferRequest = {};
384
    createOfferRequest['name'] = $("#offer_name").val();
385
    createOfferRequest['startDate'] = rangePicker.startDate;
386
    createOfferRequest['endDate'] = rangePicker.endDate;
387
    createOfferRequest['offerNotes'] = $("#offer_notes").val();
388
    createOfferRequest['baseCriteria'] = $("input[name=base_criteria]").is(":checked");
389
    createOfferRequest['terms'] = ckEditor.getData() //$("#offer_terms").val();
390
    createOfferRequest['targetType'] = $("input[name=targetType]:checked").val();
391
    createOfferRequest['payoutType'] = $("input[name=payoutType]:checked").val();
392
    createOfferRequest['schemeType'] = $("select[name=schemeType]").val();
393
    createOfferRequest['booster'] = false;
394
    createOfferRequest['activationBrands'] = null;
32065 amit.gupta 395
    createOfferRequest['discount'] = $("input[name=discount]").is(':checked');
33660 amit.gupta 396
    if (createOfferRequest['schemeType'] == 'ACTIVATION') {
397
        createOfferRequest['activationBrands'] = $("div.activation-brands select").val().join(",") || null;
398
    } else if (createOfferRequest['schemeType'] == 'SELLINBOOSTER') {
399
        createOfferRequest['schemeType'] = 'SELLIN';
400
        createOfferRequest['booster'] = true;
401
    }
402
    createOfferRequest['sellinPercentage'] = $("#sellinPercentage").val();
403
    createOfferRequest['brandShareTerms'] = $('#brandShare').val();
404
    createOfferRequest['partnerCriteria'] = {};
405
    createOfferRequest['partnerCriteria']['fofoIds'] = ($("#partners").val() || []).map(Number);
406
    createOfferRequest['partnerCriteria']['excludeFofoIds'] = [];
407
    let excludeFofoIdChecked = $('input.excludeFofoId').is(':checked');
408
    if (excludeFofoIdChecked) {
409
        createOfferRequest['partnerCriteria']['excludeFofoIds'] = createOfferRequest['partnerCriteria']['fofoIds'];
410
        createOfferRequest['partnerCriteria']['fofoIds'] = [];
411
    }
412
    createOfferRequest['partnerCriteria']['partnerTypes'] = ($("select.criteria-partner-type").val() || []);
413
    createOfferRequest['partnerCriteria']['regionIds'] = ($("select.criteria-warehouseregion").val() || []).map(Number);
27875 amit.gupta 414
 
33660 amit.gupta 415
    createOfferRequest['itemCriteria'] = itemCriteria($('div.itemCriteria'));
416
    let targetSlabs = [];
417
    $('div.targetslabs').each(function (index, ele) {
418
        let $targetSlab = $(ele);
419
        let targetOnwardsValue = $targetSlab.find('.payoutTarget').val();
420
        let targetDescription = $targetSlab.find('.targetDescription').val();
421
        let itemCriteriaPayouts = [];
422
        if (isNaN(targetOnwardsValue) || targetOnwardsValue < 0) {
423
            validated = false;
424
            alert(`Invalid Number - ${targetOnwardsValue}`);
425
        } else {
426
            if (index == 0 || targetOnwardsValue > 0) {
427
                let $itemCriteriaPayoutContainers = $targetSlab.find('.itemcriteriapayout');
428
                $itemCriteriaPayoutContainers.each(function (index, itemCriteriaPayoutContainer) {
429
                    let $itemCriteriaPayoutContainer = $(itemCriteriaPayoutContainer);
430
                    let amountType = $itemCriteriaPayoutContainer.find('input[name^=amountType]:checked').val();
431
                    let startDate = $itemCriteriaPayoutContainer.find('input.startDate').val();
432
                    let endDate = $itemCriteriaPayoutContainer.find('input.endDate').val();
433
                    if ((startDate == "" && endDate != "") && (startDate != "" && endDate == "")) {
434
                        alert("Criteria specific date is required");
435
                        return false;
436
                    }
437
                    let payoutSlabs = [];
438
                    let itemCriteria1 = itemCriteria($itemCriteriaPayoutContainer);
439
                    let $payoutSlabContainers = $itemCriteriaPayoutContainer.find('.slab');
440
                    let itemCriteriaChanged = itemCriteria1['smartPhone'] || itemCriteria1['featuredPhone']
441
                        || itemCriteria1['catalogIds'].length > 0 || itemCriteria1['brands'].length > 0
442
                        || itemCriteria1['excludeCatalogIds'].length > 0
443
                        || itemCriteria1['startPrice'] > 0 || itemCriteria1['endPrice'] > itemCriteria1['startPrice'] > 0;
444
                    if (itemCriteriaChanged || index == 0) {
445
                        $payoutSlabContainers.each(function (slabContainerIndex, slabContainer) {
446
                            let $slab = $(slabContainer);
30485 tejbeer 447
 
33660 amit.gupta 448
                            let slabOnwardsAmount = $slab.find('.slabOnwardsAmount').val();
449
                            if (isNaN(slabOnwardsAmount) || slabOnwardsAmount < 0) {
450
                                validated = false;
451
                                alert(`Invalid Payout Slab Amount - ${slabOnwardsAmount}`);
452
                            } else {
453
                                if (slabContainerIndex == 0 || slabOnwardsAmount > 0) {
454
                                    let payoutAmount = $slab.find('.payoutValue').val();
455
                                    if (isNaN(payoutAmount) || payoutAmount <= 0) {
456
                                        validated = false;
457
                                        alert(`Invalid Payout Slab Amount - ${slabOnwardsAmount}`);
458
                                    }
459
                                    let payoutSlab = {
460
                                        onwardsAmount: Number(slabOnwardsAmount),
461
                                        payoutAmount: Number(payoutAmount)
462
                                    }
463
                                    payoutSlabs.push(payoutSlab);
464
                                }
465
                            }
466
                        });
467
                        let itemCriteriaPayout = {
468
                            itemCriteria: itemCriteria1,
469
                            payoutSlabs: payoutSlabs,
470
                            amountType: amountType,
471
                            startDate: jsonStartDate(startDate),
472
                            endDate: jsonEndDate(endDate)
473
                        };
474
                        itemCriteriaPayouts.push(itemCriteriaPayout);
475
                    }
476
                });
477
                targetSlabs.push({
478
                    onwardsAmount: targetOnwardsValue,
479
                    targetDescription: targetDescription,
480
                    itemCriteriaPayouts: itemCriteriaPayouts
481
                });
482
            }
483
        }
484
    });
485
    createOfferRequest['targetSlabs'] = targetSlabs;
486
    if (validated && confirm("Confirm creating scheme offer")) {
487
        console.log("Validated");
488
        console.log(createOfferRequest);
489
        doPostAjaxRequestWithJsonHandler(`${context}/createOffer`, JSON.stringify(createOfferRequest), function (response) {
490
            alert("Offer created successfully");
491
            let dt = new Date();
492
            loadOfferHistory('#main-content', new Date().toISOString().slice(0, 7));
493
        });
494
    } else {
495
        console.log("Invalid Offer");
496
    }
27875 amit.gupta 497
}
498
 
499
function itemCriteria($container) {
33660 amit.gupta 500
    let smartPhone = $container.find("input[name=smartphone]").is(":checked");
501
    let featuredPhone = $container.find("input[name=featuredphone]").is(":checked");
502
    let led = $container.find("input[name=led]").is(":checked");
503
    let smartWatch = $container.find("input[name=smartwatch]").is(":checked");
504
    let catalogIds = $container.find('.criteria-catalogids').val() || [];
505
    let excludeCatalogIds = [];
506
    let excludeChecked = $container.find('input.exclude').is(':checked');
507
    if (excludeChecked) {
508
        excludeCatalogIds = catalogIds;
509
        catalogIds = [];
510
    }
511
    let brands = $container.find('.criteria-brands').val() || [];
512
    return {
513
        startPrice: Number($container.find('.startValue').val()),
514
        endPrice: Number($container.find('.endValue').val()),
515
        catalogIds: catalogIds.map(Number),
516
        excludeCatalogIds: excludeCatalogIds.map(Number),
517
        brands: brands,
518
        smartPhone: smartPhone,
519
        featuredPhone: featuredPhone,
520
        smartWatch: smartWatch,
521
        led: led
522
    };
27875 amit.gupta 523
}
524
 
525
function loadOffer(domId) {
33660 amit.gupta 526
    console.log(domId);
527
    doGetAjaxRequestHandler(context + "/getCreateOffer", function (response) {
528
        $('#' + domId).html(response);
30485 tejbeer 529
 
33660 amit.gupta 530
        DecoupledEditor
531
            .create(document.querySelector('#offer_terms'))
30485 tejbeer 532
 
533
 
33660 amit.gupta 534
            .then(newEditor => {
535
                const toolbarContainer = document.querySelector('#toolbar-container');
30485 tejbeer 536
 
33660 amit.gupta 537
                toolbarContainer.appendChild(newEditor.ui.view.toolbar.element);
30485 tejbeer 538
 
33660 amit.gupta 539
                ckEditor = newEditor
540
            })
541
            .catch(error => {
542
                console.error(error);
543
            });
30485 tejbeer 544
 
33660 amit.gupta 545
    });
546
}
30485 tejbeer 547
 
27875 amit.gupta 548
function loadOfferHistory(domId, yearMonth) {
33660 amit.gupta 549
    doGetAjaxRequestHandler(`${context}/offerHistory?yearMonth=${yearMonth}`, function (response) {
550
        $(domId).html(response);
551
        $(domId).find("#yearmonth").val(yearMonth);
552
    });
27875 amit.gupta 553
}
554