<?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/m/cm_controller.php');
class main2 extends cm_Controller {
    
	function fn_index() {
            $this->load->model('web/m_theme');
      # theme_type = 1 (헤드라인뉴스), theme_type = 8 (오늘의칼럼), theme_type = 11 (라이프홈), theme_type = 12 (데일리큐티)
      # 16 = 상단(2) , 17 = 라이프(3) , 18 = 은혜의샘(6), 19(3) = 하늘양식, 20=상단_빅원(1), 21=중상단(6)
      $this->load->model('web/m_theme');
      $req_data = array();
      $req_data['theme_types'] = array('21', '11','12','26');
      $arr_theme = $this->m_theme->theme_join_vw_content_where_in_theme_type_list($req_data);

      $arr_life_home      = array();
      $arr_daily_cutie    = array();
      foreach ($arr_theme as $val) {
            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']);
            if($val['theme_type'] == 21)     $arr_grace_middle[$val['rank']] = $val;
            
      }


      $req_data = array();
      $req_data['search_type']            = '';
      $req_data['search_keyword']         = '';
      $req_data['search_life_type']       = '';
      $req_data['search_category_code1']  = 17;
      $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']                  = 6;
      $this->load->model('admin/life/m_life');
      $this->load->model('web/m_channel');

      // 책
      $req_data['search_category_code2']  = 26;
      $arr_book = $this->m_channel->channel_join_category_select(26);
      $arr_book['data']   = $this->m_life->life_list($req_data);
      

      // 카드뉴스형식 깨알은혜
      $req_data['search_category_code1']  = 5;
      $req_data['search_category_code2']  = 28;
      $req_data['limit']                  = 4;
      $arr_card = $this->m_channel->channel_join_category_select(28);
      $arr_card['data']   = $this->m_life->life_list($req_data);
      
      // 영어 한구절 
      $req_data['search_category_code1']  = 10;
      $req_data['search_category_code2']  = 7;
      $req_data['limit']                  = 2;
      $arr_en = $this->m_channel->channel_join_category_select(7);
      $arr_en['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
      $arr_en['data']   = $this->m_life->life_list($req_data);

      // 영어 한구절 
      $req_data['search_category_code1']  = 10;
      $req_data['search_category_code2']  = 8;
      $arr_knowledge = $this->m_channel->channel_join_category_select(8);
      $arr_knowledge['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
      $arr_knowledge['data']   = $this->m_life->life_list($req_data);

      // 말씀엽서
      $req_data['search_category_code1']  = 5;
      $req_data['search_category_code2']  = 3;
      $arr_post = $this->m_channel->channel_join_category_select(3);

      // 운율있는 묵상
      $req_data['search_category_code1']  = 8;
      $req_data['search_category_code2']  = 6;
      $req_data['limit']                  = 4;
      $arr_poem = $this->m_channel->channel_join_category_select(8);
      $arr_poem['channel_article_count'] = $this->m_life->life_list_total_count($req_data);
      $arr_poem['data']   = $this->m_life->life_list($req_data);

      $arr_channel =array($arr_poem, $arr_post, $arr_en, $arr_card, $arr_book);

      $return_data['page_title_1'] = "은혜";
      $return_data['arr_life_home'] = $arr_life_home;
      $return_data['arr_daily_cutie'] = $arr_daily_cutie;
      $return_data['arr_grace_middle'] = $arr_grace_middle;
      $return_data['arr_book'] = $arr_book;
      $return_data['arr_card'] = $arr_card;
      $return_data['arr_en'] = $arr_en;
      $return_data['arr_knowledge'] = $arr_knowledge;
      $return_data['arr_post'] = $arr_post;
      $return_data['arr_poem'] = $arr_poem;
      $return_data['arr_channel'] = $arr_channel;

        return $this->load->view('/m/life/main3', $return_data, true);
    }
}

?>
