diff --git a/css/stats.css b/css/stats.css index 02d3da2..898336e 100644 --- a/css/stats.css +++ b/css/stats.css @@ -3,7 +3,7 @@ } -#status_totals, #community_service_hours, #shops{ +#status_totals, #community_service_hours, #shops, #members{ height: 36px; width: 98px; font-size: x-large; diff --git a/js/stats.js b/js/stats.js index 0071ad9..c4c1e2b 100644 --- a/js/stats.js +++ b/js/stats.js @@ -49,5 +49,14 @@ $(function(){ }); e.preventDefault(); }); + + $("#members").on("click keypress", function(e){ + var range_display = range.pickmeup('get_date', true); + $.post("members.php", {range1: range_display[0], range2: range_display[1]}, function (data) { + $("body").html(data); + //range.pickmeup.date($range_display[0]); + }); + e.preventDefault(); + }); }); \ No newline at end of file diff --git a/stats.php b/stats.php index 16ab155..ef5c97e 100644 --- a/stats.php +++ b/stats.php @@ -9,7 +9,7 @@

Membership

Volunteer Shops

diff --git a/stats/members.php b/stats/members.php index c5c7d83..8499ed7 100644 --- a/stats/members.php +++ b/stats/members.php @@ -2,6 +2,12 @@ require_once('../Connections/YBDB.php'); require_once('../Connections/database_functions.php'); +$page_individual_history_log = INDIVIDUAL_HISTORY_LOG; +// Needs to volunteer at least this amount of defined hours before being considered a member +$membership_hours = MEMBERSHIP_HOURS; +$membership_days = MEMBERSHIP_DAYS; +$purchased_membership_days = PURCHASED_MEMBERSHIP_DAYS; + mysql_select_db($database_YBDB, $YBDB); @@ -33,24 +39,71 @@ if (isset($_POST['range1'])) { $today = $range2; } - -$query = "SELECT COUNT(shop_id) as total_shops from shops -WHERE (date >= DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) AND date <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY));"; -$shop_totals_sql = mysql_query($query, $YBDB) or die(mysql_error()); - -$query = "SELECT shop_type, COUNT(shop_id) AS shop_totals from shops -LEFT JOIN shop_types ON shops.shop_type = shop_types.shop_type_id -WHERE (date >= DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) AND date <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY)) -GROUP BY shop_type ORDER BY shop_totals DESC;"; -$shop_totals_by_types_sql = mysql_query($query, $YBDB) or die(mysql_error()); +/* + +SELECT contact_id, full_name, email, phone, sort_visits, sort_hours FROM +(SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name, +contacts.email AS email, contacts.phone AS phone, +COUNT(shop_hours.contact_id) as sort_visits, +ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS sort_hours +FROM shop_hours +LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id +LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id +WHERE (time_in > DATE_SUB(CURDATE(),INTERVAL 12 MONTH)) +AND shop_user_roles.volunteer = 1 GROUP BY contact_id) AS members +WHERE sort_hours >= 8 AND sort_visits >= 2 +GROUP by contact_id ORDER by sort_hours DESC, sort_visits DESC; + + +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 sort_hours +FROM transaction_log +LEFT JOIN contacts ON transaction_log.sold_to = contacts.contact_id +WHERE (SUBSTRING_INDEX(date, ' ', 1) >= DATE_SUB(CURDATE(),INTERVAL 365 DAY) +AND SUBSTRING_INDEX(date, ' ', 1) <= DATE_SUB(CURDATE(), INTERVAL 0 DAY)) +AND (transaction_type="Memberships" AND paid=1); + + +*/ + +// Membership via volunteering +$query = "SELECT contact_id, full_name, normal_full_name, email, phone, sort_visits, sort_hours FROM +(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, +COUNT(shop_hours.contact_id) as sort_visits, +ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS sort_hours +FROM shop_hours +LEFT JOIN contacts ON shop_hours.contact_id = contacts.contact_id +LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id +WHERE (SUBSTRING_INDEX(time_in, ' ', 1) >= DATE_SUB(CURDATE(),INTERVAL $days_range1 DAY) +AND SUBSTRING_INDEX(time_in, ' ', 1) <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY)) +AND shop_user_roles.volunteer = 1 GROUP BY contact_id) AS members +WHERE sort_hours >= $membership_hours AND sort_visits >= $membership_days +GROUP by contact_id ORDER by sort_hours DESC, sort_visits DESC;"; +$members = mysql_query($query, $YBDB) or die(mysql_error()); +$num_member_rows = mysql_num_rows($members); + +// Purchased Membership +$purchase_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 sort_hours +FROM transaction_log +LEFT JOIN contacts ON transaction_log.sold_to = contacts.contact_id +WHERE (SUBSTRING_INDEX(date, ' ', 1) >= DATE_SUB(CURDATE(),INTERVAL $purchased_membership_days DAY) +AND SUBSTRING_INDEX(date, ' ', 1) <= DATE_SUB(CURDATE(), INTERVAL 1 DAY)) +AND (transaction_type='Memberships' AND paid=1);"; +$purchased_membership = mysql_query($purchase_query, $YBDB) or die(mysql_error()); ?> - - -Under Construction - + +

@@ -94,12 +147,70 @@ Under Construction
- +
+

Contact Information

+ Email Address:  + + + + +

+ Phone Numbers for Members Without Email Addresses
+ "; + } else { + echo $result['normal_full_name'] . ", " . $result['phone']; + } + } + + $c++; + ?> + + +

+ CSV
+ Name, Phone, Email
+ "; + } else { + echo $result['normal_full_name'] . ", " . $result['phone'] . ", ". $result['email']; + } + + $c++; + ?> +