<?php
require("../class/connect.php");
require("../class/db_sql.php");
require("../data/dbcache/class.php");
require("../member/class/user.php");
require("../class/q_functions.php");
require("../class/dpfun.php");
require LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
//验证是否登陆
$user=islogin();
$userid=$user['userid'];
$username=$user['username'];

//取得模型id
$bookid=(int)$_GET['bookid'];
//验证书审核状态
$bck=$empire->fetch1("select * from {$dbtbpre}ecms_bookname_index where id=$bookid limit 1");
if(!$bck[checked])
{
	printerror("ErrorUrl","history.go(-1)",1);
}
//验证是否当前用户
$bookname=$empire->fetch1("select * from {$dbtbpre}ecms_bookname where id=$bookid limit 1");
if(!$bookname[ismember] || $bookname[userid]!=$userid || $bookname[username]!=$username)
{
	printerror("ErrorUrl","history.go(-1)",1);
}
esetcookie("qdelinfo","dgcms");
$totalnum=(int)$_GET['totalnum'];
$start=0;
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$line=25;//每行显示
$page_line=16;
$offset=$page*$line;
$add='';
$search="&mid=$mid";

//审核表
$ecmscheck=(int)$_GET['ecmscheck'];
$addecmscheck='';
$indexchecked=1;
if($ecmscheck)
{
	$search.='&ecmscheck='.$ecmscheck;
	$addecmscheck='&ecmscheck='.$ecmscheck;
	$indexchecked=0;
}
$tbname=$emod_r[$bck[tid]][tbname];
$infotb=ReturnTbname($tbname,$indexchecked);
//显示方式
if($public_r['qlistinfomod'])
{
	$modnum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsmod where tbname='$tbanme'");
	if($modnum>1)
	{
		$add.=' and ('.ReturnClass($mr['sonclass']).')';
	}
}
//搜索
$sear=$_GET['sear'];
if($sear)
{
	$keyboard=RepPostVar2($_GET['keyboard']);
	$show=$_GET['show'];
	//关键字
	if($keyboard)
	{
		$add.=" and (title like '%$keyboard%')";
	}
	$search.="&sear=1&keyboard=$keyboard&show=$show";
}

//信息表
$totalquery="select count(*) as total from ".$infotb." where bookid='$bookid' ".$add;
if($totalnum<1)
{
	$num=$empire->gettotal($totalquery);//取得总条数
}
else
{
	$num=$totalnum;
}

$mmw='增加章节';



$woinput='<span><a href="AddBookData.php?mid=&enews=MAddInfo&bookid='.$bookid.'" class=submit_btn>'.$mmw.'</a></span>';
$search.="&totalnum=$num";
$returnpage=page1($num,$line,$page_line,$start,$page,$search);






//查询SQL，如果要显示自定义字段记得在SQL里增加查询字段
$query="select * from ".$infotb." where bookid='$bookid' ".$add." order by newstime desc limit $offset,$line";
$sql=$empire->query($query);
//返回头条和推荐级别名称
$ftnr=ReturnFirsttitleNameList(0,0);
$ftnamer=$ftnr['ftr'];
$ignamer=$ftnr['igr'];


$public_diyr['pagetitle']='《'.$bookname[title].'》分卷管理';

$url="<a href='../../'>首页</a>&nbsp;>&nbsp;<a href='../member/cp/'>会员中心</a>&nbsp;>&nbsp;<a href='ListInfo.php?mid=$mid".$addecmscheck."'>管理信息</a>&nbsp;(".$mr[qmname].")";
require(ECMS_PATH.'e/template/incfile/header.php');
?>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <form name="searchinfo" method="GET" action="ListInfo.php">
    <tr>
            <td width="25%" height="27"> 
			  <input type="button" target="_blank" name="Submit" value="增加分卷" onclick="window.open('AddVolume.php?bookid=<?=$bookid?>','','');">
            </td>
      <td width="75%"></td>
    </tr>
  </form>
</table>
<br>

<form name="add" method="post" action="ecms.php">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  	<tr class="header"> 
      <td width="10%" height="25"><div align="center">VID</div></td>
      <td width="10%" height="25"> <div align="center">排序</div></td>
	  <td width="60%" height="25"> <div align="center">分卷名称</div></td>
      <td width="20%" height="25"> <div align="center">操作</div></td>
    </tr>

<?
$sql=$empire->query("select * from {$dbtbpre}enewsvolume where bookid=$bookid order by myorder,vid");
while($r=$empire->fetch($sql)){

?>  <tr bgcolor='#ffffff'>
      <td height="25"><div align="center"><?=$r[vid]?><input type=hidden name=vid[] value="<?=$r[vid]?>"></div></td>
      <td height="25"> <div align="center"><input type=text name=myorder[] value="<?=$r[myorder]?>" size=2></div></td>
	  <td height="25"> <div align="center"><?=$r[vname]?></div></td>
      <td height="25"> <div align="center"><a href="AddVolume.php?enews=EV&vid=<?=$r[vid]?>&bookid=<?=$bookid?>">修改</a> | <a href="ecms.php?enews=DelVolume&bookid=<?=$bookid?>&vid=<?=$r[vid]?>">删除</a></div></td>
	</tr>
<?
}
?>
    <tr class="header"> 
      <td height="25" colspan="4"> <div align="left"> &nbsp;&nbsp;
          <input type="submit" name="Submit5" value="修改分卷顺序" onClick="document.editorder.enews.value='EditVOrder';document.editorder.action='ecms.php';">&nbsp;&nbsp;
          <input name="enews" type="hidden" id="enews" value="EditVOrder">
		  <input name="bookid" type="hidden" id="bookid" value="<?=$bookid?>">
		  <input name="classid" type="hidden" id="classid" value="<?=$classid?>">
        </div></td>
    </tr>

</table>
</form>
<?php
require(ECMS_PATH.'e/template/incfile/footer.php');







db_close();
$empire=null;
?>