From 97f02b678808f911b83d2387b00f2a4b6bdba6a7 Mon Sep 17 00:00:00 2001 From: Jonathan Rosenbaum Date: Fri, 26 Oct 2018 21:48:43 +0000 Subject: [PATCH] This should close #42. --- stats/community_service_hours.php | 18 ++---------------- stats/paid_members.php | 2 +- stats/shops.php | 1 - stats/stats_monthlysalestax.php | 14 +++++++------- stats/stats_paidstaffhours.php | 2 +- stats/stats_paidstaffhours_byPayPeriod.php | 2 +- stats/stats_usersbyweek.php | 4 ++-- stats/status_totals.php | 13 ++++++------- 8 files changed, 20 insertions(+), 36 deletions(-) diff --git a/stats/community_service_hours.php b/stats/community_service_hours.php index b6c59bc..e07cfef 100644 --- a/stats/community_service_hours.php +++ b/stats/community_service_hours.php @@ -41,30 +41,16 @@ if (isset($_POST['range1'])) { $today = $range2; } -/* - -SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name, -COUNT(shop_hours.contact_id) as cs_volunteer_visits, -ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS cs_volunteer_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 $days_range1 DAY) AND time_in <= DATE_SUB(CURDATE(), INTERVAL $days_range2 DAY)) -AND shop_user_roles.other_volunteer = 1 -GROUP BY contact_id -ORDER BY sort_hours DESC; - -*/ - $query = "SELECT contacts.contact_id, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS full_name, COUNT(shop_hours.contact_id) as cs_volunteer_visits, - ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS cs_volunteer_hours + ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS cs_volunteer_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.other_volunteer = 1 + AND shop_hours.shop_user_role = 'Student Volunteer/Community Service Hours' GROUP BY contact_id ORDER BY cs_volunteer_hours DESC;"; $cs_volunteers_sql = mysql_query($query, $YBDB) or die(mysql_error()); diff --git a/stats/paid_members.php b/stats/paid_members.php index f0bd28a..1c9c0da 100644 --- a/stats/paid_members.php +++ b/stats/paid_members.php @@ -41,7 +41,7 @@ $query = "SELECT contact_id, full_name, normal_full_name, email, phone, sort_vis 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 +ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, 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 diff --git a/stats/shops.php b/stats/shops.php index 7130847..935c408 100644 --- a/stats/shops.php +++ b/stats/shops.php @@ -33,7 +33,6 @@ 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()); diff --git a/stats/stats_monthlysalestax.php b/stats/stats_monthlysalestax.php index 6ab4291..89db5b6 100644 --- a/stats/stats_monthlysalestax.php +++ b/stats/stats_monthlysalestax.php @@ -37,13 +37,13 @@ $totalRows_Recordset1 = mysql_num_rows($Recordset1); - +
- - - - + + + + - + - + 0,Year(time_in),Year(time_in)-1) as Year, IF(Week(time_in) DIV 2 <>0,Week(time_in) DIV 2,26 ) as PayPeriod, contacts.contact_id as ContactID, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS Name, COUNT(shop_hours.contact_id) as Shifts, -ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60),1) AS Hours +ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS 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 diff --git a/stats/stats_paidstaffhours_byPayPeriod.php b/stats/stats_paidstaffhours_byPayPeriod.php index 378e187..47659b4 100644 --- a/stats/stats_paidstaffhours_byPayPeriod.php +++ b/stats/stats_paidstaffhours_byPayPeriod.php @@ -20,7 +20,7 @@ $query_Recordset1 = "SELECT * FROM (SELECT IF(Week(time_in) DIV 2 <>0,Year(time_in),Year(time_in)-1) as Year, IF(Week(time_in) DIV 2 <>0,Week(time_in) DIV 2,26 ) as PayPeriod, contacts.contact_id as ContactID, CONCAT(last_name, ', ', first_name, ' ',middle_initial) AS Name, COUNT(shop_hours.contact_id) as Shifts, -ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60),1) AS Hours +ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS 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 diff --git a/stats/stats_usersbyweek.php b/stats/stats_usersbyweek.php index 9b59c67..709489c 100644 --- a/stats/stats_usersbyweek.php +++ b/stats/stats_usersbyweek.php @@ -27,7 +27,7 @@ $total_users = $row_Recordset2['total_users']; $query_Recordset3 = "SELECT year(date), week(date), COUNT(shop_visit_id) AS total_visitors, -ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS total_hours +ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS total_hours FROM shops LEFT JOIN shop_hours ON shops.shop_id = shop_hours.shop_id GROUP BY year(date), week(date) ORDER BY year(date) DESC, week(date) DESC"; @@ -37,7 +37,7 @@ $totalRows_Recordset3 = mysql_num_rows($Recordset3); $query_Recordset4 = "SELECT year(date), week(date), COUNT(shop_visit_id) AS volunteer_visitors, -ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS volunteer_hours +ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS volunteer_hours FROM shops LEFT JOIN shop_hours ON shops.shop_id = shop_hours.shop_id LEFT JOIN shop_user_roles ON shop_hours.shop_user_role = shop_user_roles.shop_user_role_id diff --git a/stats/status_totals.php b/stats/status_totals.php index 0494dda..167afc5 100644 --- a/stats/status_totals.php +++ b/stats/status_totals.php @@ -42,8 +42,8 @@ if (isset($_POST['range1'])) { $query = "SELECT shop_user_role, COUNT(DISTINCT shop_hours.contact_id) as unique_volunteers, - COUNT(shop_hours.contact_id) as volunteer_visits, - ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS volunteer_hours + COUNT(shop_hours.contact_id) as volunteer_visits, + ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS volunteer_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 @@ -54,7 +54,7 @@ $query = "SELECT shop_user_role, $query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_volunteers, COUNT(shop_hours.contact_id) as volunteer_visits, - ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS volunteer_hours + ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS volunteer_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 @@ -64,8 +64,7 @@ $total_volunteers_sql = mysql_query($query, $YBDB) or die(mysql_error()); $query = "SELECT shop_user_role, COUNT(DISTINCT shop_hours.contact_id) as unique_visitors, COUNT(shop_hours.contact_id) as visits, - ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), - TIME(time_in)))/60)) AS hours + ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS 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 @@ -77,7 +76,7 @@ $visitors_sql = mysql_query($query, $YBDB) or die(mysql_error()); $query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_visitors, COUNT(shop_hours.contact_id) as visits, - ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS hours + ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS 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 @@ -87,7 +86,7 @@ $total_visitors_sql = mysql_query($query, $YBDB) or die(mysql_error()); $query = "SELECT COUNT(DISTINCT shop_hours.contact_id) as unique_vv, COUNT(shop_hours.contact_id) as visits, - ROUND(SUM(HOUR(SUBTIME( TIME(time_out), TIME(time_in))) + MINUTE(SUBTIME( TIME(time_out), TIME(time_in)))/60)) AS hours + ROUND(SUM(HOUR(TIMEDIFF( time_out, time_in)) + MINUTE(TIMEDIFF( time_out, time_in))/60)) AS 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
YearMonthTotal SalesAccounting GroupYearMonthTotal SalesAccounting Group