Add customer source when creating a new customer. #548
This commit is contained in:
parent
28d530c0a2
commit
532df141ed
8 changed files with 45 additions and 6 deletions
|
|
@ -216,7 +216,8 @@ class CreateCustomerFromWarrantyCommand extends Command
|
|||
$new_cust = new Customer();
|
||||
$new_cust->setFirstName($w_first_name)
|
||||
->setLastName($w_last_name)
|
||||
->setPhoneMobile($w_mobile_num);
|
||||
->setPhoneMobile($w_mobile_num)
|
||||
->setCreateSource('CMB_CreateFromCustomerWarranty');
|
||||
|
||||
$this->em->persist($new_cust);
|
||||
|
||||
|
|
|
|||
|
|
@ -418,7 +418,8 @@ class ImportCustomerCommand extends Command
|
|||
$fields[self::F_OFFICE_PHONE],
|
||||
$fields[self::F_FAX],
|
||||
$fields[self::F_EMAIL],
|
||||
isset($fields[self::F_NOTES]) ? $fields[self::F_NOTES] : ''
|
||||
isset($fields[self::F_NOTES]) ? $fields[self::F_NOTES] : '',
|
||||
'CMB_ImportCustomerCommand'
|
||||
];
|
||||
$cust_row = str_replace('\\', '\\\\', implode('|', $cust_fields)) . "\n";
|
||||
fputs($cust_file, $cust_row);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use App\Ramcar\JOEventType;
|
|||
use App\Ramcar\AdvanceOrderSlot;
|
||||
use App\Ramcar\AutoAssignStatus;
|
||||
use App\Ramcar\WarrantySource;
|
||||
use App\Ramcar\CustomerSource;
|
||||
|
||||
use App\Service\InvoiceGeneratorInterface;
|
||||
use App\Service\RisingTideGateway;
|
||||
|
|
@ -416,6 +417,9 @@ 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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -154,10 +156,17 @@ class CustomerController extends APIController
|
|||
else
|
||||
{
|
||||
// customer not found
|
||||
// get the api_user that made the call so that it gets added to the source
|
||||
// source becomes CAPI_USER_<insert name of api user here>
|
||||
$user_id = $_SERVER['HTTP_X_CATA_API_KEY'];
|
||||
$username = $this->getUser()->getName();
|
||||
$source = 'CAPI_USER_' . $username;
|
||||
|
||||
$new_cust = new Customer();
|
||||
$new_cust->setFirstName($first_name)
|
||||
->setLastName($last_name)
|
||||
->setPhoneMobile($mobile_number);
|
||||
->setPhoneMobile($mobile_number)
|
||||
->setCreateSource($source);
|
||||
|
||||
$em->persist($new_cust);
|
||||
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ class CustomerWarrantyController extends APIController
|
|||
'serial' => $serial,
|
||||
];
|
||||
$action = 'check';
|
||||
// TODO: we need to modify this later.
|
||||
$source = WarrantySource::CAPI;
|
||||
|
||||
// check required parameters
|
||||
|
|
@ -491,7 +492,8 @@ class CustomerWarrantyController extends APIController
|
|||
->setEmail($req->request->get('email'))
|
||||
->setCreateSource('web_warranty')
|
||||
->setPrivacyPromo($priv_promo)
|
||||
->setPhoneMobile($req->request->get('contact_num'));
|
||||
->setPhoneMobile($req->request->get('contact_num'))
|
||||
->setCreateSource($source);
|
||||
|
||||
$em->persist($cust);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -728,10 +728,12 @@ class WarrantyController extends APIController
|
|||
$w_last_name = $warranty->getLastName();
|
||||
|
||||
$new_cust = new Customer();
|
||||
// TODO: add customer source
|
||||
// add customer source
|
||||
$cust_source = $warranty->getCreateSource();
|
||||
$new_cust->setFirstName($w_first_name)
|
||||
->setLastName($w_last_name)
|
||||
->setPhoneMobile($w_mobile_num);
|
||||
->setPhoneMobile($w_mobile_num)
|
||||
->setCreateSource($cust_source);
|
||||
|
||||
$em->persist($new_cust);
|
||||
|
||||
|
|
|
|||
16
src/Ramcar/CustomerSource.php
Normal file
16
src/Ramcar/CustomerSource.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class CustomerSource extends NameValue
|
||||
{
|
||||
const MOBILE = 'mobile_api';
|
||||
const ADMIN_PANEL = 'admin_panel';
|
||||
const LEGACY = 'legacy';
|
||||
|
||||
const COLLECTION = [
|
||||
'mobile_api' => 'Mobile API',
|
||||
'admin_panel' => 'Admin Panel',
|
||||
'legacy' => 'Legacy',
|
||||
];
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -189,6 +190,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'));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue