Subversion Repositories SmartDukaan

Rev

Rev 27251 | Rev 27755 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
26846 tejbeer 1
$(function() {
27754 amit.gupta 2
	$(document).on('click', ".partner-po", function() {
26846 tejbeer 3
		loadCreatePo("main-content");
4
	});
5
 
6
	$(".partner-item-detail").live(
7
			'click',
8
			function() {
9
				var fofoId = $('#fofo-users').val();
10
 
11
				var url = "/getPartnerloadContent?fofoId=" + fofoId
12
						+ "&counterSize=" + "TEN_LAC";
13
				doAjaxRequestHandler(context + url, "GET", function(response) {
14
					{
15
					}
16
 
17
					$('.partner-po-container').html(response);
18
				});
19
			});
20
 
21
	$(".selectItemQty").live(
22
			"click",
23
			function() {
24
				var catalogId = parseInt($(this).data("catalog-id"));
25
				doGetAjaxRequestHandler(context + "/selectItemColor?catalogId="
26
						+ catalogId, function(response) {
27251 tejbeer 27
 
26846 tejbeer 28
					$('.select-item-container .modal-content').html(response);
27251 tejbeer 29
					$('#select-item-table').find('tr').each(function() {
30
						var selectRow = $(this);
31
						var selectCurrentRow = $(this).closest("tr");
32
						var itemId = selectCurrentRow.find("td:eq(1)").html();
33
						console.log(itemId)
34
						if (itemId != undefined) {
35
							$('#po-table').find('tr').each(function() {
36
								var row = $(this);
37
								var currentRow = $(this).closest("tr");
38
								var item = currentRow.find("td:eq(0)").html();
39
								if (item != undefined) {
40
									console.log(item)
41
									if (item == itemId) {
42
										selectCurrentRow.remove();
43
									}
26846 tejbeer 44
 
27251 tejbeer 45
								}
46
 
47
							});
48
						}
49
 
50
					});
26846 tejbeer 51
				});
52
 
53
			});
27754 amit.gupta 54
	$(document).on('click', ".btnDelete", function() {
26846 tejbeer 55
		console.log("Hello");
56
 
57
		$(this).closest("tr").remove();
58
 
59
	});
60
 
61
	$(".submit-item")
62
			.live(
63
					"click",
64
					function(e) {
65
						var seletedIds;
66
						var seletedIdsJson = [];
67
 
68
						$('#select-item-table').find('tr').each(
69
								function() {
70
									var row = $(this);
71
 
72
									console.log(row);
73
									if (row.find('input[type="checkbox"]').is(
74
											':checked')) {
75
										var currentRow = $(this).closest("tr");
76
 
77
										var itemId = currentRow
78
												.find("td:eq(1)").html();
79
										var name = currentRow.find("td:eq(2)")
80
												.html();
81
										var quantity = currentRow.find(
82
												"td:eq(3) input").val();
83
										console.log(quantity)
84
										if (quantity == "") {
85
											alert("Select the Quantity");
86
											return false;
87
 
88
										}
89
 
90
										seletedIds = {
91
											"itemId" : itemId,
92
											"name" : name,
93
											"qty" : quantity
94
										}
95
										seletedIdsJson.push(seletedIds)
96
 
97
									}
98
 
99
								});
100
 
101
						console.log(seletedIdsJson);
102
 
103
						for (let i = 0; i < seletedIdsJson.length; i++) {
104
							console.log(seletedIdsJson[i].itemId)
105
 
106
							markup = "<tr><td>"
107
									+ seletedIdsJson[i].itemId
108
									+ "</td><td>"
109
									+ seletedIdsJson[i].name
110
									+ "</td><td>"
111
									+ seletedIdsJson[i].qty
112
									+ "</td><td><button type = 'button' class='btnDelete'>Delete</button></td></tr>";
113
							$('#po-table > tbody:last-child').append(markup);
114
						}
115
 
116
						$("#selectItem").modal("hide");
117
					});
118
 
119
	$(".confirm_po").live(
120
			'click',
121
			function() {
122
				var jsonObject = {};
123
				var poIdsJSon = [];
124
				var poIds;
125
				var fofoId = $('#fofo-users').val();
126
 
127
				$('#po-table').find('tr').each(function() {
128
					var row = $(this);
129
 
130
					console.log(row);
131
					var currentRow = $(this).closest("tr");
132
 
133
					var itemId = currentRow.find("td:eq(0)").html();
134
					var qty = currentRow.find("td:eq(2)").html();
135
 
136
					console.log(itemId);
137
					if (itemId != undefined) {
138
						poIds = {
139
							"itemId" : itemId,
140
							"qty" : qty
141
 
142
						}
143
						console.log(poIds);
144
						poIdsJSon.push(poIds);
145
					}
146
				});
147
 
148
				console.log(poIdsJSon)
149
				console.log(fofoId)
150
				if (fofoId == null) {
151
					alert("fofoId is required");
152
					return false;
153
				}
154
				if (poIdsJSon.length === 0) {
155
					alert("Atleast one Item selected");
156
					return false;
157
				}
158
 
159
				jsonObject['poIds'] = poIdsJSon;
160
				jsonObject['fofoId'] = fofoId;
161
				console.log(jsonObject)
162
 
163
				if (confirm("Are you sure you want to create po") == true) {
164
 
165
					doPostAjaxRequestWithJsonHandler(context + "/createPo",
166
							JSON.stringify(jsonObject), function(response) {
167
								if (response == 'true') {
168
									alert("successfully create");
169
 
170
									loadCreatePo("main-content");
171
								}
172
							});
173
				}
174
 
175
			});
176
 
177
});
178
 
179
function loadCreatePo(domId) {
180
	doGetAjaxRequestHandler(context + "/partnerPendingOrder",
181
			function(response) {
182
				$('#' + domId).html(response);
183
			});
184
}