public function actionJenjangKarir($id) { $model = $this->loadModel($id); $modeljk = new KJenjangkarirR(); $indexTab = 4; if (isset($_POST['KJenjangkarirR'])) { $modeljk->attributes = $_POST['KJenjangkarirR']; $modeljk->karyawan_id = $_POST['karyawan_id']; $nourut = count(KJenjangkarirR::model()->findAllByAttributes(array('karyawan_id' => $modeljk->karyawan_id))) + 1; $modeljk->nourutjenjangkarir = $nourut; if ($modeljk->validate()) { $modeljk->save() == true ? Yii::app()->user->setFlash('status', 'Berhasil disimpan !') : Yii::app()->user->setFlash('status', 'Gagal disimpan !'); } } $this->render('_formJenjangKarir', array('model' => $model, 'modeljk' => $modeljk, 'id' => $id, 'indexTab' => $indexTab)); }
/** * 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 = KJenjangkarirR::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionJenjangKarir($id) { if (Yii::app()->request->isAjaxRequest) { $this->layout = '//layouts/polos'; } $model = KKaryawanM::model()->findByPk($id); $modeljk = new KJenjangkarirR(); $indexTab = 4; if (isset($_POST['KJenjangkarirR'])) { $modeljk->attributes = $_POST['KJenjangkarirR']; $modeljk->karyawan_id = $_POST['karyawan_id']; $nourut = count(KJenjangkarirR::model()->findAllByAttributes(array('karyawan_id' => $modeljk->karyawan_id))) + 1; $modeljk->nourutjenjangkarir = $nourut; if ($modeljk->validate()) { $modeljk->save() == true ? Yii::app()->user->setFlash('status', 'Berhasil disimpan !') : Yii::app()->user->setFlash('status', 'Gagal disimpan !'); } else { CActiveForm::validate($modeljk); } } $this->render('_formJenjangKarir', array('model' => $model, 'modeljk' => $modeljk, 'id' => $id)); }