diff --git a/app/Controllers/Admin/SalesAgency.php b/app/Controllers/Admin/SalesAgency.php index ed75380..ef8f5f5 100644 --- a/app/Controllers/Admin/SalesAgency.php +++ b/app/Controllers/Admin/SalesAgency.php @@ -26,10 +26,49 @@ class SalesAgency extends BaseController return redirect()->to(work_area_home_url())->with('error', '지자체를 선택해 주세요.'); } - $list = $this->model->where('sa_lg_idx', $lgIdx)->orderForDisplay()->paginate(20); + $saKind = trim((string) ($this->request->getGet('sa_kind') ?? '')); + $saCode = trim((string) ($this->request->getGet('sa_code') ?? '')); + $saName = trim((string) ($this->request->getGet('sa_name') ?? '')); + $saIdx = trim((string) ($this->request->getGet('sa_idx') ?? '')); + + $builder = $this->model->where('sa_lg_idx', $lgIdx); + if ($saKind !== '') { + $builder->like('sa_kind', $saKind); + } + if ($saCode !== '') { + $builder->like('sa_code', $saCode); + } + if ($saName !== '') { + $builder->like('sa_name', $saName); + } + if ($saIdx !== '' && ctype_digit($saIdx)) { + $builder->where('sa_idx', (int) $saIdx); + } + + $list = $builder->orderForDisplay()->paginate(20); $pager = $this->model->pager; - return $this->renderWorkPage('판매 대행소 관리', 'admin/sales_agency/index', ['list' => $list, 'pager' => $pager]); + $queryForPager = [ + 'sa_kind' => $saKind, + 'sa_code' => $saCode, + 'sa_name' => $saName, + 'sa_idx' => $saIdx, + ]; + $queryForPager = array_filter($queryForPager, static fn ($v) => $v !== null && $v !== ''); + $pagerPath = mgmt_url('sales-agencies'); + if ($queryForPager !== []) { + $pagerPath .= '?' . http_build_query($queryForPager); + } + $pager->setPath($pagerPath); + + return $this->renderWorkPage('판매 대행소 관리', 'admin/sales_agency/index', [ + 'list' => $list, + 'pager' => $pager, + 'sa_kind' => $saKind, + 'sa_code' => $saCode, + 'sa_name' => $saName, + 'sa_idx' => $saIdx, + ]); } public function create() diff --git a/app/Views/admin/sales_agency/index.php b/app/Views/admin/sales_agency/index.php index c428c2b..1c9aac3 100644 --- a/app/Views/admin/sales_agency/index.php +++ b/app/Views/admin/sales_agency/index.php @@ -8,6 +8,30 @@ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + 초기화 +
+
+