Add API call to list ongoing job orders
This commit is contained in:
parent
b210401150
commit
c9af452629
2 changed files with 52 additions and 0 deletions
|
|
@ -74,3 +74,8 @@ api_estimate:
|
|||
path: /api/estimate
|
||||
controller: App\Controller\APIController::getEstimate
|
||||
methods: [POST]
|
||||
|
||||
api_ongoing:
|
||||
path: /api/job_order/ongoing
|
||||
controller: App\Controller\APIController::getOngoing
|
||||
methods: [GET]
|
||||
|
|
|
|||
|
|
@ -11,12 +11,14 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
use App\Ramcar\APIResult;
|
||||
use App\Ramcar\JOStatus;
|
||||
|
||||
use App\Entity\MobileSession;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\VehicleManufacturer;
|
||||
use App\Entity\Vehicle;
|
||||
use App\Entity\CustomerVehicle;
|
||||
use App\Entity\JobOrder;
|
||||
|
||||
use DateTime;
|
||||
|
||||
|
|
@ -682,4 +684,49 @@ class APIController extends Controller
|
|||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function getOngoing(Request $req)
|
||||
{
|
||||
$required_params = [];
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
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();
|
||||
}
|
||||
|
||||
// check if we have an ongoing job order
|
||||
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
||||
'customer' => $cust,
|
||||
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
||||
]);
|
||||
|
||||
// initialize data
|
||||
$data = [];
|
||||
|
||||
// no ongoing
|
||||
if (count($ongoing_jos) <= 0)
|
||||
{
|
||||
$data = [
|
||||
'has_ongoing' => false,
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = [
|
||||
'has_ongoing' => true,
|
||||
];
|
||||
}
|
||||
|
||||
$res->setData($data);
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue