Add fuel type and vehicle status condition name value collections
This commit is contained in:
parent
034386aa59
commit
d0d83531bb
4 changed files with 52 additions and 26 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
14
src/Ramcar/FuelType.php
Normal file
14
src/Ramcar/FuelType.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class FuelType extends NameValue
|
||||
{
|
||||
const GAS = 'gas';
|
||||
const DIESEL = 'diesel';
|
||||
|
||||
const COLLECTION = [
|
||||
'gas' => 'Gas',
|
||||
'diesel' => 'Diesel',
|
||||
];
|
||||
}
|
||||
14
src/Ramcar/VehicleStatusCondition.php
Normal file
14
src/Ramcar/VehicleStatusCondition.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
class VehicleStatusCondition extends NameValue
|
||||
{
|
||||
const BRAND_NEW = 'new';
|
||||
const SECOND_HAND = 'second-hand';
|
||||
|
||||
const COLLECTION = [
|
||||
'new' => 'Brand New',
|
||||
'second-hand' => 'Second-Hand',
|
||||
];
|
||||
}
|
||||
|
|
@ -217,8 +217,9 @@
|
|||
<label for="vehicle-status" data-field="status_condition">Status</label>
|
||||
<select name="status_condition" class="form-control m-input" id="vehicle-status" data-required="1">
|
||||
<option value=""></option>
|
||||
<option value="new">Brand New</option>
|
||||
<option value="second-hand">Second-Hand</option>
|
||||
{% for key, status_condition in status_conditions %}
|
||||
<option value="{{ key }}">{{ status_condition }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<div class="form-control-feedback hide" data-field="status_condition"></div>
|
||||
</div>
|
||||
|
|
@ -226,8 +227,9 @@
|
|||
<label for="vehicle-fuel-type" data-field="fuel_type">Fuel Type</label>
|
||||
<select name="fuel_type" class="form-control m-input" id="vehicle-fuel-type" data-required="1">
|
||||
<option value=""></option>
|
||||
<option value="gas">Gas</option>
|
||||
<option value="diesel">Diesel</option>
|
||||
{% for key, fuel_type in fuel_types %}
|
||||
<option value="{{ key }}">{{ fuel_type }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<div class="form-control-feedback hide" data-field="fuel_type"></div>
|
||||
</div>
|
||||
|
|
@ -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 + '<div class="form-control-feedback hide" data-field="status_condition"></div>';
|
||||
return status_conditions[row.status_condition] + '<div class="form-control-feedback hide" data-field="status_condition"></div>';
|
||||
}
|
||||
},
|
||||
{
|
||||
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 + '<div class="form-control-feedback hide" data-field="fuel_type"></div>';
|
||||
return fuel_types[row.fuel_type] + '<div class="form-control-feedback hide" data-field="fuel_type"></div>';
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue