<?php
$menu_code = '1010';
require_once (APPPATH.'views/skin/admin/_content_comm.php');
?>
<!-- jquery UI -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<!-- //jquery UI -->


<div class="common_table"  style="margin-top: 30px">
	<span style="font-weight:bold">웹툰 등록 및 수정</span> 
</div>

<!-- 테이블 시작-->
<div class="common_table news">
<form name="frm" method="post" action="/admin/maptoon/maptoon_proc" enctype="multipart/form-data">
<!--input type="hidden" name="mode" value="<?php if(isset($mode)==TRUE) echo $mode;?>" /-->
<input type="hidden" name="idx" value="<?php if(isset($maptoon_idx)==TRUE) echo $maptoon_idx;?>" />
<?php if(isset($aaa)==TRUE) echo $aaa;?>
<table>
<tbody>
<tr>
	<th>맵툰 썸네일</th>
	<td class="tl"><?php if(isset($data['main_img'])==TRUE && $data['main_img']!='') echo '<img src="'.$data['main_img'].'" />';?> <input type="file" name="main_img" /></td>
</tr>
<tr>
	<th>맵툰 작가명</th>
	<td class="tl">
		<select name="mt_cartoonists_idx">
			<option value="">------------</option>
		<?php
		if(isset($cartoonist)==TRUE) {
			foreach($cartoonist as $v) {
				$selected = (isset($data['mt_cartoonists_idx'])==TRUE && $v['idx']==$data['mt_cartoonists_idx']) ? 'selected' : '';
				echo '<option value="'.$v['idx'].'" '.$selected.'>'.$v['name'].'</option>\n';
			}
		}
		?>
		</select>
	</td>
</tr>
<tr>
	<th>맵툰 이름</th>
	<td class="tl">
		<input type="text" name="name" id="name" class="type01" value="<?php if(isset($data['name'])==TRUE) { echo $data['name']; }?>">
	</td>
</tr>
<tr>
	<th>상태</th>
	<td class="tl">
		<input type="radio" name="status" id="status1" class="" value="0" <?php if(isset($data['status'])==TRUE && $data['status']==0) echo 'checked'; ?>> <label for="status1">연재중</label>
		<input type="radio" name="status" id="status2" class="" value="1" <?php if(isset($data['status'])==TRUE && $data['status']==1) echo 'checked'; ?>> <label for="status2">완결</label>
		<input type="radio" name="status" id="status3" class="" value="2" <?php if(isset($data['status'])==TRUE && $data['status']==2) echo 'checked'; ?>> <label for="status3">미완결</label>
	</td>
</tr>
<tr>
	<th>연재요일</th>
	<td class="tl">
		<input type="checkbox" name="date_sun" id="date_sun" class="" value="1" <?php if(isset($data['date_sun'])==TRUE && $data['date_sun']==1) echo 'checked'; ?>> <label for="date_sun">일</label> &nbsp;
		<input type="checkbox" name="date_mon" id="date_mon" class="" value="1" <?php if(isset($data['date_mon'])==TRUE && $data['date_mon']==1) echo 'checked'; ?>> <label for="date_mon">월</label> &nbsp;
		<input type="checkbox" name="date_tue" id="date_tue" class="" value="1" <?php if(isset($data['date_tue'])==TRUE && $data['date_tue']==1) echo 'checked'; ?>> <label for="date_tue">화</label> &nbsp;
		<input type="checkbox" name="date_wed" id="date_wed" class="" value="1" <?php if(isset($data['date_wed'])==TRUE && $data['date_wed']==1) echo 'checked'; ?>> <label for="date_wed">수</label> &nbsp;
		<input type="checkbox" name="date_thu" id="date_thu" class="" value="1" <?php if(isset($data['date_thu'])==TRUE && $data['date_thu']==1) echo 'checked'; ?>> <label for="date_thu">목</label> &nbsp;
		<input type="checkbox" name="date_fri" id="date_fri" class="" value="1" <?php if(isset($data['date_fri'])==TRUE && $data['date_fri']==1) echo 'checked'; ?>> <label for="date_fri">금</label> &nbsp;
		<input type="checkbox" name="date_sat" id="date_sat" class="" value="1" <?php if(isset($data['date_sat'])==TRUE && $data['date_sat']==1) echo 'checked'; ?>> <label for="date_sat">토</label> &nbsp;
	</td>
</tr>
<tr>
	<th>맵툰 설명글</th>
	<td class="tl">
		<textarea name="description" rows="10" cols="200"><?php if(isset($data['description'])==TRUE) echo $data['description']?></textarea>
	</td>
</tr>
<tr>
	<th>관심 웹툰 등록수</th>
	<td class="tl"><?php if(isset($data['interest_count'])==TRUE) echo number_format($data['interest_count']);?></td>
</tr>
<tr>
	<th>등록 편수</th>
	<td class="tl"><?php if(isset($num_of_episodes)==TRUE) echo number_format($num_of_episodes);?></td>
</tr>
<tr>
	<th>등록일</th>
	<td class="tl"><?php if(isset($data['reg_date'])==TRUE) echo $data['reg_date'];?></td>
</tr>
</tbody>
</table>
</form>

<div class="write_btn tc">
	<a href="/admin/">공지보기</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="#" id="btn_reg">저장하기</a>
	<a href="/admin/maptoon/maptoon_list/10">목록으로</a>
</div>

<script type="text/javascript">
$(document).ready(function() {
	$("#btn_reg").click(function() {
		$("form[name=frm]").submit();
	});


	/*
	$("#btn_reg").click(function() {
		$("#dialog").dialog();
		return false;
	});

	function reset_popup_form() {
		$("#c_name").val('');
		$( "#dialog" ).dialog();
	}

	function fill_popup_form(a) {
		if(a!='') {
			reset_popup_form();
			$("#c_name").val(a);
			$( "#dialog" ).dialog();
		}
	}

	$(".btn_delete").click(function() {
		idx = $(this).attr('value');
		if(idx>0 && confirm('정말 삭제하시겠습니까?')) {
			frm = $("form[name='popup']");
			frm.attr('target','ifrm');
			$("#popup_idx").val(idx);
			frm.attr('action','/admin/maptoon/category_del_proc');
			frm.submit();
		}
	});

	$(".btn_modify").click(function() {
		idx = $(this).attr('value');
		if(idx>0) {
			$.ajax({
				url: '/admin/maptoon/category/?idx='+idx,
				data: {
					format: 'json',
					idx:idx
				},
				//dataType: 'jsonp',
				type:'get',
				success: function(msg) {
			        var json = $.parseJSON(msg);
			        console.log(json);
			        if(json.result=='success') {
			        	$("#popup_mode").val('upt');
			        	$("#popup_idx").val(idx);
			        	fill_popup_form(json.c_name);
			        }
			    },
			      error: function(err) {
			        console.log(err);
			    }
			});
		}
	});

	$("#btn_open_popup").click(function() {
		reset_popup_form();
	});

	$("#btn_register").click(function() {
		frm = $("form[name='popup']");
		
		if($("#c_name").val()=='') {
			alert('카테고리를 등록해 주십시오.');
			$("#c_name").focus();
			return false;
		}

		frm.attr('target','ifrm');
		frm.attr('action','/admin/maptoon/category_proc');
		frm.submit();
	});*/
});
</script>