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