/** * Gets the total number of volunteers associated with this organization * during a period. * * @param int $start begin timestamp * @param int $start end timestamp * * @return int */ public function numVolunteers($start = false, $end = false) { if (!$start) { $start = 0; } if (!$end) { $end = time(); } return Volunteer::totalRecords(['organization' => $this->id(), 'created_at >= ' . $start, 'created_at <= ' . $end, 'role >= ' . Volunteer::ROLE_VOLUNTEER]); }
private function getOrgForAdmin($req, $res) { $org = $this->getOrg($req, $res); if (is_object($org)) { if ($org->can('admin', $this->app['user'])) { // calculate the number of unapproved volunteers, places, and hours $unapprovedVolunteers = Volunteer::totalRecords(['organization' => $org->id(), 'role' => Volunteer::ROLE_AWAITING_APPROVAL]); $unapprovedHours = VolunteerHour::totalRecords(['organization' => $org->id(), 'approved' => false]); $unapprovedPlaces = VolunteerPlace::totalRecords(['organization' => $org->id(), 'place_type' => VolunteerPlace::EXTERNAL, 'verify_approved' => false]); $this->app['view_engine']->setGlobalParameters(['volunteersAwaitingApproval' => $unapprovedVolunteers, 'hoursAwaitingApproval' => $unapprovedHours, 'placesAwaitingApproval' => $unapprovedPlaces]); } else { $res->setCode(401); return false; } } return $org; }