Subversion Repositories SmartDukaan

Rev

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

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