Subversion Repositories SmartDukaan

Rev

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