<?php 
//****************************************请求权限*****************************************
require("locked.php");                                                                 //*
setlocked(0,会计科目—恩格会计管理系统);                                                    //*
//****************************************************************************************
$t1=microtime(true);//页面执行起始时间；

include("header.php");

echo '<div align="center">
	  <h1 id="bt">会计科目</h1>
	  <form action="" method="post" name="form1">
	  
	  <select name="serach">
	  <option value="id">ID</option>
	  <option value="Fname" selected="selected">全称</option>
	  <option value="t">分类</option>
	  <option value="dc">方向</option>
	  <option value="etr">录入</option>
	  <option value="chk">审核</option>
	  </select>
	  
	  <select name="cp">
	  <option value="包含" selected="selected">包含</option>
	  <option value="等于">等于</option>
	  <option value="开头是">开头是</option>
	  <option value="结尾是">结尾是</option>
	  </select>
	  
	  <input name="keyword" type="text" />
	  <input id="tj1" name="ok" type="submit" value="提交" />
	  
	  </form>
	  </div>
	  
	  <div align="center">
	  <table id="mytable1" width="95%">
	  <tr>
	  <td align="center"><img src="picture/b_fulltext.png" width="50" height="19" /></td>
	  <td>ID</td>
	  <td>名称</td>
	  <td>全称</td>
	  <td>分类</td>
	  <td>方向</td>
	  <td>数量外币</td>
	  <td>现金流量</td>
	  <td>客户</td>
	  <td>个人</td>
	  <td>存货</td>
	  <td>供应商</td>
	  <td>部门</td>
	  <td>核算项目</td>
	  <td>录入</td>
	  <td>审核</td>
	  </tr>';

if($_SERVER['REQUEST_METHOD']=='POST' && $_POST[ok]=='提交'){
	
	include("cnn.php");
	
	//给HTML控件赋值；
	echo '<script language="javascript" type="text/javascript">
	      form1.serach.value="'.$_POST[serach].'";
		  form1.cp.value="'.$_POST[cp].'";
		  form1.keyword.value="'.$_POST[keyword].'";
		  </script>';
	
	//构造查询SQL语句；
	switch($_POST[cp]){
		case "包含":
			$strSql='select * from account where '.$_POST[serach].' like "%'.$_POST[keyword].'%" order by id asc';
			break;
		case "开头是":
		    $strSql='select * from account where '.$_POST[serach].' like "'.$_POST[keyword].'%" order by id asc';
			break;
		case "结尾是":
		    $strSql='select * from account where '.$_POST[serach].' like "%'.$_POST[keyword].'" order by id asc';
			break;
		default://等于
		    $strSql='select * from account where '.$_POST[serach].'="'.$_POST[keyword].'" order by id asc';
			break;
	}
	
	$sql=$mysqli->query($strSql);
	$info=$sql->fetch_array(MYSQLI_BOTH);
	$num_rows=$sql->num_rows;
	
	echo '<hr width="95%">';
	echo '<div id="ts" align="center">查找到 '.$num_rows.' 条符合条件的记录</div>';//显示查询的记录数及处理时间；
	echo '<hr width="95%">';
	
	if($info){ //如果存在数据；
		DO{
		   echo '<tr>';
		   echo '<td align="center">';
		   echo '<a href="#" onclick="openInsert()"><abbr title="新增"><img src="picture/b_insert.png" /></abbr></a>|';
		   echo '<a href="#" onclick="openEdit('.$info[id].')"><abbr title="修改"><img src="picture/b_edit.png" /></abbr></a>|';
		   echo '<a href="#" onclick="openDrop('.$info[id].')"><abbr title="删除"><img src="picture/b_drop.png" /></abbr></a>|';
		   echo '<a href="#" onclick="openCheck('.$info[id].')"><abbr title="审核"><img src="picture/b_check.png" /></abbr></a>|';
		   echo '<a href="#" onclick="openCopy('.$info[id].')"><abbr title="复制"><img src="picture/b_copy.png" /></abbr></a>';
		   echo '</td>';
		   echo '<td>'.$info[id].'</td>';
		   echo '<td>'.$info[name].'</td>';
		   echo '<td>'.$info[Fname].'</td>';
		   echo '<td align="center">'.$info[t].'</td>';
		   echo '<td align="center">'.$info[dc].'</td>';
		   echo '<td align="center">'.$info[slwb].'</td>';
		   echo '<td align="center">'.$info[xjll].'</td>';
		   echo '<td align="center">'.$info[kh].'</td>';
		   echo '<td align="center">'.$info[gr].'</td>';
		   echo '<td align="center">'.$info[ch].'</td>';
		   echo '<td align="center">'.$info[gys].'</td>';
		   echo '<td align="center">'.$info[bm].'</td>';
		   echo '<td align="center">'.$info[xm].'</td>';
		   echo '<td>'.$info[etr].'</td>';
		   echo '<td>'.$info[chk].'</td>';
		   echo '</tr>';
		}while($info=$sql->fetch_array(MYSQLI_BOTH));
	}else{
		echo '<tr>';
		echo '<td align="center" colspan="16">系统未检索到相关数据；<a href="#" onclick="openInsert()">新增</a></td>';
		echo '</tr>';
	}
	
	$sql->free();
	$mysqli->close();
	  
	echo '<script language="javascript" type="text/javascript">
		  //限制频繁点击提交按钮，再次提交需要等待三秒；
		  document.getElementById("tj1").disabled=true;
		  setTimeout("getTj()",3000)
		  function getTj(){
			  document.getElementById("tj1").disabled=false;
		  }
		  </script>';
		  
}else{//非"提交"页面的初始化；
	echo '<tr>';
	echo '<td align="center" colspan="16">请使用提交按钮检索相关数据；<a href="#" onclick="openInsert()">新增</a></td>';
	echo '</tr>';
}

echo '</table></div>';

?>

<script language="javascript" type="text/javascript">
<!--

mytable("mytable1");//表格样式；

//维护会计科目信息弹出页面的样式；
var sta="height=480,width=550,top="+(window.screen.availHeight-480)/2+",left="+(window.screen.availWidth-550)/2;
sta=sta+",toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no";
function openInsert(){
	var url="account_Insert.php"
	window.open(url,"",sta);
}
function openEdit(id){
	var url="account_Edit.php?keyword="+id
	window.open(url,"",sta);
}
function openDrop(id){
	var url="account_Drop.php?keyword="+id
	window.open(url,"",sta);
}
function openCheck(id){
	var url="account_Check.php?keyword="+id
	window.open(url,"",sta);
}
function openCopy(id){
	var url="account_Copy.php?keyword="+id
	window.open(url,"",sta);
}

//自动加载高亮显示；
HighLight();

//-->
</script>

<?php 

$t2=microtime(true);//页面执行终止时间；
//给HTML控件赋值；
echo '<script language="javascript" type="text/javascript">
	  document.getElementById("ts").innerHTML+="，耗时 '.round($t2-$t1,4).' 秒。";
	  </script>';
	  
include("footer.php");

?>