Subversion Repositories SmartDukaan

Rev

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

Rev 23405 Rev 23772
Line 28... Line 28...
28
					indentMap[itemId]["description"] = description; 
28
					indentMap[itemId]["description"] = description; 
29
					indentMap[itemId]["itemId"] = itemId;
29
					indentMap[itemId]["itemId"] = itemId;
30
				} else {
30
				} else {
31
					indentMap[itemId] = {"quantity": quantity, "sellingPrice":sellingPrice, "description":description, "itemId":itemId};
31
					indentMap[itemId] = {"quantity": quantity, "sellingPrice":sellingPrice, "description":description, "itemId":itemId};
32
				}
32
				}
-
 
33
				populateIndentSummary();
33
				if ('timeout' in indentMap[itemId]) {
34
				/*if ('timeout' in indentMap[itemId]) {
34
					clearTimeout(indentMap[itemId].timeout);
35
					clearTimeout(indentMap[itemId].timeout);
35
				}
36
				}
36
				var somefunction= (function () {
37
				var somefunction= (function () {
37
				    return function() {
38
				    return function() {
38
				    	if(itemId in indentMap) {
39
				    	if(itemId in indentMap) {
Line 40... Line 41...
40
				    	} else {
41
				    	} else {
41
				    		doAjaxRequestWithJsonHandler(context+"/indent-item/save", 'PUT', JSON.stringify({itemId:itemId, quantity:0}), populateIndentSummary);
42
				    		doAjaxRequestWithJsonHandler(context+"/indent-item/save", 'PUT', JSON.stringify({itemId:itemId, quantity:0}), populateIndentSummary);
42
				    	}
43
				    	}
43
				    };
44
				    };
44
				})();
45
				})();
45
				indentMap[itemId].timeout = setTimeout(somefunction, 1000);
46
				indentMap[itemId].timeout = setTimeout(somefunction, 1000);*/
46
				
47
				
47
			}
48
			}
48
		}
49
		}
49
	);
50
	);
50
	$("button.mk_submit_indent").live('click', function(){
51
	$("button.mk_submit_indent").live('click', function(){
Line 74... Line 75...
74
		$('button.mk_submit_indent').hide();
75
		$('button.mk_submit_indent').hide();
75
		$('button.bk_toedit_indent').show();
76
		$('button.bk_toedit_indent').show();
76
		$('button.confirm_indent').show();
77
		$('button.confirm_indent').show();
77
	});
78
	});
78
	$("button.confirm_indent").live('click', function(){
79
	$("button.confirm_indent").live('click', function(){
-
 
80
		var itemQtyList = [];
-
 
81
		for(itemId in indentMap) {
-
 
82
			itemQtyList.push({"quantity":indentMap[itemId]["quantity"], "itemId": indentMap[itemId]["itemId"]});
-
 
83
		}
79
		doAjaxRequestHandler(context+"/open-indent/save", 'PUT', function(data){
84
		doPostAjaxRequestWithJsonHandler(context+"/open-indent/save", JSON.stringify(itemQtyList), function(data){
80
			alert('Indent has been created Successfully!');
85
			alert('Indent has been created Successfully!');
81
			indentMap={};
86
			indentMap={};
82
			$('a.in_process_indent').click();
87
			loadIndent('main-content');
83
		});
88
		});
84
	});
89
	});
85
	$("button.bk_toedit_indent").live('click', function(){
90
	$("button.bk_toedit_indent").live('click', function(){
86
		$('button.bk_toedit_indent').hide();
91
		$('button.bk_toedit_indent').hide();
87
		$('button.confirm_indent').hide();
92
		$('button.confirm_indent').hide();
Line 95... Line 100...
95
 
100
 
96
function populateIndentSummary(){
101
function populateIndentSummary(){
97
	var totalQty=0;
102
	var totalQty=0;
98
	var totalAmount = 0;
103
	var totalAmount = 0;
99
	var totalItems = 0;
104
	var totalItems = 0;
-
 
105
	var diffAmount = 0;
-
 
106
	var diffPcs = 0;
100
	for (var itemId in indentMap) {
107
	for (var itemId in indentMap) {
101
		if(indentMap[itemId]['quantity'] > 0){
108
		if(indentMap[itemId]['quantity'] > 0){
102
			totalQty += indentMap[itemId]['quantity'];  
109
			totalQty += indentMap[itemId]['quantity'];  
103
			totalAmount += indentMap[itemId]['sellingPrice']*indentMap[itemId]['quantity'];  
110
			totalAmount += indentMap[itemId]['sellingPrice']*indentMap[itemId]['quantity'];  
104
			totalItems++;
111
			totalItems++;
-
 
112
			if(indentMap['quantity'] - indentMap['previousQuantity'] != 0) {
-
 
113
				if (indentMap['quantity'] - indentMap['previousQuantity'] > 0) {
-
 
114
					
-
 
115
				} else {
-
 
116
					
-
 
117
				}
-
 
118
			}
105
		} else {
119
		} else {
106
			delete(indentMap[itemId]);
120
			delete(indentMap[itemId]);
107
		}
121
		}
108
	}
122
	}
109
	if(totalQty===0){
123
	if(totalQty===0){