if (empty($ids)) { continue; } array_unique($ids); sort($ids); array_pop($ids); // Only keep last CAppUI::stepAjax(" -- Patient #" . $_corresp["patient_id"], UI_MSG_OK); $count = 0; foreach ($ids as $_id) { if ($dry_run) { $count++; continue; } $_correspondant = new CCorrespondant(); $_correspondant->load($_id); if ($msg = $_correspondant->delete()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); } else { $count++; } } $count_total += $count; if ($dry_run) { CAppUI::stepAjax("{$count} correspondants à supprimer", UI_MSG_OK); } else { CAppUI::stepAjax("{$count} correspondants supprimés", UI_MSG_OK); } } if ($dry_run) { CAppUI::stepAjax("{$count_total} correspondants à supprimer au total", UI_MSG_OK);