Example #1
0
 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TransferModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['date' => SORT_DESC]], 'pagination' => ['pagesize' => 10]]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('1=0');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'branch_id' => $this->branch_id, 'branch_dest_id' => $this->branch_dest_id, 'date' => $this->date, 'status' => $this->status, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'number', $this->number]);
     return $dataProvider;
 }
Example #2
0
use yii\helpers\Html;
use yii\grid\GridView;
use backend\models\inventory\Transfer;
use backend\models\inventory\search\Transfer as TransferSearch;
use backend\models\master\Branch;
/* @var $this yii\web\View */
/* @var $searchModel TransferSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Transfer';
$this->params['breadcrumbs'][] = $this->title;
?>
<p class='pull-right'>
    <?php 
echo Html::a('Create Transfer', ['create'], ['class' => 'btn btn-default']);
?>
</p>
<br>

<div class="transfer-index">

    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>


    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'tableOptions' => ['class' => 'table table-hover'], 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'number', ['attribute' => 'branch_id', 'value' => 'branch.name', 'filter' => Branch::selectOptions()], ['attribute' => 'branch_dest_id', 'value' => 'branchDest.name', 'filter' => Branch::selectOptions()], ['attribute' => 'Date'], ['attribute' => 'status', 'value' => 'nmStatus', 'filter' => Transfer::enums('STATUS_')], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTransfer()
 {
     return $this->hasOne(Transfer::className(), ['id' => 'transfer_id']);
 }
 /**
  * Finds the Transfer model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Transfer the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Transfer::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }