75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace backend\models;
|
|
|
|
use Yii;
|
|
use yii\base\Model;
|
|
use yii\data\ActiveDataProvider;
|
|
use common\models\Procurement;
|
|
|
|
/**
|
|
* ProcurementSearch represents the model behind the search form about `common\models\Procurement`.
|
|
*/
|
|
class ProcurementSearch extends Procurement
|
|
{
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['id_procurement', 'id_warehouse', 'id_user', 'id_product', 'count', 'stock', 'purchase_price'], 'integer'],
|
|
[['description', 'created_at', 'updated_at'], 'safe'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function scenarios()
|
|
{
|
|
// bypass scenarios() implementation in the parent class
|
|
return Model::scenarios();
|
|
}
|
|
|
|
/**
|
|
* Creates data provider instance with search query applied
|
|
*
|
|
* @param array $params
|
|
*
|
|
* @return ActiveDataProvider
|
|
*/
|
|
public function search($params)
|
|
{
|
|
$query = Procurement::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([
|
|
'id_procurement' => $this->id_procurement,
|
|
'id_warehouse' => $this->id_warehouse,
|
|
'id_user' => $this->id_user,
|
|
'id_product' => $this->id_product,
|
|
'count' => $this->count,
|
|
'stock' => $this->stock,
|
|
'purchase_price' => $this->purchase_price,
|
|
'created_at' => $this->created_at,
|
|
'updated_at' => $this->updated_at,
|
|
]);
|
|
|
|
$query->andFilterWhere(['like', 'description', $this->description]);
|
|
|
|
return $dataProvider;
|
|
}
|
|
}
|