컨트롤러수정
This commit is contained in:
160
app/Controllers/Manage/Areas.php
Normal file
160
app/Controllers/Manage/Areas.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
namespace App\Controllers\manage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\manage\AreasModel;
|
||||
|
||||
class Areas extends BaseController
|
||||
{
|
||||
private $areaModel;
|
||||
public function __construct()
|
||||
{
|
||||
$this->areaModel = new AreasModel();
|
||||
}
|
||||
|
||||
// 지역코드조회
|
||||
public function getAreaList()
|
||||
{
|
||||
$sido = $this->request->getPost('srcSido');
|
||||
$gugun = $this->request->getPost('srcGugun');
|
||||
|
||||
|
||||
$datas = $this->areaModel->getAreaList($sido, $gugun);
|
||||
|
||||
return $this->response->setJson($datas);
|
||||
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
{
|
||||
|
||||
$sido = $this->areaModel->getAreaList();
|
||||
$bonbu = $this->areaModel->getBonbuList();
|
||||
$team = $this->areaModel->getTeamList();
|
||||
$user = $this->areaModel->getUserList();
|
||||
|
||||
return view("pages/manage/areas/lists", [
|
||||
'sido' => $sido,
|
||||
'bonbu' => $bonbu,
|
||||
'team' => $team,
|
||||
'user' => $user,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function getSvcArea()
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
|
||||
$srcSido = $this->request->getGet('srcSido'); // 시도
|
||||
$srcGugun = $this->request->getGet('srcGugun'); // 시도
|
||||
$srcDong = $this->request->getGet('srcDong'); // 시도
|
||||
|
||||
$region = "";
|
||||
if (!empty($srcDong)) {
|
||||
$region = substr($srcDong, 0, 8);
|
||||
} else if (!empty($srcGugun)) {
|
||||
$region = substr($srcGugun, 0, 5);
|
||||
if (substr($region, 4) == "0") {
|
||||
$region = substr($srcGugun, 0, 4);
|
||||
}
|
||||
} else if (!empty($srcSido)) {
|
||||
$region = substr($srcSido, 0, 2);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'region' => $region, // 지역코드
|
||||
'srcUserbonbu' => $this->request->getGet('srcUserbonbu'), // 본부
|
||||
'srcUserteam' => $this->request->getGet('srcUserteam'), // 팀
|
||||
'positionYn' => $this->request->getGet('positionYn'), // 지정유무
|
||||
];
|
||||
|
||||
$totalCount = $this->areaModel->getTotalCount($data);
|
||||
$datas = $this->areaModel->getSvcArea($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
// 지역관리정보저장
|
||||
public function saveRegion()
|
||||
{
|
||||
try {
|
||||
|
||||
$json = $this->request->getJSON(true); // true = 배열로 반환
|
||||
|
||||
if (!$json) {
|
||||
return $this->response->setJSON([
|
||||
'status' => 'error',
|
||||
'msg' => '데이터 누락'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
foreach ($json as $row) {
|
||||
$regioncd = $row['region_cd'];
|
||||
$bonbu = $row['bonbu'];
|
||||
$team = $row['team'];
|
||||
$user = $row['user'];
|
||||
|
||||
// UPDATE region_codes
|
||||
$this->areaModel->saveRegion($regioncd, $team, $user);
|
||||
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function saveAllRegion()
|
||||
{
|
||||
try {
|
||||
|
||||
$json = $this->request->getJSON(true); // true = 배열로 반환
|
||||
|
||||
if (!$json) {
|
||||
return $this->response->setJSON([
|
||||
'status' => 'error',
|
||||
'msg' => '데이터 누락'
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($json as $row) {
|
||||
$regioncd = $row['region_cd'];
|
||||
$bonbu = $row['bonbu'];
|
||||
$team = $row['team'];
|
||||
$user = $row['user'];
|
||||
|
||||
// UPDATE region_codes
|
||||
$this->areaModel->saveRegion($regioncd, $team, $user);
|
||||
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
137
app/Controllers/Manage/Dept.php
Normal file
137
app/Controllers/Manage/Dept.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
namespace App\Controllers\manage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\manage\DeptModel;
|
||||
|
||||
class Dept extends BaseController
|
||||
{
|
||||
|
||||
private $deptModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->deptModel = new DeptModel();
|
||||
}
|
||||
|
||||
|
||||
public function dept(): string
|
||||
{
|
||||
return view("pages/manage/dept/lists");
|
||||
}
|
||||
|
||||
// 총괄팀장 페이지
|
||||
public function getchkuser(): string
|
||||
{
|
||||
return view("pages/manage/dept/users");
|
||||
}
|
||||
|
||||
public function getDeptList()
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
|
||||
$data = [
|
||||
'srchDepth' => $this->request->getGet('srchDepth') ?: '',
|
||||
'srcDeptNm' => $this->request->getGet('srcDeptNm') ?: '',
|
||||
'srcDeptHead' => $this->request->getGet('srcDeptHead') ?: '',
|
||||
'useYn' => $this->request->getGet('useYn') ?: '',
|
||||
];
|
||||
|
||||
$totalCount = $this->deptModel->getTotalCount($data);
|
||||
|
||||
|
||||
$datas = $this->deptModel->getDeptList($start, $end, $data);
|
||||
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 유저목록 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
|
||||
$totalCount = $this->deptModel->getUserCount();
|
||||
|
||||
|
||||
$datas = $this->deptModel->getUserList($start, $end);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
// 상위조직 조회
|
||||
public function getPdept()
|
||||
{
|
||||
|
||||
$datas = $this->deptModel->getPdept();
|
||||
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
// 조직정보 저장
|
||||
public function saveDept()
|
||||
{
|
||||
try {
|
||||
|
||||
$type = $this->request->getPost('type');
|
||||
|
||||
if ($type == "create") {
|
||||
$data = [
|
||||
$this->request->getPost("addPdept"), // 상위조직
|
||||
$this->request->getPost("addDeptNm"), // 조직명칭
|
||||
$this->request->getPost("addDeptDesc"), // 부서설명
|
||||
$this->request->getPost("addDeptHead"), // 총괄팀장
|
||||
$this->request->getPost(index: "addUseYn"), // 사용여부
|
||||
$this->request->getPost(index: "addDepth"), // 조직구분
|
||||
session('usr_sq'),
|
||||
session('usr_sq'),
|
||||
];
|
||||
|
||||
// INSERT departments
|
||||
$this->deptModel->insertDept($data);
|
||||
|
||||
} else if ($type == "update") {
|
||||
|
||||
$data = [
|
||||
$this->request->getPost("pdept_sq"),
|
||||
$this->request->getPost("addDeptNm"), // 조직명칭
|
||||
$this->request->getPost("addDeptDesc"), // 부서설명
|
||||
$this->request->getPost("addDeptHead"), // 총괄팀장
|
||||
$this->request->getPost("addUseYn"), // 사용여부
|
||||
$this->request->getPost("addDepth"), // 조직구분
|
||||
session('usr_sq'),
|
||||
$this->request->getPost("dept_sq"),
|
||||
];
|
||||
|
||||
// UPDATE departments
|
||||
$this->deptModel->updateDept($data);
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
56
app/Controllers/Manage/LoginLog.php
Normal file
56
app/Controllers/Manage/LoginLog.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace App\Controllers\manage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\manage\LoginLogModel;
|
||||
|
||||
|
||||
class LoginLog extends BaseController
|
||||
{
|
||||
private $logModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logModel = new LoginLogModel();
|
||||
}
|
||||
|
||||
public function lists()
|
||||
{
|
||||
return view("pages/manage/log/lists");
|
||||
}
|
||||
|
||||
public function getLogList()
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
|
||||
$data = [
|
||||
'srchTxt' => $this->request->getGet('search[value]') ?: '',
|
||||
];
|
||||
|
||||
$totalCount = $this->logModel->getTotalCount($data);
|
||||
|
||||
|
||||
$datas = $this->logModel->getLoginLogList($start, $end, $data);
|
||||
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
public function excel()
|
||||
{
|
||||
$data = [
|
||||
'srchTxt' => $this->request->getGet('search[value]') ?: '',
|
||||
];
|
||||
|
||||
$datas = $this->logModel->getExcelDownList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
}
|
||||
168
app/Controllers/Manage/Menu.php
Normal file
168
app/Controllers/Manage/Menu.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
namespace App\Controllers\manage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\manage\MenuModel;
|
||||
|
||||
class Menu extends BaseController
|
||||
{
|
||||
private $menuModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->menuModel = new MenuModel();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
{
|
||||
return view("pages/manage/menu/lists");
|
||||
}
|
||||
|
||||
|
||||
// 메뉴목록조회
|
||||
public function getMenuList()
|
||||
{
|
||||
$params = [];
|
||||
|
||||
|
||||
$total = $this->menuModel->getTotalCount();
|
||||
$datas = $this->menuModel->getMenuList($params);
|
||||
|
||||
$lft = 1;
|
||||
|
||||
if (!empty($datas)) {
|
||||
foreach ($datas as $k => $v) {
|
||||
|
||||
$menuTp = $v['mnu_tp'];
|
||||
$menuCd = $v['mnu_id'];
|
||||
$menuPid = $v['mnu_pid'];
|
||||
|
||||
// lft
|
||||
$datas[$k]['lft'] = $lft;
|
||||
|
||||
// ROOT vs 나머지 level 계산 (지금처럼 코드 길이 쓰고 싶으면 기존 로직 유지 가능)
|
||||
if ($menuPid === 'ROOT') {
|
||||
$datas[$k]['level'] = "0";
|
||||
$datas[$k]['parentLv'] = "";
|
||||
$datas[$k]['expanded'] = true;
|
||||
} else {
|
||||
// 예: "M" 제거 후 길이 기반
|
||||
$levelStr = str_replace('M', '', $menuCd);
|
||||
$len = strlen($levelStr);
|
||||
if ($len === 1 || $len === 2)
|
||||
$datas[$k]['level'] = "1";
|
||||
else
|
||||
$datas[$k]['level'] = "2"; // 필요시 더 세분화
|
||||
}
|
||||
|
||||
// 아이콘
|
||||
switch ($menuTp) {
|
||||
case "A":
|
||||
$datas[$k]['iconCls'] = "ui-icon-play";
|
||||
break;
|
||||
case "P":
|
||||
$datas[$k]['iconCls'] = "ui-icon-document";
|
||||
break;
|
||||
case "D":
|
||||
$datas[$k]['iconCls'] = "ui-icon-folder-open";
|
||||
break;
|
||||
}
|
||||
|
||||
if ($menuTp === 'A') {
|
||||
// 액션
|
||||
$datas[$k]['isLeaf'] = true;
|
||||
$datas[$k]['rgt'] = $lft + 1;
|
||||
$lft++;
|
||||
|
||||
} elseif ($menuTp === 'P') {
|
||||
// 화면: 내 자식은 mnu_pid == 내 mnu_id
|
||||
$subCnt = 0;
|
||||
foreach ($datas as $v2) {
|
||||
if ($v2['mnu_pid'] === $menuCd) {
|
||||
$subCnt++;
|
||||
}
|
||||
}
|
||||
|
||||
$datas[$k]['rgt'] = $lft + ($subCnt * 2) + 1;
|
||||
|
||||
if ($subCnt === 0) {
|
||||
$datas[$k]['isLeaf'] = true;
|
||||
$lft++;
|
||||
} else {
|
||||
$datas[$k]['isLeaf'] = false;
|
||||
}
|
||||
|
||||
} elseif ($menuTp === 'D') {
|
||||
// 디렉토리: 코드 prefix 로 자식/후손 판단 (자바와 동일)
|
||||
$subCnt = 0;
|
||||
foreach ($datas as $v2) {
|
||||
$subMenuCd = $v2['mnu_id'];
|
||||
if (strpos($subMenuCd, $menuCd) === 0) {
|
||||
$subCnt++;
|
||||
}
|
||||
}
|
||||
|
||||
$datas[$k]['rgt'] = $lft + ($subCnt * 2) + 1;
|
||||
|
||||
if ($subCnt === 0) {
|
||||
$datas[$k]['isLeaf'] = true;
|
||||
$lft++;
|
||||
} else {
|
||||
$datas[$k]['isLeaf'] = false;
|
||||
}
|
||||
|
||||
} elseif ($menuTp === 'R') {
|
||||
// 루트
|
||||
$datas[$k]['isLeaf'] = false;
|
||||
$datas[$k]['rgt'] = 1 + ($total * 2) + 1;
|
||||
}
|
||||
|
||||
$lft++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// $datas = $this->buildTree($datas);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'total' => $total,
|
||||
'rows' => $datas,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 메뉴정보저장
|
||||
public function saveMenu()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'mnu_pid' => $this->request->getPost('mnu_pid'),
|
||||
'mnu_id' => $this->request->getPost('mnu_id'),
|
||||
'mnu_nm' => $this->request->getPost('mnu_nm'),
|
||||
'mnu_url' => $this->request->getPost('mnu_url'),
|
||||
'mnu_tp' => $this->request->getPost('mnu_tp'),
|
||||
'view_odr' => $this->request->getPost('view_odr'),
|
||||
'use_yn' => $this->request->getPost('use_yn'),
|
||||
'usr_sq' => session('usr_sq'),
|
||||
];
|
||||
|
||||
|
||||
// INSERT UPDATE menu
|
||||
$this->menuModel->saveMenu($data);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
104
app/Controllers/Manage/Permit.php
Normal file
104
app/Controllers/Manage/Permit.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
namespace App\Controllers\manage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\manage\PermitModel;
|
||||
|
||||
class Permit extends BaseController
|
||||
{
|
||||
|
||||
private $permitModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->permitModel = new PermitModel();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
{
|
||||
$usrLevel = $this->permitModel->getUsrLevel();
|
||||
|
||||
return view("pages/manage/permit/lists", [
|
||||
'usrLevel' => $usrLevel,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 메뉴권한목록조회
|
||||
public function getMenuAuthList()
|
||||
{
|
||||
$usrLevel = $this->request->getGet('usr_level');
|
||||
|
||||
$lists = $this->permitModel->getMenuAuthList($usrLevel);
|
||||
|
||||
if (!empty($lists)) {
|
||||
foreach ($lists as $k => $d) {
|
||||
$state = [];
|
||||
|
||||
if ($d['state'] === "selected") {
|
||||
$state['selected'] = true;
|
||||
$lists[$k]['state'] = $state;
|
||||
} else {
|
||||
$state['selected'] = false;
|
||||
$lists[$k]['state'] = $state;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response->setJSON($lists);
|
||||
}
|
||||
|
||||
|
||||
// 메뉴권한정보저장
|
||||
public function saveMenuAuth()
|
||||
{
|
||||
try {
|
||||
$usrLevel = $this->request->getPost('usr_level');
|
||||
|
||||
if (empty($usrLevel)) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '1',
|
||||
'msg' => '그룹 데이터 누락'
|
||||
]);
|
||||
}
|
||||
|
||||
$menuArr = explode(',', $this->request->getPost('mnu_cd'));
|
||||
if (empty($menuArr)) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '1',
|
||||
'msg' => '메뉴 데이터 누락'
|
||||
]);
|
||||
} else {
|
||||
|
||||
// DELETE menu_perms
|
||||
$this->permitModel->deleteMenuPermit($usrLevel);
|
||||
|
||||
foreach ($menuArr as $m) {
|
||||
|
||||
$data = [
|
||||
'mnuId' => $m,
|
||||
'usrLevel' => $usrLevel,
|
||||
'usrSq' => session('usr_sq'),
|
||||
];
|
||||
|
||||
// INSERT menu_perms
|
||||
$this->permitModel->saveMenuAuth($data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
146
app/Controllers/Manage/Phone.php
Normal file
146
app/Controllers/Manage/Phone.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
namespace App\Controllers\manage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\manage\PhoneModel;
|
||||
|
||||
|
||||
|
||||
class Phone extends BaseController
|
||||
{
|
||||
private $phoneModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->phoneModel = new PhoneModel();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
{
|
||||
$codes = $this->phoneModel->getCodes();
|
||||
|
||||
return view("pages/manage/phone/lists", ['code' => $codes]);
|
||||
}
|
||||
|
||||
// 전화확인 목록조회
|
||||
public function getDuplPhoneList()
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
|
||||
$data = [
|
||||
'cpid' => $this->request->getGet('cpid') ?: '',
|
||||
's_date' => $this->request->getGet('s_date') ?: '',
|
||||
'e_date' => $this->request->getGet('e_date') ?: '',
|
||||
'phone' => $this->request->getGet('phone') ?: '',
|
||||
'useYn' => $this->request->getGet('useYn') ?: '',
|
||||
];
|
||||
|
||||
$totalCount = $this->phoneModel->getTotalCount($data);
|
||||
$datas = $this->phoneModel->getDuplPhoneList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 전화정보 저장
|
||||
public function savePhone()
|
||||
{
|
||||
try {
|
||||
|
||||
if ($this->validPhone($this->request->getPost('phone_number'))) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '1',
|
||||
'msg' => '유효하지 않은 연락처'
|
||||
]);
|
||||
}
|
||||
|
||||
$type = $this->request->getPost('type');
|
||||
$data = [
|
||||
$this->request->getPost('phone_number'), // 연락처
|
||||
$this->request->getPost('use_yn'),
|
||||
$this->request->getPost('s_date'),
|
||||
$this->request->getPost('e_date'),
|
||||
$this->request->getPost('address'),
|
||||
$this->request->getPost('owner'),
|
||||
$this->request->getPost('applicant'),
|
||||
$this->request->getPost('relation'),
|
||||
$this->request->getPost('cpid'),
|
||||
$this->request->getPost(index: 'memo'),
|
||||
session('usr_id'),
|
||||
];
|
||||
|
||||
if ($type === "create") {
|
||||
|
||||
// INSERT dupl_phone_list
|
||||
$this->phoneModel->insertDuplPhone($data);
|
||||
|
||||
} else if ($type === "update") {
|
||||
|
||||
array_push($data, $this->request->getPost("phone_number"));
|
||||
|
||||
// UPDATE dupl_phone_list
|
||||
$this->phoneModel->updateDuplPhone($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 엑셀다운로드
|
||||
public function excel()
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'cpid' => $this->request->getGet('cpid') ?: '',
|
||||
's_date' => $this->request->getGet('s_date') ?: '',
|
||||
'e_date' => $this->request->getGet('e_date') ?: '',
|
||||
'phone' => $this->request->getGet('phone') ?: '',
|
||||
'useYn' => $this->request->getGet('useYn') ?: '',
|
||||
];
|
||||
|
||||
$datas = $this->phoneModel->getExcelPhoneList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 연락처 유효성검사
|
||||
private function validPhone($phone)
|
||||
{
|
||||
if (preg_match('/^01[0-9]-?\d{3,4}-?\d{4}$/', $phone)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
120
app/Controllers/Manage/Scomplex.php
Normal file
120
app/Controllers/Manage/Scomplex.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
namespace App\Controllers\manage;
|
||||
|
||||
use App\Controllers\BASeController;
|
||||
use App\Models\manage\ScomplexModel;
|
||||
|
||||
class Scomplex extends BASeController
|
||||
{
|
||||
private $model;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new ScomplexModel();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
{
|
||||
$codes = $this->model->getCodeList();
|
||||
|
||||
return view("pages/manage/scomplex/lists", ['code' => $codes,]);
|
||||
}
|
||||
|
||||
|
||||
public function getScomplexList()
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
|
||||
$data = [
|
||||
'name' => $this->request->getGet('name'), // 단지명
|
||||
'apporval_date' => $this->request->getGet('apporval_date'), // 사용승인일
|
||||
'end_date' => $this->request->getGet('end_date'), // 승인종료일
|
||||
'code' => $this->request->getGet('code'), // 단지코드
|
||||
'cd' => $this->request->getGet('cd'), // 매물종류
|
||||
'address' => $this->request->getGet('address'), // 주소
|
||||
];
|
||||
|
||||
$totalCount = $this->model->getTotalCount($data);
|
||||
$datas = $this->model->getScomplexList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 특이단지 정보 저장
|
||||
public function saveScomplex()
|
||||
{
|
||||
try {
|
||||
|
||||
$type = $this->request->getPost('type');
|
||||
|
||||
$data = [
|
||||
$this->request->getPost('sm_name'),
|
||||
$this->request->getPost('sm_code'),
|
||||
$this->request->getPost('sm_address'),
|
||||
$this->request->getPost('codes'),
|
||||
$this->request->getPost('sm_apporval_date'),
|
||||
$this->request->getPost('sm_end_date'),
|
||||
$this->request->getPost('sm_memo'),
|
||||
session('usr_sq'),
|
||||
];
|
||||
|
||||
|
||||
if ($type === "create") {
|
||||
// INSERT scomplex_manage
|
||||
$this->model->insertScomplex($data);
|
||||
|
||||
} else if ($type === "update") {
|
||||
array_push($data, $this->request->getPost('sm_seq'));
|
||||
|
||||
// UPDATE scomplex_manage
|
||||
$this->model->updateScomplex($data);
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 엑셀다운로드
|
||||
public function excel()
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'name' => $this->request->getGet('name'), // 단지명
|
||||
'apporval_date' => $this->request->getGet('apporval_date'), // 사용승인일
|
||||
'end_date' => $this->request->getGet('end_date'), // 승인종료일
|
||||
'code' => $this->request->getGet('code'), // 단지코드
|
||||
'cd' => $this->request->getGet('cd'), // 매물종류
|
||||
'address' => $this->request->getGet('address'), // 주소
|
||||
];
|
||||
|
||||
$datas = $this->model->getExcelScomplexList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
105
app/Controllers/Manage/Sms.php
Normal file
105
app/Controllers/Manage/Sms.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
namespace App\Controllers\manage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\manage\SmsModel;
|
||||
|
||||
class Sms extends BaseController
|
||||
{
|
||||
private $smsModel;
|
||||
public function __construct()
|
||||
{
|
||||
$this->smsModel = new SmsModel();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
{
|
||||
return view("pages/manage/sms/lists");
|
||||
}
|
||||
|
||||
|
||||
public function getSmsList()
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
|
||||
$data = [
|
||||
'start_dt' => $this->request->getGet('start_dt'),
|
||||
'end_dt' => $this->request->getGet('end_dt'),
|
||||
'srchType' => $this->request->getGet('srchType'),
|
||||
'srchTxt' => $this->request->getGet('srchTxt'),
|
||||
];
|
||||
|
||||
$totalCount = $this->smsModel->getTotalCount($data);
|
||||
$datas = $this->smsModel->getSmsList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
// 엑셀다운로드 - 내역
|
||||
public function excel()
|
||||
{
|
||||
$data = [
|
||||
'start_dt' => $this->request->getGet('start_dt'),
|
||||
'end_dt' => $this->request->getGet('end_dt'),
|
||||
'srchType' => $this->request->getGet('srchType'),
|
||||
'srchTxt' => $this->request->getGet('srchTxt'),
|
||||
];
|
||||
|
||||
$datas = $this->smsModel->getExcelList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// sms 발송 - 화면
|
||||
public function smsSendView(): string
|
||||
{
|
||||
return view("pages/manage/sms/smsSendView");
|
||||
}
|
||||
|
||||
|
||||
// sms 발송
|
||||
public function sendSms()
|
||||
{
|
||||
try {
|
||||
|
||||
$msgType = $this->request->getPost('msg_type');
|
||||
$body = $this->request->getPost('msg_body');
|
||||
$len = strlen(iconv('UTF-8', 'EUCKR', $body));
|
||||
|
||||
$data = [
|
||||
'dest_phone' => $this->request->getPost('dest_phone'),
|
||||
'dest_name' => $this->request->getPost('dest_name'),
|
||||
'send_phone' => $this->request->getPost('send_phone'),
|
||||
'send_name' => $this->request->getPost('send_name'),
|
||||
'subject' => '문자발송',
|
||||
'msg_body' => $this->request->getPost('msg_body'),
|
||||
'msg_type' => $len > 80 && $msgType == 0 ? "5" : $msgType,
|
||||
'ect2' => 'S12',
|
||||
'etc3' => $this->request->getPost('memo'),
|
||||
];
|
||||
|
||||
$this->smsModel->sendSms($data);
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
207
app/Controllers/Manage/User.php
Normal file
207
app/Controllers/Manage/User.php
Normal file
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
namespace App\Controllers\manage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\manage\UserModel;
|
||||
|
||||
class User extends BaseController
|
||||
{
|
||||
private $userModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->userModel = new UserModel();
|
||||
}
|
||||
|
||||
public function user(): string
|
||||
{
|
||||
|
||||
$userLevel = $this->userModel->getUserLevel();
|
||||
$bonbuList = $this->userModel->getBonbuList();
|
||||
$teamList = $this->userModel->getTeamList();
|
||||
$deptCode = $this->userModel->getDeptCode();
|
||||
|
||||
return view("pages/manage/user/lists", [
|
||||
'userLevel' => $userLevel,
|
||||
'bonbuList' => $bonbuList,
|
||||
'teamList' => $teamList,
|
||||
'deptCode' => $deptCode,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function getUserList()
|
||||
{
|
||||
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
|
||||
$data = [
|
||||
'srchLevel' => $this->request->getGet('srchLevel') ?: '',
|
||||
'srchBonbu' => $this->request->getGet('srchBonbu') ?: '',
|
||||
'srchTeam' => $this->request->getGet('srchTeam') ?: '',
|
||||
'useYn' => $this->request->getGet('useYn') ?: '',
|
||||
'srchType' => $this->request->getGet('srchType') ?: '',
|
||||
'srchTxt' => $this->request->getGet('srchTxt') ?: '',
|
||||
];
|
||||
|
||||
$totalCount = $this->userModel->getTotalCount($data);
|
||||
|
||||
|
||||
$datas = $this->userModel->getUserList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 유저정보저장
|
||||
public function saveUser()
|
||||
{
|
||||
try {
|
||||
|
||||
$type = $this->request->getPost('type');
|
||||
|
||||
|
||||
|
||||
if ($type == 'create') {
|
||||
|
||||
$data = [
|
||||
$this->request->getPost('addUserId'), // 아이디
|
||||
$this->request->getPost('addUserPswd') ?: '', // 비밀번호
|
||||
$this->request->getPost('addUserDept'), // 소속조직
|
||||
$this->request->getPost('addUserNm'), // 이름
|
||||
$this->request->getPost('addUserLevel'), // 등급
|
||||
$this->request->getPost('addUserPosition'), // 직급
|
||||
$this->request->getPost('addUserTel1') ?: '', // 연락처
|
||||
$this->request->getPost('addUserTel2') ?: '', // 연락처2
|
||||
$this->request->getPost('addUserAddr1'), // 주소
|
||||
$this->request->getPost('addUserAddr2'), // 상세주소
|
||||
session('usr_sq'), // 저장유저
|
||||
$this->request->getPost('addUseYn'), // 사용여부
|
||||
$this->request->getPost('addSmsYn'), // SMS 인증여부
|
||||
|
||||
];
|
||||
|
||||
// INSERT users
|
||||
$this->userModel->insertUser($data);
|
||||
|
||||
|
||||
} else if ($type == 'update') {
|
||||
|
||||
$addUserPswd = trim($this->request->getPost('addUserPswd') ?? '');
|
||||
$usrSq = $this->request->getPost('usr_sq'); // hidden으로 넘어오는 PK라고 가정
|
||||
|
||||
$data = [
|
||||
$this->request->getPost('addUserNm'), // usr_nm
|
||||
$this->request->getPost('addUserDept'), // dept_sq
|
||||
$this->request->getPost('addUserLevel'), // usr_level
|
||||
$this->request->getPost('addUserPosition'), // usr_position
|
||||
$this->request->getPost('addUserTel1') ?: '', // usr_tel1
|
||||
$this->request->getPost('addUserTel2') ?: '', // usr_tel2
|
||||
$this->request->getPost('addUserAddr1'), // usr_addr1
|
||||
$this->request->getPost('addUserAddr2'), // usr_addr2
|
||||
session('usr_sq'), // update_usr
|
||||
$this->request->getPost('addUseYn'), // use_yn
|
||||
$this->request->getPost('addSmsYn'), // sms_auth_yn
|
||||
];
|
||||
|
||||
// 비번/PK 같이 넘김
|
||||
$this->userModel->updateUser($data, $addUserPswd, $usrSq);
|
||||
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 유저 삭제
|
||||
public function removeuser()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
session('usr_sq'),
|
||||
$this->request->getPost('usr_sq')
|
||||
];
|
||||
|
||||
|
||||
$this->userModel->removeUser($data);
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SMS 인증여부 일괄저장
|
||||
public function saveSms()
|
||||
{
|
||||
try {
|
||||
|
||||
$useYn = $this->request->getPost('useYn') ?: 'Y';
|
||||
|
||||
// UPDATE users
|
||||
$this->userModel->updateUserSmsYn($useYn);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 엑셀다운로드
|
||||
public function excel()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'srchLevel' => $this->request->getGet('srchLevl') ?: '',
|
||||
'srchBonbu' => $this->request->getGet('srchBonbu') ?: '',
|
||||
'srchTeam' => $this->request->getGet('srchTeam') ?: '',
|
||||
'useYn' => $this->request->getGet('useYn') ?: '',
|
||||
'srchType' => $this->request->getGet('srchType') ?: '',
|
||||
'srchTxt' => $this->request->getGet('srchTxt') ?: '',
|
||||
'addSmsYn' => $this->request->getPost('addSmsYn'),
|
||||
];
|
||||
|
||||
$datas = $this->userModel->getExcelUserList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user