Subversion Repositories SmartDukaan

Rev

Rev 30599 | Rev 30605 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30599 Rev 30603
Line 1... Line 1...
1
$(document).on('click', ".web-offers", function () {
1
$(document).on('click', ".web-offers", function() {
2
	doAjaxRequestHandler(context + "/web-offers", "GET", function (response) {
2
	doAjaxRequestHandler(context + "/web-offers", "GET", function(response) {
3
		$('#main-content').html(response);
3
		$('#main-content').html(response);
4
	});
4
	});
5
});
5
});
6
$(document).on('click', "a.web-offer-details", function () {
6
$(document).on('click', "a.web-offer-details", function() {
7
	var webOfferId = $(this).data("id");
7
	var webOfferId = $(this).data("id");
8
	doAjaxRequestHandler(`${context}/web-offer/${webOfferId}`, "GET", function (response) {
8
	doAjaxRequestHandler(`${context}/web-offer/${webOfferId}`, "GET", function(response) {
9
		$('.web-offer-products-container').html(response);
9
		$('.web-offer-products-container').html(response);
10
	});
10
	});
11
 
11
 
12
})
12
})
13
 
13
 
14
 
14
 
15
$(document).on('click', ".web-offer-id", function () {
15
$(document).on('click', ".web-offer-id", function() {
16
	var webOfferId = $(this).data("id");
16
	var webOfferId = $(this).data("id");
17
	doAjaxRequestHandler(`${context}/getwebOffer/${webOfferId}`, "GET", function (response) {
17
	doAjaxRequestHandler(`${context}/getwebOffer/${webOfferId}`, "GET", function(response) {
18
		$('.web-offer-edit-container .modal-content').html(response);
18
		$('.web-offer-edit-container .modal-content').html(response);
19
	});
19
	});
20
});
20
});
21
 
21
 
22
 
22
 
23
$(document).on('click', ".updateWebOfferDuration", function () {
23
$(document).on('click', ".updateWebOfferDuration", function() {
24
	var webOfferId = $(this).data("id");
24
	var webOfferId = $(this).data("id");
25
 
25
 
26
	if (confirm("Are you sure you want to update offer!") == true) {
26
	if (confirm("Are you sure you want to update offer!") == true) {
27
		doPostAjaxRequestHandler(context
27
		doPostAjaxRequestHandler(context
28
			+ "/web-offer-duration/update?id="
28
			+ "/web-offer-duration/update?id="
29
			+ webOfferId + "&startDate=" + startDate + "&endDate=" + endDate, function (response) {
29
			+ webOfferId + "&startDate=" + startDate + "&endDate=" + endDate, function(response) {
30
			if (response == 'true') {
30
				if (response == 'true') {
31
				alert("update successfully ");
31
					alert("update successfully ");
32
 
32
 
33
				$('#main-content').html(response);
33
					$('#main-content').html(response);
34
			}
34
				}
35
		});
35
			});
36
 
36
 
37
		return false;
37
		return false;
38
	}
38
	}
39
 
39
 
40
});
40
});
41
 
41
 
42
 
42
 
43
$(document).on('click', "#add-to-offer", function () {
43
$(document).on('click', "#add-to-offer", function() {
44
	var webOfferId = $(this).data("id");
44
	var webOfferId = $(this).data("id");
45
	var entityIds = [entityId];
45
	var entityIds = [entityId];
46
 
46
 
47
	var entityIdTxt = $("#entityData").val();
47
	var entityIdTxt = $("#entityData").val();
48
	if (entityIdTxt.length > 0) {
48
	if (entityIdTxt.length > 0) {
Line 53... Line 53...
53
		alert("Please enter items");
53
		alert("Please enter items");
54
		return;
54
		return;
55
	}
55
	}
56
	json = [];
56
	json = [];
57
	for (var e of entityIds) {
57
	for (var e of entityIds) {
58
		json.push({webOfferId: webOfferId, entityId: e});
58
		json.push({ webOfferId: webOfferId, entityId: e });
59
	}
59
	}
60
	console.log(json);
60
	console.log(json);
61
	console.log(JSON.stringify(json))
61
	console.log(JSON.stringify(json))
62
	doPostAjaxRequestWithJsonHandler(`${context}/web-offer-product/add`, JSON.stringify(json), function (response) {
62
	doPostAjaxRequestWithJsonHandler(`${context}/web-offer-product/add`, JSON.stringify(json), function(response) {
63
		$('.web-offer-products-container').html(response);
63
		$('.web-offer-products-container').html(response);
64
	});
64
	});
65
 
65
 
66
});
66
});
67
 
67
 
68
$(document).on('click', "a.product-remove", function () {
68
$(document).on('click', "a.product-remove", function() {
69
	var webOfferProductId = $(this).closest('tr').data("id");
69
	var webOfferProductId = $(this).closest('tr').data("id");
70
	if (confirm("Are you sure you want to remove the Item!") == true) {
70
	if (confirm("Are you sure you want to remove the Item!") == true) {
71
 
71
 
72
		doDeleteAjaxRequestHandler(`${context}/web-offer-product/remove?webOfferProductId=${webOfferProductId}`, function (response) {
72
		doDeleteAjaxRequestHandler(`${context}/web-offer-product/remove?webOfferProductId=${webOfferProductId}`, function(response) {
73
			alert("Product removed successfully");
73
			alert("Product removed successfully");
74
			$('.web-products-container').html(response);
74
			$('.web-offer-products-container').html(response);
75
		});
75
		});
76
	}
76
	}
77
 
77
 
78
})
78
})
79
 
79
 
Line 96... Line 96...
96
		smallBannerUrl: smallBannerUrl,
96
		smallBannerUrl: smallBannerUrl,
97
		startDate: getDatesFromPicker($('input[name="offerdateRange"]')).startDate,
97
		startDate: getDatesFromPicker($('input[name="offerdateRange"]')).startDate,
98
		endDate: getDatesFromPicker($('input[name="offerdateRange"]')).endDate
98
		endDate: getDatesFromPicker($('input[name="offerdateRange"]')).endDate
99
	}
99
	}
100
	if (confirm("Are you sure you want to add the offer!") == true) {
100
	if (confirm("Are you sure you want to add the offer!") == true) {
101
		doPostAjaxRequestWithJsonHandler(context + "/web-offer/add", JSON.stringify(json), function (response) {
101
		doPostAjaxRequestWithJsonHandler(context + "/web-offer/add", JSON.stringify(json), function(response) {
102
			$('#main-content').html(response);
102
			$('#main-content').html(response);
103
		});
103
		});
104
	}
104
	}
105
}
105
}
106
 
106
 
107
 
107
 
108
$(document).on('mousedown', ".grab", function (e) {
108
$(document).on('mousedown', ".grab", function(e) {
109
	var tr = $(e.target).closest("TR"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
109
	var tr = $(e.target).closest("TR"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
110
	b.addClass("grabCursor").css("userSelect", "none");
110
	b.addClass("grabCursor").css("userSelect", "none");
111
	tr.addClass("grabbed");
111
	tr.addClass("grabbed");
112
 
112
 
113
	function move(e) {
113
	function move(e) {
114
		console.log(Math.abs(e.pageY - sy));
114
		console.log(Math.abs(e.pageY - sy));
115
		if (!drag && Math.abs(e.pageY - sy) < 10) return;
115
		if (!drag && Math.abs(e.pageY - sy) < 10) return;
116
		drag = true;
116
		drag = true;
117
		tr.siblings().each(function () {
117
		tr.siblings().each(function() {
118
			var s = $(this), i = s.index(), y = s.offset().top;
118
			var s = $(this), i = s.index(), y = s.offset().top;
119
			if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
119
			if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
120
				if (e.pageY <= y + (s.outerHeight() / 2))
120
				if (e.pageY <= y + (s.outerHeight() / 2))
121
					tr.insertBefore(s);
121
					tr.insertBefore(s);
122
				else
122
				else
Line 137... Line 137...
137
	}
137
	}
138
 
138
 
139
	$(document).mousemove(move).mouseup(up);
139
	$(document).mousemove(move).mouseup(up);
140
});
140
});
141
 
141
 
142
$(document).on('click', ".update-rank", function () {
142
$(document).on('click', ".update-rank", function() {
143
	if (confirm("Are you sure you want to update ranks?")) {
143
	if (confirm("Are you sure you want to update ranks?")) {
144
		var webListingId = $(this).data("id");
144
		var webListingId = $(this).data("id");
145
		var webProductIds = [];
145
		var webProductIds = [];
146
		$("#web-product-listing-tbody").find("tr").each(function () {
146
		$("#web-product-listing-tbody").find("tr").each(function() {
147
			console.log(this);
147
			console.log(this);
148
			webProductIds.push($(this).data("id"));
148
			webProductIds.push($(this).data("id"));
149
		});
149
		});
150
		doPostAjaxRequestWithJsonHandler(`${context}/web-offer/order/${webListingId}`, JSON.stringify(webProductIds), function (response) {
150
		doPostAjaxRequestWithJsonHandler(`${context}/web-offer/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {
151
			$('.web-offer-products-container').html(response);
151
			$('.web-offer-products-container').html(response);
152
		});
152
		});
153
	}
153
	}
154
});
154
});
155
 
155