此功能是一种预订功能,用户可以选择日期和设施并搜索时间。然后用户将选择时间并进行预订。我可以检查,有没有办法同时检索信用和设施价格,以便我可以从用户拥有的信用中扣除设施价格。例如,您的钱包里有50美元(信用额),设施价格为5美元,我想知道45美元(50美元至5美元)的剩余信用额度。现在,我只能设法在__deductfromwallet(arr)函数中获得信用值,并且设施价格未定义
**get the time slot selected**
$('input[type=checkbox]:checked').each(function (index) {
var timeslotid = $(this).val();
var url = serverURL() + "/newbooking.php";
var JSONObject = {
"facilities_ID": searchFacilities,
"facilities_schedule_ID": getfacilities_schedule_ID,
"facilities_timeslot_ID": timeslotid,
"user_name": localStorage.getItem("userid"),
};
$.ajax({
url: url,
type: 'GET',
data: JSONObject,
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function (arr) {
validationMsgs("Click okay to continue ", "Booking Created", "OK" );
__getfaciltiesprice(arr);
// __getcredits(arr);
// __deductfromwallet(arr);
},
error: function () {
validationMsg();
}
});
});
}
function __getfaciltiesprice(arr) {
**I would like to get the price of the facilities**
var facilities_price;
var url = serverURL() + "/getfacilities.php";
var JSONObject = {
"facilities_ID": searchFacilities
};
$.ajax({
url: url,
type: 'GET',
data: JSONObject,
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function (arr) {
facilities_price = arr[0].facilities_price;
console.log("facilities_price in _getfaciltiesprice>>" + facilities_price);
__deductmoney(arr);
//__getcredits(arr);
// __deductfromwallet(arr);
},
error: function () {
validationMsg();
}
});
}
function __deductmoney(arr) {
facilities_price = arr[0].facilities_price;
console.log("facilities_price1>>" + facilities_price);
__getcredits(arr);
}
function __getcredits(arr) {
**I would like to get the credits of the user**
var url = serverURL() + "/getprofile.php";
var JSONObject = {
"user_name": localStorage.getItem("userid")
};
$.ajax({
url: url,
type: 'GET',
data: JSONObject,
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function (arr) {
var credits = arr[0].credits;
console.log("credits1>>" + credits);
__getcreditResults(arr);
//__deductfromwallet(arr);
},
error: function () {
validationMsg();
}
});
console.log("Outside ajax credits: " + credits);
}
function __getcreditResults(arr) {
credits = arr[0].credits;
console.log("__getcreditResults>>" + credits);
__deductfromwallet(arr);
}
function __deductfromwallet(arr) {
**I would like to get the leftover credits based on the facilities price that the user get *
facilities_price = arr[0].facilities_price;
console.log("__deductmoney facilities price>>" + facilities_price);
credits = arr[0].credits;
console.log("__deductmoney credit>>" + credits);
//var leftamt = credits - facilities_price;
//console.log("leftamt>>" + leftamt);
}