Add QR prefix removal to app api for warranty #644 #1567
2 changed files with 19 additions and 1 deletions
|
|
@ -3347,6 +3347,21 @@ class APIController extends Controller implements LoggedController
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO: put this in a service
|
||||
protected function cleanSerial($serial)
|
||||
{
|
||||
// trim and make everything upper case
|
||||
$clean_serial = trim(strtoupper($serial));
|
||||
|
||||
|
||||
// remove QR prefix if it exists
|
||||
$prefix = substr($clean_serial, 0, 2);
|
||||
if ($prefix == 'QR')
|
||||
$clean_serial = substr($clean_serial, 2);
|
||||
|
||||
return $clean_serial;
|
||||
}
|
||||
|
||||
public function warrantyCheck($serial, EntityManagerInterface $em, Request $req)
|
||||
{
|
||||
// check required parameters and api key
|
||||
|
|
@ -3356,6 +3371,7 @@ class APIController extends Controller implements LoggedController
|
|||
return $res->getReturnResponse();
|
||||
|
||||
// check if warranty serial is there
|
||||
$serial = $this->cleanSerial($serial);
|
||||
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
||||
$warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]);
|
||||
$batt = null;
|
||||
|
|
@ -3577,7 +3593,8 @@ class APIController extends Controller implements LoggedController
|
|||
$warr_card = $req->files->get('warr_card');
|
||||
|
||||
// normalize serial
|
||||
$serial = trim(strtoupper($serial));
|
||||
$serial = $this->cleanSerial($serial);
|
||||
// $serial = trim(strtoupper($serial));
|
||||
|
||||
// process picture uploads
|
||||
$upload_dir = $kernel->getProjectDir() . '/public/warranty_uploads';
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ class CustomerWarrantyController extends APIController
|
|||
return preg_replace('/\s+/', '', strtoupper($plate_num));
|
||||
}
|
||||
|
||||
// TODO: put this in a service
|
||||
protected function cleanSerial($serial)
|
||||
{
|
||||
// trim and make everything upper case
|
||||
|
|
|
|||
Loading…
Reference in a new issue