Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
23343 ashik.ali 1
$(function() {
2
	$(".create-scheme").live('click', function() {
3
		loadScheme("main-content");
4
	});
5
 
23419 ashik.ali 6
	$('#tag-listing-brands li a').live('click', function(){
7
		$('#tag-listing-brand-value').text($(this).text());
8
		loadTagListingItemsDescriptionByBrand("tag-listing-items-description-container", $(this).text());
9
	    console.log($(this).text());
10
	});
11
 
23343 ashik.ali 12
	$("#schemes-paginated .next").live('click', function() {
13
		var start = $( "#schemes-paginated .start" ).text();
14
		var end = $( "#schemes-paginated .end" ).text();
15
		getSchemesNextItems(start, end);
16
		$("#schemes-paginated .next").blur();
17
    });
18
 
19
	$("#schemes-paginated .previous").live('click', function() {
20
		var start = $( "#schemes-paginated .start" ).text();
21
		var end =  $( "#schemes-paginated .end" ).text();
23419 ashik.ali 22
		var size = $("#schemes-paginated .size").text();
23
		if(parseInt(end) == parseInt(size)){
24
			var mod = parseInt(end) % 10;
25
			end = parseInt(end) + (10 - mod); 
26
		}
23343 ashik.ali 27
		var pre = end - 20;
28
		getSchemesPreviousItems(start, end, pre);
29
		$("#schemes-paginated .previous").blur();
30
    });
31
 
32
	$(".scheme-details").live('click',function(){
33
		var schemeId = $(this).attr('data');
34
		console.log("schemeId = "+schemeId);
35
		loadSchemeDetails(schemeId, "scheme-details-container");
36
	});
37
 
38
	$(".active-scheme").live('click',function(){
39
		var schemeId = $(this).attr('data');
40
		console.log("active-scheme id : "+schemeId);
41
		var start = $( "#schemes-paginated .start" ).text();
42
		//var end = $( "#schemes-paginated .end" ).text();
43
		var offset = start - 1;
44
		if(confirm("Are you sure you want to Active Scheme!") == true){
45
			activeScheme(schemeId, offset, "schemes-table");
46
		}
47
	});
48
 
49
	$(".expire-scheme").live('click',function(){
50
		var schemeId = $(this).attr('data');
51
		console.log("expire-scheme id : "+schemeId);
52
		var start = $( "#schemes-paginated .start" ).text();
53
		//var end = $( "#schemes-paginated .end" ).text();
54
		var offset = start - 1;
55
		if(confirm("Are you sure you want to Expire Scheme!") == true){
56
			expireScheme(schemeId, offset, "schemes-table");
57
		}
58
	});
59
 
23347 ashik.ali 60
	$(".schemes").live('click', function() {
61
		console.log("Active Schemes Button Clicked...")
62
		schemes("main-content");
63
	});
23343 ashik.ali 64
 
23347 ashik.ali 65
	$(".schemes-download-page").live('click', function() {
66
		console.log("Schemes Download Clicked...")
67
		loadSchemesDownloadPage("main-content");
22860 ashik.ali 68
	});
23556 amit.gupta 69
 
70
	$(".schemes-update").live('click', function() {
71
		loadSchemeUpdatePage("main-content");
72
	});
22860 ashik.ali 73
});
74
 
23419 ashik.ali 75
function configureTagListingItemsDescriptionDropDown(){
23347 ashik.ali 76
	$(document).ready(function() {
23419 ashik.ali 77
        $('#tagListingItemsDescription').multiselect({
78
	        	includeSelectAllOption: true,
79
	        	maxHeight: 200,
80
	        	buttonWidth: '180px',
81
	        	numberDisplayed: 1,
82
	        	nonSelectedText: 'Items',
83
	        	nSelectedText: ' - Items Selected',
84
	        	allSelectedText: 'All Items Selected',
85
	        	enableFiltering: true
23347 ashik.ali 86
        });
87
    });
23343 ashik.ali 88
}
89
 
90
function schemesDownload(){
91
	console.log("downloadItemLedgerReport Button clicked")
23347 ashik.ali 92
	var startDateTime = $('input[name="startDateTime"]').val();
23343 ashik.ali 93
	console.log("startDateTime : "+startDateTime);
23347 ashik.ali 94
	var endDateTime = $('input[name="endDateTime"]').val();
23343 ashik.ali 95
	console.log("endDateTime : "+endDateTime);
96
	doAjaxGetDownload(context+"/schemes/download?startDateTime="+startDateTime+"&endDateTime="+endDateTime,
23347 ashik.ali 97
			"SchemesReport.xlsx");
23343 ashik.ali 98
}
99
 
100
function getSchemesNextItems(start, end){
101
	console.log(start);
102
	console.log(end);
103
	console.log(+end + +10);
104
	console.log(+start + +10);
23500 ashik.ali 105
	doGetAjaxRequestHandler(context+"/getPaginatedSchemes?offset="+end, function(response){
23419 ashik.ali 106
		var size = $("#schemes-paginated .size").text();
107
		if((parseInt(end) + 10) > parseInt(size)){
108
			console.log("(end + 10) > size == true");
109
			$( "#schemes-paginated .end" ).text(size);
110
		}else{
111
			console.log("(end + 10) > size == false");
112
			$( "#schemes-paginated .end" ).text(+end + +10);
113
		}
23343 ashik.ali 114
		$( "#schemes-paginated .start" ).text(+start + +10);
115
		var last = $( "#schemes-paginated .end" ).text();
116
		var temp = $( "#schemes-paginated .size" ).text();
117
		if (parseInt(last) >= parseInt(temp)){
118
			$("#schemes-paginated .next").prop('disabled', true);
119
			//$( "#good-inventory-paginated .end" ).text(temp);
120
		}
121
	    $('#schemes-table').html(response);
122
	    $('#scheme-details-container').html('');
123
	    $("#schemes-paginated .previous").prop('disabled', false);
124
	});
125
 
126
}
127
 
128
 
129
function getSchemesPreviousItems(start, end, pre){
130
 
23500 ashik.ali 131
	doGetAjaxRequestHandler(context+"/getPaginatedSchemes/?offset="+pre, function(response){
23343 ashik.ali 132
		$( "#schemes-paginated .end" ).text(+end - +10);
133
		$( "#schemes-paginated .start" ).text(+start - +10);
134
		$('#schemes-table').html(response);
135
		$('#scheme-details-container').html('');
136
		$("#schemes-paginated .next").prop('disabled', false);
137
		if (parseInt(pre)==0)
138
		{
139
			$("#schemes-paginated .previous").prop('disabled', true);
140
		}
141
	});
142
 
23347 ashik.ali 143
 
23343 ashik.ali 144
}
145
 
146
function loadSchemeDetails(schemeId, domId){
23500 ashik.ali 147
	doGetAjaxRequestHandler(context+"/getSchemeById?schemeId="+schemeId, function(response){
23343 ashik.ali 148
		$('#' + domId).html(response);
149
		window.dispatchEvent(new Event('resize'));
150
	});
151
}
152
 
153
function activeScheme(schemeId, offset, domId){
23500 ashik.ali 154
	doPutAjaxRequestHandler(context+"/activeSchemeById?schemeId="+schemeId
155
	        +"&offset="+offset, function(response){
23343 ashik.ali 156
		$('#' + domId).html(response);
157
		$('#scheme-details-container').html('');
158
	});
23347 ashik.ali 159
 
23343 ashik.ali 160
}
161
 
162
function expireScheme(schemeId, offset, domId){
23500 ashik.ali 163
	doPutAjaxRequestHandler(context+"/expireSchemeById?schemeId="+schemeId
164
	        +"&offset="+offset, function(response){
23343 ashik.ali 165
		$('#' + domId).html(response);
166
		$('#scheme-details-container').html('');
167
	});
168
}
169
 
170
function loadScheme(domId){
23500 ashik.ali 171
	doGetAjaxRequestHandler(context+"/createScheme", function(response){
23343 ashik.ali 172
		$('#' + domId).html(response);
173
	});
23347 ashik.ali 174
 
23343 ashik.ali 175
}
176
 
23419 ashik.ali 177
function loadTagListingItemsDescriptionByBrand(domId, brand){
23500 ashik.ali 178
	doGetAjaxRequestHandler(context+"/getTagListingItemsByBrand?brand="+brand, function(response){
23343 ashik.ali 179
		$('#' + domId).html(response);
23419 ashik.ali 180
		configureTagListingItemsDescriptionDropDown();
23343 ashik.ali 181
	});
182
 
183
}
184
 
185
function schemes(domId){
23500 ashik.ali 186
	doGetAjaxRequestHandler(context+"/getSchemes", function(response){
23343 ashik.ali 187
		$('#' + domId).html(response);
188
	});
189
}
190
 
191
function loadSchemesDownloadPage(domId){
23500 ashik.ali 192
	doGetAjaxRequestHandler(context+"/schemes/downloadPage", function(response){
23343 ashik.ali 193
		$('#' + domId).html(response);
194
	});
23556 amit.gupta 195
}
196
 
197
function loadSchemeUpdatePage(domId){
198
	doGetAjaxRequestHandler(context+"/schemes/update-schemes-page", function(response){
199
		$('#' + domId).html(response);
200
	});
23343 ashik.ali 201
}