Staging #1663

Merged
korina.cordero merged 16 commits from staging into master 2023-02-09 10:19:34 +00:00
5 changed files with 56 additions and 64 deletions
Showing only changes of commit 765b3a99b9 - Show all commits

View file

@ -823,27 +823,24 @@ class APIController extends Controller implements LoggedController
// batteries
$batt_list = [];
$batts = $vehicle->getBatteries();
// $batts = $vehicle->getBatteries();
$batts = $vehicle->getActiveBatteries();
foreach ($batts as $batt)
{
// check if battery is active
if ($batt->isActive())
{
// TODO: Add warranty_tnv to battery information
$batt_list[] = [
'id' => $batt->getID(),
'mfg_id' => $batt->getManufacturer()->getID(),
'mfg_name' => $batt->getManufacturer()->getName(),
'model_id' => $batt->getModel()->getID(),
'model_name' => $batt->getModel()->getName(),
'size_id' => $batt->getSize()->getID(),
'size_name' => $batt->getSize()->getName(),
'price' => $batt->getSellingPrice(),
'wty_private' => $batt->getWarrantyPrivate(),
'wty_commercial' => $batt->getWarrantyCommercial(),
'image_url' => $this->getBatteryImageURL($req, $batt),
];
}
// TODO: Add warranty_tnv to battery information
$batt_list[] = [
'id' => $batt->getID(),
'mfg_id' => $batt->getManufacturer()->getID(),
'mfg_name' => $batt->getManufacturer()->getName(),
'model_id' => $batt->getModel()->getID(),
'model_name' => $batt->getModel()->getName(),
'size_id' => $batt->getSize()->getID(),
'size_name' => $batt->getSize()->getName(),
'price' => $batt->getSellingPrice(),
'wty_private' => $batt->getWarrantyPrivate(),
'wty_commercial' => $batt->getWarrantyCommercial(),
'image_url' => $this->getBatteryImageURL($req, $batt),
];
}
// data

View file

@ -45,27 +45,24 @@ class BatteryController extends APIController
// batteries
$batt_list = [];
$batts = $vehicle->getBatteries();
// $batts = $vehicle->getBatteries();
$batts = $vehicle->getActiveBatteries();
foreach ($batts as $batt)
{
// check if battery is active
if ($batt->isActive())
{
// TODO: Add warranty_tnv to battery information
$batt_list[] = [
'id' => $batt->getID(),
'mfg_id' => $batt->getManufacturer()->getID(),
'mfg_name' => $batt->getManufacturer()->getName(),
'model_id' => $batt->getModel()->getID(),
'model_name' => $batt->getModel()->getName(),
'size_id' => $batt->getSize()->getID(),
'size_name' => $batt->getSize()->getName(),
'price' => $batt->getSellingPrice(),
'wty_private' => $batt->getWarrantyPrivate(),
'wty_commercial' => $batt->getWarrantyCommercial(),
'image_url' => $this->getBatteryImageURL($req, $batt),
];
}
// TODO: Add warranty_tnv to battery information
$batt_list[] = [
'id' => $batt->getID(),
'mfg_id' => $batt->getManufacturer()->getID(),
'mfg_name' => $batt->getManufacturer()->getName(),
'model_id' => $batt->getModel()->getID(),
'model_name' => $batt->getModel()->getName(),
'size_id' => $batt->getSize()->getID(),
'size_name' => $batt->getSize()->getName(),
'price' => $batt->getSellingPrice(),
'wty_private' => $batt->getWarrantyPrivate(),
'wty_commercial' => $batt->getWarrantyCommercial(),
'image_url' => $this->getBatteryImageURL($req, $batt),
];
}
// data

View file

@ -495,23 +495,20 @@ class VehicleController extends Controller
$battery_index = [];
// get compatible batteries from selected manufacturer
foreach ($vobj->getBatteries() as $battery)
// foreach ($vobj->getBatteries() as $battery)
foreach ($vobj->getActiveBatteries() as $battery)
{
// need to check if battery is active
if ($battery->isActive())
{
$batteries[] = [
'id' => $battery->getID(),
'mfg_name' => $battery->getManufacturer()->getName(),
'model_name' => $battery->getModel()->getName(),
'size_name' => $battery->getSize()->getName(),
'prod_code' => $battery->getProductCode(),
'sell_price' => $battery->getSellingPrice(),
'warr_private' => $battery->getWarrantyPrivate(),
'warr_commercial' => $battery->getWarrantyCommercial(),
];
$battery_index[$battery->getID()] = 1;
}
$batteries[] = [
'id' => $battery->getID(),
'mfg_name' => $battery->getManufacturer()->getName(),
'model_name' => $battery->getModel()->getName(),
'size_name' => $battery->getSize()->getName(),
'prod_code' => $battery->getProductCode(),
'sell_price' => $battery->getSellingPrice(),
'warr_private' => $battery->getWarrantyPrivate(),
'warr_commercial' => $battery->getWarrantyCommercial(),
];
$battery_index[$battery->getID()] = 1;
}
// add all other batteries, because they want options

View file

@ -4,6 +4,8 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -177,4 +179,12 @@ class Vehicle
{
return $this->cust_vehicles;
}
public function getActiveBatteries()
{
$crit = Criteria::create();
$crit->where(Criteria::expr()->eq('flag_active', true));
return $this->batteries->matching($crit);
}
}

View file

@ -233,14 +233,13 @@ $(function() {
var batteryIds = [];
var battMfgModelSize = []
{% for batt in obj.getBatteries %}
{% for batt in obj.getActiveBatteries %}
trow = {
id: "{{ batt.getID }}",
manufacturer: "{{ batt.getManufacturer.getName|default('') }} ",
model: "{{ batt.getModel.getName|default('') }}",
size: "{{ batt.getSize.getName|default('') }}",
sell_price: "{{ batt.getSellingPrice }}",
flag_active: "{{ batt.isActive }}"
};
battRows.push(trow);
@ -342,14 +341,6 @@ $(function() {
layout: {
scroll: true
},
rows: {
beforeTemplate: function(row, data, index) {
var is_active = data.flag_active;
if (is_active == false) {
$(row).addClass('hide');
}
}
},
columns: [
{
field: 'id',