public function index($req, $res) { $org = $this->getOrgForAdmin($req, $res); if (!is_object($org)) { return $org; } $periods = [['title' => 'This Week', 'start' => VolunteerHour::timestampToStartOfDay(strtotime('last Sunday'))], ['title' => 'This Month', 'start' => VolunteerHour::timestampToStartOfDay(mktime(0, 0, 0, date('m'), 1, date('y')))], ['title' => 'This Year', 'start' => VolunteerHour::timestampToStartOfDay(mktime(0, 0, 0, 1, 1, date('y')))], ['title' => 'All Time', 'start' => false]]; foreach ($periods as $k => $period) { $periods[$k]['hoursVolunteered'] = $org->totalHoursVolunteered($period['start']); $periods[$k]['volunteers'] = $org->numVolunteers($period['start']); $topVolunteers = $org->topVolunteers(1, $period['start']); $periods[$k]['topVolunteer'] = count($topVolunteers) == 1 ? $topVolunteers[0] : false; } return new View('dashboard', ['org' => $org, 'title' => 'Pulse', 'periods' => $periods, 'dashboardPage' => true]); }
public function testTimestampToStartOfDay() { $this->assertEquals(mktime(0, 0, 0, 7, 18, 2013), VolunteerHour::timestampToStartOfDay(mktime(10, 10, 10, 7, 18, 2013))); }
public function volunteerHub($req, $res) { $req->setParams(['type' => 'organizations']); $org = $this->getOrg($req, $res); if (!is_object($org)) { return $org; } $periods = [['title' => 'This Week', 'start' => VolunteerHour::timestampToStartOfDay(strtotime('last Sunday'))], ['title' => 'This Month', 'start' => VolunteerHour::timestampToStartOfDay(mktime(0, 0, 0, date('m'), 1, date('y')))], ['title' => 'This Year', 'start' => VolunteerHour::timestampToStartOfDay(mktime(0, 0, 0, 1, 1, date('y')))], ['title' => 'All Time', 'start' => false]]; foreach ($periods as $k => $period) { $periods[$k]['hoursVolunteered'] = $org->totalHoursVolunteered($period['start']); $periods[$k]['volunteers'] = $org->numVolunteers($period['start']); $topVolunteers = $org->topVolunteers(1, $period['start']); $periods[$k]['topVolunteer'] = count($topVolunteers) == 1 ? $topVolunteers[0] : false; } $role = $org->getRoleOfUser($this->app['user']); return new View('profile', ['title' => $org->name . ' Volunteer Hub', 'org' => $org->toArray(), 'orgObj' => $org, 'username' => $org->username, 'awaitingApproval' => $role == Volunteer::ROLE_AWAITING_APPROVAL, 'isVolunteer' => $role >= Volunteer::ROLE_VOLUNTEER, 'isVolunteerCoordinator' => $role == Volunteer::ROLE_ADMIN, 'topVolunteers' => $org->topVolunteers(6), 'periods' => $periods, 'rsvpd' => $req->query('rsvpd')]); }