public function actionInsertProgram() { Yii::app()->user->returnUrl = Yii::app()->request->urlReferrer; if ($_POST) { // $cek = DatabaseUmum::cekExist("program","nama_program",$_POST['namaTP']); // cek menggunakan component DatabaseUmum $cek = DatabaseUmum::cekExist2('program', 'nama_program', 'tahun_anggaran', $_POST['namaTP'], $_POST['tahunTP']); if ($cek <= 0) { $program = new Program(); $program->nama_program = $_POST['namaTP']; $program->kode_program = $_POST['kodeTP']; $program->target = $_POST['targetTP']; $program->tahun_anggaran = $_POST['tahunTP']; $program->id_rekaman = 0; if ($program->validate()) { $program->save(); // echo $program->nama_program; $this->redirect(array('index')); } else { Yii::app()->user->setFlash('error', 'Maaf, simpan Program gagal. Mohon periksa kembali data yang anda inputkan'); $this->redirect(array('/errPage/errDB')); } } else { Yii::app()->user->setFlash('error', 'Maaf, simpan Program gagal. Data sudah ada'); $this->redirect(array('/errPage/errDB')); } } else { $this->actionIndex(); } }