Merge branch '339-cmb-mobile-phone-validation-check' into '270-final-cmb-fixes'

Resolve "CMB - mobile phone validation check"

See merge request jankstudio/resq!381
This commit is contained in:
Kendrick Chan 2020-02-13 04:33:50 +00:00
commit 3ec6ca0ee1
50 changed files with 2348 additions and 1160 deletions

2077
composer.lock generated

File diff suppressed because it is too large Load diff

229
config/cmb.services.yaml Normal file
View file

@ -0,0 +1,229 @@
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
map_default:
latitude: 14.6091
longitude: 121.0223
image_upload_directory: '%kernel.project_dir%/public/uploads'
job_order_refresh_interval: 300000
api_acl_file: 'api_acl.yaml'
api_access_key: 'api_access_keys'
app_acl_file: 'acl.yaml'
app_access_key: 'access_keys'
cvu_brand_id: "%env(CVU_BRAND_ID)%"
country_code: "%env(COUNTRY_CODE)%"
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests,Menu,Access}'
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
App\Menu\Generator:
arguments:
$router: "@router.default"
$cache_dir: "%kernel.cache_dir%"
$config_dir: "%kernel.root_dir%/../config"
Catalyst\AuthBundle\Service\ACLGenerator:
arguments:
$router: "@router.default"
$cache_dir: "%kernel.cache_dir%"
$config_dir: "%kernel.root_dir%/../config"
$acl_file: "%app_acl_file%"
Catalyst\AuthBundle\Service\ACLVoter:
arguments:
$user_class: "App\\Entity\\User"
tags: ['security.voter']
Catalyst\AuthBundle\Service\UserChecker:
App\Service\FileUploader:
arguments:
$target_dir: '%image_upload_directory%'
App\Service\MapTools:
arguments:
$em: "@doctrine.orm.entity_manager"
$gmaps_api_key: "%env(GMAPS_API_KEY)%"
App\Service\RisingTideGateway:
arguments:
$em: "@doctrine.orm.entity_manager"
$user: "%env(RT_USER)%"
$pass: "%env(RT_PASS)%"
$usage_type: "%env(RT_USAGE_TYPE)%"
$shortcode: "%env(RT_SHORTCODE)%"
App\Service\MQTTClient:
arguments:
$redis_client: "@App\\Service\\RedisClientProvider"
$key: "mqtt_events"
App\Service\APNSClient:
arguments:
$redis_client: "@App\\Service\\RedisClientProvider"
App\Service\RedisClientProvider:
arguments:
$scheme: "%env(REDIS_CLIENT_SCHEME)%"
$host: "%env(REDIS_CLIENT_HOST)%"
$port: "%env(REDIS_CLIENT_PORT)%"
$password: "%env(REDIS_CLIENT_PASSWORD)%"
App\Service\GeofenceTracker:
arguments:
$geofence_flag: "%env(GEOFENCE_ENABLE)%"
App\Service\WarrantyHandler:
arguments:
$em: "@doctrine.orm.entity_manager"
App\Command\SetCustomerPrivacyPolicyCommand:
arguments:
$policy_promo: "%env(POLICY_PROMO)%"
$policy_third_party: "%env(POLICY_THIRD_PARTY)%"
$policy_mobile: "%env(POLICY_MOBILE)%"
App\Command\CreateCustomerFromWarrantyCommand:
arguments:
$cvu_mfg_id: "%env(CVU_MFG_ID)%"
$cvu_brand_id: "%env(CVU_BRAND_ID)%"
# rider tracker service
App\Service\RiderTracker:
arguments:
$redis_client: "@App\\Service\\RedisClientProvider"
Catalyst\APIBundle\Security\APIKeyUserProvider:
arguments:
$em: "@doctrine.orm.entity_manager"
Catalyst\APIBundle\Security\APIKeyAuthenticator:
arguments:
$em: "@doctrine.orm.entity_manager"
Catalyst\APIBundle\Command\UserCreateCommand:
arguments:
$em: "@doctrine.orm.entity_manager"
tags: ['console.command']
Catalyst\APIBundle\Command\TestCommand:
tags: ['console.command']
Catalyst\APIBundle\Command\TestAPICommand:
tags: ['console.command']
Catalyst\APIBundle\Access\Voter:
arguments:
$acl_gen: "@Catalyst\\APIBundle\\Access\\Generator"
$user_class: "Catalyst\\APIBundle\\Entity\\User"
tags: ['security.voter']
Catalyst\APIBundle\Access\Generator:
arguments:
$router: "@router.default"
$cache_dir: "%kernel.cache_dir%"
$config_dir: "%kernel.root_dir%/../config"
$acl_file: "%api_acl_file%"
Catalyst\MenuBundle\Menu\Generator:
arguments:
$router: "@router.default"
$cache_dir: "%kernel.cache_dir%"
$config_dir: "%kernel.root_dir%/../config"
Catalyst\MenuBundle\Listener\MenuAnnotationListener:
arguments:
$menu_name: "main_menu"
tags:
- { name: kernel.event_listener, event: kernel.controller, method: onKernelController }
# invoice generator
App\Service\InvoiceGenerator\CMBInvoiceGenerator: ~
# invoice generator interface
App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceGenerator\\CMBInvoiceGenerator"
# job order generator
App\Service\JobOrderHandler\CMBJobOrderHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
#job order generator interface
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\CMBJobOrderHandler"
# customer generator
App\Service\CustomerHandler\CMBCustomerHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
# customer generator interface
App\Service\CustomerHandlerInterface: "@App\\Service\\CustomerHandler\\CMBCustomerHandler"
# rider assignment
App\Service\RiderAssignmentHandler\CMBRiderAssignmentHandler: ~
# rider assignment interface
App\Service\RiderAssignmentHandlerInterface: "@App\\Service\\RiderAssignmentHandler\\CMBRiderAssignmentHandler"
# rider API service
App\Service\RiderAPIHandler\CMBRiderAPIHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
# rider API interface
App\Service\RiderAPIHandlerInterface: "@App\\Service\\RiderAPIHandler\\CMBRiderAPIHandler"
# map manager
#App\Service\GISManager\Bing: ~
App\Service\GISManager\OpenStreet: ~
#App\Service\GISManager\Google: ~
#App\Service\GISManagerInterface: "@App\\Service\\GISManager\\Bing"
App\Service\GISManagerInterface: "@App\\Service\\GISManager\\OpenStreet"
#App\Service\GISManagerInterface: "@App\\Service\\GISManager\\Google"
App\EventListener\JobOrderActiveCacheListener:
arguments:
$jo_cache: "@App\\Service\\JobOrderCache"
$mqtt: "@App\\Service\\MQTTClient"
tags:
- name: 'doctrine.orm.entity_listener'
event: 'postUpdate'
entity: 'App\Entity\JobOrder'
- name: 'doctrine.orm.entity_listener'
event: 'postRemove'
entity: 'App\Entity\JobOrder'
- name: 'doctrine.orm.entity_listener'
event: 'postPersist'
entity: 'App\Entity\JobOrder'
App\Service\JobOrderCache:
arguments:
$redis_prov: "@App\\Service\\RedisClientProvider"
$active_jo_key: "%env(LOCATION_JO_ACTIVE_KEY)%"
App\Service\RiderCache:
arguments:
$redis_prov: "@App\\Service\\RedisClientProvider"
$loc_key: "%env(LOCATION_RIDER_ACTIVE_KEY)%"
$status_key: "%env(STATUS_RIDER_KEY)%"

228
config/resq.services.yaml Normal file
View file

@ -0,0 +1,228 @@
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
map_default:
latitude: 14.6091
longitude: 121.0223
image_upload_directory: '%kernel.project_dir%/public/uploads'
job_order_refresh_interval: 300000
api_acl_file: 'api_acl.yaml'
api_access_key: 'api_access_keys'
app_acl_file: 'acl.yaml'
app_access_key: 'access_keys'
cvu_brand_id: "%env(CVU_BRAND_ID)%"
country_code: "%env(COUNTRY_CODE)%"
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests,Menu,Access}'
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
App\Menu\Generator:
arguments:
$router: "@router.default"
$cache_dir: "%kernel.cache_dir%"
$config_dir: "%kernel.root_dir%/../config"
Catalyst\AuthBundle\Service\ACLGenerator:
arguments:
$router: "@router.default"
$cache_dir: "%kernel.cache_dir%"
$config_dir: "%kernel.root_dir%/../config"
$acl_file: "%app_acl_file%"
Catalyst\AuthBundle\Service\ACLVoter:
arguments:
$user_class: "App\\Entity\\User"
tags: ['security.voter']
Catalyst\AuthBundle\Service\UserChecker:
App\Service\FileUploader:
arguments:
$target_dir: '%image_upload_directory%'
App\Service\MapTools:
arguments:
$em: "@doctrine.orm.entity_manager"
$gmaps_api_key: "%env(GMAPS_API_KEY)%"
App\Service\RisingTideGateway:
arguments:
$em: "@doctrine.orm.entity_manager"
$user: "%env(RT_USER)%"
$pass: "%env(RT_PASS)%"
$usage_type: "%env(RT_USAGE_TYPE)%"
$shortcode: "%env(RT_SHORTCODE)%"
App\Service\MQTTClient:
arguments:
$redis_client: "@App\\Service\\RedisClientProvider"
$key: "mqtt_events"
App\Service\APNSClient:
arguments:
$redis_client: "@App\\Service\\RedisClientProvider"
App\Service\RedisClientProvider:
arguments:
$scheme: "%env(REDIS_CLIENT_SCHEME)%"
$host: "%env(REDIS_CLIENT_HOST)%"
$port: "%env(REDIS_CLIENT_PORT)%"
$password: "%env(REDIS_CLIENT_PASSWORD)%"
App\Service\GeofenceTracker:
arguments:
$geofence_flag: "%env(GEOFENCE_ENABLE)%"
App\Service\WarrantyHandler:
arguments:
$em: "@doctrine.orm.entity_manager"
App\Command\SetCustomerPrivacyPolicyCommand:
arguments:
$policy_promo: "%env(POLICY_PROMO)%"
$policy_third_party: "%env(POLICY_THIRD_PARTY)%"
$policy_mobile: "%env(POLICY_MOBILE)%"
App\Command\CreateCustomerFromWarrantyCommand:
arguments:
$cvu_mfg_id: "%env(CVU_MFG_ID)%"
$cvu_brand_id: "%env(CVU_BRAND_ID)%"
# rider tracker service
App\Service\RiderTracker:
arguments:
$redis_client: "@App\\Service\\RedisClientProvider"
Catalyst\APIBundle\Security\APIKeyUserProvider:
arguments:
$em: "@doctrine.orm.entity_manager"
Catalyst\APIBundle\Security\APIKeyAuthenticator:
arguments:
$em: "@doctrine.orm.entity_manager"
Catalyst\APIBundle\Command\UserCreateCommand:
arguments:
$em: "@doctrine.orm.entity_manager"
tags: ['console.command']
Catalyst\APIBundle\Command\TestCommand:
tags: ['console.command']
Catalyst\APIBundle\Command\TestAPICommand:
tags: ['console.command']
Catalyst\APIBundle\Access\Voter:
arguments:
$acl_gen: "@Catalyst\\APIBundle\\Access\\Generator"
$user_class: "Catalyst\\APIBundle\\Entity\\User"
tags: ['security.voter']
Catalyst\APIBundle\Access\Generator:
arguments:
$router: "@router.default"
$cache_dir: "%kernel.cache_dir%"
$config_dir: "%kernel.root_dir%/../config"
$acl_file: "%api_acl_file%"
Catalyst\MenuBundle\Menu\Generator:
arguments:
$router: "@router.default"
$cache_dir: "%kernel.cache_dir%"
$config_dir: "%kernel.root_dir%/../config"
Catalyst\MenuBundle\Listener\MenuAnnotationListener:
arguments:
$menu_name: "main_menu"
tags:
- { name: kernel.event_listener, event: kernel.controller, method: onKernelController }
# invoice generator
App\Service\InvoiceGenerator\ResqInvoiceGenerator: ~
# invoice generator interface
App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceGenerator\\ResqInvoiceGenerator"
# job order generator
App\Service\JobOrderHandler\ResqJobOrderHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
#job order generator interface
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
# customer generator
App\Service\CustomerHandler\ResqCustomerHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
# customer generator interface
App\Service\CustomerHandlerInterface: "@App\\Service\\CustomerHandler\\ResqCustomerHandler"
# rider assignment
App\Service\RiderAssignmentHandler\ResqRiderAssignmentHandler: ~
# rider assignment interface
App\Service\RiderAssignmentHandlerInterface: "@App\\Service\\RiderAssignmentHandler\\ResqRiderAssignmentHandler"
# rider API service
App\Service\RiderAPIHandler\ResqRiderAPIHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
App\Service\RiderAPIHandlerInterface: "@App\\Service\\RiderAPIHandler\\ResqRiderAPIHandler"
# map manager
#App\Service\GISManager\Bing: ~
App\Service\GISManager\OpenStreet: ~
#App\Service\GISManager\Google: ~
#App\Service\GISManagerInterface: "@App\\Service\\GISManager\\Bing"
App\Service\GISManagerInterface: "@App\\Service\\GISManager\\OpenStreet"
#App\Service\GISManagerInterface: "@App\\Service\\GISManager\\Google"
App\EventListener\JobOrderActiveCacheListener:
arguments:
$jo_cache: "@App\\Service\\JobOrderCache"
$mqtt: "@App\\Service\\MQTTClient"
tags:
- name: 'doctrine.orm.entity_listener'
event: 'postUpdate'
entity: 'App\Entity\JobOrder'
- name: 'doctrine.orm.entity_listener'
event: 'postRemove'
entity: 'App\Entity\JobOrder'
- name: 'doctrine.orm.entity_listener'
event: 'postPersist'
entity: 'App\Entity\JobOrder'
App\Service\JobOrderCache:
arguments:
$redis_prov: "@App\\Service\\RedisClientProvider"
$active_jo_key: "%env(LOCATION_JO_ACTIVE_KEY)%"
App\Service\RiderCache:
arguments:
$redis_prov: "@App\\Service\\RedisClientProvider"
$loc_key: "%env(LOCATION_RIDER_ACTIVE_KEY)%"
$status_key: "%env(STATUS_RIDER_KEY)%"

View file

@ -39,6 +39,11 @@ battery_delete:
controller: App\Controller\BatteryController::destroy
methods: [DELETE]
battery_ajax_get:
path: /ajax/battery_find
controller: App\Controller\BatteryController::getBattery
methods: [GET]
# battery manufacturers
bmfg_list:

View file

@ -157,18 +157,22 @@ services:
tags:
- { name: kernel.event_listener, event: kernel.controller, method: onKernelController }
# invoice generator
# CMB invoice generator
App\Service\InvoiceGenerator\CMBInvoiceGenerator: ~
# Resq invoice generator
#App\Service\InvoiceGenerator\ResqInvoiceGenerator: ~
# invoice generator interface
App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceGenerator\\CMBInvoiceGenerator"
#App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceGenerator\\ResqInvoiceGenerator"
# job order generator
# Resq job order generator
#App\Service\JobOrderHandler\ResqJobOrderHandler:
# arguments:
# $country_code: "%env(COUNTRY_CODE)%"
# CMB job order generator
App\Service\JobOrderHandler\CMBJobOrderHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
@ -177,11 +181,12 @@ services:
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\CMBJobOrderHandler"
#App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
# customer generator
# CMB customer generator
App\Service\CustomerHandler\CMBCustomerHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
# Resq customer generator
#App\Service\CustomerHandler\ResqCustomerHandler:
# arguments:
# $country_code: "%env(COUNTRY_CODE)%"
@ -191,7 +196,7 @@ services:
#App\Service\CustomerHandlerInterface: "@App\\Service\\CustomerHandler\\ResqCustomerHandler"
# rider assignment
App\Service\RiderAssignmentHandler\CMBRiderAssignmentHandler: ~
#App\Service\RiderAssignmentHandler\CMBRiderAssignmentHandler: ~
# rider assignment interface
App\Service\RiderAssignmentHandlerInterface: "@App\\Service\\RiderAssignmentHandler\\CMBRiderAssignmentHandler"

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\JobOrder;
@ -17,9 +17,9 @@ class AdjustLongLatCommand extends Command
{
protected $em;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $em)
{
$this->em = $om;
$this->em = $em;
parent::__construct();
}

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Battery;
@ -18,7 +18,7 @@ class ComputeWarrantyExpiryDateCommand extends Command
protected $em;
protected $wh;
public function __construct(ObjectManager $em, WarrantyHandler $wh)
public function __construct(EntityManagerInterface $em, WarrantyHandler $wh)
{
$this->em = $em;
$this->wh = $wh;

View file

@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Warranty;
use App\Entity\Customer;
@ -33,7 +33,7 @@ class CreateCustomerFromWarrantyCommand extends Command
protected $cvu_mfg_id;
protected $cvu_brand_id;
public function __construct(ObjectManager $em, $cvu_mfg_id, $cvu_brand_id)
public function __construct(EntityManagerInterface $em, $cvu_mfg_id, $cvu_brand_id)
{
$this->em = $em;

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\JobOrder;
use App\Entity\JOEvent;
@ -22,7 +22,7 @@ class FulfillOldJobOrderCommand extends Command
{
protected $em;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\JobOrder;
use App\Entity\JOEvent;
@ -22,7 +22,7 @@ class FulfillPendingJobOrderCommand extends Command
{
protected $em;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\VehicleManufacturer;
use App\Entity\Vehicle;
@ -21,7 +21,7 @@ class GenerateBatteryCompatibilityCommand extends Command
protected $em;
protected $vmfg_index;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;

View file

@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\JobOrder;
use App\Entity\Warranty;
@ -25,7 +25,7 @@ class GenerateWarrantyFromJobOrderCommand extends Command
protected $sapbatt_hash;
protected $warranties_hash;
public function __construct(ObjectManager $em)
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use CrEOF\Spatial\PHP\Types\Geometry\Point;
use DateTime;
@ -30,7 +30,7 @@ class ImportBatteryPriceCommand extends Command
protected $em;
protected $size_index;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;
$this->size_index = [];

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Battery;
use App\Entity\BatteryManufacturer;
@ -27,7 +27,7 @@ class ImportCMBBatteryDataCommand extends Command
protected $bsize_hash;
protected $batt_hash;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\BatterySize;
@ -20,7 +20,7 @@ class ImportCMBBatteryTradeInPriceCommand extends Command
protected $bsize_hash;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\BatteryManufacturer;
use App\Entity\BatteryModel;
@ -50,7 +50,7 @@ class ImportCMBVehicleCompatibilityCommand extends Command
protected $vmanu_hash;
protected $vmake_hash;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use DateTime;
@ -49,7 +49,7 @@ class ImportCustomerCommand extends Command
protected $mfg_index;
protected $vehicle_index;
public function __construct(ObjectManager $em)
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
$this->populateMfgIndex();

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Warranty;
use App\Entity\Battery;
@ -44,7 +44,7 @@ class ImportLegacyJobOrderCommand extends Command
protected $row_max_field_size;
protected $data_max_field_size;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;

View file

@ -7,7 +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\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Outlet;
use App\Entity\Hub;
@ -19,7 +19,7 @@ class ImportOutletsCommand extends Command
{
private $object_manager;
public function __construct(ObjectManager $om, ValidatorInterface $validator)
public function __construct(EntityManagerInterface $om, ValidatorInterface $validator)
{
$this->object_manager = $om;
$this->validator = $validator;

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use CrEOF\Spatial\PHP\Types\Geometry\Point;
use DateTime;
@ -34,7 +34,7 @@ class ImportPartnersCommand extends Command
protected $em;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;

View file

@ -7,7 +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\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\SAPBattery;
use App\Entity\SAPBatteryBrand;
@ -22,7 +22,7 @@ class ImportSAPBatteryCommand extends Command
private $batt_size_hash;
private $batt_brand_hash;
public function __construct(ObjectManager $em)
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
$this->initBatteryHash();

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use CrEOF\Spatial\PHP\Types\Geometry\Point;
use DateTime;
@ -35,7 +35,7 @@ class ImportVehicleBatteryCommand extends Command
protected $batt_index;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;
$this->vmfg_index = [];

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use CrEOF\Spatial\PHP\Types\Geometry\Point;
use DateTime;
@ -28,7 +28,7 @@ class ImportVehicleCompatibilityCommand extends Command
protected $bsize_index;
protected $b_index;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;
$this->vmfg_index = [];

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Vehicle;
@ -15,7 +15,7 @@ class MergeDuplicateVehiclesCommand extends Command
{
protected $em;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;

View file

@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\DBAL\Connection;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Service\JobOrderCache;
use App\Entity\JobOrder;
use App\Ramcar\JOStatus;
@ -21,7 +21,7 @@ class RefreshJobOrderCacheCommand extends Command
protected $em;
protected $jo_cache;
public function __construct(ObjectManager $om, JobOrderCache $jo_cache)
public function __construct(EntityManagerInterface $om, JobOrderCache $jo_cache)
{
$this->em = $om;
$this->jo_cache = $jo_cache;

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use DateTime;
@ -21,7 +21,7 @@ class ReportRiderTime extends Command
protected $jo_index;
protected $filtered_jo_index;
public function __construct(ObjectManager $em)
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;

View file

@ -6,7 +6,7 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Service\RedisClientProvider;
@ -17,7 +17,7 @@ class SeedRiderSessionsCommand extends Command
protected $em;
protected $redis;
public function __construct(ObjectManager $om, RedisClientProvider $redis)
public function __construct(EntityManagerInterface $om, RedisClientProvider $redis)
{
$this->em = $om;
$this->redis = $redis->getRedisClient();

View file

@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Customer;
use App\Entity\PrivacyPolicy;
@ -22,7 +22,7 @@ class SetCustomerPrivacyPolicyCommand extends Command
private $policy_third_party_id;
private $policy_mobile_id;
public function __construct(ObjectManager $om, $policy_promo,
public function __construct(EntityManagerInterface $om, $policy_promo,
$policy_third_party, $policy_mobile)
{
$this->em = $om;

View file

@ -7,8 +7,6 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use App\Service\APNSClient;
use DateTime;

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\JobOrder;
@ -18,7 +18,7 @@ class UpdateCustomerVehicleBatteryCommand extends Command
protected $em;
protected $custvehicle_hash;
public function __construct(ObjectManager $om)
public function __construct(EntityManagerInterface $om)
{
$this->em = $om;
$this->custvehicle_hash = [];

View file

@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Warranty;
use App\Entity\CustomerVehicle;
@ -19,7 +19,7 @@ class UpdateCustomerVehicleWarrantyCommand extends Command
protected $em;
protected $wh;
public function __construct(ObjectManager $em, WarrantyHandler $wh)
public function __construct(EntityManagerInterface $em, WarrantyHandler $wh)
{
$this->em = $em;
$this->wh = $wh;

View file

@ -7,7 +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\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Rider;
use App\Entity\Battery;
@ -20,7 +20,7 @@ class UploadCleanupCommand extends Command
private $encoder_factory;
private $object_manager;
public function __construct(ObjectManager $om, Filesystem $fs, FileUploader $uploader)
public function __construct(EntityManagerInterface $om, Filesystem $fs, FileUploader $uploader)
{
$this->object_manager = $om;
$this->filesystem = $fs;

View file

@ -8,7 +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\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\User;
use App\Entity\Role;
@ -18,7 +18,7 @@ class UserCreateCommand extends Command
private $encoder_factory;
private $object_manager;
public function __construct(EncoderFactoryInterface $ef, ObjectManager $om)
public function __construct(EncoderFactoryInterface $ef, EntityManagerInterface $om)
{
$this->encoder_factory = $ef;
$this->object_manager = $om;

View file

@ -415,6 +415,57 @@ class BatteryController extends Controller
]);
}
public function getBattery(Request $req)
{
// no access check, grant all for this ajax call
// parse the id: model size
$bmfg_id = $req->query->get('mfg_id');
$bmodel_id = $req->query->get('model_id');
$bsize_id = $req->query->get('size_id');
// find the battery using model and size
$em = $this->getDoctrine()->getManager();
$query = $em->createQuery('SELECT b FROM App\Entity\Battery b
JOIN b.model bm
JOIN b.size bs
JOIN b.manufacturer bmfg
WHERE bm.id = :bm_id
AND bs.id = :bs_id
AND bmfg.id = :bmfg_id')
->setParameter('bmfg_id', $bmfg_id)
->setParameter('bm_id', $bmodel_id)
->setParameter('bs_id', $bsize_id);
$result = $query->getResult();
if (empty($result))
{
// TODO: will have to change from 422 to 404
return $this->json([
'success' => false,
'errors' => "Battery does not exist",
], 422);
}
$batteries = [];
foreach ($result as $row)
{
$batteries[] = [
'id' => $row->getID(),
'manufacturer' => $row->getManufacturer()->getName(),
'model' => $row->getModel()->getName(),
'size' => $row->getSize()->getName(),
'price' => $row->getSellingPrice(),
];
}
return $this->json([
'data' => $batteries
]);
}
// check if datatable filter is present and append to query
protected function setQueryFilters($datatable, &$query) {
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {

View file

@ -909,7 +909,7 @@ class JobOrderController extends Controller
$this->denyAccessUnlessGranted('jo_onestep.edit', null, 'No access.');
$error_array = [];
$error_array = $jo_handler->generateOneStepJobOrder($req, $id);
$error_array = $jo_handler->processOneStepJobOrder($req, $id);
// check if any errors were found
if (!empty($error_array)) {

View file

@ -4,7 +4,10 @@ namespace App\Controller;
use App\Entity\Vehicle;
use App\Entity\VehicleManufacturer;
use App\Entity\BatteryManufacturer;
use App\Entity\Battery;
use App\Entity\BatteryModel;
use App\Entity\BatterySize;
use Doctrine\ORM\Query;
use Symfony\Component\HttpFoundation\Request;
@ -225,6 +228,11 @@ class VehicleController extends Controller
$params['years'] = $this->generateYearOptions();
$params['obj'] = $row;
// get battery information for compatible batteries
$params['bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll();
$params['bmodels'] = $em->getRepository(BatteryModel::class)->findAll();
$params['bsizes'] = $em->getRepository(BatterySize::class)->findAll();
// response
return $this->render('vehicle/form.html.twig', $params);
}
@ -278,6 +286,7 @@ class VehicleController extends Controller
$batteries = $req->request->get('batteries');
if (!empty($batteries))
{
// TODO: need to move the checking for batteries to a function
// need to check if a battery has been removed
if (count($current_batteries) > count($batteries))
{
@ -302,6 +311,96 @@ class VehicleController extends Controller
}
}
}
// need to check if a battery has been added
if (count($current_batteries) < count($batteries))
{
// get the ids of current batteries
$cbatt_ids = [];
foreach ($current_batteries as $cbatt)
{
$cbatt_ids = [
$cbatt->getID(),
];
}
// find the battery to add
foreach ($batteries as $batt)
{
$batt_id = $batt;
if (in_array($batt_id, $cbatt_ids))
{
// do nothing since battery already there
continue;
}
else
{
// batt is the new battery
$battery = $em->getRepository(Battery::class)->find($batt_id);
if (!empty($battery))
{
$battery->addVehicle($row);
$em->persist($battery);
}
}
}
}
// check if battery was deleted then another one was added
if (count($current_batteries) == count($batteries))
{
// find deleted battery
foreach ($current_batteries as $cbatt)
{
$cbatt_id = $cbatt->getID();
if (in_array($cbatt_id, $batteries))
{
// do nothing, move to next element
continue;
}
else
{
// cbatt_id has been deleted
$del_battery = $em->getRepository(Battery::class)->find($cbatt_id);
if (!empty($del_battery))
{
$del_battery->removeVehicle($row);
}
}
}
// find the battery to add
$cbatt_ids = [];
foreach ($current_batteries as $cbatt)
{
$cbatt_ids = [
$cbatt->getID(),
];
}
foreach ($batteries as $batt)
{
$batt_id = $batt;
if (in_array($batt_id, $cbatt_ids))
{
// do nothing since battery already there
continue;
}
else
{
// batt is the new battery
$new_battery = $em->getRepository(Battery::class)->find($batt_id);
if (!empty($new_battery))
{
$new_battery->addVehicle($row);
$em->persist($new_battery);
}
}
}
}
}
else
{

View file

@ -165,6 +165,21 @@ class Customer
*/
protected $privpol_promo;
/**
* @ORM\Column(type="boolean", options={"default":false})
*/
protected $flag_promo_email;
/**
* @ORM\Column(type="boolean", options={"default":false})
*/
protected $flag_promo_sms;
/**
* @ORM\Column(type="boolean", options={"default":false})
*/
protected $flag_dpa_consent;
public function __construct()
{
$this->numbers = new ArrayCollection();
@ -191,6 +206,10 @@ class Customer
$this->priv_promo = 0;
$this->flag_csat = false;
$this->flag_promo_email = false;
$this->flag_promo_sms = false;
$this->flag_dpa_consent = false;
}
public function getID()
@ -490,5 +509,36 @@ class Customer
return $this->privpol_promo;
}
public function setPromoEmail($flag_promo_email = true)
{
$this->flag_promo_email = $flag_promo_email;
return $this;
}
public function isPromoEmail()
{
return $this->flag_promo_email;
}
public function setPromoSms($flag_promo_sms = true)
{
$this->flag_promo_sms = $flag_promo_sms;
return $this;
}
public function isPromoSms()
{
return $this->flag_promo_sms;
}
public function setDpaConsent($flag_dpa_consent = true)
{
$this->flag_dpa_consent = $flag_dpa_consent;
return $this;
}
public function isDpaConsent()
{
return $this->flag_dpa_consent;
}
}

View file

@ -320,7 +320,9 @@ class CMBCustomerHandler implements CustomerHandlerInterface
$nerror_array = [];
$verror_array = [];
// TODO: validate mobile numbers
if (!($this->validateMobileNumber($req->request->get('phone_mobile'))))
$error_array['phone_mobile'] = 'Invalid mobile phone number.';
// TODO: validate vehicles
// custom validation for vehicles
@ -685,6 +687,18 @@ class CMBCustomerHandler implements CustomerHandlerInterface
}
}
protected function validateMobileNumber($mobile_number)
{
if (empty($mobile_number))
return true;
if (strlen($mobile_number) != 9)
return false;
if(preg_match('/^\d+$/',$mobile_number))
return true;
return false;
}
// check if datatable filter is present and append to query
protected function setQueryFilters($datatable, &$query) {
if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) {

View file

@ -514,6 +514,10 @@ class ResqCustomerHandler implements CustomerHandlerInterface
'phone_landline' => $customer->getPhoneLandline(),
'phone_office' => $customer->getPhoneOffice(),
'phone_fax' => $customer->getPhoneFax(),
'email' => $customer->getEmail(),
'flag_dpa_consent' => $customer->isDpaConsent(),
'flag_promo_sms' => $customer->isPromoSms(),
'flag_promo_email' => $customer->isPromoEmail(),
],
'vehicle' => [
'id' => $vehicle->getID(),
@ -566,7 +570,10 @@ class ResqCustomerHandler implements CustomerHandlerInterface
->setCustomerNotes($req->request->get('customer_notes'))
->setEmail($req->request->get('email'))
->setIsCSAT($req->request->get('flag_csat') ? true : false)
->setActive($req->request->get('flag_active') ? true : false);
->setActive($req->request->get('flag_active') ? true : false)
->setPromoSms($req->request->get('flag_promo_sms', false))
->setPromoEmail($req->request->get('flag_promo_email', false))
->setDpaConsent($req->request->get('flag_dpa_consent', false));
// phone numbers
$obj->setPhoneMobile($req->request->get('phone_mobile'))

View file

@ -444,7 +444,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
->setColor('')
->setStatusCondition('')
->setFuelType('')
->setActive();
->setActive()
->setWarrantyCode($req->request->get('warranty_code'));
if (($req->request->get('service_type')) == CMBServiceType::BATTERY_REPLACEMENT_NEW)
{
@ -480,6 +481,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
{
$jo->setCustomerVehicle($cust_vehicle);
$jo->setCustomer($cust_vehicle->getCustomer());
// save serial into cv
$cust_vehicle->setWarrantyCode($req->request->get('warranty_code'));
$em->persist($cust_vehicle);
}
}
}
@ -731,7 +737,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
}
// assign job order
public function assignJobOrder(Request $req, $id, MQTTCLient $mclient, APNSClient $aclient)
public function assignJobOrder(Request $req, $id)
{
// get object data
$em = $this->em;
@ -827,7 +833,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
}
// fulfill job order
public function fulfillJobOrder(Request $req, $id, MQTTClient $mclient)
public function fulfillJobOrder(Request $req, $id)
{
// initialize error list
$error_array = [];
@ -893,8 +899,11 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
// save to customer vehicle battery record
$this->updateVehicleBattery($obj);
// validated! save the entity
$em->flush();
// save serial to customer vehicle
$cust_vehicle = $obj->getCustomerVehicle();
$cust_vehicle->setWarrantyCode($req->request->get('warranty_code'));
$em->persist($cust_vehicle);
// get rider
$rider = $obj->getRider();
@ -907,9 +916,9 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->rah->fulfillJobOrder($obj, $image_url, $rider);
// create the warranty if new battery only
if ($obj->getServiceType () == CMBServiceType::BATTERY_REPLACEMENT_NEW)
if ($this->checkIfNewBattery($obj))
{
$serial = null;
$serial = $req->request->get('warranty_code') ;
$warranty_class = $obj->getWarrantyClass();
$first_name = $obj->getCustomer()->getFirstName();
$last_name = $obj->getCustomer()->getLastName();
@ -945,6 +954,9 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
$this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
}
}
// validated! save the entity
$em->flush();
}
}
@ -2268,7 +2280,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
public function updateVehicleBattery(JobOrder $jo)
{
// check if new battery
if ($jo->getServiceType() != CMBServiceType::BATTERY_REPLACEMENT_NEW)
if (!($this->checkIfNewBattery($jo)))
return;
// customer vehicle
@ -2301,6 +2313,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
// warranty expiration
// use GetWarrantyPrivate for passenger warranty
$warr_months = 0;
$warr = $jo->getWarrantyClass();
if ($warr == CMBWarrantyClass::WTY_PASSENGER)
$warr_months = $battery->getWarrantyPrivate();
@ -2324,6 +2337,14 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
return $params;
}
public function checkIfNewBattery(JobOrder $jo)
{
if ($jo->getServiceType() == CMBServiceType::BATTERY_REPLACEMENT_NEW)
return true;
return false;
}
protected function fillDropdownParameters(&$params)
{
$em = $this->em;

View file

@ -23,6 +23,8 @@ use App\Entity\Hub;
use App\Entity\Promo;
use App\Entity\Rider;
use App\Entity\JORejection;
use App\Entity\Warranty;
use App\Entity\Customer;
use App\Ramcar\InvoiceCriteria;
use App\Ramcar\ServiceType;
@ -38,6 +40,7 @@ use App\Ramcar\JORejectionReason;
use App\Service\InvoiceGeneratorInterface;
use App\Service\JobOrderHandlerInterface;
use App\Service\RiderAssignmentHandlerInterface;
use App\Service\WarrantyHandler;
use App\Service\MQTTClient;
use App\Service\APNSClient;
@ -59,6 +62,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
protected $security;
protected $validator;
protected $translator;
protected $rah;
protected $country_code;
protected $wh;
@ -66,14 +70,15 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
public function __construct(Security $security, EntityManagerInterface $em,
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
TranslatorInterface $translator, string $country_code,
WarrantyHandler $wh)
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
string $country_code, WarrantyHandler $wh)
{
$this->em = $em;
$this->ic = $ic;
$this->security = $security;
$this->validator = $validator;
$this->translator = $translator;
$this->rah = $rah;
$this->country_code = $country_code;
$this->wh = $wh;
@ -276,6 +281,22 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$jo = new JobOrder();
}
// find customer
$cust_id = $req->request->get('cid');
$customer = $em->getRepository(Customer::class)->find($cust_id);
if (empty($customer))
{
$error_array['customer_vehicle'] = 'Invalid customer specified.';
}
else
{
// get email, dpa_consent, promo_sms, and promo_email, if set
$customer->setEmail($req->request->get('customer_email'))
->setPromoSms($req->request->get('flag_promo_sms', false))
->setPromoEmail($req->request->get('flag_promo_email', false))
->setDpaConsent($req->request->get('flag_dpa_consent', false));
}
// check if lat and lng are provided
if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) {
$error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.';
@ -361,8 +382,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// check if errors are found
if (empty($error_array))
{
// validated, no error. save the job order
// validated, no error. save the job order and customer
$em->persist($jo);
$em->persist($customer);
// the event
$event = new JOEvent();
@ -515,7 +537,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
}
// assign job order
public function assignJobOrder(Request $req, $id, MQTTCLient $mclient, APNSClient $aclient)
public function assignJobOrder(Request $req, $id)
{
// get object data
$em = $this->em;
@ -606,22 +628,15 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// validated! save the entity
$em->flush();
// send event to mobile app
$payload = [
'event' => 'driver_assigned'
];
$mclient->sendEvent($obj, $payload);
$mclient->sendRiderEvent($obj, $payload);
// sned push notification
$aclient->sendPush($obj, "A RESQ rider is on his way to you.");
// call rider assignment handler's assignJobOrder
$this->rah->assignJobOrder($obj, $rider);
}
return $error_array;
}
// fulfill job order
public function fulfillJobOrder(Request $req, $id, MQTTClient $mclient)
public function fulfillJobOrder(Request $req, $id)
{
// initialize error list
$error_array = [];
@ -697,19 +712,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
if ($rider->getImageFile() != null)
$image_url = $req->getScheme() . '://' . $req->getHttpHost() . $req->getBasePath() . '/uploads/' . $rider->getImageFile();
// send to mqtt
$payload = [
'event' => 'fulfilled',
'jo_id' => $obj->getID(),
'driver_image' => $image_url,
'driver_name' => $rider->getFullName(),
'driver_id' => $rider->getID(),
];
$mclient->sendEvent($obj, $payload);
$mclient->sendRiderEvent($obj, $payload);
// call rider assignment handler's fulfillJobOrder
$this->rah->fulfillJobOrder($obj, $image_url, $rider);
// create the warranty if new battery only
if ($obj->getServiceType () == ServiceType::BATTERY_REPLACEMENT_NEW)
if ($this->checkIfNewBattery($obj))
{
$serial = null;
$warranty_class = $obj->getWarrantyClass();
@ -2215,10 +2222,18 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
return null;
}
public function getOtherParameters()
{
// get riders for dropdown
$params['riders'] = $this->em->getRepository(Rider::class)->findAll();
return $params;
}
public function updateVehicleBattery(JobOrder $jo)
{
// check if new battery
if ($jo->getServiceType() != ServiceType::BATTERY_REPLACEMENT_NEW)
if (!($this->checkIfNewBattery($jo)))
return;
// customer vehicle
@ -2251,6 +2266,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
// warranty expiration
$warr = $jo->getWarrantyClass();
$warr_months = 0;
if ($warr == WarrantyClass::WTY_PRIVATE)
$warr_months = $battery->getWarrantyPrivate();
else if ($warr == WarrantyClass::WTY_COMMERCIAL)
@ -2267,6 +2283,14 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->setWarrantyExpiration($warr_date);
}
public function checkIfNewBattery(JobOrder $jo)
{
if ($jo->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW)
return true;
return false;
}
protected function fillDropdownParameters(&$params)
{
$em = $this->em;
@ -2453,7 +2477,36 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
switch ($tier)
{
case 'fulfill':
$query->where('q.status IN (:statuses)')
if (isset($datatable['query']['data-rows-search']))
{
$query->innerJoin('q.cus_vehicle', 'cv')
->innerJoin('q.customer', 'c')
->where('cv.plate_number like :filter')
->orWhere('c.phone_mobile like :filter')
->orWhere('c.first_name like :filter or c.last_name like :filter')
->setParameter('filter', $datatable['query']['data-rows-search'] . '%');
}
if (isset($datatable['query']['rider']))
{
$query->innerJoin('q.rider', 'r')
->andWhere('r.id = :rider_id')
->setParameter('rider_id', $datatable['query']['rider']);
}
if (isset($datatable['query']['schedule_date']))
{
$start = $datatable['query']['schedule_date'][0] . ' ' . '00:00:00';
$end = $datatable['query']['schedule_date'][1] . ' ' . '23:59:00';
$date_start = DateTime::createFromFormat('m/d/Y H:i:s', $start);
$date_end = DateTime::createFromFormat('m/d/Y H:i:s', $end);
$query->andWhere('q.date_schedule >= :date_start')
->andWhere('q.date_schedule <= :date_end')
->setParameter('date_start', $date_start)
->setParameter('date_end', $date_end);
}
$query->andWhere('q.status IN (:statuses)')
->andWhere('q.hub IN (:hubs)')
->setParameter('statuses', $status, Connection::PARAM_STR_ARRAY)
->setParameter('hubs', $hubs, Connection::PARAM_STR_ARRAY);
@ -2479,6 +2532,25 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$query->where('q.status IN (:statuses)')
->setParameter('statuses', $status, Connection::PARAM_STR_ARRAY);
}
if (isset($datatable['query']['rider']))
{
$query->innerJoin('q.rider', 'r')
->andWhere('r.id = :rider_id')
->setParameter('rider_id', $datatable['query']['rider']);
}
if (isset($datatable['query']['schedule_date']))
{
$start = $datatable['query']['schedule_date'][0] . ' ' . '00:00:00';
$end = $datatable['query']['schedule_date'][1] . ' ' . '23:59:00';
$date_start = DateTime::createFromFormat('m/d/Y H:i:s', $start);
$date_end = DateTime::createFromFormat('m/d/Y H:i:s', $end);
$query->andWhere('q.date_schedule >= :date_start')
->andWhere('q.date_schedule <= :date_end')
->setParameter('date_start', $date_start)
->setParameter('date_end', $date_end);
}
break;
case 'all':
if (isset($datatable['query']['data-rows-search']))
@ -2490,6 +2562,25 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
->orWhere('c.first_name like :filter or c.last_name like :filter')
->setParameter('filter', $datatable['query']['data-rows-search'] . '%');
}
if (isset($datatable['query']['rider']))
{
$query->innerJoin('q.rider', 'r')
->andWhere('r.id = :rider_id')
->setParameter('rider_id', $datatable['query']['rider']);
}
if (isset($datatable['query']['schedule_date']))
{
$start = $datatable['query']['schedule_date'][0] . ' ' . '00:00:00';
$end = $datatable['query']['schedule_date'][1] . ' ' . '23:59:00';
$date_start = DateTime::createFromFormat('m/d/Y H:i:s', $start);
$date_end = DateTime::createFromFormat('m/d/Y H:i:s', $end);
$query->andWhere('q.date_schedule >= :date_start')
->andWhere('q.date_schedule <= :date_end')
->setParameter('date_start', $date_start)
->setParameter('date_end', $date_end);
}
break;
default:
$query->where('q.status = :status')

View file

@ -31,10 +31,10 @@ interface JobOrderHandlerInterface
public function dispatchJobOrder(Request $req, int $id, MQTTClient $mclient);
// assign job order
public function assignJobOrder(Request $req, int $id, MQTTCLient $mclient, APNSClient $aclient);
public function assignJobOrder(Request $req, int $id);
// fulfill job order
public function fulfillJobOrder(Request $req, int $id, MQTTClient $mclient);
public function fulfillJobOrder(Request $req, int $id);
// cancel job order
public function cancelJobOrder(Request $req, int $id, MQTTClient $mclient);
@ -95,4 +95,7 @@ interface JobOrderHandlerInterface
// update customer vehicle battery warranty info
public function updateVehicleBattery(JobOrder $jo);
// check if service type is new battery
public function checkIfNewBattery(JobOrder $jo);
}

View file

@ -524,9 +524,9 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$this->em->flush();
// create warranty
if ($jo->getServiceType() == CMBServiceType::BATTERY_REPLACEMENT_NEW)
if($this->jo_handler->checkIfNewBattery($jo))
{
$serial = null;
$serial = $jo->getCustomerVehicle()->getWarrantyCode();
$warranty_class = $jo->getWarrantyClass();
$first_name = $jo->getCustomer()->getFirstName();
$last_name = $jo->getCustomer()->getLastName();

View file

@ -523,7 +523,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
$this->em->flush();
// create warranty
if ($jo->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW)
if($this->jo_handler->checkIfNewBattery($jo))
{
$serial = null;
$warranty_class = $jo->getWarrantyClass();

View file

@ -0,0 +1,72 @@
<?php
namespace App\Service\RiderAssignmentHandler;
use Doctrine\ORM\EntityManagerInterface;
use App\Service\RiderAssignmentHandlerInterface;
use App\Service\MQTTClient;
use App\Service\APNSClient;
use App\Entity\JobOrder;
use App\Entity\Rider;
use App\Ramcar\JOStatus;
class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface
{
protected $em;
protected $aclient;
protected $mclient;
public function __construct(EntityManagerInterface $em, MQTTClient $mclient,
APNSClient $aclient)
{
$this->em = $em;
$this->mclient = $mclient;
$this->aclient = $aclient;
}
// assign job order to rider
public function assignJobOrder(JobOrder $obj, Rider $rider)
{
// create the payload
$payload = [
'event' => 'driver_assigned'
];
// send event
$this->mclient->sendEvent($obj, $payload);
// check if rider is available
if ($rider->isAvailable())
{
error_log('set rider availability to false');
// set rider to unavailable
$rider->setAvailable(false);
// send event to rider
$this->mclient->sendRiderEvent($obj, $payload);
// send push notification
$this->aclient->sendPush($obj, "A RESQ rider is on his way to you.");
}
}
// complete job order
public function fulfillJobOrder(JobOrder $obj, string $image_url, Rider $rider)
{
// send to mqtt
$payload = [
'event' => 'fulfilled',
'jo_id' => $obj->getID(),
'driver_image' => $image_url,
'driver_name' => $rider->getFullName(),
'driver_id' => $rider->getID(),
];
$this->mclient->sendEvent($obj, $payload);
// send fulfill/complete event to rider
$this->mclient->sendRiderEvent($obj, $payload);
}
}

View file

@ -122,6 +122,9 @@
"ocramius/proxy-manager": {
"version": "2.2.0"
},
"php": {
"version": "7.2"
},
"predis/predis": {
"version": "v1.1.1"
},
@ -185,6 +188,9 @@
"symfony/dotenv": {
"version": "v4.0.2"
},
"symfony/error-handler": {
"version": "v4.4.4"
},
"symfony/event-dispatcher": {
"version": "v4.0.2"
},

View file

@ -92,7 +92,7 @@
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-12">
<div class="col-lg-4">
<span class="m-switch m-switch--icon block-switch">
<label>
<input type="checkbox" name="flag_csat" id="flag_csat" value="1"{{ obj.isCSAT() ? ' checked' }}>
@ -102,6 +102,30 @@
</span>
<div class="form-control-feedback hide" data-field="flag_active"></div>
</div>
<div class="col-lg-4">
<div class="col-lg-12 form-group-inner">
<label data-field="source">Marketing Promo</label>
<div class="m-checkbox-list">
<label class="m-checkbox">
<input type="checkbox" name="flag_promo_sms" value="1"{{ obj.isPromoSms ? ' checked' }} >
SMS
<span></span>
<div class="form-control-feedback hide" data-field="flag_promo_sms"></div>
</label>
<label class="m-checkbox">
<input type="checkbox" name="flag_promo_email" value="1"{{ obj.isPromoEmail ? ' checked' }} >
Email
<span></span>
<div class="form-control-feedback hide" data-field="flag_promo_email"></div>
</label>
</div>
</div>
</div>
<div class="col-lg-4">
<input type="checkbox" name="flag_dpa_consent" id="flag-dpa_consent" value="1"{{ obj.isDpaConsent ? ' checked' }} >
<label class="switch-label">With DPA Consent</label>
<div class="form-control-feedback hide" data-field="flag_dpa_consent"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-12">

View file

@ -211,7 +211,7 @@
</div>
<div class="col-lg-3">
<label data-field="warranty_code">Serial Number</label>
<input type="text" name="warranty_code" id="warranty-code" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getWarrantyCode }}" data-vehicle-field="1" disabled>
<input type="text" name="warranty_code" id="warranty-code" class="form-control m-input" value="{{ obj.getCustomerVehicle ? obj.getCustomerVehicle.getWarrantyCode }}">
<div class="form-control-feedback hide" data-field="warranty_code"></div>
</div>
<div class="col-lg-3">
@ -1109,7 +1109,7 @@ $(function() {
$("#warranty-code").val(vdata.battery.warranty_code);
$("#warranty-expiration").val(vdata.battery.warranty_expiration);
} else {
$("#current-battery, #warranty-code, #warranty-expiration").val("No current battery").css('color', '#f4516c');
$("#current-battery, #warranty-expiration").val("No current battery").css('color', '#f4516c');
}
})
}).focus();

View file

@ -46,6 +46,7 @@
</div>
<form id="row-form" class="m-form m-form--fit m-form--label-align-right" method="post" action="{{ submit_url }}">
<input type="hidden" id="invoice-change" name="invoice_change" value="0">
<input type="hidden" id="cid" name="cid" value="0">
<div class="m-portlet__body">
{% if ftags.vehicle_dropdown %}
@ -148,6 +149,11 @@
<textarea name="customer_customer_notes" id="customer-customer-notes" class="form-control m-input" data-vehicle-field="1" rows="4" disabled>{{ obj.getCustomer ? obj.getCustomer.getCustomerNotes }}</textarea>
<div class="form-control-feedback hide" data-field="customer_customer_notes"></div>
</div>
<div class="col-lg-6">
<input type="checkbox" name="flag_dpa_consent" id="flag-dpa-consent" value="1"{{ obj.getCustomer ? obj.getCustomer.isDpaConsent ? ' checked' }} >
<label class="switch-label">With DPA Consent</label>
<div class="form-control-feedback hide" data-field="flag_dpa_consent"></div>
</div>
</div>
</div>
<div class="m-form__section">
@ -331,6 +337,34 @@
<div class="form-control-feedback hide" data-field="date_transaction"></div>
</div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<div class="col-lg-12 form-group-inner">
<label data-field="source">Marketing Promo</label>
<div class="m-checkbox-list">
<label class="m-checkbox">
<input type="checkbox" name="flag_promo_sms" id="flag-promo-sms" value="1"{{ obj.getCustomer ? obj.getCustomer.isPromoSms ? ' checked' }} >
SMS
<span></span>
<div class="form-control-feedback hide" data-field="flag_promo_sms"></div>
</label>
<label class="m-checkbox">
<input type="checkbox" name="flag_promo_email" id="flag-promo-email" value="1"{{ obj.getCustomer ? obj.getCustomer.isPromoEmail ? ' checked' }} >
Email
<span></span>
<div class="form-control-feedback hide" data-field="flag_promo_email"></div>
</label>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="col-lg-12 form-group-inner">
<label>Email Address</label>
<input type="text" name="customer_email" id="customer-email" class="form-control m-input" value="{{ obj.getCustomer ? obj.getCustomer.getEmail|default('') }}" data-vehicle-field="1" >
<div class="form-control-feedback hide" data-field="customer_email"></div>
</div>
</div>
</div>
<!--
<div class="form-group m-form__group row">
@ -1032,6 +1066,14 @@ $(function() {
{% endfor %}
{% endif %}
// disable the enabled customer fields
{% if mode != 'create' %}
$("#customer-email").prop("disabled", true);
$("#flag-dpa-consent").prop("disabled", true);
$("#flag-promo-sms").prop("disabled", true);
$("#flag-promo-email").prop("disabled", true);
{% endif %}
$("#row-form").submit(function(e) {
if (form_in_process) {
alert("Cannot submit form twice. First submission still in progress.");
@ -1172,12 +1214,27 @@ $(function() {
$("#customer-phone-office").val(vdata.customer.phone_office);
$("#customer-phone-fax").val(vdata.customer.phone_fax);
$("#customer-customer-notes").val(vdata.customer.customer_notes);
$("#customer-email").val(vdata.customer.email);
$("#vmfg").val(vdata.vehicle.mfg_name);
$("#vehicle-make").val(vdata.vehicle.make);
$("#vehicle-year").val(vdata.vehicle.model_year);
$("#vehicle-color").val(vdata.vehicle.color);
$("#vehicle-plate").val(vdata.vehicle.plate_number);
// checkboxes
if (vdata.customer.flag_dpa_consent === true) {
$("#flag-dpa-consent").prop("checked", true);
}
if (vdata.customer.flag_promo_sms === true) {
$("#flag-promo-sms").prop("checked", true);
}
if (vdata.customer.flag_promo_email === true) {
$("#flag-promo-email").prop("checked", true);
}
// set hidden customer id
$("#cid").val(vdata.customer.id);
if (typeof vdata.battery !== 'undefined') {
$("#current-battery").val(vdata.battery.mfg_name + " " + vdata.battery.model_name + " " + vdata.battery.size_name + " (" + vdata.battery.prod_code + ")");
$("#warranty-code").val(vdata.battery.warranty_code);
@ -1213,6 +1270,10 @@ $(function() {
// reset all vehicle info form fields
function resetVehicleFields() {
$("[data-vehicle-field='1']").val("").css('color', '').prop('placeholder', 'Select a vehicle first');
$("#flag-dpa-consent").prop("checked", false);
$("#flag-promo-sms").prop("checked", false);
$("#flag-promo-email").prop("checked", false);
}
// datepicker

View file

@ -97,7 +97,6 @@
{% if mode == 'update' %}
<div class="m-form__seperator m-form__seperator--dashed"></div>
<div class="m-form__section m-form__section--last">
<div class="m-form__heading">
<h3 class="m-form__heading-title">
@ -109,9 +108,37 @@
<div class="m_datatable" id="data-batts"></div>
</div>
</div>
<div class="form-group m-form__group row">
<label class="col-lg-1 col-form-label" data-field="battery_list">
Add Battery:
</label>
<div class="col-lg-3">
<select name="bmfg_list" class="form-control m-input" id="bmfg">
{% for bmfg in bmfgs %}
<option value="{{ bmfg.getID }}">{{ bmfg.getName }}</option>
{% endfor %}
</select>
</div>
<div class="col-lg-3">
<select name="bmodel_list" class="form-control m-input" id="bmodel">
{% for bmodel in bmodels %}
<option value="{{ bmodel.getID }}">{{ bmodel.getName }}</option>
{% endfor %}
</select>
</div>
<div class="col-lg-3">
<select name="bsize_list" class="form-control m-input" id="bsize">
{% for bsize in bsizes %}
<option value="{{ bsize.getID }}">{{ bsize.getName }}</option>
{% endfor %}
</select>
</div>
<div class="col-lg-3">
<button type="button" class="btn btn-primary" id="btn-add-battery" >Add to List</button>
</div>
</div>
</div>
{% endif %}
</div>
<div class="m-portlet__foot m-portlet__foot--fit">
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
@ -201,12 +228,15 @@ $(function() {
});
});
// initialize battery arrays
var battRows = [];
var batteryIds = [];
var battMfgModelSize = []
{% for batt in obj.getBatteries %}
trow = {
id: "{{ batt.getID }}",
manufacturer: "{{ batt.getManufacturer.getName|default('') }} ",
model: "{{ batt.getModel.getName|default('') }}",
size: "{{ batt.getSize.getName|default('') }}",
sell_price: "{{ batt.getSellingPrice }}"
@ -214,6 +244,7 @@ $(function() {
battRows.push(trow);
batteryIds.push({{ batt.getID }});
battMfgModelSize.push({{ batt.getManufacturer.getID }} + ' ' + {{ batt.getModel.getID }} + ' ' + {{ batt.getSize.getID }});
{% endfor %}
// remove battery from table
@ -237,6 +268,66 @@ $(function() {
battTable.reload();
});
// add a battery to the table
$("#btn-add-battery").click(function() {
var bmfg_id = $("#bmfg").val();
var bmodel_id = $("#bmodel").val();
var bsize_id = $("#bsize").val();
var batt_key = (bmfg_id + ' ' + bmodel_id + ' ' + bsize_id);
if (battMfgModelSize.indexOf(batt_key) !== -1) {
swal({
title: 'Whoops',
text: 'This battery is already on the list.',
type: 'warning'
});
return true;
}
// get the battery given the model and size
$.ajax({
method: "GET",
url: "{{ url('battery_ajax_get') }}",
data: {mfg_id: bmfg_id, model_id: bmodel_id, size_id: bsize_id}
}).done(function(response) {
if (response.data.length > 0) {
var batt = response.data[0];
batteryIds.push(batt.id);
brow = {
id: batt.id,
manufacturer: batt.manufacturer,
model: batt.model,
size: batt.size,
sell_price: batt.price
};
battRows.push(brow);
// add battery to arrays
battMfgModelSize.push(batt_key);
// refresh the data table
battTable.originalDataSet = battRows;
battTable.reload();
}
}).fail(function(response) {
// TODO: change response status to 404. For some strange reason,
// if status is set to 422, the swal does not display.
// Instead, we get the technical error box.
if (response.status == 422) {
swal({
title: 'Whoops',
text: 'This battery does not exist.',
type: 'warning'
});
return true;
}
});
});
// battery data table
var battOptions = {
data: {
@ -256,6 +347,10 @@ $(function() {
title: 'ID',
width: 50
},
{
field: 'manufacturer',
title: 'Manufacturer',
},
{
field: 'size',
title: 'Size'