<?
if($result_code == '0000') {
    echo '0000|||||';
    $row_count = count($list);
    if($row_count > 0) {

		$ci=& get_instance();
		$ci->load->model('web/m_life');
		$ci->load->model('web/m_column');
		$ci->load->model('web/m_tag');
		foreach ($list as $val) {

			$idx                    = $val['idx'];
			$delivery_count         = $val['delivery_count'];
			$reg_date               = $val['reg_date'];
			$main_idx               = $val['main_idx'];
			$content_type         	= $val['content_type'];

			$now_date               = date("Y-m-d").' 00:00:00';

			if($content_type == '2') {
				$article_count      	= $val['article_count'];
				$delivery_title         = $val['partner_name'];
				$main_img           	= $val['partner_img'];

				$req_data = array();
				$req_data['offset']   	 	= 0;
				$req_data['limit']    		= 1;
				$req_data['sort_column']   	= 'display_date';
				$req_data['search_type']   	= 'partner_idx';
				$req_data['search_key']   	= $val['main_idx'];
				$delivery_row    = $ci->m_column->column_list($req_data);

				$delivery_row_display_date_txt = ''; $title=''; $article_view_url='';
				if(count($delivery_row) > 0) {
					$display_date           = $delivery_row[0]['display_date'];
					$delivery_row_display_date_txt  = substr($display_date, 0, 16);
					$title 					= $delivery_row[0]['title'];
					$article_view_url = '/web/news/column_view/'.$delivery_row[0]['idx'];
				}

				$view_url  = '/web/news/columnist/'.$main_idx;

				$req_data = array();
                $req_data['partner_idx']    = $val['main_idx'];
                $req_data['now_date']    	= $now_date;

				$delivery_today_count       = $ci->m_column->column_where_display_date_partner_idx_count($req_data);


			} else if($content_type == '3') {
				$article_count      	= $val['article_count'];
				$delivery_title         = $val['channel_name'];
				$main_img           	= $val['channel_icon'];


				$req_data = array();
				$req_data['channel_idx']    = $val['main_idx'];
				$delivery_row    = $ci->m_life->life_where_channel_idx_list_limit1($req_data);
				$display_date           = $delivery_row['display_date'];
				$delivery_row_display_date_txt  = substr($display_date, 0, 16);

				$article_view_url = '/web/life/life_view/'.$delivery_row['idx'];
				$view_url  = '/web/life/channel/'.$main_idx;

				$req_data = array();
                $req_data['channel_idx']    = $val['main_idx'];
                $req_data['now_date']    = $now_date;

                $delivery_today_count       = $ci->m_life->life_where_display_date_channel_idx_count($req_data);

				$title = $delivery_row['title'];

			} else if($content_type == '9') {
				$delivery_title         = '#'.$main_idx;
				$main_img           	= '';

				$req_data = array();
				$req_data['tag']    = $val['main_idx'];
				$delivery_row    	= $ci->m_tag->tag_join_life_where_tag_list_limit1($req_data);
				$article_count      = $ci->m_tag->tag_join_life_where_tag_count($req_data);

				$display_date           = $delivery_row['display_date'];
				$delivery_row_display_date_txt  = substr($display_date, 0, 16);
				

				$req_data = array();
				$req_data['tag']    		= $val['main_idx'];
				$req_data['now_date']    	= $now_date;

				$delivery_today_count       = $ci->m_tag->tag_join_life_where_display_date_count($req_data);

				$article_view_url = '/web/life/life_view/'.$delivery_row['idx'];
				$view_url  = '/web/life/tag/'.$main_idx;

				$title = $delivery_row['title'];
				$title = mb_strimwidth($title, '0', '200', '..', 'utf-8');

			}


	?>
			<div class="pop_cont_box_d">
				<input type="text" name="copy_delivery_url<?=$idx?>" id="copy_delivery_url<?=$idx?>" style="position:absolute;top:-9999em;" value="<?=WWW_CROSSMAP?><?=$view_url?>">
				<input type="hidden" name="is_del[]" value="<?=$idx?>">
			<? if(count($delivery_row) > 0) { ?>
				<div class="pop_cont_title_d">
					<a href="<?=$article_view_url?>"><?=$title?></a>
					<p class="popup_date_d"><?=$delivery_row_display_date_txt?></p>
				</div>
			<?	}?>
				<div class="pop_cont_txt">
				<? 	if($main_img!='') {?>
					<span class="pop_cont_img_d" style="padding-top: 10px">
						<div onclick="location.href='<?=$view_url?>'" style="border-radius:50px;cursor:pointer;width:50px;height:50px;background:url('<?=$main_img?>') no-repeat center; background-size:cover;"></div>
					</span>
				<?	}?>
					<div class="pop_cont_txt_box_d">
						<p class="t_black"><a href="<?=$view_url?>"><?=$delivery_title?></a> <? if($delivery_today_count>0) {?><span class="pop_cont_like_d"><?=number_format($delivery_today_count)?>+</span><? }?></p>
						<p><span class="beachblue"><?=number_format($article_count)?></span>개의 글이 있습니다.   <span style="padding:0 10px;">|</span>  <span class="beachblue"><?=number_format($delivery_count)?></span>명에게 배달 중</p>
					</div>
					<div class="pop_cont_info_d">
						<span class="fr"><a href="javascript:change_toggle('delivery_info<?=$idx?>')"><img src="/img/web/pop_info.png"></a></span>
						<ul class="info_popup_d" id="delivery_info<?=$idx?>" style="display:none;">
							<li><a href="javascript:delivery_del('<?=$idx?>');">삭제하기</a></li>
							<li style="border-top:1px solid #ededed"><a href="javascript:copy_delivery_url('<?=$idx?>');">링크복사</a></li>
						</ul>
					</div>
				</div>
			</div>
	<?  }

    }

    if($more_list=='N') echo '<div style="height:50px"></div>';

    echo '|||||'.$total_count.'|||||'.$more_list;

} else {
    echo $result_code.'|||||데이터 가져오기에 실패했습니다.';

}
?>