Browse Source

Won't charge stand time if a member. Simplified callback reusing funtion.

devel
Jonathan Rosenbaum 7 years ago
parent
commit
7a09ccfead
  1. 8
      js/transaction.js
  2. 16
      json/transaction.php

8
js/transaction.js

@ -727,12 +727,14 @@ $(function() {
}); // volunteers post
// Stand Time
// Stand Time - if a paid member, nothing is owed
if ( $("#trans_type_info").text() === "Stand Time" ) {
$.post("json/transaction.php", { stand_time: 1, contact_id: this.value, shop_id: shop_id }, function (data) {
if (data) {
var obj = $.parseJSON(data);
amount.val(obj.total + ".00");
var obj = $.parseJSON(data);
if(!obj.membership) {
amount.val(obj.total + ".00");
}
$("#stand_time_total").text(obj.hours + " hours " + obj.minutes + " minutes");
} else {
amount.val(data);

16
json/transaction.php

@ -88,18 +88,7 @@ $timezone = TIMEZONE;
// Membership Benefits
if (isset($_POST['membership_benefits'])) {
$query = "SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name,
CONCAT(first_name, ' ', last_name) AS normal_full_name, contacts.email AS email, contacts.phone AS phone,
transaction_log.date AS membership_start, SUBSTRING_INDEX(DATE_ADD(date, INTERVAL 365 DAY), ' ', 1) AS expiration_date
FROM transaction_log LEFT JOIN contacts ON transaction_log.sold_to = contacts.contact_id
WHERE SUBSTRING_INDEX(date, ' ', 1) <= DATE_ADD(date, INTERVAL 365 DAY)
AND (transaction_type='Memberships' AND paid=1) AND contact_id=" .
$_POST['contact_id'] .
" ORDER by membership_start DESC;";
$sql = mysql_query($query, $YBDB) or die(mysql_error());
$result = mysql_fetch_assoc($sql);
echo json_encode($result);
echo json_encode(membership_benefits($_POST['contact_id']));
} // Membership Benefits
@ -219,6 +208,9 @@ $timezone = TIMEZONE;
$total = $stand_time * $stand_time_hourly_rate;
$stand_time_array = array("total" => $total, "hours" => $hours, "minutes" => $minutes, "answer" => $answer);
if(membership_benefits($_POST['contact_id'])) {
$stand_time_array["membership"] = true;
}
echo json_encode($stand_time_array);
} // end if time_ins

Loading…
Cancel
Save