/** * Creates a new ClnTranInjResp model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $user_id = 'admin'; $model = new ClnTranInjResp(); // if ($model->load(Yii::$app->request->post()) && $model->save()) { if (Yii::$app->request->post()) { $model->TRAN_INJ_RESP_ID = ClnTranInjResp::getNewID(); $model->TRAN_INJ_GEN_NO = $_POST['TRAN_INJ_GEN_NO']; $model->STAFF_ID = $_POST['STAFF_ID']; $model->CREATE_BY = $user_id; $model->CREATE_DATE = new \yii\db\Expression('SYSDATE'); if ($model->save()) { $data['result'] = 'success'; } else { $data['result'] = 'error'; } header('Content-type: application/json'); echo json_encode($data); } else { $searchModel = new ClnStaffSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->renderAjax('selectstaff', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); } /* $model = new ClnTranInjResp(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->TRAN_INJ_RESP_ID]); } else { return $this->render('create', [ 'model' => $model, ]); } */ }
/** * Lists all ClnStaff models. * @return mixed */ public function actionIndex() { $searchModel = new ClnStaffSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }