Browse Source

Turns off/on spinner for membership based on choices in functions.

devel
Jonathan Rosenbaum 7 years ago
parent
commit
d0e88bac58
  1. 12
      Connections/database_functions.php
  2. 28
      js/transaction.js
  3. 13
      json/transaction.php

12
Connections/database_functions.php

@ -72,24 +72,24 @@ May add capability to adjust limits based on status, but that can get complex if
define("SWEAT_EQUITY_LIMIT",100);
define("MAX_BIKE_EARNED",1);
define("VOLUNTEER_HOUR_VALUE",8);
define("STAND_TIME_VALUE",10);
define("VOLUNTEER_DISCOUNT",25);
define("SPECIAL_VOLUNTEER_HOURS_QUALIFICATION",100);
define("SPECIAL_VOLUNTEER_DISCOUNT",50);
define("STAND_TIME_VALUE",10);
// Determines the behaviour of Bicycles (transaction_type_id) for volunteer to earn-a-bike purchases
define("EARN_A_BIKE_LIMIT",1);
// 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",
"Stand Time",
"Used Parts"
$transactions_with_volunteer_benefits = array( "Bicycles" => true,
"Stand Time" => true,
"Used Parts" => true
);
// Volunteer benefits take priority over membership benefits if patron qualifies for both
$transactions_with_membership_benefits = array( "Used Parts",
"New Parts"
$transactions_with_membership_benefits = array( "Used Parts" => true,
"New Parts" => true
);
/*******

28
js/transaction.js

@ -918,13 +918,35 @@ $(function() {
$("#redeemable_hours").hide();
$(".ui-spinner").hide();
}
}
}
// Determine membership benefits of current transaction
$.post("json/transaction.php", { transaction_benefits: 1 }, function (data) {
var obj = $.parseJSON(data);
// Volunteer benefits
if ( obj.transactions_with_volunteer_benefits[$("#trans_type_info").text()] === true ) {
if ($("#redeemable_hours").data("ui-spinner"))
$("#redeemable_hours").spinner("enable");
} else {
if ($("#redeemable_hours").data("ui-spinner"))
$("#redeemable_hours").spinner("disable");
}
// Membership benefits
for (var n in obj.transactions_with_membership_benefits) {
//console.log(obj.transactions_with_volunteer_benefits[n]);
}
});
// control spinner behavior of transaction_type "Stand Time"
if ($("#trans_type_info").text() === "Stand Time" && $("#stand_time_total").is(":empty")) {
$("#redeemable_hours").spinner("disable");
} else if ($("#trans_type_info").text() === "Stand Time") {
$("#redeemable_hours").spinner("enable");
}
if ($("#redeemable_hours").data("ui-spinner"))
$("#redeemable_hours").spinner("enable");
}
}); // volunteers post

13
json/transaction.php

@ -158,7 +158,18 @@ $stand_time_value = STAND_TIME_VALUE;
$result = (object)array_merge((array)$result, (array)$result2, (array)$result3);
echo json_encode($result);
} // Volunteer Benefits
} // end Volunteer Benefits
// Volunteer Benefits
if (isset($_POST['transaction_benefits'])) {
$result = ["transactions_with_volunteer_benefits" => $transactions_with_volunteer_benefits,
"transactions_with_membership_benefits" => $transactions_with_membership_benefits
];
echo json_encode($result);
} // end transaction_benefits
// Stand Time
if (isset($_POST['stand_time'])) {

Loading…
Cancel
Save