Add clean serial functionality for QR prefix in CAPI customer warranty #643
This commit is contained in:
parent
aa529e7411
commit
b1150d6c93
1 changed files with 19 additions and 5 deletions
|
|
@ -89,18 +89,29 @@ class CustomerWarrantyController extends APIController
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function cleanSerial($serial)
|
|
||||||
{
|
|
||||||
return trim(strtoupper($serial));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function cleanPlateNumber($plate_num)
|
protected function cleanPlateNumber($plate_num)
|
||||||
{
|
{
|
||||||
return preg_replace('/\s+/', '', strtoupper($plate_num));
|
return preg_replace('/\s+/', '', strtoupper($plate_num));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 check($serial, EntityManagerInterface $em, Request $req, WarrantyAPILogger $logger)
|
public function check($serial, EntityManagerInterface $em, Request $req, WarrantyAPILogger $logger)
|
||||||
{
|
{
|
||||||
|
$serial = $this->cleanSerial($serial);
|
||||||
|
|
||||||
$user_id = $_SERVER['HTTP_X_CATA_API_KEY'];
|
$user_id = $_SERVER['HTTP_X_CATA_API_KEY'];
|
||||||
$log_data = [
|
$log_data = [
|
||||||
'serial' => $serial,
|
'serial' => $serial,
|
||||||
|
|
@ -303,6 +314,7 @@ class CustomerWarrantyController extends APIController
|
||||||
public function register($serial, EntityManagerInterface $em, Request $req, KernelInterface $kernel, RisingTideGateway $rt, TranslatorInterface $trans,
|
public function register($serial, EntityManagerInterface $em, Request $req, KernelInterface $kernel, RisingTideGateway $rt, TranslatorInterface $trans,
|
||||||
WarrantyAPILogger $logger)
|
WarrantyAPILogger $logger)
|
||||||
{
|
{
|
||||||
|
$serial = $this->cleanSerial($serial);
|
||||||
error_log('HERE - register');
|
error_log('HERE - register');
|
||||||
|
|
||||||
// set up information for logging
|
// set up information for logging
|
||||||
|
|
@ -366,6 +378,8 @@ class CustomerWarrantyController extends APIController
|
||||||
// TODO: move this to a service, since it's shared by all warranty updaters
|
// TODO: move this to a service, since it's shared by all warranty updaters
|
||||||
protected function handlePictureUpload($file, $target_dir, $serial, $name)
|
protected function handlePictureUpload($file, $target_dir, $serial, $name)
|
||||||
{
|
{
|
||||||
|
$serial = $this->cleanSerial($serial);
|
||||||
|
|
||||||
error_log("handling $name upload");
|
error_log("handling $name upload");
|
||||||
// no file sent
|
// no file sent
|
||||||
if ($file == null)
|
if ($file == null)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue