diff --git a/src/Command/ImportCarClubCustomerHubCommand.php b/src/Command/ImportCarClubCustomerHubCommand.php index 3b16d4b2..29040955 100644 --- a/src/Command/ImportCarClubCustomerHubCommand.php +++ b/src/Command/ImportCarClubCustomerHubCommand.php @@ -98,9 +98,12 @@ class ImportCarClubCustomerHubCommand extends Command // get first customer that matches any of the numbers $customer = $this->findCustomerByNumbers($valid_contact_numbers); - // if no customer found, log to output info + // if no customer found, create one if ($customer == null) { + error_log('Creating customer...'); + + // TODO: create customer // add info to output array return $this->setOutputInfo($fields, 'NOT ADDED', 'No customer found', ''); } diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index e50f12ec..eacf6195 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -446,6 +446,29 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface } } + // check service type if new battery + // check if new JO + if (($stype == ServiceType::BATTERY_REPLACEMENT_NEW) && + ($flag_new_jo)) + { + // check if customer has customer tag promo + if (($customer->getCustomerTag('TAG_CAR_CLUB_OFFICER_PROMO')) || + ($customer->getCustomerTag('TAG_CAR_CLUB_MEMBER_PROMO'))) + { + // if has customer tag, customer has not availed of promo, get the hub where customer is pre-registered + $car_club_hub = $customer->getCarClubCustomerHub(); + if ($car_club_hub != null) + { + // assign hub, change the jo status + $hub = $car_club_hub->getHub(); + $jo->setHub($hub) + ->setStatus(JOStatus::RIDER_ASSIGN); + } + } + + } + + // call service to generate job order and invoice $invoice_items = $req->request->get('invoice_items', []); $promo_id = $req->request->get('invoice_promo'); @@ -484,6 +507,22 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface } $em->persist($event); + + // check if JOStatus is rider assign + if ($jo->getStatus() == JOStatus::RIDER_ASSIGN) + { + $rider_assign_event = new JOEvent(); + $rider_assign_event->setDateHappen(new DateTime()) + ->setTypeID(JOEventType::HUB_ASSIGN) + ->setJobOrder($jo); + + if ($user != null) + { + $rider_assign_event->setUser($user); + } + $em->persist($rider_assign_event); + } + $em->flush(); } }