<?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/web/cm_controller.php');
class cmtv extends cm_Controller {

    #---------------------------------------------------------------------------
    # PURPOSE : 메인
    # CREATE  :	2019-04-17
    #---------------------------------------------------------------------------
	function fn_index() {

        $this->load->library('user_agent');
        if ($this->agent->is_mobile()){
            $this->load->helper('url');
            redirect($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].'/m/cmtv/', 'refresh');
        }

        // 말씀과 묵상
        $req_data = array();
        $req_data['search_type']            = '';
        $req_data['search_keyword']         = '';
        $req_data['search_life_type']       = '';
        $req_data['search_category_code1']  = 22;
        $req_data['search_category_code2']  = '';
        $req_data['search_click1']          = '';
        $req_data['search_click2']          = '1';
        $req_data['sort_column']            = 'a.reg_date';
        $req_data['search_write_id']        = '';
        $req_data['offset']                 = 0;
        $req_data['limit']                  = 4;
        $this->load->model('admin/life/m_life');
        $this->load->model('web/m_channel');

        // 말씀영상
        $req_data['search_category_code2']  = '42';
        $arr_words = $this->m_channel->channel_join_category_select(42);
        $arr_words['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
        $arr_words['data']   = $this->m_life->life_list($req_data);

        //찬양영상
        $req_data['search_category_code2']  = '43';
        $arr_praise = $this->m_channel->channel_join_category_select(43);
        $arr_praise['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
        $arr_praise['data'] = $this->m_life->life_list($req_data);

        // 간증
        $req_data['search_category_code2']  = '44';
        $arr_testimony = $this->m_channel->channel_join_category_select(44);
        $arr_testimony['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
        $arr_testimony['data']   = $this->m_life->life_list($req_data);

        //토크쇼
        $req_data['search_category_code2']  = '45';
        $arr_talkshow   = $this->m_channel->channel_join_category_select(45);
        $arr_talkshow['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
        $arr_talkshow['data']   = $this->m_life->life_list($req_data);

        # view data
        $return_data['channel'] = array();
        array_push($return_data['channel'], $arr_words, $arr_praise, $arr_testimony, $arr_talkshow);
        // $return_data['arr_praise']           = ;
        // $return_data['arr_testimony']        = ;
        // $return_data['arr_talkshow']         = ;

        # view
        return $this->load->view('/web/cmtv/channel_recommend', $return_data, true);

    }
}
?>