Exemple #1
0
 public function getDataToAppointmentGraph($date)
 {
     $graphData = $this->reportsRepository->getDatatoDashboard($date);
     $hoursService = new HoursControl();
     $hoursGraph = [];
     $tasksGraph = [];
     $labelsGraph = [];
     $monthHours = [];
     $percentageHours = [];
     $eletronicPointHours = [];
     foreach ($graphData as $data) {
         $dataBase = $data->split_date . '-01';
         $dataBase = Carbon::createFromFormat('Y-m-d', $dataBase);
         $pointHours = $hoursService->getHoursByDate($dataBase->firstOfMonth()->format('Y-m-d'), $dataBase->endOfMonth()->format('Y-m-d'), true);
         $pointHours = str_replace(':', '.', $pointHours);
         $eletronicPointHours[] = substr($pointHours, 0, 5);
         $auxDate = explode('-', $data->split_date);
         $hoursInMonth = $this->getTotalHoursByMonth($auxDate[0], $auxDate[1]);
         $monthHours[] = $hoursInMonth;
         $percentageHours[] = round($data->hours / $hoursInMonth * 100, 2);
         $hoursGraph[] = $data->hours;
         $tasksGraph[] = $data->tasks;
         $labelsGraph[] = Date::$months[$auxDate[1]] . '/' . $auxDate[0];
     }
     return ['eletronicPointHours' => $eletronicPointHours, 'monthGraph' => $monthHours, 'hoursGraph' => $hoursGraph, 'tasksGraph' => $tasksGraph, 'labelsGraph' => $labelsGraph, 'percentageGraph' => $percentageHours];
 }
 public function reportAction(Request $request)
 {
     $hours = [];
     $startDate = Carbon::now()->firstOfMonth()->format('Y-m-d');
     $endDate = Carbon::now()->endOfMonth()->format('Y-m-d');
     if ($request->input('startDate') && $request->input('endDate')) {
         $startDate = Date::conversion($request->input('startDate'));
         $endDate = Date::conversion($request->input('endDate'));
         $service = new HoursControlService();
         $reports = new Reports();
         $hours = $service->getHoursByDate($startDate, $endDate);
         $hours['workingHours'] = $reports->getTotalWorkingHoursByDate($startDate, $endDate);
     }
     return view('hours-control.report', ['hours' => $hours, 'startDate' => Date::conversion($startDate), 'endDate' => Date::conversion($endDate)]);
 }