mirror of
https://github.com/fspc/Yellow-Bike-Database.git
synced 2025-02-23 09:13:23 -05:00
Max Bike Earned logic now working.
This commit is contained in:
parent
fb0e9cfbfb
commit
e852af5e5f
@ -869,11 +869,12 @@ $(function() {
|
|||||||
var volunteer_hours_redeemed = 0;
|
var volunteer_hours_redeemed = 0;
|
||||||
var obj = $.parseJSON(data);
|
var obj = $.parseJSON(data);
|
||||||
|
|
||||||
var volunteer = "", remaining = 0, vhr = "";
|
var volunteer = "", remaining = 0, vhr = "", max_bikes_earned = 0;
|
||||||
if (obj.volunteer) {
|
if (obj.volunteer) {
|
||||||
volunteer = $.parseJSON(obj.volunteer);
|
volunteer = $.parseJSON(obj.volunteer);
|
||||||
remaining = obj.current_year_volunteer_hours - volunteer[year].volunteer_hours_redeemed;
|
remaining = obj.current_year_volunteer_hours - volunteer[year].volunteer_hours_redeemed;
|
||||||
vhr = volunteer[year].volunteer_hours_redeemed;
|
vhr = volunteer[year].volunteer_hours_redeemed;
|
||||||
|
max_bikes_earned = volunteer[year].max_bike_earned;
|
||||||
} else {
|
} else {
|
||||||
vhr = 0;
|
vhr = 0;
|
||||||
}
|
}
|
||||||
@ -884,7 +885,8 @@ $(function() {
|
|||||||
"Volunteer Hours for last 365 days: " + obj.volunteer_hours + "\r\n" +
|
"Volunteer Hours for last 365 days: " + obj.volunteer_hours + "\r\n" +
|
||||||
"Volunteer Hours \(" + year + "\): " + obj.current_year_volunteer_hours + "\r\n" +
|
"Volunteer Hours \(" + year + "\): " + obj.current_year_volunteer_hours + "\r\n" +
|
||||||
"Volunteer Hours Redeemed: " + vhr + "\r\n" +
|
"Volunteer Hours Redeemed: " + vhr + "\r\n" +
|
||||||
"Volunteer Hours Remaining: " + remaining;
|
"Volunteer Hours Remaining: " + remaining + "\r\n" +
|
||||||
|
"Max Bikes Earned: " + max_bikes_earned;
|
||||||
|
|
||||||
$("#volunteer_hours").prop("title","").empty();
|
$("#volunteer_hours").prop("title","").empty();
|
||||||
$("#redeemable_hours").hide();
|
$("#redeemable_hours").hide();
|
||||||
@ -901,8 +903,6 @@ $(function() {
|
|||||||
max = obj.current_year_volunteer_hours;
|
max = obj.current_year_volunteer_hours;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("MAX " + max);
|
|
||||||
|
|
||||||
$("#volunteer_hours").prop("title",title).html("Volunteer Hours");
|
$("#volunteer_hours").prop("title",title).html("Volunteer Hours");
|
||||||
|
|
||||||
$(".ui-spinner").show();
|
$(".ui-spinner").show();
|
||||||
@ -994,6 +994,15 @@ $(function() {
|
|||||||
$("#redeemable_hours").spinner("enable");
|
$("#redeemable_hours").spinner("enable");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// more than max_bike_limit turn off spinner
|
||||||
|
if ($("#trans_type_info").text() === "Bicycles") {
|
||||||
|
if (volunteer && obj.max_bike_earned) {
|
||||||
|
if (volunteer[year].max_bike_earned >= obj.max_bike_earned) {
|
||||||
|
$("#redeemable_hours").spinner("disable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}); // volunteers post
|
}); // volunteers post
|
||||||
|
|
||||||
|
|
||||||
@ -1046,9 +1055,19 @@ $(function() {
|
|||||||
} else {
|
} else {
|
||||||
vhr = parseFloat($("#redeemable_hours").val());
|
vhr = parseFloat($("#redeemable_hours").val());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't require paid to be selected, only amount >= 0
|
||||||
|
var max_bike_earned = 0;
|
||||||
|
if ($("#trans_type_info").text() === "Bicycles") {
|
||||||
|
// hours were redeemed and this is a Bicycle transaction
|
||||||
|
if (vhr !== "0.00") {
|
||||||
|
max_bike_earned = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
volunteer_benefits_history[year] = {
|
volunteer_benefits_history[year] = {
|
||||||
volunteer_hours_redeemed: vhr,
|
volunteer_hours_redeemed: vhr,
|
||||||
max_bike_earned: 0
|
max_bike_earned: max_bike_earned
|
||||||
};
|
};
|
||||||
|
|
||||||
// Volunteer History query
|
// Volunteer History query
|
||||||
@ -1079,8 +1098,12 @@ $(function() {
|
|||||||
if ($("#redeemable_hours").val().length) {
|
if ($("#redeemable_hours").val().length) {
|
||||||
volunteer_benefits_history[year].volunteer_hours_redeemed = parseFloat(volunteer_benefits_history[year].volunteer_hours_redeemed) +
|
volunteer_benefits_history[year].volunteer_hours_redeemed = parseFloat(volunteer_benefits_history[year].volunteer_hours_redeemed) +
|
||||||
parseFloat($("#redeemable_hours").val());
|
parseFloat($("#redeemable_hours").val());
|
||||||
|
|
||||||
|
volunteer_benefits_history[year].max_bike_earned = parseFloat(volunteer_benefits_history[year].max_bike_earned) +
|
||||||
|
max_bike_earned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$.post("json/transaction.php",{ volunteer_history_update: 1,
|
$.post("json/transaction.php",{ volunteer_history_update: 1,
|
||||||
contact_id: sold_to,
|
contact_id: sold_to,
|
||||||
volunteer_history: volunteer_benefits_history,
|
volunteer_history: volunteer_benefits_history,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user