Subversion Repositories SmartDukaan

Rev

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

Rev 23343 Rev 23347
Line 1... Line -...
1
$(function() {
-
 
2
	
-
 
3
	$(".schemes").live('click', function() {
-
 
4
		console.log("Active Schemes Button Clicked...")
-
 
5
		schemes("main-content");
-
 
6
	});
-
 
7
	
-
 
8
	$(".schemes-download-page").live('click', function() {
-
 
9
		console.log("Schemes Download Clicked...")
-
 
10
		loadSchemesDownloadPage("main-content");
-
 
11
	});
-
 
12
	
-
 
13
	$(".create-scheme").live('click', function() {
-
 
14
		loadScheme("main-content");
-
 
15
	});
-
 
16
	
-
 
17
	
-
 
18
	$('#brands li a').live('click', function(){
-
 
19
		$('#brand-value').text($(this).text());
-
 
20
		loadItemsDescriptionByBrand("items-description-container", $(this).text());
-
 
21
	    console.log($(this).text());
-
 
22
	});
-
 
23
	
-
 
24
	$("#schemes-paginated .next").live('click', function() {
-
 
25
		var start = $( "#schemes-paginated .start" ).text();
-
 
26
		var end = $( "#schemes-paginated .end" ).text();
-
 
27
		getSchemesNextItems(start, end);
-
 
28
		$("#schemes-paginated .next").blur();
-
 
29
    });
-
 
30
	
-
 
31
	$("#schemes-paginated .previous").live('click', function() {
-
 
32
		var start = $( "#schemes-paginated .start" ).text();
-
 
33
		var end =  $( "#schemes-paginated .end" ).text();
-
 
34
		var pre = end - 20;
-
 
35
		getSchemesPreviousItems(start, end, pre);
-
 
36
		$("#schemes-paginated .previous").blur();
-
 
37
    });
-
 
38
	
-
 
39
	$(".scheme-details").live('click',function(){
-
 
40
		var schemeId = $(this).attr('data');
-
 
41
		console.log("schemeId = "+schemeId);
-
 
42
		loadSchemeDetails(schemeId, "scheme-details-container");
-
 
43
	});
-
 
44
	
-
 
45
	
-
 
46
	$(".active-scheme").live('click',function(){
-
 
47
		var schemeId = $(this).attr('data');
-
 
48
		console.log("active-scheme id : "+schemeId);
-
 
49
		var start = $( "#schemes-paginated .start" ).text();
-
 
50
		//var end = $( "#schemes-paginated .end" ).text();
-
 
51
		var offset = start - 1;
-
 
52
		if(confirm("Are you sure you want to Active Scheme!") == true){
-
 
53
			activeScheme(schemeId, offset, "schemes-table");
-
 
54
		}
-
 
55
	});
-
 
56
	
-
 
57
	$(".expire-scheme").live('click',function(){
-
 
58
		var schemeId = $(this).attr('data');
-
 
59
		console.log("expire-scheme id : "+schemeId);
-
 
60
		var start = $( "#schemes-paginated .start" ).text();
-
 
61
		//var end = $( "#schemes-paginated .end" ).text();
-
 
62
		var offset = start - 1;
-
 
63
		if(confirm("Are you sure you want to Expire Scheme!") == true){
-
 
64
			expireScheme(schemeId, offset, "schemes-table");
-
 
65
		}
-
 
66
	});
-
 
67
	
-
 
68
	
-
 
69
});
-
 
70
 
-
 
71
$().ready(function() {
1
$().ready(function() {
72
	$("form#create-scheme-form input").each(function(){
2
	$("form#create-scheme-form input").each(function(){
73
		$(this).attr('autocomplete', 'off');
3
		$(this).attr('autocomplete', 'off');
74
	});
4
	});
75
});
5
});
Line 154... Line 84...
154
         }
84
         }
155
	});
85
	});
156
  
86
  
157
});
87
});
158
 
88
 
-
 
89
 
-
 
90
$('#retailerAll').on('change', function() {
-
 
91
    if (this.checked) {
-
 
92
    	$('#retailerAll').val('true');
-
 
93
    	$('#retailer-ids').html('');
-
 
94
    }else{
-
 
95
    	$('#retailerAll').val('false');
-
 
96
    	$('#retailer-ids').html('<input placeholder="Retailer Ids" id="retailerIds" name="retailerIds" type="text" value="" pattern="^[0-9]{1,10}(?:,[0-9]{1,10})*$" title="Comma Seperated Positive Integer Retailer Ids" class="form-control input-sm">');
-
 
97
    }
-
 
98
});
-
 
99
 
-
 
100
 
159
function validateSchemeDetails(){
101
function validateSchemeDetails(){
160
	console.log("validating Scheme Details...");
102
	console.log("validating Scheme Details...");
161
	var error = false;
103
	var error = false;
162
	var name = $("form#create-scheme-form input[name=schemeName]").val();
104
	var name = $("form#create-scheme-form input[name=schemeName]").val();
163
	console.log("schemeName = " + name);
105
	console.log("schemeName = " + name);
Line 277... Line 219...
277
		for(var retailerId of retailerIds){
219
		for(var retailerId of retailerIds){
278
			schemeObject['retailerIds'].push(parseInt(retailerId));
220
			schemeObject['retailerIds'].push(parseInt(retailerId));
279
		}
221
		}
280
	}
222
	}
281
	return JSON.stringify(schemeObject);
223
	return JSON.stringify(schemeObject);
282
}
-
 
283
 
-
 
284
$('#retailerAll').on('change', function() { 
-
 
285
    if (this.checked) {
-
 
286
    	$('#retailerAll').val('true');
-
 
287
    	$('#retailer-ids').html('');
-
 
288
    }else{
-
 
289
    	$('#retailerAll').val('false');
-
 
290
    	$('#retailer-ids').html('<input placeholder="Retailer Ids" id="retailerIds" name="retailerIds" type="text" value="" pattern="^[0-9]{1,10}(?:,[0-9]{1,10})*$" title="Comma Seperated Positive Integer Retailer Ids" class="form-control input-sm">');
-
 
291
    }
-
 
292
});
-
 
293
 
-
 
294
 
-
 
295
function schemesDownload(){
-
 
296
	
-
 
297
	console.log("downloadItemLedgerReport Button clicked")
-
 
298
	
-
 
299
	var startEndDateTime = $('input[name="startEndDateTime"]').val().split("-");
-
 
300
	var startDateTime = $.trim(startEndDateTime[0]);
-
 
301
	console.log("startDateTime : "+startDateTime);
-
 
302
	var endDateTime = $.trim(startEndDateTime[1]);
-
 
303
	console.log("endDateTime : "+endDateTime);
-
 
304
	doAjaxGetDownload(context+"/schemes/download?startDateTime="+startDateTime+"&endDateTime="+endDateTime,
-
 
305
			 "SchemesReport.xlsx");
-
 
306
}
-
 
307
 
-
 
308
function getSchemesNextItems(start, end){
-
 
309
	console.log(start);
-
 
310
	console.log(end);
-
 
311
	console.log(+end + +10);
-
 
312
	console.log(+start + +10);
-
 
313
	doAjaxRequestHandler(context+"/getPaginatedSchemes?offset="+end, "GET", function(response){
-
 
314
		$( "#schemes-paginated .end" ).text(+end + +10);
-
 
315
		$( "#schemes-paginated .start" ).text(+start + +10);
-
 
316
		var last = $( "#schemes-paginated .end" ).text();
-
 
317
		var temp = $( "#schemes-paginated .size" ).text();
-
 
318
		if (parseInt(last) >= parseInt(temp)){
-
 
319
			$("#schemes-paginated .next").prop('disabled', true);
-
 
320
			//$( "#good-inventory-paginated .end" ).text(temp);
-
 
321
		}
-
 
322
	    $('#schemes-table').html(response);
-
 
323
	    $('#scheme-details-container').html('');
-
 
324
	    $("#schemes-paginated .previous").prop('disabled', false);
-
 
325
	});
-
 
326
	
-
 
327
    
-
 
328
}
-
 
329
 
-
 
330
 
-
 
331
function getSchemesPreviousItems(start, end, pre){
-
 
332
	
-
 
333
	doAjaxRequestHandler(context+"/getPaginatedSchemes/?offset="+pre, "GET", function(response){
-
 
334
		$( "#schemes-paginated .end" ).text(+end - +10);
-
 
335
		$( "#schemes-paginated .start" ).text(+start - +10);
-
 
336
		$('#schemes-table').html(response);
-
 
337
		$('#scheme-details-container').html('');
-
 
338
		$("#schemes-paginated .next").prop('disabled', false);
-
 
339
		if (parseInt(pre)==0)
-
 
340
		{
-
 
341
			$("#schemes-paginated .previous").prop('disabled', true);
-
 
342
		}
-
 
343
	});
-
 
344
	
-
 
345
}
-
 
346
 
-
 
347
function loadSchemeDetails(schemeId, domId){
-
 
348
	doAjaxRequestHandler(context+"/getSchemeById?schemeId="+schemeId, "GET", function(response){
-
 
349
		$('#' + domId).html(response);
-
 
350
		window.dispatchEvent(new Event('resize'));
-
 
351
	});
-
 
352
}
-
 
353
 
-
 
354
function activeScheme(schemeId, offset, domId){
-
 
355
	doAjaxRequestHandler(context+"/activeSchemeById?schemeId="+schemeId
-
 
356
	        +"&offset="+offset, "PUT", function(response){
-
 
357
		$('#' + domId).html(response);
-
 
358
		$('#scheme-details-container').html('');
-
 
359
	});
-
 
360
}
-
 
361
 
-
 
362
function expireScheme(schemeId, offset, domId){
-
 
363
	doAjaxRequestHandler(context+"/expireSchemeById?schemeId="+schemeId
-
 
364
	        +"&offset="+offset, "PUT", function(response){
-
 
365
		$('#' + domId).html(response);
-
 
366
		$('#scheme-details-container').html('');
-
 
367
	});
-
 
368
	
-
 
369
}
-
 
370
 
-
 
371
function loadScheme(domId){
-
 
372
	doAjaxRequestHandler(context+"/createScheme", "GET", function(response){
-
 
373
		$('#' + domId).html(response);
-
 
374
	});
-
 
375
}
-
 
376
 
-
 
377
function loadItemsDescriptionByBrand(domId, brand){
-
 
378
	doAjaxRequestHandler(context+"/getItemsByBrand?brand="+brand, "GET", function(response){
-
 
379
		$('#' + domId).html(response);
-
 
380
		configureItemsDescriptionDropDown();
-
 
381
	});
-
 
382
	
-
 
383
}
-
 
384
 
-
 
385
function configureItemsDescriptionDropDown(){
-
 
386
	$(document).ready(function() {
-
 
387
        $('#itemsDescription').multiselect({
-
 
388
        	includeSelectAllOption: true,
-
 
389
        	maxHeight: 200,
-
 
390
        	buttonWidth: '180px',
-
 
391
        	numberDisplayed: 1,
-
 
392
        	nonSelectedText: 'Items',
-
 
393
        	nSelectedText: ' - Items Selected',
-
 
394
        	allSelectedText: 'All Items Selected',
-
 
395
        	enableFiltering: true
-
 
396
        });
-
 
397
    });
-
 
398
}
-
 
399
 
-
 
400
function schemes(domId){
-
 
401
	doAjaxRequestHandler(context+"/getSchemes", "GET", function(response){
-
 
402
		$('#' + domId).html(response);
-
 
403
	});
-
 
404
}
-
 
405
 
-
 
406
function loadSchemesDownloadPage(domId){
-
 
407
	doAjaxRequestHandler(context+"/schemes/downloadPage", "GET", function(response){
-
 
408
		$('#' + domId).html(response);
-
 
409
	});
-
 
410
}
224
}
411
225