Add date argument to command. #654

This commit is contained in:
Korina Cordero 2022-03-31 06:45:40 +00:00
parent 618769ab5d
commit 4e1613540d

View file

@ -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