function calculateValues(Group $objGroup) { global $startDate; global $endDate; //global $tempDate; global $objPersonArray; global $monthCount; $objGroupParticipationArray = $objGroup->GetGroupParticipationArray(); foreach ($objGroupParticipationArray as $objParticipation) { // If role is Volunteer or Volunteer Leader if ($objParticipation->GroupRole->GroupRoleTypeId == 1 || $objParticipation->GroupRole->GroupRoleTypeId == 3) { // If a volunteer, then instantiate arrays $tempDate = new QDateTime($startDate); while ($tempDate->IsEarlierOrEqualTo($endDate)) { if ($objParticipation->DateStart < $tempDate && ($objParticipation->DateEnd > $tempDate || $objParticipation->DateEnd == null)) { // Verify unique person each time if (!in_array($objParticipation->PersonId, $objPersonArray[$tempDate->__toString('MMM YYYY')])) { $objPersonArray[$tempDate->__toString('MMM YYYY')][] = $objParticipation->PersonId; $monthCount[$tempDate->__toString('MMM YYYY')]++; } } $tempDate->AddMonths(1); } } } }
/** * Given the start date, end date and meeting day of the week for this class, * this will return an array of all the meeting days * @return QDateTime[] */ public function GetClassMeetingDays() { // Figure out the first real start date $dttStartDate = new QDateTime($this->DateStart); if ($dttStartDate->PhpDate('w') < $this->intMeetingDay) { $dttStartDate->Day += $this->intMeetingDay - $dttStartDate->PhpDate('w'); } else { if ($dttStartDate->PhpDate('w') > $this->intMeetingDay) { $dttStartDate->Day += 7 - ($dttStartDate->PhpDate('w') - $this->intMeetingDay); } } // Array to Return $dttArrayToReturn = array(); while ($dttStartDate->IsEarlierOrEqualTo($this->DateEnd)) { $dttToAdd = new QDateTime($dttStartDate); $dttArrayToReturn[] = $dttToAdd; $dttStartDate->Day += 7; } return $dttArrayToReturn; }