<?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 prayer 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/prayer/', 'refresh');
        }
        // 말씀과 묵상
        $req_data = array();
        $req_data['search_type']            = '';
        $req_data['search_keyword']         = '';
        $req_data['search_life_type']       = '';
        $req_data['search_category_code1']  = 26;
        $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']  = '49';
        $world = $this->m_channel->channel_join_category_select(49);
        $world['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
        $world['data']   = $this->m_life->life_list($req_data);

        //아침을 여는 기도
        $req_data['search_category_code2']  = '18';
        $moning = $this->m_channel->channel_join_category_select(18);
        $moning['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
        $moning['data'] = $this->m_life->life_list($req_data);

        // 순교자의 소리
        $req_data['search_category_code2']  = '46';
        $sound = $this->m_channel->channel_join_category_select(46);
        $sound['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
        $sound['data']   = $this->m_life->life_list($req_data);

        //Open door
        $req_data['search_category_code2']  = '47';
        $open_door   = $this->m_channel->channel_join_category_select(47);
        $open_door['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
        $open_door['data']   = $this->m_life->life_list($req_data);

		//Corner stone
        $req_data['search_category_code2']  = '50';
        $corner_stone   = $this->m_channel->channel_join_category_select(50);
        $corner_stone['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
        $corner_stone['data']   = $this->m_life->life_list($req_data);

        # view data
        $return_data['channel'] = array();
        $return_data['page_title'] = "기도공감";
        array_push($return_data['channel'], $world, $moning, $sound, $open_door, $corner_stone);
        // $return_data['arr_praise']           = ;
        // $return_data['arr_testimony']        = ;
        // $return_data['arr_talkshow']         = ;

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

    }
}
?>