{template nheader.html}
<script type="text/javascript">
	$(function(){
		// 排序操作
		$('.dr_table th').click(function(e) {
			var _class = $(this).attr("class");
			if (_class == undefined) return;
			var _name = $(this).attr("name");
			var _order = '';
			if (_class == "sorting") {
				_order = 'desc';
			} else if (_class == "sorting_desc") {
				_order = 'asc';
			} else {
				_order = 'desc';
			}
			var url = "{dr_member_order($moreurl)}&order="+_name+" "+_order;
			location.href=url;
		});
	});
	function dr_flag() {
		$("#action").val('flag');
		var _data = $("#myform").serialize();
		var _url = window.location.href;
		if ((_data.split('ids')).length-1 <= 0) {
			dr_tips("到底推荐谁？您还没有选择呢", 2);
			return true;
		}
		// 将表单数据ajax提交验证
		$.ajax({type: "POST",dataType:"json", url: _url, data: _data,
			success: function(data) {
				//验证成功
				if (data.status == 1) {
					dr_tips(data.code, 3, 1);
					// 刷新页
					setTimeout('window.location.reload(true)', 3000);
				} else {
					dr_tips(data.code, 3, 2);
					return true;
				}
			},
			error: function(HttpRequest, ajaxOptions, thrownError) {
				alert(thrownError + "\r\n" + HttpRequest.statusText + "\r\n" + HttpRequest.responseText);
			}
		});
		return false;
	}
	function dr_update() {
		$("#action").val('update');
		var _data = $("#myform").serialize();
		var _url = window.location.href;
		if ((_data.split('ids')).length-1 <= 0) {
			dr_tips("到底更新谁？您还没有选择呢", 2);
			return true;
		}
		$.ajax({type: "POST",dataType:"json", url: _url, data: _data,
			success: function(data) {
				if (data.status == 1) {
					dr_tips(data.code, 3, 1);
					$("input[name='ids[]']:checkbox:checked").each(function(){
						$.post("{$html_url}c=show&m=create_html&id="+$(this).val(), {}, function(){});
					});
					setTimeout('window.location.reload(true)', 3000);
				} else {
					dr_tips(data.code, 3, 2);
					return true;
				}
			},
			error: function(HttpRequest, ajaxOptions, thrownError) {
				alert(thrownError + "\r\n" + HttpRequest.statusText + "\r\n" + HttpRequest.responseText);
			}
		});
		return false;
	}
	function dr_delete(catid, id) {

		var d = top.dialog({
			title: lang["tips"],
			fixed: true,
			content: '<img src="/statics/js/skins/icons/question.png"> <font color=red><b>你确认要删除吗？</b></font>',
			okValue: lang['ok'],
			ok: function () {
				$.ajax({type: "POST",dataType:"json", url: "{dr_member_url(MOD_DIR.'/home/del')}",data: {catid:catid,id:id}, success: function(data) {
					if (data.status == 1) {
						dr_tips(data.code, 3, 1);
						$("#dr_row_"+id).hide();
					} else {
						dr_tips(data.code, 3, 0);
					}
					art.dialog.close();
					return false;
				},
					error: function(HttpRequest, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + HttpRequest.statusText + "\r\n" + HttpRequest.responseText);
					}
				});
				return true
			},
			cancelValue: lang['cancel'],
			cancel: function () {}
		});
		d.show();
	}
	function dr_status(id, v) {
		var title = "";
		if (v == 9) {
			title = "<font color=red><b>{fc_lang('您确定要将它关闭吗？')}</b></font>";
		} else {
			title = "<font color=blue><b>{fc_lang('您确定要将它开启吗？')}</b></font>";
		}
		var d = top.dialog({
			title: lang["tips"],
			fixed: true,
			content: '<img src="/statics/js/skins/icons/question.png"> '+title,
			okValue: lang['ok'],
			ok: function () {
				// 将表单数据ajax提交验证
				$.ajax({type: "POST",dataType:"json", url: "{dr_member_url(MOD_DIR.'/home/status')}&id="+id+"&v="+v, success: function(data) {
					//验证成功
					if (data.status == 1) {
						dr_tips(data.code, 3, 1);
						if (data.id) {
							$.ajax({
								type: "POST",
								dataType:"jsonp",
								url:"{$html_url}c=show&m=create_html&id="+id,
								success: function(data) { },
								error: function(HttpRequest, ajaxOptions, thrownError) { }
							});
							$.ajax({
								type: "POST",
								dataType:"jsonp",
								url:"{$html_url}c=show&m=create_list_html&id="+data.id,
								success: function(data) { },
								error: function(HttpRequest, ajaxOptions, thrownError) { }
							});
						}
						setTimeout('window.location.reload(true)', 3000); // 刷新页
					} else {
						dr_tips(data.code);
					}
				},
					error: function(HttpRequest, ajaxOptions, thrownError) {
						alert(HttpRequest.responseText);
					}
				});
				return true
			},
			cancelValue: lang['cancel'],
			cancel: function () {}
		});
		d.show();
	}
</script>

<div class="row">
	<div class="col-md-12">

		<div class="portlet-body">
			<div class="table-toolbar">
				<form method="get" action="">
					<input name="s" type="hidden" value="member" />
					<input name="mod" type="hidden" value="{MOD_DIR}" />
					<input name="c" type="hidden" value="home" />
					<input name="m" type="hidden" value="index" />
					<input id="dr_order" name="order" type="hidden" value="{$get.order}" />
					<div class="row">
						<div class="col-md-6">
							<label>
								<div class="btn-group">
									<a class="btn green" href="{dr_member_url(MOD_DIR.'/home/add')}"> {fc_lang('发布')}
										<i class="fa fa-plus"></i>
									</a>
								</div>
							</label>
						</div>
						<div class="col-md-4 col-md-offset-2">
							<label class="text-right">
								<div class="input-group">
									<input type="text" class="form-control" id="dr_keywords" name="kw" placeholder="关键字查询" value="{$kw}">
									<span class="input-group-btn">
										<button class="btn green mysubmit" type="submit"><i class="fa fa-search"></i> 搜索</button>
									</span>
								</div>
							</label>
						</div>

					</div>
				</form>
			</div>

			<form action="" method="post" name="myform" id="myform">
				<input name="action" id="action" type="hidden" value="" />
				<div class="table-responsive">
					<table class="dr_table table dataTable">
						<thead>
						<tr>
							<th style="width:20px;" class="algin_r">&nbsp;</th>
							<th class="{ns_sorting('title')}" name="title">主题</th>
							<th class="{ns_sorting('catid')}" name="catid">栏目</th>
							<th class="{ns_sorting('updatetime')}" name="updatetime">更新时间</th>
							<th class="{ns_sorting('status')}" name="status">状态</th>
							<th></th>
						</tr>
						</thead>
						<tbody id="dr_body">
						{loop $list $t}
						<tr id="dr_row_{$t.id}">
							<td class="" style="padding-top:7px;padding-left:15px"><input type="checkbox" value="{$t.id}" class="dr_select toggle md-check" name="ids[]"></td>
							<td class=""><div class="dr_title"><a href="{if $t.status==9}{dr_url_prefix($t.url, MOD_DIR)}{else}{SITE_URL}index.php?s={MOD_DIR}&c=show&id={$t.id}{/if}" title="{$t.title}" target="_blank">{dr_keyword_highlight($t.title, $kw)}</a></div></td>
							<td class=""><a href="{CATEGORY.$t[catid].url}" target="_blank">{CATEGORY.$t[catid].name}</a></td>
							<td class="">{dr_date($t.updatetime, '', 'red')}</td>
							<td class=" html5">{if $t.status == 9}<a class="btn green btn-xs" href="javascript:dr_status({$t.id}, '{$t.status}');">{fc_lang('正常')}</a>{else}<a class="btn red btn-xs" href="javascript:dr_status({$t.id}, '{$t.status}');">{fc_lang('关闭')}</a>{/if}</td>
							<td class="">
								{if $extend}
								<a href="{dr_member_url(MOD_DIR.'/extend/index',array('cid'=>$t.id))}" class="btn btn-primary btn-xs" ><i class="fa fa-server"></i> {fc_lang('章节管理')}</a>
								{/if}
								{loop $form $f}
								<a href="{$f.url}&cid={$t.id}" class="btn blue btn-xs" ><i class="fa fa-reorder"></i> {$f.name}（{intval($t[$f['field']])}）</a>
								{/loop}
								{if $module_rule[$t['catid']]['edit']}
								<a href="{dr_member_url(MOD_DIR.'/home/edit', array('id'=>$t.id))}" class="btn green btn-xs" ><i class="fa fa-edit"></i> 修改</a>
								{/if}
								{if $module_rule[$t['catid']]['del']}
								<a href="javascript:;" onclick="dr_delete('{$t.catid}', '{$t.id}')" class="btn red-mint btn-xs" ><i class="fa fa-trash-o"></i> 删除</a>
								{/if}
							</td>
						</tr>
						{/loop}
						</tbody>
						<tr>
							<td style="padding-top:15px;padding-left:15px"><input class="toggle md-check" ck="0" type="checkbox" onclick="dr_selected2()" id="dr_select" name="dr_select"></td>
							<td colspan="22">
								<div class="row">
									<div class="col-md-1">
										<label>
											<button type="button" class="btn btn-sm btn-success" onClick="dr_update()"><i class="fa fa-refresh"></i> 更新</button>
										</label>
									</div>
									{if $flagdata}
									<div class="col-md-5">
										<label>
											<button type="button" class="btn btn-sm btn-success" onClick="dr_flag()"><i class="fa fa-flag"></i> 推荐到：</button>
										</label>
										<select name="flag">
											<option value=""> -- </option>
											{loop $flagdata $i $t}
											<option value="{$i}"> {$t.name} </option>
											{/loop}
										</select>
									</div>
									{/if}
									{if $member_rule.update_score}
									<div class="col-md-5" style="padding-top: 8px;">
										{if $member_rule.update_score > 0}
										更新一次增加<font color="#0000FF"><b>{$member_rule.update_score}</b></font>{SITE_SCORE}
										{else}
										更新一次减少<font color="#FF0000"><b>{abs($member_rule.update_score)}</b></font>{SITE_SCORE}
										{/if}
									</div>
									{else}
									<div class="col-md-5">
										&nbsp;
									</div>
									{/if}
								</div>
							</td>
						</tr>
					</table>
				</div>
			</form>
		</div>


	</div>
</div>


<div class="row">
	<div class="col-md-12 text-center">
		<ul class="pagination">
			{$pages}
			<li><a href="javascript:;">共{$page_total}条</a></li>
		</ul>
	</div>
</div>

{if IS_MOBILE}
<div class="alert alert-info" style="margin-top: 15px">
	左右滑动表格可以查看更多的内容
</div>
{/if}
{template "nfooter.html"}