<?php defined('BASEPATH') OR exit('No direct script access allowed');
header("Content-Type: text/html; charset=UTF-8");
/**
 * 인클루드 class
 *
 * cm_controller: 부모 Class(CI_Controller 확장한 custome class)
 */
include_once(APPPATH.'core/admin/cm_controller.php');

class cs extends cm_Controller {

    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 1:1문의 list
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_question_list() {
        # request
	    $page                   = $this->uri->segment(5);
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $search_click1          = trim($this->input->get_post('search_click1', TRUE));
        $search_click2          = trim($this->input->get_post('search_click2', TRUE));

        # paging 설정
        if($page == '') $page = 1;
        $limit  = PAGE_SIZE;
        $offset = ($page-1) * $limit;

        # 검색
        $req_data['search_type']            = $search_type;
        $req_data['search_keyword']         = addslashes($search_keyword);
        $req_data['search_click1']          = $search_click1;
        $req_data['search_click2']          = $search_click2;


        $req_data['offset']                 = $offset;
        $req_data['limit']                  = $limit;

	    # model - 카테고리 list
        $this->load->model('admin/cs/m_bbs_question');
        $total_count        = $this->m_bbs_question->bbs_question_list_total_count($req_data);
        $result             = $this->m_bbs_question->bbs_question_list($req_data);

        $new_count          =  $this->m_bbs_question->bbs_question_new_count($req_data);
        $is_reply_count     =  $this->m_bbs_question->bbs_question_group_by_is_reply($req_data);

        $arr_is_reply_count = array();
        foreach($is_reply_count as $val) {
            $arr_is_reply_count[$val['is_reply']] = $val['cnt'];
        }

        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/cs/cs_question_list/7' ;
        $req_data['suffix']         = '?'.$_SERVER['QUERY_STRING'];

        $this->load->library('comm_admin');
        $pagination = $this->comm_admin->fn_pagination($req_data);


        # view data
		$return_data['pagination']	        = $pagination;
        $return_data['page']                = $page;
        $return_data['limit']               = $limit;
        $return_data['total_count']         = $total_count;
        $return_data['search_type']         = $search_type;
        $return_data['search_keyword']      = $search_keyword;
        $return_data['list']                = $result;
        $return_data['new_count']           = $new_count;
        $return_data['arr_is_reply_count']  = $arr_is_reply_count;
        $return_data['search_click1']       = $search_click1;
        $return_data['search_click2']       = $search_click2;

        # view
        return $this->load->view('/admin/cs/cs_question_list', $return_data, true);

    }

    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 1:1문의 reply add
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_question_reply_add() {
	    # request
	    $page                   = trim($this->input->get_post('page', TRUE));;
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));

        # model
        $this->load->model('admin/cs/m_bbs_question');
        $return_data    = $this->m_bbs_question->bbs_question_select($idx);
        if(count($return_data) == 0) {
            gf_alert("잘못된 접근입니다.", '/admin/main');
        }

        # view data
		$return_data['page']                = $page;
        $return_data['search_type']         = $search_type;
        $return_data['search_keyword']      = $search_keyword;
        $return_data['idx']                 = $idx;
        $return_data['result']              = $return_data[0];

        # view
        return $this->load->view('/admin/cs/cs_question_reply_add', $return_data, true);

    }




    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 1:1문의 reply add - 저장
    # CREATE  :	2018-02-21
    #---------------------------------------------------------------------------
	function fn_cs_question_reply_add_proc() {
        # request
        $page                   = trim($this->input->get_post('page', TRUE));;
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $title                  = trim($this->input->get_post('title', TRUE));
        $content                = trim($this->input->get_post('content', FALSE));


        # model
        $this->load->model('admin/cs/m_bbs_question');

        # select
        $result = $this->m_bbs_question->bbs_question_select($idx);
        if(count($result)==0) {
            gf_alert("저장에 실패했습니다. 다시시도해 주세요.", '/admin/cs/cs_question_list/7');
            exit;
        }
        $member_id = $result[0]['member_id'];

        $req_data = array();
        $req_data['p_idx']      = $idx;
        $req_data['title']      = $title;
        $req_data['content']    = $content;
        $req_data['member_id']  = $member_id;

        # insert
        $result1 = $this->m_bbs_question->bbs_question_reply_insert($req_data);
        if(!$result1) {
            gf_alert("저장에 실패했습니다. 다시시도해 주세요.", '/admin/cs/cs_question_list/7');
            exit;
        }

        # is_reply update
        $this->m_bbs_question->bbs_question_is_reply_update($idx);


        gf_alert("등록되었습니다.", '/admin/cs/cs_question_list/7');

    }

    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 1:1문의 reply 삭제 - 저장
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_question_reply_del_proc() {
        # request
        $idx                    = trim($this->input->get_post('idx', TRUE));

        $req_date[] = $idx;

        # model - update
        $this->load->model('admin/cs/m_bbs_question');
        $this->m_bbs_question->bbs_question_is_del_update($req_date);

        gf_alert("삭제되었습니다.", '/admin/cs/cs_question_list/7');

    }




    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 1:1문의 reply 삭제 - 저장 (다중)
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_question_reply_arr_del_proc() {
        # request
        $arr_idx    = $this->input->get_post('is_del', TRUE);   // 삭제할 idx

        # model - update
        $this->load->model('admin/cs/m_bbs_question');
        $this->m_bbs_question->bbs_question_is_del_update($arr_idx);

        gf_alert("삭제되었습니다.", '/admin/cs/cs_question_list/7');

    }



    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 1:1문의 view
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_question_view() {
	    # request
	    $page                   = trim($this->input->get_post('page', TRUE));;
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $search_is_reply        = trim($this->input->get_post('search_is_reply', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));

        # model
        $this->load->model('admin/cs/m_bbs_question');
        $return_data    = $this->m_bbs_question->bbs_question_select($idx);
        if(count($return_data) == 0) {
            gf_alert("잘못된 접근입니다.", '/admin/main');
        }

        # view data
		$return_data['page']                = $page;
        $return_data['search_type']         = $search_type;
        $return_data['search_keyword']      = $search_keyword;
        $return_data['search_is_reply']     = $search_is_reply;
        $return_data['idx']                 = $idx;
        $return_data['result']              = $return_data[0];

        # view
        return $this->load->view('/admin/cs/cs_question_view', $return_data, true);

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 공지사항 list
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_notice_list() {
        # request
	    $page                   = $this->uri->segment(5);
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $search_click           = trim($this->input->get_post('search_click', TRUE));

        # paging 설정
        if($page == '') $page = 1;
        $limit  = PAGE_SIZE;
        $offset = ($page-1) * $limit;

        # 검색
        $req_data['search_type']            = $search_type;
        $req_data['search_keyword']         = addslashes($search_keyword);
        $req_data['search_click']           = $search_click;
        $req_data['offset']                 = $offset;
        $req_data['limit']                  = $limit;

	    # model - 카테고리 list
        $this->load->model('admin/cs/m_bbs_notice');
        $total_count        = $this->m_bbs_notice->bbs_notice_list_total_count($req_data);
        $result             = $this->m_bbs_notice->bbs_notice_list($req_data);
        $new_count          = $this->m_bbs_notice->bbs_notice_new_count();


        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/cs/cs_notice_list/7' ;
        $req_data['suffix']         = '?'.$_SERVER['QUERY_STRING'];

        $this->load->library('comm_admin');
        $pagination = $this->comm_admin->fn_pagination($req_data);

        # view data
		$return_data['pagination']	        = $pagination;
        $return_data['page']                = $page;
        $return_data['limit']               = $limit;
        $return_data['total_count']         = $total_count;
        $return_data['search_type']         = $search_type;
        $return_data['search_keyword']      = $search_keyword;
        $return_data['search_click']        = $search_click;
        $return_data['list']                = $result;
        $return_data['new_count']           = $new_count;

        # view
        return $this->load->view('/admin/cs/cs_notice_list', $return_data, true);

    }

    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 공지사항 select
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_notice_reg() {
        # request
        $mode            = trim($this->input->get_post('mode', TRUE));
        $page            = trim($this->input->get_post('page', TRUE));
        $search_type     = trim($this->input->get_post('search_type', TRUE));
        $search_keyword  = trim($this->input->get_post('search_keyword', TRUE));
        $idx             = trim($this->input->get_post('idx', TRUE));

        if($mode == '')     $mode = 'add';

        $return_data = array();
	    if($mode == 'edit') {
	        # model
            $this->load->model('admin/cs/m_bbs_notice');
            $result = $this->m_bbs_notice->bbs_notice_select($idx);
            $return_data['result'] = $result[0];
        }

        $return_data['mode']            = $mode;
        $return_data['page']            = $page;
        $return_data['search_type']     = $search_type;
        $return_data['search_keyword']  = $search_keyword;
        $return_data['idx']             = $idx;

        # view
        return $this->load->view('/admin/cs/cs_notice_reg', $return_data, true);

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 공지사항 - 저장
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_notice_reg_proc() {
        # request
        $page                   = trim($this->input->get_post('page', TRUE));
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $title                  = trim($this->input->get_post('title', TRUE));
        $content                = trim($this->input->get_post('content', FALSE));
        $mode                   = trim($this->input->get_post('mode', TRUE));;

        $req_data['title']      = $title;
        $req_data['content']    = $content;


        if($mode == 'add') {
            # model - insert
            $this->load->model('admin/cs/m_bbs_notice');
            $result = $this->m_bbs_notice->bbs_notice_insert($req_data);


        } else if($mode == 'edit') {

            $req_data['idx']      = $idx;

            # model - insert
            $this->load->model('admin/cs/m_bbs_notice');
            $result = $this->m_bbs_notice->bbs_notice_update($req_data);

        }

        if(!$result) {
            gf_alert("저장에 실패했습니다. 다시시도해 주세요.", '/admin/cs/cs_notice_list/7/'.$page.'?search_type='.$search_type.'&search_keyword='.$search_keyword);
            exit;
        }


        gf_alert("저장되었습니다.", '/admin/cs/cs_notice_list/7/'.$page.'?search_type='.$search_type.'&search_keyword='.$search_keyword);

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 공지사항 삭제 - 저장
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_notice_del_proc() {
        # request
        $idx                    = trim($this->input->get_post('idx', TRUE));

        $req_date[] = $idx;

        # model - update
        $this->load->model('admin/cs/m_bbs_notice');
        $this->m_bbs_notice->bbs_notice_is_del_update($req_date);

        gf_alert("삭제되었습니다.", '/admin/cs/cs_notice_list/7');

    }



    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 공지사항 삭제 (다중)
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_notice_arr_del_proc() {
        # request
        $arr_idx    = $this->input->get_post('is_del', TRUE);   // 삭제할 idx

        # model - update
        $this->load->model('admin/cs/m_bbs_notice');
        $this->m_bbs_notice->bbs_notice_is_del_update($arr_idx);

        gf_alert("삭제되었습니다.", '/admin/cs/cs_notice_list/7');

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - faq list
    # CREATE  :	2018-02-28
    #---------------------------------------------------------------------------
	function fn_cs_faq_list() {
        # request
	    $page                   = $this->uri->segment(5);
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $search_category_code   = trim($this->input->get_post('search_category_code', TRUE));

        # paging 설정
        if($page == '') $page = 1;
        $limit  = PAGE_SIZE;
        $offset = ($page-1) * $limit;

        if($search_category_code=='') {
            $search_category_code = '27';
        }

        $search_category1 = substr($search_category_code, 0, 2);
        $search_category2 = substr($search_category_code, 2, 2);


        # 검색
        $req_data['search_type']            = $search_type;
        $req_data['search_keyword']         = addslashes($search_keyword);

        $req_data['offset']                 = $offset;
        $req_data['limit']                  = $limit;
        $req_data['search_category1']       = $search_category1;
        $req_data['search_category2']       = $search_category2;


	    # model - 카테고리 list
        $this->load->model('admin/cs/m_bbs_faq');
        $total_count        = $this->m_bbs_faq->bbs_faq_list_total_count($req_data);
        $result             = $this->m_bbs_faq->bbs_faq_list($req_data);
        $category_result    = $this->m_bbs_faq->faq_category_all_list();

        $arr_category1 = array();
        $arr_category2 = array();
        foreach ($category_result as $val) {
            if($val['depth']=='1') {
                $arr_category1[] = array('category_code'=>$val['category_code'], 'category_name'=>$val['category_name']);
            } else if($val['depth']=='2') {
                $arr_category2[$val['p_category_code']][]= array('category_code'=>$val['category_code'], 'category_name'=>$val['category_name']);
            }
        }




        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/cs/cs_faq_list/7' ;
        $req_data['suffix']         = '?'.$_SERVER['QUERY_STRING'];

        $this->load->library('comm_admin');
        $pagination = $this->comm_admin->fn_pagination($req_data);




        # view data
		$return_data['pagination']	        = $pagination;
        $return_data['page']                = $page;
        $return_data['limit']               = $limit;
        $return_data['total_count']         = $total_count;
        $return_data['search_type']         = $search_type;
        $return_data['search_keyword']      = $search_keyword;
        $return_data['search_category1']    = $search_category1;
        $return_data['search_category2']    = $search_category2;
        $return_data['search_category_code']= $search_category_code;
        $return_data['list']                = $result;
        $return_data['arr_category1']       = $arr_category1;
        $return_data['arr_category2']       = $arr_category2;
        # view
        return $this->load->view('/admin/cs/cs_faq_list', $return_data, true);

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 faq - 등록 / 수정
    # CREATE  :	2018-02-28
    #---------------------------------------------------------------------------
	function fn_cs_faq_reg() {
        # request
        $mode                   = trim($this->input->get_post('mode', TRUE));
        $page                   = trim($this->input->get_post('page', TRUE));
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $search_category_code   = trim($this->input->get_post('search_category_code', TRUE));

        if($mode == '')     $mode = 'add';

        # model - 카테고리 list
        $this->load->model('admin/cs/m_bbs_faq');
        $category_result    = $this->m_bbs_faq->faq_category_all_list();

        $arr_category1 = array();
        foreach ($category_result as $val) {
            if($val['depth']=='1') {
                $arr_category1[] = array('category_code'=>$val['category_code'], 'category_name'=>$val['category_name']);
            } else if($val['depth']=='2') {
                $arr_category2[]= array('p_category_code' => $val['p_category_code'], 'category_code'=>$val['category_code'], 'category_name'=>$val['category_name']);
            }
        }

        $return_data = array();
	    if($mode == 'edit') {
	        # model
            $this->load->model('admin/cs/m_bbs_faq');
            $result = $this->m_bbs_faq->bbs_faq_select($idx);
            $return_data['result'] = $result[0];
        }

        $return_data['mode']                = $mode;
        $return_data['page']                = $page;
        $return_data['search_type']         = $search_type;
        $return_data['search_keyword']      = $search_keyword;
        $return_data['search_category_code']= $search_category_code;
        $return_data['arr_category1']       = $arr_category1;
        $return_data['arr_category2']       = $arr_category2;
        $return_data['idx']                 = $idx;

        # view
        return $this->load->view('/admin/cs/cs_faq_reg', $return_data, true);

    }



    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - faq - 저장
    # CREATE  :	2018-02-28
    #---------------------------------------------------------------------------
	function fn_cs_faq_reg_proc() {
        # request
        $page                   = trim($this->input->get_post('page', TRUE));
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $search_category_code   = trim($this->input->get_post('search_category_code', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $category1              = trim($this->input->get_post('category1', TRUE));
        $category2              = trim($this->input->get_post('category2', TRUE));
        $title                  = trim($this->input->get_post('title', TRUE));
        $content                = trim($this->input->get_post('content', FALSE));
        $mode                   = trim($this->input->get_post('mode', TRUE));;

        $category_code          = $category1.$category2;

        $req_data['title']              = $title;
        $req_data['content']            = $content;
        $req_data['faq_category_code1'] = $category1;
        $req_data['faq_category_code2'] = $category2;



        if($mode == 'add') {
            # model - insert
            $this->load->model('admin/cs/m_bbs_faq');
            $result = $this->m_bbs_faq->bbs_faq_insert($req_data);


        } else if($mode == 'edit') {

            $req_data['idx']      = $idx;

            # model - insert
            $this->load->model('admin/cs/m_bbs_faq');
            $result = $this->m_bbs_faq->bbs_faq_update($req_data);

        }

        if(!$result) {
            gf_alert("저장에 실패했습니다. 다시시도해 주세요.", '/admin/cs/cs_faq_list/7/'.$page.'?search_category_code='.$search_category_code.'&search_type='.$search_type.'&search_keyword='.$search_keyword);
            exit;
        }


        gf_alert("저장되었습니다.", '/admin/cs/cs_faq_list/7/'.$page.'?search_category_code='.$search_category_code.'&search_type='.$search_type.'&search_keyword='.$search_keyword);

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - faq 삭제
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_faq_del_proc() {
        # request
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $search_category_code   = trim($this->input->get_post('search_category_code', TRUE));

        $req_date[] = $idx;

        # model - update
        $this->load->model('admin/cs/m_bbs_faq');
        $this->m_bbs_faq->bbs_faq_is_del_update($req_date);

        gf_alert("삭제되었습니다.", '/admin/cs/cs_faq_list/7?search_category_code='.$search_category_code);

    }



    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - 공지사항 삭제 (다중)
    # CREATE  :	2018-02-27
    #---------------------------------------------------------------------------
	function fn_cs_faq_arr_del_proc() {
        # request
        $arr_idx    = $this->input->get_post('is_del', TRUE);   // 삭제할 idx
        $search_category_code   = trim($this->input->get_post('search_category_code', TRUE));

        # model - update
        $this->load->model('admin/cs/m_bbs_faq');
        $this->m_bbs_faq->bbs_faq_is_del_update($arr_idx);

        gf_alert("삭제되었습니다.", '/admin/cs/cs_faq_list/7?search_category_code='.$search_category_code);

    }




    #---------------------------------------------------------------------------
    # PURPOSE : 고객센터 faq 카테고리별 count
    # CREATE  :	2018-02-28
    #---------------------------------------------------------------------------
	function fn_ajax_cs_faq_category_code_count() {
        # request
        $depth                  = trim($this->input->get_post('depth', TRUE));
        $category_code          = trim($this->input->get_post('category_code', TRUE));


        $req_date['depth']          = $depth;
        $req_date['category_code']  = $category_code;

        # model - update
        $this->load->model('admin/cs/m_bbs_faq');
        $count = $this->m_bbs_faq->bbs_faq_category_code_count($req_date);


        $return_data['result'] = $count;

        # view
        return $this->load->view('/admin/cs/cs_faq_category_code_count', $return_data);

    }






    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 - faq 카테고리 리스트
    # CREATE  :	2018-02-28
    #---------------------------------------------------------------------------
	function fn_cs_faq_category_list() {
        # request
	    $page                   = $this->uri->segment(5);
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));

        # paging 설정
        if($page == '') $page = 1;
        $limit  = PAGE_SIZE;
        $offset = ($page-1) * $limit;

        # 검색
        $req_data['search_type']            = $search_type;
        $req_data['search_keyword']         = addslashes($search_keyword);

        $req_data['offset']                 = $offset;
        $req_data['limit']                  = $limit;

	    # model - 카테고리 list
        $this->load->model('admin/cs/m_bbs_faq');
        $total_count         = $this->m_bbs_faq->faq_category_list_total_count($req_data);
        $result              = $this->m_bbs_faq->faq_category_list($req_data);


        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/cs/cs_faq_category_list/4' ;
        $req_data['suffix']         = '?'.$_SERVER['QUERY_STRING'];

        $this->load->library('comm_admin');
        $pagination = $this->comm_admin->fn_pagination($req_data);




        # view data
		$return_data['pagination']	        = $pagination;
        $return_data['page']                = $page;
        $return_data['limit']               = $limit;
        $return_data['total_count']         = $total_count;
        $return_data['search_type']         = $search_type;
        $return_data['search_keyword']      = $search_keyword;
        $return_data['list']                = $result;

        # view
        return $this->load->view('/admin/cs/cs_faq_category_list', $return_data, true);

    }



    #---------------------------------------------------------------------------
    # PURPOSE : 고객센터 faq 카테고리 - 저장
    # CREATE  :	2018-02-28
    #---------------------------------------------------------------------------
	function fn_ajax_cs_faq_category_reg_proc() {
        # request
        $mode                   = trim($this->input->get_post('mode', TRUE));
        $category_name          = trim($this->input->get_post('category_name', TRUE));
        $p_category_code        = trim($this->input->get_post('p_category_code', TRUE));
        $category_idx           = trim($this->input->get_post('category_idx', TRUE));

        $req_data['category_name']      = $category_name;

        if($mode == 'add') {
            $depth = '1';
            if($p_category_code!='')    $depth = '2';

            $req_data['p_category_code']    = $p_category_code;
            $req_data['depth']              = $depth;

            # model - insert
            $this->load->model('admin/cs/m_bbs_faq');
            $result = $this->m_bbs_faq->bbs_faq_category_insert($req_data);
            $result_code = '0000';
            if(!$result) {
                $result_code = '9999';
            }

        } else if($mode == 'edit') {
            $req_data['idx']        = $category_idx;

            # model
            $this->load->model('admin/cs/m_bbs_faq');
            $result = $this->m_bbs_faq->bbs_faq_category_update($req_data);
            $result_code = '0000';
            if(!$result) {
                $result_code = '9999';
            }

        }

        $return_data['result'] = $result_code;

        # view
        return $this->load->view('/admin/comm/result_html', $return_data);

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	고객센터 faq 카테고리 삭제 - 저장
    # CREATE  :	2018-02-28
    #---------------------------------------------------------------------------
	function fn_cs_faq_category_del_proc() {
        # request
        $depth                  = trim($this->input->get_post('depth', TRUE));
        $del_key                = trim($this->input->get_post('del_key', TRUE));

        if($depth == '1') {
            $req_date['p_category_code']= $del_key;
            $req_date['idx']            = '';
        } else {
            $req_date['p_category_code']= '';
            $req_date['idx']            = $del_key;
        }

        # model - update
        $this->load->model('admin/cs/m_bbs_faq');
        $this->m_bbs_faq->bbs_faq_category_is_del_update($req_date);

        gf_alert("삭제되었습니다.", '/admin/cs/cs_faq_category_list/7');

    }








}

?>