<?php
/*
页面功能：配合页面V_1.php,从会计科目表中提取过滤信息；
*/
//****************************************请求权限*****************************************
require("locked.php");                                                                 //*
setlocked(8);                                                                          //*
//****************************************************************************************

//提取核算项目的类
class pro{
	public $proName;
	public function xmhs($id){
		include("cnn.php");
	    $sql=$mysqli->query('select slwb,xjll,kh,gr,ch,gys,bm,xm from account where id="'.$id.'"');
		$info=$sql->fetch_array(MYSQLI_BOTH);
		if($info[slwb]==-1){
			$this->proName='数量外币';
		}
		if($info[xjll]==-1){
			$this->proName=$this->proName.'/现金流量';
		}
		if($info[kh]==-1){
			$this->proName=$this->proName.'/客户';
		}
		if($info[gr]==-1){
			$this->proName=$this->proName.'/个人';
		}
		if($info[ch]==-1){
			$this->proName=$this->proName.'/存货';
		}
		if($info[gys]==-1){
			$this->proName=$this->proName.'/供应商';
		}
		if($info[bm]==-1){
			$this->proName=$this->proName.'/部门';
		}
		if($info[xm]==-1){
			$this->proName=$this->proName.'/核算项目';
		}
		if(substr($this->proName,0,1)=="/"){
			$this->proName=substr($this->proName,1,strlen($this->proName)-1);
		}
		if(strlen($this->proName)>0){
			return $this->proName;
		}else{
			return "空白";
		}
	}
}

include("cnn.php");
$searchText=$mysqli->real_escape_string($_GET[searchText]);
$strsql='select id,Fname,t,dc from account where id like "'.$searchText.'%" or Fname like "%'.$searchText.'%" order by id asc';
$sql=$mysqli->query($strsql);
$info=$sql->fetch_array(MYSQLI_BOTH);
echo '<table border=1 cellspacing=0 bgcolor="white" id="tbl2" style="float:left; margin:0px; padding:0px;">';
if($info){ //如果存在数据；
    DO{
	   echo '<tr onmouseover="trMouseover(this)" onmouseout="trMouseout(this)" onclick="trClick(this)">';
	   echo '<td>'.$info[id].'</td>';
	   echo '<td>'.$info[Fname].'</td>';
	   $xmName=new pro();
	   echo '<td>'.$xmName->xmhs($info[id]).'</td>';
	   echo '<td>'.$info[dc].'</td>';
	   echo '<td>'.$info[t].'</td>';
	   echo '</tr>';
	}while($info=$sql->fetch_array(MYSQLI_BOTH));
	//写最后一行内容；
	echo '<tr>';
	echo '<td colspan="5">';
	echo '<div style="float:left"><input id="addKM" value="新增会计科目" onclick="openInsertAccount()" type="button" /></div>';
	echo '</td>';
	echo '</tr>';
}else{
    //写最后一行内容；
	echo '<tr>';
	echo '<td>';
	echo '<div style="float:left"><input id="addKM" value="新增会计科目" onclick="openInsertAccount()" type="button" /></div>';
	echo '</td>';
	echo '</tr>';
}
echo '</table>';

$sql->free();
$mysqli->close();
?>