Add route for getJobOrderInfo. Modify the responses for getJobOrderInfo. #686
This commit is contained in:
parent
4e613e3c01
commit
144afae551
2 changed files with 33 additions and 29 deletions
|
|
@ -21,6 +21,11 @@ tapi_jo_cancel:
|
|||
controller: App\Controller\TAPI\JobOrderController:cancelJobOrder
|
||||
methods: [POST]
|
||||
|
||||
tapi_jo_info:
|
||||
path: /tapi/job_order/{id}/info
|
||||
controller: App\Controller\TAPI\JobOrderController::getJobOrderInfo
|
||||
methods: [GET]
|
||||
|
||||
# vehicle manufacturer and vehicle
|
||||
tapi_vehicle_mfg_list:
|
||||
path: /tapi/vehicle/mfgs
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ use App\Entity\Hub;
|
|||
use App\Entity\Invoice;
|
||||
use App\Entity\Vehicle;
|
||||
use App\Entity\VehicleManufacturer;
|
||||
use App\Entity\Warranty;
|
||||
|
||||
use DateTime;
|
||||
use DateInterval;
|
||||
|
|
@ -575,47 +576,29 @@ class JobOrderController extends APIController
|
|||
{
|
||||
$this->denyAccessUnlessGranted('tapi_jo.get.info', null, 'No access.');
|
||||
|
||||
// check required parameters and api key
|
||||
$res = $this->checkParamsAndKey($req, $em, []);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
|
||||
// get customer
|
||||
// TODO: modify to get customer
|
||||
$cust = $this->session->getCustomer();
|
||||
if ($cust == null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('No customer information found');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
// check required parameters
|
||||
$required_params = [];
|
||||
$msg = $this->checkRequiredParameters($req, $required_params);
|
||||
if ($msg)
|
||||
return new APIResponse(false, $msg);
|
||||
|
||||
// get job order data
|
||||
$jo = $em->getRepository(JobOrder::class)->find($id);
|
||||
if ($jo == null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('No job order information found');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
// check if job order belongs to customer / user
|
||||
if ($cust->getID() != $jo->getCustomer()->getID())
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('No job order information found');
|
||||
return $res->getReturnResponse();
|
||||
$message = 'No job order information found';
|
||||
return new APIResponse(false, $message);
|
||||
}
|
||||
|
||||
// put into job order data array
|
||||
$jo_data = $this->generateJobOrderData($req, $jo, $rt);
|
||||
$jo_data = $this->generateJobOrderData($req, $jo, $rt, $em);
|
||||
|
||||
$data = [
|
||||
'job_order' => $jo_data
|
||||
];
|
||||
$res->setData($data);
|
||||
|
||||
return $res->getReturnResponse();
|
||||
$message = 'Job order information found.';
|
||||
return new APIResponse(true, $message, $data);
|
||||
}
|
||||
|
||||
public function getJOHistory(Request $req, EntityManagerInterface $em)
|
||||
|
|
@ -930,7 +913,7 @@ class JobOrderController extends APIController
|
|||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
protected function generateJobOrderData($req, $jo, $rt)
|
||||
protected function generateJobOrderData($req, $jo, $rt, $em)
|
||||
{
|
||||
$status = $jo->getStatus();
|
||||
|
||||
|
|
@ -1864,6 +1847,22 @@ class JobOrderController extends APIController
|
|||
return $dummy_cv;
|
||||
}
|
||||
|
||||
protected function generateAPIRiderStatus($status)
|
||||
{
|
||||
switch ($status)
|
||||
{
|
||||
case JOStatus::PENDING:
|
||||
return APIRiderStatus::OUTLET_ASSIGN;
|
||||
case JOStatus::RIDER_ASSIGN:
|
||||
return APIRiderStatus::RIDER_ASSIGN;
|
||||
case JOStatus::ASSIGNED:
|
||||
case JOStatus::IN_TRANSIT:
|
||||
case JOStatus::IN_PROGRESS:
|
||||
return APIRiderStatus::RIDER_PICK_UP;
|
||||
}
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
protected function cleanPhoneNumber($mobile)
|
||||
{
|
||||
// remove any non digit character from string
|
||||
|
|
|
|||
Loading…
Reference in a new issue