Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
30599 amit.gupta 1
$(function () {
2
	$(document).on('click', ".customer-offer", function () {
29707 tejbeer 3
		loadCustomerOffer("main-content");
4
	});
5
 
6
 
30599 amit.gupta 7
	$(document).on('click', ".samsung-upgrade-offer", function () {
29707 tejbeer 8
		loadSamsungUpgradeOffer("main-content");
9
	});
10
 
30599 amit.gupta 11
	$(document).on('click', ".createoffer", function () {
29707 tejbeer 12
 
13
 
14
		var offerName = $("#offername").val();
15
 
16
		if (offerName === "") {
17
			alert("Offer Name is required");
18
			return;
19
		}
20
 
21
		var params = {
22
			"offerName": offerName,
30599 amit.gupta 23
			"startDate": getDatesFromPicker('input[name="dateRange"]').startDate,
24
			"endDate": getDatesFromPicker('input[name="dateRange"]').endDate,
29707 tejbeer 25
 
26
		}
27
		if (confirm("Are you sure you want to create offer!") == true) {
28
			doPostAjaxRequestWithParamsHandler(context
30599 amit.gupta 29
				+ "/createCustomerOffer", params, function (response) {
30
				if (response = true) {
29707 tejbeer 31
 
32
 
30599 amit.gupta 33
					alert("create  successfully");
34
					loadCustomerOffer("main-content");
35
				}
36
			});
29707 tejbeer 37
		}
38
 
39
 
40
	});
41
 
30599 amit.gupta 42
	$(document).on('click', "#downloadCustomerOfferTemplate", function () {
29707 tejbeer 43
 
44
		window.location.href = context + "/customerOffer/downloadTemplate";
45
	});
46
 
47
 
30599 amit.gupta 48
	$(document).on('click', ".downloadOffer", function () {
29707 tejbeer 49
		var id = $(this).data('requestid');
50
 
51
		window.location.href = context + "/customerOfferItem/download?offerId=" + id;
52
	});
53
 
54
 
30599 amit.gupta 55
	$(document).on('click', ".extendeDate-button", function () {
56
		let id = $(this).data('requestid');
57
		let row = $(this).closest("tr");
58
		let params = {
29707 tejbeer 59
			"id": id,
30599 amit.gupta 60
			"endDate": getDatesFromPicker('input[name="extendEndDate"]').endDate
29707 tejbeer 61
		}
62
		if (confirm("Are you sure you want extend the offer") == true) {
63
			doPostAjaxRequestWithParamsHandler(context
30599 amit.gupta 64
				+ "/extendCustomerOffer", params, function (response) {
65
				row.html(response);
66
			});
29707 tejbeer 67
		}
68
 
69
	});
70
 
71
 
30599 amit.gupta 72
	$(document).on('input', 'table#offer-customer-table input[type=file]', function () {
29851 tejbeer 73
		var row = $(this).closest("tr");
74
		var id = $(row).find("td:eq(0)").text();
75
		if (confirm('Confirm upload ?')) {
76
			var fileSelector = $(this)[0];
77
			if (fileSelector != undefined
78
				&& fileSelector.files[0] != undefined) {
79
				var url = `${context}/customerOfferItem/upload?offerId=` + id;
80
				console.log(url);
81
				var file = this.files[0];
82
				console.log("file" + file);
83
				let fileInput = $(this);
84
				console.log("fileInput" + file);
30599 amit.gupta 85
				doAjaxUploadRequestHandler(url, 'POST', file, function (response) {
86
					console.log(response)
87
					alert("successfully uploaded");
88
				});
29849 tejbeer 89
			}
29851 tejbeer 90
		}
91
	});
29707 tejbeer 92
 
93
 
30599 amit.gupta 94
	$(document).on('click', ".upgrade-approved", function () {
29851 tejbeer 95
		var id = $(this).data('requestid');
96
		var row = $(this).closest("tr");
29707 tejbeer 97
 
29851 tejbeer 98
		if (confirm("Are you sure you want Approve r!") == true) {
30599 amit.gupta 99
			doPostAjaxRequestHandler(`${context}/approveSamsungUpgradeOffer?id=${id}`, function (response) {
100
				alert("Successfully Approved");
101
				row.html(response);
102
				return false;
103
			});
29851 tejbeer 104
		}
29707 tejbeer 105
 
106
	});
107
 
30599 amit.gupta 108
	$(document).on('click', ".upgrade-rejected", function () {
109
		let id = $(this).data('requestid');
29851 tejbeer 110
		if (confirm("Are you sure you want Reject!") == true) {
30599 amit.gupta 111
			doPostAjaxRequestHandler(`${context}/rejectSamsungUpgradeOffer?id=${id}`, function (response) {
112
				if (response == 'true') {
113
					alert("Successfully Rejected");
114
					loadWalletRequest("main-content");
115
				}
116
				return false;
117
			});
29851 tejbeer 118
		}
119
	});
120
 
121
 
122
});
123
 
124
function loadCustomerOffer(domId) {
125
 
30599 amit.gupta 126
	doGetAjaxRequestHandler(`${context}/getCustomerOffer`, function (response) {
29851 tejbeer 127
		$('#' + domId).html(response);
128
	});
129
}
130
 
131
function loadSamsungUpgradeOffer(domId) {
30599 amit.gupta 132
	doGetAjaxRequestHandler(context + "/getSamsungUpgradeOffer", function (response) {
29851 tejbeer 133
		$('#' + domId).html(response);
134
	});
135
}