Фильтр по продуктам в списке отчётов

This commit is contained in:
n1rwana 2022-08-21 23:48:12 +03:00
parent 5f32b6e837
commit f41df39b0f
2 changed files with 8 additions and 4 deletions

View file

@ -38,9 +38,11 @@ class BugtrackerReports
yield new BugReport($report);
}
function getReportsCount(): int
function getReportsCount(int $product_id): int
{
return sizeof($this->reports->where(["deleted" => NULL]));
return $product_id
? sizeof($this->reports->where(["deleted" => NULL, "product_id" => $product_id]))
: sizeof($this->reports->where(["deleted" => NULL]));
}
function getByReporter(int $reporter_id, int $page = 1): \Traversable

View file

@ -39,8 +39,10 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->template->count = $this->reports->getCountByReporter((int) $this->queryParam("id"));
} else {
$this->template->page = (int) ($this->queryParam("p") ?? 1);
$this->template->count = $this->reports->getReportsCount(0);
$this->template->iterator = $this->reports->getAllReports($this->template->page);
$this->template->count = $this->reports->getReportsCount((int) $this->queryParam("product"));
$this->template->iterator = $this->queryParam("product")
? $this->reports->getReports((int) $this->queryParam("product"), $this->template->page)
: $this->reports->getAllReports($this->template->page);
}
$this->template->canAdminBugTracker = $this->user->identity->getChandlerUser()->can("admin")->model('openvk\Web\Models\Repositories\BugtrackerReports')->whichBelongsTo(NULL);