diff --git a/config/routes/customer.yaml b/config/routes/customer.yaml index 7cc30fe8..90ac5591 100644 --- a/config/routes/customer.yaml +++ b/config/routes/customer.yaml @@ -44,3 +44,8 @@ customer_delete: path: /customers/{id} controller: App\Controller\CustomerController::destroy methods: [DELETE] + +customer_vehicle_warranty_edit_ajax: + path: /ajax/customer_vehicle/{id} + controller: App\Controller\CustomerController::editCustomerVehicleWarranty + methods: [POST] diff --git a/src/Controller/CustomerController.php b/src/Controller/CustomerController.php index 17f8e7bc..e15e050d 100644 --- a/src/Controller/CustomerController.php +++ b/src/Controller/CustomerController.php @@ -6,6 +6,7 @@ use App\Ramcar\CrudException; use App\Service\CustomerHandlerInterface; use App\Entity\Customer; +use App\Entity\CustomerVehicle; use Doctrine\ORM\EntityManagerInterface; @@ -226,4 +227,21 @@ class CustomerController extends Controller ]); } } + + public function editCustomerVehicleWarranty($id, Request $req, EntityManagerInterface $em) + { + $cv = $em->getRepository(CustomerVehicle::class)->find($id); + + $serial = $req->request->get('warr_serial'); + $cv->setWarrantyCode($serial); + + $em->flush(); + + return $this->json([ + 'success' => true, + 'data' => [ + 'warranty_code' => $serial, + ], + ]); + } } diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index e23a623e..ab090c61 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -219,6 +219,12 @@
+ {% if obj.getCustomerVehicle %} +
+
+ Edit +
+ {% endif %}
@@ -913,6 +919,33 @@ + + {% if mode in ['update-processing', 'update-reassign-hub'] %}