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

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

	    $now_date  = date("Y-m-d");
        
        # 영적기상도
        $this->load->model('web/m_weather');
        $arr_weather = $this->m_weather->weather_join_relation_article_join_news_list();

        # 오늘의 말씀
        $this->load->model('web/m_today_word');
        $arr_today_word = $this->m_today_word->today_word_where_display_date_select($now_date);

        # 테마
        # theme_type = 1 (헤드라인뉴스), theme_type = 8 (오늘의칼럼), theme_type = 11 (라이프홈), theme_type = 12 (데일리큐티)
        $this->load->model('web/m_theme');
        $req_data = array();
        $req_data['theme_types'] = array('1', '11', '12');
        $arr_theme = $this->m_theme->theme_join_vw_content_where_in_theme_type_list($req_data);

        $arr_headline_news  = array();
        $arr_life_home      = array();
        $arr_daily_cutie    = array();
        foreach ($arr_theme as $val) {
            if($val['theme_type'] == 1)     $arr_headline_news[$val['rank']] = array('title' => $val['title'], 'sub_content' => $val['sub_content'], 'theme_img' => $val['theme_img'], 'content_idx' => $val['content_idx']);
            if($val['theme_type'] == 11)    $arr_life_home[$val['rank']] = array('title' => $val['title'], 'sub_title'=> $val['sub_title'], 'sub_content' => $val['sub_content'], 'theme_img' => $val['theme_img'], 'content_idx' => $val['content_idx']);
            if($val['theme_type'] == 12)    $arr_daily_cutie[$val['rank']] = array('title' => $val['title'], 'sub_content' => $val['sub_content'], 'theme_img' => $val['theme_img'], 'content_idx' => $val['content_idx']);
        }
        

        # 카드뉴스 - 기타섹션 테마
        $this->load->model('web/m_etc_section');
        $etc_section_type     = 4;
        $arr_card_news = $this->m_etc_section->etc_section_where_theme_type_list($etc_section_type);

        # 언론
        $this->load->model('web/m_press');
        $arr_press = $this->m_press->press_all_list();

        # 카테고리별
        $this->load->model('web/m_main_category_company');
        $arr_company = $this->m_main_category_company->main_category_company_all_list();

        # view data
        $return_data = array();
        $return_data['arr_weather']         = $arr_weather;
        $return_data['arr_today_word']      = $arr_today_word;
        $return_data['arr_headline_news']   = $arr_headline_news;
        $return_data['arr_life_home']       = $arr_life_home;
        $return_data['arr_daily_cutie']     = $arr_daily_cutie;
        $return_data['arr_card_news']       = $arr_card_news;
        $return_data['arr_press']           = $arr_press;
        $return_data['arr_company']         = $arr_company;


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

}

?>