<?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 life extends cm_Controller {


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 채널&카테고리관리 > 카테고리 리스트
    # CREATE  :	2018-02-21
    #---------------------------------------------------------------------------
	function fn_life_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));
        $sort                   = trim($this->input->get_post('sort', TRUE));


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


        if($sort=='')   $sort ='1';
        switch ($sort) {
            case '1': $sort_column = 'channel_count'; break;
            case '2': $sort_column = 'editor_count'; break;
            case '3': $sort_column = 'article_count'; break;
            case '4': $sort_column = 'hit_count'; break;
            default : $sort_column = 'channel_count'; break;
        }


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

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

	    # model - 카테고리 list
        $this->load->model('admin/life/m_life');
        $total_count         = $this->m_life->category_list_total_count($req_data);
        $result              = $this->m_life->category_list($req_data);



        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/life/life_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['sort']                = $sort;
        $return_data['list']                = $result;
        
        # view
        return $this->load->view('/admin/life/life_category_list', $return_data, true);

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 채널&카테고리관리 > 카테고리 등록 - 저장
    # CREATE  :	2018-02-21
    #---------------------------------------------------------------------------
	function fn_ajax_life_category_add_proc() {
        # request
        $category_name          = trim($this->input->get_post('category_name', TRUE));
        $display_sort           = trim($this->input->get_post('display_sort', TRUE));

        $req_data['category_name']  = $category_name;
        $req_data['display_sort']   = $display_sort;

        # model - insert
        $this->load->model('admin/life/m_life');
        $result = $this->m_life->category_insert($req_data);

        if(!$result) {
            $result = '9999';
        } else {
            $result = '0000';
        }

        $return_data['result'] = $result;

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


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 채널&카테고리관리 > 카테고리 - 삭제
    # CREATE  :	2018-02-21
    #---------------------------------------------------------------------------
	function fn_life_category_del_proc() {
        # request
        $category_idx   = $this->input->get_post('category_idx', TRUE);   // 삭제할 idx

        # model - update
        $this->load->model('admin/life/m_life');
        $this->m_life->category_is_del_update($category_idx);

        gf_alert("삭제되었습니다.", '/admin/life/life_category_list/5');

    }

    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 채널&카테고리관리 > 채널리스트
    # CREATE  :	2018-02-21
    #---------------------------------------------------------------------------
	function fn_life_channel_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        = trim($this->input->get_post('search_category', TRUE));
        $sort                   = trim($this->input->get_post('sort', TRUE));


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

        if($sort=='')   $sort = '1';
        switch ($sort) {
            case '1': $sort_column = 'editor_count'; break;
            case '2': $sort_column = 'article_count'; break;
            case '3': $sort_column = 'hit_count'; break;
            default : $sort_column = 'editor_count'; break;
        }


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

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

	    # model - 채널 list
        $this->load->model('admin/life/m_life_channel');
        $total_count         = $this->m_life_channel->channel_list_total_count($req_data);
        $result              = $this->m_life_channel->channel_list($req_data);

        # model - 카테고리 list
        $this->load->model('admin/life/m_life_category');
        $category_list  = $this->m_life_category->category_all_list();


        # model - 아이콘 list
        $channel_icon_list  = $this->m_life_channel->channel_icon_list();
        


        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/life/life_channel_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['search_category']     = $search_category;
        $return_data['list']                = $result;
        $return_data['category_list']       = $category_list;
        $return_data['channel_icon_list']   = $channel_icon_list;
        $return_data['sort']                = $sort;

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

    }


    #---------------------------------------------------------------------------
    # PURPOSE : 채널아이콘 등록
    # CREATE  :	2018-03-13
    #---------------------------------------------------------------------------
	function fn_life_channel_icon_add_proc() {
	    $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        = trim($this->input->get_post('search_category', TRUE));


        # 이미지업로드
        $filename = '';
        if($_FILES['channel_icon']['name']!='') {
             # image upload
            $upload_path = './files/channel/'.date("Y")."/".date("m");
            if (!is_dir($upload_path)) {
                mkdir($upload_path, 0775, TRUE);
            }
            $config['upload_path']      = $upload_path;
            $config['allowed_types']    = 'gif|jpg|png';
            $config['encrypt_name']     = TRUE;

            $this->load->library('upload');
            $this->upload->initialize($config);

            if ( ! $this->upload->do_upload('channel_icon')) {
                $error = array('error' => $this->upload->display_errors());
                gf_alert("이미지 업로드에 실패했습니다.", 'back');
                exit;
            }
            $arr_upload_data = $this->upload->data();
            $filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);

        }

        # model - insert
        $this->load->model('admin/life/m_life_channel');
        $result = $this->m_life_channel->channel_icon_insert($filename);

        $url = '/admin/life/life_channel_list/5/'.$page.'?search_type='.$search_type.'&search_keyword='.$search_keyword.'&search_category='.$search_category;
        gf_alert("등록되었습니다.", $url);


    }




    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 채널&카테고리관리 > 채널 등록
    # CREATE  :	2018-02-21
    #---------------------------------------------------------------------------
	function fn_life_channel_reg() {
        # request
        $page                   = trim($this->input->get_post('page', TRUE));
        $mode                   = trim($this->input->get_post('mode', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $search_category        = trim($this->input->get_post('search_category', TRUE));
        $editor_idx             = 6;


        $req_data = array();
        $req_data['member_group_idx'] = $editor_idx;

        # model - 채널에디터 list
        $this->load->model('admin/member/m_partner');
        //$editor_all_list  = $this->m_partner->partner_list_where_member_group_idx($req_data);
        $editor_all_list  = $this->m_partner->partner_list_no_channel_new();

        # model - 카테고리 list
        $this->load->model('admin/life/m_life_category');
        $category_list  = $this->m_life_category->category_all_list();


        # model - 아이콘 list
        $this->load->model('admin/life/m_life_channel');
        $channel_icon_list  = $this->m_life_channel->channel_icon_list();

        $editor_count = 0;
        $article_count = 0;
        $result = array();
        $channel_editor_list = array();
        if($mode=='edit') {

            # model - 채널 select
            $this->load->model('admin/life/m_life_channel');
            $result  = $this->m_life_channel->channel_select($idx);

            # model - 채널에디터 list
            $this->load->model('admin/member/m_partner');
            //$channel_editor_list  = $this->m_partner->partner_where_channel_idx_list($idx);
            $channel_editor_list  = $this->m_partner->partner_my_channel_idx_list($idx);
            $editor_count = count($channel_editor_list);

            # 등록글수
            $article_count = 0;

        }


        $return_data = array();
        $return_data['page']                    = $page;
        $return_data['mode']                    = $mode;
        $return_data['idx']                     = $idx;
        $return_data['search_type']             = $search_type;
        $return_data['search_keyword']          = $search_keyword;
        $return_data['search_category']         = $search_category;
        $return_data['category_list']           = $category_list;
        $return_data['editor_all_list']         = $editor_all_list;
        $return_data['channel_editor_list']     = $channel_editor_list;
        $return_data['channel_icon_list']       = $channel_icon_list;
        $return_data['editor_count']            = $editor_count;
        $return_data['article_count']           = $article_count;
        $return_data['result']                  = $result;

        # view
        return $this->load->view('/admin/life/life_channel_reg', $return_data, true);
    }




    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 채널&카테고리관리 > 채널 등록
    # CREATE  :	2018-03-13
    #---------------------------------------------------------------------------
	function fn_life_channel_reg_proc() {
        # request
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $mode                   = trim($this->input->get_post('mode', TRUE));
        $search_type            = trim($this->input->get_post('search_type', TRUE));
        $search_keyword         = trim($this->input->get_post('search_keyword', TRUE));
        $search_category        = trim($this->input->get_post('search_category', TRUE));
        $editor_idx             = 6;

        $category_idx           = trim($this->input->get_post('category_idx', TRUE));
        $channel_name           = trim($this->input->get_post('channel_name', TRUE));
        $channel_icon           = trim($this->input->get_post('channel_icon', TRUE));
        $channel_intro          = trim($this->input->get_post('channel_intro', TRUE));
        $is_del_main_img        = trim($this->input->get_post('is_del_main_img', TRUE));
        $org_main_img           = trim($this->input->get_post('org_main_img', TRUE));
        
        /* NEW ADD */
        $editor_val             = trim($this->input->get_post('editor_val', TRUE));


        # 이미지 삭제
        if($is_del_main_img=='Y') {
            unlink('.'.$org_main_img);
            $org_main_img = '';
        }

        # 이미지업로드
        if($_FILES['main_img']['name']!='') {
             # image upload
            $upload_path = './files/channel/'.date("Y")."/".date("m");
            if (!is_dir($upload_path)) {
                mkdir($upload_path, 0775, TRUE);
            }
            $config['upload_path']      = $upload_path;
            $config['allowed_types']    = 'gif|jpg|png';
            $config['encrypt_name']     = TRUE;

            $this->load->library('upload');
            $this->upload->initialize($config);

            if ( ! $this->upload->do_upload('main_img')) {
                $error = array('error' => $this->upload->display_errors());
                gf_alert("이미지 업로드에 실패했습니다.", 'back');
                exit;
            }
            $arr_upload_data = $this->upload->data();
            $filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);

        } else {
            $filename = $org_main_img;
        }

        # request data
        $req_data['category_idx']   = $category_idx;
        $req_data['channel_name']   = $channel_name;
        $req_data['channel_icon']   = $channel_icon;
        $req_data['channel_intro']  = $channel_intro;
        $req_data['main_img']       = $filename;
        
        $update_data['partner_idx'] = $editor_val;

        if($mode == 'edit') {
            # update data
            $req_data['idx']                    = $idx;

            # model
            $this->load->model('admin/life/m_life_channel');
            $return_data    = $this->m_life_channel->channel_update($req_data);
            if(!$return_data) {
                gf_alert("저장에 실패했습니다.", '/admin/life/life_setting_reg/5');
                exit;
            }
            
            $return_data    = $this->m_life_channel->channel_partner_update($req_data, $update_data);
            if(!$return_data) {
                gf_alert("저장에 실패했습니다.", '/admin/life/life_setting_reg/5');
                exit;
            }
            
        } else {

            # model
            $this->load->model('admin/life/m_life_channel');
            $return_data    = $this->m_life_channel->channel_insert($req_data);
            if(!$return_data) {
                gf_alert("저장에 실패했습니다.", 'back');
                exit;
            }

        }

        gf_alert("저장되었습니다.", '/admin/life/life_channel_list/5');

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 채널 - 삭제
    # CREATE  :	2018-03-13
    #---------------------------------------------------------------------------
	function fn_life_channel_del_proc() {
        # request
        $channel_idx   = $this->input->get_post('idx', TRUE);   // 삭제할 idx
        
        # model - update
        $this->load->model('admin/life/m_life_channel');
        $this->m_life_channel->channel_is_del_update($channel_idx);

        # model - update
        $this->load->model('admin/life/m_life');
        $this->m_life->life_is_del_where_channel_idx_update($channel_idx);


        gf_alert("삭제되었습니다.", '/admin/life/life_channel_list/5');

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 기능별 관리
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_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_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $search_click1          = trim($this->input->get_post('search_click1', TRUE));
        $search_click2          = trim($this->input->get_post('search_click2', TRUE));
        $sort                   = trim($this->input->get_post('sort', TRUE));


        # 에디터일 경우 자기 글만 볼수 있게 처리
        $search_write_id = '';
        $admin_type = $this->session->userdata('Adm_Type');
        if($admin_type == '1') {
            $search_write_id = $this->session->userdata('Adm_Id');
        }

        if($sort=='')   $sort ='1';
        switch ($sort) {
            case '1': $sort_column = 'a.reg_date'; break;
            case '2': $sort_column = 'a.hit_count'; break;
            case '3': $sort_column = 'a.like_count'; break;
            case '4': $sort_column = 'a.comment_count'; break;
            default : $sort_column = 'a.reg_date'; break;
        }

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

        # 검색
        $req_data = array();
        $req_data['search_type']            = $search_type;
        $req_data['search_keyword']         = addslashes($search_keyword);
        $req_data['search_life_type']       = $search_life_type;
        $req_data['search_category_code1']  = $search_category_code1;
        $req_data['search_category_code2']  = $search_category_code2;
        $req_data['search_click1']          = $search_click1;
        $req_data['search_click2']          = $search_click2;
        $req_data['sort_column']            = $sort_column;
        $req_data['search_write_id']        = $search_write_id;

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

	    # model - 카테고리 list
        $this->load->model('admin/life/m_life');
        $total_count        = $this->m_life->life_list_total_count($req_data);
        $result             = $this->m_life->life_list($req_data);
        $new_count          = $this->m_life->life_new_count($req_data);
        $arr_display_count  = $this->m_life->life_is_display_group_by_list($req_data);

        # 카테고리 리스트
        $this->load->model('admin/life/m_life_category');
        $arr_category1   = $this->m_life_category->category_all_list();

        # 카테고리 리스트
        $this->load->model('admin/life/m_life_channel');
        $arr_category2   = $this->m_life_channel->channel_all_list();


        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/life/life_list/5';
        $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_category_code1']   = $search_category_code1;
        $return_data['search_category_code2']   = $search_category_code2;
        $return_data['search_click1']           = $search_click1;
        $return_data['search_click2']           = $search_click2;
        $return_data['search_life_type']        = $search_life_type;
        $return_data['sort']                    = $sort;
        $return_data['list']                    = $result;
        $return_data['arr_category1']           = $arr_category1;
        $return_data['arr_category2']           = $arr_category2;
        $return_data['new_count']               = $new_count;
        $return_data['arr_display_count']       = $arr_display_count;

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

    }



    #---------------------------------------------------------------------------
    # PURPOSE :	라이프 > 기능별 뉴스관리 등록/수정
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_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));
        $search_category_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $search_click1          = trim($this->input->get_post('search_click1', TRUE));
        $search_click2          = trim($this->input->get_post('search_click2', TRUE));
        $sort                   = trim($this->input->get_post('sort', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $content_type           = DEF_LIFE_CODE;


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


        $this->load->model('admin/life/m_life_category');
        $this->load->model('admin/life/m_life_channel');
        $this->load->model('admin/member/m_partner');

        # 에디터의 경우
        $admin_type = $this->session->userdata('Adm_Type');
        if($admin_type == '1') {
            $search_write_id = $this->session->userdata('Adm_Id');

            # 내정보 가져오기
            $this->load->model('admin/member/m_partner');
            $arr_category3   = $this->m_partner->partner_where_partner_id_select($search_write_id);
            if(!$arr_category3){
                gf_alert("잘못된 접근입니다.", '/admin/main');
                exit;
            }
            # 카테고리 리스트
            $category_idx = $arr_category3[0]['category_idx'];
            $arr_category1   = $this->m_life_category->category_select($category_idx);

            # 채널 리스트
            $channel_idx    = $arr_category3[0]['channel_idx'];
            $arr_category2   = $this->m_life_channel->channel_select($channel_idx);


        } else {
             # 카테고리 리스트
            $arr_category1   = $this->m_life_category->category_all_list();

            # 채널 리스트
            $arr_category2   = $this->m_life_channel->channel_all_list();

            # 에디터 리스트
            $req_data = array();
            $req_data['member_group_idx'] = 6;
            $req_data['search_write_id']    = '';
            $arr_category3   = $this->m_partner->partner_list_where_member_group_idx($req_data);

        }


        $return_data = array();
        $arr_theme  = array();
        $arr_section = array();
	    if($mode == 'edit') {

            $req_data = array();
            $req_data['content_idx']    = $idx;
            $req_data['content_type']   = $content_type;

            # 테마리스트
            $this->load->model('admin/comm/m_theme');
            $arr_theme   = $this->m_theme->theme_content_idx_select($req_data);

            # etc_section
            $this->load->model('admin/etc_section/m_etc_section');
            $arr_section   = $this->m_etc_section->etc_section_content_idx_select($req_data);

	        # model
            $this->load->model('admin/life/m_life');
            $result = $this->m_life->life_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_life_type']        = $search_life_type;
        $return_data['search_category_code1']   = $search_category_code1;
        $return_data['search_category_code2']   = $search_category_code2;
        $return_data['search_click1']           = $search_click1;
        $return_data['search_click2']           = $search_click2;
        $return_data['sort']                    = $sort;
        $return_data['idx']                     = $idx;
        $return_data['arr_category1']           = $arr_category1;
        $return_data['arr_category2']           = $arr_category2;
        $return_data['arr_category3']           = $arr_category3;
        $return_data['arr_theme']               = $arr_theme;
        $return_data['arr_section']             = $arr_section;

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

    }



    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 기능별 뉴스관리 - 저장
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_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_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $sort                   = trim($this->input->get_post('sort', TRUE));
        $mode                   = trim($this->input->get_post('mode', TRUE));
        $search_click1          = trim($this->input->get_post('search_click1', TRUE));
        $search_click2          = trim($this->input->get_post('search_click2', TRUE));

        $idx                    = trim($this->input->get_post('idx', TRUE));
        $life_type              = trim($this->input->get_post('life_type', TRUE));
        $category_idx           = trim($this->input->get_post('category1', TRUE));
        $channel_idx            = trim($this->input->get_post('category2', TRUE));
        $editor_idx             = trim($this->input->get_post('category3', TRUE));

        $head_title             = trim($this->input->get_post('head_title', TRUE));
        $title                  = trim($this->input->get_post('title', TRUE));
        $sub_title              = trim($this->input->get_post('sub_title', TRUE));

        $tag                    = trim($this->input->get_post('tag', TRUE));
        $org_url                = trim($this->input->get_post('org_url', TRUE));
        $content                = trim($this->input->get_post('content', FALSE));

        $hit_count              = trim($this->input->get_post('hit_count', TRUE));
        $share_count            = trim($this->input->get_post('share_count', TRUE));
        $like_count             = trim($this->input->get_post('like_count', TRUE));

        $relation_idxs          = trim($this->input->get_post('relation_idxs', TRUE));
        $theme_type11           = trim($this->input->get_post('theme_type11', TRUE));
        $theme_type12           = trim($this->input->get_post('theme_type12', TRUE));
        $theme_type13           = trim($this->input->get_post('theme_type13', TRUE));
        $theme_type14           = trim($this->input->get_post('theme_type14', TRUE));
        $theme_type15           = trim($this->input->get_post('theme_type15', TRUE));
        $theme_type16           = trim($this->input->get_post('theme_type16', TRUE));
        $theme_type17           = trim($this->input->get_post('theme_type17', TRUE));
        $theme_type18           = trim($this->input->get_post('theme_type18', TRUE));
        $theme_type19           = trim($this->input->get_post('theme_type19', TRUE));
        $theme_type20           = trim($this->input->get_post('theme_type20', TRUE));
        $theme_type21           = trim($this->input->get_post('theme_type21', TRUE));
        $section_type1          = trim($this->input->get_post('section_type1', TRUE));
        $section_type2          = trim($this->input->get_post('section_type2', TRUE));
        $section_type3          = trim($this->input->get_post('section_type3', TRUE));
        $section_type4          = trim($this->input->get_post('section_type4', TRUE));
        $display_date           = trim($this->input->get_post('display_date', TRUE));
        $display_hour           = trim($this->input->get_post('display_hour', TRUE));
        $display_min            = trim($this->input->get_post('display_min', TRUE));
        $display_sec            = trim($this->input->get_post('display_sec', TRUE));
        $is_del_img             = trim($this->input->get_post('is_del_img', TRUE));
        $org_main_img           = trim($this->input->get_post('org_main_img', TRUE));
        $video_url              = trim($this->input->get_post('video_url', TRUE));

        $content_type           = DEF_LIFE_CODE;

        $video_playtime = '';
        if($video_url!='') {
            $this->load->library('comm_admin');
            $video_playtime = $this->comm_admin->fn_youtube_playtime($video_url);
            $video_url = 'https://www.youtube.com/embed/'.$video_url;
        }




        # 이미지 삭제
        if($is_del_img=='Y') {
            unlink('.'.$org_main_img);
            $org_main_img = '';
        }

        # 이미지업로드
        if($_FILES['main_img']['name']!='') {
             # image upload
            $upload_path = FCPATH. 'files/life/'.date("Y")."/".date("m");
            if (!is_dir($upload_path)) {
                mkdir($upload_path, 0775, TRUE);
            }
            $config['upload_path']      = $upload_path;
            $config['allowed_types']    = 'gif|jpg|png';
            $config['encrypt_name']     = TRUE;

            $this->load->library('upload');
            $this->upload->initialize($config);

            if ( ! $this->upload->do_upload('main_img')) {                
                log_message('debug', 'Upload path: '. $upload_path);
                log_message('debug', 'Upload Error: '. $this->upload->display_errors('',''));                
                gf_alert("이미지 업로드에 실패했습니다.", 'back');
                exit;
            }
            $arr_upload_data = $this->upload->data();
            $filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);

        } else {
            $filename = $org_main_img;
        }



        # model - editor_name
        $this->load->model('admin/member/m_partner');
        $result = $this->m_partner->partner_select($editor_idx);
        $editor_name = '';
        $write_id = '';
        if(count($result) > 0){
            $editor_name    = $result[0]['partner_name'];
            $write_id       = $result[0]['partner_id'];
        }

        # 예약시간
        $now_date       = date("Y-m-d H:i:s");
        if($display_date=='' || $display_date=='0000-00-00') {
            $display_date   = $now_date;
        } else {
            $display_hour   = sprintf('%02d',$display_hour);
            $display_min    = sprintf('%02d',$display_min);
            $display_sec    = sprintf('%02d',$display_sec);
            $display_date   = $display_date.' '.$display_hour.':'.$display_min.':'.$display_sec;
        }

        $is_display = 'Y';
        if($display_date > $now_date) {
            $is_display = 'N';
        }

        # tag
        $tag = str_replace(' ','', $tag);
        $tag = str_replace(',',' ', $tag);


        # update data
        $req_data = array();
        $req_data['life_type']      = $life_type;
        $req_data['category_idx']   = $category_idx;
        $req_data['channel_idx']    = $channel_idx;
        $req_data['partner_idx']    = $editor_idx;
        $req_data['editor_name']    = $editor_name;
        $req_data['write_name']     = $editor_name;
        $req_data['write_id']       = $write_id;
        $req_data['head_title']     = $head_title;
        $req_data['title']          = $title;
        $req_data['sub_title']      = $sub_title;
        $req_data['main_img']       = $filename;
        $req_data['content']        = $content;
        $req_data['org_url']        = $org_url;
        $req_data['tag']            = $tag;
        $req_data['like_count']     = $like_count;
        $req_data['hit_count']      = $hit_count;
        $req_data['share_count']    = $share_count;
        $req_data['is_display']     = strtotime($display_date) > time() ? 'N' : 'Y';
        $req_data['display_date']   = $display_date;
        $req_data['video_url']      = $video_url;
        $req_data['video_playtime'] = $video_playtime;

        if($mode=='add') {


            # model
            $this->load->model('admin/life/m_life');
            $idx = $this->m_life->life_insert($req_data);
            if(!$idx) {
                gf_alert("등록에 실패했습니다.", 'back');
                exit;
            }

            $url = '/admin/life/life_list/5';

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

            $req_data['idx']     = $idx;

            # model
            $this->load->model('admin/life/m_life');
            $result = $this->m_life->life_update($req_data);

            if(!$result) {
                gf_alert("수정에 실패했습니다.", 'back');
                exit;
            }

            $url = '/admin/life/life_list/5/'.$page.'?search_type='.$search_type.'&search_keyword='.$search_keyword.'&search_category_code1='.$search_category_code1.'&search_category_code2='.$search_category_code2.'&search_life_type='.$search_life_type.'&sort='.$sort.'&search_click1='.$search_click1.'&search_click2='.$search_click2;
            


        }

        # tag
        $req_data = array();
        $req_data['content_type']   = $content_type;
        $req_data['content_idx']    = $idx;

        # model - tag 삭제
        $this->load->model('admin/comm/m_tag');
        $this->m_tag->tag_delete($req_data);

        $arr_tag = explode(" ", $tag);
        $arr_tag = array_filter(array_map('trim', $arr_tag));

        foreach ($arr_tag as $val) {
            $req_data['tag']            = $val;

            # model
            $tag_count = $this->m_tag->tag_select_where_tag_count($req_data);
            if($tag_count==0) { // insert
                $result = $this->m_tag->tag_insert($req_data);

            }
        }


        # 테마 등록
        for($i=11; $i<=21; $i++) {
            $rank = ${"theme_type".$i};

            if($rank != '') {
                $req_data = array();
                $req_data['theme_type']     = $i;
                $req_data['content_type']   = $content_type;
                $req_data['rank']           = $rank;
                $req_data['content_idx']    = $idx;
                $req_data['filename']       = $filename;
                $req_data['title']          = $title;
                $req_data['is_display']     = $is_display;

                $this->load->library('comm_admin');
                $result = $this->comm_admin->fn_theme_reg($req_data);

                if (!$result) {
                    gf_alert("테마등록에 실패했습니다.", 'back');
                    exit;
                }
            }

        }

        # 기타섹션 등록
        for($i=1; $i<=4; $i++) {
            $rank = ${"section_type".$i};
            if($rank != '') {
                $req_data = array();
                $req_data['etc_section_type']   = $i;
                $req_data['content_type']       = $content_type;
                $req_data['rank']               = $rank;
                $req_data['content_idx']        = $idx;
                $req_data['filename']           = $filename;
                $req_data['title']              = $title;
                $req_data['is_display']         = $is_display;

                $this->load->library('comm_admin');
                $result = $this->comm_admin->fn_etc_section_reg($req_data);

                if (!$result) {
                    gf_alert("기타섹션등록에 실패했습니다.", 'back');
                    exit;
                }
            }
        }



        gf_alert("저장되었습니다.", $url);
    }
    

    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 기능별 관리 - 삭제
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_reg_del_proc() {
        # request
        $idx                    = trim($this->input->get_post('idx', TRUE));

        # model
        $this->load->model('admin/life/m_life');

        // 이미지 삭제
        $result1 = $this->m_life->life_select($idx);
        if(count($result1) > 0){
            if($result1[0]['main_img']!=''){
                unlink('.'.$result1[0]['main_img']);
            }
        }
        $req_date[] = $idx;

        # model - update
        $this->m_life->life_is_del_update($req_date);

        gf_alert("삭제되었습니다.", '/admin/life/life_list/5');

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 기능별 관리 - 삭제 (다중)
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_reg_arr_del_proc() {
        # request
        $arr_idx    = $this->input->get_post('is_del', TRUE);   // 삭제할 idx


        # model
        $this->load->model('admin/life/m_life');

        // 이미지 삭제
        $result1 = $this->m_life->life_select_in_idx($arr_idx);
        if(count($result1) > 0){
            foreach ($result1 as $val) {
                if($val['main_img']!=''){
                    unlink('.'.$val['main_img']);
                }
            }
        }

        # model - update
        $this->m_life->life_is_del_update($arr_idx);

        gf_alert("삭제되었습니다.", '/admin/life/life_list/5');

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 테마별 관리
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_theme_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_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $search_theme_type      = trim($this->input->get_post('search_theme_type', TRUE));
        $sort                   = trim($this->input->get_post('sort', TRUE));
        $content_type           = DEF_LIFE_CODE;
        $search_click1          = trim($this->input->get_post('search_click1', TRUE));
        $search_click2          = trim($this->input->get_post('search_click2', TRUE));


        if($sort=='')   $sort ='1';
        switch ($sort) {
            case '1': $sort_column = 'a.reg_date'; break;
            case '2': $sort_column = 'b.hit_count'; break;
            case '3': $sort_column = 'b.like_count'; break;
            case '4': $sort_column = 'b.comment_count'; break;
            default : $sort_column = 'a.reg_date'; break;
        }

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


        # 검색
        $req_data = array();
        $req_data['search_type']            = $search_type;
        $req_data['search_keyword']         = addslashes($search_keyword);
        $req_data['search_theme_type']      = $search_theme_type;
        $req_data['search_category_code1']  = $search_category_code1;
        $req_data['search_category_code2']  = $search_category_code2;
        $req_data['search_life_type']       = $search_life_type;
        $req_data['sort_column']            = $sort_column;
        $req_data['content_type']           = $content_type;
        $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/life/m_life');
        $total_count        = $this->m_life->theme_join_life_list_total_count($req_data);
        $result             = $this->m_life->theme_join_life_list($req_data);
        $new_count          = $this->m_life->theme_join_life_new_count($req_data);
        $arr_display_count  = $this->m_life->theme_join_life_is_display_group_by_list($req_data);

        # 카테고리 리스트
        $this->load->model('admin/life/m_life_category');
        $arr_category1   = $this->m_life_category->category_all_list();

        # 채널 리스트
        $this->load->model('admin/life/m_life_channel');
        $arr_category2   = $this->m_life_channel->channel_all_list();

        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/life/life_theme_list/5';
        $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_category_code1']   = $search_category_code1;
        $return_data['search_category_code2']   = $search_category_code2;
        $return_data['search_life_type']        = $search_life_type;
        $return_data['search_theme_type']       = $search_theme_type;
        $return_data['sort']                    = $sort;
        $return_data['list']                    = $result;
        $return_data['arr_category1']           = $arr_category1;
        $return_data['arr_category2']           = $arr_category2;
        $return_data['new_count']               = $new_count;
        $return_data['search_click1']           = $search_click1;
        $return_data['search_click2']           = $search_click2;
        $return_data['arr_display_count']       = $arr_display_count;

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

    }

    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 테마별 뉴스관리 등록/수정
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_theme_list_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));
        $search_category_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $search_theme_type      = trim($this->input->get_post('search_theme_type', TRUE));
        $sort                   = trim($this->input->get_post('sort', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $content_type           = DEF_LIFE_CODE;

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

        if($search_theme_type == '')   $search_theme_type = '11';

        $req_data = array();
        $req_data['content_type']   = $content_type;
        $req_data['theme_type']     = $search_theme_type;

        # 테마리스트
        $this->load->model('admin/life/m_life');
        $arr_theme   = $this->m_life->theme_join_life_type_list($req_data);

        $return_data = array();
        $return_data['mode']                    = $mode;
        $return_data['page']                    = $page;
        $return_data['search_type']             = $search_type;
        $return_data['search_keyword']          = $search_keyword;
        $return_data['search_theme_type']       = $search_theme_type;
        $return_data['search_category_code1']   = $search_category_code1;
        $return_data['search_category_code2']   = $search_category_code2;
        $return_data['search_life_type']        = $search_life_type;
        $return_data['sort']                    = $sort;
        $return_data['content_type']            = $content_type;
        $return_data['idx']                     = $idx;
        $return_data['arr_theme']               = $arr_theme;

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

    }






    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 테마별 관리 - 저장
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_theme_list_reg_proc() {
        # request
        $theme_type             = trim($this->input->get_post('theme_type', TRUE));
        $content_type           = DEF_LIFE_CODE;


        include_once ("./static_data/code.php");
        $arr_req_data = array();
        for($i=1;$i<=$def_arr_life_theme[$theme_type]['count'];$i++){
            ${"content_idx".$i}    = trim($this->input->get_post('content_idx'.$i, TRUE));
            ${"head_title".$i}     = trim($this->input->get_post('head_title'.$i, TRUE));
            ${"title".$i}          = trim($this->input->get_post('title'.$i, TRUE));
            ${"sub_title".$i}      = trim($this->input->get_post('sub_title'.$i, TRUE));
            ${"sub_content".$i}    = trim($this->input->get_post('sub_content'.$i, TRUE));
            ${"img".$i}            = trim($this->input->get_post('img'.$i, TRUE));
            ${"org_img".$i}        = trim($this->input->get_post('org_img'.$i, TRUE));
            ${"hit_count".$i}      = trim($this->input->get_post('hit_count'.$i, TRUE));
            ${"like_count".$i}     = trim($this->input->get_post('like_count'.$i, TRUE));

            if(${"title".$i}!=''){
                // 조회수 업데이트
                if($theme_type=='21') {
                    $req_data = array();
                    $req_data['idx']        = ${"content_idx".$i};
                    $req_data['hit_count']  = ${"hit_count".$i};

                    $this->load->model('admin/life/m_life');
                    $this->m_life->life_update($req_data);

                } else if($theme_type=='19') {
                    $req_data = array();
                    $req_data['idx']        = ${"content_idx".$i};
                    $req_data['like_count'] = ${"like_count".$i};

                    $this->load->model('admin/life/m_life');
                    $this->m_life->life_update($req_data);
                }



                # 이미지업로드
                if($_FILES['theme_img'.$i]['name']!='') {
                     # image upload
                    $upload_path = './files/theme/'.date("Y")."/".date("m");
                    if (!is_dir($upload_path)) {
                        mkdir($upload_path, 0775, TRUE);
                    }
                    $config['upload_path']      = $upload_path;
                    $config['allowed_types']    = 'gif|jpg|png';
                    $config['encrypt_name']     = TRUE;

                    $this->load->library('upload');
                    $this->upload->initialize($config);

                    if ( ! $this->upload->do_upload('theme_img'.$i)) {
                        $error = array('error' => $this->upload->display_errors());
                        gf_alert("이미지 업로드에 실패했습니다.", 'back');
                        exit;
                    }
                    $arr_upload_data = $this->upload->data();
                    $filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);
                    $is_file_copy = 'N';
                } else {
                    if(${"img".$i}=='') {
                        $filename = ${"org_img".$i};
                        $is_file_copy = 'N';
                    } else {
                        $filename = ${"img".$i};
                        $is_file_copy = 'Y';
                    }
                }

                $req_data['theme_type']     = $theme_type;
                $req_data['content_type']   = $content_type;
                $req_data['rank']           = $i;
                $req_data['content_idx']    = ${"content_idx".$i};
                $req_data['filename']       = $filename;
                $req_data['is_file_copy']   = $is_file_copy;
                $req_data['is_display']     = 'Y';
                $req_data['head_title']     = ${"head_title".$i};
                $req_data['title']          = ${"title".$i};
                $req_data['sub_title']      = ${"sub_title".$i};
                $req_data['sub_content']    = ${"sub_content".$i};

                $this->load->library('comm_admin');
                $result = $this->comm_admin->fn_theme_reg($req_data);

                if (!$result) {
                    gf_alert("테마등록에 실패했습니다.", 'back');
                    exit;
                }


            }

        }

        gf_alert("저장되었습니다.", "/admin/life/life_theme_list/5");


    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 테마별 관리 수정
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_theme_edit() {
        # 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_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $search_theme_type      = trim($this->input->get_post('search_theme_type', TRUE));
        $sort                   = trim($this->input->get_post('sort', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $content_type           = DEF_LIFE_CODE;


        # model
        $this->load->model('admin/life/m_life');
        $result   = $this->m_life->theme_join_life_select($idx);

        $return_data = array();
        $return_data['page']                    = $page;
        $return_data['search_type']             = $search_type;
        $return_data['search_keyword']          = $search_keyword;
        $return_data['search_theme_type']       = $search_theme_type;
        $return_data['search_category_code1']   = $search_category_code1;
        $return_data['search_category_code2']   = $search_category_code2;
        $return_data['search_life_type']        = $search_life_type;
        $return_data['sort']                    = $sort;
        $return_data['idx']                     = $idx;
        $return_data['result']                  = $result[0];
        $return_data['content_type']            = $content_type;
        # view
        return $this->load->view('/admin/life/life_theme_edit', $return_data, true);

    }



    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 테마 - 수정
    # CREATE  :	2018-03-22
    #---------------------------------------------------------------------------
	function fn_life_theme_edit_proc() {
        # request
        $content_idx        = trim($this->input->get_post('content_idx', TRUE));
        $head_title         = trim($this->input->get_post('head_title', TRUE));
        $title              = trim($this->input->get_post('title', TRUE));
        $sub_title          = trim($this->input->get_post('sub_title', TRUE));
        $sub_content        = trim($this->input->get_post('sub_content', TRUE));
        $img                = trim($this->input->get_post('img', TRUE));
        $org_img            = trim($this->input->get_post('org_img', TRUE));
        $idx                = trim($this->input->get_post('idx', TRUE));



        # 이미지업로드
        if($_FILES['theme_img']['name']!='') {
             # image upload
            $upload_path = FCPATH. 'files/theme/'.date("Y")."/".date("m");
            if (!is_dir($upload_path)) {
                mkdir($upload_path, 0775, TRUE);
            }
            $config['upload_path']      = $upload_path;
            $config['allowed_types']    = 'gif|jpg|png';
            $config['encrypt_name']     = TRUE;

            $this->load->library('upload');
            $this->upload->initialize($config);

            if ( ! $this->upload->do_upload('theme_img')) {
                log_message('debug', 'Upload path: '. $upload_path);
                log_message('debug', 'Upload Error: '. $this->upload->display_errors('','')); 
                gf_alert("이미지 업로드에 실패했습니다.", 'back');
                exit;
            }
            $arr_upload_data = $this->upload->data();
            $filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);

        } else {
            if($img!='') {
                # image upload
                $upload_path = './files/theme/'.date("Y")."/".date("m");
                if (!is_dir($upload_path)) {
                    mkdir($upload_path, 0775, TRUE);
                }

                $arr_new_file =  explode('/', $img);
                copy('.'.$img, $upload_path.'/'.$arr_new_file[5]);
                $filename = '/files/theme/'.date("Y").'/'.date("m").'/'.$arr_new_file[5];

            } else {
                $filename = $org_img;
            }
        }

        $req_data['content_idx']    = $content_idx;
        $req_data['head_title']     = $head_title;
        $req_data['title']          = $title;
        $req_data['sub_content']    = $sub_content;
        $req_data['sub_title']      = $sub_title;
        $req_data['theme_img']      = $filename;
        $req_data['idx']            = $idx;
        $this->load->model('admin/comm/m_theme');
        $this->m_theme->theme_where_idx_update($req_data);



        gf_alert("저장되었습니다.", "/admin/life/life_theme_list/5");


    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 테마별 관리 - 삭제
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_theme_reg_del_proc() {
        # request
        $idx                    = trim($this->input->get_post('idx', TRUE));

        # model
        $this->load->model('admin/comm/m_theme');


        $req_date[] = $idx;

        # model - update
        $this->m_theme->theme_is_del_update($req_date);

        gf_alert("삭제되었습니다.", '/admin/life/life_theme_list/5');

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 테마별 관리 - 삭제 (다중)
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_theme_reg_arr_del_proc() {
        # request
        $arr_idx    = $this->input->get_post('is_del', TRUE);   // 삭제할 idx


        # model
        $this->load->model('admin/comm/m_theme');


        # model - update
        $this->m_theme->theme_is_del_update($arr_idx);

        gf_alert("삭제되었습니다.", '/admin/life/life_theme_list/5');



    }



    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 랭킹별 관리
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_ranking_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_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $search_theme_type      = trim($this->input->get_post('search_theme_type', TRUE));
        $search_ranking_type    = trim($this->input->get_post('search_ranking_type', TRUE));
        $sort                   = trim($this->input->get_post('sort', TRUE));
        $content_type           = DEF_LIFE_CODE;


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


        # 검색
        $req_data = array();
        $req_data['search_type']            = $search_type;
        $req_data['search_keyword']         = addslashes($search_keyword);
        $req_data['search_ranking_type']    = $search_ranking_type;
        $req_data['search_category_code1']  = $search_category_code1;
        $req_data['search_category_code2']  = $search_category_code2;
        $req_data['search_life_type']       = $search_life_type;
        $req_data['search_theme_type']      = $search_theme_type;
        $req_data['content_type']           = $content_type;

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

	    # model - list
        $this->load->model('admin/life/m_ranking');
        $total_count    = $this->m_ranking->ranking_join_life_list_total_count($req_data);
        $result         = $this->m_ranking->ranking_join_life_list($req_data);


        # 카테고리 리스트
        $this->load->model('admin/life/m_life_category');
        $arr_category1   = $this->m_life_category->category_all_list();

        # 채널 리스트
        $this->load->model('admin/life/m_life_channel');
        $arr_category2   = $this->m_life_channel->channel_all_list();


        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/life/life_ranking_list/5';
        $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_category_code1']   = $search_category_code1;
        $return_data['search_category_code2']   = $search_category_code2;
        $return_data['search_ranking_type']     = $search_ranking_type;
        $return_data['search_life_type']        = $search_life_type;
        $return_data['search_theme_type']       = $search_theme_type;
        $return_data['sort']                    = $sort;
        $return_data['list']                    = $result;
        $return_data['arr_category1']           = $arr_category1;
        $return_data['arr_category2']           = $arr_category2;

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

    }

    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 랭킹관리 송출관리 등록/수정
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_ranking_list_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));
        $search_category_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $search_theme_type      = trim($this->input->get_post('search_theme_type', TRUE));
        $search_ranking_type    = trim($this->input->get_post('search_ranking_type', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $content_type           = DEF_LIFE_CODE;

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

        if($search_ranking_type == '')   $search_ranking_type = '1';

        $req_data = array();
        $req_data['content_type']   = $content_type;
        $req_data['ranking_type']   = $search_ranking_type;

        # 테마리스트
        $this->load->model('admin/life/m_ranking');
        $arr_ranking   = $this->m_ranking->ranking_join_life_type_list($req_data);

        $return_data = array();
        $return_data['mode']                    = $mode;
        $return_data['page']                    = $page;
        $return_data['search_type']             = $search_type;
        $return_data['search_keyword']          = $search_keyword;
        $return_data['search_ranking_type']     = $search_ranking_type;
        $return_data['search_category_code1']   = $search_category_code1;
        $return_data['search_category_code2']   = $search_category_code2;
        $return_data['search_life_type']        = $search_life_type;
        $return_data['search_theme_type']       = $search_theme_type;
        $return_data['content_type']            = $content_type;
        $return_data['idx']                     = $idx;
        $return_data['arr_ranking']             = $arr_ranking;

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

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 랭킹 관리 - 저장
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_ranking_list_reg_proc() {
        # request
        $ranking_type           = trim($this->input->get_post('ranking_type', TRUE));
        $mode                   = trim($this->input->get_post('mode', TRUE));
        $content_type           = DEF_LIFE_CODE;


        include_once ("./static_data/code.php");
        $arr_req_data = array();
        for($i=1;$i<=$def_arr_ranking[$ranking_type]['count'];$i++){
            ${"content_idx".$i}    = trim($this->input->get_post('content_idx'.$i, TRUE));
            ${"head_title".$i}     = trim($this->input->get_post('head_title'.$i, TRUE));
            ${"title".$i}          = trim($this->input->get_post('title'.$i, TRUE));
            ${"sub_content".$i}    = trim($this->input->get_post('sub_content'.$i, TRUE));
            ${"img".$i}            = trim($this->input->get_post('img'.$i, TRUE));
            ${"org_img".$i}        = trim($this->input->get_post('org_img'.$i, TRUE));
            if($ranking_type == '1')    ${"hit_count".$i}        = trim($this->input->get_post('hit_count'.$i, TRUE));
            if($ranking_type == '3')    ${"share_count".$i}      = trim($this->input->get_post('share_count'.$i, TRUE));

            # model
            $req_data['ranking_type']   = $ranking_type;
            $req_data['content_type']   = $content_type;
            $req_data['rank']           = $i;

            $this->load->model('admin/comm/m_ranking');
            $rank_count = $this->m_ranking->ranking_rank_count($req_data);

            if(${"title".$i}!=''){
                # 이미지업로드
                if($_FILES['main_img'.$i]['name']!='') {
                     # image upload
                    $upload_path = './files/ranking/'.date("Y")."/".date("m");
                    if (!is_dir($upload_path)) {
                        mkdir($upload_path, 0775, TRUE);
                    }
                    $config['upload_path']      = $upload_path;
                    $config['allowed_types']    = 'gif|jpg|png';
                    $config['encrypt_name']     = TRUE;

                    $this->load->library('upload');
                    $this->upload->initialize($config);

                    if ( ! $this->upload->do_upload('main_img'.$i)) {
                        $error = array('error' => $this->upload->display_errors());
                        gf_alert("이미지 업로드에 실패했습니다.", 'back');
                        exit;
                    }
                    $arr_upload_data = $this->upload->data();
                    $filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);

                } else {
                    if(${"img".$i}!='') {
                        # image upload
                        $upload_path = './files/ranking/'.date("Y")."/".date("m");
                        if (!is_dir($upload_path)) {
                            mkdir($upload_path, 0775, TRUE);
                        }

                        $arr_new_file =  explode('/', ${"img".$i});
                        copy('.'.${"img".$i}, $upload_path.'/'.$arr_new_file[5]);
                        $filename = '/files/ranking/'.date("Y").'/'.date("m").'/'.$arr_new_file[5];

                    } else {
                        $filename = ${"org_img".$i};
                    }
                }
                $arr_req_data = array('ranking_type'=> $ranking_type, 'content_type'=> $content_type, 'rank'=>$i, 'content_idx' => ${"content_idx".$i}, 'head_title' => ${"head_title".$i}, 'title' => ${"title".$i}, 'sub_content' => ${"sub_content".$i}, 'main_img' => $filename);

                if($rank_count == 0) {
                    $this->m_ranking->ranking_insert($arr_req_data);
                } else {
                    $this->m_ranking->ranking_update($arr_req_data);
                }

                if($ranking_type == '1' && ${"hit_count".$i} > 0) {

                    $insert_data['idx']         = ${"content_idx".$i};
                    $insert_data['hit_count']   = ${"hit_count".$i};

                    $this->load->model('admin/life/m_life');
                    $this->m_life->life_update($insert_data);
                    
                } else if($ranking_type == '3' && ${"share_count".$i} > 0) {
                    $insert_data['idx']         = ${"content_idx".$i};
                    $insert_data['share_count'] = ${"share_count".$i};

                    $this->load->model('admin/life/m_life');
                    $this->m_life->life_update($insert_data);
                }

            } else {
                if($rank_count > 0 && $mode != 'edit') {
                    $this->m_ranking->ranking_rank_is_del_update($req_data);
                }
            }

        }

        gf_alert("저장되었습니다.", "/admin/life/life_ranking_list/5");


    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 랭킹관리 수정
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_ranking_edit() {
        # 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_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $search_theme_type      = trim($this->input->get_post('search_theme_type', TRUE));
        $search_ranking_type    = trim($this->input->get_post('search_ranking_type', TRUE));
        $idx                    = trim($this->input->get_post('idx', TRUE));
        $content_type           = DEF_LIFE_CODE;


        # model
        $this->load->model('admin/life/m_ranking');
        $result   = $this->m_ranking->ranking_join_life_select($idx);
        if(count($result) ==0){
            gf_alert("잘못된 접근입니다.", '/admin/main');
            exit;

        }



        $return_data = array();
        $return_data['page']                    = $page;
        $return_data['search_type']             = $search_type;
        $return_data['search_keyword']          = $search_keyword;
        $return_data['search_ranking_type']     = $search_ranking_type;
        $return_data['search_category_code1']   = $search_category_code1;
        $return_data['search_category_code2']   = $search_category_code2;
        $return_data['search_life_type']        = $search_life_type;
        $return_data['search_theme_type']       = $search_theme_type;
        $return_data['idx']                     = $idx;
        $return_data['result']                  = $result[0];
        $return_data['content_type']            = $content_type;
        # view
        return $this->load->view('/admin/life/life_ranking_edit', $return_data, true);

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 랭킹 관리 - 저장
    # CREATE  :	2018-03-22
    #---------------------------------------------------------------------------
	function fn_life_ranking_edit_proc() {
        # request
        $ranking_type       = trim($this->input->get_post('ranking_type', TRUE));
        $content_idx        = trim($this->input->get_post('content_idx', TRUE));
        $head_title         = trim($this->input->get_post('head_title', TRUE));
        $title              = trim($this->input->get_post('title', TRUE));
        $sub_content        = trim($this->input->get_post('sub_content', TRUE));
        $img                = trim($this->input->get_post('img', TRUE));
        $org_img            = trim($this->input->get_post('org_img', TRUE));
        $idx                = trim($this->input->get_post('idx', TRUE));
        $hit_count          = trim($this->input->get_post('hit_count', TRUE));
        $share_count        = trim($this->input->get_post('share_count', TRUE));


        # 이미지업로드
        if($_FILES['main_img']['name']!='') {
             # image upload
            $upload_path = './files/ranking/'.date("Y")."/".date("m");
            if (!is_dir($upload_path)) {
                mkdir($upload_path, 0775, TRUE);
            }
            $config['upload_path']      = $upload_path;
            $config['allowed_types']    = 'gif|jpg|png';
            $config['encrypt_name']     = TRUE;

            $this->load->library('upload');
            $this->upload->initialize($config);

            if ( ! $this->upload->do_upload('main_img')) {
                $error = array('error' => $this->upload->display_errors());
                gf_alert("이미지 업로드에 실패했습니다.", 'back');
                exit;
            }
            $arr_upload_data = $this->upload->data();
            $filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);

        } else {
            if($img!='') {
                # image upload
                $upload_path = './files/ranking/'.date("Y")."/".date("m");
                if (!is_dir($upload_path)) {
                    mkdir($upload_path, 0775, TRUE);
                }

                $arr_new_file =  explode('/', $img);
                copy('.'.$img, $upload_path.'/'.$arr_new_file[5]);
                $filename = '/files/ranking/'.date("Y").'/'.date("m").'/'.$arr_new_file[5];

            } else {
                $filename = $org_img;
            }
        }


        $req_data = array();
        $req_data['content_idx']    = $content_idx;
        $req_data['head_title']     = $head_title;
        $req_data['title']          = $title;
        $req_data['sub_content']    = $sub_content;
        $req_data['main_img']       = $filename;
        $req_data['idx']            = $idx;
        $this->load->model('admin/comm/m_ranking');
        $this->m_ranking->ranking_where_idx_update($req_data);

        # news 에 조회수, 공유수 업데이트
        $update_date = array();
        if($ranking_type == '1' && $hit_count > 0) {
            $update_date['idx']         = $content_idx;
            $update_date['hit_count']   = $hit_count;

            $this->load->model('admin/life/m_life');
            $this->m_life->life_update($update_date);
        } else if($ranking_type == '3' && $share_count > 0) {
            $update_date['idx']         = $content_idx;
            $update_date['share_count'] = $share_count;

            $this->load->model('admin/life/m_life');
            $this->m_life->life_update($update_date);
        }

        gf_alert("저장되었습니다.", "/admin/life/life_ranking_list/5");


    }





    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 랭킹관리 - 삭제
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_ranking_reg_del_proc() {
        # request
        $idx                    = trim($this->input->get_post('idx', TRUE));

        # model
        $this->load->model('admin/comm/m_ranking');


        $req_date[] = $idx;

        # model - update
        $this->m_ranking->ranking_is_del_update($req_date);

        gf_alert("삭제되었습니다.", '/admin/life/life_ranking_list/5');

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	라이프관리 > 랭킹관리 - 삭제 (다중)
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_ranking_reg_arr_del_proc() {
        # request
        $arr_idx    = $this->input->get_post('is_del', TRUE);   // 삭제할 idx


        # model
        $this->load->model('admin/comm/m_ranking');



        # model - update
        $this->m_ranking->ranking_is_del_update($arr_idx);

        gf_alert("삭제되었습니다.", '/admin/life/life_ranking_list/5');

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	지난 랭킹별 라이프관리
    # CREATE  :	2018-04-13
    #---------------------------------------------------------------------------
	function fn_life_ranking_log_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_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $search_theme_type      = trim($this->input->get_post('search_theme_type', TRUE));
        $search_ranking_type    = trim($this->input->get_post('search_ranking_type', TRUE));
        $sort                   = trim($this->input->get_post('sort', TRUE));
        $content_type           = DEF_LIFE_CODE;


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

        

        # 검색
        $req_data = array();
        $req_data['search_type']            = $search_type;
        $req_data['search_keyword']         = addslashes($search_keyword);
        $req_data['search_ranking_type']    = $search_ranking_type;
        $req_data['search_category_code1']  = $search_category_code1;
        $req_data['search_category_code2']  = $search_category_code2;
        $req_data['search_life_type']       = $search_life_type;
        $req_data['search_theme_type']      = $search_theme_type;
        $req_data['content_type']           = $content_type;

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


        # model - 카테고리 list
        $this->load->model('admin/comm/m_ranking_log');
        $total_count    = $this->m_ranking_log->ranking_log_join_life_list_total_count($req_data);
        $result         = $this->m_ranking_log->ranking_log_join_life_list($req_data);


        # 카테고리 리스트
        $this->load->model('admin/life/m_life_category');
        $arr_category1   = $this->m_life_category->category_all_list();

        # 채널 리스트
        $this->load->model('admin/life/m_life_channel');
        $arr_category2   = $this->m_life_channel->channel_all_list();



        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/life/life_ranking_log_list/5';
        $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_category_code1']   = $search_category_code1;
        $return_data['search_category_code2']   = $search_category_code2;
        $return_data['search_ranking_type']     = $search_ranking_type;
        $return_data['search_life_type']        = $search_life_type;
        $return_data['search_theme_type']        = $search_theme_type;
        $return_data['sort']                    = $sort;
        $return_data['list']                    = $result;
        $return_data['arr_category1']           = $arr_category1;
        $return_data['arr_category2']           = $arr_category2;

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

    }


    #---------------------------------------------------------------------------
    # PURPOSE :	댓글관리
    # CREATE  :	2018-03-21
    #---------------------------------------------------------------------------
	function fn_life_comment_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_life_type       = trim($this->input->get_post('search_life_type', TRUE));
        $search_comment_type    = trim($this->input->get_post('search_comment_type', TRUE));
        $search_category_code1  = trim($this->input->get_post('search_category_code1', TRUE));
        $search_category_code2  = trim($this->input->get_post('search_category_code2', TRUE));
        $search_theme_type      = trim($this->input->get_post('search_theme_type', TRUE));
        $search_today           = trim($this->input->get_post('search_today', TRUE));
        $search_today_best      = trim($this->input->get_post('search_today_best', TRUE));

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

        if($search_comment_type == '')  $search_comment_type = 'N';

        $search_category_code   = $search_category_code1;
        if($search_category_code2!='')  $search_category_code   = $search_category_code2;


        # 검색
        $req_data = array();
        $req_data['search_type']            = $search_type;
        $req_data['search_keyword']         = addslashes($search_keyword);
        $req_data['search_comment_type']    = $search_comment_type;
        $req_data['search_life_type']       = $search_life_type;
        $req_data['search_category_code']   = $search_category_code;
        $req_data['offset']                 = $offset;
        $req_data['limit']                  = $limit;
        $req_data['search_theme_type']      = $search_theme_type;
        $req_data['content_type']           = DEF_LIFE_CODE;
        $req_data['search_today_best']      = $search_today_best;
        $req_data['search_today']           = $search_today;

	    # model - 카테고리 list
        $this->load->model('admin/life/m_life_comment');
        $total_count    = $this->m_life_comment->life_comment_list_total_count($req_data);
        $result         = $this->m_life_comment->life_comment_list($req_data);
        $new_count      = $this->m_life_comment->life_comment_new_count($req_data);
        $best_count     = $this->m_life_comment->life_comment_is_best_count($req_data);
        $best_new_count = $this->m_life_comment->life_comment_is_best_new_count($req_data);



        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/life/life_comment_list/5';
        $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_life_type']        = $search_life_type;
        $return_data['search_comment_type']     = $search_comment_type;
        $return_data['search_theme_type']       = $search_theme_type;
        $return_data['search_category_code1']   = $search_category_code1;
        $return_data['search_category_code2']   = $search_category_code2;
        $return_data['list']                    = $result;
        $return_data['new_count']               = $new_count;
        $return_data['best_count']              = $best_count;
        $return_data['best_new_count']          = $best_new_count;
        $return_data['search_today']            = $search_today;
        $return_data['search_today_best']       = $search_today_best;

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

    }

    #---------------------------------------------------------------------------
    # PURPOSE :	칼럼댓글 삭제
    # CREATE  :	2018-03-08
    #---------------------------------------------------------------------------
	function fn_life_comment_del_proc() {
        # request
        $idx                    = trim($this->input->get_post('idx', TRUE));

        $comment = '관리자에 의해 삭제된 댓글입니다.';

        # 검색
        $req_data = array();
        $req_data['idx']            = $idx;
        $req_data['comment_status'] = '6';  // 관리자삭제
        $req_data['comment']        = $comment;
        # model
        $this->load->model('admin/column/m_column_comment');
        $this->m_column_comment->column_comment_is_del_update($req_data);

        gf_alert("삭제되었습니다.", '/admin/life/life_comment_list/5');

    }







    #---------------------------------------------------------------------------
    # PURPOSE :	태그관리
    # CREATE  :	2018-03-12
    #---------------------------------------------------------------------------
	function fn_life_tag_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));
        $sort                   = trim($this->input->get_post('sort', TRUE));
        $content_type           = DEF_LIFE_CODE;

        if($sort=='')   $sort ='1';
        switch ($sort) {
            case '1': $sort_column = 'reg_date'; break;
            case '2': $sort_column = 'hit_count'; break;
            default : $sort_column = 'reg_date'; break;
        }

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


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

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

	    # model - list
        $this->load->model('admin/comm/m_tag');
        $total_count    = $this->m_tag->tag_list_total_count($req_data);
        $result         = $this->m_tag->tag_list($req_data);



        # pagination
        $req_data = array();
        $req_data['total_count']    = $total_count;
        $req_data['limit']          = $limit;
        $req_data['base_url']       = '/admin/life/life_tag_list/5';
        $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['sort']                    = $sort;
        $return_data['list']                    = $result;


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

    }



    #---------------------------------------------------------------------------
    # PURPOSE : 상태,노출일 변경
    # CREATE  :	2018-05-01
    #---------------------------------------------------------------------------
	function fn_ajax_life_is_display_update() {
        # request
        $idx            = trim($this->input->get_post('idx', TRUE));
        $is_display     = trim($this->input->get_post('is_display', TRUE));
        $content_type   = 3;

        $req_data = array();
        $req_data['content_type']   = $content_type;
        $req_data['content_idx']    = $idx;
        $req_data['search_type']    = 'is_display';
        $req_data['search_key']     = 'N';

        // 테마
        $this->load->library('comm_admin');
        $this->comm_admin->fn_theme_change_is_display($req_data);

        // 기타테마
        $this->load->library('comm_admin');
        $this->comm_admin->fn_etc_section_change_is_display($req_data);



        $req_data = array();
        $req_data['idx']            = $idx;
        $req_data['is_display']     = $is_display;

        # model
        $this->load->model('admin/life/m_life');
        $result = $this->m_life->life_is_display_update($req_data);
        if(!$result){
            $return_data['result'] = array('result_code' => '9999');
        } else {
            $return_data['result'] = array('result_code' => '0000');
        }


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

    }











}

?>