<?
$menu_code = '44';
require_once (APPPATH.'views/skin/admin/_content_comm.php');
?>


<form name="input_form" id="input_form" method="post" action="/admin/member/columnist_list/4">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<input type="hidden" id="sort" name="sort" value="<?=$sort?>">
<input type="hidden" id="member_group_idx" name="member_group_idx" value="<?=$member_group_idx?>">
<input type="hidden" id="idx" name="idx">
<input type="hidden" id="mode" name="mode">



<div class="common_table clearfix type01">

	<div class="searh_area">
		<select name="search_type" id="search_type">
			<option value="">선택</option>
            <option value="partner_name" <? if($search_type=='partner_name'){ echo 'selected';}?>>칼럼명</option>
            <option value="partner_real_name" <? if($search_type=='partner_real_name'){ echo 'selected';}?>>이름</option>
		</select> <input type="text" name="search_keyword" id="search_keyword" value="<?=$search_keyword?>" onkeypress="if( event.keyCode==13 ){check_search();}">
		<a href="javascript:check_search();" class="btn"><i class="fa moving_all fa-search" style="margin-left:8px;"></i></a>
	</div>
</div>



<div class="common_table">
<span style="font-weight:bold">Total:</span> <?=number_format($total_count);?>
<span style="margin-left: 5px"><input type="radio" name="sort" value="1" <? if($sort=='1') { echo 'checked';}?> onclick="check_search();"> 최신순</span>
<span style="margin-left: 5px"><input type="radio" name="sort" value="2" <? if($sort=='2') { echo 'checked';}?> onclick="check_search();"> 작성글순</span>

<table>
<tr>
	<th><input type="checkbox" name="allcheck" id="allcheck"></th>
	<th>번호</th>
	<th>이미지</th>
	<th>칼럼명</th>
	<th>이름</th>
	<th>성별</th>
	<th>가입일</th>
	<th>최종방문</th>
	<th>출력순위</th>
	<th>작성글수</th>
	<th>관리</th>
</tr>

<?
	if(count($list)==0) {
?>
		<tr>
			<td colspan="10">등록된 내용이 없습니다.</td>
		</tr>
<?
	} else {

	    $dataNumber = ($total_count + $limit)-($page*$limit);
		foreach($list as $val) {
            $idx                = $val['idx'];
			$partner_id 	    = $val['partner_id'];
			$partner_img 	    = $val['partner_img'];
			$partner_real_name 	= $val['partner_real_name'];
			$partner_name 	    = $val['partner_name'];
			$partner_gender 	= $val['partner_gender'];
			$reg_date 	        = $val['reg_date'];
			$last_login_date 	= $val['last_login_date'];
			$article_count 		= $val['article_count'];
			$display_sort 		= $val['display_sort'];

           	$partner_gender_txt = '';
            if($partner_gender == 1) {
            	$partner_gender_txt = '남';
			} else if($partner_gender == 2) {
				$partner_gender_txt = '여';
			}

?>

		<tr>
			<td><input type="checkbox" name="is_del[]" value="<?=$idx?>"></td>
			<td><?=$dataNumber?></td>
			<td><img src="<?=$partner_img?>" width="40"></td>
			<td><a href="/admin/column/column_list/3?search_type=write_id&search_keyword=<?=$partner_id?>"><?=$partner_name?></a></td>
			<td><?=$partner_real_name?></td>
			<td><?=$partner_gender_txt?></td>
			<td><?=$reg_date?></td>
			<td><?=$last_login_date?></td>
			<td><?=number_format($display_sort)?></td>
			<td><?=number_format($article_count)?></td>
			<td style="width:200px" class="tool_btn">
				<a href="javascript:partner_edit('<?=$idx?>')"><i class="fa fa-pencil"></i>수정</a>
				<a href="javascript:partner_del_proc('<?=$idx?>')"><i class="fa fa-close"></i>삭제</a>
				<a href="javascript:partner_article_del_proc('<?=$idx?>')"><i class="fa fa-close"></i>전체게시글삭제</a>
				<a href="/admin/column/column_list/3?search_type=write_id&search_keyword=<?=$partner_id?>"><i class="fa fa-file"></i>전체게시글보기</a>
			</td>
		</tr>

<?
		    $dataNumber--;
		}
	}
?>

</tbody>
</table>
</div>
<div class="write_btn">
	<a href="javascript:partner_arr_del_proc();">삭제</a>
	<a href="javascript:partner_add();">칼럼니스트등록</a>
</div>


<div class="pasing_wrap">
	<?=$pagination?>
</div>
</form>


<script type="text/javascript">
function check_search(){
    if($("#search_type").val()=="" && $("#search_keyword").val()!=""){
        alert("검색할 항목을 선택해주세요.");
        return false;
    }

    $("#input_form").submit();
}


function partner_add(){
	$("#mode").val('add');
	$("#input_form").attr("action", "/admin/member/columnist_reg/4");
	$("#input_form").submit();
}


// 수정페이지
function partner_edit(idx){
	$("#mode").val('edit');
	$("#idx").val(idx);
	$("#input_form").attr("action", "/admin/member/columnist_reg/4");
	$("#input_form").submit();
}

// 삭제
function partner_del_proc(idx) {
	$("#idx").val(idx);
	if(confirm("에디터가 삭제됩니다. 삭제하시겠습니까?") == true) {    //확인
		$("#partner_idx").val(idx);
		$("#input_form").attr("action", "/admin/member/partner_del_proc");
		$("#input_form").submit();
	} else {   //취소
		return;
	}
}
// 복수 삭제
function partner_arr_del_proc() {
	if($("input:checkbox[name='is_del[]']").is(":checked") == false) {
		alert("삭제할 내용이 없습니다.");
		return false;
	}
	if(confirm("에디터가 삭제됩니다. 삭제하시겠습니까?") == true) {    //확인
		$("#input_form").attr("action", "/admin/member/partner_del_arr_del_proc");
		$("#input_form").submit();
	} else {   //취소
		return;
	}
}

// 칼럼리스트의 글 모두 삭제
function partner_article_del_proc(idx) {
	if(confirm("칼럼리스트의 글이 모두 삭제됩니다. 삭제하시겠습니까?") == true) {    //확인
        $("#idx").val(idx);
		$("#input_form").attr("action", "/admin/member/partner_article_del_proc");
		$("#input_form").submit();
	} else {   //취소
		return;
	}
}





// checkbox all checked/unchecked
$(function(){
	$("#allcheck").click(function(){
    	if($("#allcheck").prop("checked")) {
    		$("input:checkbox[name='is_del[]']").prop('checked', true); // 전체선택하기
		} else {
      		$("input:checkbox[name='is_del[]']").prop("checked", false);
    	}
  	})
})







</script>