<?php
# Name: PHP版程氏音乐CMS管理系统 v3.0
# Author: 程氏<web@chshcms.com> [QQ:848769359]
# Homepage:http://www.chshcms.cn/
include_once("../../lib/cs_label.php");
include_once("../loginstate.php");
SystemPer('1_5');
$ac=CS_Request("ac");
?>
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>chshdjcms management</title>
<link href="../res/css/admin_style.css" rel="stylesheet" />
<link href="../../public/css/webox.css" rel="stylesheet" />
<script type="text/javascript" src="../res/js/ajax.js"></script>
<script language="javascript" src="../res/js/jquery.js"></script>
<script type="text/javascript" src="../../public/js/webox.js"></script>
<script language="javascript"> 
function del(_id){ 
  if (confirm("确定删除吗？")){
    window.location='?ac=del&id='+_id;
    return true;
  }else{
     return false;
  }		
}

function Dhid(_id){ 
      var cur=document.getElementById('dh_'+_id);
      var cur2=document.getElementById('ddh_'+_id);
        if(cur.style.display=='none'){
              cur.style.display='';
              cur2.className='away_icon';
        }else{
              cur.style.display='none';
              cur2.className='start_icon';
        }	
}
</script>
</head>
<body>
<div class="wrap">
<!-- start -->
<div class="nav">
	<ul class="cc">
			<li class="current"><a href="?">Tags标签管理</a></li>
		        <li><a href="javascript:Popsboxif('添加标签',450,305,'tags_add.php');">添加标签</a></li>
	</ul>
</div>
<form method="post" class="J_ajaxForm" action="?ac=edit" data-role="list">
<div class="table_list">
	<table width="100%" id="J_table_list" style="table-layout:fixed;">
		<colgroup>
			<col width="30">
			<col width="280">
			<col width="280">
			<col width="80">
			<col>
		</colgroup>
		<thead>
			<tr>
				<td></td>
				<td>[ID] 标签名称</td>
				<td>操作</td>
			</tr>
		</thead>

		<tbody>
		<tr>
			<td><span id="ddh_1" onClick="Dhid(1);" class="J_start_icon away_icon"></span></td>
			<td>
				<input name="CS_CSID" type="text" class="input length_0 mr10" value="T1">
				<input name="CS_TT" type="text" class="input length_3 mr5" value="按年代">
			</td>
			<td>
				[删除]
			</td>
		</tr>
		</tbody>
                 <tbody id="dh_1" style="display:">
<?php
	global $db;
	$sql="select * from ".Getdbname('tags')."  where CS_CID=1";
	$result=$db->query($sql);
                if($result){
                     while($row=$db->fetch_array($result)){
?>
			<tr>
				<td>&nbsp;</td>
				<td><span class="plus_icon  plus_end_icon mr10"></span>
				    <input name="CS_ID[]" type="text" class="input length_0 mr10" value="<?php echo $row['CS_ID']?>">
				    <input name="CS_Name<?php echo $row['CS_ID']?>" type="text" class="input length_3 mr5" value="<?php echo $row['CS_Name']?>">
			        </td>
				<td>
				        <a style="cursor:pointer;"  onclick="del(<?php echo $row['CS_ID']?>);" class="mr10 J_ajax_del">[删除]</a>
				</td>
			</tr>
<?php
                     }
                }
?>
                 </tbody>

		<tbody>
		<tr>
			<td><span id="ddh_2" onClick="Dhid(2);" class="J_start_icon away_icon"></span></td>
			<td>
				<input name="CS_CSID" type="text" class="input length_0 mr10" value="T2">
				<input name="CS_TT" type="text" class="input length_3 mr5" value="按曲风">
			</td>
			<td>
				[删除]
			</td>
		</tr>
		</tbody>
                 <tbody id="dh_2" style="display:">
<?php
	$sql2="select * from ".Getdbname('tags')."  where CS_CID=2";
	$result=$db->query($sql2);
                if($result){
                     while($row2=$db->fetch_array($result)){
?>
			<tr>
				<td>&nbsp;</td>
				<td><span class="plus_icon  plus_end_icon mr10"></span>
				    <input name="CS_ID[]" type="text" class="input length_0 mr10" value="<?php echo $row2['CS_ID']?>">
				    <input name="CS_Name<?php echo $row2['CS_ID']?>" type="text" class="input length_3 mr5" value="<?php echo $row2['CS_Name']?>">
			        </td>
				<td>
				        <a style="cursor:pointer;"  onclick="del(<?php echo $row2['CS_ID']?>);" class="mr10 J_ajax_del">[删除]</a>
				</td>
			</tr>
<?php
                     }
                }
?>
                 </tbody>

		<tbody>
		<tr>
			<td><span id="ddh_3" onClick="Dhid(3);" class="J_start_icon away_icon"></span></td>
			<td>
				<input name="CS_CSID" type="text" class="input length_0 mr10" value="T3">
				<input name="CS_TT" type="text" class="input length_3 mr5" value="按心情">
			</td>
			<td>
				[删除]
			</td>
		</tr>
		</tbody>
                 <tbody id="dh_3" style="display:">
<?php
	$sql3="select * from ".Getdbname('tags')."  where CS_CID=3";
	$result=$db->query($sql3);
                if($result){
                     while($row3=$db->fetch_array($result)){
?>
			<tr>
				<td>&nbsp;</td>
				<td><span class="plus_icon  plus_end_icon mr10"></span>
				    <input name="CS_ID[]" type="text" class="input length_0 mr10" value="<?php echo $row3['CS_ID']?>">
				    <input name="CS_Name<?php echo $row3['CS_ID']?>" type="text" class="input length_3 mr5" value="<?php echo $row3['CS_Name']?>">
			        </td>
				<td>
				        <a style="cursor:pointer;"  onclick="del(<?php echo $row3['CS_ID']?>);" class="mr10 J_ajax_del">[删除]</a>
				</td>
			</tr>
<?php
                     }
                }
?>
                 </tbody>

		<tbody>
		<tr>
			<td><span id="ddh_4" onClick="Dhid(4);" class="J_start_icon away_icon"></span></td>
			<td>
				<input name="CS_CSID" type="text" class="input length_0 mr10" value="T4">
				<input name="CS_TT" type="text" class="input length_3 mr5" value="按地域">
			</td>
			<td>
				[删除]
			</td>
		</tr>
		</tbody>
                 <tbody id="dh_4" style="display:">
<?php
	$sql4="select * from ".Getdbname('tags')."  where CS_CID=4";
	$result=$db->query($sql4);
                if($result){
                     while($row4=$db->fetch_array($result)){
?>
			<tr>
				<td>&nbsp;</td>
				<td><span class="plus_icon  plus_end_icon mr10"></span>
				    <input name="CS_ID[]" type="text" class="input length_0 mr10" value="<?php echo $row4['CS_ID']?>">
				    <input name="CS_Name<?php echo $row4['CS_ID']?>" type="text" class="input length_3 mr5" value="<?php echo $row4['CS_Name']?>">
			        </td>
				<td>
				        <a style="cursor:pointer;"  onclick="del(<?php echo $row4['CS_ID']?>);" class="mr10 J_ajax_del">[删除]</a>
				</td>
			</tr>
<?php
                     }
                }
?>
                 </tbody>
        </table>
</div>
<div class="btn_wrap">
	<div class="btn_wrap_pd">
		<button class="btn btn_submit mr10 J_ajax_submit_btn" id="addlist" type="submit">提交</button>
                <div class="tips_error" id="Msg"></div>
	</div>
</div>	
</form>
<!-- end -->
<?php
   if($ac=='edit'){   //修改
        global $db;
   	$CS_ID=CS_RequestBox("CS_ID");
	$ID=explode(",",$CS_ID);
		for($i=0;$i<count($ID);$i++){
			$CS_Name=CS_Request("CS_Name".$ID[$i]);
                        if(!empty($CS_Name)){
				$sql="update ".Getdbname('tags')." set CS_Name='".$CS_Name."' where CS_ID=".$ID[$i]."";
				$db->query($sql);
                        }
		}

      echo '<script>document.getElementById("Msg").className="tips_success";$("#Msg").text("恭喜您,修改成功！").css("color","#026E12");</script>';
      echo "<script>setTimeout(\"window.location.href ='tags.php';\",2000);</script>";
   }
   if($ac=='del'){   //删除
       $CS_ID=CS_Request("id");		
                $sql="delete from ".Getdbname('tags')." where CS_ID=".$CS_ID;
		if($db->query($sql)){
                     echo '<script>document.getElementById("Msg").className="tips_success";$("#Msg").text("恭喜您,删除成功！").css("color","#026E12");</script>';
                     echo "<script>setTimeout(\"window.location.href ='tags.php';\",2000);</script>";
                }else{
                     echo '<script>$("#Msg").text("抱歉,删除失败！").css("color","red");</script>';
                }
   }
?>
</div>
</body>
</html>

