Subversion Repositories SmartDukaan

Rev

Rev 24986 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
24159 tejbeer 1
$(function() {
2
	$(".promoter-info").live('click', function() {
3
		loadPromotor("main-content");
4
	});
5
 
6
 
7
 
8
	$("#promoter-info-paginated .next").live(
9
			'click',
10
			function() {
11
				loadPaginatedNextItems('/getPaginatedPromoterInfo', null,
12
						'promoter-info-paginated', 'promoter-Info-table',
13
						'promoter-container');
14
 
15
				$(this).blur();
16
			});
17
 
18
	$("#promoter-info-paginated .previous").live(
19
			'click',
20
			function() {
21
 
22
				loadPaginatedPreviousItems('/getPaginatedPromoterInfo', null,
23
						'promoter-info-paginated', 'promoter-Info-table',
24
						'promoter-container');
25
 
26
				$(this).blur();
27
			});
28
 
29
	var id = 0;
30
	$(".create-promoter").live(
31
			'click',
32
			function() {
33
				var name = $('#promoterName').val();
34
				var brand = $('#tag-listing-brands').val();
35
				var email=$('#promoterEmail').val();
36
				var mobile=$('#promoterMobile').val();
37
				var retailerId = currentFofoId;
38
 
39
				console.log(id);
40
 
41
				if (name === "" && brand === "" && email===""&&mobile ==="") {
42
					alert("Field can't be empty");
43
					return;
44
				}
45
 
46
				if (name === "") {
47
					alert("Promoter Name is required");
48
					return;
49
				}
50
				if (brand === "") {
51
					alert("Brand is required");
52
					return;
53
				}
54
				if (email === "") {
55
					alert("email is required");
56
					return;
57
				}
58
				if (mobile === "") {
59
					alert("mobile Number is required");
60
					return;
61
				}
62
				var promoterdetailData = {}
63
				promoterdetailData['id'] = id;
64
				promoterdetailData['name'] = $('#promoterName').val();
65
				promoterdetailData['brand'] = $('#tag-listing-brands').val();
66
				promoterdetailData['email'] = $('#promoterEmail').val();
67
				promoterdetailData['mobile'] = $('#promoterMobile').val();
68
				promoterdetailData['retailerId'] = currentFofoId;
69
 
70
				console.log(promoterdetailData);
71
				if (confirm("Are you sure you want to add Promoter!") == true) {
72
					doPostAjaxRequestWithJsonHandler(context
73
							+ "/createPromoter", JSON
74
							.stringify(promoterdetailData), function(response) {
75
						if (response == 'true') {
76
							alert("successfully Add");
77
							loadPromotor("main-content");
78
							id = 0;
79
 
80
						}
81
					});
82
 
83
					return false;
84
				}
85
			});
86
 
87
	$(".updatePromoterdetail").live('click', function() {
88
		id = $(this).data('requestid');
89
		name = $(this).data('name');
90
		brand = $(this).data('brand');
91
		partner = $(this).data('partner');
92
		email =$(this).data('email')
93
		mobile=$(this).data('mobile')
94
		console.log(name);
95
		console.log(brand);
96
		console.log(partner);
97
		$('#promoterName').val(name);
98
		$('#tag-listing-brands').val(brand);
99
		$('#promoterEmail').val(email);
100
		$('#promoterMobile').val(mobile);
101
		$('#promoterName').attr('readonly', true);
102
		$('#promoterMobile').attr('readonly', true);
103
		$('#promoterEmail').attr('readonly', true);
104
		$('#promoterMobile').attr('readonly', true);
105
		$('#tag-listing-brands').attr('disabled', true);
106
 
107
	});
108
	$(".removePromoter")
109
			.live(
110
					'click',
111
					function() {
112
						id = $(this).data('requestid');
113
						if (confirm("Are you sure you want to remove Promoter Partner Store!") == true) {
114
							doPostAjaxRequestHandler(context
115
									+ "/removePromoterfromPartnerStore?id="
116
									+ id, function(response) {
117
								if (response == 'true') {
118
									alert("successfully remove");
119
									loadPromotor("main-content");
120
									id =0;
121
 
122
								}
123
							});
124
 
125
							return false;
126
						}
127
 
128
					});
129
});
130
 
131
function loadPromotor(domId) {
132
	doGetAjaxRequestHandler(context + "/getPromoterInfo", function(response) {
133
		$('#' + domId).html(response);
134
	});
135
}