Subversion Repositories SmartDukaan

Rev

Rev 23419 | Rev 23556 | 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
	});
69
});
70
 
23419 ashik.ali 71
function configureTagListingItemsDescriptionDropDown(){
23347 ashik.ali 72
	$(document).ready(function() {
23419 ashik.ali 73
        $('#tagListingItemsDescription').multiselect({
74
	        	includeSelectAllOption: true,
75
	        	maxHeight: 200,
76
	        	buttonWidth: '180px',
77
	        	numberDisplayed: 1,
78
	        	nonSelectedText: 'Items',
79
	        	nSelectedText: ' - Items Selected',
80
	        	allSelectedText: 'All Items Selected',
81
	        	enableFiltering: true
23347 ashik.ali 82
        });
83
    });
23343 ashik.ali 84
}
85
 
86
function schemesDownload(){
87
	console.log("downloadItemLedgerReport Button clicked")
23347 ashik.ali 88
	var startDateTime = $('input[name="startDateTime"]').val();
23343 ashik.ali 89
	console.log("startDateTime : "+startDateTime);
23347 ashik.ali 90
	var endDateTime = $('input[name="endDateTime"]').val();
23343 ashik.ali 91
	console.log("endDateTime : "+endDateTime);
92
	doAjaxGetDownload(context+"/schemes/download?startDateTime="+startDateTime+"&endDateTime="+endDateTime,
23347 ashik.ali 93
			"SchemesReport.xlsx");
23343 ashik.ali 94
}
95
 
96
function getSchemesNextItems(start, end){
97
	console.log(start);
98
	console.log(end);
99
	console.log(+end + +10);
100
	console.log(+start + +10);
23500 ashik.ali 101
	doGetAjaxRequestHandler(context+"/getPaginatedSchemes?offset="+end, function(response){
23419 ashik.ali 102
		var size = $("#schemes-paginated .size").text();
103
		if((parseInt(end) + 10) > parseInt(size)){
104
			console.log("(end + 10) > size == true");
105
			$( "#schemes-paginated .end" ).text(size);
106
		}else{
107
			console.log("(end + 10) > size == false");
108
			$( "#schemes-paginated .end" ).text(+end + +10);
109
		}
23343 ashik.ali 110
		$( "#schemes-paginated .start" ).text(+start + +10);
111
		var last = $( "#schemes-paginated .end" ).text();
112
		var temp = $( "#schemes-paginated .size" ).text();
113
		if (parseInt(last) >= parseInt(temp)){
114
			$("#schemes-paginated .next").prop('disabled', true);
115
			//$( "#good-inventory-paginated .end" ).text(temp);
116
		}
117
	    $('#schemes-table').html(response);
118
	    $('#scheme-details-container').html('');
119
	    $("#schemes-paginated .previous").prop('disabled', false);
120
	});
121
 
122
}
123
 
124
 
125
function getSchemesPreviousItems(start, end, pre){
126
 
23500 ashik.ali 127
	doGetAjaxRequestHandler(context+"/getPaginatedSchemes/?offset="+pre, function(response){
23343 ashik.ali 128
		$( "#schemes-paginated .end" ).text(+end - +10);
129
		$( "#schemes-paginated .start" ).text(+start - +10);
130
		$('#schemes-table').html(response);
131
		$('#scheme-details-container').html('');
132
		$("#schemes-paginated .next").prop('disabled', false);
133
		if (parseInt(pre)==0)
134
		{
135
			$("#schemes-paginated .previous").prop('disabled', true);
136
		}
137
	});
138
 
23347 ashik.ali 139
 
23343 ashik.ali 140
}
141
 
142
function loadSchemeDetails(schemeId, domId){
23500 ashik.ali 143
	doGetAjaxRequestHandler(context+"/getSchemeById?schemeId="+schemeId, function(response){
23343 ashik.ali 144
		$('#' + domId).html(response);
145
		window.dispatchEvent(new Event('resize'));
146
	});
147
}
148
 
149
function activeScheme(schemeId, offset, domId){
23500 ashik.ali 150
	doPutAjaxRequestHandler(context+"/activeSchemeById?schemeId="+schemeId
151
	        +"&offset="+offset, function(response){
23343 ashik.ali 152
		$('#' + domId).html(response);
153
		$('#scheme-details-container').html('');
154
	});
23347 ashik.ali 155
 
23343 ashik.ali 156
}
157
 
158
function expireScheme(schemeId, offset, domId){
23500 ashik.ali 159
	doPutAjaxRequestHandler(context+"/expireSchemeById?schemeId="+schemeId
160
	        +"&offset="+offset, function(response){
23343 ashik.ali 161
		$('#' + domId).html(response);
162
		$('#scheme-details-container').html('');
163
	});
164
}
165
 
166
function loadScheme(domId){
23500 ashik.ali 167
	doGetAjaxRequestHandler(context+"/createScheme", function(response){
23343 ashik.ali 168
		$('#' + domId).html(response);
169
	});
23347 ashik.ali 170
 
23343 ashik.ali 171
}
172
 
23419 ashik.ali 173
function loadTagListingItemsDescriptionByBrand(domId, brand){
23500 ashik.ali 174
	doGetAjaxRequestHandler(context+"/getTagListingItemsByBrand?brand="+brand, function(response){
23343 ashik.ali 175
		$('#' + domId).html(response);
23419 ashik.ali 176
		configureTagListingItemsDescriptionDropDown();
23343 ashik.ali 177
	});
178
 
179
}
180
 
181
function schemes(domId){
23500 ashik.ali 182
	doGetAjaxRequestHandler(context+"/getSchemes", function(response){
23343 ashik.ali 183
		$('#' + domId).html(response);
184
	});
185
}
186
 
187
function loadSchemesDownloadPage(domId){
23500 ashik.ali 188
	doGetAjaxRequestHandler(context+"/schemes/downloadPage", function(response){
23343 ashik.ali 189
		$('#' + domId).html(response);
190
	});
191
}