Subversion Repositories SmartDukaan

Rev

Rev 27251 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
26846 tejbeer 1
$(function() {
2
	$(".partner-po").live('click', function() {
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) {
27
					$('.select-item-container .modal-content').html(response);
28
 
29
				});
30
 
31
			});
32
	$(".btnDelete").live('click', function() {
33
		console.log("Hello");
34
 
35
		$(this).closest("tr").remove();
36
 
37
	});
38
 
39
	$(".submit-item")
40
			.live(
41
					"click",
42
					function(e) {
43
						var seletedIds;
44
						var seletedIdsJson = [];
45
 
46
						$('#select-item-table').find('tr').each(
47
								function() {
48
									var row = $(this);
49
 
50
									console.log(row);
51
									if (row.find('input[type="checkbox"]').is(
52
											':checked')) {
53
										var currentRow = $(this).closest("tr");
54
 
55
										var itemId = currentRow
56
												.find("td:eq(1)").html();
57
										var name = currentRow.find("td:eq(2)")
58
												.html();
59
										var quantity = currentRow.find(
60
												"td:eq(3) input").val();
61
										console.log(quantity)
62
										if (quantity == "") {
63
											alert("Select the Quantity");
64
											return false;
65
 
66
										}
67
 
68
										seletedIds = {
69
											"itemId" : itemId,
70
											"name" : name,
71
											"qty" : quantity
72
										}
73
										seletedIdsJson.push(seletedIds)
74
 
75
									}
76
 
77
								});
78
 
79
						console.log(seletedIdsJson);
80
 
81
						for (let i = 0; i < seletedIdsJson.length; i++) {
82
							console.log(seletedIdsJson[i].itemId)
83
 
84
							markup = "<tr><td>"
85
									+ seletedIdsJson[i].itemId
86
									+ "</td><td>"
87
									+ seletedIdsJson[i].name
88
									+ "</td><td>"
89
									+ seletedIdsJson[i].qty
90
									+ "</td><td><button type = 'button' class='btnDelete'>Delete</button></td></tr>";
91
							$('#po-table > tbody:last-child').append(markup);
92
						}
93
 
94
						$("#selectItem").modal("hide");
95
					});
96
 
97
	$(".confirm_po").live(
98
			'click',
99
			function() {
100
				var jsonObject = {};
101
				var poIdsJSon = [];
102
				var poIds;
103
				var fofoId = $('#fofo-users').val();
104
 
105
				$('#po-table').find('tr').each(function() {
106
					var row = $(this);
107
 
108
					console.log(row);
109
					var currentRow = $(this).closest("tr");
110
 
111
					var itemId = currentRow.find("td:eq(0)").html();
112
					var qty = currentRow.find("td:eq(2)").html();
113
 
114
					console.log(itemId);
115
					if (itemId != undefined) {
116
						poIds = {
117
							"itemId" : itemId,
118
							"qty" : qty
119
 
120
						}
121
						console.log(poIds);
122
						poIdsJSon.push(poIds);
123
					}
124
				});
125
 
126
				console.log(poIdsJSon)
127
				console.log(fofoId)
128
				if (fofoId == null) {
129
					alert("fofoId is required");
130
					return false;
131
				}
132
				if (poIdsJSon.length === 0) {
133
					alert("Atleast one Item selected");
134
					return false;
135
				}
136
 
137
				jsonObject['poIds'] = poIdsJSon;
138
				jsonObject['fofoId'] = fofoId;
139
				console.log(jsonObject)
140
 
141
				if (confirm("Are you sure you want to create po") == true) {
142
 
143
					doPostAjaxRequestWithJsonHandler(context + "/createPo",
144
							JSON.stringify(jsonObject), function(response) {
145
								if (response == 'true') {
146
									alert("successfully create");
147
 
148
									loadCreatePo("main-content");
149
								}
150
							});
151
				}
152
 
153
			});
154
 
155
});
156
 
157
function loadCreatePo(domId) {
158
	doGetAjaxRequestHandler(context + "/partnerPendingOrder",
159
			function(response) {
160
				$('#' + domId).html(response);
161
			});
162
}