diff --git a/src/Controller/CustomerController.php b/src/Controller/CustomerController.php index 8e510bc1..e93f867f 100644 --- a/src/Controller/CustomerController.php +++ b/src/Controller/CustomerController.php @@ -3,6 +3,8 @@ namespace App\Controller; use App\Ramcar\BaseController; +use App\Ramcar\FuelType; +use App\Ramcar\VehicleStatusCondition; use App\Entity\Customer; use App\Entity\CustomerVehicle; use App\Entity\MobileNumber; @@ -141,6 +143,8 @@ class CustomerController extends BaseController // get parent associations $params['bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll(); $params['vmfgs'] = $em->getRepository(VehicleManufacturer::class)->findAll(); + $params['fuel_types'] = FuelType::getCollection(); + $params['status_conditions'] = VehicleStatusCondition::getCollection(); $params['years'] = $this->generateYearOptions(); @@ -313,6 +317,8 @@ class CustomerController extends BaseController // get parent associations $params['bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll(); $params['vmfgs'] = $em->getRepository(VehicleManufacturer::class)->findAll(); + $params['fuel_types'] = FuelType::getCollection(); + $params['status_conditions'] = VehicleStatusCondition::getCollection(); $params['years'] = $this->generateYearOptions(); diff --git a/src/Ramcar/FuelType.php b/src/Ramcar/FuelType.php new file mode 100644 index 00000000..c85a4d81 --- /dev/null +++ b/src/Ramcar/FuelType.php @@ -0,0 +1,14 @@ + 'Gas', + 'diesel' => 'Diesel', + ]; +} diff --git a/src/Ramcar/VehicleStatusCondition.php b/src/Ramcar/VehicleStatusCondition.php new file mode 100644 index 00000000..041f1d1b --- /dev/null +++ b/src/Ramcar/VehicleStatusCondition.php @@ -0,0 +1,14 @@ + 'Brand New', + 'second-hand' => 'Second-Hand', + ]; +} diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index f38e0818..62ebc0a7 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -217,8 +217,9 @@
@@ -226,8 +227,9 @@ @@ -992,36 +994,26 @@ field: 'status_condition', title: 'Cond.', template: function (row, index, datatable) { - var label; + var status_conditions = { + {% for key, status_condition in status_conditions %} + "{{ key }}": "{{ status_condition }}", + {% endfor %} + }; - switch (row.status_condition) { - case 'new': - return 'Brand New'; - break; - case 'second-hand': - return 'Second-Hand'; - break; - } - - return label + ''; + return status_conditions[row.status_condition] + ''; } }, { field: 'fuel_type', title: 'Fuel Type', template: function (row, index, datatable) { - var label; + var fuel_types = { + {% for key, fuel_type in fuel_types %} + "{{ key }}": "{{ fuel_type }}", + {% endfor %} + }; - switch (row.fuel_type) { - case 'gas': - return 'Gas'; - break; - case 'diesel': - return 'Diesel'; - break; - } - - return label + ''; + return fuel_types[row.fuel_type] + ''; } }, {