Add logging when warranty is created via admin panel. #555
This commit is contained in:
parent
d2cae08fb0
commit
c1d54ec626
1 changed files with 26 additions and 1 deletions
|
|
@ -12,8 +12,10 @@ use App\Entity\CustomerVehicle;
|
||||||
|
|
||||||
use App\Ramcar\WarrantyClass;
|
use App\Ramcar\WarrantyClass;
|
||||||
use App\Ramcar\WarrantyStatus;
|
use App\Ramcar\WarrantyStatus;
|
||||||
|
use App\Ramcar\WarrantySource;
|
||||||
|
|
||||||
use App\Service\WarrantyHandler;
|
use App\Service\WarrantyHandler;
|
||||||
|
use App\Service\WarrantyAPILogger;
|
||||||
|
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
@ -149,7 +151,7 @@ class WarrantyController extends Controller
|
||||||
return $this->render('warranty/form.html.twig', $params);
|
return $this->render('warranty/form.html.twig', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addSubmit(Request $req, ValidatorInterface $validator)
|
public function addSubmit(Request $req, ValidatorInterface $validator, WarrantyAPILogger $logger)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('warranty.add', null, 'No access.');
|
$this->denyAccessUnlessGranted('warranty.add', null, 'No access.');
|
||||||
|
|
||||||
|
|
@ -255,6 +257,28 @@ class WarrantyController extends Controller
|
||||||
$em->persist($obj);
|
$em->persist($obj);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
|
// log warranty creation
|
||||||
|
$action = 'create';
|
||||||
|
$user_id = $this->getUser()->getUsername();
|
||||||
|
$source = WarrantySource::ADMIN_PANEL;
|
||||||
|
$log_data = [
|
||||||
|
'serial' => $req->request->get('serial'),
|
||||||
|
'warranty_class' => $req->request->get('warranty_class'),
|
||||||
|
'first_name' => $req->request->get('first_name'),
|
||||||
|
'last_name' => $req->request->get('last_name'),
|
||||||
|
'mobile_number' => $req->request->get('mobile_number'),
|
||||||
|
'date_purchase' => $req->request->get('date_purchase'),
|
||||||
|
'claim_from' => $req->request->get('claim_from'),
|
||||||
|
'status' => $req->request->get('status'),
|
||||||
|
'date_claim' => $req->request->get('date_claim'),
|
||||||
|
'date_expire' => $req->request->get('date_expire'),
|
||||||
|
'battery_model' => $req->request->get('battery_model'),
|
||||||
|
'battery_size' => $req->request->get('battery_size'),
|
||||||
|
'sap_battery' => $req->request->get('sap_battery'),
|
||||||
|
'plate_number' => $req->request->get('plate_number'),
|
||||||
|
];
|
||||||
|
$logger->logWarrantyInfo($log_data, '', $user_id, $action, $source);
|
||||||
|
|
||||||
// return successful response
|
// return successful response
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'success' => 'Changes have been saved!'
|
'success' => 'Changes have been saved!'
|
||||||
|
|
@ -677,4 +701,5 @@ class WarrantyController extends Controller
|
||||||
// remove spaces and make upper case
|
// remove spaces and make upper case
|
||||||
return strtoupper(str_replace(' ', '', $plate));
|
return strtoupper(str_replace(' ', '', $plate));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue