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
|
||||
if (count($vehicle_ids) > 0)
|
||||
// delete all vehicles not in list
|
||||
$cvs = $cust->getVehicles();
|
||||
foreach ($cvs as $cv)
|
||||
{
|
||||
// delete all vehicles not in list
|
||||
$cvs = $cust->getVehicles();
|
||||
foreach ($cvs as $cv)
|
||||
if (!isset($vehicle_ids[$cv->getID()]))
|
||||
{
|
||||
if (!isset($vehicle_ids[$cv->getID()]))
|
||||
$em->remove($cv);
|
||||
$cust->removeVehicle($cv);
|
||||
$em->remove($cv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -458,15 +458,20 @@ class CustomerController extends BaseController
|
|||
$number_ids[] = $mobile_number->getID();
|
||||
}
|
||||
|
||||
error_log('cleanup');
|
||||
|
||||
// cleanup
|
||||
if (count($number_ids) > 0)
|
||||
// delete all not in list
|
||||
$mns = $cust->getMobileNumbers();
|
||||
foreach ($mns as $mn)
|
||||
{
|
||||
// delete all not in list
|
||||
$mns = $cust->getMobileNumbers();
|
||||
foreach ($mns as $mn)
|
||||
error_log($mn->getID());
|
||||
error_log(print_r($number_ids, true));
|
||||
if (!isset($number_ids[$mn->getID()]))
|
||||
{
|
||||
if (!isset($number_ids[$mn->getID()]))
|
||||
$em->remove($mn);
|
||||
error_log('removing ' . $mn->getID());
|
||||
$cust->removeMobileNumber($mn);
|
||||
$em->remove($mn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,6 +160,12 @@ class Customer
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function removeMobileNumber($num)
|
||||
{
|
||||
$this->numbers->removeElement($num);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMobileNumbers()
|
||||
{
|
||||
return $this->numbers;
|
||||
|
|
@ -212,6 +218,12 @@ class Customer
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function removeVehicle($vehicle)
|
||||
{
|
||||
$this->vehicles->removeElement($vehicle);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVehicles()
|
||||
{
|
||||
return $this->vehicles;
|
||||
|
|
|
|||
Loading…
Reference in a new issue