Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
23419 ashik.ali 1
$(function() {
26218 tejbeer 2
 
27754 amit.gupta 3
	$(document).on('click', ".create-prebooking-listing", function() {
23419 ashik.ali 4
		console.log("Create Prebooking Listing Button Clicked...")
5
		loadCreatePrebookingListing("main-content");
6
	});
26218 tejbeer 7
 
27754 amit.gupta 8
	$(document).on('click', ".prebooking-listings", function() {
23419 ashik.ali 9
		console.log("Prebooking Listings Button Clicked...")
10
		loadPrebookingListings("main-content");
11
	});
26218 tejbeer 12
 
27754 amit.gupta 13
	$(document).on('click', ".create-prebooking-order", function() {
23419 ashik.ali 14
		console.log("Create Prebooking Order Button Clicked...")
15
		loadCreatePrebookingListings("main-content");
16
	});
26218 tejbeer 17
 
27754 amit.gupta 18
	$(document).on('click', ".prebooking-orders", function() {
23419 ashik.ali 19
		console.log("Prebooking Orders Button Clicked...")
20
		loadPrebookingOrders("main-content");
21
	});
26218 tejbeer 22
 
27755 amit.gupta 23
	$(document).on('click', "#prebooking-listings-paginated .next",
26218 tejbeer 24
			function() {
25
				loadPaginatedNextItems('/getPaginatedPrebookingListings', null,
26
						'prebooking-listings-paginated',
27
						'prebooking-listings-table',
28
						'prebooking-listing-details-container');
29
				$(this).blur();
30
			});
31
 
27755 amit.gupta 32
	$(document).on('click', "#prebooking-listings-paginated .previous",
26218 tejbeer 33
			function() {
34
				loadPaginatedPreviousItems('/getPaginatedPrebookingListings',
35
						null, 'prebooking-listings-paginated',
36
						'prebooking-listings-table',
37
						'prebooking-listing-details-container');
38
				$(this).blur();
39
			});
40
 
27755 amit.gupta 41
	$(document).on('click', "#prebooking-orders-paginated .next",
26218 tejbeer 42
			function() {
43
				loadPaginatedNextItems('/getPaginatedPrebookingOrders', null,
44
						'prebooking-orders-paginated',
45
						'prebooking-orders-table',
46
						'prebooking-order-details-container');
47
				$(this).blur();
48
			});
49
 
27755 amit.gupta 50
	$(document).on('click', "#prebooking-orders-paginated .previous",
26218 tejbeer 51
			function() {
52
				loadPaginatedPreviousItems('/getPaginatedPrebookingOrders',
53
						null, 'prebooking-orders-paginated',
54
						'prebooking-orders-table',
55
						'prebooking-order-details-container');
56
				$(this).blur();
57
			});
58
 
59
	/*
27754 amit.gupta 60
	 * $(document).on('click', '#brands li a', function(){
26218 tejbeer 61
	 * $('#brand-value').text($(this).text());
62
	 * loadItemsDescriptionByBrand("items-description-container",
63
	 * $(this).text()); console.log($(this).text()); });
64
	 */
65
 
27755 amit.gupta 66
	$(document).on('click', ".prebooking-listing-details",
26218 tejbeer 67
			function() {
68
				var prebookingListingId = $(this).attr('data');
69
				console.log("prebookingListingId = " + prebookingListingId);
70
				loadPrebookingListingDetails(prebookingListingId,
71
						"prebooking-listing-details-container");
72
			});
73
 
27755 amit.gupta 74
	$(document).on('click', ".active-prebooking-listing",
26218 tejbeer 75
					function() {
76
						var prebookingListingId = $(this).attr('data');
77
						console.log("active-prebooking-listing id : "
78
								+ prebookingListingId);
79
						var start = $("#prebooking-listings-paginated .start")
80
								.text();
81
						// var end = $( "#schemes-paginated .end" ).text();
82
						var offset = start - 1;
83
						if (confirm("Are you sure you want to Active Prebooking Listing!") == true) {
84
							activePrebookingListing(prebookingListingId,
85
									offset, "prebooking-listings-table");
86
						}
87
					});
88
 
27755 amit.gupta 89
	$(document).on('click', ".expire-prebooking-listing",
26218 tejbeer 90
					function() {
91
						var prebookingListingId = $(this).attr('data');
92
						console.log("expire-prebooking-listing id : "
93
								+ prebookingListingId);
94
						var start = $("#prebooking-listings-paginated .start")
95
								.text();
96
						// var end = $( "#schemes-paginated .end" ).text();
97
						var offset = start - 1;
98
						if (confirm("Are you sure you want to Expire Prebooking Listing!") == true) {
99
							expirePrebookingListing(prebookingListingId,
100
									offset, "prebooking-listings-table");
101
						}
102
					});
103
 
27755 amit.gupta 104
	$(document).on('click', ".update-prebooking-duration",
26218 tejbeer 105
					function() {
106
						var prebookingListingId = $(this).attr('data');
107
						console.log("update-prebooking-listing id : "
108
								+ prebookingListingId);
109
						var start = $("#prebooking-listings-paginated .start")
110
								.text();
111
						// var end = $( "#schemes-paginated .end" ).text();
112
						var offset = start - 1;
113
						if (confirm("Are you sure you want to Active Prebooking Listing!") == true) {
114
							updatePrebookingListing(prebookingListingId,
115
									offset, "prebooking-listings-table");
116
						}
117
					});
118
 
27754 amit.gupta 119
	$(document).on("change paste keyup", "#quantity", function() {
23419 ashik.ali 120
		var quantity = parseFloat($(this).val());
26218 tejbeer 121
		if (quantity <= 0) {
23419 ashik.ali 122
			alert("Quantity must be greater than zero");
123
			$(this).val(1);
26218 tejbeer 124
		} else if (quantity > 0) {
23419 ashik.ali 125
			var totalAmount = parseFloat($('#advanceAmount').val());
126
			$('#totalAmount').val(quantity * totalAmount);
127
		}
128
	});
26218 tejbeer 129
 
23419 ashik.ali 130
});
131
 
132
$(document).ready(function() {
26218 tejbeer 133
 
27754 amit.gupta 134
	$(document).on("blur", "#quantity", function() {
23419 ashik.ali 135
		console.log("quantity blur called");
26218 tejbeer 136
		if ($(this).val() == "") {
23419 ashik.ali 137
			$(this).val(1);
138
			$('#totalAmount').val($('#advanceAmount').val());
139
		}
140
	});
26218 tejbeer 141
 
23419 ashik.ali 142
});
143
 
26218 tejbeer 144
function configureItemsDescriptionDropDown() {
23419 ashik.ali 145
	$(document).ready(function() {
26218 tejbeer 146
		$('#itemsDescription').multiselect({
147
			// includeSelectAllOption: true,
148
			maxHeight : 200,
149
			buttonWidth : '280px',
150
			// numberDisplayed: 1,
151
			nonSelectedText : 'Items',
152
			nSelectedText : ' - Items Selected',
153
			enableFiltering : true,
154
			enableCaseInsensitiveFiltering : true,
155
			multiple : false
156
		});
157
	});
23419 ashik.ali 158
}
159
 
26218 tejbeer 160
function loadCreatePrebookingListing(domId) {
161
	doAjaxRequestHandler(context + "/createPrebookingListing", "GET", function(
162
			response) {
23419 ashik.ali 163
		$('#' + domId).html(response);
164
	});
165
}
166
 
26218 tejbeer 167
function loadPrebookingListings(domId) {
168
	doAjaxRequestHandler(context + "/getPrebookingListings", "GET", function(
169
			response) {
23419 ashik.ali 170
		$('#' + domId).html(response);
171
	});
172
}
173
 
26218 tejbeer 174
function loadCreatePrebookingListings(domId) {
175
	doAjaxRequestHandler(context + "/createPrebookingOrder", "GET", function(
176
			response) {
23419 ashik.ali 177
		$('#' + domId).html(response);
178
	});
179
}
180
 
26218 tejbeer 181
function loadPrebookingOrders(domId) {
182
	doAjaxRequestHandler(context + "/getPrebookingOrders", "GET", function(
183
			response) {
23419 ashik.ali 184
		$('#' + domId).html(response);
185
	});
186
}
187
 
26218 tejbeer 188
function loadItemsDescriptionByBrand(domId, brand) {
189
	doAjaxRequestHandler(context + "/getItemsByBrand?brand=" + brand, "GET",
190
			function(response) {
191
				$('#' + domId).html(response);
192
				configureItemsDescriptionDropDown();
193
			});
23419 ashik.ali 194
}
195
 
26218 tejbeer 196
function loadPrebookingListingDetails(prebookingListingId, domId) {
197
	doAjaxRequestHandler(context
198
			+ "/getPrebookingListingById?prebookingListingId="
199
			+ prebookingListingId, "GET", function(response) {
23419 ashik.ali 200
		$('#' + domId).html(response);
201
		window.dispatchEvent(new Event('resize'));
202
	});
203
}
204
 
26218 tejbeer 205
function activePrebookingListing(prebookingListingId, offset, domId) {
206
	doAjaxRequestHandler(context
207
			+ "/activePrebookingListingById?prebookingListingId="
208
			+ prebookingListingId + "&offset=" + offset, "PUT", function(
209
			response) {
23419 ashik.ali 210
		$('#' + domId).html(response);
211
		$('#prebooking-listing-details-container').html('');
212
	});
26218 tejbeer 213
 
23419 ashik.ali 214
}
215
 
26218 tejbeer 216
function expirePrebookingListing(prebookingListingId, offset, domId) {
217
	doAjaxRequestHandler(context
218
			+ "/expirePrebookingListingById?prebookingListingId="
219
			+ prebookingListingId + "&offset=" + offset, "PUT", function(
220
			response) {
23419 ashik.ali 221
		$('#' + domId).html(response);
222
		$('#prebooking-listing-details-container').html('');
223
	});
26218 tejbeer 224
}
225
function updatePrebookingListing(prebookingListingId, offset, domId) {
226
	doAjaxRequestHandler(context
227
			+ "/updatePrebookingListingById?prebookingListingId="
228
			+ prebookingListingId + "&activeTimestamp=" + startDate
229
			+ "&expireTimestamp=" + endDate + "&offset=" + offset, "PUT",
230
			function(response) {
231
				$('#' + domId).html(response);
232
				$('#prebooking-listing-details-container').html('');
233
			});
23419 ashik.ali 234
}