<?php
define('EmpireCMSAdmin','1');
require("../class/connect.php");
require("../class/db_sql.php");
require("../class/functions.php");
require("../class/dpfun.php");
require("../class/writer.php");
require("../data/dbcache/class.php");
require LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
//验证用户
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];

$wid=$_GET['wid'];

if(!$wid){
	printerror('ErrorUrl','history.go(-1)');
}
$w=$empire->fetch1("select * from {$dbtbpre}enewswriter where wid=$wid limit 1");
if($w[wid]!=$wid){
	printerror('ErrorUrl','history.go(-1)');
}
$len=strlen($w[wbook]);
$str0=substr($w[wbook],0,-1);
$gg='';
if($len<2){
	$gg='<tr  bgcolor=\'#ffffff\'><td colspan=4 height="25" align=center>暂无书籍</td></tr>';
}
if($len>1){
	$str=explode('|',$str0);
	for($i=0;$i<count($str);$i++){
		$bookid=$str[$i];
		$in_b=$empire->fetch1("select id,classid,checked,wid from {$dbtbpre}ecms_bookname_index where id=$bookid");
		if($in_b[checked]){$intb='';}else{$intb='_check';}
		$b=$empire->fetch1("select title,titleurl from {$dbtbpre}ecms_bookname".$intb." where id=$bookid");
		if($bookid==$in_b[id] && $in_b[wid]==$wid){
			$gg.='
				<tr  bgcolor=\'#ffffff\'>
				  <td height="25"><div align="center">
				    <input name="id[]" type="checkbox" id="id[]" value="'.$bookid.'">
					<input name="infoid[]" type="hidden" value="'.$bookid.'">
				  </div></td>
				  <td height="25"><div align="center">'.$in_b[id].'</div></td>
				  <td height="25"> <div align="center"><a href="'.$b[titleurl].'" target="_blank">《'.$b[title].'》</a></div></td>
				  <td height="25"> <div align="center"><a href="'.ClassUrl($in_b[classid]).'" target="_blank">'.$class_r[$in_b[classid]][classname].'</a></div></td>
				  <td height="25"> <div align="center"><a href="AddBook.php?enews=EditNews&id='.$bookid.'&classid='.$in_b[classid].'">修改</a>&nbsp;|&nbsp;<a href="ListWriter.php?enews=DelBfromW&wid='.$wid.'&bookid='.$in_b[id].'">移除</a></div></td>
				</tr>';
		}
	}
}

//导航
$url='<a href="ListWriter.php">作者管理</a>&nbsp;>&nbsp;<a href="ListWriterClass.php"><b>'.$w[wname].'</b>的作品管理</a>';

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="adminstyle/<?=$loginadminstyleid?>/adminstyle.css" type="text/css">
<title>作者分类管理</title>
<script>
function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
    }
  }

function GetSelectId(form)
{
  var ids='';
  var dh='';
  for (var i=0;i<form.elements.length;i++)
  {
	var e = form.elements[i];
	if (e.name == 'id[]')
	{
	   if(e.checked==true)
	   {
       		ids+=dh+e.value;
			dh=',';
	   }
	}
  }
  return ids;
}

function PushInfoToZt(form)
{
	var id='';
	id=GetSelectId(form);
	if(id=='')
	{
		alert('请选择要移动的书籍');
		return false;
	}
	window.open('MvToW.php?wid=<?=$wid?>&id='+id,'PushToZt','width=600,height=500,scrollbars=yes,left=300,top=150,resizable=yes');
}
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr> 
    <td width="52%">位置： 
      <?=$url?>
    </td>
    <td width="48%"><div align="right"></div>
	</td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<form name="listform" method="post" action="ListWriter.php">
  <input type=hidden name=enews value=MVTOWid>
  	<tr class="header">
	  <td width="5%" height="25">&nbsp;</td>
      <td width="10%" height="25"><div align="center">BookID</div></td>
	  <td width="30%" height="25"> <div align="center">书名</div></td>
      <td width="30%" height="25"> <div align="center">栏目</div></td>
      <td width="25%" height="25"> <div align="center">操作</div></td>
    </tr>
	<?=$gg?>
	<tr bgcolor='#ffffff'> 
    <td align=center> 
      <input type=checkbox name=chkall value=on onClick="CheckAll(this.form)">
    </td>
    <td colspan=4><div align="right"><input type="button" name="Submit52" value="移动到其它作者" onClick="PushInfoToZt(this.form);"></div>
	</td>
  </tr>
 </form>
</table>
</body>
</html>
<?
db_close();
$empire=null;
?>