summaryrefslogtreecommitdiffstats
path: root/viewmember.php
diff options
context:
space:
mode:
Diffstat (limited to 'viewmember.php')
-rw-r--r--viewmember.php36
1 files changed, 26 insertions, 10 deletions
diff --git a/viewmember.php b/viewmember.php
index 8087c5e..226356c 100644
--- a/viewmember.php
+++ b/viewmember.php
@@ -44,9 +44,9 @@ if ( (isset($_GET[URI_NAME])) && (strval($_GET[URI_NAME] != '')) )
// Find the percent of raids they've attended in the last 30, 60 and 90 days
$percent_of_raids = array(
- '30' => raid_count(mktime(0, 0, 0, date('m'), date('d')-30, date('Y')), time(), $member['member_name']),
- '60' => raid_count(mktime(0, 0, 0, date('m'), date('d')-60, date('Y')), time(), $member['member_name']),
- '90' => raid_count(mktime(0, 0, 0, date('m'), date('d')-90, date('Y')), time(), $member['member_name']),
+ '30' => raid_count_view('30', $member['member_name']),
+ '60' => raid_count_view('60', $member['member_name']),
+ '90' => raid_count_view('90', $member['member_name']),
'lifetime' => raid_count($member['member_firstraid'], $member['member_lastraid'], $member['member_name'])
);
@@ -394,26 +394,42 @@ else
// ---------------------------------------------------------
// Page-specific functions
// ---------------------------------------------------------
+function raid_count_view($numdays, $member_name)
+{
+ global $db;
+
+ $condition = "(raid_name = 'On time bonus' OR raid_name = 'Attendance Log')";
+
+ $raid_count = $db->query_first('SELECT count(*) FROM ' . RAIDS_TABLE . ' WHERE raid_date >= (unix_timestamp() - ('. $numdays . '*24*3600)) AND ' . $condition);
+
+ $sql = 'SELECT raid_count_' . $numdays . ' FROM R' . $numdays . ' WHERE member_name = \'' . $member_name . '\'';
+ $individual_raid_count = $db->query_first($sql);
+
+ $percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0;
+
+ return $percent_of_raids;
+}
+
function raid_count($start_date, $end_date, $member_name)
{
global $db;
- $raid_count = $db->query_first('SELECT count(*) FROM ' . RAIDS_TABLE . ' WHERE (raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ')');
+ $condition = "(raid_name = 'On time bonus' OR raid_name = 'Attendance Log')";
+
+ $raid_count = $db->query_first('SELECT count(*) FROM ' . RAIDS_TABLE . ' WHERE (raid_date BETWEEN ' . $start_date . ' AND ' . $end_date . ') AND ' . $condition);
$sql = 'SELECT count(*)
FROM ' . RAID_ATTENDEES_TABLE . ' ra LEFT JOIN ' . RAIDS_TABLE . " r
ON (ra.raid_id = r.raid_id)
WHERE (ra.member_name='" . $member_name . "')
- AND (r.raid_date BETWEEN " . $start_date . ' AND ' . $end_date . ')';
+ AND (r.raid_date BETWEEN " . $start_date . ' AND ' . $end_date . ')
+ AND ' . $condition;
+
$individual_raid_count = $db->query_first($sql);
$percent_of_raids = ( $raid_count > 0 ) ? round(($individual_raid_count / $raid_count) * 100) : 0;
- $raid_count_stats = array(
- 'percent' => $percent_of_raids,
- 'total_count' => $raid_count,
- 'indiv_count' => $individual_raid_count);
+ return $percent_of_raids;
- return $raid_count_stats['percent']; // Only thing needed ATM
}
?>