Browse Source

Fixes #51; a matter of SQL.

devel
Jonathan Rosenbaum 7 years ago
parent
commit
937bf5adff
  1. 11
      js/shop.js
  2. 7
      json/transaction.php

11
js/shop.js

@ -126,21 +126,20 @@ $(function(){
function volunteer_status(contacts) {
var all_members_obj; //reuse this object
var year = d.getFullYear();
if (contacts) {
$.post("json/transaction.php", { volunteer_benefits: 1, contact_id: contacts }, function (data) {
all_members_obj = $.parseJSON(data);
$.each(all_members_obj, function() {
var year = d.getFullYear();
var bikes_earned = 0;
var volunteer_hours_redeemed = 0;
var obj = this;
var volunteer = "", remaining = 0, vhr = "", max_bikes_earned = 0;
if (obj.volunteer) {
volunteer = $.parseJSON(obj.volunteer);
@ -158,7 +157,7 @@ $(function(){
"Volunteer Hours Remaining: " + remaining + "\r\n" +
"Max Bikes Earned: " + max_bikes_earned;
var volunteer_with_redeemed_hours_at_zero = obj.current_year_volunteer_hours - vhr;
var volunteer_with_redeemed_hours_at_zero = obj.current_year_volunteer_hours - vhr;
if (obj.contact_id) {

7
json/transaction.php

@ -125,7 +125,7 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
AND shop_user_roles.volunteer = 1 AND " .
$_POST['contact_id'] .
" GROUP BY contact_id) AS firstset
INNER JOIN
LEFT JOIN
(SELECT contacts.contact_id,
COUNT(shop_hours.contact_id) AS current_year_visits,
ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS current_year_volunteer_hours
@ -137,7 +137,10 @@ $membership_discount = MEMBERSHIP_DISCOUNT;
AND shop_user_roles.volunteer = 1
AND " .
$_POST['contact_id'] .
") AS secondset;";
" GROUP BY contact_id) AS secondset ON firstset.contact_id = secondset.contact_id;";
//$handler->debug($query);
$sql = mysql_query($query, $YBDB) or die(mysql_error());

Loading…
Cancel
Save