/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Deptsub::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(['DEP_SUB_STS' => $this->DEP_SUB_STS, 'SORT' => $this->SORT]); $query->andFilterWhere(['like', 'DEP_SUB_ID', $this->DEP_SUB_ID])->andFilterWhere(['like', 'DEP_ID', $this->DEP_ID])->andFilterWhere(['like', 'DEP_SUB_NM', $this->DEP_SUB_NM])->andFilterWhere(['like', 'DEP_SUB_AVATAR', $this->DEP_SUB_AVATAR])->andFilterWhere(['like', 'DEP_SUB_DCRP', $this->DEP_SUB_DCRP]); return $dataProvider; }
public function actionSubdept() { $out = []; if (isset($_POST['depdrop_parents'])) { $parents = $_POST['depdrop_parents']; if ($parents != null) { $DEP_ID = $parents[0]; $param1 = null; if (!empty($_POST['depdrop_params'])) { $params = $_POST['depdrop_params']; $param1 = $params[0]; // get the value of sub dept =js value/html } $model = Deptsub::find()->asArray()->where(['DEP_ID' => $DEP_ID])->all(); foreach ($model as $key => $value) { $out[] = ['id' => $value['DEP_SUB_ID'], 'name' => $value['DEP_SUB_NM']]; } echo json_encode(['output' => $out, 'selected' => $param1]); return; } } echo Json::encode(['output' => '', 'selected' => '']); }
use kartik\widgets\FileInput; use yii\helpers\Url; use kartik\widgets\DepDrop; $this->sideCorp = 'HRM - Data Employee'; /* Title Select Company pada header pasa sidemenu/menu samping kiri */ $this->sideMenu = 'hrd_personalia'; /* kd_menu untuk list menu pada sidemenu, get from table of database */ $this->title = Yii::t('app', 'Personalia - Detail & Edit Employee'); /* title pada header page */ ?> <?php $Corp_MDL = Corp::find()->where(['CORP_ID' => $model->EMP_CORP_ID])->orderBy('SORT')->one(); $Dept_MDL = Dept::find()->where(['DEP_ID' => $model->DEP_ID])->orderBy('SORT')->one(); $DeptSub_MDL = Deptsub::find()->where(['DEP_SUB_ID' => $model->DEP_SUB_ID])->orderBy('SORT')->one(); $Gf_MDL = Groupfunction::find()->where(['GF_ID' => $model->GF_ID])->orderBy('SORT')->one(); $GSeqmen_MDL = Groupseqmen::find()->where(['SEQ_ID' => $model->SEQ_ID])->one(); $Jabatan_MDL = Jobgrade::find()->where(['JOBGRADE_ID' => $model->JOBGRADE_ID])->orderBy('SORT')->one(); $Status_MDL = Status::find()->where(['STS_ID' => $model->EMP_STS])->orderBy('SORT')->one(); /*COORPORATE*/ if (count($Corp_MDL) == 0) { $Val_Corp = 'none'; } else { $Val_Corp = $Corp_MDL->CORP_NM; } /*DEPARTMENT*/ if (count($Dept_MDL) == 0) { $Val_Dept = 'none'; } else { $Val_Dept = $Dept_MDL->DEP_NM;
/** * Finds the Deptsub model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Deptsub the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Deptsub::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getDeptsub() { return $this->hasOne(Deptsub::className(), ['DEP_SUB_ID' => 'DEP_SUB_ID']); }