update thống kê
This commit is contained in:
@@ -10,23 +10,25 @@ use app\models\Logs;
|
||||
/**
|
||||
* LogsSearch represents the model behind the search form of `app\models\Logs`.
|
||||
*/
|
||||
class LogsSearch extends Logs
|
||||
{
|
||||
class LogsSearch extends Logs {
|
||||
|
||||
public $staff_name;
|
||||
public $staff_department;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
public function rules() {
|
||||
return [
|
||||
[['id', 'staff_id', 'device_id', 'door_id', 'in_out_state', 'time', 'event_type'], 'integer'],
|
||||
[['id', 'staff_id', 'device_id', 'in_out_state', 'event_type', 'card_number', 'staff_department'], 'integer'],
|
||||
[['staff_name'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
public function scenarios() {
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
@@ -38,9 +40,9 @@ class LogsSearch extends Logs
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
public function search($params) {
|
||||
$query = Logs::find();
|
||||
$query->joinWith("staff");
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
@@ -56,6 +58,11 @@ class LogsSearch extends Logs
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
if ($this->staff_name)
|
||||
$query->andFilterWhere(['LIKE', 'name', $this->staff_name]);
|
||||
if ($this->staff_department)
|
||||
$query->andFilterWhere(['department_id' => $this->staff_department]);
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
@@ -69,4 +76,5 @@ class LogsSearch extends Logs
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user