Subversion Repositories SmartDukaan

Rev

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

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