Fix delete number / vehicle bug in customer
This commit is contained in:
parent
53f30f5f3b
commit
9841d5c215
2 changed files with 29 additions and 12 deletions
|
|
@ -409,14 +409,14 @@ class CustomerController extends BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
if (count($vehicle_ids) > 0)
|
// delete all vehicles not in list
|
||||||
|
$cvs = $cust->getVehicles();
|
||||||
|
foreach ($cvs as $cv)
|
||||||
{
|
{
|
||||||
// delete all vehicles not in list
|
if (!isset($vehicle_ids[$cv->getID()]))
|
||||||
$cvs = $cust->getVehicles();
|
|
||||||
foreach ($cvs as $cv)
|
|
||||||
{
|
{
|
||||||
if (!isset($vehicle_ids[$cv->getID()]))
|
$cust->removeVehicle($cv);
|
||||||
$em->remove($cv);
|
$em->remove($cv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -458,15 +458,20 @@ class CustomerController extends BaseController
|
||||||
$number_ids[] = $mobile_number->getID();
|
$number_ids[] = $mobile_number->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_log('cleanup');
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
if (count($number_ids) > 0)
|
// delete all not in list
|
||||||
|
$mns = $cust->getMobileNumbers();
|
||||||
|
foreach ($mns as $mn)
|
||||||
{
|
{
|
||||||
// delete all not in list
|
error_log($mn->getID());
|
||||||
$mns = $cust->getMobileNumbers();
|
error_log(print_r($number_ids, true));
|
||||||
foreach ($mns as $mn)
|
if (!isset($number_ids[$mn->getID()]))
|
||||||
{
|
{
|
||||||
if (!isset($number_ids[$mn->getID()]))
|
error_log('removing ' . $mn->getID());
|
||||||
$em->remove($mn);
|
$cust->removeMobileNumber($mn);
|
||||||
|
$em->remove($mn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,12 @@ class Customer
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function removeMobileNumber($num)
|
||||||
|
{
|
||||||
|
$this->numbers->removeElement($num);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getMobileNumbers()
|
public function getMobileNumbers()
|
||||||
{
|
{
|
||||||
return $this->numbers;
|
return $this->numbers;
|
||||||
|
|
@ -212,6 +218,12 @@ class Customer
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function removeVehicle($vehicle)
|
||||||
|
{
|
||||||
|
$this->vehicles->removeElement($vehicle);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getVehicles()
|
public function getVehicles()
|
||||||
{
|
{
|
||||||
return $this->vehicles;
|
return $this->vehicles;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue