diff --git a/src/Command/SetCustomerMobileAppFlagCommand.php b/src/Command/SetCustomerMobileAppFlagCommand.php new file mode 100644 index 00000000..8671865d --- /dev/null +++ b/src/Command/SetCustomerMobileAppFlagCommand.php @@ -0,0 +1,66 @@ +em = $em; + + parent::__construct(); + } + + protected function configure() + { + $this->setName('customer:setmobileappflag') + ->setDescription('Sets customers mobile app flag.') + ->setHelp('Sets customers mobile app flag.'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + // get all mobile sessions with a customer, confirm_flag true + $conn = $this->em->getConnection(); + + $ms_sql = 'SELECT ms.customer_id AS cust_id + FROM mobile_session ms + WHERE ms.customer_id is not null + AND ms.confirm_flag = :confirm_flag'; + $ms_stmt = $conn->prepare($ms_sql); + $ms_stmt->bindValue('confirm_flag', true); + + $ms_results = $ms_stmt->executeQuery(); + + while ($row = $ms_results->fetchAssociative()) + { + $cust_id = $row['cust_id']; + + // need to get the customer object itself + $customer = $this->em->getRepository(Customer::class)->find($cust_id); + if ($customer != null) + { + error_log('Setting customer mobile app flag to true for ' . $cust_id); + // set mobile app flag + $customer->setHasMobileApp(); + } + } + + $this->em->flush(); + + return 0; + } +} diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 0df9bffe..6ab112ef 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -374,6 +374,9 @@ class APIController extends Controller implements LoggedController // TODO: if there is a dupe_sess, do we need to check if // dupe_cust is the same as the customer we found? $this->session->setCustomer($customer); + + // set the flag mobile app for the customer + $customer->setHasMobileApp(); } $em->flush(); diff --git a/src/Service/CustomerHandler/ResqCustomerHandler.php b/src/Service/CustomerHandler/ResqCustomerHandler.php index f8685801..a76ec8ea 100644 --- a/src/Service/CustomerHandler/ResqCustomerHandler.php +++ b/src/Service/CustomerHandler/ResqCustomerHandler.php @@ -553,6 +553,7 @@ class ResqCustomerHandler implements CustomerHandlerInterface 'flag_research_sms' => $customer->isResearchSms(), 'flag_research_email' => $customer->isResearchEmail(), 'customer_tags' => $customer->getCustomerTags(), + 'flag_mobile_app' => $customer->hasMobileApp(), ], 'vehicle' => [ 'id' => $vehicle->getID(), diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index e57f8114..6b0822fa 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -200,11 +200,24 @@