Merge branch '104-fix-items-for-ios-user-app' into 'master'
Resolve "Fix items for iOS user app" Closes #104 See merge request jankstudio/resq!83
This commit is contained in:
commit
23dbe7552c
3 changed files with 1152 additions and 2 deletions
|
|
@ -94,3 +94,13 @@ api_jo_cancel:
|
||||||
path: /api/job_order/cancel
|
path: /api/job_order/cancel
|
||||||
controller: App\Controller\APIController:cancelJobOrder
|
controller: App\Controller\APIController:cancelJobOrder
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
|
api_jo_history:
|
||||||
|
path: /api/job_order/history
|
||||||
|
controller: App\Controller\APIController:getJOHistory
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
api_device_id:
|
||||||
|
path: /api/device_id
|
||||||
|
controller: App\Controller\APIController:updateDeviceID
|
||||||
|
methods: [POST]
|
||||||
|
|
|
||||||
1016
sql/resq.backup.20180419.1710.sql
Normal file
1016
sql/resq.backup.20180419.1710.sql
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -19,6 +19,7 @@ use App\Ramcar\ServiceType;
|
||||||
use App\Ramcar\WarrantyClass;
|
use App\Ramcar\WarrantyClass;
|
||||||
use App\Ramcar\APIRiderStatus;
|
use App\Ramcar\APIRiderStatus;
|
||||||
use App\Ramcar\TransactionOrigin;
|
use App\Ramcar\TransactionOrigin;
|
||||||
|
use App\Ramcar\TradeInType;
|
||||||
|
|
||||||
use App\Service\InvoiceCreator;
|
use App\Service\InvoiceCreator;
|
||||||
|
|
||||||
|
|
@ -781,10 +782,26 @@ class APIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// put battery in criteria
|
// put battery in criteria
|
||||||
$icrit->addBattery($batt);
|
$icrit->addBattery($batt);
|
||||||
|
*/
|
||||||
|
|
||||||
// TODO: check trade-in
|
// check trade-in
|
||||||
|
// only allow motolite, other, none
|
||||||
|
$trade_in = $req->request->get('trade_in');
|
||||||
|
switch ($trade_in)
|
||||||
|
{
|
||||||
|
case TradeInType::MOTOLITE:
|
||||||
|
case TradeInType::OTHER:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$trade_in = '';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$icrit->addEntry($batt, $trade_in, 1);
|
||||||
|
|
||||||
// send to invoice generator
|
// send to invoice generator
|
||||||
$invoice = $ic->processCriteria($icrit);
|
$invoice = $ic->processCriteria($icrit);
|
||||||
|
|
@ -831,6 +848,7 @@ class APIController extends Controller
|
||||||
{
|
{
|
||||||
// check required parameters and api key
|
// check required parameters and api key
|
||||||
$required_params = [
|
$required_params = [
|
||||||
|
'service_type',
|
||||||
'cv_id',
|
'cv_id',
|
||||||
'batt_id',
|
'batt_id',
|
||||||
'trade_in',
|
'trade_in',
|
||||||
|
|
@ -851,6 +869,7 @@ class APIController extends Controller
|
||||||
|
|
||||||
// make invoice criteria
|
// make invoice criteria
|
||||||
$icrit = new InvoiceCriteria();
|
$icrit = new InvoiceCriteria();
|
||||||
|
$icrit->setServiceType($req->request->get('service_type'));
|
||||||
|
|
||||||
// check promo
|
// check promo
|
||||||
$promo_id = $req->request->get('promo_id');
|
$promo_id = $req->request->get('promo_id');
|
||||||
|
|
@ -894,10 +913,26 @@ class APIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// put battery in criteria
|
// put battery in criteria
|
||||||
$icrit->addBattery($batt);
|
$icrit->addBattery($batt);
|
||||||
|
*/
|
||||||
|
|
||||||
// TODO: check trade-in
|
// check trade-in
|
||||||
|
// only allow motolite, other, none
|
||||||
|
$trade_in = $req->request->get('trade_in');
|
||||||
|
switch ($trade_in)
|
||||||
|
{
|
||||||
|
case TradeInType::MOTOLITE:
|
||||||
|
case TradeInType::OTHER:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$trade_in = '';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$icrit->addEntry($batt, $trade_in, 1);
|
||||||
|
|
||||||
// send to invoice generator
|
// send to invoice generator
|
||||||
$invoice = $ic->processCriteria($icrit);
|
$invoice = $ic->processCriteria($icrit);
|
||||||
|
|
@ -1187,4 +1222,93 @@ class APIController extends Controller
|
||||||
|
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getJOHistory(Request $req)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$res = $this->checkParamsAndKey($req, $em, []);
|
||||||
|
if ($res->isError())
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
|
||||||
|
// get 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 = [];
|
||||||
|
$jos = $cust->getJobOrders();
|
||||||
|
foreach ($jos as $jo)
|
||||||
|
{
|
||||||
|
$status = $jo->getStatus();
|
||||||
|
|
||||||
|
$jo_data = [
|
||||||
|
'id' => $jo->getID(),
|
||||||
|
'date_create' => $jo->getDateCreate()->format('M d, Y'),
|
||||||
|
'service_type' => $jo->getServiceType(),
|
||||||
|
'status' => $status,
|
||||||
|
];
|
||||||
|
|
||||||
|
// 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:
|
||||||
|
$jo_data['date_fulfilled'] = $jo->getDateFulfilled()->format('M d, Y');
|
||||||
|
break;
|
||||||
|
case JOStatus::CANCELLED:
|
||||||
|
$jo_data['date_cancelled'] = $jo->getDateCancelled()->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 updateDeviceID(Request $req)
|
||||||
|
{
|
||||||
|
$required_params = [
|
||||||
|
'device_id',
|
||||||
|
];
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||||
|
if ($res->isError())
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
|
||||||
|
$device_id = $req->request->get('device_id');
|
||||||
|
$this->session->setDevicePushID($device_id);
|
||||||
|
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
// response
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue