/** * Creates a new ClnMedicineTest model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $user_id = 'admin'; $model = new ClnMedicineTest(); if ($model->load(Yii::$app->request->post())) { $model->MEDICINE_GEN_NO = ClnMedicineTest::getNewID(); $model->CREATE_BY = $user_id; $model->CREATE_DATE = new \yii\db\Expression('SYSDATE'); $model->UPDATE_BY = $user_id; $model->UPDATE_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 { $getData = unserialize(base64_decode(Yii::$app->request->get('params'))); $cureItems = ArrayHelper::map(ClnCure::find()->all(), 'CURE_GEN_NO', 'CURE_NAME'); $model->TRAN_INJ_GEN_NO = $getData['TRAN_INJ_GEN_NO']; $seqNumItems = Yii::$app->utilsHelper->getSeqNum10(); return $this->renderAjax('create', ['model' => $model, 'cureItems' => $cureItems, 'seqNumItems' => $seqNumItems]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ClnCure::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['CURE_GEN_NO' => $this->CURE_GEN_NO, 'CURE_EXPENSES' => $this->CURE_EXPENSES, 'CREATE_DATE' => $this->CREATE_DATE, 'UPDATE_DATE' => $this->UPDATE_DATE, 'VERSION' => $this->VERSION]); $query->andFilterWhere(['like', 'CURE_CODE', $this->CURE_CODE])->andFilterWhere(['like', 'CURE_NAME', $this->CURE_NAME])->andFilterWhere(['like', 'CREATE_BY', $this->CREATE_BY])->andFilterWhere(['like', 'UPDATE_BY', $this->UPDATE_BY]); return $dataProvider; }