/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Faktur::find(); $query->joinWith(['penjualan0']); $query->join('INNER JOIN', 'pembeli', 'penjualan.id_pembeli = pembeli.id'); $query->join('INNER JOIN', 'motor', 'penjualan.id_motor = motor.id'); $query->join('INNER JOIN', 'jenis_motor', 'jenis_motor.id = motor.id_jenis'); $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; } $dataProvider->sort->attributes['Tgl Penjualan'] = ['asc' => ['penjualan.tgl' => SORT_ASC], 'desc' => ['penjualan.tgl' => SORT_DESC]]; $dataProvider->sort->attributes['Nama Pembeli'] = ['asc' => ['pembeli.nama_lengkap' => SORT_ASC], 'desc' => ['pembeli.nama_lengkap' => SORT_DESC]]; $dataProvider->sort->attributes['jenisMotor0.nama'] = ['asc' => ['motor.id_jenis' => SORT_ASC], 'desc' => ['motor.id_jenis' => SORT_DESC]]; $query->andFilterWhere(['id' => $this->id, 'id_penjualan' => $this->id_penjualan]); $query->andFilterWhere(['like', 'nama_penerima', $this->nama_penerima])->andFilterWhere(['like', 'no_faktur', $this->no_faktur])->andFilterWhere(['like', 'nama', $this->nama])->andFilterWhere(['like', 'keterangan', $this->keterangan])->andFilterWhere(['like', 'tgl_faktur', $this->tgl_faktur])->andFilterWhere(['like', 'nama_lengkap', $this->nama_lengkap])->andFilterWhere(['like', 'foto', $this->foto]); return $dataProvider; }
<?php use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel app\models\SuratJalanSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Data Surat Jalan'; $this->params['breadcrumbs'][] = $this->title; ?> <?php //use app\models\Country; $no_faktur = \app\models\Faktur::find()->all(); $listData = \yii\helpers\ArrayHelper::map($no_faktur, 'id', 'no_faktur'); ?> <div class="surat-jalan-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create Surat Jalan', ['create'], ['class' => 'btn btn-success']); ?>
/** * @return \yii\db\ActiveQuery */ public function getFaktur0() { return $this->hasOne(Faktur::className(), ['id' => 'id_faktur']); }
/** * Finds the Faktur model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Faktur the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Faktur::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getFakturs() { return $this->hasMany(Faktur::className(), ['id_penjualan' => 'id']); }