| 28371 |
amit.gupta |
1 |
$(document).on('click', ".web-offers", function() {
|
|
|
2 |
doAjaxRequestHandler(context + "/web-offers", "GET", function(response) {
|
|
|
3 |
$('#main-content').html(response);
|
|
|
4 |
});
|
|
|
5 |
});
|
|
|
6 |
$(document).on('click', "a.web-offer-details", function() {
|
|
|
7 |
var webOfferId = $(this).data("id");
|
|
|
8 |
doAjaxRequestHandler(`${context}/web-offer/${webOfferId}`, "GET", function(response) {
|
|
|
9 |
$('.web-offer-products-container').html(response);
|
|
|
10 |
});
|
| 30596 |
tejbeer |
11 |
|
| 28371 |
amit.gupta |
12 |
})
|
|
|
13 |
|
| 30596 |
tejbeer |
14 |
|
|
|
15 |
$(document).on('click', ".web-offer-id", function() {
|
|
|
16 |
var webOfferId = $(this).data("id");
|
|
|
17 |
doAjaxRequestHandler(`${context}/getwebOffer/${webOfferId}`, "GET", function(response) {
|
|
|
18 |
$('.web-offer-edit-container .modal-content').html(response);
|
|
|
19 |
});
|
|
|
20 |
});
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
$(document).on('click', ".updateWebOfferDuration", function() {
|
|
|
25 |
var webOfferId = $(this).data("id");
|
|
|
26 |
|
|
|
27 |
if (confirm("Are you sure you want to update offer!") == true) {
|
|
|
28 |
doPostAjaxRequestHandler(context
|
|
|
29 |
+ "/web-offer-duration/update?id="
|
|
|
30 |
+ webOfferId + "&startDate=" + startDate + "&endDate=" + endDate, function(response) {
|
|
|
31 |
if (response == 'true') {
|
|
|
32 |
alert("update successfully ");
|
|
|
33 |
|
|
|
34 |
$('#main-content').html(response);
|
|
|
35 |
}
|
|
|
36 |
});
|
|
|
37 |
|
|
|
38 |
return false;
|
| 28371 |
amit.gupta |
39 |
}
|
| 30596 |
tejbeer |
40 |
|
| 28371 |
amit.gupta |
41 |
});
|
| 30596 |
tejbeer |
42 |
|
|
|
43 |
|
| 28371 |
amit.gupta |
44 |
$(document).on('click', "#add-to-offer", function() {
|
| 30596 |
tejbeer |
45 |
var webOfferId = $(this).data("id");
|
| 28371 |
amit.gupta |
46 |
var entityIds = [entityId];
|
|
|
47 |
|
| 30596 |
tejbeer |
48 |
var entityIdTxt = $("#entityData").val();
|
|
|
49 |
if (entityIdTxt.length > 0) {
|
|
|
50 |
if (entityIdTxt.indexOf(",") > 0) {
|
| 28371 |
amit.gupta |
51 |
entityIds = entityIdTxt.split(",");
|
|
|
52 |
}
|
|
|
53 |
} else {
|
|
|
54 |
alert("Please enter items");
|
|
|
55 |
return;
|
|
|
56 |
}
|
|
|
57 |
json = [];
|
| 30596 |
tejbeer |
58 |
for (var e of entityIds) {
|
|
|
59 |
json.push({ webOfferId: webOfferId, entityId: e });
|
| 28371 |
amit.gupta |
60 |
}
|
|
|
61 |
console.log(json);
|
|
|
62 |
console.log(JSON.stringify(json))
|
|
|
63 |
doPostAjaxRequestWithJsonHandler(`${context}/web-offer-product/add`, JSON.stringify(json), function(response) {
|
|
|
64 |
$('.web-offer-products-container').html(response);
|
|
|
65 |
});
|
| 30596 |
tejbeer |
66 |
|
| 28371 |
amit.gupta |
67 |
});
|
|
|
68 |
|
|
|
69 |
$(document).on('click', "a.product-remove", function() {
|
|
|
70 |
var webOfferProductId = $(this).closest('tr').data("id");
|
|
|
71 |
if (confirm("Are you sure you want to remove the Item!") == true) {
|
|
|
72 |
|
|
|
73 |
doDeleteAjaxRequestHandler(`${context}/web-offer-product/remove?webOfferProductId=${webOfferProductId}`, function(response) {
|
| 30596 |
tejbeer |
74 |
alert("Product removed successfully");
|
|
|
75 |
$('.web-products-container').html(response);
|
|
|
76 |
});
|
| 28371 |
amit.gupta |
77 |
}
|
|
|
78 |
|
|
|
79 |
})
|
|
|
80 |
|
|
|
81 |
function addWebOffer() {
|
|
|
82 |
webOfferTitle = $("#web-offer-title").val();
|
|
|
83 |
smallText = $("#small-text").val();
|
|
|
84 |
largeText = $("#large-text").val();
|
|
|
85 |
smallBannerUrl = $("#offer-banner-small").val();
|
| 30596 |
tejbeer |
86 |
|
|
|
87 |
if (webOfferTitle === "") {
|
|
|
88 |
alert("Title is required");
|
|
|
89 |
return false;
|
|
|
90 |
}
|
|
|
91 |
|
| 28371 |
amit.gupta |
92 |
var json = {
|
| 30596 |
tejbeer |
93 |
id: 0,
|
|
|
94 |
title: webOfferTitle,
|
|
|
95 |
smallText: smallText,
|
|
|
96 |
largeText: largeText,
|
|
|
97 |
smallBannerUrl: smallBannerUrl,
|
|
|
98 |
startDate: startDate,
|
|
|
99 |
endDate: endDate
|
| 28371 |
amit.gupta |
100 |
}
|
| 30596 |
tejbeer |
101 |
if (confirm("Are you sure you want to add the offer!") == true) {
|
|
|
102 |
doPostAjaxRequestWithJsonHandler(context + "/web-offer/add", JSON.stringify(json), function(response) {
|
|
|
103 |
$('#main-content').html(response);
|
|
|
104 |
});
|
|
|
105 |
}
|
| 28371 |
amit.gupta |
106 |
}
|
|
|
107 |
|
|
|
108 |
|
| 30596 |
tejbeer |
109 |
$(document).on('mousedown', ".grab", function(e) {
|
|
|
110 |
var tr = $(e.target).closest("TR"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
|
|
|
111 |
b.addClass("grabCursor").css("userSelect", "none");
|
|
|
112 |
tr.addClass("grabbed");
|
|
|
113 |
function move(e) {
|
|
|
114 |
console.log(Math.abs(e.pageY - sy));
|
|
|
115 |
if (!drag && Math.abs(e.pageY - sy) < 10) return;
|
|
|
116 |
drag = true;
|
|
|
117 |
tr.siblings().each(function() {
|
|
|
118 |
var s = $(this), i = s.index(), y = s.offset().top;
|
|
|
119 |
if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
|
|
|
120 |
if (e.pageY <= y + (s.outerHeight() / 2))
|
|
|
121 |
tr.insertBefore(s);
|
|
|
122 |
else
|
|
|
123 |
tr.insertAfter(s);
|
|
|
124 |
return false;
|
|
|
125 |
}
|
|
|
126 |
});
|
|
|
127 |
}
|
|
|
128 |
function up(e) {
|
|
|
129 |
if (drag && si != tr.index()) {
|
|
|
130 |
drag = false;
|
|
|
131 |
$(".update-rank").prop('disabled', false);
|
|
|
132 |
}
|
|
|
133 |
$(document).unbind("mousemove", move).unbind("mouseup", up);
|
|
|
134 |
b.removeClass("grabCursor").css("userSelect", "none");
|
|
|
135 |
tr.removeClass("grabbed");
|
|
|
136 |
}
|
|
|
137 |
$(document).mousemove(move).mouseup(up);
|
| 28371 |
amit.gupta |
138 |
});
|
|
|
139 |
|
|
|
140 |
$(document).on('click', ".update-rank", function() {
|
|
|
141 |
if (confirm("Are you sure you want to update ranks?")) {
|
|
|
142 |
var webListingId = $(this).data("id");
|
|
|
143 |
var webProductIds = [];
|
|
|
144 |
$("#web-product-listing-tbody").find("tr").each(function() {
|
|
|
145 |
console.log(this);
|
|
|
146 |
webProductIds.push($(this).data("id"));
|
|
|
147 |
});
|
| 30596 |
tejbeer |
148 |
doPostAjaxRequestWithJsonHandler(`${context}/web-offer/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {
|
| 28371 |
amit.gupta |
149 |
$('.web-offer-products-container').html(response);
|
|
|
150 |
});
|
|
|
151 |
}
|
|
|
152 |
});
|
|
|
153 |
|
|
|
154 |
|