Remove getJOHistory. Add route for locationSupport. Modify responses of locationSupport. #686
This commit is contained in:
parent
144afae551
commit
2112edd4f0
3 changed files with 17 additions and 159 deletions
|
|
@ -101,8 +101,6 @@ access_keys:
|
||||||
label: Third Party Get Ongoing Job Order
|
label: Third Party Get Ongoing Job Order
|
||||||
- id: tapi_jo.cancel
|
- id: tapi_jo.cancel
|
||||||
label: Third Party Cancel Job Order
|
label: Third Party Cancel Job Order
|
||||||
- id: tapi_jo.get.history
|
|
||||||
label: Third Party Get Job Order History
|
|
||||||
- id: tapi_jo.get.invoice
|
- id: tapi_jo.get.invoice
|
||||||
label: Third Party Get Job Order Invoice
|
label: Third Party Get Job Order Invoice
|
||||||
- id: tapi_jo.location.support
|
- id: tapi_jo.location.support
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,15 @@ tapi_jo_cancel:
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
tapi_jo_info:
|
tapi_jo_info:
|
||||||
path: /tapi/job_order/{id}/info
|
path: /tapi/job_order/{jo_id}/info
|
||||||
controller: App\Controller\TAPI\JobOrderController::getJobOrderInfo
|
controller: App\Controller\TAPI\JobOrderController::getJobOrderInfo
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
|
|
||||||
|
tapi_location_support:
|
||||||
|
path: /tapi/location_support
|
||||||
|
controller: App\Controller\TAPI\JobOrderController:locationSupport
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
# vehicle manufacturer and vehicle
|
# vehicle manufacturer and vehicle
|
||||||
tapi_vehicle_mfg_list:
|
tapi_vehicle_mfg_list:
|
||||||
path: /tapi/vehicle/mfgs
|
path: /tapi/vehicle/mfgs
|
||||||
|
|
|
||||||
|
|
@ -601,130 +601,6 @@ class JobOrderController extends APIController
|
||||||
return new APIResponse(true, $message, $data);
|
return new APIResponse(true, $message, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJOHistory(Request $req, EntityManagerInterface $em)
|
|
||||||
{
|
|
||||||
$this->denyAccessUnlessGranted('tapi_jo.get.history', null, 'No access.');
|
|
||||||
|
|
||||||
$res = $this->checkParamsAndKey($req, $em, []);
|
|
||||||
if ($res->isError())
|
|
||||||
return $res->getReturnResponse();
|
|
||||||
|
|
||||||
// get customer
|
|
||||||
// TODO: modify to find customer
|
|
||||||
$cust = $this->session->getCustomer();
|
|
||||||
if ($cust == null)
|
|
||||||
{
|
|
||||||
$res->setError(true)
|
|
||||||
->setErrorMessage('No customer information found');
|
|
||||||
return $res->getReturnResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
// get job orders
|
|
||||||
$all_jo_data = [];
|
|
||||||
// get the fulfilled and cancelled job orders, since ongoing jos are not yet part of history
|
|
||||||
$jos = $em->getRepository(JobOrder::class)->findBy([
|
|
||||||
'customer' => $cust,
|
|
||||||
'status' => [JOStatus::CANCELLED, JOStatus::FULFILLED]
|
|
||||||
], ['date_schedule' => 'DESC']);
|
|
||||||
foreach ($jos as $jo)
|
|
||||||
{
|
|
||||||
// NOTE: use generateJobOrderData method, maybe?
|
|
||||||
$status = $jo->getStatus();
|
|
||||||
|
|
||||||
$jo_data = [
|
|
||||||
'id' => $jo->getID(),
|
|
||||||
'date_create' => $jo->getDateCreate()->format('M d, Y'),
|
|
||||||
'service_type' => $jo->getServiceType(),
|
|
||||||
'status' => $status,
|
|
||||||
];
|
|
||||||
|
|
||||||
// customer vehicle and warranty
|
|
||||||
$cv = $jo->getCustomerVehicle();
|
|
||||||
|
|
||||||
// get latest warranty using plate number
|
|
||||||
$warranty = $this->findWarranty($cv->getPlateNumber(), $em);
|
|
||||||
|
|
||||||
$jo_data['customer_vehicle'] = [
|
|
||||||
'id' => $cv->getID(),
|
|
||||||
'plate_number' => $cv->getPlateNumber(),
|
|
||||||
'warranty' => $warranty,
|
|
||||||
];
|
|
||||||
|
|
||||||
// rider
|
|
||||||
$rider = $jo->getRider();
|
|
||||||
|
|
||||||
// check if jo has rider rating set to true
|
|
||||||
$has_rider_rating = $jo->hasRiderRating();
|
|
||||||
$rating = 0;
|
|
||||||
$comment = '';
|
|
||||||
if ($rider != null)
|
|
||||||
{
|
|
||||||
$jo_data['rider'] = $rider->getFullName();
|
|
||||||
|
|
||||||
// find the rider rating if any
|
|
||||||
if ($has_rider_rating)
|
|
||||||
{
|
|
||||||
$jo_rating = $jo->getRating();
|
|
||||||
if ($jo_rating != null)
|
|
||||||
{
|
|
||||||
$rating = $jo_rating->getRating();
|
|
||||||
|
|
||||||
// get comment
|
|
||||||
$comment = $jo_rating->getComment();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rider rating for jo
|
|
||||||
$jo_data['has_rider_rating'] = $has_rider_rating;
|
|
||||||
$jo_data['rider_rating'] = $rating;
|
|
||||||
$jo_data['comment'] = $comment;
|
|
||||||
|
|
||||||
// invoice items
|
|
||||||
$items = [];
|
|
||||||
$jo_items = $jo->getInvoice()->getItems();
|
|
||||||
foreach ($jo_items as $item)
|
|
||||||
{
|
|
||||||
$items[] = [
|
|
||||||
'id' => $item->getID(),
|
|
||||||
'title' => $item->getTitle(),
|
|
||||||
'qty' => $item->getQuantity(),
|
|
||||||
'price' => $item->getPrice(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$jo_data['items'] = $items;
|
|
||||||
|
|
||||||
// dates depending on status
|
|
||||||
switch ($status)
|
|
||||||
{
|
|
||||||
case JOStatus::FULFILLED:
|
|
||||||
if ($jo->getDateFulfill() == null)
|
|
||||||
$jo_data['date_fulfilled'] = '';
|
|
||||||
else
|
|
||||||
$jo_data['date_fulfilled'] = $jo->getDateFulfill()->format('M d, Y');
|
|
||||||
break;
|
|
||||||
case JOStatus::CANCELLED:
|
|
||||||
$date_cancel = $jo->getDateCancel();
|
|
||||||
if ($date_cancel == null)
|
|
||||||
$date_cancel = new DateTime();
|
|
||||||
$jo_data['date_cancelled'] = $date_cancel->format('M d, Y');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$all_jo_data[] = $jo_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return data
|
|
||||||
$data = [
|
|
||||||
'job_orders' => $all_jo_data
|
|
||||||
];
|
|
||||||
$res->setData($data);
|
|
||||||
|
|
||||||
// response
|
|
||||||
return $res->getReturnResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function locationSupport(Request $req, GeofenceTracker $geo, EntityManagerInterface $em)
|
public function locationSupport(Request $req, GeofenceTracker $geo, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('tapi_jo.location.support', null, 'No access.');
|
$this->denyAccessUnlessGranted('tapi_jo.location.support', null, 'No access.');
|
||||||
|
|
@ -733,52 +609,31 @@ class JobOrderController extends APIController
|
||||||
'longitude',
|
'longitude',
|
||||||
'latitude',
|
'latitude',
|
||||||
];
|
];
|
||||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
$msg = $this->checkRequiredParameters($req, $required_params);
|
||||||
if ($res->isError())
|
if ($msg)
|
||||||
return $res->getReturnResponse();
|
return new APIResponse(false, $msg);
|
||||||
|
|
||||||
$long = $req->query->get('longitude');
|
$long = $req->request->get('longitude');
|
||||||
$lat = $req->query->get('latitude');
|
$lat = $req->request->get('latitude');
|
||||||
|
|
||||||
// NOTE: had to add this for promo tag
|
|
||||||
// TODO: modify to find customer if we still need this
|
|
||||||
$cust = $this->session->getCustomer();
|
|
||||||
if ($cust == null)
|
|
||||||
{
|
|
||||||
$res->setError(true)
|
|
||||||
->setErrorMessage('No customer information found');
|
|
||||||
return $res->getReturnResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
$is_covered = false;
|
$is_covered = false;
|
||||||
// check if customer still has promo
|
|
||||||
if (($cust->getCustomerTag('TAG_CAR_CLUB_OFFICER_PROMO')) ||
|
|
||||||
($cust->getCustomerTag('TAG_CAR_CLUB_MEMBER_PROMO')))
|
|
||||||
{
|
|
||||||
// if has customer tag, customer has not availed of promo
|
|
||||||
$is_covered = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// geofence
|
// geofence
|
||||||
$is_covered = $geo->isCovered($long, $lat);
|
$is_covered = $geo->isCovered($long, $lat);
|
||||||
}
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'longitude' => $long,
|
'longitude' => $long,
|
||||||
'latitude' => $lat,
|
'latitude' => $lat,
|
||||||
'supported' => $is_covered,
|
'supported' => $is_covered,
|
||||||
];
|
];
|
||||||
$res->setData($data);
|
|
||||||
|
|
||||||
// check if is_covered is false. If so, we need to set the error part in the response
|
// check if is_covered is false. If so, we need to modify the message
|
||||||
|
$message = 'Location is supported.';
|
||||||
if (!$is_covered)
|
if (!$is_covered)
|
||||||
{
|
{
|
||||||
$res->setError(true)
|
$message = 'Oops! Our service is limited to some areas in Metro Manila, Laguna, and Baguio only. We will update you as soon as we are able to cover your area';
|
||||||
->setErrorMessage('Oops! Our service is limited to some areas in Metro Manila, Laguna, and Baguio only. We will update you as soon as we are able to cover your area');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res->getReturnResponse();
|
return new APIResponse(true, $message, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: should we change to the HubSelector?
|
// TODO: should we change to the HubSelector?
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue