1
0
mirror of https://github.com/fspc/Yellow-Bike-Database.git synced 2025-02-23 01:03:23 -05:00

Improves the max bike earned logic.

This commit is contained in:
Jonathan Rosenbaum 2017-08-05 22:01:02 +00:00
parent e852af5e5f
commit aab521eb6b

View File

@ -862,6 +862,7 @@ $(function() {
} }
// How many hours does this volunteer have? // How many hours does this volunteer have?
$("#redeemable_hours").val("");
$.post("json/transaction.php", { volunteer_benefits: 1, contact_id: this.value }, function (data) { $.post("json/transaction.php", { volunteer_benefits: 1, contact_id: this.value }, function (data) {
var year = d.getFullYear(); var year = d.getFullYear();
@ -1057,7 +1058,7 @@ $(function() {
} }
// Don't require paid to be selected, only amount >= 0 // Don't require paid to be selected, only amount >= 0
var max_bike_earned = 0; var max_bike_earned = 0, maximum_allowable_earned_bikes;
if ($("#trans_type_info").text() === "Bicycles") { if ($("#trans_type_info").text() === "Bicycles") {
// hours were redeemed and this is a Bicycle transaction // hours were redeemed and this is a Bicycle transaction
if (vhr !== "0.00") { if (vhr !== "0.00") {
@ -1065,6 +1066,11 @@ $(function() {
} }
} }
$.post("json/transaction.php",{ max_bike_earned: 1 }, function(data) {
var obj = $.parseJSON(data);
maximum_allowable_earned_bikes = obj.max_bike_earned;
});
volunteer_benefits_history[year] = { volunteer_benefits_history[year] = {
volunteer_hours_redeemed: vhr, volunteer_hours_redeemed: vhr,
max_bike_earned: max_bike_earned max_bike_earned: max_bike_earned
@ -1099,9 +1105,11 @@ $(function() {
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());
if (parseFloat(volunteer_benefits_history[year].max_bike_earned) < maximum_allowable_earned_bikes) {
volunteer_benefits_history[year].max_bike_earned = parseFloat(volunteer_benefits_history[year].max_bike_earned) + volunteer_benefits_history[year].max_bike_earned = parseFloat(volunteer_benefits_history[year].max_bike_earned) +
max_bike_earned; max_bike_earned;
} }
}
$.post("json/transaction.php",{ volunteer_history_update: 1, $.post("json/transaction.php",{ volunteer_history_update: 1,