{template nheader.html}
<script type="text/javascript">
function dr_confirm_move() {
	var d = top.dialog({
		title: lang["tips"],
		fixed: true,
		content: '<img src="/statics/js/skins/icons/question.png"> {fc_lang("您确定要这样操作吗？")}',
		okValue: lang['ok'],
		ok: function () {
			$('#action').val('move');
			var _data = $("#myform").serialize();
			var _url = window.location.href;
			if ((_data.split('ids')).length-1 <= 0) {
				d.close().remove();
				dr_tips(lang['select_null'], 2);
				return true;
			}
			// 将表单数据ajax提交验证
			$.ajax({type: "POST",dataType:"json", url: _url, data: _data,
				success: function(data) {
					d.close().remove();
					//验证成功
					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(){});
						});
						$.post("{$html_url}c=category&m=create_html&id="+$('#move_id').val(), {}, function(){});
						setTimeout('window.location.reload(true)', 3000); // 刷新页
						return true;
					} else {
						dr_tips(data.code, 3, 2);
						return true;
					}
				},
				error: function(HttpRequest, ajaxOptions, thrownError) {
					alert(HttpRequest.responseText);
				}
			});
		},
		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({type: "POST",dataType:"json", url: "{dr_url(APP_DIR.'/home/status')}&id="+id+"&v="+v, success: function(data) {
				//验证成功
				if (data.status == 1) {
					dr_tips(data.code, 3, 1);
					if (data.id) {
						$.post("{$html_url}c=show&m=create_html&id="+id, {}, function(){});
						$.post("{$html_url}c=category&m=create_html&id="+data.id, {}, function(){});
					}
					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();
}
function dr_ts() {
    var v = $("#myform").serialize();
    if ((v.split('ids')).length-1 <= 0) {
        dr_tips(lang['select_null'], 2);
        return true;
    }
    var url = "{dr_url(APP_DIR.'/home/ts_ajax')}";
    art.dialog.open(url, { title: '{fc_lang("推送")}',
        ok: function () {
            var iframe = this.iframe.contentWindow;
            if (!iframe.document.body) {
                alert('iframe loading')
                return false;
            };
            var tab = iframe.$('#dr_tab').val();
            var url = "{dr_url(APP_DIR.'/home/ts_ajax')}";
            url+='&ispost=1&tab='+tab;
            if (tab == 1) {
                // 推荐位
                var id = iframe.document.getElementsByName('dr_flag');
                var value = new Array();
                for (var i = 0; i < id.length; i++){
                    if (id[i].checked) {
                        value.push(id[i].value);
                    }
                }
                $.ajax({type: "POST", url:url+'&value='+value, data:v, dataType:'json', success: function (data) {
                    if (data.status == 1) {
                        dr_tips(data.code, 3, 1);
                        setTimeout('window.location.reload(true)', 3000); // 刷新页
                    } else {
                        dr_tips(data.code);
                    }
                }});
            } else if (tab == 2) {
				var id = iframe.document.getElementsByName('weixin');
				var value = new Array();
				for (var i = 0; i < id.length; i++){
					if (id[i].checked) {
						value.push(id[i].value);
					}
				}
				var url = "{dr_url('weixin/ts', array('mid'=>APP_DIR))}&"+v;
				window.location.href = url;
            } else if (tab == 0) {
                var o = iframe.document.getElementById("dr_synid");  
				  var str = "";  
				  for(i=0;i<o.length;i++){     
					if(o.options[i].selected){  
						str+=o.options[i].value+",";  
					}  
				}  
				$.ajax({type: "POST", url:url+'&value='+str, data:v, dataType:'json', success: function (data) {
                    if (data.status == 1) {
                        dr_tips(data.code, 3, 1);
                        setTimeout('window.location.reload(true)', 3000); // 刷新页
                    } else {
                        dr_tips(data.code);
                    }
                }});
            }
            return true;
        },
        cancel: true
    });
    return;
}
</script>
<div class="page-bar">
	<div class="page-toolbar pull-left">
		<div class="btn-group">
			<button type="button" class="btn blue btn-sm btn-outline dropdown-toggle" data-toggle="dropdown" data-hover="dropdown">
				{$meta_name}
				<i class="fa fa-angle-down"></i>
			</button>
			<ul class="dropdown-menu" role="menu">
				<li>
					<a href="{$list_url}"> {fc_lang("已通过内容")} </a>
				</li>
				{if $flags}
				<li class="divider"> </li>
				{loop $flags $t}
				<li>
					<a href="{$t.url}"> {fc_lang($t.name)} </a>
				</li>
				{/loop}
				{/if}
			</ul>
		</div>
		<a href="{$post_url}" class="btn btn-sm green"> {fc_lang('发布')}
			<i class="fa fa-plus"></i>
		</a>
	</div>

	<div class="page-toolbar">
		<div class="btn-group pull-right">
			<button type="button" class="btn green btn-sm btn-outline dropdown-toggle" data-toggle="dropdown" aria-expanded="false" data-hover="dropdown"> {fc_lang('操作菜单')}
				<i class="fa fa-angle-down"></i>
			</button>
			<ul class="dropdown-menu pull-right" role="menu">
				<li>
					<a href="{dr_url(APP_DIR.'/home/index')}"><i class="icon-table"></i> {fc_lang('全部内容')}</a></li>
				</li>
				<li>
					<a href="{$ci->duri->uri2url($post)}"> <i class="fa fa-plus"></i> {fc_lang('发布')}</a>
				</li>
				<li class="divider"> </li>
				{loop $menu.quick $t}
				<li>
					<a href="{$t.url}">{$t.icon} {$t.name}</a>
				</li>
				{/loop}
				<li class="divider"> </li>
				<li>
					<a href="javascript:window.location.reload();">
						<i class="icon-refresh"></i> {fc_lang('刷新页面')}</a>
				</li>
			</ul>
		</div>
	</div>
</div>
{if $flag}
<h3 class="page-title">
	<small>{fc_lang('推荐位用于对文档进行归档管理，如首页幻灯，今日视点，首页头条等等')}</small>
</h3>
{else}
<div class="mytopsearch">
	<form method="post" class="row" action="" name="searchform" id="searchform">
		<input name="search" id="search" type="hidden" value="1" />
		<div class="col-md-12">
			<label style="padding-right: 5px;">{$select2}</label>
			<label style="padding-right: 10px;"><i class="fa"></i></label>
			<label>
				<select name="data[field]" class="form-control">
					<option value="id" {if $param.field=='id'}selected{/if}>Id</option>
					{loop $field $t}
					{if $t.ismain && $t.fieldname != 'inputtime' && $t.fieldname != 'updatetime'}
					<option value="{$t.fieldname}" {if $param.field==$t.fieldname}selected{/if}>{$t.name}</option>
					{/if}
					{/loop}
				</select>
			</label>
			<label><i class="fa fa-caret-right"></i></label>
			<label style="padding-right: 20px;"><input type="text" class="form-control" placeholder="{fc_lang('多个Id可以用“,”分隔')}" value="{$param['keyword']}" name="data[keyword]" /></label>
			<label>{fc_lang('录入时间')} ：</label>
			<label>{dr_field_input('start', 'Date', array('option'=>array('format'=>'Y-m-d','width'=>'110')), (int)$param.start)}</label>
			<label><i class="fa fa-minus"></i></label>
			<label style="margin-right:10px">{dr_field_input('end', 'Date', array('option'=>array('format'=>'Y-m-d','width'=>'110')), (int)$param.end)}</label>
			<label><button type="submit" class="btn green btn-sm" name="submit" > <i class="fa fa-search"></i> {fc_lang('搜索')}</button></label>
		</div>
	</form>
</div>
{/if}

<form action="" method="post" name="myform" id="myform">
	<input name="action" id="action" type="hidden" value="" />
	<div class="portlet mylistbody">
		<div class="portlet-body">
			<div class="table-scrollable">

				{load $list_data_tpl}
		</div>
	</div>
</div>

</form>
<div id="pages"><a>{fc_lang('共%s条', $param.total)}</a>{$pages}</div>
{template nfooter.html}