Subversion Repositories SmartDukaan

Rev

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

Rev 23855 Rev 24229
Line 50... Line 50...
50
		loadIndent("main-content");
50
		loadIndent("main-content");
51
	});
51
	});
52
	$("button.create_indent").live('click', function() {
52
	$("button.create_indent").live('click', function() {
53
		loadIndent("main-content");
53
		loadIndent("main-content");
54
	});
54
	});
-
 
55
	
55
	$("a.in_process_indent").live('click', function() {
56
	$("button.download_indent").live('click', function(){
56
		loadInprocessIndent("main-content");
57
		downloadIndent();
57
	});
58
	})
58
 
59
 
59
	$("#entire-catalog-table input").live({
60
	$("#entire-catalog-table input").live({
60
		change : function() {
61
		change : function() {
61
			var itemId = parseInt($(this).data("item-id"));
62
			var catalogId = parseInt($(this).data("catalog-id"));
62
			var sellingPrice = parseInt($(this).data("selling-price"));
63
			var sellingPrice = parseInt($(this).data("selling-price"));
63
			var quantity = parseInt($(this).val());
64
			var quantity = parseInt($(this).val());
64
			if (quantity > 10) {
65
			if (quantity > 10) {
65
				alert("Quantity should not be above 10");
66
				alert("Quantity should not be above 10");
66
				if (itemId in indentMap) {
67
				if (catalogId in indentMap) {
67
					$(this).val(indentMap[itemId].quantity);
68
					$(this).val(indentMap[catalogId].quantity);
68
				} else {
69
				} else {
69
					$(this).val(0);
70
					$(this).val(0);
70
				}
71
				}
71
				return;
72
				return;
72
			}
73
			}
73
			description = $(this).data("description");
74
			description = $(this).data("description");
74
			if (itemId in indentMap) {
75
			if (catalogId in indentMap) {
75
				indentMap[itemId]["quantity"] = quantity;
76
				indentMap[catalogId]["quantity"] = quantity;
76
				indentMap[itemId]["sellingPrice"] = sellingPrice;
77
				indentMap[catalogId]["sellingPrice"] = sellingPrice;
77
				indentMap[itemId]["description"] = description;
78
				indentMap[catalogId]["description"] = description;
78
				indentMap[itemId]["itemId"] = itemId;
79
				indentMap[catalogId]["catalogId"] = catalogId;
79
				indentMap[itemId]["diff"] =  quantity - indentMap[itemId]["initialQuantity"];
80
				indentMap[catalogId]["diff"] =  quantity - indentMap[catalogId]["initialQuantity"];
80
			} else {
81
			} else {
81
				indentMap[itemId] = {
82
				indentMap[catalogId] = {
82
					"quantity" : quantity,
83
					"quantity" : quantity,
83
					"sellingPrice" : sellingPrice,
84
					"sellingPrice" : sellingPrice,
84
					"description" : description,
85
					"description" : description,
85
					"itemId" : itemId,
86
					"catalogId" : catalogId,
86
					"initialQuantity" : 0,
87
					"initialQuantity" : 0,
87
					"diff" : quantity
88
					"diff" : quantity
88
				};
89
				};
89
			}
90
			}
90
			populateIndentSummary();
91
			populateIndentSummary();
91
			/*
-
 
92
			 * if ('timeout' in indentMap[itemId]) {
-
 
93
			 * clearTimeout(indentMap[itemId].timeout); } var somefunction=
-
 
94
			 * (function () { return function() { if(itemId in indentMap) {
-
 
95
			 * doAjaxRequestWithJsonHandler(context+"/indent-item/save", 'PUT',
-
 
96
			 * JSON.stringify(indentMap[itemId]), populateIndentSummary); } else {
-
 
97
			 * doAjaxRequestWithJsonHandler(context+"/indent-item/save", 'PUT',
-
 
98
			 * JSON.stringify({itemId:itemId, quantity:0}),
-
 
99
			 * populateIndentSummary); } }; })(); indentMap[itemId].timeout =
-
 
100
			 * setTimeout(somefunction, 1000);
-
 
101
			 */
-
 
102
 
-
 
103
		}
92
		}
104
	});
93
	});
105
	$("button.mk_submit_indent")
94
	$("button.mk_submit_indent")
106
			.live(
95
			.live(
107
					'click',
96
					'click',
108
					function() {
97
					function() {
109
						confirmString = [];
98
						confirmString = [];
110
						confirmString
99
						confirmString
111
								.push('<table class="table table-striped table-condensed table-bordered" id="entire-catalog-table">');
100
								.push('<table class="table table-striped table-condensed table-bordered" id="entire-catalog-table">');
112
						confirmString.push('<tr>');
101
						confirmString.push('<tr>');
113
						confirmString.push('<th style="width:100px">Item Id</th>');
102
						confirmString.push('<th style="width:100px">Catalog Id</th>');
114
						confirmString.push('<th style="width:250px">Description</th>');
103
						confirmString.push('<th style="width:250px">Description</th>');
115
						confirmString.push('<th style="width:150px">Unit Price</th>');
104
						confirmString.push('<th style="width:150px">Unit Price</th>');
116
						confirmString.push('<th style="width:150px">Quantity</th>');
105
						confirmString.push('<th style="width:150px">Quantity</th>');
117
						confirmString.push('<th style="width:200px">Item total</th>');
106
						confirmString.push('<th style="width:200px">Item total</th>');
118
						confirmString.push('</tr>');
107
						confirmString.push('</tr>');
Line 173... Line 162...
173
					});
162
					});
174
	$("button.confirm_indent").live(
163
	$("button.confirm_indent").live(
175
			'click',
164
			'click',
176
			function() {
165
			function() {
177
				var itemQtyList = [];
166
				var itemQtyList = [];
178
				for (itemId in indentMap) {
167
				for (catalogId in indentMap) {
179
					diff = indentMap[itemId]["quantity"] - indentMap[itemId]["initialQuantity"];
168
					diff = indentMap[catalogId]["quantity"] - indentMap[catalogId]["initialQuantity"];
180
					if(diff!=0) {
169
					if(diff!=0) {
181
						itemQtyList.push({
170
						itemQtyList.push({
182
							"quantity" : indentMap[itemId]["quantity"],
171
							"quantity" : indentMap[catalogId]["quantity"],
183
							"itemId" : indentMap[itemId]["itemId"]
172
							"catalogId" : indentMap[catalogId]["catalogId"]
184
						});
173
						});
185
					}
174
					}
186
				}
175
				}
187
				doPostAjaxRequestWithJsonHandler(context + "/open-indent/save?fofoId=" + currentFofoId + "&counterSize=" + counterSize,
176
				doPostAjaxRequestWithJsonHandler(context + "/open-indent/save?fofoId=" + currentFofoId + "&counterSize=" + counterSize,
188
						JSON.stringify(itemQtyList), function(data) {
177
						JSON.stringify(itemQtyList), function(data) {
Line 260... Line 249...
260
	var url = "/indent/loadIndent?fofoId=" + currentFofoId + "&counterSize=" + counterSize;
249
	var url = "/indent/loadIndent?fofoId=" + currentFofoId + "&counterSize=" + counterSize;
261
	doAjaxRequestHandler(context + url, "GET", function(response) {
250
	doAjaxRequestHandler(context + url, "GET", function(response) {
262
		$('#' + domId).html(response);
251
		$('#' + domId).html(response);
263
	});
252
	});
264
}
253
}
265
function loadInprocessIndent(domId) {
254
function downloadIndent() {
266
	doAjaxRequestHandler(context + "/indent/inProcess", "GET", function(
255
	var url = "/indent/download?fofoId=" + currentFofoId + "&counterSize=" + counterSize;
267
			response) {
-
 
268
		$('#' + domId).html(response);
256
	doAjaxGetDownload(url, "indent.csv")
269
	});
-
 
270
}
257
}
271
function raisePO(){
258
function raisePO(){
272
	doPostAjaxRequestWithJsonHandler(context+"/indent/create-po", {}, function(response) {
259
	doPostAjaxRequestWithJsonHandler(context+"/indent/create-po", {}, function(response) {
273
		if(response) {
260
		if(response) {
274
			alert("PO Created Successfully");
261
			alert("PO Created Successfully");