<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<div class="row">

	<div class="col-lg-10 mx-auto">

		<div class="card">
		    <div class="card-header pb-1"> 
					<div class="row">
						<div class="col-lg-4">
						<p class="m-y-xs text-muted fl">栏目设置</p></div>
						
					</div>
					
			</div>

			<div class="card-body">

				<form action="<?php echo url('plugin-setting-hfdr_umbbs');?>" method="post" id="form">
<div class="table-responsive arrlist">

						<table class="table" style="min-width: 800px">

							<thead>

								<tr align="center">

									<th width="40">ID</th>
									
									<th width="40">图标</th>

									<th>栏目名称</th>

									<th>版块ID</th>

									<th width="80">横排数量</th>

									<th width="40">排序</th>

									<th>删除</th>

								</tr>

								<thead>

									<tbody>

										<?php foreach($themegamelist as $arr) { ?>

										<?php $rowid = $arr['themegameid'];?>

										<tr align="center" rowid="<?php echo $rowid; ?>">

											<td><input type="text" class="form-control text-center" style="width: 30px;" name="rowid[<?php echo $rowid;?>]" value="<?php echo $rowid; ?>" placeholder="ID" /></td>

											<td><input type="text" class="form-control" name="icoimg[<?php echo $rowid;?>]" value="<?php echo $arr['icoimg']; ?>" placeholder="大板块ICO" /></td>
											
											<td><input type="text" class="form-control" name="name[<?php echo $rowid;?>]" value="<?php echo $arr['name']; ?>" placeholder="大块名称" /></td>

											<td><input type="text" class="form-control" name="formid[<?php echo $rowid;?>]" value="<?php echo $arr['formid']; ?>" placeholder="版块ID" /></td>

											<td><input type="text" class="form-control" style="width: 200px;" name="viewnum[<?php echo $rowid;?>]" value="<?php echo $arr['viewnum']; ?>" placeholder="横排数量" /></td>

											<td><input type="text" class="form-control  text-center" style="width: 30px;" name="rank[<?php echo $rowid;?>]" value="<?php echo $arr['rank']; ?>" placeholder="顺序" /></td>

											<td><a class="btn row_delete  text-center"  role="btn">删除</a></td>

										</tr>

										<?php } ?>

										<tr align="center" rowid="<?php echo !empty($rowid) ? $rowid : 0; ?>" class="d-none">

											<td><input type="text" class="form-control text-center" style="width: 30px;" name="rowid[0]" value="" placeholder="ID" /></td>
											
											<td><input type="text" class="form-control" name="icoimg[0]" value="" placeholder="大板块ICO" /></td>

											<td><input type="text" class="form-control" name="name[0]" value="" placeholder="大块名称" /></td>

											<td><input type="text" class="form-control" name="formidl[0]" value="" placeholder="版块ID" /></td>

											<td><input type="text" class="form-control" style="width: 200px;" name="viewnum[0]" value="" placeholder="横排数量" /></td>

											<td><input type="text" class="form-control text-center" style="width: 30px;" name="rank[0]" value="" /></td>

											<td><a class="btn row_delete" role="btn">删除</a></td>

										</tr>

									</tbody>

						</table>

					</div>

					<p><a role="button" class="btn row_add">[+]增加一行</a></p>

					<p class="text-center">

						<button type="submit" class="btn btn-primary" id="submit" data-loading-text="<?php echo lang('submiting');?>..."><?php echo lang('confirm');?></button>

					</p>

				</form>
				<p>
				<a href="http://shop.1um.cc" target="_blank">更多xiuno模板下载，请访问http://shop.1um.cc</a>
				</p>

			</div>

		</div>

	</div>

</div>


<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>


<script>

	var maxid = <?php echo $maxid;?>;



	var jform = $("#form");

	var jsubmit = $("#submit");

	var jarrlist = $('.arrlist');

	jform.base64_encode_file(); // 对文件进行 base64 编码，处理文件上传，很方便



	jform.on('submit', function() {

		jform.reset();

		var postdata = jform.serialize();

		jsubmit.button('loading');

		$.xpost(jform.attr('action'), postdata, function(code, message) {

			if (code == 0) {

				$.alert(message);

				jsubmit.text(message).delay(3000).location();

				return;

			} else {

				alert(message);

				jsubmit.button('reset');

			}

		});

		return false;

	});



	// 删除

	var jdelete = $('a.row_delete');

	jarrlist.on('click', 'a.row_delete', function() {

		var jthis = $(this);

		var jtr = jthis.parents('tr');

		var rowid = jtr.attr('rowid');

		if (jform.find('tbody').find('tr').length <= 2) {

			$.alert('不能删除系统保留的版块。');

			return;

		}

		jtr.remove();

		return false;

	});

	// 增加

	var jadd = $('a.row_add');

	jadd.on('click', function() {

		var jclone = jarrlist.find('tr').last().clone();

		jclone.insertAfter(jarrlist.find('tr').last()).removeClass('d-none');

		var jrowid = jclone.find('input[name^="rowid"]');

		//var rowid = xn.intval(jrowid.val()) + 1;

		var rowid = ++maxid;

		jrowid.val(rowid);

		jclone.attr('rowid', rowid);



		// 清空值

		jclone.find('input').not('[name^="rowid"]').val('');



		// 修改 [] 中的值为 rowid

		jclone.find('input').attr_name_index(rowid);



		return false;

	});



	$('#nav_pc li.plugin, #nav_mobile li.plugin').addClass('active');

</script>