Пример #1
0
 /**
  * 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);
 }
Пример #2
0
 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']));
 }