Set third party source when creating JO from third party. #737

This commit is contained in:
Korina Cordero 2023-02-14 03:12:24 +00:00
parent f8da38fd26
commit f03d2bf7ef
4 changed files with 39 additions and 2 deletions

View file

@ -68,7 +68,7 @@ class User extends BaseUser
// third party job order source linked to api_user
/**
* @ORM\ManyToOne(targetEntity="App\Entity\JobOrderSource", inversedBy="api_users")
* @ORM\JoinColumn(name="source_id", referencedColumnName="id")
* @ORM\JoinColumn(name="source_id", referencedColumnName="id", nullable=true)
*/
protected $source;

View file

@ -112,6 +112,10 @@ class JobOrderController extends APIController
// geofence
$is_covered = $geo->isCovered($data['long'], $data['lat']);
// get the api_user
$api_user = $this->getUser();
$jo_source = $api_user->getSource();
if (!$is_covered)
{
// TODO: put geofence error message in config file somewhere
@ -133,7 +137,8 @@ class JobOrderController extends APIController
->setModeOfPayment($data['payment_mode'])
->setAdvanceOrder($data['is_advance_order'])
->setStatusAutoAssign(AutoAssignStatus::NOT_ASSIGNED)
->setLandmark($data['landmark']);
->setLandmark($data['landmark'])
->setJOSource($jo_source);
$jo->setCustomer($data['customer']);
$jo->setCustomerVehicle($data['customer_vehicle']);

View file

@ -422,6 +422,13 @@ class JobOrder
*/
protected $ownership_type;
// third party jo source linked to job order
/**
* @ORM\ManyToOne(targetEntity="App\Entity\JobOrderSource", inversedBy="job_orders")
* @ORM\JoinColumn(name="job_order_source_id", referencedColumnName="id", nullable=true)
*/
protected $jo_source;
public function __construct()
{
$this->date_create = new DateTime();
@ -446,6 +453,8 @@ class JobOrder
$this->phone_mobile = '';
$this->will_wait = WillingToWaitContent::WILLING_TO_WAIT;
$this->jo_source = null;
}
public function getID()
@ -1199,4 +1208,15 @@ class JobOrder
{
return $this->ownership_type;
}
public function setJOSource($jo_source = null)
{
$this->jo_source = $jo_source;
return $this;
}
public function getJOSource()
{
return $this->jo_source;
}
}

View file

@ -47,6 +47,12 @@ class JobOrderSource
*/
protected $api_users;
// one job order source can be associated to many job orders
/**
* @ORM\OneToMany(targetEntity="JobOrder", mappedBy="jo_source")
*/
protected $job_orders;
public function __construct()
{
$this->code = '';
@ -54,6 +60,7 @@ class JobOrderSource
$this->callback_url = '';
$this->api_users = new ArrayCollection();
$this->job_orders = new ArrayCollection();
}
public function getID()
@ -98,5 +105,10 @@ class JobOrderSource
{
return $this->api_users;
}
public function getJobOrders()
{
return $this->job_orders;
}
}