Resolve "Add button for battery compatibility in vehicle form" #1176

Merged
korina.cordero merged 5 commits from 323-add-button-for-battery-compatibility-in-vehicle-form into master 2020-02-04 01:58:35 +00:00
Showing only changes of commit ac908e9bcd - Show all commits

View file

@ -310,6 +310,41 @@ class VehicleController extends Controller
}
}
}
// need to check if a battery has been added
if (count($current_batteries) < count($batteries))
{
// get the ids of current batteries
$cbatt_ids = [];
foreach ($current_batteries as $cbatt)
{
$cbatt_ids = [
$cbatt->getID(),
];
}
// find the battery to add
foreach ($batteries as $batt)
{
$batt_id = $batt;
if (in_array($batt_id, $cbatt_ids))
{
// do nothing since battery already there
continue;
}
else
{
// batt is the new battery
$battery = $em->getRepository(Battery::class)->find($batt_id);
if (!empty($battery))
{
$battery->addVehicle($row);
$em->persist($battery);
}
}
}
}
}
else
{