Merge branch '540-paperless-warranty' into 'master'
Add battery image_url to warranty check and other improvements #540 Closes #540 See merge request jankstudio/resq!634
This commit is contained in:
commit
033a16f02a
2 changed files with 23 additions and 1 deletions
BIN
public/battery/generic.png
Normal file
BIN
public/battery/generic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
|
|
@ -11,6 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\Dotenv\Dotenv;
|
use Symfony\Component\Dotenv\Dotenv;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
|
||||||
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||||
|
|
||||||
|
|
@ -2758,9 +2759,11 @@ class APIController extends Controller implements LoggedController
|
||||||
if ($res->isError())
|
if ($res->isError())
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
|
|
||||||
|
/*
|
||||||
// initialize data
|
// initialize data
|
||||||
$data = [
|
$data = [
|
||||||
'is_valid' => false,
|
'is_valid' => false,
|
||||||
|
'is_registered' => false,
|
||||||
'customer' => [
|
'customer' => [
|
||||||
'first_name' => '',
|
'first_name' => '',
|
||||||
'last_name' => '',
|
'last_name' => '',
|
||||||
|
|
@ -2772,6 +2775,7 @@ class APIController extends Controller implements LoggedController
|
||||||
'size' => '',
|
'size' => '',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
*/
|
||||||
|
|
||||||
// check if warranty serial is there
|
// check if warranty serial is there
|
||||||
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
||||||
|
|
@ -2779,6 +2783,13 @@ class APIController extends Controller implements LoggedController
|
||||||
$batt = null;
|
$batt = null;
|
||||||
$is_registered = false;
|
$is_registered = false;
|
||||||
|
|
||||||
|
if ($warr_serial == null)
|
||||||
|
{
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage('Invalid warranty serial code.');
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
// if warranty serial is there
|
// if warranty serial is there
|
||||||
if ($warr_serial != null)
|
if ($warr_serial != null)
|
||||||
{
|
{
|
||||||
|
|
@ -2786,10 +2797,17 @@ class APIController extends Controller implements LoggedController
|
||||||
if ($warr != null)
|
if ($warr != null)
|
||||||
{
|
{
|
||||||
$is_registered = true;
|
$is_registered = true;
|
||||||
|
|
||||||
|
// null mobile number should be blank string instead
|
||||||
|
if ($warr->getMobileNumber() == null)
|
||||||
|
$mobile_num = '';
|
||||||
|
else
|
||||||
|
$mobile_num = $warr->getMobileNumber();
|
||||||
|
|
||||||
$customer = [
|
$customer = [
|
||||||
'first_name' => $warr->getFirstName(),
|
'first_name' => $warr->getFirstName(),
|
||||||
'last_name' => $warr->getLastName(),
|
'last_name' => $warr->getLastName(),
|
||||||
'mobile_number' => $warr->getMobileNumber(),
|
'mobile_number' => $mobile_num,
|
||||||
'plate_number' => $warr->getPlateNumber(),
|
'plate_number' => $warr->getPlateNumber(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -2805,11 +2823,14 @@ class APIController extends Controller implements LoggedController
|
||||||
|
|
||||||
$sku = $warr_serial->getSKU();
|
$sku = $warr_serial->getSKU();
|
||||||
$batt = $em->getRepository(SAPBattery::class)->find($sku);
|
$batt = $em->getRepository(SAPBattery::class)->find($sku);
|
||||||
|
// TODO: put this in a config file
|
||||||
|
$image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png';
|
||||||
if ($batt != null)
|
if ($batt != null)
|
||||||
{
|
{
|
||||||
$battery = [
|
$battery = [
|
||||||
'brand' => $batt->getBrand()->getName(),
|
'brand' => $batt->getBrand()->getName(),
|
||||||
'size' => $batt->getSize()->getName(),
|
'size' => $batt->getSize()->getName(),
|
||||||
|
'image_url' => $image_url,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -2817,6 +2838,7 @@ class APIController extends Controller implements LoggedController
|
||||||
$battery = [
|
$battery = [
|
||||||
'brand' => '',
|
'brand' => '',
|
||||||
'size' => '',
|
'size' => '',
|
||||||
|
'image_url' => '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue