/** * Generates whole week from a specific date * @param string * @return array */ public static function getWeek($date) { $week = array(); $allmonths = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $tempDate = new ExpressiveDate($date); $startWeek = $tempDate->startOfWeek()->getDate(); $currentDay = new ExpressiveDate($startWeek); for ($i = 0; $i < 7; $i++) { $tempday = array(); $tempday['day'] = $currentDay->getDay(); $tempday['year'] = $currentDay->getYear(); $tempday['dayofweek'] = $currentDay->getDayOfWeek(); $tempday['month'] = $allmonths[(int) $currentDay->getMonth()]; $tempday['class'] = 'calendar-day-' . $currentDay->getDate(); $tempday['date'] = $currentDay->getDate(); $currentDay = $currentDay->addOneDay(); $week[] = $tempday; } return $week; }
/** * Generate the Monthly Project Report for Selected User * @return View */ public function postUserProjectReport() { //Get the selected UserId $userId = \Input::get('userprojectreportid'); //Get Details of User $user = \User::find($userId); $firstName = $user->first_name; $lastName = $user->last_name; //Get selected Project Id $projectId = \Input::get('projectmonth'); //Get the selected Date for the month $selectedMonth = \Input::get('userprojectdate_submit'); //Generate Month from the date $daysArray = \DateAndTime::getMonthDates($selectedMonth); //Get Data $data = $this->report->generateWeeklyProjectReport($daysArray, $projectId, $userId); //Manipulation for View $tempDates = array(); foreach ($daysArray as $day) { $tempDay = new \ExpressiveDate($day); $tempDates[] = $tempDay->format('jS F, Y'); } //Manipulation for Charts $chartWeek = json_encode($tempDates); $tempDate = new \ExpressiveDate($selectedMonth); $year = $tempDate->getYear(); $month = $tempDate->getMonth(); $totalNoOfDays = (int) $tempDate->getDaysInMonth(); $allmonths = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $chartWeekData = json_encode($data['dayTime'], JSON_NUMERIC_CHECK); return \View::make('dashboard.reports.monthlyproject')->with('data', $data)->with('name', $firstName . $lastName)->with('totalDays', $totalNoOfDays)->with('dates', $daysArray)->with('year', (int) $year)->with('month', $allmonths[(int) $month])->with('chartWeek', $chartWeek)->with('chartWeekData', $chartWeekData); }