diff --git a/catalyst/api-bundle/Command/TestAPICommand.php b/catalyst/api-bundle/Command/TestAPICommand.php index 7e959808..952b98b6 100644 --- a/catalyst/api-bundle/Command/TestAPICommand.php +++ b/catalyst/api-bundle/Command/TestAPICommand.php @@ -64,7 +64,7 @@ class TestAPICommand extends Command 'start' => '1', ]; - $api->get('/capi/warranties', $params); + //$api->get('/capi/warranties', $params); // warranty find @@ -123,7 +123,7 @@ class TestAPICommand extends Command // privacy policy $privacy_policy_id = 2; - $api->get('/capi/privacy_policy/' . $privacy_policy_id ); + //$api->get('/capi/privacy_policy/' . $privacy_policy_id ); // register new customer $params = [ @@ -137,6 +137,19 @@ class TestAPICommand extends Command 'v_condition' => 'new', 'v_fuel_type' => 'gas', ]; - $api->post('/capi/quick_registration', $params); + //$api->post('/capi/quick_registration', $params); + + // get warranties given list of serial numbers + $serial_list = [ + 'AJ34LJADR12134LKJM4', + 'AJ34LJADR12134LKJL5', + 'test', + ]; + + $params = [ + 'serial_list' => $serial_list, + ]; + + $api->post('/capi/warranties_list', $params); } } diff --git a/config/api_acl.yaml b/config/api_acl.yaml index 2ff18704..a7ad72d5 100644 --- a/config/api_acl.yaml +++ b/config/api_acl.yaml @@ -20,6 +20,8 @@ access_keys: label: Delete - id: warranty.set.privacypolicy label: Set Privacy Policy + - id: warranty.list.serial + label: List by Serial - id: batterybrand label: Battery Brand Access acls: diff --git a/config/routes/capi.yaml b/config/routes/capi.yaml index ee3c8668..0c2e5ac1 100644 --- a/config/routes/capi.yaml +++ b/config/routes/capi.yaml @@ -108,6 +108,12 @@ capi_warranty_privacy_policy: controller: App\Controller\CAPI\WarrantyController::setPrivacyPolicy methods: [POST] +# get list of warranties given list of serials +capi_warranty_get_warranties_from_serials: + path: /capi/warranties_list + controller: App\Controller\CAPI\WarrantyController::getWarrantiesBySerialList + methods: [POST] + # customer vehicle api # find customer vehicle by id diff --git a/src/Command/AdjustLongLatCommand.php b/src/Command/AdjustLongLatCommand.php index 62405269..86e4fc0f 100644 --- a/src/Command/AdjustLongLatCommand.php +++ b/src/Command/AdjustLongLatCommand.php @@ -46,5 +46,7 @@ class AdjustLongLatCommand extends Command } $em->flush(); + + return 0; } } diff --git a/src/Command/ComputeWarrantyExpiryDateCommand.php b/src/Command/ComputeWarrantyExpiryDateCommand.php index cffc24ef..fa0fdc14 100644 --- a/src/Command/ComputeWarrantyExpiryDateCommand.php +++ b/src/Command/ComputeWarrantyExpiryDateCommand.php @@ -71,5 +71,7 @@ class ComputeWarrantyExpiryDateCommand extends Command $this->em->clear(); } + + return 0; } } diff --git a/src/Command/CreateCustomerFromWarrantyCommand.php b/src/Command/CreateCustomerFromWarrantyCommand.php index 42b2fe73..416ee514 100644 --- a/src/Command/CreateCustomerFromWarrantyCommand.php +++ b/src/Command/CreateCustomerFromWarrantyCommand.php @@ -290,6 +290,8 @@ class CreateCustomerFromWarrantyCommand extends Command //$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); + + return 0; } protected function getDefaultVehicle() diff --git a/src/Command/FulfillOldJobOrderCommand.php b/src/Command/FulfillOldJobOrderCommand.php index 2a4132cc..dcf9d761 100644 --- a/src/Command/FulfillOldJobOrderCommand.php +++ b/src/Command/FulfillOldJobOrderCommand.php @@ -22,9 +22,9 @@ class FulfillOldJobOrderCommand extends Command { protected $em; - public function __construct(EntityManagerInterface $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } @@ -76,5 +76,7 @@ class FulfillOldJobOrderCommand extends Command } $em->flush(); + + return 0; } } diff --git a/src/Command/FulfillPendingJobOrderCommand.php b/src/Command/FulfillPendingJobOrderCommand.php index 997dd62e..1ff47e8e 100644 --- a/src/Command/FulfillPendingJobOrderCommand.php +++ b/src/Command/FulfillPendingJobOrderCommand.php @@ -22,9 +22,9 @@ class FulfillPendingJobOrderCommand extends Command { protected $em; - public function __construct(EntityManagerInterface $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } @@ -79,5 +79,7 @@ class FulfillPendingJobOrderCommand extends Command } $em->flush(); + + return 0; } } diff --git a/src/Command/GenerateBatteryCompatibilityCommand.php b/src/Command/GenerateBatteryCompatibilityCommand.php index c4eea3a3..e4ca2d6c 100644 --- a/src/Command/GenerateBatteryCompatibilityCommand.php +++ b/src/Command/GenerateBatteryCompatibilityCommand.php @@ -21,9 +21,9 @@ class GenerateBatteryCompatibilityCommand extends Command protected $em; protected $vmfg_index; - public function __construct(EntityManagerInterface $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } @@ -100,5 +100,7 @@ class GenerateBatteryCompatibilityCommand extends Command fwrite($json_file, json_encode($this->vmfg_index, JSON_PRETTY_PRINT)); fclose($json_file); + return 0; + } } diff --git a/src/Command/GenerateWarrantyFromJobOrderCommand.php b/src/Command/GenerateWarrantyFromJobOrderCommand.php index 1d3f100b..23f436c4 100644 --- a/src/Command/GenerateWarrantyFromJobOrderCommand.php +++ b/src/Command/GenerateWarrantyFromJobOrderCommand.php @@ -211,5 +211,7 @@ class GenerateWarrantyFromJobOrderCommand extends Command $em->detach($row[0]); $em->clear(); } + + return 0; } } diff --git a/src/Command/ImportBatteryPriceCommand.php b/src/Command/ImportBatteryPriceCommand.php index 592720bf..f7395a6e 100644 --- a/src/Command/ImportBatteryPriceCommand.php +++ b/src/Command/ImportBatteryPriceCommand.php @@ -30,9 +30,9 @@ class ImportBatteryPriceCommand extends Command protected $em; protected $size_index; - public function __construct(EntityManagerInterface $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; $this->size_index = []; parent::__construct(); @@ -174,5 +174,7 @@ class ImportBatteryPriceCommand extends Command } $em->flush(); + + return 0; } } diff --git a/src/Command/ImportCMBBatteryDataCommand.php b/src/Command/ImportCMBBatteryDataCommand.php index 7fbee55a..79e84571 100644 --- a/src/Command/ImportCMBBatteryDataCommand.php +++ b/src/Command/ImportCMBBatteryDataCommand.php @@ -170,6 +170,8 @@ class ImportCMBBatteryDataCommand extends Command } } + + return 0; } protected function addBatteryManufacturer($name) diff --git a/src/Command/ImportCMBBatteryTradeInPriceCommand.php b/src/Command/ImportCMBBatteryTradeInPriceCommand.php index 03f594da..b75f9ebb 100644 --- a/src/Command/ImportCMBBatteryTradeInPriceCommand.php +++ b/src/Command/ImportCMBBatteryTradeInPriceCommand.php @@ -92,9 +92,9 @@ class ImportCMBBatteryTradeInPriceCommand extends Command { error_log('Cannot find battery size ' . $size); } - - } + + return 0; } protected function loadBatterySizes() diff --git a/src/Command/ImportCMBVehicleCompatibilityCommand.php b/src/Command/ImportCMBVehicleCompatibilityCommand.php index 81a5a828..4034aec8 100644 --- a/src/Command/ImportCMBVehicleCompatibilityCommand.php +++ b/src/Command/ImportCMBVehicleCompatibilityCommand.php @@ -289,6 +289,8 @@ class ImportCMBVehicleCompatibilityCommand extends Command $row_num++; } + + return 0; } protected function addVehicleManufacturer($name) diff --git a/src/Command/ImportCustomerCommand.php b/src/Command/ImportCustomerCommand.php index 4c0e75e7..e2c55832 100644 --- a/src/Command/ImportCustomerCommand.php +++ b/src/Command/ImportCustomerCommand.php @@ -479,5 +479,7 @@ class ImportCustomerCommand extends Command } fclose($cust_file); fclose($cv_file); + + return 0; } } diff --git a/src/Command/ImportKMLFileCommand.php b/src/Command/ImportKMLFileCommand.php index 4d2e71a2..64bd2b7d 100644 --- a/src/Command/ImportKMLFileCommand.php +++ b/src/Command/ImportKMLFileCommand.php @@ -35,5 +35,7 @@ class ImportKMLFileCommand extends Command $kml_file = $input->getArgument('file'); $this->importer->getMapData($kml_file); + + return 0; } } diff --git a/src/Command/ImportLegacyJobOrderCommand.php b/src/Command/ImportLegacyJobOrderCommand.php index c0edfc80..bf5b3d52 100644 --- a/src/Command/ImportLegacyJobOrderCommand.php +++ b/src/Command/ImportLegacyJobOrderCommand.php @@ -44,9 +44,9 @@ class ImportLegacyJobOrderCommand extends Command protected $row_max_field_size; protected $data_max_field_size; - public function __construct(EntityManagerInterface $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; $this->loadBatteryModels(); $this->loadBatterySizes(); @@ -544,6 +544,8 @@ class ImportLegacyJobOrderCommand extends Command fclose($warr_outfile); fclose($jo_outfile); fclose($jorow_outfile); + + return 0; } protected function initializeMaxFieldCounters() diff --git a/src/Command/ImportOutletsCommand.php b/src/Command/ImportOutletsCommand.php index 2de7a80e..158929b8 100644 --- a/src/Command/ImportOutletsCommand.php +++ b/src/Command/ImportOutletsCommand.php @@ -7,6 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; + use Doctrine\ORM\EntityManagerInterface; use App\Entity\Outlet; @@ -17,11 +18,11 @@ use DateTime; class ImportOutletsCommand extends Command { - private $object_manager; + private $em; - public function __construct(EntityManagerInterface $om, ValidatorInterface $validator) + public function __construct(EntityManagerInterface $em, ValidatorInterface $validator) { - $this->object_manager = $om; + $this->em = $em; $this->validator = $validator; parent::__construct(); @@ -60,7 +61,7 @@ class ImportOutletsCommand extends Command } // get entity manager - $em = $this->object_manager; + $em = $this->em; // row counter $row = 1; @@ -167,7 +168,8 @@ class ImportOutletsCommand extends Command { $output->writeln("Errors occurred! Please check the CSV file is in the proper format."); } - + + return 0; } protected function setObject($obj, $fields) diff --git a/src/Command/ImportPartnersCommand.php b/src/Command/ImportPartnersCommand.php index e46a5aa2..facc74df 100644 --- a/src/Command/ImportPartnersCommand.php +++ b/src/Command/ImportPartnersCommand.php @@ -34,9 +34,9 @@ class ImportPartnersCommand extends Command protected $em; - public function __construct(EntityManagerInterface $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } @@ -163,6 +163,7 @@ class ImportPartnersCommand extends Command $row_num++; } + return 0; } } diff --git a/src/Command/ImportSAPBatteryCommand.php b/src/Command/ImportSAPBatteryCommand.php index 91c14cba..439cb230 100644 --- a/src/Command/ImportSAPBatteryCommand.php +++ b/src/Command/ImportSAPBatteryCommand.php @@ -7,6 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; + use Doctrine\ORM\EntityManagerInterface; use App\Entity\SAPBattery; @@ -37,12 +38,14 @@ class ImportSAPBatteryCommand extends Command $this->setName('sap_battery:import') ->setDescription('Import a CSV file with SAP battery data.') ->setHelp('Creates SAP battery data entries off imported CSV.') - ->addArgument('file', InputArgument::REQUIRED, 'Path to the CSV file.'); + ->addArgument('file', InputArgument::REQUIRED, 'Path to the CSV file.') + ->addArgument('output_file', InputArgument::REQUIRED, 'Path to the output CSV file.'); } protected function execute(InputInterface $input, OutputInterface $output) { $csv_file = $input->getArgument('file'); + $report_file = $input->getArgument('output_file'); // CSV column order: // 0 - brand @@ -68,6 +71,9 @@ class ImportSAPBatteryCommand extends Command // has error? $has_error = false; + $dupe_brands = []; + $dupe_sizes = []; + $dupe_batteries = []; // loop through rows and build hashes while (($fields = fgetcsv($handle)) !== false) { @@ -77,7 +83,7 @@ class ImportSAPBatteryCommand extends Command // clean up fields $clean_brand = trim($fields[0]); - $clean_sku = trim($fields[1]); + $clean_sku = strtoupper(trim($fields[1])); $clean_size = trim($fields[2]); $output->writeln("Parsing $clean_sku..."); @@ -92,6 +98,11 @@ class ImportSAPBatteryCommand extends Command $this->batt_brand_hash[$clean_brand] = $brand; } + else + { + // add to duplicate list + $dupe_brands[] = $clean_brand; + } // size hash if (!isset($this->batt_size_hash[$clean_size])) @@ -103,6 +114,10 @@ class ImportSAPBatteryCommand extends Command $this->batt_size_hash[$clean_size] = $size; } + else + { + $dupe_sizes[] = $clean_size; + } // battery hash if (!isset($this->battery_hash[$clean_sku])) @@ -110,14 +125,28 @@ class ImportSAPBatteryCommand extends Command // create battery entry $battery = new SAPBattery(); $battery->setID($clean_sku) - ->setSize($size_hash[$clean_size]) - ->setBrand($brand_hash[$clean_brand]); + ->setSize($this->batt_size_hash[$clean_size]) + ->setBrand($this->batt_brand_hash[$clean_brand]); $em->persist($battery); } + else + { + $dupe_batteries[] = $clean_sku; + } } $em->flush(); + + // write dupes report + if ((count($dupe_brands) > 0) || + (count($dupe_sizes) > 0) || + (count($dupe_batteries) > 0)) + { + $this->writeDupeReport($report_file, $dupe_brands, $dupe_sizes, $dupe_batteries); + } + + return 0; } protected function initBatteryHash() @@ -146,4 +175,40 @@ class ImportSAPBatteryCommand extends Command foreach ($brands as $brand) $this->batt_brand_hash[$brand->getName()] = $brand; } + + protected function writeDupeReport($report_file, $brands, $sizes, $batts) + { + try + { + $fh = fopen($report_file, "w"); + } + catch (Exception $e) + { + throw new Exception('The file "' . $report_file . '" could be opened.'); + } + + fputs($fh, 'Brands not added: ' . "\n"); + foreach ($brands as $brand) + { + fputs($fh, $brand, strlen($brand)); + fputs($fh, "\n"); + } + + fputs($fh, 'Sizes not added: ' . "\n"); + foreach ($sizes as $size) + { + fputs($fh, $size, strlen($size)); + fputs($fh, "\n"); + } + + fputs($fh, 'SKUs not added: ' . "\n"); + foreach ($batts as $batt) + { + fputs($fh, $batt, strlen($batt)); + fputs($fh, "\n"); + } + + fclose($fh); + + } } diff --git a/src/Command/ImportVehicleBatteryCommand.php b/src/Command/ImportVehicleBatteryCommand.php index 73628894..79ee07dc 100644 --- a/src/Command/ImportVehicleBatteryCommand.php +++ b/src/Command/ImportVehicleBatteryCommand.php @@ -35,9 +35,9 @@ class ImportVehicleBatteryCommand extends Command protected $batt_index; - public function __construct(EntityManagerInterface $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; $this->vmfg_index = []; $this->v_index = []; $this->batt_index = []; @@ -221,6 +221,6 @@ class ImportVehicleBatteryCommand extends Command $em->flush(); - // print_r($batteries); + return 0; } } diff --git a/src/Command/ImportVehicleCompatibilityCommand.php b/src/Command/ImportVehicleCompatibilityCommand.php index 1c39862c..14517885 100644 --- a/src/Command/ImportVehicleCompatibilityCommand.php +++ b/src/Command/ImportVehicleCompatibilityCommand.php @@ -28,9 +28,9 @@ class ImportVehicleCompatibilityCommand extends Command protected $bsize_index; protected $b_index; - public function __construct(EntityManagerInterface $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; $this->vmfg_index = []; $this->v_index = []; $this->b_index = []; @@ -317,6 +317,6 @@ class ImportVehicleCompatibilityCommand extends Command $em->flush(); - // print_r($batteries); + return 0; } } diff --git a/src/Command/MergeDuplicateVehiclesCommand.php b/src/Command/MergeDuplicateVehiclesCommand.php index 93fa94ad..79b7ce52 100644 --- a/src/Command/MergeDuplicateVehiclesCommand.php +++ b/src/Command/MergeDuplicateVehiclesCommand.php @@ -15,9 +15,9 @@ class MergeDuplicateVehiclesCommand extends Command { protected $em; - public function __construct(EntityManagerInterface $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } @@ -161,8 +161,7 @@ class MergeDuplicateVehiclesCommand extends Command $em->flush(); } } - - // print_r($dupes); + return 0; } } diff --git a/src/Command/RefreshJobOrderCacheCommand.php b/src/Command/RefreshJobOrderCacheCommand.php index 0e314c56..99fcb331 100644 --- a/src/Command/RefreshJobOrderCacheCommand.php +++ b/src/Command/RefreshJobOrderCacheCommand.php @@ -64,5 +64,7 @@ class RefreshJobOrderCacheCommand extends Command { $this->jo_cache->addActiveJobOrder($jo); } + + return 0; } } diff --git a/src/Command/ReportRiderTime.php b/src/Command/ReportRiderTime.php index e8825b5b..62a2a8e6 100644 --- a/src/Command/ReportRiderTime.php +++ b/src/Command/ReportRiderTime.php @@ -142,5 +142,7 @@ class ReportRiderTime extends Command } fclose($fh); + + return 0; } } diff --git a/src/Command/SeedRiderSessionsCommand.php b/src/Command/SeedRiderSessionsCommand.php index cc7dc26d..e1c44954 100644 --- a/src/Command/SeedRiderSessionsCommand.php +++ b/src/Command/SeedRiderSessionsCommand.php @@ -55,5 +55,7 @@ class SeedRiderSessionsCommand extends Command $this->redis->set($redis_key, $rider_id); } } + + return 0; } } diff --git a/src/Command/SetCustomerPrivacyPolicyCommand.php b/src/Command/SetCustomerPrivacyPolicyCommand.php index 9cb13f4b..6700b8e6 100644 --- a/src/Command/SetCustomerPrivacyPolicyCommand.php +++ b/src/Command/SetCustomerPrivacyPolicyCommand.php @@ -22,10 +22,10 @@ class SetCustomerPrivacyPolicyCommand extends Command private $policy_third_party_id; private $policy_mobile_id; - public function __construct(EntityManagerInterface $om, $policy_promo, + public function __construct(EntityManagerInterface $em, $policy_promo, $policy_third_party, $policy_mobile) { - $this->em = $om; + $this->em = $em; $this->policy_promo_id = $policy_promo; $this->policy_third_party_id = $policy_third_party; @@ -80,5 +80,7 @@ class SetCustomerPrivacyPolicyCommand extends Command } $this->em->flush(); + + return 0; } } diff --git a/src/Command/TestGeneralSearchCommand.php b/src/Command/TestGeneralSearchCommand.php index 0696fb86..c5d8d335 100644 --- a/src/Command/TestGeneralSearchCommand.php +++ b/src/Command/TestGeneralSearchCommand.php @@ -66,5 +66,7 @@ class TestGeneralSearchCommand extends Command echo "Last Name: " . $warranty->getLastName() . "\n"; echo "First Name: " . $warranty->getFirstName() . "\n"; } + + return 0; } } diff --git a/src/Command/TestGeofenceCommand.php b/src/Command/TestGeofenceCommand.php index 1397f08f..a4bdff69 100644 --- a/src/Command/TestGeofenceCommand.php +++ b/src/Command/TestGeofenceCommand.php @@ -40,5 +40,7 @@ class TestGeofenceCommand extends Command echo "In geofence\n"; else echo "NOT in geofence\n"; + + return 0; } } diff --git a/src/Command/TestHubCounterCommand.php b/src/Command/TestHubCounterCommand.php index e08c11dd..f9ba5eee 100644 --- a/src/Command/TestHubCounterCommand.php +++ b/src/Command/TestHubCounterCommand.php @@ -35,5 +35,7 @@ class TestHubCounterCommand extends Command $available_rc = $this->hc->getAvailableRiderCount($hub_id); echo "Available Riders in Hub: " . $available_rc . "\n"; + + return 0; } } diff --git a/src/Command/TestJobOrderManagerCommand.php b/src/Command/TestJobOrderManagerCommand.php index 4beeea46..7fefe37f 100644 --- a/src/Command/TestJobOrderManagerCommand.php +++ b/src/Command/TestJobOrderManagerCommand.php @@ -36,5 +36,7 @@ class TestJobOrderManagerCommand extends Command echo "Job Order successfully updated" . "\n"; else echo "Job Order not updated" . "\n"; + + return 0; } } diff --git a/src/Command/TestRegAPNSCommand.php b/src/Command/TestRegAPNSCommand.php index 52ec7d76..aeb7ad6a 100644 --- a/src/Command/TestRegAPNSCommand.php +++ b/src/Command/TestRegAPNSCommand.php @@ -34,5 +34,7 @@ class TestRegAPNSCommand extends Command { $push_id = $input->getArgument('push_id'); $this->apns->sendReg($push_id, 'Test Delay', 'Body'); + + return 0; } } diff --git a/src/Command/TestRiderTrackerCommand.php b/src/Command/TestRiderTrackerCommand.php index 7b26a9ed..c975c16e 100644 --- a/src/Command/TestRiderTrackerCommand.php +++ b/src/Command/TestRiderTrackerCommand.php @@ -42,5 +42,7 @@ class TestRiderTrackerCommand extends Command { echo "Invalid rider id." . "\n"; } + + return 0; } } diff --git a/src/Command/UpdateCustomerVehicleBatteryCommand.php b/src/Command/UpdateCustomerVehicleBatteryCommand.php index 6726c2f0..3b858711 100644 --- a/src/Command/UpdateCustomerVehicleBatteryCommand.php +++ b/src/Command/UpdateCustomerVehicleBatteryCommand.php @@ -18,9 +18,9 @@ class UpdateCustomerVehicleBatteryCommand extends Command protected $em; protected $custvehicle_hash; - public function __construct(EntityManagerInterface $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; $this->custvehicle_hash = []; parent::__construct(); @@ -63,5 +63,7 @@ class UpdateCustomerVehicleBatteryCommand extends Command } } } + + return 0; } } diff --git a/src/Command/UpdateCustomerVehicleWarrantyCommand.php b/src/Command/UpdateCustomerVehicleWarrantyCommand.php index 98fec1cb..20fad9b1 100644 --- a/src/Command/UpdateCustomerVehicleWarrantyCommand.php +++ b/src/Command/UpdateCustomerVehicleWarrantyCommand.php @@ -94,5 +94,7 @@ class UpdateCustomerVehicleWarrantyCommand extends Command $this->em->detach($row[0]); } + + return 0; } } diff --git a/src/Command/UploadCleanupCommand.php b/src/Command/UploadCleanupCommand.php index 03831ee9..0bb98353 100644 --- a/src/Command/UploadCleanupCommand.php +++ b/src/Command/UploadCleanupCommand.php @@ -7,6 +7,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Exception\IOExceptionInterface; + use Doctrine\ORM\EntityManagerInterface; use App\Entity\Rider; @@ -18,11 +19,11 @@ use DirectoryIterator; class UploadCleanupCommand extends Command { private $encoder_factory; - private $object_manager; + private $em; - public function __construct(EntityManagerInterface $om, Filesystem $fs, FileUploader $uploader) + public function __construct(EntityManagerInterface $em, Filesystem $fs, FileUploader $uploader) { - $this->object_manager = $om; + $this->em = $em; $this->filesystem = $fs; $this->uploader = $uploader; @@ -41,7 +42,7 @@ class UploadCleanupCommand extends Command $output->writeln('Retrieving file whitelist...'); // get all image filenames - $em = $this->object_manager; + $em = $this->em; $riders = $em->getRepository(Rider::class)->findAll(); $whitelist = ['.gitkeep']; @@ -95,5 +96,7 @@ class UploadCleanupCommand extends Command $output->writeln('Deleted ' . $i . ' orphaned file(s). Done!'); else $output->writeln('No files found. Done!'); + + return 0; } } diff --git a/src/Command/UserCreateCommand.php b/src/Command/UserCreateCommand.php index 025086af..697f66fe 100644 --- a/src/Command/UserCreateCommand.php +++ b/src/Command/UserCreateCommand.php @@ -8,6 +8,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; + use Doctrine\ORM\EntityManagerInterface; use App\Entity\User; @@ -16,12 +17,12 @@ use App\Entity\Role; class UserCreateCommand extends Command { private $encoder_factory; - private $object_manager; + private $em; - public function __construct(EncoderFactoryInterface $ef, EntityManagerInterface $om) + public function __construct(EncoderFactoryInterface $ef, EntityManagerInterface $em) { $this->encoder_factory = $ef; - $this->object_manager = $om; + $this->em = $em; parent::__construct(); } @@ -49,7 +50,7 @@ class UserCreateCommand extends Command // get entity manager // $em = $this->getContainer()->get('doctrine')->getEntityManager(); - $em = $this->object_manager; + $em = $this->em; // build user $user->setUsername($username) @@ -66,5 +67,7 @@ class UserCreateCommand extends Command $em->persist($user); $em->flush(); + + return 0; } } diff --git a/src/Controller/CAPI/WarrantyController.php b/src/Controller/CAPI/WarrantyController.php index 83ecf74a..e5f5437e 100644 --- a/src/Controller/CAPI/WarrantyController.php +++ b/src/Controller/CAPI/WarrantyController.php @@ -502,6 +502,48 @@ class WarrantyController extends APIController } + public function getWarrantiesBySerialList(Request $req, EntityManagerInterface $em) + { + $this->denyAccessUnlessGranted('warranty.list.serial', null, 'No access.'); + + error_log('getWarrantiesBySerialList'); + // required parameters + $params = [ + 'serial_list', + ]; + + $msg = $this->checkRequiredParameters($req, $params); + error_log('msg - ' . $msg); + if ($msg) + return new APIResponse(false, $msg); + + $serial_list = $req->request->get('serial_list'); + + if (empty($serial_list)) + return new APIResponse(false, 'Empty serial numbers list.'); + + $warranty_list = []; + $warr_not_found_list = []; + foreach ($serial_list as $serial) + { + $clean_serial = $this->cleanSerial($serial); + $warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $clean_serial]); + + if ($warr == null) + $warr_not_found_list[] = $clean_serial; + else + $warranty_list[] = $this->generateWarrantyData($warr); + } + + + $data = [ + 'warranties_found' => $warranty_list, + 'warranties_not_found' => $warr_not_found_list, + ]; + + return new APIResponse(true, 'Warranties found.', $data); + } + protected function getCustomerFromMobile($em, $warranty) { $w_mobile = $warranty->getMobileNumber();