/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Penjualan::find();
     $query->joinWith(['pembeli0']);
     $query->joinWith(['motor0']);
     $query->joinWith(['jenisMotor0']);
     // add conditions that should always apply here
     //var_dump($sql);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['nama_lengkap'] = ['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]];
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'id_motor' => $this->id_motor, 'tgl' => $this->tgl, 'harga' => $this->harga, 'nama' => $this->nama]);
     $query->andFilterWhere(['like', 'tipe_pembayaran', $this->tipe_pembayaran])->andFilterWhere(['like', 'nama_lengkap', $this->nama_lengkap])->andFilterWhere(['like', 'keterangan', $this->keterangan]);
     //->andFilterWhere(['like', 'nama', $this->motor0->jenisMotor0->nama]);
     //->andFilterWhere(['like', 'id_jenis', $this->jenisMotor0.nama]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\models\DataFisik */
/* @var $form yii\widgets\ActiveForm */
?>

<?php 
$sql = 'SELECT a.id, concat(a.id, " - ", a.no_faktur, " - ", date_format(a.tgl, "%d-%m-%Y")) as keterangan
FROM
faktur a
where a.id not in(Select id_faktur FROM data_fisik)';
$faktur = \app\models\Penjualan::findBySql($sql)->all();
$listData = \yii\helpers\ArrayHelper::map($faktur, 'id', 'keterangan');
?>

<div class="data-fisik-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
echo $form->field($model, 'id_faktur')->dropDownList($listData, ['prompt' => 'PILIH DATA FAKTUR ..']);
?>

    <?php 
echo $form->field($model, 'foto_ktp')->textInput(['maxlength' => true]);
?>
Ejemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPenjualan0()
 {
     return $this->hasOne(Penjualan::className(), ['id' => 'id_penjualan']);
 }
 /**
  * Finds the Penjualan model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Penjualan the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Penjualan::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }