Subversion Repositories SmartDukaan

Rev

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

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