From 7e38f7a719e3b6920bad590f670753e021b3f281 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 17 Sep 2018 12:34:37 +0800 Subject: [PATCH] Modify rider report to accept date range #162 --- src/Command/ReportRiderTime.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Command/ReportRiderTime.php b/src/Command/ReportRiderTime.php index bfd74900..6ff82031 100644 --- a/src/Command/ReportRiderTime.php +++ b/src/Command/ReportRiderTime.php @@ -33,12 +33,18 @@ class ReportRiderTime extends Command $this->setName('report:rider-time') ->setDescription('Generate CSV file with report on rider time.') ->setHelp('Generate report on rider time from assignment to fulfilled.') - ->addArgument('file', InputArgument::REQUIRED, 'Path to the output CSV file.'); + ->addArgument('file', InputArgument::REQUIRED, 'Path to the output CSV file.') + ->addArgument('date_from', InputArgument::REQUIRED, 'Date from.') + ->addArgument('date_to', InputArgument::REQUIRED, 'Date to.'); } - protected function populateJOIndex() + protected function populateJOIndex($date_from, $date_to) { - $jo_events = $this->em->createQuery("select e from App\Entity\JOEvent e where e.date_create >= '20180805'") + $jo_events = $this->em->createQuery("select e from App\Entity\JOEvent e where e.date_create >= :dfrom and e.date_create <= :dto") + ->setParameters([ + 'dfrom' => '20180805', + 'dto' => '20180920', + ]) ->getResult(); // $jo_events = $this->em->getRepository(JOEvent::class)->findBy('date_create' => '20180905'); @@ -89,6 +95,11 @@ class ReportRiderTime extends Command foreach ($this->jo_index as $index => $joi) { + // no hub assign because they used re-assign right away + // TODO: fix so we take this into account + if ($joi['hub_assign'] == null) + continue; + if($joi['rider_assign'] != null && $joi['fulfill'] != null) { $this->filtered_jo_index[$index] = $joi; @@ -104,6 +115,8 @@ class ReportRiderTime extends Command protected function execute(InputInterface $input, OutputInterface $output) { $csv_file = $input->getArgument('file'); + $date_from = $input->getArgument('date_from'); + $date_to = $input->getArgument('date_to'); // attempt to open file try @@ -115,7 +128,7 @@ class ReportRiderTime extends Command throw new Exception('The file "' . $csv_file . '" could be opened.'); } - $this->populateJOIndex(); + $this->populateJOIndex($date_from, $date_to); $this->filterJOIndex(); foreach ($this->filtered_jo_index as $joi)