Exemplo n.º 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);
 }
 public function saveAction(Request $request)
 {
     $params = $request->all();
     unset($params['_token'], $params['q']);
     if (strlen($params['password'])) {
         $params['password'] = Crypt::encrypt($params['password']);
     }
     if ($request->getMethod() == 'POST') {
         // saving data!
         $isValid = $this->repository->validateRequest($request);
         if (!is_bool($isValid)) {
             $request->session()->flash('message', "Invalid data, please check the following errors: ");
             $request->session()->flash('validationErrros', $isValid);
             return redirect()->route('configuration')->withInput();
         }
         $configuration = $this->repository->findById($params['id']);
         if (!$configuration) {
             $request->session()->flash('message', "Configuration not found");
             return redirect('configuration');
         }
         $this->repository->update($params, $params['id']);
         $request->session()->flash('message', "Configuration updated successfully!");
         $request->session()->flash('success', true);
         return redirect('configuration');
     }
     $request->session()->flash('message', "Method not allowed");
     return redirect('configuration');
 }
Exemplo n.º 3
0
 /**
  * @param Tasks $task
  * @return bool
  */
 public function saved(Tasks $task)
 {
     $configurationRepository = new ConfigurationRepository();
     $enableQueueProcess = $configurationRepository->getValue('enable_queue_process');
     if ($task->status != Tasks::STATUS_PENDING || !$enableQueueProcess) {
         return true;
     }
     $this->dispatch(new TaskProcess($task->id));
     return true;
 }
Exemplo n.º 4
0
 /**
  * @param null $password
  * @throws \Exception
  */
 public function __construct($password = null)
 {
     libxml_use_internal_errors(true);
     $configurationRepository = new ConfigurationRepository();
     $this->configuration = $configurationRepository->findFirst();
     $this->password = $password;
     $this->checkConfiguration();
     $this->taskRepository = new TaskRepository();
     $jar = new \GuzzleHttp\Cookie\CookieJar();
     $options = array_merge(['cookies' => $jar], self::$defaultOptions);
     $this->client = new Client($options);
 }
Exemplo n.º 5
0
 /**
  * @return bool
  */
 public function handle()
 {
     $configurationRepository = new ConfigurationRepository();
     $enableQueueProcess = $configurationRepository->getValue('enable_queue_process');
     $task = Tasks::findOrNew($this->idTask);
     if (!$enableQueueProcess || !$task->id || $task->status != Tasks::STATUS_PENDING) {
         return true;
     }
     $processor = new TaskProcessor();
     $processor->processOneTask($task);
     return true;
 }