Exemplo n.º 1
0
 public function actionInsertSatuan()
 {
     if ($_POST) {
         $cek = DatabaseUmum::cekExist("satuan", "nama", $_POST['namaSt']);
         // cek menggunakan component DatabaseUmum
         if ($cek <= 0) {
             $SumberDana = new Satuan();
             $SumberDana->nama = $_POST['namaSt'];
             $SumberDana->deskripsi = $_POST['deskripsiSt'];
             if ($SumberDana->save()) {
                 $this->redirect(array('index'));
             } else {
                 Yii::app()->user->setFlash('error', 'Maaf, simpan gagal');
                 $this->redirect(array('/errPage/errDB'));
             }
         } else {
             Yii::app()->user->setFlash('error', 'Maaf, simpan Satuan gagal. Data sudah ada');
             $this->redirect(array('/errPage/errDB'));
         }
     } else {
         $this->actionIndex();
     }
 }
Exemplo n.º 2
0
 public function actionInsertKegiatan()
 {
     Yii::app()->user->returnUrl = Yii::app()->request->urlReferrer;
     if ($_POST) {
         $cek = DatabaseUmum::cekExist("kegiatan", "nama_kegiatan", $_POST['namaKg']);
         // cek menggunakan component DatabaseUmum
         if ($cek <= 0) {
             $kegiatan = new Kegiatan();
             $kegiatan->nama_kegiatan = $_POST['namaKg'];
             $kegiatan->kode_kegiatan = $_POST['kodeKg'];
             $kegiatan->id_layanan = $_POST['id_layanan'];
             $kegiatan->target = $_POST['targetKg'];
             $kegiatan->bulan = $_POST['bulanKg'];
             $kegiatan->volume = $_POST['volumeKg'];
             $kegiatan->harga_satuan = $_POST['harga_satuanKg'];
             $kegiatan->satuan = $_POST['satuanKg'];
             $kegiatan->sumber_dana = $_POST['sumber_danaKg'];
             $kegiatan->penanggung_jawab = $_POST['penanggung_jawabKg'];
             $kegiatan->id_rekaman = 0;
             $kegiatan->versi = 0;
             $kegiatan->status = 0;
             if ($kegiatan->validate()) {
                 $kegiatan->save();
                 $this->redirect(array('kegiatan', 'id' => $_POST['id_layanan']));
             } 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();
     }
 }