支持工单功能(9/10)

支持获取待处理工代数量
修正查询逻辑
This commit is contained in:
Chenx221 2024-04-18 17:17:30 +08:00
parent 89d87fa4dc
commit a25f0ef32d
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021

View File

@ -64,7 +64,7 @@ class TicketsSearch extends Tickets
} }
// grid filtering conditions // grid filtering conditions
// if can user // if can admin
if(Yii::$app->user->can('admin')) { if(Yii::$app->user->can('admin')) {
$query->andFilterWhere([ $query->andFilterWhere([
'id' => $this->id, 'id' => $this->id,
@ -75,7 +75,7 @@ class TicketsSearch extends Tickets
]); ]);
} else{ } else{
$query->andFilterWhere([ $query->andFilterWhere([
'user_id' => $this->user_id, 'id' => $this->id,
'status' => $this->status, 'status' => $this->status,
'created_at' => $this->created_at, 'created_at' => $this->created_at,
'updated_at' => $this->updated_at, 'updated_at' => $this->updated_at,
@ -87,4 +87,14 @@ class TicketsSearch extends Tickets
return $dataProvider; return $dataProvider;
} }
/**
* give me the count of pending tickets
* @return bool|int|string|null
*/
public static function getPendingTicketsCount(): bool|int|string|null
{
//Tickets::STATUS_OPEN or Tickets::STATUS_USER_REPLY
return Tickets::find()->where(['status' => [Tickets::STATUS_OPEN, Tickets::STATUS_USER_REPLY]])->count();
}
} }