Resolve "Delete icon for battery in vehicle screen" #1172

Merged
korina.cordero merged 2 commits from 317-delete-icon-for-battery-in-vehicle-screen into master 2020-01-29 11:17:25 +00:00
Showing only changes of commit 33fdc857f2 - Show all commits

View file

@ -282,15 +282,25 @@ class VehicleController extends Controller
// need to check if a battery has been removed
if (count($current_batteries) > count($batteries))
{
error_log('A battery has been removed');
}
foreach ($batteries as $battery_id)
{
$battery = $em->getRepository(Battery::class)->find($battery_id);
if (!empty($battery))
// battery/batteries have been removed
foreach ($current_batteries as $cbatt)
{
error_log('battery id ' . $battery->getID());
$cbatt_id = $cbatt->getID();
if (in_array($cbatt_id, $batteries))
{
// do nothing, move to next element
continue;
}
else
{
// cbatt_id has been deleted
$battery = $em->getRepository(Battery::class)->find($cbatt_id);
if (!empty($battery))
{
$battery->removeVehicle($row);
}
}
}
}
}