Subversion Repositories SmartDukaan

Rev

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

Rev 23340 Rev 23343
Line 1... Line -...
1
var grnhistory= grnhistory || {};
-
 
2
grnhistory.searchText = "";
-
 
3
grnhistory.searchType = "";
-
 
4
grnhistory.startTime = "0";
-
 
5
grnhistory.endTime = "0";
-
 
6
 
-
 
7
var saleHistory=saleHistory || {};
-
 
8
saleHistory.searchText="";
-
 
9
saleHistory.searchType="";
-
 
10
saleHistory.startTime="";
-
 
11
saleHistory.endTime="";
-
 
12
 
-
 
13
var walletHistory = walletHistory || {};
-
 
14
walletHistory.startTime="";
-
 
15
walletHistory.endTime="";
-
 
16
 
-
 
17
$(function() {
1
$(function() {
18
	$(".new_grn").live('click', function() {
-
 
19
		loadNewGrn("main-content");
-
 
20
	});
-
 
21
	
-
 
22
	$("#retailerDocumentForm").submit(function(event) {
-
 
23
		event.preventDefault();
-
 
24
		var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
-
 
25
		var file = $("#retailerDocument").val();
-
 
26
		uploadRetailerDocument("retailer-details-container", file, emailIdOrMobileNumber);
-
 
27
	});
-
 
28
	
-
 
29
	
-
 
30
	$(".good_inventory").live('click', function() {
-
 
31
		loadGoodInventory("main-content","");
-
 
32
	});
-
 
33
	
-
 
34
	$(".catalog").live('click', function() {
-
 
35
		loadCatalog("main-content","");
-
 
36
	});
-
 
37
	
-
 
38
	$(".item_aging").live('click', function() {
-
 
39
		getInventoryItemAgingByInterval("main-content", "");
-
 
40
	});
-
 
41
	
-
 
42
	$("#item-aging-paginated .next").live('click', function() {
-
 
43
		var end = $( "#item-aging-paginated .end" ).text();
-
 
44
		getItemAgingNextPreviousItems(end, "");
-
 
45
		$("#item-aging-paginated .next").blur();
-
 
46
    });
-
 
47
	
-
 
48
	$("#item-aging-search-button").live('click', function() {
-
 
49
		searchContent = $("#item-aging-search-text").val();
-
 
50
		if (typeof (searchContent) == "undefined" || !searchContent){
-
 
51
			searchContent = "";
-
 
52
		}
-
 
53
		getInventoryItemAgingByInterval("main-content", searchContent);
-
 
54
    });
-
 
55
	
-
 
56
	$("#retailer-details-search-button").live('click', function() {
-
 
57
		searchContent = $("#retailer-details-search-text").val();
-
 
58
		if (typeof (searchContent) == "undefined" || !searchContent){
-
 
59
			searchContent = "";
-
 
60
		}
-
 
61
		getRetailerDetailsByEmailIdOrMobileNumber("retailer-details-container", searchContent);
-
 
62
    });
-
 
63
	
-
 
64
	$("#item-aging-search-text").live("keyup", function(e) {
-
 
65
		var keyCode = e.keyCode || e.which;
-
 
66
    	if(keyCode == 13){
-
 
67
        	$("#item-aging-search-button").click();
-
 
68
    	}
-
 
69
	});
-
 
70
	
-
 
71
	$("#item-aging-paginated .previous").live('click', function() {
-
 
72
		var start = $( "#item-aging-paginated .start" ).text();
-
 
73
		getItemAgingNextPreviousItems(start - 11, "");
-
 
74
		$("#item-aging-paginated .previous").blur();
-
 
75
    });
-
 
76
	
-
 
77
	$(".download_aging_report").live('click', function() {
-
 
78
		downloadAgingReport();
-
 
79
	});
-
 
80
	
-
 
81
	$(".item-ledger-report-download-page").live('click', function() {
-
 
82
		loadItemLedgerReportDownloadPage("main-content");
-
 
83
	});
-
 
84
	
-
 
85
	/*$(".item-ledger-report-download").live('click', function() {
-
 
86
		var startEndDateTime = $('input[name="startEndDateTime"]').val().split("-");
-
 
87
		var startDateTime = $.trim(startEndDateTime[0]);
-
 
88
		var endDateTime = $.trim(startEndDateTime[1]);
-
 
89
		downloadItemLedgerReport(startDateTime, endDateTime);
-
 
90
	});*/
-
 
91
	
-
 
92
	$(".bad_inventory").live('click', function() {
-
 
93
		loadBadInventory("main-content","");
-
 
94
	});
-
 
95
 
-
 
96
	$(".grn_history").live('click', function() {
-
 
97
		loadGrnHistory("main-content","","","0","0");
-
 
98
	});
-
 
99
	
-
 
100
	$(".pending_grn").live('click', function() {
-
 
101
		loadPendingGrn("main-content", "", "", "0", "0");
-
 
102
	});
-
 
103
	
-
 
104
	$(".cart_icon_header").live('click', function() {
-
 
105
		loadCart("main-content");
-
 
106
	});
-
 
107
	
-
 
108
	$(".wallet_icon_header").live('click', function() {
-
 
109
		loadWallet("main-content", "", "");
-
 
110
	});
-
 
111
	
-
 
112
	$(".cart-checkout").live('click', function() {
-
 
113
		checkout("main-content");
-
 
114
	});
-
 
115
	
-
 
116
	$(".create-order").live('click', function() {
-
 
117
		checkout("main-content");
-
 
118
	});
-
 
119
	
-
 
120
	$(".sale-history").live('click', function() {
-
 
121
		console.log("Sale History Button Clicked...")
-
 
122
		saleHistory("main-content","","","0","0");
-
 
123
	});
-
 
124
	
-
 
125
	$(".schemes").live('click', function() {
-
 
126
		console.log("Active Schemes Button Clicked...")
-
 
127
		schemes("main-content");
-
 
128
	});
-
 
129
	
-
 
130
	$(".schemes-download-page").live('click', function() {
-
 
131
		console.log("Schemes Download Clicked...")
-
 
132
		loadSchemesDownloadPage("main-content");
-
 
133
	});
-
 
134
	
-
 
135
	
2
	
136
	$(".contact-us").live('click', function() {
3
	$(".contact-us").live('click', function() {
137
		console.log("Contact Us Button Clicked...")
4
		console.log("Contact Us Button Clicked...")
138
		contactUs("main-content");
5
		contactUs("main-content");
139
	});
6
	});
140
	
7
	
141
	$(".create-scheme").live('click', function() {
-
 
142
		loadScheme("main-content");
-
 
143
	});
-
 
144
	
-
 
145
	$(".retailer-info").live('click', function() {
-
 
146
		retailerInfo("main-content");
-
 
147
	});
-
 
148
	
-
 
149
	$('#brands li a').live('click', function(){
-
 
150
		$('#brand-value').text($(this).text());
-
 
151
		loadItemsDescriptionByBrand("items-description-container", $(this).text());
-
 
152
	    console.log($(this).text());
-
 
153
	});
-
 
154
	
-
 
155
 
-
 
156
	$("td.startGrnSerialized").live('click', function() {
-
 
157
		var invoiceNumber = $(this).attr('invoiceNumber');
-
 
158
		var quantity = $(this).attr('quantity');
-
 
159
		var displayName = $(this).attr('displayName');
-
 
160
		var itemId = $(this).attr('itemId');
-
 
161
		console.log(quantity);
-
 
162
		$(".modal-body .grnInvoiceNumber>span").text(invoiceNumber);
-
 
163
		$(".modal-body .grnProductInfo>span").text(displayName);
-
 
164
		$("#scanModel .invoiceNumber").val(invoiceNumber);
-
 
165
		$("#scanModel .itemId").val(itemId);
-
 
166
		$( "#grnImeiInformation" ).empty();
-
 
167
		var qty = parseInt(quantity);
-
 
168
		var divCode = '<div class="row">CONTENT</div><p></p>';
-
 
169
		var innerDiv = '<div class="col-sm-3">'+
-
 
170
		'<div class="input-group">'+
-
 
171
		'<input type="text" class="form-control">'+
-
 
172
		'</div>'+
-
 
173
		'</div>';
-
 
174
		while(qty!=0){
-
 
175
			var divText  = "";
-
 
176
			if (qty < 4){
-
 
177
				var cp = qty;
-
 
178
				for (var i=0;i<cp;i++ ){
-
 
179
					divText = divText + innerDiv;
-
 
180
					qty = qty - 1;
-
 
181
				}
-
 
182
			}
-
 
183
			else{
-
 
184
				for(var i=0;i<4;i++){
-
 
185
					divText = divText + innerDiv;
-
 
186
					qty = qty - 1;
-
 
187
				}
-
 
188
			}
-
 
189
			divText = divCode.replace("CONTENT",divText); 
-
 
190
			$("#grnImeiInformation")
-
 
191
			.append(divText)
-
 
192
		}
-
 
193
	});
-
 
194
 
-
 
195
	$("td.startGrnNonSerialized").live('click', function() {
-
 
196
		var invoiceNumber = $(this).attr('invoiceNumber');
-
 
197
		var quantity = $(this).attr('quantity');
-
 
198
		var displayName = $(this).attr('displayName');
-
 
199
		var itemId = $(this).attr('itemId');
-
 
200
		console.log(quantity);
-
 
201
		$("#scanNonSerializedModel .modal-body .grnInvoiceNumber>span").text(invoiceNumber);
-
 
202
		$("#scanNonSerializedModel .modal-body .grnProductInfo>span").text(displayName);
-
 
203
		$("#scanNonSerializedModel .invoiceNumber").val(invoiceNumber);
-
 
204
		$("#scanNonSerializedModel .itemId").val(itemId);
-
 
205
		$( "#grnImeiInformation" ).empty();
-
 
206
		var qty = parseInt(quantity);
-
 
207
		var divCode = '<div class="row">CONTENT</div><p></p>';
-
 
208
		var innerDiv = '<div class="col-sm-3">'+
-
 
209
		'<div class="input-group">'+
-
 
210
		'<input type="text" class="form-control">'+
-
 
211
		'</div>'+
-
 
212
		'</div>';
-
 
213
		while(qty!=0){
-
 
214
			var divText  = "";
-
 
215
			if (qty < 4){
-
 
216
				var cp = qty;
-
 
217
				for (var i=0;i<cp;i++ ){
-
 
218
					divText = divText + innerDiv;
-
 
219
					qty = qty - 1;
-
 
220
				}
-
 
221
			}
-
 
222
			else{
-
 
223
				for(var i=0;i<4;i++){
-
 
224
					divText = divText + innerDiv;
-
 
225
					qty = qty - 1;
-
 
226
				}
-
 
227
			}
-
 
228
			divText = divCode.replace("CONTENT",divText); 
-
 
229
			$("#grnImeiInformation")
-
 
230
			.append(divText)
-
 
231
		}
-
 
232
	});
-
 
233
	
-
 
234
	$("#grnSubmitSerialized").live('click', function(){
-
 
235
		var imeis = [];
-
 
236
		var error = false;
-
 
237
		var errorText = "";
-
 
238
		$("#grnImeiInformation :input").each(function(){
-
 
239
			var input = $(this).val().trim();
-
 
240
			if (imeis.indexOf(input) !=-1 || !input){
-
 
241
				error = true;
-
 
242
				if (!input){
-
 
243
					$(this).addClass("border-highlight");
-
 
244
				}
-
 
245
			}
-
 
246
			imeis.push(input);
-
 
247
			
-
 
248
		});
-
 
249
		if (error){
-
 
250
			return false;
-
 
251
		}
-
 
252
		var invoiceNumber = $("#scanModel .invoiceNumber").val();
-
 
253
		var itemId = $("#scanModel .itemId").val();
-
 
254
		var postData = JSON.stringify({"itemId":parseInt(itemId),"invoiceNumber":invoiceNumber,"serialNumbers":imeis});
-
 
255
		jQuery.ajax({
-
 
256
			url: context+"/scanSerialized",
-
 
257
			type: 'POST',
-
 
258
			data: postData,
-
 
259
			contentType:'application/json',
-
 
260
			async: false,
-
 
261
			success: function (data) {
-
 
262
				alert("Purchase booked successfully");
-
 
263
				$('#scanModel').modal('hide');
-
 
264
				$("#scanModel").on("hidden.bs.modal", function () {
-
 
265
					$("#purchase-reference-submit-button").click();
-
 
266
				});
-
 
267
			},
-
 
268
			cache: false,
-
 
269
			processData: false
-
 
270
		});
-
 
271
		return false;
-
 
272
	});
-
 
273
	
-
 
274
	$("#grnNonSerializedSubmit").live('click', function(){
-
 
275
		var error = false;
-
 
276
		var errorText = "";
-
 
277
		if (error){
-
 
278
			return false;
-
 
279
		}
-
 
280
		var invoiceNumber = $("#scanNonSerializedModel .invoiceNumber").val();
-
 
281
		var itemId = $("#scanNonSerializedModel .itemId").val();
-
 
282
		var quantity = $("#scanNonSerializedModel .quantity").val();
-
 
283
		var postData = JSON.stringify({"itemId":parseInt(itemId),"invoiceNumber":invoiceNumber,"quantity":parseInt(quantity)});
-
 
284
		jQuery.ajax({
-
 
285
			url: context+"/scanNonSerialized",
-
 
286
			type: 'POST',
-
 
287
			data: postData,
-
 
288
			contentType:'application/json',
-
 
289
			async: false,
-
 
290
			success: function (data) {
-
 
291
				alert("Purchase booked successfully");
-
 
292
				$('#scanNonSerializedModel').modal('hide');
-
 
293
				$("#scanNonSerializedModel").on("hidden.bs.modal", function () {
-
 
294
					$("#purchase-reference-submit-button").click();
-
 
295
				});
-
 
296
			},
-
 
297
			cache: false,
-
 
298
			processData: false
-
 
299
		});
-
 
300
		return false;
-
 
301
	});
-
 
302
 
-
 
303
	$("#grnImeiInformation :input").live('change paste keyup mouseup', function() {
-
 
304
		if ($(this).val().trim() != "") {
-
 
305
			console.log('The text box really changed this time');
-
 
306
			$('#grnImeiInformation :input').removeClass("border-highlight");
-
 
307
			if(findDuplicateSerialNumbers( $(this).val().trim()) > 0){
-
 
308
				var inputs = $("#grnImeiInformation :input[value="+$(this).val().trim()+"]");
-
 
309
				if(inputs.length > 1){
-
 
310
					inputs.each(function(){$(this).addClass("border-highlight")});
-
 
311
				}
-
 
312
			}
-
 
313
		}
-
 
314
	});
-
 
315
	
-
 
316
	
-
 
317
	$("#grnImeiInformation :input").live('paste', function() {
-
 
318
		if ($(this).val().trim() != "") {
-
 
319
			console.log('paste event');
-
 
320
			$(this).next("input .form-control").focus();
-
 
321
		}
-
 
322
	});
-
 
323
	
-
 
324
	$("#good-inventory-paginated .next").live('click', function() {
-
 
325
		var start = $( "#good-inventory-paginated .start" ).text();
-
 
326
		var end = $( "#good-inventory-paginated .end" ).text();
-
 
327
		var searchText = $("#good-inventory-search-text").val();
-
 
328
		if (typeof (searchText) == "undefined" || !searchText){
-
 
329
			searchText = "";
-
 
330
		}
-
 
331
		getNextItems(start,end, searchText);
-
 
332
		$("#good-inventory-paginated .next").blur();
-
 
333
		
-
 
334
    });
-
 
335
	
-
 
336
	$("#good-inventory-paginated .previous").live('click', function() {
-
 
337
		var start = $( "#good-inventory-paginated .start" ).text();
-
 
338
		var end =  $( "#good-inventory-paginated .end" ).text();
-
 
339
		var searchText = $("#good-inventory-search-text").val();
-
 
340
		if (typeof (searchText) == "undefined" || !searchText){
-
 
341
			searchText = "";
-
 
342
		}
-
 
343
		var pre = end - 20;
-
 
344
		getPreviousItems(start, end, pre, searchText);
-
 
345
		$("#good-inventory-paginated .previous").blur();
-
 
346
    });
-
 
347
	
-
 
348
	$("#good-inventory-search-button").live('click', function() {
-
 
349
		var searchText = $("#good-inventory-search-text").val();
-
 
350
		if (typeof (searchText) == "undefined" || !searchText){
-
 
351
			searchText = "";
-
 
352
		}
-
 
353
		loadGoodInventorySearchInfo(searchText);
-
 
354
    });
-
 
355
	
-
 
356
	$("#good-inventory-search-text").live("keyup", function(e) {
-
 
357
		var keyCode = e.keyCode || e.which;
-
 
358
    	if(keyCode == 13){
-
 
359
        	$("#good-inventory-search-button").click();
-
 
360
    	}
-
 
361
	});
-
 
362
	
-
 
363
	$("#airwayBillOrInvoiceNumberText").live("keyup", function(e) {
-
 
364
		var keyCode = e.keyCode || e.which;
-
 
365
    	if(keyCode == 13){
-
 
366
        	$("#purchase-reference-submit-button").click();
-
 
367
    	}
-
 
368
	});
-
 
369
	
-
 
370
	$("#catalog-paginated .next").live('click', function() {
-
 
371
		var start = $( "#catalog-paginated .start" ).text();
-
 
372
		var end = $( "#catalog-paginated .end" ).text();
-
 
373
		var searchText = $("#catalog-search-text").val();
-
 
374
		if (typeof (searchText) == "undefined" || !searchText){
-
 
375
			searchText = "";
-
 
376
		}
-
 
377
		getNextCatalogItems(start,end,searchText);
-
 
378
		$("#catalog-paginated .next").blur();
-
 
379
    });
-
 
380
	
-
 
381
	$("#catalog-paginated .previous").live('click', function() {
-
 
382
		var start = $( "#catalog-paginated .start" ).text();
-
 
383
		var end =  $( "#catalog-paginated .end" ).text();
-
 
384
		var searchText = $("#catalog-search-text").val();
-
 
385
		if (typeof (searchText) == "undefined" || !searchText){
-
 
386
			searchText = "";
-
 
387
		}
-
 
388
		var pre = end - 20;
-
 
389
		getPreviousCatalogItems(start,end,pre,searchText);
-
 
390
		$("#catalog-paginated .previous").blur();
-
 
391
    });
-
 
392
	
-
 
393
	$("#catalog-search-button").live('click', function() {
-
 
394
		var searchText = $("#catalog-search-text").val();
-
 
395
		if (typeof (searchText) == "undefined" || !searchText){
-
 
396
			searchText = "";
-
 
397
		}
-
 
398
		loadCatalogSearchInfo(searchText);
-
 
399
    });
-
 
400
	
-
 
401
	$("#catalog-search-text").live("keyup", function(e) {
-
 
402
		var keyCode = e.keyCode || e.which;
-
 
403
    	if(keyCode == 13){
-
 
404
        	$("#catalog-search-button").click();
-
 
405
    	}
-
 
406
	});
-
 
407
	
-
 
408
	$("#grn-history-search-button").live('click', function() {
-
 
409
		grnhistory.searchText = $("#grn-history-search-text").val();
-
 
410
		grnhistory.searchType = "purchaseReference";
-
 
411
		grnhistory.startTime = "0";
-
 
412
		grnhistory.endTime = "0";
-
 
413
		if (typeof (grnhistory.searchText) == "undefined" || !grnhistory.searchText){
-
 
414
			grnhistory.searchText = "";
-
 
415
		}
-
 
416
		loadGrnHistorySearchInfo(grnhistory.searchText,grnhistory.searchType,grnhistory.startTime,grnhistory.endTime);
-
 
417
    });
-
 
418
	
-
 
419
	$("#grn-history-search-text").live("keyup", function(e) {
-
 
420
		var keyCode = e.keyCode || e.which;
-
 
421
    	if(keyCode == 13){
-
 
422
        	$("#grn-history-search-button").click();
-
 
423
    	}
-
 
424
	});
-
 
425
	
-
 
426
	$("#retailer-details-search-text").live("keyup", function(e) {
-
 
427
		var keyCode = e.keyCode || e.which;
-
 
428
    	if(keyCode == 13){
-
 
429
        	$("#retailer-details-search-button").click();
-
 
430
    	}
-
 
431
	});
-
 
432
	
-
 
433
	
-
 
434
	$('#searchType').live('change', function() { 
-
 
435
	    var searchType = $(this).find('option:selected').text();
-
 
436
	    console.log("selected searchType = " + searchType);
-
 
437
	    $("#sale-history-search-text").attr('placeholder', 'Search By '+searchType);
-
 
438
	    $("#sale-history-search-text").val('');
-
 
439
	});
-
 
440
	
-
 
441
	$('#retailerAddressState').live('change', function() { 
-
 
442
	    var stateName = $(this).find('option:selected').text();
-
 
443
	    loadDistrictNames(stateName);
-
 
444
	});
-
 
445
	
-
 
446
	
-
 
447
	$("#sale-history-search-button").live('click', function() {
-
 
448
		console.log("sale-history-search-button clicked")
-
 
449
		var searchType = $("#searchType option:selected").val();
-
 
450
		console.log("searchType = " + searchType);
-
 
451
		$("#searchType").removeClass("border-highlight");
-
 
452
		if(searchType == ""){
-
 
453
			alert("Please choose Search Type");
-
 
454
			$("#searchType").addClass("border-highlight");
-
 
455
		}else{
-
 
456
			var startDateTime = $('input[name="startDateTime"]').val();
-
 
457
			console.log("startDateTime : "+startDateTime);
-
 
458
			var endDateTime = $('input[name="endDateTime"]').val();
-
 
459
			console.log("endDateTime : "+endDateTime);
-
 
460
			
-
 
461
			saleHistory.searchText = $("#sale-history-search-text").val();
-
 
462
			saleHistory.searchType = searchType;
-
 
463
			saleHistory.startTime = startDateTime;
-
 
464
			saleHistory.endTime = endDateTime;
-
 
465
			if (typeof (saleHistory.searchText) == "undefined" || !saleHistory.searchText){
-
 
466
				saleHistory.searchText = "";
-
 
467
			}
-
 
468
			saleHistorySearchInfo(saleHistory.searchType, saleHistory.searchText, saleHistory.startTime, saleHistory.endTime);
-
 
469
			$("#sale-history-search-text").val(saleHistory.searchText);
-
 
470
			$("#searchType").val(searchType);
-
 
471
			$('input[name="startDateTime"]').val(saleHistory.startTime);
-
 
472
			$('input[name="endDateTime"]').val(saleHistory.endTime);
-
 
473
		}
-
 
474
    });
-
 
475
	
-
 
476
	/*$("#sale-history-search-text").live("keyup", function(e) {
-
 
477
		var keyCode = e.keyCode || e.which;
-
 
478
    	if(keyCode == 13){
-
 
479
        	$("#sale-history-search-button").click();
-
 
480
    	}
-
 
481
	});*/
-
 
482
	
-
 
483
	$("#grn-history-paginated .next").live('click', function() {
-
 
484
		var start = $( "#grn-history-paginated .start" ).text();
-
 
485
		var end = $( "#grn-history-paginated .end" ).text();
-
 
486
		getGrnHistoryNextItems(start,end,grnhistory.searchText,grnhistory.searchType,grnhistory.startTime,grnhistory.endTime);
-
 
487
		$("#grn-history-paginated .next").blur();
-
 
488
		
-
 
489
    });
-
 
490
	
-
 
491
	$("#grn-history-paginated .previous").live('click', function() {
-
 
492
		var start = $( "#grn-history-paginated .start" ).text();
-
 
493
		var end =  $( "#grn-history-paginated .end" ).text();
-
 
494
		var pre = end - 20;
-
 
495
		getGrnHistoryPreviousItems(start,end,pre,grnhistory.searchText,grnhistory.searchType,grnhistory.startTime,grnhistory.endTime);
-
 
496
		$("#grn-history-paginated .previous").blur();
-
 
497
    });
-
 
498
	
-
 
499
	$("#grn-history-date-button").live('click', function() {
-
 
500
		var dateRange = $('#reportrange span').text();
-
 
501
		grnhistory.startTime = new Date(dateRange.split("-")[0]).getTime();
-
 
502
		grnhistory.endTime = new Date(dateRange.split("-")[1]).getTime();
-
 
503
		grnhistory.searchType = "dateFilter";
-
 
504
		grnhistory.searchText = "";
-
 
505
		loadGrnHistorySearchInfo(grnhistory.searchText,grnhistory.searchType,grnhistory.startTime,grnhistory.endTime);
-
 
506
    });
-
 
507
	
-
 
508
	
-
 
509
	$("#sale-history-paginated .next").live('click', function() {
-
 
510
		var start = $( "#sale-history-paginated .start" ).text();
-
 
511
		var end = $( "#sale-history-paginated .end" ).text();
-
 
512
		getSaleHistoryNextItems(start, end, saleHistory.searchType, saleHistory.searchText, saleHistory.startTime, saleHistory.endTime);
-
 
513
		$("#sale-history-paginated .next").blur();
-
 
514
    });
-
 
515
	
-
 
516
	$("#sale-history-paginated .previous").live('click', function() {
-
 
517
		var start = $( "#sale-history-paginated .start" ).text();
-
 
518
		var end =  $( "#sale-history-paginated .end" ).text();
-
 
519
		var pre = end - 20;
-
 
520
		getSaleHistoryPreviousItems(start, end, pre, saleHistory.searchType, saleHistory.searchText, saleHistory.startTime, saleHistory.endTime);
-
 
521
		$("#sale-history-paginated .previous").blur();
-
 
522
    });
-
 
523
	
-
 
524
	$("#schemes-paginated .next").live('click', function() {
-
 
525
		var start = $( "#schemes-paginated .start" ).text();
-
 
526
		var end = $( "#schemes-paginated .end" ).text();
-
 
527
		getSchemesNextItems(start, end);
-
 
528
		$("#schemes-paginated .next").blur();
-
 
529
    });
-
 
530
	
-
 
531
	$("#schemes-paginated .previous").live('click', function() {
-
 
532
		var start = $( "#schemes-paginated .start" ).text();
-
 
533
		var end =  $( "#schemes-paginated .end" ).text();
-
 
534
		var pre = end - 20;
-
 
535
		getSchemesPreviousItems(start, end, pre);
-
 
536
		$("#schemes-paginated .previous").blur();
-
 
537
    });
-
 
538
	
-
 
539
	$("#wallet-history-paginated .next").live('click', function() {
-
 
540
		var start = $( "#wallet-history-paginated .start" ).text();
-
 
541
		var end = $( "#wallet-history-paginated .end" ).text();
-
 
542
		getWalletHistoryNextItems(start, end, walletHistory.startTime, walletHistory.endTime);
-
 
543
		$("#wallet-history-paginated .next").blur();
-
 
544
    });
-
 
545
	
-
 
546
	$("#wallet-history-paginated .previous").live('click', function() {
-
 
547
		var start = $( "#wallet-history-paginated .start" ).text();
-
 
548
		var end =  $( "#wallet-history-paginated .end" ).text();
-
 
549
		var pre = end - 20;
-
 
550
		getWalletHistoryPreviousItems(start, end, pre, walletHistory.startTime, walletHistory.endTime);
-
 
551
		$("#wallet-history-paginated .previous").blur();
-
 
552
    });
-
 
553
	
-
 
554
	/*$("#sale-history-date-button").live('click', function() {
-
 
555
		var dateRange = $('#reportrange span').text();
-
 
556
		saleHistory.startTime = new Date(dateRange.split("-")[0]).getTime();
-
 
557
		saleHistory.endTime = new Date(dateRange.split("-")[1]).getTime();
-
 
558
		saleHistory.searchType = "";
-
 
559
		saleHistory.searchText = "";
-
 
560
		saleHistorySearchInfo(saleHistory.searchType, saleHistory.searchText, saleHistory.startTime, saleHistory.endTime);
-
 
561
    });*/
-
 
562
	
-
 
563
	
-
 
564
	//grn-details
-
 
565
	
-
 
566
	$(".grn-details").live('click',function(){
-
 
567
		var purchaseId = $(this).attr('data');
-
 
568
		console.log(purchaseId);
-
 
569
		loadGrnDetails(purchaseId,"grn-details-container");
-
 
570
	});
-
 
571
	
-
 
572
	$(".pending-grn-details").live('click',function(){
-
 
573
		console.log("pending-grn-details clicked");
-
 
574
		var orderId = $(this).attr('data');
-
 
575
		console.log("orderId : "+orderId);
-
 
576
		loadPendingGrnDetails(orderId, "pending-grn-details-container");
-
 
577
	});
-
 
578
	
-
 
579
	$(".sale-details").live('click',function(){
-
 
580
		var orderId = $(this).attr('data');
-
 
581
		console.log("orderId = "+orderId);
-
 
582
		loadSaleDetails(orderId,"sale-details-container");
-
 
583
	});
-
 
584
	
-
 
585
	$(".scheme-details").live('click',function(){
-
 
586
		var schemeId = $(this).attr('data');
-
 
587
		console.log("schemeId = "+schemeId);
-
 
588
		loadSchemeDetails(schemeId, "scheme-details-container");
-
 
589
	});
-
 
590
	
-
 
591
	$(".pending-grn").live('click',function(){
-
 
592
		var purchaseReference = $(this).attr('data');
-
 
593
		console.log(purchaseReference);
-
 
594
		loadPendingGrnDetails(purchaseReference,"main-content");
-
 
595
	});
-
 
596
	
-
 
597
	$(".active-scheme").live('click',function(){
-
 
598
		var schemeId = $(this).attr('data');
-
 
599
		console.log("active-scheme id : "+schemeId);
-
 
600
		var start = $( "#schemes-paginated .start" ).text();
-
 
601
		//var end = $( "#schemes-paginated .end" ).text();
-
 
602
		var offset = start - 1;
-
 
603
		if(confirm("Are you sure you want to Active Scheme!") == true){
-
 
604
			activeScheme(schemeId, offset, "schemes-table");
-
 
605
		}
-
 
606
	});
-
 
607
	
-
 
608
	$(".expire-scheme").live('click',function(){
-
 
609
		var schemeId = $(this).attr('data');
-
 
610
		console.log("expire-scheme id : "+schemeId);
-
 
611
		var start = $( "#schemes-paginated .start" ).text();
-
 
612
		//var end = $( "#schemes-paginated .end" ).text();
-
 
613
		var offset = start - 1;
-
 
614
		if(confirm("Are you sure you want to Expire Scheme!") == true){
-
 
615
			expireScheme(schemeId, offset, "schemes-table");
-
 
616
		}
-
 
617
	});
-
 
618
	
-
 
619
	//add-to-bag
-
 
620
	
-
 
621
	$(".add-to-bag").live('click', function() {
-
 
622
		var itemId = $(this).attr('data');
-
 
623
		$("#bagModel .itemId").val(itemId);
-
 
624
		$("#bagModel .quantity").val(0);
-
 
625
		jQuery.ajax({
-
 
626
			url: context+"/checkItemAvailability/?itemId="+itemId,
-
 
627
			type: 'GET',
-
 
628
			contentType:'application/json',
-
 
629
			async: false,
-
 
630
			success: function (data) {
-
 
631
				var obj = JSON.parse(data);
-
 
632
				console.log(obj);
-
 
633
				console.log(obj.displayName);
-
 
634
				$(".modal-body h4.bagModalProductInfo.modelHeaderCustom > span").text(obj.displayName);
-
 
635
				$(".modal-body h4.bagModalAvailability.modelHeaderCustom > span").text(obj.availability);
-
 
636
				$("#bagModel .availability").val(obj.availability);
-
 
637
			},
-
 
638
			cache: false,
-
 
639
			processData: false
-
 
640
		});
-
 
641
	});
-
 
642
	
-
 
643
	//addToBagButton
-
 
644
	
-
 
645
	$("#addToBagButton").live('click', function() {
-
 
646
		var itemId = $(this).attr('data');
-
 
647
		var itemId = $("#bagModel .itemId").val();
-
 
648
		var tempAvailability = $("#bagModel .availability").val();
-
 
649
		var quantity = $("#bagModel .quantity").val();
-
 
650
		
-
 
651
		if (!quantity || parseInt(quantity) <= 0 || isNaN(parseInt(quantity)) || quantity.indexOf('.') != -1){
-
 
652
			alert("Please enter valid quantity");
-
 
653
			return;
-
 
654
		}
-
 
655
		
-
 
656
		jQuery.ajax({
-
 
657
			url: context+"/checkItemAvailability/?itemId="+itemId,
-
 
658
			type: 'GET',
-
 
659
			contentType:'application/json',
-
 
660
			async: false,
-
 
661
			success: function (data) {
-
 
662
				var obj = JSON.parse(data);
-
 
663
				console.log(obj);
-
 
664
				if (obj.availability < parseInt(quantity) || obj.availability == 0){
-
 
665
					alert("You don't have enough inventory of this item");
-
 
666
					return;
-
 
667
				}
-
 
668
				var obj = {'itemId':obj.itemId,'displayName':obj.displayName,'quantity':parseInt(quantity),'iconUrl':obj.iconUrl};
-
 
669
				console.log(obj);
-
 
670
				addItemInLocalStorage(obj);
-
 
671
				alert("Item added to bag successfully");
-
 
672
				$('#bagModel').modal('hide');
-
 
673
			},
-
 
674
			cache: false,
-
 
675
			processData: false
-
 
676
		});
-
 
677
	});
-
 
678
	
-
 
679
	$(".cart-trash").live('click',function(){
-
 
680
		var itemId = $(this).attr('data');
-
 
681
		removeItemFromLocalStorage(itemId);
-
 
682
		$('div[itemId="' + itemId + '"]').remove();
-
 
683
		if ($('#cart-details').html().trim() == ""){
-
 
684
			$('#cart-details-empty').show();
-
 
685
			$('#cart-checkout').hide();
-
 
686
		}
-
 
687
	});
-
 
688
	
-
 
689
	$(".cart-qty").live('change paste keyup mouseup', function() {
-
 
690
		var itemId = $(this).attr('data');
-
 
691
		var maxQty = $(this).attr('max');
-
 
692
		var qty = $(this).val();
-
 
693
		if (!qty){
-
 
694
			qty = 0;
-
 
695
		}
-
 
696
		if(parseInt(qty) < 0){
-
 
697
			alert("Invalid quantity");
-
 
698
			$(this).val(0);
-
 
699
			qty = 0;
-
 
700
		}
-
 
701
		if (parseInt(qty) > parseInt(maxQty)){
-
 
702
			alert("You don't have availability of "+qty);
-
 
703
			$(this).val(maxQty);
-
 
704
			qty = maxQty;
-
 
705
		}
-
 
706
		changeQuantityInLocalStorage(itemId, qty);
-
 
707
	});
-
 
708
	
-
 
709
	$("form#cd input.discountAmount").live('change paste keyup mouseup', function() {
-
 
710
		var discountAmount = parseFloat($(this).val());
-
 
711
		if (isNaN(discountAmount)){
-
 
712
			discountAmount = 0;
-
 
713
		}
-
 
714
		if(discountAmount < 0){
-
 
715
			alert("Invalid insurance Value");
-
 
716
			$(this).val(0);
-
 
717
		}
-
 
718
		calculateTotalAmount();
-
 
719
	});
-
 
720
	
-
 
721
	$("form#cd input.unitPrice").live('change paste keyup mouseup', function() {
-
 
722
		
-
 
723
		var unitPrice = parseFloat($(this).val());
-
 
724
		if (isNaN(unitPrice)){
-
 
725
			unitPrice = 0;
-
 
726
		}
-
 
727
		if(unitPrice < 0){
-
 
728
			alert("Invalid unit price");
-
 
729
			$(this).val(0);
-
 
730
		}
-
 
731
		
-
 
732
		calculateTotalAmount();
-
 
733
	});
-
 
734
	
-
 
735
	
-
 
736
	$("form#cd input.insuranceAmount").live('change paste keyup mouseup', function() {
-
 
737
		calculateTotalAmount();
-
 
738
	});
-
 
739
 
-
 
740
});
8
});
741
 
9
 
742
function calculateTotalAmount() {
10
function contactUs(domId){
743
	var netPayableAmount = 0;
-
 
744
	$("#cd").find('tr:gt(0)').each(function(index, el){
11
	doAjaxRequestHandler(context+"/contactUs", "GET", function(response){
745
		var rowTotal = 0;
-
 
746
		$tr = $(el);
-
 
747
 
-
 
748
		var insuranceAmount = $tr.find('.insuranceAmount').val();
-
 
749
		if (!insuranceAmount){
-
 
750
			insuranceAmount = 0;
-
 
751
		}else{
-
 
752
			insuranceAmount = parseFloat(insuranceAmount);
-
 
753
		}
-
 
754
		
-
 
755
		var qty = parseFloat($(el).find('.unitPrice').attr('quantity'));
-
 
756
		var unitPrice = parseFloat($(el).find('.unitPrice').val());
-
 
757
		
-
 
758
		var discountAmount =  parseFloat($(el).find('.discountAmount').val());
-
 
759
		if(isNaN(discountAmount)){
-
 
760
			discountAmount = 0;
-
 
761
		}
-
 
762
 
-
 
763
		rowTotal = unitPrice*qty + insuranceAmount - discountAmount; 
-
 
764
		$tr.find('.totalPrice').val(rowTotal);
12
		$('#' + domId).html(response);
765
		netPayableAmount += rowTotal;
-
 
766
	});
13
	});
767
	$('#cd').find('input.netPayableAmount').val(netPayableAmount);
-
 
768
}
-
 
769
 
-
 
770
function updateRetailerDocument(){
-
 
771
	//$("#updateRetailerShopDocument0").click( function() {
-
 
772
	console.log("Update Retailer Document Clicked");
-
 
773
	//console.log(ownerId);
-
 
774
	var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
-
 
775
	console.log("emailIdOrMobileNumber: "+ emailIdOrMobileNumber);
-
 
776
	var file = $('#retailerDocument')[0].files[0];
-
 
777
	console.log("file : "+file.name);
-
 
778
	uploadRetailerDocument("retailer-details-container", file, emailIdOrMobileNumber);
-
 
779
}
-
 
780
 
-
 
781
function updateRetailerShopDocument(ownerId){
-
 
782
	//$("#updateRetailerShopDocument0").click( function() {
-
 
783
	console.log("Update Retailer Shop Document Clicked");
-
 
784
	console.log(ownerId);
-
 
785
	var shopSize = parseInt($("#shopDetailsSize").attr('size'));
-
 
786
	console.log("size : "+shopSize);
-
 
787
	for(var index = 0; index < shopSize; index++){
-
 
788
		if("updateRetailerShopDocument"+index == ownerId){
-
 
789
			var emailIdOrMobileNumber = $('#retailer-details-search-text').val();
-
 
790
			console.log("emailIdOrMobileNumber: "+ emailIdOrMobileNumber);
-
 
791
			var shopId = $('#retailerShopDocument'+index).attr("shopId");
-
 
792
			console.log("shopId : "+shopId);
-
 
793
			var file = $('#retailerShopDocument'+index)[0].files[0];
-
 
794
			console.log("file : "+file.name);
-
 
795
			uploadRetailerShopDocument("retailer-details-container", file, emailIdOrMobileNumber, shopId);
-
 
796
		}
-
 
797
	}
-
 
798
}
-
 
799
 
-
 
800
function updateDetails(){
-
 
801
	
-
 
802
}
14
}
803
15