<?
$main_column_name 	= $arr_columnist['partner_name'];
$main_column_idx 	= $arr_columnist['idx'];

$column_delivery_btn = '/img/web/bt_delivery_off_gray.png';
if($column_delivery_count > 0) {
	$column_delivery_btn = '/img/web/bt_delivery_on_gray.png';
}

$content_type ='2';

$SES_MEMBER_ID          = $this->session->userdata('C_Member_Id');


?>



	<div class="contents">
		<div class="wrap">
			<div class="list_left">
				<div class="news_list">
					<div class="rankynews">
						<div class="news_cate">
							<span class="beachblue" style="padding-right:5px;"><a href="/web/news/column">오피니언</a></span>
				            <span class="text"><a href="/web/news/columnist/<?=$main_column_idx?>"><?=$main_column_name?></a></span>
							<span class="category" style="float:right">
							<span style="padding-top:1px;"><a href="javascript:column_delivery();"><img src="<?=$column_delivery_btn?>" id="column_delivery_btn"></a>　</span>
						</div>
						<div class="rankytop" style="margin-bottom:10px">
							<span <? if($search_sort=='1') { echo 'class="radio_on" '; } else { echo 'class="radio_off"';}?> style="margin-right:10px;width: 60px;float: left;"><a href="/web/news/columnist/<?=$main_column_idx?>?search_sort=1">최신순</a></span>
							<span <? if($search_sort=='2') { echo 'class="radio_on" '; } else { echo 'class="radio_off"';}?> style="float: left;width: 60px;"><a href="/web/news/columnist/<?=$main_column_idx?>?search_sort=2">인기순</a></span>
						</div>
					</div>

			<?
				if($total_count == 0) {
			?>
					<div style="margin:30px 0px 40px 0px;text-align: center;">
						등록된 칼럼이 없습니다.
					</div>
			<?
				} else {

                    foreach ($list as $val) {

                        $comment_count = $val['comment_count'];
                        $comment_count_txt = $comment_count;
                        if($comment_count > 9) {
                            $calc_count = str_pad(1, strlen($comment_count), "0", STR_PAD_RIGHT);
                            $comment_count_txt = (floor($comment_count/$calc_count)) * $calc_count;
                            $comment_count_txt = $comment_count_txt.'+';
                        }

                        $display_date =  $val['display_date'];
                        $display_date_txt = substr($display_date, 0, 10);
                        $display_date_txt = str_replace('-', '.', $display_date_txt);

                        $title_txt 		= mb_strimwidth($val['title'], '0', '50', '..', 'utf-8');
						$content 		= preg_replace("(\<(/?[^\>]+)\>)", "", $val['content']);
                        $content_txt 	= mb_strimwidth(strip_tags($content), '0', '250', '..', 'utf-8');

			?>


					<div class="news_list_cont">
						<div class="art-img2"><a href="/web/news/column_view/<?=$val['idx']?>"><img src="<?=$val['main_img']?>" width="160"></a></div>
						<div class="art-info2">
							<h2 class="art-title"><a href="/web/news/column_view/<?=$val['idx']?>"><?=$title_txt?></a><span class="comment fr"><img src="/img/web/img_comment.png"> <?=$comment_count_txt?></span></h2>
							<p class="art-sum"><a href="/web/news/column_view/<?=$val['idx']?>"><?=$content_txt?></a> </p>
						</div>
					</div>

		 	<?		}

				}
			?>
				</div>
			<? if($pagination !='') {?>
				<div class="pagenumber">
					<?=$pagination?>
				</div>
			<? }?>


				<? include_once ('news_main_content_inc.php');?>

			</div>

            <? include_once ('news_right_inc.php');?>

		</div>
	</div>

    <? include_once ('news_footer_inc.php');?>



<script>
function column_delivery(){
	if("<?=$SES_MEMBER_ID?>"=="") {
        alert("로그인 후에 이용가능합니다.");
        return;
    }
	var form_data = {
		"main_idx"			: <?=$main_column_idx?>,
		"content_type"		: <?=$content_type?>
	};
	$.ajax({
        url: '/web/comm/delivery_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
				$("#column_delivery_btn").attr("src","/img/web/bt_delivery_"+rtnJson.data+"_gray.png");

            } else {
                alert("저장에 실패했습니다.");
                return false;
            }
        },
        error: function (rtnJson) {
            alert('저장에 실패했습니다.');
            return false;
        }
    });

}


</script>


