85 lines
1.8 KiB
PHP
85 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace frontend\models;
|
|
|
|
use common\models\DoorManagerLog;
|
|
use Yii;
|
|
use yii\base\Model;
|
|
use yii\data\ActiveDataProvider;
|
|
|
|
/**
|
|
* InventorySearch represents the model behind the search form about `common\models\Inventory`.
|
|
*/
|
|
class DoorManagerLogSearch extends DoorManagerLog
|
|
{
|
|
public $searchTerm;
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
['searchTerm','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 = DoorManagerLog::find();
|
|
|
|
$dataProvider = new ActiveDataProvider([
|
|
'query' => $query,
|
|
'sort' =>[
|
|
'defaultOrder' => [ 'created_at' => 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;
|
|
}
|
|
|
|
$query->orFilterWhere([
|
|
'like',
|
|
'ticket_type_name' , $this->searchTerm,
|
|
]);
|
|
|
|
$query->orFilterWhere([
|
|
'like',
|
|
'customer_name' , $this->searchTerm,
|
|
]);
|
|
|
|
$query->orFilterWhere([
|
|
'like',
|
|
'card_number' , $this->searchTerm,
|
|
]);
|
|
|
|
$query->orFilterWhere([
|
|
'like',
|
|
'key_number' , $this->searchTerm,
|
|
]);
|
|
|
|
return $dataProvider;
|
|
}
|
|
}
|