Add command to set to true customers' mobila app flags if customer has mobile app. Add checkbox to JO form to indicate if customer has mobile app. #699

This commit is contained in:
Korina Cordero 2022-08-16 07:23:59 +00:00
parent 52545c8a4f
commit ca3bd52004
4 changed files with 92 additions and 5 deletions

View file

@ -0,0 +1,66 @@
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Customer;
use App\Entity\MobileSession;
class SetCustomerMobileAppFlagCommand extends Command
{
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->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;
}
}

View file

@ -374,6 +374,9 @@ class APIController extends Controller implements LoggedController
// TODO: if there is a dupe_sess, do we need to check if // TODO: if there is a dupe_sess, do we need to check if
// dupe_cust is the same as the customer we found? // dupe_cust is the same as the customer we found?
$this->session->setCustomer($customer); $this->session->setCustomer($customer);
// set the flag mobile app for the customer
$customer->setHasMobileApp();
} }
$em->flush(); $em->flush();

View file

@ -553,6 +553,7 @@ class ResqCustomerHandler implements CustomerHandlerInterface
'flag_research_sms' => $customer->isResearchSms(), 'flag_research_sms' => $customer->isResearchSms(),
'flag_research_email' => $customer->isResearchEmail(), 'flag_research_email' => $customer->isResearchEmail(),
'customer_tags' => $customer->getCustomerTags(), 'customer_tags' => $customer->getCustomerTags(),
'flag_mobile_app' => $customer->hasMobileApp(),
], ],
'vehicle' => [ 'vehicle' => [
'id' => $vehicle->getID(), 'id' => $vehicle->getID(),

View file

@ -200,11 +200,24 @@
</div> </div>
</div> </div>
<div class="col-lg-3"> <div class="col-lg-3">
{% if is_granted('customer.dpa') %} <div class="col-lg-12 form-group-inner">
<input type="checkbox" name="flag_dpa_consent" id="flag-dpa-consent" value="1"{{ obj.getCustomer ? obj.getCustomer.isDpaConsent ? ' checked' }} > <div class="m-checkbox-list">
<label class="switch-label">With DPA Consent</label> <label class="m-checkbox">
<div class="form-control-feedback hide" data-field="flag_dpa_consent"></div> {% if is_granted('customer.dpa') %}
{% endif %} <input type="checkbox" name="flag_dpa_consent" id="flag-dpa-consent" value="1"{{ obj.getCustomer ? obj.getCustomer.isDpaConsent ? ' checked' }} >
With DPA Consent
<span></span>
<div class="form-control-feedback hide" data-field="flag_dpa_consent"></div>
{% endif %}
</label>
<label class="m-checkbox">
<input type="checkbox" name="flag_mobile_app" id="flag-mobile-app" value="1"{{ obj.getCustomer ? obj.getCustomer.hasMobileApp ? ' checked' }} >
Has Mobile App
<span></span>
<div class="form-control-feedback hide" data-field="flag_mobile_app"></div>
</label>
</div>
</div>
</div> </div>
<div class="col-lg-3"> <div class="col-lg-3">
<div class="col-lg-12 form-group-inner"> <div class="col-lg-12 form-group-inner">
@ -1477,6 +1490,9 @@ $(function() {
if (vdata.customer.flag_research_email === true) { if (vdata.customer.flag_research_email === true) {
$("#flag-research-email").prop("checked", true); $("#flag-research-email").prop("checked", true);
} }
if (vdata.customer.flag_mobile_app === true) {
$("#flag-mobile-app").prop("checked", true);
}
if (vdata.customer.customer_tags.length > 0) { if (vdata.customer.customer_tags.length > 0) {
var checkboxes = document.getElementsByName("customer_tags[]"); var checkboxes = document.getElementsByName("customer_tags[]");
@ -1537,6 +1553,7 @@ $(function() {
$("#flag-promo-email").prop("checked", false); $("#flag-promo-email").prop("checked", false);
$("#flag-research-sms").prop("checked", false); $("#flag-research-sms").prop("checked", false);
$("#flag-research-email").prop("checked", false); $("#flag-research-email").prop("checked", false);
$("#flag-mobile-app").prop("checked", false);
var checkboxes = document.getElementsByName("customer_tags[]"); var checkboxes = document.getElementsByName("customer_tags[]");
for (var x = 0; checkboxes.length > x; x++) for (var x = 0; checkboxes.length > x; x++)