Subversion Repositories SmartDukaan

Rev

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

Rev 22860 Rev 22956
Line 17... Line 17...
17
    });
17
    });
18
    attachSignin(document.getElementById('customBtn'));
18
    attachSignin(document.getElementById('customBtn'));
19
  });
19
  });
20
};
20
};
21
 
21
 
-
 
22
function badRequestAlert(response){
-
 
23
	console.log(response.responseText);
-
 
24
	var errorObject = JSON.parse(response.responseText);
-
 
25
	errorObject = errorObject.response;
-
 
26
	alert('Bad Request\n'+
-
 
27
			'rejectedType : '+errorObject.rejectedType+'\n'+
-
 
28
			'rejectedValue : '+errorObject.rejectedValue+'\n'+
-
 
29
			'message : '+errorObject.message);
-
 
30
}
-
 
31
 
-
 
32
function internalServerErrorAlert(response){
-
 
33
	console.log(response.responseText);
-
 
34
	var errorObject = JSON.parse(response.responseText);
-
 
35
	errorObject = errorObject.response;
-
 
36
	alert('Internal Server Error\n'+
-
 
37
		'rejectedType : '+errorObject.rejectedType+'\n'+
-
 
38
		'rejectedValue : '+errorObject.rejectedValue+'\n'+
-
 
39
		'message : '+errorObject.message);
-
 
40
}
-
 
41
 
-
 
42
$( document ).ajaxError(function(event, jqxhr, settings, thrownError) {
-
 
43
	//$( ".log" ).text( "Triggered ajaxError handler." );
-
 
44
	if(jqxhr.status == 400){
-
 
45
		$('#error-prompt-model').modal();
-
 
46
		badRequestAlert(jqxhr);	
-
 
47
	}else{
-
 
48
		internalServerErrorAlert(jqxhr);
-
 
49
	}
-
 
50
});
-
 
51
 
22
function attachSignin(element) {
52
function attachSignin(element) {
23
    console.log(element.id);
53
    console.log(element.id);
24
    auth2.attachClickHandler(element, {},
54
    auth2.attachClickHandler(element, {},
25
        function(googleUser) {
55
        function(googleUser) {
26
    		googleProfile = googleUser.getBasicProfile();
56
    		googleProfile = googleUser.getBasicProfile();
Line 90... Line 120...
90
        processData: false,
120
        processData: false,
91
        async: false,
121
        async: false,
92
        data : JSON.stringify([5,15,30,45]),
122
        data : JSON.stringify([5,15,30,45]),
93
        success : function(response) {
123
        success : function(response) {
94
            $('#' + domId).html(response);
124
            $('#' + domId).html(response);
95
        },
125
        }
96
        error : function() {
-
 
97
			alert("OOPS!!!Failed to do changes.Try Again.",'ERROR');
-
 
98
		},
-
 
99
    });  
126
    });  
100
}
127
}
101
 
128
 
102
function downloadAgingReport(){
129
function downloadAgingReport(){
103
	data = JSON.stringify([5,15,30,45]),
130
	data = JSON.stringify([5,15,30,45]),
Line 112... Line 139...
112
	        a.download = "InventoryItemAging.xlsx";
139
	        a.download = "InventoryItemAging.xlsx";
113
	        a.style.display = 'none';
140
	        a.style.display = 'none';
114
	        document.body.appendChild(a);
141
	        document.body.appendChild(a);
115
	        a.click();
142
	        a.click();
116
	    }
143
	    }
-
 
144
	    if(xhttp.readyState == 4 && xhttp.status === 400){
-
 
145
	    	badRequestAlert(xhttp.responseText);
-
 
146
	    }
-
 
147
	    if(xhttp.readyState == 4 && xhttp.status === 500){
-
 
148
	    	internalServerErrorAlert(xhttp.responseText);
-
 
149
	    }
117
	};
150
	};
118
	// Post data to URL which handles post request
151
	// Post data to URL which handles post request
119
	xhttp.open("POST", context+"/getInventoryItemAgingByInterval");
152
	xhttp.open("POST", context+"/getInventoryItemAgingByInterval");
120
	xhttp.setRequestHeader("Content-Type", "application/json");
153
	xhttp.setRequestHeader("Content-Type", "application/json");
121
	// You should set responseType as blob for binary responses
154
	// You should set responseType as blob for binary responses
Line 136... Line 169...
136
	        a.download = "ItemCompleteLedegerReport.xlsx";
169
	        a.download = "ItemCompleteLedegerReport.xlsx";
137
	        a.style.display = 'none';
170
	        a.style.display = 'none';
138
	        document.body.appendChild(a);
171
	        document.body.appendChild(a);
139
	        a.click();
172
	        a.click();
140
	    }
173
	    }
-
 
174
	    if(xhttp.readyState == 4 && xhttp.status === 400){
-
 
175
	    	badRequestAlert(xhttp.responseText);
-
 
176
	    }
-
 
177
	    if(xhttp.readyState == 4 && xhttp.status === 500){
-
 
178
	    	internalServerErrorAlert(xhttp.responseText);
-
 
179
	    }
141
	};
180
	};
142
	// Post data to URL which handles post request
181
	// Post data to URL which handles post request
143
	xhttp.open("GET", context+"/itemLedger/complete/download");
182
	xhttp.open("GET", context+"/itemLedger/complete/download");
144
	//xhttp.setRequestHeader("Content-Type", "application/json");
183
	//xhttp.setRequestHeader("Content-Type", "application/json");
145
	// You should set responseType as blob for binary responses
184
	// You should set responseType as blob for binary responses
Line 163... Line 202...
163
        complete: function(){
202
        complete: function(){
164
        	//$('#ajax-spinner').hide();
203
        	//$('#ajax-spinner').hide();
165
        },
204
        },
166
        success : function(response) {
205
        success : function(response) {
167
        	$('#main-content').html(response);
206
        	$('#main-content').html(response);
168
        },
207
        }
169
		error : function() {
-
 
170
			alert("Unable to fetch items");
-
 
171
		 },
-
 
172
    });
208
    });
173
}
209
}
174
 
210
 
175
function getGrnHistoryPreviousItems(start,end,pre,purchase_reference, searchType,startTime,endTime){
211
function getGrnHistoryPreviousItems(start,end,pre,purchase_reference, searchType,startTime,endTime){
176
	jQuery.ajax({
212
	jQuery.ajax({
Line 192... Line 228...
192
				if (parseInt(pre)==0)
228
				if (parseInt(pre)==0)
193
				{
229
				{
194
					$("#grn-history-paginated .previous").prop('disabled', true);
230
					$("#grn-history-paginated .previous").prop('disabled', true);
195
				}
231
				}
196
				
232
				
197
	        },
233
	        }
198
			error : function() {
-
 
199
				alert("Unable to fetch items");
-
 
200
			 },
-
 
201
	    });
234
	    });
202
}
235
}
203
 
236
 
204
function loadBadInventory(domId, search_text){
237
function loadBadInventory(domId, search_text){
205
	jQuery.ajax({
238
	jQuery.ajax({
Line 222... Line 255...
222
        }
255
        }
223
    });  
256
    });  
224
}
257
}
225
 
258
 
226
 
259
 
227
 
-
 
228
 
-
 
229
 
-
 
230
function getNextItems(start, end, searchText){
260
function getNextItems(start, end, searchText){
231
	console.log(start);
261
	console.log(start);
232
	console.log(end);
262
	console.log(end);
233
	console.log(+end + +10);
263
	console.log(+end + +10);
234
	console.log(+start + +10);
264
	console.log(+start + +10);
Line 250... Line 280...
250
					$("#good-inventory-paginated .next").prop('disabled', true);
280
					$("#good-inventory-paginated .next").prop('disabled', true);
251
					//$( "#good-inventory-paginated .end" ).text(temp);
281
					//$( "#good-inventory-paginated .end" ).text(temp);
252
				}
282
				}
253
	            $('#good-inventory-table').html(response);
283
	            $('#good-inventory-table').html(response);
254
	            $("#good-inventory-paginated .previous").prop('disabled', false);
284
	            $("#good-inventory-paginated .previous").prop('disabled', false);
255
	        },
285
	        }
256
			error : function() {
-
 
257
				alert("Unable to fetch items");
-
 
258
			 },
-
 
259
	    });  
286
	    });  
260
	}
287
	}
261
function getPreviousItems(start,end,pre,searchText){
288
function getPreviousItems(start,end,pre,searchText){
262
	jQuery.ajax({
289
	jQuery.ajax({
263
	        type : "GET",
290
	        type : "GET",
Line 276... Line 303...
276
				if (parseInt(pre)==0)
303
				if (parseInt(pre)==0)
277
				{
304
				{
278
					$("#good-inventory-paginated .previous").prop('disabled', true);
305
					$("#good-inventory-paginated .previous").prop('disabled', true);
279
				}
306
				}
280
				
307
				
281
	        },
308
	        }
282
			error : function() {
-
 
283
				alert("Unable to fetch items");
-
 
284
			 },
-
 
285
	    });
309
	    });
286
}
310
}
287
 
311
 
288
function getGrnHistoryNextItems(start, end, purchase_reference, searchType,startTime,endTime){
312
function getGrnHistoryNextItems(start, end, purchase_reference, searchType,startTime,endTime){
289
	console.log(start);
313
	console.log(start);
Line 310... Line 334...
310
					$("#grn-history-paginated .next").prop('disabled', true);
334
					$("#grn-history-paginated .next").prop('disabled', true);
311
					//$( "#good-inventory-paginated .end" ).text(temp);
335
					//$( "#good-inventory-paginated .end" ).text(temp);
312
				}
336
				}
313
	            $('#grn-history-table').html(response);
337
	            $('#grn-history-table').html(response);
314
	            $("#grn-history-paginated .previous").prop('disabled', false);
338
	            $("#grn-history-paginated .previous").prop('disabled', false);
315
	        },
339
	        }
316
			error : function() {
-
 
317
				alert("Unable to fetch items");
-
 
318
			},
-
 
319
	    });  
340
	    });  
320
	}
341
	}
321
function getGrnHistoryPreviousItems(start,end,pre,purchase_reference, searchType,startTime,endTime){
342
function getGrnHistoryPreviousItems(start,end,pre,purchase_reference, searchType,startTime,endTime){
322
	jQuery.ajax({
343
	jQuery.ajax({
323
	        type : "GET",
344
	        type : "GET",
Line 338... Line 359...
338
				if (parseInt(pre)==0)
359
				if (parseInt(pre)==0)
339
				{
360
				{
340
					$("#grn-history-paginated .previous").prop('disabled', true);
361
					$("#grn-history-paginated .previous").prop('disabled', true);
341
				}
362
				}
342
				
363
				
343
	        },
364
	        }
344
			error : function() {
-
 
345
				alert("Unable to fetch items");
-
 
346
			 },
-
 
347
	    });
365
	    });
348
}
366
}
349
 
367
 
350
function getSaleHistoryNextItems(start, end, invoiceNumber, searchType, startTime, endTime){
368
function getSaleHistoryNextItems(start, end, invoiceNumber, searchType, startTime, endTime){
351
	console.log(start);
369
	console.log(start);
Line 372... Line 390...
372
					$("#sale-history-paginated .next").prop('disabled', true);
390
					$("#sale-history-paginated .next").prop('disabled', true);
373
					//$( "#good-inventory-paginated .end" ).text(temp);
391
					//$( "#good-inventory-paginated .end" ).text(temp);
374
				}
392
				}
375
	            $('#sale-history-table').html(response);
393
	            $('#sale-history-table').html(response);
376
	            $("#sale-history-paginated .previous").prop('disabled', false);
394
	            $("#sale-history-paginated .previous").prop('disabled', false);
377
	        },
395
	        }
378
			error : function() {
-
 
379
				alert("Unable to fetch items");
-
 
380
			 },
-
 
381
	    });  
396
	    });  
382
	}
397
	}
383
function getSaleHistoryPreviousItems(start, end, pre, invoiceNumber, searchType,startTime,endTime){
398
function getSaleHistoryPreviousItems(start, end, pre, invoiceNumber, searchType,startTime,endTime){
384
	jQuery.ajax({
399
	jQuery.ajax({
385
	        type : "GET",
400
	        type : "GET",
Line 399... Line 414...
399
	        	$("#sale-history-paginated .next").prop('disabled', false);
414
	        	$("#sale-history-paginated .next").prop('disabled', false);
400
				if (parseInt(pre)==0)
415
				if (parseInt(pre)==0)
401
				{
416
				{
402
					$("#sale-history-paginated .previous").prop('disabled', true);
417
					$("#sale-history-paginated .previous").prop('disabled', true);
403
				}
418
				}
404
	        },
419
	        }
405
			error : function() {
-
 
406
				alert("Unable to fetch items");
-
 
407
			 },
-
 
408
	    });
420
	    });
409
}
421
}
410
 
422
 
411
 
423
 
412
function getSchemesNextItems(start, end){
424
function getSchemesNextItems(start, end){
Line 433... Line 445...
433
					//$( "#good-inventory-paginated .end" ).text(temp);
445
					//$( "#good-inventory-paginated .end" ).text(temp);
434
				}
446
				}
435
	            $('#schemes-table').html(response);
447
	            $('#schemes-table').html(response);
436
	            $('#scheme-details-container').html('');
448
	            $('#scheme-details-container').html('');
437
	            $("#schemes-paginated .previous").prop('disabled', false);
449
	            $("#schemes-paginated .previous").prop('disabled', false);
438
	        },
450
	        }
439
			error : function() {
-
 
440
				alert("Unable to fetch items");
-
 
441
			 },
-
 
442
	    });  
451
	    });  
443
	}
452
	}
444
 
453
 
445
 
454
 
446
function getSchemesPreviousItems(start, end, pre){
455
function getSchemesPreviousItems(start, end, pre){
Line 461... Line 470...
461
	        	$("#schemes-paginated .next").prop('disabled', false);
470
	        	$("#schemes-paginated .next").prop('disabled', false);
462
				if (parseInt(pre)==0)
471
				if (parseInt(pre)==0)
463
				{
472
				{
464
					$("#schemes-paginated .previous").prop('disabled', true);
473
					$("#schemes-paginated .previous").prop('disabled', true);
465
				}
474
				}
466
	        },
475
	        }
467
			error : function() {
-
 
468
				alert("Unable to fetch items");
-
 
469
			 },
-
 
470
	    });
476
	    });
471
}
477
}
472
 
478
 
473
 
479
 
474
 
480
 
Line 496... Line 502...
496
					$("#wallet-history-paginated .next").prop('disabled', true);
502
					$("#wallet-history-paginated .next").prop('disabled', true);
497
					//$( "#good-inventory-paginated .end" ).text(temp);
503
					//$( "#good-inventory-paginated .end" ).text(temp);
498
				}
504
				}
499
	            $('#wallet-history-table').html(response);
505
	            $('#wallet-history-table').html(response);
500
	            $("#wallet-history-paginated .previous").prop('disabled', false);
506
	            $("#wallet-history-paginated .previous").prop('disabled', false);
501
	        },
507
	        }
502
			error : function() {
-
 
503
				alert("Unable to fetch items");
-
 
504
			 },
-
 
505
	    });  
508
	    });  
506
	}
509
	}
507
function getWalletHistoryPreviousItems(start, end, pre, startTime, endTime){
510
function getWalletHistoryPreviousItems(start, end, pre, startTime, endTime){
508
	jQuery.ajax({
511
	jQuery.ajax({
509
	        type : "GET",
512
	        type : "GET",
Line 522... Line 525...
522
	        	$("#wallet-history-paginated .next").prop('disabled', false);
525
	        	$("#wallet-history-paginated .next").prop('disabled', false);
523
				if (parseInt(pre)==0)
526
				if (parseInt(pre)==0)
524
				{
527
				{
525
					$("#wallet-history-paginated .previous").prop('disabled', true);
528
					$("#wallet-history-paginated .previous").prop('disabled', true);
526
				}
529
				}
527
	        },
530
	        }
528
			error : function() {
-
 
529
				alert("Unable to fetch items");
-
 
530
			 },
-
 
531
	    });
531
	    });
532
}
532
}
533
 
533
 
534
function loadGoodInventorySearchInfo(search_text){
534
function loadGoodInventorySearchInfo(search_text){
535
	loadGoodInventory("main-content",search_text);
535
	loadGoodInventory("main-content",search_text);
Line 607... Line 607...
607
		type: 'POST',
607
		type: 'POST',
608
		async: false,
608
		async: false,
609
		success: function (data) {
609
		success: function (data) {
610
			$('#'+domId).html(data);
610
			$('#'+domId).html(data);
611
		},
611
		},
612
		error : function() {
-
 
613
			alert("OOPS!!!Failed to do changes.Try Again.",'ERROR');
-
 
614
		},
-
 
615
		cache: false,
612
		cache: false,
616
		contentType: false,
613
		contentType: false,
617
		processData: false
614
		processData: false
618
	});
615
	});
619
}
616
}
Line 640... Line 637...
640
				if (parseInt(last) >= parseInt(temp)){
637
				if (parseInt(last) >= parseInt(temp)){
641
					$("#catalog-paginated .next").prop('disabled', true);
638
					$("#catalog-paginated .next").prop('disabled', true);
642
				}
639
				}
643
	            $('#catalog-table').html(response);
640
	            $('#catalog-table').html(response);
644
	            $("#catalog-paginated .previous").prop('disabled', false);
641
	            $("#catalog-paginated .previous").prop('disabled', false);
645
	        },
642
	        }
646
			error : function() {
-
 
647
				alert("Unable to fetch items");
-
 
648
			 },
-
 
649
	    });  
643
	    });  
650
	}
644
	}
651
function getPreviousCatalogItems(start,end,pre,searchText){
645
function getPreviousCatalogItems(start,end,pre,searchText){
652
	jQuery.ajax({
646
	jQuery.ajax({
653
	        type : "GET",
647
	        type : "GET",
Line 666... Line 660...
666
				if (parseInt(pre)==0)
660
				if (parseInt(pre)==0)
667
				{
661
				{
668
					$("#catalog-paginated .previous").prop('disabled', true);
662
					$("#catalog-paginated .previous").prop('disabled', true);
669
				}
663
				}
670
				
664
				
671
	        },
665
	        }
672
			error : function() {
-
 
673
				alert("Unable to fetch items");
-
 
674
			 },
-
 
675
	    });
666
	    });
676
}
667
}
677
 
668
 
678
function loadCatalogSearchInfo(search_text){
669
function loadCatalogSearchInfo(search_text){
679
	loadCatalog("main-content",search_text);
670
	loadCatalog("main-content",search_text);