/** * Execute the console command. * * @return mixed */ public function handle() { $this->comment(PHP_EOL . 'Start pending hours validation' . PHP_EOL); $referenceDate = Carbon::now(); $referenceDate->hour(13)->minute(0)->second(0); $configurationRepository = new ConfigurationRepository(); $enableQueueProcess = $configurationRepository->getValue('enable_queue_process'); $reportsService = new Reports(); $now = Carbon::now(); if ($referenceDate->diffInMinutes($now, false) > 0) { $date = $now; } else { $date = Carbon::now()->subDay(1); } $this->info(PHP_EOL . 'Checking ' . $date->format('d/m/Y') . PHP_EOL); $pendingAppointment = $reportsService->getDaysWithPendingAppointmentHours($date, $date); if (isset($pendingAppointment['hoursPending'][0]) && $pendingAppointment['hoursPending'][0] > 0) { $notifier = NotifierFactory::create(); $message = sprintf('You have pending hours in the day %s. You need to send %s hours.', $pendingAppointment['date'][0], $pendingAppointment['hoursPending'][0]); $this->error(PHP_EOL . $message . PHP_EOL); if ($notifier) { // Create your notification $notification = (new Notification())->setTitle('Pending Hours')->setBody($message)->setIcon(__DIR__ . '/../../../public/img/clock.png'); // Send it $notifier->send($notification); } } $this->comment(PHP_EOL . 'End pending hours validation' . PHP_EOL); }
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'])); }
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)]); }