Merge branch '162-phase-2-changes' into 'master'

Resolve "Phase 2 changes"

Closes #162

See merge request jankstudio/resq!169
This commit is contained in:
Kendrick Chan 2018-08-10 14:17:25 +00:00
commit fcaa8c3537
3 changed files with 65 additions and 2 deletions

View file

@ -1055,7 +1055,7 @@ class APIController extends Controller
$item_batt = $item->getBattery(); $item_batt = $item->getBattery();
if ($item_batt != null) if ($item_batt != null)
{ {
$my_data['image_url'] = $this->getBatteryImageURL($req, $batt); $my_data['image_url'] = $this->getBatteryImageURL($req, $item_batt);
} }
$items_data[] = $my_data; $items_data[] = $my_data;
@ -1098,6 +1098,10 @@ class APIController extends Controller
// return $res->getReturnResponse(); // return $res->getReturnResponse();
if (count($ongoing_jos) <= 0) if (count($ongoing_jos) <= 0)
{ {
// TODO: check if the latest jo they have needs rider rating
// $query = $em->createQuery('select
// no pending
$res->setData([ $res->setData([
'status' => APIRiderStatus::NO_PENDING_JO 'status' => APIRiderStatus::NO_PENDING_JO
]); ]);
@ -1143,6 +1147,7 @@ class APIController extends Controller
$data['status'] = APIRiderStatus::RIDER_PICK_UP; $data['status'] = APIRiderStatus::RIDER_PICK_UP;
// TODO: fix this to actual location of rider // TODO: fix this to actual location of rider
// default rider location to hub
$data['rider'] = [ $data['rider'] = [
'id' => $rider->getID(), 'id' => $rider->getID(),
'name' => $rider->getFullName(), 'name' => $rider->getFullName(),
@ -1322,8 +1327,42 @@ class APIController extends Controller
return $res->getReturnResponse(); return $res->getReturnResponse();
} }
$inv = $jo->getInvoice(); $invoice = $jo->getInvoice();
// make invoice json data
$data = [
'total_price' => $invoice->getTotalPrice(),
'vat_ex_price' => $invoice->getVATExclusivePrice(),
'vat' => $invoice->getVAT(),
'discount' => $invoice->getDiscount(),
'trade_in' => $invoice->getTradeIn(),
];
$items = $invoice->getItems();
$items_data = [];
foreach ($items as $item)
{
$my_data = [
'title' => $item->getTitle(),
'qty' => $item->getQuantity() + 0,
'price' => $item->getPrice() + 0.0,
];
$item_batt = $item->getBattery();
if ($item_batt != null)
{
$my_data['image_url'] = $this->getBatteryImageURL($req, $item_batt);
}
$items_data[] = $my_data;
}
$data['items'] = $items_data;
// set data
$res->setData($data);
/*
// invoice items // invoice items
$inv_items = []; $inv_items = [];
foreach ($inv->getItems() as $item) foreach ($inv->getItems() as $item)
@ -1355,6 +1394,7 @@ class APIController extends Controller
$res->setData($data); $res->setData($data);
*/
return $res->getReturnResponse(); return $res->getReturnResponse();
} }

View file

@ -237,6 +237,12 @@ class JobOrder
*/ */
protected $trade_in_type; protected $trade_in_type;
// if the user has left a rating for the rider
/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $flag_rider_rating;
public function __construct() public function __construct()
{ {
$this->date_create = new DateTime(); $this->date_create = new DateTime();
@ -252,6 +258,7 @@ class JobOrder
$this->events = new ArrayCollection(); $this->events = new ArrayCollection();
$this->trade_in_type = null; $this->trade_in_type = null;
$this->flag_rider_rating = false;
} }
public function getID() public function getID()
@ -686,4 +693,18 @@ class JobOrder
$this->makeRiderAvailable(); $this->makeRiderAvailable();
} }
public function setHasRiderRating($flag = true)
{
$this->flag_rider_rating = $flag;
return $this;
}
public function HasRiderRating()
{
if ($this->flag_rider_rating == null)
return false;
return $this->flag_rider_rating;
}
} }

View file

@ -10,6 +10,7 @@ class APIRiderStatus extends NameValue
const RIDER_PICK_UP = 'rider_pick_up'; const RIDER_PICK_UP = 'rider_pick_up';
const RIDER_OTW = 'rider_otw'; const RIDER_OTW = 'rider_otw';
const RIDER_UNAVAIL = 'rider_unavail'; const RIDER_UNAVAIL = 'rider_unavail';
const RIDER_RATING = 'rider_rating';
const COLLECTION = [ const COLLECTION = [
'no_pending_jo' => 'No pending job order', 'no_pending_jo' => 'No pending job order',
@ -18,5 +19,6 @@ class APIRiderStatus extends NameValue
'rider_pick_up' => 'Rider is picking up item from outlet', 'rider_pick_up' => 'Rider is picking up item from outlet',
'rider_otw' => 'Rider is on the way to customer', 'rider_otw' => 'Rider is on the way to customer',
'rider_unavail' => 'No available rider for delivery', 'rider_unavail' => 'No available rider for delivery',
'rider_rating' => 'Rider waiting for rating from customer',
]; ];
} }