Add ids to env.dist. #274
This commit is contained in:
parent
98c5bdc670
commit
737dd4e22a
2 changed files with 153 additions and 122 deletions
|
|
@ -45,3 +45,8 @@ OTP_MODE=settotestorrandom
|
|||
|
||||
# geofence
|
||||
GEOFENCE_ENABLE=settotrueorfalse
|
||||
|
||||
# unknown manufacturer and vehicle ids
|
||||
CVU_MFG_ID=insertmfgidforunknownvehicles
|
||||
CVU_BRAND_ID=insertbrandidforunknownvehicles
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Symfony\Component\Console\Input\InputOption;
|
|||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
|
||||
|
|
@ -42,6 +43,13 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
}
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
// get the default ids from .env
|
||||
$dotenv = new Dotenv();
|
||||
$dotenv->loadEnv(__DIR__.'/../../.env');
|
||||
|
||||
$cvu_mfg_id = $_ENV['CVU_MFG_ID'];
|
||||
$cvu_brand_id = $_ENV['CVU_BRAND_ID'];
|
||||
|
||||
$csv_file = $input->getArgument('file');
|
||||
|
||||
// attempt to open file
|
||||
|
|
@ -60,15 +68,25 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
$total_cust_added = 0;
|
||||
$total_cv_added = 0;
|
||||
|
||||
$default_vehicle = $this->em->getRepository(Vehicle::class)->find($cvu_brand_id);
|
||||
if (empty($default_vehicle))
|
||||
{
|
||||
$output->writeln("Need to add vehicle with default values.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// load all customers
|
||||
$this->loadCustomers();
|
||||
$output->writeln('Loading customer data...');
|
||||
$this->loadCustomers($output);
|
||||
|
||||
// get all warranties
|
||||
$warranties = $this->em->getRepository(Warranty::class)->findAll();
|
||||
|
||||
$invalid_warranties = [];
|
||||
$output->writeln('Processing warranties... ');
|
||||
foreach($warranties as $warr)
|
||||
{
|
||||
$total_warr++;
|
||||
$cust_found = false;
|
||||
// check if warranty mobile already exists in customer
|
||||
$w_mobile = $warr->getMobileNumber();
|
||||
|
|
@ -100,11 +118,6 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
continue;
|
||||
}
|
||||
$w_plate_number = $clean_plate;
|
||||
$default_vehicle = $this->em->getRepository(Vehicle::class)->findOneBy(['make' =>'Unknown']);
|
||||
if (empty($default_vehicle))
|
||||
{
|
||||
$output->writeln("Need to add vehicle with manufacturer name Unknown and make name Unknown");
|
||||
}
|
||||
|
||||
foreach ($w_mobile_array as $w_mobile_num)
|
||||
{
|
||||
|
|
@ -130,6 +143,7 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
// add the vehicle from warranty
|
||||
$cust_found = true;
|
||||
$this->createCustomerVehicle($customer, $default_vehicle, $w_plate_number);
|
||||
$total_cv_added++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -147,6 +161,7 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
// add customer vehicle to existing customer with unknown manufacturer and make
|
||||
$cust_found = true;
|
||||
$this->createCustomerVehicle($customer, $default_vehicle, $w_plate_number);
|
||||
$total_cv_added++;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -155,6 +170,7 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
// add customer vehicle to existing customer with unknown manufacturer and make
|
||||
$cust_found = true;
|
||||
$this->createCustomerVehicle($customer, $default_vehicle, $w_plate_number);
|
||||
$total_cv_added++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -181,6 +197,9 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
|
||||
// add latest customer to hash
|
||||
$this->cust_index[$w_mobile_num][] = $new_cust;
|
||||
|
||||
$total_cust_added++;
|
||||
$total_cv_added++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -211,11 +230,18 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
|
||||
foreach($invalid_warranties as $row)
|
||||
{
|
||||
$total_inv_warr++;
|
||||
fputcsv($fh, $row);
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fh);
|
||||
|
||||
$output->writeln('Total warranties: ' . $total_warr);
|
||||
$output->writeln('Total warranties with no mobile number: ' . $total_inv_warr);
|
||||
$output->writeln('Total customers added: ' . $total_cust_added);
|
||||
$output->writeln('Total customer vehicles added: ' . $total_cv_added);
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadCustomers()
|
||||
|
|
|
|||
Loading…
Reference in a new issue