feat: improve admin master data management
This commit is contained in:
@@ -39,7 +39,7 @@ class DesignatedShop extends BaseController
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
|
||||
if ($lgIdx === null || $lgIdx <= 0) {
|
||||
return redirect()->to(site_url('admin'))
|
||||
return redirect()->to(work_area_home_url())
|
||||
->with('error', '작업할 지자체가 선택되지 않았습니다. 지자체를 선택해 주세요.');
|
||||
}
|
||||
|
||||
@@ -73,17 +73,14 @@ class DesignatedShop extends BaseController
|
||||
$db = \Config\Database::connect();
|
||||
$gugunCodes = $db->query("SELECT DISTINCT ds_gugun_code FROM designated_shop WHERE ds_lg_idx = ? AND ds_gugun_code != '' ORDER BY ds_gugun_code", [$lgIdx])->getResult();
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '지정판매소 관리',
|
||||
'content' => view('admin/designated_shop/index', [
|
||||
'list' => $list,
|
||||
'lgMap' => $lgMap,
|
||||
'pager' => $pager,
|
||||
'dsName' => $dsName ?? '',
|
||||
'dsGugunCode' => $dsGugunCode ?? '',
|
||||
'dsState' => $dsState ?? '',
|
||||
'gugunCodes' => $gugunCodes,
|
||||
]),
|
||||
return $this->renderWorkPage('지정판매소 관리', 'admin/designated_shop/index', [
|
||||
'list' => $list,
|
||||
'lgMap' => $lgMap,
|
||||
'pager' => $pager,
|
||||
'dsName' => $dsName ?? '',
|
||||
'dsGugunCode' => $dsGugunCode ?? '',
|
||||
'dsState' => $dsState ?? '',
|
||||
'gugunCodes' => $gugunCodes,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -92,7 +89,7 @@ class DesignatedShop extends BaseController
|
||||
helper(['admin', 'export']);
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
if (!$lgIdx) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))->with('error', '지자체를 선택해 주세요.');
|
||||
return redirect()->to(mgmt_url('designated-shops'))->with('error', '지자체를 선택해 주세요.');
|
||||
}
|
||||
|
||||
$list = $this->shopModel->where('ds_lg_idx', $lgIdx)->orderBy('ds_idx', 'DESC')->findAll();
|
||||
@@ -129,22 +126,19 @@ class DesignatedShop extends BaseController
|
||||
helper('admin');
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
if ($lgIdx === null || $lgIdx <= 0) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '작업할 지자체가 선택되지 않았습니다. 지자체를 선택해 주세요.');
|
||||
}
|
||||
|
||||
$currentLg = $this->lgModel->find($lgIdx);
|
||||
if ($currentLg === null) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '선택한 지자체 정보를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '지정판매소 등록',
|
||||
'content' => view('admin/designated_shop/create', [
|
||||
'localGovs' => [],
|
||||
'currentLg' => $currentLg,
|
||||
]),
|
||||
return $this->renderWorkPage('지정판매소 등록', 'admin/designated_shop/create', [
|
||||
'localGovs' => [],
|
||||
'currentLg' => $currentLg,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -154,7 +148,7 @@ class DesignatedShop extends BaseController
|
||||
public function store()
|
||||
{
|
||||
if (! $this->isSuperAdmin() && ! $this->isLocalAdmin()) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '지정판매소 등록은 관리자만 가능합니다.');
|
||||
}
|
||||
|
||||
@@ -211,7 +205,7 @@ class DesignatedShop extends BaseController
|
||||
|
||||
$this->shopModel->insert($data);
|
||||
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('success', '지정판매소가 등록되었습니다.');
|
||||
}
|
||||
|
||||
@@ -222,31 +216,28 @@ class DesignatedShop extends BaseController
|
||||
public function edit(int $id)
|
||||
{
|
||||
if (! $this->isSuperAdmin() && ! $this->isLocalAdmin()) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '권한이 없습니다.');
|
||||
}
|
||||
|
||||
helper('admin');
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
if ($lgIdx === null || $lgIdx <= 0) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '작업할 지자체가 선택되지 않았습니다.');
|
||||
}
|
||||
|
||||
$shop = $this->shopModel->find($id);
|
||||
if ($shop === null || (int) $shop->ds_lg_idx !== $lgIdx) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '해당 지정판매소를 찾을 수 없거나 수정할 수 없습니다.');
|
||||
}
|
||||
|
||||
$currentLg = $this->lgModel->find($lgIdx);
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '지정판매소 수정',
|
||||
'content' => view('admin/designated_shop/edit', [
|
||||
'shop' => $shop,
|
||||
'currentLg' => $currentLg,
|
||||
]),
|
||||
return $this->renderWorkPage('지정판매소 수정', 'admin/designated_shop/edit', [
|
||||
'shop' => $shop,
|
||||
'currentLg' => $currentLg,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -256,20 +247,20 @@ class DesignatedShop extends BaseController
|
||||
public function update(int $id)
|
||||
{
|
||||
if (! $this->isSuperAdmin() && ! $this->isLocalAdmin()) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '권한이 없습니다.');
|
||||
}
|
||||
|
||||
helper('admin');
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
if ($lgIdx === null || $lgIdx <= 0) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '작업할 지자체가 선택되지 않았습니다.');
|
||||
}
|
||||
|
||||
$shop = $this->shopModel->find($id);
|
||||
if ($shop === null || (int) $shop->ds_lg_idx !== $lgIdx) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '해당 지정판매소를 찾을 수 없거나 수정할 수 없습니다.');
|
||||
}
|
||||
|
||||
@@ -305,7 +296,7 @@ class DesignatedShop extends BaseController
|
||||
|
||||
$this->shopModel->update($id, $data);
|
||||
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('success', '지정판매소 정보가 수정되었습니다.');
|
||||
}
|
||||
|
||||
@@ -316,26 +307,26 @@ class DesignatedShop extends BaseController
|
||||
public function delete(int $id)
|
||||
{
|
||||
if (! $this->isSuperAdmin() && ! $this->isLocalAdmin()) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '권한이 없습니다.');
|
||||
}
|
||||
|
||||
helper('admin');
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
if ($lgIdx === null || $lgIdx <= 0) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '작업할 지자체가 선택되지 않았습니다.');
|
||||
}
|
||||
|
||||
$shop = $this->shopModel->find($id);
|
||||
if ($shop === null || (int) $shop->ds_lg_idx !== $lgIdx) {
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('error', '해당 지정판매소를 찾을 수 없거나 삭제할 수 없습니다.');
|
||||
}
|
||||
|
||||
$this->shopModel->delete($id);
|
||||
|
||||
return redirect()->to(site_url('admin/designated-shops'))
|
||||
return redirect()->to(mgmt_url('designated-shops'))
|
||||
->with('success', '지정판매소가 삭제되었습니다.');
|
||||
}
|
||||
|
||||
@@ -347,7 +338,7 @@ class DesignatedShop extends BaseController
|
||||
helper('admin');
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
if ($lgIdx === null || $lgIdx <= 0) {
|
||||
return redirect()->to(site_url('admin'))
|
||||
return redirect()->to(work_area_home_url())
|
||||
->with('error', '작업할 지자체가 선택되지 않았습니다.');
|
||||
}
|
||||
|
||||
@@ -356,11 +347,8 @@ class DesignatedShop extends BaseController
|
||||
->where('ds_state', 1)
|
||||
->findAll();
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '지정판매소 지도',
|
||||
'content' => view('admin/designated_shop/map', [
|
||||
'shops' => $shops,
|
||||
]),
|
||||
return $this->renderWorkPage('지정판매소 지도', 'admin/designated_shop/map', [
|
||||
'shops' => $shops,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -372,7 +360,7 @@ class DesignatedShop extends BaseController
|
||||
helper('admin');
|
||||
$lgIdx = admin_effective_lg_idx();
|
||||
if ($lgIdx === null || $lgIdx <= 0) {
|
||||
return redirect()->to(site_url('admin'))
|
||||
return redirect()->to(work_area_home_url())
|
||||
->with('error', '작업할 지자체가 선택되지 않았습니다.');
|
||||
}
|
||||
|
||||
@@ -400,14 +388,11 @@ class DesignatedShop extends BaseController
|
||||
$totalActive = $this->shopModel->where('ds_lg_idx', $lgIdx)->where('ds_state', 1)->countAllResults(false);
|
||||
$totalInactive = $this->shopModel->where('ds_lg_idx', $lgIdx)->where('ds_state !=', 1)->countAllResults(false);
|
||||
|
||||
return view('admin/layout', [
|
||||
'title' => '지정판매소 현황',
|
||||
'content' => view('admin/designated_shop/status', [
|
||||
'newByYear' => $newByYear,
|
||||
'cancelByYear' => $cancelByYear,
|
||||
'totalActive' => $totalActive,
|
||||
'totalInactive' => $totalInactive,
|
||||
]),
|
||||
return $this->renderWorkPage('지정판매소 현황', 'admin/designated_shop/status', [
|
||||
'newByYear' => $newByYear,
|
||||
'cancelByYear' => $cancelByYear,
|
||||
'totalActive' => $totalActive,
|
||||
'totalInactive' => $totalInactive,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user