Add filtering for inactive batteries. #733
This commit is contained in:
parent
72fc6ee9b0
commit
6e9e56b1be
6 changed files with 66 additions and 41 deletions
|
|
@ -47,6 +47,10 @@ class GenerateBatteryCompatibilityCommand extends Command
|
||||||
$comp_batt = [];
|
$comp_batt = [];
|
||||||
foreach ($batteries as $battery)
|
foreach ($batteries as $battery)
|
||||||
{
|
{
|
||||||
|
// check if battery is active
|
||||||
|
if (!($battery->isActive()))
|
||||||
|
continue;
|
||||||
|
|
||||||
// set to the first compatible battery found until a more expensive one is found
|
// set to the first compatible battery found until a more expensive one is found
|
||||||
$comp_batt['id'] = $battery->getID();
|
$comp_batt['id'] = $battery->getID();
|
||||||
$comp_batt['name'] = $battery->getModel()->getName() . ' ' .
|
$comp_batt['name'] = $battery->getModel()->getName() . ' ' .
|
||||||
|
|
|
||||||
|
|
@ -826,20 +826,24 @@ class APIController extends Controller implements LoggedController
|
||||||
$batts = $vehicle->getBatteries();
|
$batts = $vehicle->getBatteries();
|
||||||
foreach ($batts as $batt)
|
foreach ($batts as $batt)
|
||||||
{
|
{
|
||||||
// TODO: Add warranty_tnv to battery information
|
// check if battery is active
|
||||||
$batt_list[] = [
|
if ($batt->isActive())
|
||||||
'id' => $batt->getID(),
|
{
|
||||||
'mfg_id' => $batt->getManufacturer()->getID(),
|
// TODO: Add warranty_tnv to battery information
|
||||||
'mfg_name' => $batt->getManufacturer()->getName(),
|
$batt_list[] = [
|
||||||
'model_id' => $batt->getModel()->getID(),
|
'id' => $batt->getID(),
|
||||||
'model_name' => $batt->getModel()->getName(),
|
'mfg_id' => $batt->getManufacturer()->getID(),
|
||||||
'size_id' => $batt->getSize()->getID(),
|
'mfg_name' => $batt->getManufacturer()->getName(),
|
||||||
'size_name' => $batt->getSize()->getName(),
|
'model_id' => $batt->getModel()->getID(),
|
||||||
'price' => $batt->getSellingPrice(),
|
'model_name' => $batt->getModel()->getName(),
|
||||||
'wty_private' => $batt->getWarrantyPrivate(),
|
'size_id' => $batt->getSize()->getID(),
|
||||||
'wty_commercial' => $batt->getWarrantyCommercial(),
|
'size_name' => $batt->getSize()->getName(),
|
||||||
'image_url' => $this->getBatteryImageURL($req, $batt),
|
'price' => $batt->getSellingPrice(),
|
||||||
];
|
'wty_private' => $batt->getWarrantyPrivate(),
|
||||||
|
'wty_commercial' => $batt->getWarrantyCommercial(),
|
||||||
|
'image_url' => $this->getBatteryImageURL($req, $batt),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// data
|
// data
|
||||||
|
|
|
||||||
|
|
@ -48,20 +48,24 @@ class BatteryController extends APIController
|
||||||
$batts = $vehicle->getBatteries();
|
$batts = $vehicle->getBatteries();
|
||||||
foreach ($batts as $batt)
|
foreach ($batts as $batt)
|
||||||
{
|
{
|
||||||
// TODO: Add warranty_tnv to battery information
|
// check if battery is active
|
||||||
$batt_list[] = [
|
if ($batt->isActive())
|
||||||
'id' => $batt->getID(),
|
{
|
||||||
'mfg_id' => $batt->getManufacturer()->getID(),
|
// TODO: Add warranty_tnv to battery information
|
||||||
'mfg_name' => $batt->getManufacturer()->getName(),
|
$batt_list[] = [
|
||||||
'model_id' => $batt->getModel()->getID(),
|
'id' => $batt->getID(),
|
||||||
'model_name' => $batt->getModel()->getName(),
|
'mfg_id' => $batt->getManufacturer()->getID(),
|
||||||
'size_id' => $batt->getSize()->getID(),
|
'mfg_name' => $batt->getManufacturer()->getName(),
|
||||||
'size_name' => $batt->getSize()->getName(),
|
'model_id' => $batt->getModel()->getID(),
|
||||||
'price' => $batt->getSellingPrice(),
|
'model_name' => $batt->getModel()->getName(),
|
||||||
'wty_private' => $batt->getWarrantyPrivate(),
|
'size_id' => $batt->getSize()->getID(),
|
||||||
'wty_commercial' => $batt->getWarrantyCommercial(),
|
'size_name' => $batt->getSize()->getName(),
|
||||||
'image_url' => $this->getBatteryImageURL($req, $batt),
|
'price' => $batt->getSellingPrice(),
|
||||||
];
|
'wty_private' => $batt->getWarrantyPrivate(),
|
||||||
|
'wty_commercial' => $batt->getWarrantyCommercial(),
|
||||||
|
'image_url' => $this->getBatteryImageURL($req, $batt),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// data
|
// data
|
||||||
|
|
|
||||||
|
|
@ -497,17 +497,21 @@ class VehicleController extends Controller
|
||||||
// get compatible batteries from selected manufacturer
|
// get compatible batteries from selected manufacturer
|
||||||
foreach ($vobj->getBatteries() as $battery)
|
foreach ($vobj->getBatteries() as $battery)
|
||||||
{
|
{
|
||||||
$batteries[] = [
|
// need to check if battery is active
|
||||||
'id' => $battery->getID(),
|
if ($battery->isActive())
|
||||||
'mfg_name' => $battery->getManufacturer()->getName(),
|
{
|
||||||
'model_name' => $battery->getModel()->getName(),
|
$batteries[] = [
|
||||||
'size_name' => $battery->getSize()->getName(),
|
'id' => $battery->getID(),
|
||||||
'prod_code' => $battery->getProductCode(),
|
'mfg_name' => $battery->getManufacturer()->getName(),
|
||||||
'sell_price' => $battery->getSellingPrice(),
|
'model_name' => $battery->getModel()->getName(),
|
||||||
'warr_private' => $battery->getWarrantyPrivate(),
|
'size_name' => $battery->getSize()->getName(),
|
||||||
'warr_commercial' => $battery->getWarrantyCommercial(),
|
'prod_code' => $battery->getProductCode(),
|
||||||
];
|
'sell_price' => $battery->getSellingPrice(),
|
||||||
$battery_index[$battery->getID()] = 1;
|
'warr_private' => $battery->getWarrantyPrivate(),
|
||||||
|
'warr_commercial' => $battery->getWarrantyCommercial(),
|
||||||
|
];
|
||||||
|
$battery_index[$battery->getID()] = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add all other batteries, because they want options
|
// add all other batteries, because they want options
|
||||||
|
|
|
||||||
|
|
@ -714,7 +714,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
if (isset($data['error']))
|
if (isset($data['error']))
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
$batts = $this->em->getRepository(Battery::class)->findAll();
|
$batts = $this->em->getRepository(Battery::class)->findBy(['flag_active' => true]);
|
||||||
$models = $this->em->getRepository(BatteryModel::class)->findAll();
|
$models = $this->em->getRepository(BatteryModel::class)->findAll();
|
||||||
$sizes = $this->em->getRepository(BatterySize::class)->findAll();
|
$sizes = $this->em->getRepository(BatterySize::class)->findAll();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,8 @@ $(function() {
|
||||||
manufacturer: "{{ batt.getManufacturer.getName|default('') }} ",
|
manufacturer: "{{ batt.getManufacturer.getName|default('') }} ",
|
||||||
model: "{{ batt.getModel.getName|default('') }}",
|
model: "{{ batt.getModel.getName|default('') }}",
|
||||||
size: "{{ batt.getSize.getName|default('') }}",
|
size: "{{ batt.getSize.getName|default('') }}",
|
||||||
sell_price: "{{ batt.getSellingPrice }}"
|
sell_price: "{{ batt.getSellingPrice }}",
|
||||||
|
flag_active: "{{ batt.isActive }}"
|
||||||
};
|
};
|
||||||
|
|
||||||
battRows.push(trow);
|
battRows.push(trow);
|
||||||
|
|
@ -341,6 +342,14 @@ $(function() {
|
||||||
layout: {
|
layout: {
|
||||||
scroll: true
|
scroll: true
|
||||||
},
|
},
|
||||||
|
rows: {
|
||||||
|
beforeTemplate: function(row, data, index) {
|
||||||
|
var is_active = data.flag_active;
|
||||||
|
if (is_active == false) {
|
||||||
|
$(row).addClass('hide');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
field: 'id',
|
field: 'id',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue