Display latest JO without rider rating in rider status api call #162
This commit is contained in:
parent
ff8e4090ae
commit
f47e280b37
1 changed files with 65 additions and 5 deletions
|
|
@ -1089,10 +1089,13 @@ class APIController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we have an ongoing job order
|
// check if we have an ongoing job order
|
||||||
|
/*
|
||||||
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
||||||
'customer' => $cust,
|
'customer' => $cust,
|
||||||
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::IN_TRANSIT, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::IN_TRANSIT, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
||||||
]);
|
]);
|
||||||
|
*/
|
||||||
|
$ongoing_jos = $this->getOngoingJobOrders($cust);
|
||||||
|
|
||||||
// $res->setData(['here' => count($ongoing_jos)]);
|
// $res->setData(['here' => count($ongoing_jos)]);
|
||||||
// return $res->getReturnResponse();
|
// return $res->getReturnResponse();
|
||||||
|
|
@ -1101,12 +1104,55 @@ class APIController extends Controller
|
||||||
error_log('No pending jo');
|
error_log('No pending jo');
|
||||||
|
|
||||||
// check if the latest fulfilled jo they have needs rider rating
|
// check if the latest fulfilled jo they have needs rider rating
|
||||||
$query = $em->createQuery('select jo from JobOrder where jo.customer = :cust and jo.status = ' . JOStatus::FULFILLED . ' order by jo.date_fulfill desc');
|
$query = $em->createQuery('select jo from App\Entity\JobOrder jo where jo.customer = :cust and jo.status = :status order by jo.date_fulfill desc');
|
||||||
$fulfill_jos = $query->setParameters([
|
$fulfill_jo = $query->setParameters([
|
||||||
'cust' => $cust
|
'cust' => $cust,
|
||||||
|
'status' => JOStatus::FULFILLED,
|
||||||
])
|
])
|
||||||
->setMaxResults(1)
|
->setMaxResults(1)
|
||||||
->getResult();
|
->getSingleResult();
|
||||||
|
|
||||||
|
// we got a recently fulfilled job order
|
||||||
|
if ($fulfill_jo)
|
||||||
|
{
|
||||||
|
// check if the rider has been rated
|
||||||
|
if (!$fulfill_jo->hasRiderRating())
|
||||||
|
{
|
||||||
|
$dest = $fulfill_jo->getCoordinates();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'jo_id' => $fulfill_jo->getID(),
|
||||||
|
'service_type' => $fulfill_jo->getServiceType(),
|
||||||
|
'destination' => [
|
||||||
|
'long' => $dest->getLongitude(),
|
||||||
|
'lat' => $dest->getLatitude(),
|
||||||
|
],
|
||||||
|
'delivery_address' => $fulfill_jo->getDeliveryAddress(),
|
||||||
|
'delivery_instructions' => $fulfill_jo->getDeliveryInstructions(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$rider = $fulfill_jo->getRider();
|
||||||
|
|
||||||
|
// default image url
|
||||||
|
$url_prefix = $req->getSchemeAndHttpHost();
|
||||||
|
$image_url = $url_prefix . '/assets/images/user.gif';
|
||||||
|
if ($rider->getImageFile() != null)
|
||||||
|
$image_url = $url_prefix . '/uploads/' . $rider->getImageFile();
|
||||||
|
|
||||||
|
$data['status'] = APIRiderStatus::RIDER_RATING;
|
||||||
|
// default rider location to hub
|
||||||
|
$data['rider'] = [
|
||||||
|
'id' => $rider->getID(),
|
||||||
|
'name' => $rider->getFullName(),
|
||||||
|
'plate_num' => $rider->getPlateNumber(),
|
||||||
|
'contact_num' => $rider->getContactNumber(),
|
||||||
|
'image_url' => $image_url,
|
||||||
|
];
|
||||||
|
$res->setData($data);
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// no pending
|
// no pending
|
||||||
$res->setData([
|
$res->setData([
|
||||||
|
|
@ -1178,6 +1224,17 @@ class APIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getOngoingJobOrders($cust)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
||||||
|
'customer' => $cust,
|
||||||
|
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::IN_TRANSIT, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $ongoing_jos;
|
||||||
|
}
|
||||||
|
|
||||||
public function getOngoing(Request $req)
|
public function getOngoing(Request $req)
|
||||||
{
|
{
|
||||||
$required_params = [];
|
$required_params = [];
|
||||||
|
|
@ -1195,11 +1252,14 @@ class APIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// check if we have an ongoing job order
|
// check if we have an ongoing job order
|
||||||
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
||||||
'customer' => $cust,
|
'customer' => $cust,
|
||||||
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::IN_TRANSIT, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
||||||
]);
|
]);
|
||||||
|
*/
|
||||||
|
$ongoing_jos = $this->getOngoingJobOrders($cust);
|
||||||
|
|
||||||
// initialize data
|
// initialize data
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue