예제 #1
0
 public function actionPrestasiKerja($id)
 {
     $model = $this->loadModel($id);
     $modelpresk = new KPrestasikerjaR();
     if (isset($_POST['KPrestasikerjaR'])) {
         $modelpresk->attributes = $_POST['KPrestasikerjaR'];
         $modelpresk->karyawan_id = $_POST['karyawan_id'];
         $nourut = count(KPrestasikerjaR::model()->findAllByAttributes(array('karyawan_id' => $modelpresk->karyawan_id))) + 1;
         $modelpresk->nourutprestasi = $nourut;
         if ($modelpresk->validate()) {
             $modelpresk->save() == true ? Yii::app()->user->setFlash('status', 'Berhasil disimpan !') : Yii::app()->user->setFlash('status', 'Gagal disimpan !');
         }
     }
     $this->render('_formPrestasiKerja', array('model' => $model, 'modelpresk' => $modelpresk));
 }
 public function actionPrestasiKerja($id)
 {
     if (Yii::app()->request->isAjaxRequest) {
         $this->layout = '//layouts/polos';
     }
     $model = KKaryawanM::model()->findByPk($id);
     $modelpresk = new KPrestasikerjaR();
     if (isset($_POST['KPrestasikerjaR'])) {
         $modelpresk->attributes = $_POST['KPrestasikerjaR'];
         $modelpresk->karyawan_id = $_POST['karyawan_id'];
         $nourut = count(KPrestasikerjaR::model()->findAllByAttributes(array('karyawan_id' => $modelpresk->karyawan_id))) + 1;
         $modelpresk->nourutprestasi = $nourut;
         CActiveForm::validate($modelpresk);
         if ($modelpresk->validate()) {
             $modelpresk->save() == true ? Yii::app()->user->setFlash('status', 'Berhasil disimpan !') : Yii::app()->user->setFlash('status', 'Gagal disimpan !');
         }
     }
     $this->render('_formPrestasiKerja', array('model' => $model, 'modelpresk' => $modelpresk));
 }