This commit is contained in:
@@ -1,58 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
use App\Models\common\MenuModel;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\CLIRequest;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class BaseController
|
||||
*
|
||||
* BaseController provides a convenient place for loading components
|
||||
* and performing functions that are needed by all your controllers.
|
||||
* Extend this class in any new controllers:
|
||||
* class Home extends BaseController
|
||||
*
|
||||
* For security be sure to declare any new methods as protected or private.
|
||||
*/
|
||||
abstract class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var CLIRequest|IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* An array of helpers to be loaded automatically upon
|
||||
* class instantiation. These helpers will be available
|
||||
* to all other controllers that extend BaseController.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $helpers = [];
|
||||
protected $session;
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* Be sure to declare properties for any property fetch you initialized.
|
||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||
*/
|
||||
// protected $session;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
public function initController($request, $response, $logger)
|
||||
{
|
||||
// Do Not Edit This Line
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
// Preload any models, libraries, etc, here.
|
||||
$this->session = \Config\Services::session();
|
||||
|
||||
// E.g.: $this->session = service('session');
|
||||
// 메뉴 전역 로딩
|
||||
$menuModel = new MenuModel();
|
||||
$menus = $menuModel->getMenuList();
|
||||
$this->data['menus'] = $menus["mainMenu"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
class Home extends BaseController
|
||||
{
|
||||
public function index(): string
|
||||
{
|
||||
return view('welcome_message');
|
||||
}
|
||||
|
||||
public function hello() : string {
|
||||
return 'hello111';
|
||||
}
|
||||
}
|
||||
164
app/Controllers/Login.php
Normal file
164
app/Controllers/Login.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\common\LoginModel;
|
||||
|
||||
class Login extends BaseController
|
||||
{
|
||||
private $loginModel;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->loginModel = new LoginModel();
|
||||
}
|
||||
|
||||
public function index(): string
|
||||
{
|
||||
return view('pages/login');
|
||||
}
|
||||
|
||||
// 로그인
|
||||
public function chkLogin()
|
||||
{
|
||||
$logs = [
|
||||
'usr_id' => $this->request->getPost('user_id'),
|
||||
'userIp' => $this->get_user_ip(),
|
||||
'userAgent' => $_SERVER['HTTP_USER_AGENT'] ?: '',
|
||||
];
|
||||
|
||||
try {
|
||||
|
||||
/** ------------------------------------
|
||||
* 1) 유효성 검사
|
||||
* ------------------------------------*/
|
||||
$rules = [
|
||||
'user_id' => [
|
||||
'rules' => 'required|min_length[4]|max_length[20]',
|
||||
'errors' => [
|
||||
'required' => '아이디를 입력해주세요.',
|
||||
'min_length' => '아이디는 최소 {param}자 이상이어야 합니다.',
|
||||
'max_length' => '아이디는 최대 {param}자까지 가능합니다.',
|
||||
],
|
||||
],
|
||||
'user_pw' => [
|
||||
'rules' => 'required|min_length[4]|max_length[30]',
|
||||
'errors' => [
|
||||
'required' => '비밀번호를 입력해주세요.',
|
||||
'min_length' => '비밀번호는 최소 {param}자 이상이어야 합니다.',
|
||||
'max_length' => '비밀번호는 최대 {param}자까지 가능합니다.',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if (!$this->validate($rules)) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '1',
|
||||
'errors' => $this->validator->getErrors()
|
||||
]);
|
||||
}
|
||||
|
||||
/** ------------------------------------
|
||||
* 2) 로그인 정보 조회
|
||||
* ------------------------------------*/
|
||||
$userId = $this->request->getPost('user_id');
|
||||
$userPw = $this->request->getPost('user_pw');
|
||||
|
||||
$this->loginModel = new LoginModel();
|
||||
$user = $this->loginModel->getUserByIdPw($userId, $userPw);
|
||||
|
||||
if (!$user) {
|
||||
$logs['results'] = 0;
|
||||
$logs['usr_sq'] = null;
|
||||
$logs['reason'] = '존재하지 않는 아이디입니다.';
|
||||
|
||||
$this->loginModel->insertUserLog($logs);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '1',
|
||||
'msg' => '존재하지 않는 아이디입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
if (strcmp($user['usr_pw'], $user['chk_pw']) !== 0) {
|
||||
$logs['results'] = 0;
|
||||
$logs['usr_sq'] = $user['usr_sq'];
|
||||
$logs['reason'] = '잘못된 비밀번호 입니다.';
|
||||
|
||||
$this->loginModel->insertUserLog($logs);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'code' => '1',
|
||||
'msg' => '잘못된 비밀번호 입니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------
|
||||
* 3) 세션 저장
|
||||
* ------------------------------------*/
|
||||
$newdata = [
|
||||
'usr_sq' => $user['usr_sq'],
|
||||
'usr_id' => $user['usr_id'],
|
||||
'usr_nm' => $user['usr_nm'],
|
||||
'dept_sq' => $user['dept_sq'],
|
||||
'dept_nm' => $user['dept_nm'],
|
||||
'bonbu_sq' => $user['bonbu_sq'],
|
||||
'bonbu_nm' => $user['bonbu_nm'],
|
||||
'usr_level' => $user['usr_level'],
|
||||
'depth' => $user['depth'],
|
||||
'logged_in' => true
|
||||
];
|
||||
|
||||
$logs['results'] = 1;
|
||||
$logs['usr_sq'] = $user['usr_sq'];
|
||||
$logs['reason'] = '로그인 성공';
|
||||
|
||||
$this->loginModel->insertUserLog($logs);
|
||||
|
||||
$this->session->set($newdata);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
/** ------------------------------------
|
||||
* 4) 예외발생 처리 (DB 오류, 세션 오류 등)
|
||||
* ------------------------------------*/
|
||||
log_message('error', '[LOGIN ERROR] ' . $e->getMessage());
|
||||
log_message('error', $e->getTraceAsString());
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => '서버 내부 오류가 발생했습니다. 잠시 후 다시 시도해주세요.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function out()
|
||||
{
|
||||
$this->session->destroy();
|
||||
return redirect()->to('/login');
|
||||
}
|
||||
|
||||
|
||||
private function get_user_ip()
|
||||
{
|
||||
$ip_address = '';
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$ip_address = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
// Check for multiple IPs in the header, take the first one (most likely the client)
|
||||
$ip_address = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])[0];
|
||||
} else {
|
||||
$ip_address = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
return $ip_address;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
use mysqli;
|
||||
|
||||
class Main extends BaseController
|
||||
{
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public function dashboard() : string
|
||||
{
|
||||
return view('pages/dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
298
app/Controllers/board/Notice.php
Normal file
298
app/Controllers/board/Notice.php
Normal file
@@ -0,0 +1,298 @@
|
||||
<?php
|
||||
namespace App\Controllers\board;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\board\NoticeModel;
|
||||
|
||||
class Notice extends BaseController
|
||||
{
|
||||
private $notice;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->notice = new NoticeModel();
|
||||
}
|
||||
|
||||
public function notice(): string
|
||||
{
|
||||
return view('pages/board/notice');
|
||||
}
|
||||
|
||||
|
||||
public function getNoticeList()
|
||||
{
|
||||
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
|
||||
$data = [
|
||||
'srchType' => $this->request->getGet('srchType') ?: '',
|
||||
'srchTxt' => $this->request->getGet('srchTxt') ?: '',
|
||||
];
|
||||
|
||||
$totalCount = $this->notice->getTotalCount($data);
|
||||
|
||||
|
||||
$datas = $this->notice->getNoticeList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 공지사항 상세
|
||||
public function detail($id = null)
|
||||
{
|
||||
$id = (int) $id;
|
||||
|
||||
if ($id <= 0) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
// 데이터 조회
|
||||
$data = $this->notice->getNoticeData($id);
|
||||
|
||||
if (!$data) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
return view('pages/board/noticeDetail', $data);
|
||||
}
|
||||
|
||||
// 첨부파일 다운로드
|
||||
public function download($fileSq = null)
|
||||
{
|
||||
$fileSq = (int) $fileSq;
|
||||
|
||||
if ($fileSq <= 0) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
// 1) DB에서 파일 정보 조회
|
||||
$fileInfo = $this->notice->getFile($fileSq);
|
||||
|
||||
if (!$fileInfo) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
// DB에 이렇게 저장했다고 가정:
|
||||
// file_path : /var/www/html/writable/upload/notice
|
||||
// file_name : 실제 서버 파일명 (orig or new)
|
||||
|
||||
// dd($fileInfo);
|
||||
|
||||
$filePath = rtrim($fileInfo['file_path'], '/\\') . DIRECTORY_SEPARATOR . $fileInfo['file_name'];
|
||||
|
||||
if (!is_file($filePath)) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
// 브라우저에 보여줄 다운로드 파일명 (원본 이름)
|
||||
$downloadName = $fileInfo['orig_name'];
|
||||
|
||||
// 2) CI4 내장 다운로드 헬퍼 사용
|
||||
return $this->response->download($filePath, null)->setFileName($downloadName);
|
||||
}
|
||||
|
||||
|
||||
// 공지사항 작성 화면
|
||||
public function write(): string
|
||||
{
|
||||
return view('pages/board/noticeWrite');
|
||||
}
|
||||
|
||||
// 공지사항 작성
|
||||
public function actWrite()
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
$data = [
|
||||
'subject' => $this->request->getPost('subject'),
|
||||
'content' => $this->request->getPost('content'),
|
||||
'insert_usr' => session()->get('usr_id'),
|
||||
'insert_nm' => session()->get('usr_nm'),
|
||||
];
|
||||
|
||||
|
||||
|
||||
$file = $this->request->getFile('file');
|
||||
|
||||
if ($file && $file->isValid() && !$file->hasMoved()) {
|
||||
$origName = $file->getClientName();
|
||||
$ext = $file->getClientExtension();
|
||||
$size = $file->getSize();
|
||||
$mime = $file->getMimeType();
|
||||
$type = $file->getClientMimeType();
|
||||
$tempName = $file->getTempName();
|
||||
$imgYn = (strpos($mime, 'image/') === 0) ? 'Y' : 'N';
|
||||
|
||||
// 저장 경로
|
||||
$saveDir = WRITEPATH . 'upload/notice';
|
||||
if (!is_dir($saveDir)) {
|
||||
mkdir($saveDir, 0777, true);
|
||||
}
|
||||
|
||||
// 서버 저장 이름 (덮어쓰기 방지를 위해 랜덤으로 추천)
|
||||
$newName = $file->getRandomName();
|
||||
$file->move($saveDir, $newName);
|
||||
|
||||
// 모델로 넘길 파일 정보
|
||||
$data['file'] = [
|
||||
'orig_name' => $origName,
|
||||
'new_name' => $newName,
|
||||
'file_path' => $saveDir,
|
||||
'ext' => $ext,
|
||||
'size' => $size,
|
||||
'img_yn' => $imgYn,
|
||||
'img_height' => null,
|
||||
'img_width' => null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$result = $this->notice->write($data);
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', '[LOGIN ERROR] ' . $e->getMessage());
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 공지사항 수정
|
||||
public function modify($id = null): string
|
||||
{
|
||||
|
||||
$id = (int) $id;
|
||||
|
||||
|
||||
if ($id <= 0) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
// 데이터 조회
|
||||
$data = $this->notice->getNoticeData($id);
|
||||
|
||||
if (!$data) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
|
||||
return view('pages/board/noticeModify', $data);
|
||||
|
||||
}
|
||||
|
||||
// 공지사항 수정요청
|
||||
public function actModify()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'bbs_sq' => $this->request->getPost('bbs_sq'),
|
||||
'subject' => $this->request->getPost('subject'),
|
||||
'content' => $this->request->getPost('content'),
|
||||
'update_usr' => session()->get('usr_id'),
|
||||
'update_nm' => session()->get('usr_nm'),
|
||||
];
|
||||
|
||||
|
||||
|
||||
$file = $this->request->getFile('file');
|
||||
|
||||
if ($file && $file->isValid() && !$file->hasMoved()) {
|
||||
$origName = $file->getClientName();
|
||||
$ext = $file->getClientExtension();
|
||||
$size = $file->getSize();
|
||||
$mime = $file->getMimeType(); // ★ move() 전에!
|
||||
$type = $file->getClientMimeType();
|
||||
$tempName = $file->getTempName();
|
||||
$imgYn = (strpos($mime, 'image/') === 0) ? 'Y' : 'N';
|
||||
|
||||
// 저장 경로
|
||||
$saveDir = WRITEPATH . 'upload/notice';
|
||||
if (!is_dir($saveDir)) {
|
||||
mkdir($saveDir, 0777, true);
|
||||
}
|
||||
|
||||
// 서버 저장 이름 (덮어쓰기 방지를 위해 랜덤으로 추천)
|
||||
$newName = $file->getRandomName();
|
||||
$file->move($saveDir, $newName);
|
||||
|
||||
// 모델로 넘길 파일 정보
|
||||
$data['file'] = [
|
||||
'file_sq' => $this->request->getPost('file_sq'),
|
||||
'orig_name' => $origName,
|
||||
'new_name' => $newName,
|
||||
'file_path' => $saveDir, // 필요에 따라 상대경로로만 저장
|
||||
'ext' => $ext,
|
||||
'size' => $size,
|
||||
'img_yn' => $imgYn,
|
||||
// 높이/폭은 나중에 getimagesize 등으로 구해도 됨
|
||||
'img_height' => null,
|
||||
'img_width' => null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$result = $this->notice->modify($data);
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', '[LOGIN ERROR] ' . $e->getMessage());
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 공지사항 삭제요청
|
||||
public function actRemove()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'bbs_sq' => $this->request->getPost('bbs_sq'),
|
||||
'update_usr' => session()->get('usr_id'),
|
||||
'update_nm' => session()->get('usr_nm'),
|
||||
];
|
||||
|
||||
$this->notice->remove($data);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', '[LOGIN ERROR] ' . $e->getMessage());
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
app/Controllers/home/Home.php
Normal file
45
app/Controllers/home/Home.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\home;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\Home\HomeModel;
|
||||
|
||||
class Home extends BaseController
|
||||
{
|
||||
private $homeModel;
|
||||
|
||||
private $sdate = '';
|
||||
private $edate = '';
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->sdate = date('Y-m-d', strtotime('-1 month'));
|
||||
$this->edate = date('Y-m-d');
|
||||
|
||||
$this->homeModel = new HomeModel();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function dashboard(): string
|
||||
{
|
||||
|
||||
$notice = $this->homeModel->getNoticeList();
|
||||
$statistics = $this->homeModel->getHomeStatistics($this->sdate, $this->edate);
|
||||
|
||||
|
||||
return view('pages/home/dashboard', [
|
||||
'menus' => $this->data,
|
||||
'notice' => $notice,
|
||||
'statistics' => $statistics,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
188
app/Controllers/listfax/ListFax.php
Normal file
188
app/Controllers/listfax/ListFax.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
namespace App\Controllers\listfax;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Libraries\Common;
|
||||
use App\Models\listfax\ListFaxModel;
|
||||
|
||||
|
||||
class ListFax extends BaseController
|
||||
{
|
||||
|
||||
private $todo = ''; // 검색, 엑셀다운 구분
|
||||
private $menuid = ''; // 레프트메뉴아이디
|
||||
|
||||
private $page = ''; // 현재페이지
|
||||
private $pagesize = ''; // 페이징 개수
|
||||
|
||||
private $atcl_no = ''; // 매물번호
|
||||
private $stat_cd = ''; // 현재상태
|
||||
private $chk_atcl_no = ''; // 매물번호 입력/미입력 구분
|
||||
private $realtor_nm = ''; // 중개소
|
||||
private $recv_stime = ''; // 수신기간(시간)
|
||||
private $recv_etime = ''; // 수신기간(시간)
|
||||
private $complete_stime = ''; // 처리기간(전송)
|
||||
private $complete_etime = ''; // 처리기간(전송)
|
||||
private $sido = ''; // 시도
|
||||
private $gugun = ''; // 시군구
|
||||
private $dong = ''; // 읍면동
|
||||
private $target_yn = ''; // 작업대상여부(정상여부)
|
||||
private $cpid = ''; // 매체사(CP)ID
|
||||
private $caller_no = ''; // 발신번호
|
||||
private $charger = ''; // 담당자
|
||||
private $charger_gbn = ''; // 담당구분 1: 서류/전화, 2: 등기부등본
|
||||
private $dept1_sq = ''; // 본부
|
||||
private $dept2_sq = ''; // 팀
|
||||
private $assign_yn = ''; // 배정여부 1: 배정, 2: 미배정
|
||||
private $checking = '0'; // 조회여부 확인
|
||||
|
||||
private $pars = [];
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->initParams();
|
||||
}
|
||||
|
||||
|
||||
public function initParams()
|
||||
{
|
||||
// parent::__construct();
|
||||
|
||||
$this->todo = $this->request->getGet('todo', TRUE);
|
||||
$this->menuid = $this->request->getGet('m', TRUE);
|
||||
|
||||
$this->page = $this->request->getGet('page', TRUE);
|
||||
$this->pagesize = $this->request->getGet('pagesize', TRUE);
|
||||
|
||||
if (empty($this->todo)) {
|
||||
$this->todo = 'inq';
|
||||
}
|
||||
|
||||
$this->atcl_no = $this->request->getGet('atcl_no', TRUE);
|
||||
$this->stat_cd = $this->request->getGet('stat_cd', TRUE);
|
||||
$this->chk_atcl_no = $this->request->getGet('chk_atcl_no', TRUE);
|
||||
$this->realtor_nm = $this->request->getGet('realtor_nm', TRUE);
|
||||
$this->recv_stime = $this->request->getGet('recv_stime', TRUE);
|
||||
$this->recv_etime = $this->request->getGet('recv_etime', TRUE);
|
||||
$this->complete_stime = $this->request->getGet('complete_stime', TRUE);
|
||||
$this->complete_etime = $this->request->getGet('complete_etime', TRUE);
|
||||
$this->sido = $this->request->getGet('sido', TRUE);
|
||||
$this->gugun = $this->request->getGet('gugun', TRUE);
|
||||
$this->dong = $this->request->getGet('dong', TRUE);
|
||||
$this->target_yn = $this->request->getGet('target_yn', TRUE);
|
||||
$this->cpid = $this->request->getGet('cpid', TRUE);
|
||||
$this->caller_no = $this->request->getGet('caller_no', TRUE);
|
||||
$this->charger = $this->request->getGet('charger', TRUE);
|
||||
$this->charger_gbn = $this->request->getGet('charger_gbn', TRUE);
|
||||
$this->dept1_sq = $this->request->getGet('dept1_sq', TRUE);
|
||||
$this->dept2_sq = $this->request->getGet('dept2_sq', TRUE);
|
||||
$this->assign_yn = $this->request->getGet('assign_yn', TRUE);
|
||||
$this->checking = $this->request->getGet('checking', TRUE);
|
||||
|
||||
// 기본 선택 - 기본값을 수신시간을 당일로 처리한다.
|
||||
$toDay = date('Y-m-d');
|
||||
if (empty($this->recv_stime))
|
||||
$this->recv_stime = date("Y-m-d", strtotime("-7 days")) . ' 00:00:00';
|
||||
if (empty($this->recv_etime))
|
||||
$this->recv_etime = $toDay . ' 23:59:59';
|
||||
|
||||
if (empty($this->assign_yn))
|
||||
$this->assign_yn = 'A';
|
||||
|
||||
$this->pars = array(
|
||||
'm' => $this->menuid,
|
||||
'todo' => $this->todo,
|
||||
'page' => $this->page,
|
||||
'pagesize' => $this->pagesize,
|
||||
|
||||
'atcl_no' => $this->atcl_no,
|
||||
'stat_cd' => $this->stat_cd,
|
||||
'chk_atcl_no' => $this->chk_atcl_no,
|
||||
'realtor_nm' => $this->realtor_nm,
|
||||
'recv_stime' => $this->recv_stime,
|
||||
'recv_etime' => $this->recv_etime,
|
||||
'complete_stime' => $this->complete_stime,
|
||||
'complete_etime' => $this->complete_etime,
|
||||
'sido' => $this->sido,
|
||||
'gugun' => $this->gugun,
|
||||
'dong' => $this->dong,
|
||||
'target_yn' => $this->target_yn,
|
||||
'cpid' => $this->cpid,
|
||||
'caller_no' => $this->caller_no,
|
||||
'charger' => $this->charger,
|
||||
'charger_gbn' => $this->charger_gbn,
|
||||
'dept1_sq' => $this->dept1_sq,
|
||||
'dept2_sq' => $this->dept2_sq,
|
||||
'assign_yn' => $this->assign_yn,
|
||||
'checking' => $this->checking,
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 홍보확인서 팩스 목록
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
// CI3 __construct 대체
|
||||
$this->initParams();
|
||||
|
||||
// CI3: $base_uri = '/listfax/listfax/lists';
|
||||
$base_uri = '/listfax/listfax/lists';
|
||||
|
||||
// CI3: $this->load->model('v2/listfax_model', 'listfax_model');
|
||||
$listfaxModel = new ListFaxModel();
|
||||
|
||||
// CI3: $this->load->helper('array_helper');
|
||||
helper(filenames: 'array'); // array_helper => array 로 이름 바꿨다면 이렇게
|
||||
|
||||
// CI3: $this->load->library('common');
|
||||
$common = new Common();
|
||||
|
||||
// checking 값에 따라 조회 여부 결정
|
||||
if ($this->pars['checking'] === '0') {
|
||||
$resultData = [
|
||||
'data' => [],
|
||||
'total' => 0,
|
||||
];
|
||||
} else {
|
||||
$resultData = $listfaxModel->getLists(
|
||||
$this->todo,
|
||||
$this->page,
|
||||
$this->pagesize,
|
||||
$this->recv_stime,
|
||||
$this->recv_etime,
|
||||
$this->caller_no
|
||||
);
|
||||
}
|
||||
|
||||
// total 기본값 처리
|
||||
if (!isset($resultData['total'])) {
|
||||
$resultData['total'] = 0;
|
||||
}
|
||||
|
||||
// 페이지네이션 (기존 common 라이브러리 그대로 사용)
|
||||
$pagination = $common->make_pagenation(
|
||||
$base_uri,
|
||||
$this->pars,
|
||||
$resultData['total'],
|
||||
$this->page,
|
||||
$this->pagesize
|
||||
);
|
||||
|
||||
$data = [
|
||||
'pars' => $this->pars,
|
||||
'dataList' => $resultData['data'] ?? [],
|
||||
'total' => $resultData['total'],
|
||||
'pagination' => $pagination,
|
||||
];
|
||||
|
||||
// BaseController에서 메뉴 등 공통 $this->data 세팅했다면 같이 합쳐서 넘겨도 됨
|
||||
// return view('listfax/listfax/lists', array_merge($this->data, $data));
|
||||
return view('listfax/listfax/lists', $data);
|
||||
}
|
||||
|
||||
}
|
||||
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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
225
app/Controllers/manage/Menu.php
Normal file
225
app/Controllers/manage/Menu.php
Normal file
@@ -0,0 +1,225 @@
|
||||
<?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,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// private function buildTree(array $items, $parentId = 'ROOT', int $level = 0): array
|
||||
// {
|
||||
// $branch = [];
|
||||
|
||||
// $lft = 1;
|
||||
// foreach ($items as $k => $item) {
|
||||
|
||||
// // 현재 parentId의 자식인지 확인
|
||||
// if ($item['mnu_pid'] === $parentId) {
|
||||
|
||||
// $item['lft'] = $lft;
|
||||
|
||||
// if ($item['mnu_tp'] === 'R') {
|
||||
// $item['isLeaf'] = false;
|
||||
// $item['rgt'] = 1 + (63 * 2 + 1);
|
||||
// } else if ($item['mnu_tp'] === 'D') {
|
||||
// $item['level'] = 1;
|
||||
// $item['menu_tp'] = 'D';
|
||||
// $item['menu_tp_nm'] = '디렉토리';
|
||||
// $item['iconCls'] = 'ui-icon-folder-open';
|
||||
|
||||
// $subCnt = 0;
|
||||
// foreach ($items as $item2):
|
||||
|
||||
// if (strpos($item2['mnu_id'], $item['mnu_id'] . '.') === 0) {
|
||||
// $subCnt++;
|
||||
// }
|
||||
|
||||
// endforeach;
|
||||
|
||||
// $item['rgt'] = $lft + ($subCnt * 2) + 1;
|
||||
|
||||
// if ($subCnt === 0) {
|
||||
// $item['isLeaf'] = true;
|
||||
// } else {
|
||||
// $item['isLeaf'] = false;
|
||||
// }
|
||||
|
||||
// } else if ($item['mnu_tp'] == 'P') {
|
||||
// $item['level'] = 2;
|
||||
// $item['menu_tp'] = 'R';
|
||||
// $item['menu_tp_nm'] = '화면';
|
||||
// $item['iconCls'] = 'ui-icon-document';
|
||||
// }
|
||||
// // else {
|
||||
// // // 예: 루트 R 같은 경우
|
||||
// // $item['menu_tp'] = $item['mnu_tp'];
|
||||
// // $item['menu_tp_nm'] = ($item['mnu_tp'] === 'R') ? '루트' : '메뉴';
|
||||
// // $item['iconCls'] = 'ui-icon-home';
|
||||
// // }
|
||||
|
||||
// // 자식 찾기 (⚠️ 여기 반드시 $this->buildTree)
|
||||
// // $children = $this->buildTree($items, $item['mnu_id'], $level + 1);
|
||||
|
||||
// // if (!empty($children)) {
|
||||
// // // 자식 정렬 (view_odr → mnu_id 순)
|
||||
// // usort($children, function ($a, $b) {
|
||||
// // $ao = $a['view_odr'] ?? 0;
|
||||
// // $bo = $b['view_odr'] ?? 0;
|
||||
|
||||
// // if ($ao == $bo) {
|
||||
// // return strcmp($a['mnu_id'], $b['mnu_id']);
|
||||
// // }
|
||||
// // return $ao <=> $bo;
|
||||
// // });
|
||||
|
||||
// // $item['children'] = $children;
|
||||
// // }
|
||||
|
||||
// $branch[] = $item;
|
||||
// }
|
||||
|
||||
// $lft++;
|
||||
// }
|
||||
|
||||
// // 현재 레벨도 정렬 (view_odr → mnu_id 순)
|
||||
// usort($branch, function ($a, $b) {
|
||||
// $ao = $a['view_odr'] ?? 0;
|
||||
// $bo = $b['view_odr'] ?? 0;
|
||||
|
||||
// if ($ao == $bo) {
|
||||
// return strcmp($a['mnu_id'], $b['mnu_id']);
|
||||
// }
|
||||
// return $ao <=> $bo;
|
||||
// });
|
||||
|
||||
// return $branch;
|
||||
// }
|
||||
|
||||
}
|
||||
115
app/Controllers/manage/Phone.php
Normal file
115
app/Controllers/manage/Phone.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?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 = [
|
||||
'srchTxt' => $this->request->getGet('search[value]') ?: '',
|
||||
];
|
||||
|
||||
$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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 연락처 유효성검사
|
||||
private function validPhone($phone)
|
||||
{
|
||||
if (preg_match('/^01[0-9]-?\d{3,4}-?\d{4}$/', $phone)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
183
app/Controllers/manage/User.php
Normal file
183
app/Controllers/manage/User.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 엑셀다운로드
|
||||
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