<?php
require '../conn/conn.php';
require '../conn/function.php';
require 'admin_check.php';

$page=$_GET["page"];
$action=$_GET["action"];
$orderby=$_GET["orderby"];
$S_id=intval($_GET["S_id"]);
$N_id=intval($_GET["N_id"]);


switch($orderby){
	case "order_desc":
	$order=" order by N_order desc";
	break;
	case "order_asc":
	$order=" order by N_order asc";
	break;
	case "price_desc":
	$order=" order by N_price desc";
	break;
	case "price_asc":
	$order=" order by N_price asc";
	break;
	case "title_desc":
	$order=" order by N_title desc";
	break;
	case "title_asc":
	$order=" order by N_title asc";
	break;
	case "time_desc":
	$order=" order by N_date desc";
	break;
	case "time_asc":
	$order=" order by N_date asc";
	break;
	default:
	$order=" order by N_top desc,N_id desc";
	break;
}

if($page==""){
	$page=1;
}

if($action=="saveds"){
	if($_POST["ds"]!=""){
		mysqli_query($conn,"update sl_config set C_newsds='".$_POST["ds"]."'");
		if($C_cache==1){
			@removeDir("../conn/cache");  //更新缓存
			@mkdir("../conn/cache",0777,true);
		}
		die("success");
	}else{
		die("请填写内容！");
	}
}
if($action=="del"){
	mysqli_query($conn,"update sl_news set N_del=1 where N_id=".$N_id);
	mysqli_query($conn, "insert into sl_log(L_aid,L_time,L_add,L_ip,L_title) values(".$_SESSION["A_id"].",'".date('Y-m-d H:i:s')."','".$_SESSION["add"]."','".getip()."','删除文章')");
	if($C_cache==1){
			@removeDir("../conn/cache");  //更新缓存
			@mkdir("../conn/cache",0777,true);
		}
	die("success");
}

if($action=="dels"){
	mysqli_query($conn,"update sl_nsort set S_del=1 where S_id=".$S_id." or S_sub=".$S_id);
	mysqli_query($conn,"update sl_news set N_del=1 where N_sort=".$S_id." or N_sort in (select S_id from sl_nsort where S_sub=".$S_id.")");
	mysqli_query($conn, "insert into sl_log(L_aid,L_time,L_add,L_ip,L_title) values(".$_SESSION["A_id"].",'".date('Y-m-d H:i:s')."','".$_SESSION["add"]."','".getip()."','删除文章分类')");
	if($C_cache==1){
			@removeDir("../conn/cache");  //更新缓存
			@mkdir("../conn/cache",0777,true);
		}
	die("success");
}

if($action=="excelout"){
	$sql="select * from sl_news";
	$result = mysqli_query($conn, $sql);
	$arr = array();  
	while($row = mysqli_fetch_array($result)) {
	$count=count($row);
	  for($i=0;$i<$count;$i++){ 
	    unset($row[$i]);
	  }
    array_push($arr,$row);
	}

	exportToCsv(["N_id","N_title","N_content","N_pic","N_price","N_sort","N_del","N_order","N_long","N_date","N_author","N_view","N_preview","N_mid","N_sh","N_tag","N_fx","N_video","N_tpl","N_top","N_vshow","N_shuxing","N_price2","N_keywords","N_description","N_ds","N_dsintro","N_sort2","N_viponly","N_uncopy","N_unlogin","N_vip"] , $arr ,'news_'.date('YmdHis'),[]);
	die();
}

if($action=="save"){
	foreach ($_POST as $x=>$value) {
		if(splitx($x,"_",0)=="title"){
			mysqli_query($conn,"update sl_news set N_title='".$_POST[$x]."' where N_id=".intval(splitx($x,"_",1)));
		}
		if(splitx($x,"_",0)=="date"){
			mysqli_query($conn,"update sl_news set N_date='".$_POST[$x]."' where N_id=".intval(splitx($x,"_",1)));
		}
		if(splitx($x,"_",0)=="order"){
			mysqli_query($conn,"update sl_news set N_order=".$_POST[$x]." where N_id=".intval(splitx($x,"_",1)));
		}
		if(splitx($x,"_",0)=="sort"){
			mysqli_query($conn,"update sl_news set N_sort=".$_POST[$x]." where N_id=".intval(splitx($x,"_",1)));
		}
		if(splitx($x,"_",0)=="price"){
			mysqli_query($conn,"update sl_news set N_price=".$_POST[$x]." where N_id=".intval(splitx($x,"_",1)));
		}
	}
	if($C_cache==1){
			@removeDir("../conn/cache");  //更新缓存
			@mkdir("../conn/cache",0777,true);
		}
	die("success");
}

if($action=="delall"){
	$id=$_POST["id"];
	if(count($id)>0) {
		$shu=0 ;
		for ($i=0 ;$i<count($id);$i++ ) {
			mysqli_query($conn,"update sl_news set N_del=1 where N_id=".intval($id[$i]));
			$shu=$shu+1 ;
			$ids=$ids.$id[$i].",";
		}
		$ids= substr($ids,0,strlen($ids)-1);
		if($shu>0) {
			mysqli_query($conn, "insert into sl_log(L_aid,L_time,L_add,L_ip,L_title) values(".$_SESSION["A_id"].",'".date('Y-m-d H:i:s')."','".$_SESSION["add"]."','".getip()."','批量删除文章')");
			die("success");
		} else {
			die("删除失败");
		}
		if($C_cache==1){
			@removeDir("../conn/cache");  //更新缓存
			@mkdir("../conn/cache",0777,true);
		}
	} else {
		die("未选择要删除的内容");
	}
}

if($S_id==0){
	$S_title="";
	$sql="select count(N_id) as N_count from sl_news,sl_nsort where N_sort=S_id and N_del=0";
}else{
	$S_title=getrs("select * from sl_nsort where S_id=".$S_id,"S_title")." - ";
	$sql="select count(N_id) as N_count from sl_news,sl_nsort where N_sort=S_id and N_del=0 and (S_id=".$S_id." or S_sub=".$S_id.")";
}
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$N_counts=$row["N_count"];
$N_all=getrs("select count(N_id) as N_count from sl_news where N_del=0","N_count");
?>

<!DOCTYPE html>
<html lang="en">
	<head>

		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>文章列表 - 后台管理</title>

		<!--favicon -->
		<link rel="icon" href="../media/<?php echo $C_ico?>" type="image/x-icon"/>

		<!--Bootstrap.min css-->
		<!--Bootstrap.min css-->
		<link rel="stylesheet" href="assets/plugins/bootstrap/css/bootstrap.min.css">

		<!--Icons css-->
		<link rel="stylesheet" href="assets/css/icons.css">

		<!--Style css-->
		<link rel="stylesheet" href="assets/css/style.css">

		<!--mCustomScrollbar css-->
		<link rel="stylesheet" href="assets/plugins/scroll-bar/jquery.mCustomScrollbar.css">

		<!--Sidemenu css-->
		<link rel="stylesheet" href="assets/plugins/toggle-menu/sidemenu.css">

		<!--Toastr css-->
		<link rel="stylesheet" href="assets/plugins/toastr/build/toastr.css">

		<style type="text/css">
			.list-group a{text-decoration:none}
			.active{color: #f00}
		</style>

	</head>

	<body class="app ">

		<div id="spinner"></div>

		<div id="app">
			<div class="main-wrapper" >
				
					<?php
					require 'nav.php';
					?>


				<div class="app-content">

					<a href="recycle.php" class="btn btn-info pull-right btn-sm" style="z-index: 2;position: relative;"><i class="fa fa-recycle"></i> 回收站</a>
					<a href="javascript:;" onclick="news_list_newsds()" class="btn btn-danger pull-right btn-sm" style="z-index: 2;position: relative;margin-right: 5px;"><i class="fa fa-cny"></i> 文章打赏</a>

					<a href="news_up.php" class="btn btn-primary pull-right btn-sm" style="z-index: 2;position: relative;margin-right: 5px;"><i class="fa fa-plus-circle"></i> Word文档批量上传</a>

					<a href="nsort_add.php" class="btn btn-primary pull-right btn-sm" style="z-index: 2;position: relative;margin-right: 5px;"><i class="fa fa-plus-circle"></i> 新增文章分类</a>
					<a href="news_add.php" class="btn btn-primary pull-right btn-sm" style="z-index: 2;position: relative;margin-right: 5px;"><i class="fa fa-plus-circle"></i> 新增文章</a>
					<form class="input-group pull-right" style="width: 300px;z-index: 2;position: relative;margin-right: 5px;" method="post" action="?action=search">
						<select name="type">
							<option value="title">文章名称</option>
							<option value="shop">店铺名称</option>
							<option value="member">卖家账号</option>
							<option value="tag">TAG标签</option>
						</select>
	                    <input type="text" class="form-control input-sm" name="keyword" value="<?php echo t($_POST["keyword"])?>" placeholder="搜索文章">
	                    <span class="input-group-btn">
	                        <button class="btn btn-info btn-sm" type="form"><i class="fa fa-search"></i> 搜索</button>
	                    </span>
	                </form>

					<section class="section">
						<ol class="breadcrumb">
                            <li class="breadcrumb-item active"><a href="news_list.php">文章管理</a></li>
                            <li class="breadcrumb-item"><a href="nsort_add.php">文章分类</a></li>
                        </ol>
                        <style type="text/css">
                        .active a{font-weight: bold;color: #a2a9d4}

                    	</style>

						<div class="section-body ">

							<div class="row">

								<div class="col-lg-4">

									<div class="card card-primary">

										<div class="card-header">
											<h4>文章分类列表</h4>
											
										</div>
										
										<ul class="list-group">
											<a href="?S_id=0" class="list-group-item <?php if($S_id==0){echo "active";}?>"><b>所有文章 [<?php echo $N_all?>个]</b>
<span class="pull-right">首页展示 / 编辑 / 删除</span>
											</a>
											<?php 
													$sql="select * from sl_nsort where S_del=0 and S_sub=0 order by S_order,S_id desc";
														$result = mysqli_query($conn, $sql);
														if (mysqli_num_rows($result) > 0) {
														while($row = mysqli_fetch_assoc($result)) {
															if($row["S_id"]==$S_id){
																$active="active";
															}else{
																$active="";
															}
															if($row["S_show"]==1){
																$show="<i class='fa fa-check-circle pull-right' style='margin-right:90px;'></i>";
															}else{
																$show="";
															}

															$N_count=getrs("select count(N_id) as N_count from sl_news,sl_nsort where N_sort=S_id and S_sub=".$row["S_id"]." and N_del=0","N_count");
															echo "<div style=\"position:relative;border-top:solid 1px #EEEEEE;\" id=\"s".$row["S_id"]."\"><a href=\"?S_id=".$row["S_id"]."\" class=\"list-group-item ".$active."\"><b>└ ".$row["S_order"].".".$row["S_title"]." [".$N_count."个] </b>".$show."</a><a href=\"nsort_add.php?S_id=".$row["S_id"]."\" style=\"position:absolute;right:55px;top:10px;z-index:999;font-size:15px\" class=\"btn btn-sm btn-info\"><i class=\"fa fa-edit\"></i></a> <button style=\"position:absolute;right:10px;top:10px;z-index:999;font-size:15px\" class=\"btn btn-sm btn-danger\" onClick=\"news_list_dels(".$row["S_id"].")\"><i class=\"fa fa-times-circle\"></i></button></div>";


															$sql2="select * from sl_nsort where S_del=0 and S_sub=".$row["S_id"]." order by S_order,S_id desc";
																$result2 = mysqli_query($conn, $sql2);
																if (mysqli_num_rows($result2) > 0) {
																while($row2 = mysqli_fetch_assoc($result2)) {
																	if($row2["S_id"]==$S_id){
																		$active2="active";
																	}else{
																		$active2="";
																	}

																	if($row2["S_show"]==1){
																		$show="<i class='fa fa-check-circle pull-right' style='margin-right:90px;'></i>";
																	}else{
																		$show="";
																	}

																	$N_count2=getrs("select count(N_id) as N_count from sl_news where N_del=0 and N_sort=".$row2["S_id"],"N_count");
																	echo "<div style=\"position:relative;border-top:solid 1px #EEEEEE;\" id=\"s".$row2["S_id"]."\"><a href=\"?S_id=".$row2["S_id"]."\" class=\"list-group-item ".$active2."\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└ ".$row2["S_order"].".".$row2["S_title"]." [".$N_count2."个] ".$show."</a><a href=\"nsort_add.php?S_id=".$row2["S_id"]."\" style=\"position:absolute;right:55px;top:10px;z-index:999;font-size:15px\" class=\"btn btn-sm btn-info\"><i class=\"fa fa-edit\"></i></a> <button style=\"position:absolute;right:10px;top:10px;z-index:999;font-size:15px\" class=\"btn btn-sm btn-danger\" onClick=\"news_list_dels(".$row2["S_id"].")\"><i class=\"fa fa-times-circle\"></i></button></div>";

																}
															}


														}
													}
											?>
											
										</ul>
											
									</div>

									<a href="nsort_add.php" class="btn btn-sm btn-primary"><i class="fa fa-plus-circle"></i> 新增文章分类</a>
									<a href="excel_news.php" class="btn btn-sm btn-warning"><i class="fa fa-upload"></i> 导入Excel</a>
									<a href="?action=excelout" class="btn btn-sm btn-info"><i class="fa fa-download"></i> 导出Excel</a>

								</div>
								<div class="col-lg-8">
									<form id="form">
									<div class="card card-primary">

										<div class="card-header">
											<h4><?php 
											if($action=="search"){
												echo "搜索“".t($_POST["keyword"])."” - ";
											}else{
												echo $S_title;
											}
											
											?>文章列表</h4>

										</div>
										<div class="card-body p-0">
											<div class="table-responsive">
												<table class="table table-striped mb-0 text-nowrap">
													<tr>
														<th>选择</th>
														<th>排序
															<a href="?orderby=order_asc"><i class="fa fa-caret-up <?php if($orderby=="order_asc"){echo "active";}?>"></i></a>
															<a href="?orderby=order_desc"><i class="fa fa-caret-down <?php if($orderby=="order_desc"){echo "active";}?>"></i></a> 
														</th>
														<th>名称
															<a href="?orderby=title_asc"><i class="fa fa-caret-up <?php if($orderby=="title_asc"){echo "active";}?>"></i></a>
															<a href="?orderby=title_desc"><i class="fa fa-caret-down <?php if($orderby=="title_desc"){echo "active";}?>"></i></a> 
														</th>
														<th>价格
															<a href="?orderby=price_asc"><i class="fa fa-caret-up <?php if($orderby=="price_asc"){echo "active";}?>"></i></a>
															<a href="?orderby=price_desc"><i class="fa fa-caret-down <?php if($orderby=="price_desc"){echo "active";}?>"></i></a>

															| 日期
															<a href="?orderby=time_asc"><i class="fa fa-caret-up <?php if($orderby=="time_asc"){echo "active";}?>"></i></a>
															<a href="?orderby=time_desc"><i class="fa fa-caret-down <?php if($orderby=="time_desc"){echo "active";}?>"></i></a>
														</th>
														<th>配图</th>
														
														<th>分类</th>
														<th>卖家</th>
														
														<th>操作</th>
														

													</tr>

<?php
		if($action=="sh"){
			$sql="select * from sl_news,sl_nsort where N_del=0 and S_del=0 and N_sort=S_id and N_sh=0 $order";
		}else{
			if($action=="search"){


				switch($_POST["type"]){
					case "title":
					$sql="select * from sl_news,sl_nsort where N_del=0 and S_del=0 and N_sort=S_id and N_title like '%".t($_POST["keyword"])."%' $order";
					break;
					case "shop":
					$sql="select * from sl_news,sl_nsort,sl_member where N_del=0 and S_del=0 and N_sort=S_id and N_mid=M_id and M_shop like '%".t($_POST["keyword"])."%' $order";
					break;
					case "member":
					$sql="select * from sl_news,sl_nsort,sl_member where N_del=0 and S_del=0 and N_sort=S_id and N_mid=M_id and M_login like '%".t($_POST["keyword"])."%' $order";
					break;
					case "tag":
					$sql="select * from sl_news,sl_nsort where N_del=0 and S_del=0 and N_sort=S_id and N_tag like '%".t($_POST["keyword"])."%' $order";
					break;
				}
			}else{
				if($S_id==0){
					$sql="select * from sl_news,sl_nsort where N_del=0 and S_del=0 and N_sort=S_id $order limit ".(($page-1)*20).",20";
				}else{
					$sql="select * from sl_news,sl_nsort where N_del=0 and S_del=0 and N_sort=S_id and (S_id=".$S_id." or S_sub=".$S_id.") $order limit ".(($page-1)*20).",20";
				}
			}
		}
		

		$result = mysqli_query($conn, $sql);
		if (mysqli_num_rows($result) > 0) {
		while($row = mysqli_fetch_assoc($result)) {


		switch($row["N_sh"]){
			case 0:
			$sh="<span style=\"color:#ff9900\">未审核</span>";
			break;
			case 1:
			$sh="<span style=\"color:#009900\">已通过</span>";
			break;
			case 2:
			$sh="<span style=\"color:#ff0000\">未通过</span>";
			break;

		}


		if($row["N_mid"]>0){
			$from=getrs("select M_login from sl_member where M_id=".$row["N_mid"],"M_login");
		}else{
			$from="自营";
		}

		if($row["N_top"]==1){
			$top="<div style=\"background:#0099ff;color:#ffffff;border-radius:5px;font-size:12px;padding:2px 6px;display:inline-block;margin-top:5px;\"><i class=\"fa fa-arrow-circle-up\"></i> 置顶</div>";
		}else{
			$top="";
		}
			echo "<tr id='".$row["N_id"]."'>
			<td><input type=\"checkbox\" name=\"id[]\" value=\"".$row["N_id"]."\"></td>
			<td><input type=\"txt\" style=\"width:50px;\" class=\"form-control\" name=\"order_".$row["N_id"]."\" value=\"".$row["N_order"]."\" onblur=\"news_list_save()\">".$top."</td>
			<td><textarea style=\"width:100%;min-width:180px;\" rows=\"3\" class=\"form-control\" name=\"title_".$row["N_id"]."\" onblur=\"news_list_save()\"/>".htmlspecialchars($row["N_title"])."</textarea></td>
			<td>
			<p><input type=\"text\" class=\"form-control\" style=\"min-width:80px;max-width:120px\" name=\"price_".$row["N_id"]."\" value=\"".$row["N_price"]."\" onblur=\"news_list_save()\"></p>
			<p><input type=\"text\" class=\"form-control\" style=\"min-width:80px;max-width:120px\" name=\"date_".$row["N_id"]."\" value=\"".$row["N_date"]."\" onblur=\"news_list_save()\"></p>


			</td>
			<td><img src=\"".pic2($row["N_pic"])."\" height=\"50\" alt=\"<img src='".pic2($row["N_pic"])."' width='500'>\"></td>
			<td><p><select name=\"sort_".$row["N_id"]."\" class=\"form-control\" style=\"width:120px;\" onchange=\"news_list_save()\">";
													$sql2="select * from sl_nsort where S_del=0 and S_sub=0 order by S_order,S_id desc";
																	$result2 = mysqli_query($conn, $sql2);
																	if (mysqli_num_rows($result2) > 0) {
																	while($row2 = mysqli_fetch_assoc($result2)) {
																		echo "<optgroup label=\"".$row2["S_title"]."\">";
																		$sql3="select * from sl_nsort where S_del=0 and S_sub=".$row2["S_id"]." order by S_order,S_id desc";
																			$result3 = mysqli_query($conn, $sql3);
																			if (mysqli_num_rows($result3) > 0) {
																			while($row3 = mysqli_fetch_assoc($result3)) {
																				if($row["S_id"]==$row3["S_id"]){
																					$selected="selected";
																				}else{
																					$selected="";
																				}
																				echo "<option value=\"".$row3["S_id"]."\" ".$selected.">".$row3["S_title"]."</option>";
																			}
																		}
																		echo "</optgroup>";
																	}
																}

													echo "</select><p><p>
<a class=\"btn btn-sm btn-warning\" target=\"_blank\" href=\"../?type=newsinfo&id=".$row["N_id"]."\"><i class=\"fa fa-send\"></i> 浏览</a>
<button class=\"btn btn-primary btn-sm\" type=\"button\" onclick=\"\$('#haibao').modal('show');\$('#poster').html('<iframe src=\'poster.php?type=news&id=".$row["N_id"]."\' scrolling=\'no\' name=\'mapif\' type=\'1\' frameborder=\'0\' height=\'820\' width=\'100%\'></iframe>')\"><i class=\"fa fa-image\"></i> 海报</button></p>
													</td>
			<td><p>".$from."</p><p>".$sh."</p></td>
			<td><p><a href='news_add.php?N_id=".$row["N_id"]."' class='btn btn-sm btn-info'><i class=\"fa fa-edit\"></i> 编辑</a></p><p><button class='btn btn-sm btn-danger' type='button' onClick='news_list_del(".$row["N_id"].")'><i class=\"fa fa-times-circle\"></i> 删除</button></p></td>
			
			</tr>";

		}
	}
?>

												</table>
											</div>
										</div>
									</div>

									<label><input type="checkbox" id="selectAll" name="selectAll"> 全选</label>
									<button class="btn btn-sm btn-danger" type="button" onClick="news_list_delall()"><i class="fa fa-times-circle" ></i> 删除所选</button>
									<button class="btn btn-sm btn-primary" type="button" onclick="news_list_save()"><i class="fa fa-save"></i> 保存修改</button>
									<a href="news_add.php" class="btn btn-sm btn-info"><i class="fa fa-plus-circle"></i> 新增文章</a>
									

									<ul class="pagination" id="pagination" style="float: right;"></ul>
									</form>
								</div>
								
							</div>
						</div>
<?php if($action!="search" && $action!="sh"){?>	
        <input type="hidden" id="PageCount" runat="server" />
        <input type="hidden" id="PageSize" runat="server" value="20" />
        <input type="hidden" id="countindex" runat="server" value="20"/>
        <!--设置最多显示的页码数 可以手动设置 默认为7-->
        <input type="hidden" id="visiblePages" runat="server" value="7" />
<?php }?>
					</section>
				</div>

			</div>
		</div>


<!-- Large Modal -->
<div id="haibao" class="modal fade">
	<div class="modal-dialog" role="document" >
		<div class="modal-content">
			<div class="modal-header pd-x-20">
				<h6 class="modal-title">生成海报</h6>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<div id="poster"></div>
		</div>
	</div><!-- modal-dialog -->
</div><!-- modal -->

<div id="myModal" class="modal fade">
					<div class="modal-dialog modal-lg" role="document">
						<div class="modal-content ">
							<div class="modal-header pd-x-20">
								<h6 class="modal-title">文章打赏设置</h6>
								<button type="button" class="close" data-dismiss="modal" aria-label="Close">
									<span aria-hidden="true">&times;</span>
								</button>
							</div>
							<div class="modal-body pd-20">
								<form id="ds">
							<div class="form-group row">
													
													<div class="col-md-12">
														<script charset='utf-8' src='../kindeditor/kindeditor-all-min.js'></script>
		                                                <script charset='utf-8' src='../kindeditor/lang/zh-CN.js'></script>
		                                                <script>KindEditor.ready(function(K) {window.editor = K.create('#content', {uploadJson : '../kindeditor/php/upload_json.php', fileManagerJson : '../kindeditor/php/file_manager_json.php',allowFileManager : true,items:[
        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
         'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
        'anchor', 'link', 'unlink', '|', 'about'
] });});</script>
		                                                <textarea name='ds' style='width:100%;height:450px;' id='content'><?php echo $C_newsds?></textarea>
														
													</div>
												</div>
						</form>
							</div><!-- modal-body -->
							<div class="modal-footer">
								<button type="button" class="btn btn-primary" onclick="news_list_saveds()">保存</button>
								<button type="button" class="btn btn-success" data-dismiss="modal">关闭</button>
							</div>
						</div>
					</div><!-- modal-dialog -->
				</div><!-- modal -->




		<!--Jquery.min js-->
		<script src="assets/js/jquery.min.js"></script>
		<script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
		<script src="assets/plugins/toggle-menu/sidemenu.js"></script>
		<script src="assets/plugins/scroll-bar/jquery.mCustomScrollbar.concat.min.js"></script>
		<script src="assets/js/scripts.js"></script>
		<script src="assets/js/help.js"></script>
		<script src="assets/plugins/toastr/build/toastr.min.js"></script>

		<script src="assets/js/jqPaginator.min.js" type="text/javascript"></script>
		<script src="ajax.js"></script>
		<script>
			
function loadData(num) {
            $("#PageCount").val("<?php echo $N_counts?>");
        }
function loadpage(id) {
    var myPageCount = parseInt($("#PageCount").val());
    var myPageSize = parseInt($("#PageSize").val());
    var countindex = myPageCount % myPageSize > 0 ? (myPageCount / myPageSize) + 1 : (myPageCount / myPageSize);
    $("#countindex").val(countindex);

    $.jqPaginator('#pagination', {
        totalPages: parseInt($("#countindex").val()),
        visiblePages: parseInt($("#visiblePages").val()),
        currentPage: id,
        first: '<li class="first page-item"><a href="javascript:;" class="page-link">首页</a></li>',
        prev: '<li class="prev page-item"><a href="javascript:;" class="page-link"><i class="arrow arrow2"></i>上一页</a></li>',
        next: '<li class="next page-item"><a href="javascript:;" class="page-link">下一页<i class="arrow arrow3"></i></a></li>',
        last: '<li class="last page-item"><a href="javascript:;" class="page-link">末页</a></li>',
        page: '<li class="page page-item"><a href="javascript:;" class="page-link">{{page}}</a></li>',
        onPageChange: function (num, type) {
            if (type == "change") {
                window.location="news_list.php?S_id=<?php echo $S_id?>&orderby=<?php echo $orderby?>&page="+num;
            }
        }
    });
}
$(function () {
    loadData(<?php echo $page?>);
    loadpage(<?php echo $page?>);

});


$('input[name="selectAll"]').on("click",function(){
        if($(this).is(':checked')){
            $('input[name="id[]"]').each(function(){
                $(this).prop("checked",true);
            });
        }else{
            $('input[name="id[]"]').each(function(){
                $(this).prop("checked",false);
            });
        }
    });

		</script>
	</body>
</html>