Add upload photo event type. #424

This commit is contained in:
Korina Cordero 2020-07-23 04:40:48 +00:00
parent eadcd4604a
commit ff83dec5ce
2 changed files with 49 additions and 15 deletions

View file

@ -4,21 +4,22 @@ namespace App\Ramcar;
class CMBJOEventType extends NameValue class CMBJOEventType extends NameValue
{ {
const CREATE = 'create'; const CREATE = 'create';
const HUB_ASSIGN = 'hub_assign'; const HUB_ASSIGN = 'hub_assign';
const RIDER_ASSIGN = 'rider_assign'; const RIDER_ASSIGN = 'rider_assign';
const CANCEL = 'cancel'; const CANCEL = 'cancel';
const FULFILL = 'fulfill'; const FULFILL = 'fulfill';
const OPEN_EDIT = 'open_edit'; const OPEN_EDIT = 'open_edit';
const REQUEUE = 'requeue'; const REQUEUE = 'requeue';
const RIDER_ACCEPT = 'accept'; const RIDER_ACCEPT = 'accept';
const RIDER_IN_TRANSIT = 'rider_in_transit'; const RIDER_IN_TRANSIT = 'rider_in_transit';
const RIDER_ARRIVE = 'arrive'; const RIDER_ARRIVE = 'arrive';
const RIDER_START = 'rider_start'; const RIDER_START = 'rider_start';
const RIDER_EDIT = 'rider_edit'; const RIDER_EDIT = 'rider_edit';
const PAID = 'paid'; const PAID = 'paid';
const PERFORM = 'perform'; const PERFORM = 'perform';
const RIDER_FINISH = 'finish'; const RIDER_FINISH = 'finish';
const RIDER_UPLOAD_PHOTO = 'rider_upload_photo';
const COLLECTION = [ const COLLECTION = [
'create' => 'Created', 'create' => 'Created',
@ -36,5 +37,6 @@ class CMBJOEventType extends NameValue
'paid' => 'Paid', 'paid' => 'Paid',
'perform' => 'Perform', 'perform' => 'Perform',
'finish' => 'Finish', 'finish' => 'Finish',
'rider_upload_photo' => 'Rider Upload Photo',
]; ];
} }

View file

@ -522,6 +522,17 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$jo_event = current($complete_results); $jo_event = current($complete_results);
$date_complete = $jo_event->getDateHappen()->format('Ymd H:i:s'); $date_complete = $jo_event->getDateHappen()->format('Ymd H:i:s');
} }
else
{
// find the time when photos were uploaded
$upload_event_type = CMBJOEventType::RIDER_UPLOAD_PHOTO;
$upload_results = $this->em->getRepository(JOEvent::class)->findby(['type_id' => $upload_event_type, 'rider' => $rider_id, 'job_order' => $jo_id], ['date_happen' => 'DESC']);
if ($upload_results != null)
{
$jo_event = current($upload_results);
$date_complete = $jo_event->getDateHappen()->format('Ymd H:i:s');
}
}
$jo_data[] = [ $jo_data[] = [
'job_order' => [ 'job_order' => [
@ -856,6 +867,17 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$jo_event = current($complete_results); $jo_event = current($complete_results);
$date_complete = $jo_event->getDateHappen()->format('Ymd H:i:s'); $date_complete = $jo_event->getDateHappen()->format('Ymd H:i:s');
} }
else
{
// find the time when photos were uploaded
$upload_event_type = CMBJOEventType::RIDER_UPLOAD_PHOTO;
$upload_results = $this->em->getRepository(JOEvent::class)->findby(['type_id' => $upload_event_type, 'rider' => $rider_id, 'job_order' => $jo_id], ['date_happen' => 'DESC']);
if ($upload_results != null)
{
$jo_event = current($upload_results);
$date_complete = $jo_event->getDateHappen()->format('Ymd H:i:s');
}
}
$data = [ $data = [
'id' => $jo->getID(), 'id' => $jo->getID(),
@ -1805,6 +1827,8 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
return $data; return $data;
} }
$rider = $this->session->getRider();
// get longitude and latitude // get longitude and latitude
// TODO: right now, we're just checking if we get the coordinates // TODO: right now, we're just checking if we get the coordinates
$this->getHeaderCoordinates($req); $this->getHeaderCoordinates($req);
@ -1973,6 +1997,14 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
} }
} }
// create event for upload photo
$rider_event = new JOEvent();
$rider_event->setDateHappen(new DateTime())
->setTypeID(CMBJOEventType::RIDER_UPLOAD_PHOTO)
->setJobOrder($jo)
->setRider($rider);
$this->em->persist($rider_event);
$this->em->flush(); $this->em->flush();
} }