diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index b03f057e..4b80b074 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -28,6 +28,7 @@ use App\Ramcar\TradeInType; use App\Ramcar\JOEventType; use App\Ramcar\AdvanceOrderSlot; use App\Ramcar\AutoAssignStatus; +use App\Ramcar\CustomerSource; use App\Service\InvoiceGeneratorInterface; use App\Service\RisingTideGateway; @@ -413,6 +414,10 @@ class APIController extends Controller implements LoggedController if ($cust == null) { $cust = new Customer(); + + // set customer source + $cust->setCreateSource(CustomerSource::MOBILE); + $em->persist($cust); $this->session->setCustomer($cust); diff --git a/src/Controller/CAPI/CustomerController.php b/src/Controller/CAPI/CustomerController.php index 55aae2bd..33d87249 100644 --- a/src/Controller/CAPI/CustomerController.php +++ b/src/Controller/CAPI/CustomerController.php @@ -15,6 +15,8 @@ use App\Entity\Customer; use App\Entity\CustomerVehicle; use App\Entity\Vehicle; +use App\Ramcar\CustomerSource; + use Catalyst\APIBundle\Access\Generator as ACLGenerator; class CustomerController extends APIController @@ -157,7 +159,8 @@ class CustomerController extends APIController $new_cust = new Customer(); $new_cust->setFirstName($first_name) ->setLastName($last_name) - ->setPhoneMobile($mobile_number); + ->setPhoneMobile($mobile_number) + ->setCreateSource(CustomerSource::THIRD_PARTY); $em->persist($new_cust); diff --git a/src/Controller/CAPI/CustomerWarrantyController.php b/src/Controller/CAPI/CustomerWarrantyController.php index 0ebc2c60..cce42ab2 100644 --- a/src/Controller/CAPI/CustomerWarrantyController.php +++ b/src/Controller/CAPI/CustomerWarrantyController.php @@ -420,7 +420,7 @@ class CustomerWarrantyController extends APIController $cust->setFirstName($req->request->get('first_name')) ->setLastName($req->request->get('last_name')) ->setEmail($req->request->get('email')) - ->setCreateSource('web_warranty') + ->setCreateSource(CustomerSource::WEB_WARRANTY) ->setPrivacyPromo($priv_promo) ->setPhoneMobile($req->request->get('contact_num')); diff --git a/src/Controller/CAPI/WarrantyController.php b/src/Controller/CAPI/WarrantyController.php index c444370c..5b9230c3 100644 --- a/src/Controller/CAPI/WarrantyController.php +++ b/src/Controller/CAPI/WarrantyController.php @@ -26,6 +26,7 @@ use App\Ramcar\WarrantyClass; use App\Ramcar\WarrantyStatus; use App\Ramcar\FuelType; use App\Ramcar\VehicleStatusCondition; +use App\Ramcar\CustomerSource; use DateTime; @@ -636,7 +637,8 @@ class WarrantyController extends APIController $new_cust = new Customer(); $new_cust->setFirstName($w_first_name) ->setLastName($w_last_name) - ->setPhoneMobile($w_mobile_num); + ->setPhoneMobile($w_mobile_num) + ->setCreateSource(CustomerSource::APP_WARRANTY); $em->persist($new_cust); diff --git a/src/Ramcar/CustomerSource.php b/src/Ramcar/CustomerSource.php new file mode 100644 index 00000000..7f8538aa --- /dev/null +++ b/src/Ramcar/CustomerSource.php @@ -0,0 +1,22 @@ + 'Mobile API', + 'third_party_api' => 'Third Party API', + 'web_warranty' => 'Web Warranty', + 'app_warranty' => 'App Warranty', + 'admin_panel' => 'Admin Panel', + 'legacy' => 'Legacy', + ]; +} diff --git a/src/Service/CustomerHandler/ResqCustomerHandler.php b/src/Service/CustomerHandler/ResqCustomerHandler.php index 76d20054..321eb976 100644 --- a/src/Service/CustomerHandler/ResqCustomerHandler.php +++ b/src/Service/CustomerHandler/ResqCustomerHandler.php @@ -15,6 +15,7 @@ use App\Ramcar\CustomerClassification; use App\Ramcar\FuelType; use App\Ramcar\VehicleStatusCondition; use App\Ramcar\CrudException; +use App\Ramcar\CustomerSource; use App\Entity\Customer; use App\Entity\CustomerVehicle; @@ -185,6 +186,9 @@ class ResqCustomerHandler implements CustomerHandlerInterface $this->setObject($row, $req); + // set customer source only when new customer + $row->setCreateSource(CustomerSource::ADMIN_PANEL); + // custom validation for vehicles $vehicles = json_decode($req->request->get('vehicles'));