/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Securitas::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(['like', 'KODE', $this->KODE])->andFilterWhere(['like', 'NAMA', $this->NAMA])->andFilterWhere(['like', 'ALAMAT', $this->ALAMAT])->andFilterWhere(['like', 'TELP', $this->TELP])->andFilterWhere(['like', 'CP', $this->CP])->andFilterWhere(['like', 'HP', $this->HP]); return $dataProvider; }
public function actionGetSecuritas($id) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; if (($model = Securitas::find()->where(['KODE' => $id])->asArray()->one()) !== null) { return ['data' => $model]; } else { return ['data' => '']; } }
/** * @return \yii\db\ActiveQuery */ public function getSecuritas() { return $this->hasOne(Securitas::className(), ['KODE' => 'SECURITAS_KODE']); }
</div> <div class="col-xs-6 col-sm-9"> <label class="control-label">Nama Emiten</label> <?php $emiten_name = $model->emiten ? $model->emiten->NAMA : ''; ?> <?php echo Html::input('text', 'emiten_name', $emiten_name, ['class' => 'form-control', 'id' => 'emiten-name', 'readonly' => 'true']); ?> </div> </div> <div class="row"> <div class="col-xs-6 col-sm-3"> <?php $data = ArrayHelper::map(Securitas::find()->select(['KODE', 'NAMA', 'DERIVED' => 'CONCAT(KODE," - ",NAMA)'])->asArray()->all(), 'KODE', 'KODE'); echo $form->field($model, 'SECURITAS_KODE')->widget(Select2::classname(), ['data' => $data, 'options' => ['placeholder' => 'Pilih Securitas ...', 'onchange' => ' //var id = Aes.Ctr.encrypt($(this).val(), "123456", 256); var id = $(this).val() $.post( "' . Url::to(['get-securitas']) . '?id="+id, function( data ) { $( "#securitas-name" ).val( data.data.NAMA ); $( "#securitas-name" ).focus(); }); '], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-xs-6 col-sm-9"> <label class="control-label">Nama Securitas</label> <?php $securitas_name = $model->securitas ? $model->securitas->NAMA : ''; ?>
/** * Finds the Securitas model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Securitas the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Securitas::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }