|
@ -89,49 +89,57 @@ $(function(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// could have done this in php, but this separates out the view logic
|
|
|
// could have done this in php, but this separates out the view logic
|
|
|
var d = new Date(); |
|
|
var membership_ids, volunteer_ids; |
|
|
volunteer_status(); |
|
|
var last_index = $("#shop_log tr[id]").length; |
|
|
|
|
|
|
|
|
var membership_ids; |
|
|
|
|
|
var last_index = $("#shop_log tr").length; |
|
|
|
|
|
if (last_index) { |
|
|
if (last_index) { |
|
|
last_index = last_index -1; |
|
|
last_index = last_index - 1; |
|
|
$.each($("#shop_log tr"), function(index) { |
|
|
$.each($("#shop_log tr[id]"), function(index) { |
|
|
|
|
|
|
|
|
if (this.id) { |
|
|
if (this.id) { |
|
|
|
|
|
|
|
|
var id = this.id; |
|
|
var id = this.id; |
|
|
|
|
|
|
|
|
// 2 tr for first created login
|
|
|
if (last_index <= 1) { |
|
|
if (last_index <= 2) { |
|
|
membership_ids = "contact_id=" + id; |
|
|
membership_ids = "contact_id=" + id; |
|
|
} |
|
|
} |
|
|
else if (!membership_ids) { |
|
|
else if (!membership_ids) { |
|
|
membership_ids = "(contact_id=" + id + " OR "; |
|
|
membership_ids = "(contact_id=" + id + " OR "; |
|
|
} else if ( index === last_index) { |
|
|
} else if ( index === last_index) { |
|
|
membership_ids += "contact_id=" + id + ")"; |
|
|
membership_ids += "contact_id=" + id + ")"; |
|
|
} else { |
|
|
} else { |
|
|
membership_ids += "contact_id=" + id + " OR "; |
|
|
membership_ids += "contact_id=" + id + " OR "; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (membership_ids) { |
|
|
|
|
|
volunteer_ids = membership_ids.replace(/contact_id/g,"contacts.contact_id"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var d = new Date(); |
|
|
|
|
|
volunteer_status(volunteer_ids); |
|
|
membership_status(membership_ids); |
|
|
membership_status(membership_ids); |
|
|
|
|
|
|
|
|
// volunteer status
|
|
|
// volunteer status
|
|
|
function volunteer_status() { |
|
|
function volunteer_status(contacts) { |
|
|
|
|
|
|
|
|
$.each($("#shop_log tr"), function() { |
|
|
var all_members_obj; //reuse this object
|
|
|
|
|
|
|
|
|
if (this.id) { |
|
|
if (contacts) { |
|
|
var id = this.id; |
|
|
|
|
|
|
|
|
|
|
|
$.post("json/transaction.php", { volunteer_benefits: 1, contact_id: this.id }, function (data) { |
|
|
$.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 year = d.getFullYear(); |
|
|
var bikes_earned = 0; |
|
|
var bikes_earned = 0; |
|
|
var volunteer_hours_redeemed = 0; |
|
|
var volunteer_hours_redeemed = 0; |
|
|
var obj = $.parseJSON(data); |
|
|
var obj = this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var volunteer = "", remaining = 0, vhr = "", max_bikes_earned = 0; |
|
|
var volunteer = "", remaining = 0, vhr = "", max_bikes_earned = 0; |
|
|
if (obj.volunteer) { |
|
|
if (obj.volunteer) { |
|
@ -217,9 +225,34 @@ $(function(){ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); // post volunteer benefits
|
|
|
}); // each all_members_obj
|
|
|
} // if id
|
|
|
}); // post volunteer benefits
|
|
|
}); // each tr
|
|
|
} // if this is a volunteer
|
|
|
|
|
|
|
|
|
|
|
|
// not a current volunteer within the last 365 days, or never has been a volunteer
|
|
|
|
|
|
$(".volunteer_hours:not([title])").prevAll(".existing_shop_user") |
|
|
|
|
|
.children().each( function() { |
|
|
|
|
|
|
|
|
|
|
|
var name = $(this).text(); |
|
|
|
|
|
var name_obj = name.trim().split(", "); |
|
|
|
|
|
name = name_obj[1] + " " + name_obj[0]; |
|
|
|
|
|
|
|
|
|
|
|
var id = this.href.split("=")[1]; |
|
|
|
|
|
|
|
|
|
|
|
var title = name + "\r\n" + |
|
|
|
|
|
"Volunteer Hours for last 365 days: None" + "\r\n"; |
|
|
|
|
|
|
|
|
|
|
|
$(".volunteer_hours_" + id). |
|
|
|
|
|
html("<span class='update_interests'><a href='./contact_add_edit_select.php?contact_id=" + |
|
|
|
|
|
id + |
|
|
|
|
|
"'>Update Interests</a></span>"). |
|
|
|
|
|
parent().css({backgroundColor: "rgb(190, 199, 204)", textAlign: "center", cursor: "cell"}). |
|
|
|
|
|
prop("title",title).css({textAlign: "center"}); |
|
|
|
|
|
|
|
|
|
|
|
$('.update_interests a').css({color: "#1b691e", textDecoration: "none", cursor: "crosshair"}); |
|
|
|
|
|
$('.update_interests a').hover( function(e){ $(this).css("color",e.type === "mouseenter"?"blue":"#1b691e");}); |
|
|
|
|
|
|
|
|
|
|
|
}); // .each not a current volunteer
|
|
|
|
|
|
|
|
|
} // function volunteer_status
|
|
|
} // function volunteer_status
|
|
|
|
|
|
|
|
@ -232,56 +265,54 @@ $(function(){ |
|
|
var membership_transaction; |
|
|
var membership_transaction; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//$.each($("#shop_log tr"), function() {
|
|
|
if (contacts) { |
|
|
|
|
|
|
|
|
if (contacts) { |
|
|
$.post("json/transaction.php", { membership_benefits: 1, contact_id: contacts }, function (data) { |
|
|
|
|
|
|
|
|
$.post("json/transaction.php", { membership_benefits: 1, contact_id: contacts }, function (data) { |
|
|
all_members_obj = $.parseJSON(data); |
|
|
|
|
|
|
|
|
all_members_obj = $.parseJSON(data); |
|
|
$.each(all_members_obj, function() { |
|
|
|
|
|
|
|
|
$.each(all_members_obj, function() { |
|
|
var membership_obj = this; |
|
|
|
|
|
|
|
|
var membership_obj = this; |
|
|
var title = membership_obj.normal_full_name + "\r\n" + |
|
|
|
|
|
"expiration: " + membership_obj.expiration_date; |
|
|
|
|
|
|
|
|
var title = membership_obj.normal_full_name + "\r\n" + |
|
|
|
|
|
"expiration: " + membership_obj.expiration_date; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (membership_obj.expiration_date) { |
|
|
if (membership_obj.expiration_date) { |
|
|
var exp = membership_obj.expiration_date; |
|
|
var exp = membership_obj.expiration_date; |
|
|
expiration_date = new Date(exp.split("-").toString()); |
|
|
expiration_date = new Date(exp.split("-").toString()); |
|
|
if (d < expiration_date) { |
|
|
if (d < expiration_date) { |
|
|
membership_transaction = true; |
|
|
membership_transaction = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (typeof membership_obj.expiration_date && membership_obj.expiration_date !== undefined) { |
|
|
if (typeof membership_obj.expiration_date && membership_obj.expiration_date !== undefined) { |
|
|
|
|
|
|
|
|
var exp = membership_obj.expiration_date; |
|
|
var exp = membership_obj.expiration_date; |
|
|
expiration_date = new Date(exp.split("-").toString()); |
|
|
expiration_date = new Date(exp.split("-").toString()); |
|
|
|
|
|
|
|
|
// expired membership
|
|
|
// expired membership
|
|
|
if (d >= expiration_date) { |
|
|
if (d >= expiration_date) { |
|
|
$(".paid_membership_" + membership_obj.contact_id).html("Expired"). |
|
|
$(".paid_membership_" + membership_obj.contact_id).html("Expired"). |
|
|
parent().css({backgroundColor: "red", textAlign: "center", cursor: "cell", textDecoration: "none"}).prop("title",title); |
|
|
parent().css({backgroundColor: "red", textAlign: "center", cursor: "cell", textDecoration: "none"}).prop("title",title); |
|
|
|
|
|
|
|
|
// paid membership
|
|
|
// paid membership
|
|
|
} else if (d < expiration_date) { |
|
|
} else if (d < expiration_date) { |
|
|
$(".paid_membership_" + membership_obj.contact_id).html("Current"). |
|
|
$(".paid_membership_" + membership_obj.contact_id).html("Current"). |
|
|
parent().css({backgroundColor: "green", textAlign: "center", cursor: "cell"}).prop("title",title).css({textAlign: "center"}); |
|
|
parent().css({backgroundColor: "green", textAlign: "center", cursor: "cell"}).prop("title",title).css({textAlign: "center"}); |
|
|
|
|
|
|
|
|
} // paid membership
|
|
|
} // paid membership
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); // each all_members_obj
|
|
|
}); // each all_members_obj
|
|
|
}); // end if this a paid member
|
|
|
}); // end if this a paid member
|
|
|
|
|
|
|
|
|
// never been a member
|
|
|
// never been a member
|
|
|
$(".paid_membership:not([title])").css({cursor: "not-allowed"}); |
|
|
$(".paid_membership:not([title])").css({cursor: "not-allowed"}); |
|
|
|
|
|
|
|
|
} // if contacts
|
|
|
} // if contacts
|
|
|
} // function membership status
|
|
|
} // function membership status
|
|
|
|
|
|
|
|
|
}); |
|
|
}); |