public function actionDeleteERODRules()
{
if (!empty($_POST['erod'])) {
$transaction = Yii::app()->db->beginTransaction();
try {
foreach ($_POST['erod'] as $erod_id) {
if ($_erod = OphTrOperationbooking_Operation_EROD_Rule::model()->findByPk($erod_id)) {
foreach ($_erod->items as $item) {
if (!$item->delete()) {
throw new Exception('Unable to delete rule item: ' . print_r($item->getErrors(), true));
}
}
if (!$_erod->delete()) {
throw new Exception('Unable to delete erod rule: ' . print_r($_erod->getErrors(), true));
}
} else {
throw new Exception('EROD Rule not found for id ' . $erod_id);
}
}
Audit::add('admin', 'delete', null, null, array('module' => 'OphTrOperationbooking', 'model' => 'OphTrOperationbooking_Operation_EROD_Rule'));
$transaction->commit();
} catch (Exception $e) {
$transaction->rollback();
echo $e->getMessage();
Yii::app()->end();
}
}
echo '1';
}