| 23419 |
ashik.ali |
1 |
$().ready(function() {
|
|
|
2 |
$("form#create-prebooking-order-form input").each(function(){
|
|
|
3 |
$(this).attr('autocomplete', 'off');
|
|
|
4 |
});
|
|
|
5 |
});
|
|
|
6 |
$().ready(function() {
|
|
|
7 |
// validate the comment form when it is submitted
|
|
|
8 |
$('#create-prebooking-order-form').validate({
|
|
|
9 |
rules:{
|
|
|
10 |
customerName:{
|
|
|
11 |
required:true
|
|
|
12 |
},
|
|
|
13 |
customerMobileNumber:{
|
|
|
14 |
required:true
|
|
|
15 |
},
|
|
|
16 |
customerEmailId:{
|
|
|
17 |
required:true
|
|
|
18 |
}
|
|
|
19 |
},
|
|
|
20 |
messages:{
|
|
|
21 |
customerName:{
|
|
|
22 |
required:"Please enter the customer name"
|
|
|
23 |
},
|
|
|
24 |
customerMobileNumber:{
|
|
|
25 |
required:"Please enter customer mobile number"
|
|
|
26 |
},
|
|
|
27 |
customerEmailId:{
|
|
|
28 |
required:"Please enter customer email id"
|
|
|
29 |
}
|
|
|
30 |
},
|
|
|
31 |
submitHandler: function (form, event) {
|
|
|
32 |
event.preventDefault();
|
|
|
33 |
if(validatePrebookingOrderDetails()){
|
|
|
34 |
alert("Please fix errors");
|
|
|
35 |
return false;
|
|
|
36 |
}
|
|
|
37 |
var json = prebookingOrderDetailsJson();
|
|
|
38 |
console.log("schemeJson = " + json);
|
|
|
39 |
if(confirm("Are you sure you want to create Prebooking Order!") == true){
|
|
|
40 |
doAjaxRequestWithJsonHandler(context+"/createPrebookingOrder", "POST", json, function(response){
|
|
|
41 |
$('#main-content').html(response);
|
|
|
42 |
});
|
|
|
43 |
return false; // required to block normal submit since you used ajax
|
|
|
44 |
}
|
|
|
45 |
}
|
|
|
46 |
});
|
|
|
47 |
|
|
|
48 |
});
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
function validatePrebookingOrderDetails(){
|
|
|
52 |
console.log("validating prebooking order details...");
|
|
|
53 |
var error = false;
|
|
|
54 |
|
|
|
55 |
var customerName = $("form#create-prebooking-order-form input[name=customerName]").val();
|
|
|
56 |
console.log("customerName = " + customerName);
|
|
|
57 |
$("#customerName").removeClass("border-highlight");
|
|
|
58 |
if(customerName == ""){
|
|
|
59 |
alert("Customer name can not be empty");
|
|
|
60 |
$("#customerName").addClass("border-highlight");
|
|
|
61 |
error = true;
|
|
|
62 |
return error;
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
var customerMobileNumber = $("form#create-prebooking-order-form input[name=customerMobileNumber]").val();
|
|
|
66 |
console.log("customerMobileNumber = " + customerMobileNumber);
|
|
|
67 |
$("#customerMobileNumber").removeClass("border-highlight");
|
|
|
68 |
if(customerMobileNumber == ""){
|
|
|
69 |
alert("Customer mobile number can not be empty");
|
|
|
70 |
$("#customerMobileNumber").addClass("border-highlight");
|
|
|
71 |
error = true;
|
|
|
72 |
return error;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
var customerEmailId = $("form#create-prebooking-order-form input[name=customerEmailId]").val();
|
|
|
76 |
console.log("customerEmailId = " + customerEmailId);
|
|
|
77 |
$("#customerEmailId").removeClass("border-highlight");
|
|
|
78 |
if(customerEmailId == ""){
|
|
|
79 |
alert("Customer email id can not be empty");
|
|
|
80 |
$("#customerEmailId").addClass("border-highlight");
|
|
|
81 |
error = true;
|
|
|
82 |
return error;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
var quantity = $("form#create-prebooking-order-form input[name=quantity]").val();
|
|
|
86 |
console.log("quantity = " + quantity);
|
|
|
87 |
$("#quantity").removeClass("border-highlight");
|
|
|
88 |
if (quantity == ""){
|
|
|
89 |
$("form#create-order-form input[name=quantity]").val(1);
|
|
|
90 |
}else if(tentativeAmount <= 0){
|
|
|
91 |
alert("quantity should be greater than 0");
|
|
|
92 |
$("#quantity").addClass("border-highlight");
|
|
|
93 |
error = true;
|
|
|
94 |
return error;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
console.log("validation prebooking order error = " + error);
|
|
|
98 |
return error;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
function prebookingOrderDetailsJson(){
|
|
|
102 |
console.log("prebookingOrderDetailsJson");
|
|
|
103 |
var prebookingOrderObject = {};
|
|
|
104 |
prebookingOrderObject['customerName'] = $("#customerName").val();
|
|
|
105 |
prebookingOrderObject['customerMobileNumber'] = $('#customerMobileNumber').val();
|
|
|
106 |
prebookingOrderObject['customerEmailId'] = $('#customerEmailId').val();
|
|
|
107 |
var prebookingListing = $('#activePrebookingItemsDescription').val().split(",");
|
| 24087 |
amit.gupta |
108 |
prebookingOrderObject['catalogId'] = parseInt(prebookingListing[0]);
|
| 23419 |
ashik.ali |
109 |
prebookingOrderObject['quantity'] = $('#quantity').val();
|
|
|
110 |
return JSON.stringify(prebookingOrderObject);
|
|
|
111 |
}
|