Example #1
0
 /**
  * @param $startDateAppointmentCheck
  * @param $endDateAppointmentCheck
  * @return array|mixed
  */
 public function getDaysWithPendingAppointmentHours($startDateAppointmentCheck, $endDateAppointmentCheck)
 {
     $datesWithPendingAppointment = $this->reportsRepository->getDaysWithoutFullHours($startDateAppointmentCheck);
     $period = Date::getDatesFromRange($startDateAppointmentCheck, $endDateAppointmentCheck);
     $return = [];
     foreach ($period as $date) {
         if (Date::isWeekend($date)) {
             continue;
         }
         if (Date::isHoliday($date)) {
             continue;
         }
         foreach ($datesWithPendingAppointment as $key => $pendingDay) {
             if ($date == $pendingDay->date) {
                 if ($pendingDay->hours < 8) {
                     $return[] = $pendingDay;
                     continue 2;
                 }
                 continue 2;
             }
         }
         $newDate = new \stdClass();
         $newDate->hours = 0;
         $newDate->hoursPending = 8;
         $newDate->date = $date;
         $return[] = $newDate;
     }
     $this->sortByArrayObjectDate($return);
     return $this->transformDataToGraph($return);
 }
 public function indexAction()
 {
     $reportsService = new Reports();
     $date = Carbon::now()->subYear(1);
     $totalsYear = $this->repository->getTotals($date);
     $graphData = $reportsService->getDataToAppointmentGraph($date);
     $lastTasks = $this->repository->getLastTasks();
     $startDateAppointmentCheck = Carbon::now()->subMonth(1);
     $endDateAppointmentCheck = Carbon::now()->format('Y-m-d');
     $datesWithPendingAppointment = $reportsService->getDaysWithPendingAppointmentHours($startDateAppointmentCheck, $endDateAppointmentCheck);
     $task = new Tasks();
     $task->status = Tasks::STATUS_PENDING;
     return view('dashboard.index')->with('hoursGraph', json_encode($graphData['hoursGraph']))->with('tasksGraph', json_encode($graphData['tasksGraph']))->with('labelsGraph', json_encode($graphData['labelsGraph']))->with('lastTasks', $lastTasks)->with('statusLabels', self::$statusLabels)->with('task', $task)->with('redirect', 'dashboard')->with('totalsYear', $totalsYear)->with('daysPendingHourGraph', json_encode($datesWithPendingAppointment['hours']))->with('daysPendingHourPendingGraph', json_encode($datesWithPendingAppointment['hoursPending']))->with('daysPendingLabelsGraph', json_encode($datesWithPendingAppointment['date']));
 }