public function beforeDelete() { $id = $this->student_transaction_id; $fees_check = FeesPaymentTransaction::model()->findAll(array('condition' => 'fees_student_id=' . $id)); $att_check = Attendence::model()->findAll(array('condition' => 'st_id=' . $id)); $mis_fees = MiscellaneousFeesPaymentTransaction::model()->findAll(array('condition' => 'student_fees_id=' . $id)); $left_check = LeftDetainedPassStudentTable::model()->findAll(array('condition' => 'student_id=' . $id)); $st_archive = StudentArchiveTable::model()->findAll(array('condition' => 'student_archive_stud_tran_id=' . $id)); if (!empty($fees_check) || !empty($att_check) || !empty($mis_fees) || !empty($left_check) || !empty($st_archive)) { Yii::app()->user->setFlash('error', "You can not delete this record because it is used in another table."); return false; } else { Yii::app()->user->setFlash('success', "Deleted Sucessfully"); return true; } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = MiscellaneousFeesPaymentTransaction::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }