From 3c5eea235a292b2daf429810b5974a7ed22e404d Mon Sep 17 00:00:00 2001 From: Jonathan Rosenbaum Date: Thu, 19 Oct 2017 04:27:44 +0000 Subject: [PATCH] This fixes #9 by allowing two behaviors via REDEEM_ONE_TO_ONE: * based on the SWEAT_EQUITY_LIMIT with discounts applied, * based on 1 to 1 (1hr of volunteering === 1hr of free stand time) regardless of the SWEAT_EQUITY_LIMIT --- Connections/database_functions.php | 4 ++++ js/transaction.js | 6 ++++++ json/transaction.php | 2 ++ 3 files changed, 12 insertions(+) diff --git a/Connections/database_functions.php b/Connections/database_functions.php index 6db8d7b..b016180 100644 --- a/Connections/database_functions.php +++ b/Connections/database_functions.php @@ -89,6 +89,10 @@ define("SPECIAL_VOLUNTEER_DISCOUNT",50); // PERCENTAGE // Determines the behaviour of Bicycles (transaction_type_id) for volunteer to earn-a-bike purchases define("EARN_A_BIKE_LIMIT",1); +// Determine if stand time behaviour will be based on the SWEAT_EQUITY_LIMIT with discounts applied, +// or 1 to 1 (1hr of volunteering === 1hr of free stand time) regardless of the SWEAT_EQUITY_LIMIT +define("REDEEM_ONE_TO_ONE", true); + // Map transaction_type_id for transaction to benefits; // Bicycles and Stand Time are special transaction types for volunteers, but they should still be mapped if benefits are desired. $transactions_with_volunteer_benefits = array( "Bicycles" => true, diff --git a/js/transaction.js b/js/transaction.js index c1ba445..c7caecd 100644 --- a/js/transaction.js +++ b/js/transaction.js @@ -629,6 +629,12 @@ $(function() { discount = obj.volunteer_discount; } + if ($("#transaction_type").val() === "Stand Time") { + if (obj.redeem_one_to_one === true) { + discount = 100; + } + } + // figure out remaining hours that can be redeemed if some, but not all, volunteer hours have been redeemed. var remaining, year = d.getFullYear(), exceeded_sweat_equity_limit = false, price_after_redeeming, spinner_difference; if (volunteer) { diff --git a/json/transaction.php b/json/transaction.php index 54f703d..dc8a753 100644 --- a/json/transaction.php +++ b/json/transaction.php @@ -18,6 +18,7 @@ $stand_time_value = STAND_TIME_VALUE; $free_stand_time_period = FREE_STAND_TIME_PERIOD; $timezone = TIMEZONE; $sweat_equity_limit = SWEAT_EQUITY_LIMIT; +$redeem_one_to_one = REDEEM_ONE_TO_ONE; $max_bike_earned = MAX_BIKE_EARNED; $volunteer_hour_value = VOLUNTEER_HOUR_VALUE; $volunteer_discount = VOLUNTEER_DISCOUNT; @@ -157,6 +158,7 @@ $membership_discount = MEMBERSHIP_DISCOUNT; $result3["special_volunteer_hours_qualification"] = $special_volunteer_hours_qualification; $result3["special_volunteer_discount"] = $special_volunteer_discount; $result3["stand_time_value"] = $stand_time_value; + $result3["redeem_one_to_one"] = $redeem_one_to_one; $result = (object)array_merge((array)$result, (array)$result2, (array)$result3); echo json_encode($result);