Subversion Repositories SmartDukaan

Rev

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

Rev 30596 Rev 32639
Line 35... Line 35...
35
		added = false;
35
		added = false;
36
		$('#catalogModalBody').hide();
36
		$('#catalogModalBody').hide();
37
		var itemId = $(this).closest('tr').attr('data');
37
		var itemId = $(this).closest('tr').attr('data');
38
 
38
 
39
		var poItemId = $(this).closest('tr').find("#poItemId").val();
39
		var poItemId = $(this).closest('tr').find("#poItemId").val();
40
		console.log(poItemId)
-
 
-
 
40
 
41
 
41
 
42
		var poId = $(this).closest('tr').find("#poId").val();
42
		var poId = $(this).closest('tr').find("#poId").val();
43
		console.log(poId)
-
 
-
 
43
 
44
 
44
 
45
		$("#bagModel .itemId").val(itemId);
45
		$("#bagModel .itemId").val(itemId);
-
 
46
 
46
		$("#bagModel .quantity").val(0);
47
		$("#bagModel .quantity").val(0);
-
 
48
 
47
		doGetAjaxRequestHandler(context + "/checkItemAvailability/?itemId=" + itemId, function(response) {
49
		doGetAjaxRequestHandler(context + "/checkItemAvailability/?itemId=" + itemId, function(response) {
48
			var obj = JSON.parse(response);
50
			var obj = JSON.parse(response);
49
			console.log(obj);
-
 
50
			console.log(obj.displayName);
-
 
-
 
51
 
51
			$(".modal-body h4.bagModalProductInfo.modelHeaderCustom > span").text(obj.displayName);
52
			$(".modal-body h4.bagModalProductInfo.modelHeaderCustom > span").text(obj.displayName);
-
 
53
 
52
			$(".modal-body h4.bagModalAvailability.modelHeaderCustom > span").text(obj.availability);
54
			$(".modal-body h4.bagModalAvailability.modelHeaderCustom > span").text(obj.availability);
53
			inputEle = [];
55
			inputEle = [];
-
 
56
 
54
			if ("earlyImeis" in obj) {
57
			if ("earlyImeis" in obj && obj.earlyImeis.length > 0) {
-
 
58
 
55
				for (i in obj.earlyImeis) {
59
				for (var i in obj.earlyImeis) {
56
					inputEle.push('<span class="input-group-addon">');
60
					inputEle.push('<span class="input-group-addon">');
57
					inputEle.push('<input type="checkbox" aria-label="..." name="interest" value="' + obj.earlyImeis[i] + '" id="' + obj.earlyImeis[i] + '"/>');
61
					inputEle.push('<input type="checkbox" aria-label="..." name="interest" value="' + obj.earlyImeis[i] + '" id="' + obj.earlyImeis[i] + '"/>');
58
					inputEle.push('<label for="' + obj.earlyImeis[i] + '">' + obj.earlyImeis[i] + '</label>');
62
					inputEle.push('<label for="' + obj.earlyImeis[i] + '">' + obj.earlyImeis[i] + '</label>');
59
					inputEle.push('</span>');
63
					inputEle.push('</span>');
60
					if (i % 3 == 2) {
64
					if (i % 3 == 2) {
Line 63... Line 67...
63
				}
67
				}
64
				$(".modal-body h4.bagModalEarlyImeis.modelHeaderCustom > span").html(inputEle.join(''));
68
				$(".modal-body h4.bagModalEarlyImeis.modelHeaderCustom > span").html(inputEle.join(''));
65
				$(".modal-body h4.bagModalEarlyImeis.modelHeaderCustom").show();
69
				$(".modal-body h4.bagModalEarlyImeis.modelHeaderCustom").show();
66
				$(".modal-body h4.bagModalQuantity.modelHeaderCustom").hide();
70
				$(".modal-body h4.bagModalQuantity.modelHeaderCustom").hide();
67
			} else {
71
			} else {
68
				$(".modal-body h4.bagModalEarlyImeis.modelHeaderCustom").html("");
72
				$(".modal-body h4.bagModalEarlyImeis.modelHeaderCustom > span").html("");
69
				$(".modal-body h4.bagModalEarlyImeis.modelHeaderCustom").hide();
73
				$(".modal-body h4.bagModalEarlyImeis.modelHeaderCustom").hide();
70
				$(".modal-body h4.bagModalQuantity.modelHeaderCustom").show();
74
				$(".modal-body h4.bagModalQuantity.modelHeaderCustom").show();
71
 
-
 
72
			}
75
			}
-
 
76
 
73
			$("#bagModel .availability").val(obj.availability);
77
			$("#bagModel .availability").val(obj.availability);
74
 
78
 
75
			$("#bagModel .poitemId").val(poItemId);
79
			$("#bagModel .poitemId").val(poItemId);
76
			$("#bagModel .poId").val(poId);
80
			$("#bagModel .poId").val(poId);
77
 
81
 
78
			$('#catalogModalBody').show();
82
			$('#catalogModalBody').show();
79
		});
83
		});
80
 
-
 
81
 
-
 
82
	});
84
	});
83
 
85
 
84
	// addToBagButton
86
	// addToBagButton
85
 
87
 
86
	$(document).on('click', "#addToBagButton", function() {
88
	$(document).on('click', "#addToBagButton", function() {
Line 118... Line 120...
118
					obj['imeis'].push(ele.value);
120
					obj['imeis'].push(ele.value);
119
				});
121
				});
120
			}
122
			}
121
			console.log(obj);
123
			console.log(obj);
122
			addItemInLocalStorage(obj);
124
			addItemInLocalStorage(obj);
-
 
125
			//alert("Item added to bag successfully");
-
 
126
			showToast("Item, Item added to bag successfully!");
-
 
127
			$('#bagModel').modal('hide');
-
 
128
 
-
 
129
		});
-
 
130
 
-
 
131
	});
-
 
132
 
-
 
133
	// add to bag with cart page
-
 
134
 
-
 
135
	$(document).on('click', "#addToBagButtonwithCart", function () {
-
 
136
		var itemId = $("#bagModel .itemId").val();
-
 
137
		var poitemId = $("#bagModel .poitemId").val();
-
 
138
		var poId = $("#bagModel .poId").val();
-
 
139
		console.log(poitemId)
-
 
140
		console.log(poId)
-
 
141
 
-
 
142
		var tempAvailability = $("#bagModel .availability").val();
-
 
143
		var quantity = $("#bagModel .quantity").val();
-
 
144
		imeiCount = $('h4.bagModalEarlyImeis').find('input').length;
-
 
145
		if (imeiCount > 0) {
-
 
146
			quantity = $('h4.bagModalEarlyImeis').find('input:checked').length;
-
 
147
			if (quantity == 0) {
-
 
148
				alert("Please check one of the imei(s)");
-
 
149
				return;
-
 
150
			}
-
 
151
		} else if (!quantity || parseInt(quantity) <= 0 || isNaN(parseInt(quantity)) || quantity.indexOf('.') != -1) {
-
 
152
			alert("Please enter valid quantity");
-
 
153
			return;
-
 
154
		}
-
 
155
 
-
 
156
		doGetAjaxRequestHandler(context + "/checkItemAvailability/?itemId=" + itemId, function (response) {
-
 
157
			var obj = JSON.parse(response);
-
 
158
			console.log(obj);
-
 
159
			if (obj.availability < parseInt(quantity) || obj.availability == 0) {
-
 
160
				alert("You don't have enough inventory of this item");
-
 
161
				return;
-
 
162
			}
-
 
163
			var obj = {
-
 
164
				'itemId': obj.itemId,
-
 
165
				'displayName': obj.displayName,
-
 
166
				'quantity': parseInt(quantity),
-
 
167
				'iconUrl': obj.iconUrl,
-
 
168
				'poItemId': poitemId,
-
 
169
				'poId': poId
-
 
170
			};
-
 
171
			if (imeiCount > 0) {
-
 
172
				obj['imeis'] = [];
-
 
173
				$('h4.bagModalEarlyImeis').find('input:checked').each(function (index, ele) {
-
 
174
					obj['imeis'].push(ele.value);
-
 
175
				});
-
 
176
			}
-
 
177
			console.log(obj);
-
 
178
			addItemInLocalStorage(obj);
123
			alert("Item added to bag successfully");
179
			//alert("Item added to bag successfully");
-
 
180
			showToast("Item, Item added to bag successfully!");
124
			$('#bagModel').modal('hide');
181
			$('#bagModel').modal('hide');
-
 
182
			// Trigger the click event for the cart icon
-
 
183
			$(".cart_icon_header").trigger('click');
125
 
184
 
126
		});
185
		});
127
 
186
 
128
	});
187
	});
129
 
188