<!DOCTYPE html>
<html>
	<?php echo $this->fetch('head.html'); ?>

	<body>
		<div class="header">
			<div class="header-back"></div>
			<div class="header-title">编辑</div>
		</div>
		<div class="header-row"></div>
		<div class="main-body">

			<form method="post" action="/module.php?m=olprint_book&a=save">
				<input type="hidden" name="bookid" style="display:none;" value="<?php echo $this->_var['data']['bookid']; ?>">

				<div class="input-flex">
					<div class="input-flex-label">标题：</div>
					<input class="input-flex-text" type="text" name="title" id="title" value="<?php echo $this->_var['data']['title']; ?>">
				</div>
				<div class="input-flex">
					<div class="input-flex-label">分类：</div>
					<select class="input-flex-select" name="catid">
						<option value="0">请选择</option>
						<?php $_from = $this->_var['catlist']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
						<option value="<?php echo $this->_var['c']['catid']; ?>" <?php if ($this->_var['data']['catid'] == $this->_var['c']['catid']): ?>selected<?php endif; ?>><?php echo $this->_var['c']['title']; ?> </option> 
						<?php if ($this->_var['c']['child']): ?> 
						<?php $_from = $this->_var['c']['child']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'cc');if (count($_from)):
    foreach ($_from AS $this->_var['cc']):
?> 
						<option value="<?php echo $this->_var['cc']['catid']; ?>" <?php if ($this->_var['data']['catid'] == $this->_var['cc']['catid']): ?>selected<?php endif; ?>>|--<?php echo $this->_var['cc']['title']; ?> </option>
						 <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
						 <?php endif; ?> 
						 <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?> 
					</select> 

				</div>
				<div class="input-flex">
					<div class="input-flex-label">描述：</div>
					<input class="input-flex-text" type="text" name="description" id="description" value="<?php echo $this->_var['data']['description']; ?>">
				</div>

				<div class="input-flex">
					<div class="input-flex-label">金额：</div>
					<input class="input-flex-text" type="text" name="money" id="money" value="<?php echo $this->_var['data']['money']; ?>">
					<div class="mgl-5 cl-money">元</div>
				</div>

				<div class="input-flex flex-ai-center">
					<div class="input-flex-label">上传文件</div>
					<div class="btn-small js-upfile">选择文件</div>
					<div id="upfile-loading" style="display: none;">上传中..</div>
					<input type="hidden" name="fileurl" value="<?php echo $this->_var['data']['fileurl']; ?>" id="fileurl" />
					<span class="mgl-5 cl-red f12">*只支持zip压缩包</span>
					<input type="file" name="upfile" class="none" id="upfile" />
				</div>

				<div class="input-flex">
					<div class="input-flex-label">页数：</div>
					<input class="input-flex-text" type="text" name="page_num" id="page_num" value="<?php echo $this->_var['data']['page_num']; ?>">
					<div>页</div>
				</div>

				<div class="input-flex">
					<div class="input-flex-label">所属学期：</div>
					<div class="flex-1 flex-ai-center flex">
						<input <?php if ($this->_var['data']['xtime'] == 1): ?>checked<?php endif; ?> type="radio" name="xtime" value="1"> 上学期
						<input <?php if ($this->_var['data']['xtime'] == 2): ?>checked<?php endif; ?> type="radio" name="xtime" value="2"> 下学期
					</div>
				</div>

				<div class="input-flex">
					<div>内容：
					</div>
					
				</div>
				<div >
					<div class="sky-editor-content" name="content" id="content" contenteditable="true"><?php echo $this->_var['data']['content']; ?></div>
				</div>
				<div class="btn-row-submit js-submit">保存</div>
			</form>

		</div>
		<?php echo $this->fetch('footer.html'); ?>
		<script src="/plugin/lrz/lrz.bundle.js"></script>
		<script src="/plugin/skyeditor/skyeditor.js"></script>
		<script>
			$(document).on("click", ".js-upfile", function() {
				$("#upfile").click();
			})
			$(document).on("change", "#upfile", function() {
				$("#upfile-loading").html("上传中...").show();
				skyUpload("upfile", "/index.php?m=upload&a=upload&ajax=1", function(e) {

					var res = JSON.parse(e.target.responseText);
					if (res.error == 0) {
						$("#upfile-loading").html("上传成功...");
						$("#fileurl").val(res.imgurl);

					} else {
						$("#upfile-loading").html("上传失败...");
					}

				}, function(e) {
					console.log(e)
				}, function(e) {
					console.log(e)
				})
			})
		</script>
	</body>
</html>
