diff --git a/src/Command/FulfillAssignedJobOrderCommand.php b/src/Command/FulfillAssignedJobOrderCommand.php index ae17f5ac..a26067e2 100644 --- a/src/Command/FulfillAssignedJobOrderCommand.php +++ b/src/Command/FulfillAssignedJobOrderCommand.php @@ -43,17 +43,18 @@ class FulfillAssignedJobOrderCommand extends Command { $this->setName('joborder:fulfillassignednosms') ->setDescription('Fulfill assigned job orders without sending an SMS message.') - ->setHelp('Mark assigned job orders as fulfilled after a set time has passed with no update and should not send a SMS message'); + ->setHelp('Mark assigned job orders as fulfilled and should not send a SMS message. Date format: YYYY-MM-DD') + ->addArgument('end_date', InputArgument::REQUIRED, 'End date. Format: YYYY-MM-DD'); } protected function execute(InputInterface $input, OutputInterface $output) { - // retrieve job orders that have status assigned and has not been updated after a certain amount of time has passed. + // get the input date + $str_date_end = $input->getArgument('end_date'); + + // retrieve job orders that have status assigned and has not been fulfilled starting from input date and before. // starting time to count is date schedule - $time_now = new DateTime(); - $date_end = new DateTime(); - // TODO: for now set to 2 hours - $date_end->add(new DateInterval('PT2H')); + $date_end = new DateTime($str_date_end); $query = $this->em->createQuery('SELECT jo FROM App\Entity\JobOrder jo WHERE jo.status = :status AND jo.date_schedule <= :date_end'); @@ -71,6 +72,8 @@ class FulfillAssignedJobOrderCommand extends Command foreach ($jo_results as $jo) { + error_log('Fulfilling job order ' . $jo->getID()); + $jo->fulfill(); // set delivery status