<?php
require('../../../QPlatform/Common/Component/ComInitialHead.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Nets/System/netssysservice.php');

class PaDefault extends CustomPage {
	public $ssetParid=1;
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnPInitial(){
		$this->checkUser('1,2,3,');
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'netssysservice','sttColumnHead'=>'ssert'),
			array('sttTableName'=>$this->sysTableHead.'netssysservicecont','sttColumnHead'=>'sserct'),);
		$this->sUiName='Platform/nets/system_service';
	}
	public function OnBInitial(){
		$this->sMetaTitle='服务';
		$this->sLimitCount=0;
		$this->sApp=new netssysservice($this->sConnString);
	}
	public function OnList(){
		//-- ------ #Search data ------ --
		$tmpSTR0='DList0';
		$tmpAR0=$this->getQueryString($tmpSTR0);
		$tmpSTR1='DSort0';
		$tmpAR1=$this->AnalyerRequest($tmpSTR1,'ssertID,2',0);
		$tmpSTR2='Search0';
		$this->sSearchData=$this->AnalyerRequest($tmpSTR2,',-1',0);
		//#Spell sql
		$tmpSQL=' SELECT 
			A.ssertID,A.ssertName,A.ssertParid
			FROM '.$this->sysTableHead.'netssysservice AS A 
			WHERE 1=1 
			AND A.ssertID>'.$this->sLimitCount;
		if($this->sSearchData[0]!=''){
			$tmpSQL.=' AND A.ssertName LIKE \'%'.$this->sSearchData[0].'%\' ';
		}
		if($this->sSearchData[1]!='-1'){
			$tmpSQL.=' AND A.ssertParid='.$this->sSearchData[1].' ';
		}
		if($tmpAR1[1]==1){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' ';
		}else if($tmpAR1[1]==2){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' DESC ';
		}
		$this->sListData=$this->sDb->SearchP($tmpSQL,$tmpAR0);
		//#Set page button
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&'.$tmpSTR2.'='.$this->sSearchData[0].','.$this->sSearchData[1];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		$this->sPButton->setSort($tmpAR1);
		$this->sSortButton[0]=array('stcotName'=>'ssertID','stcoctUiName'=>'编号');
		$this->sSortButton[1]=array('stcotName'=>'ssertName','stcoctUiName'=>'项名');
		
		return 0;
	}
	public function OnNormal(){
		$tmpAR0=$this->AnalyerRequest('Normal','0,0',0);
		
		$tmpSQL=' SELECT * 
			FROM '.$this->sysTableHead.'netssysservice AS A 
			INNER JOIN '.$this->sysTableHead.'netssysservicecont AS B ON B.sserctIndexID=A.ssertID ';
		$Coun0=2;
		foreach ($this->sTable as $Row0){
			if (count($this->sTable)>2) {
				$tmpSQL.=' INNER JOIN '.$Row0['sttTableName'].' AS '.$this->sysTableMark[$Coun0].' ON '.$this->sysTableMark[$Coun0].'.'.$Row0['sttColumnHead'].'IndexID=A.ssertID ';
				$Coun0++;
			}
		}
		$tmpSQL.=' WHERE 1=1 AND A.ssertID='.$tmpAR0[0].' ';
		$tmpDataCollection0=$this->sDb->Search($tmpSQL);
		if(count($tmpDataCollection0)>0){
			$tmpRow=$tmpDataCollection0[0];
			$this->sMainID=$tmpRow[$this->sTable[0]['sttColumnHead'].'ID'];
			//-- #Get value --
			$Coun0=0;
			while (count($this->sUiDescription_Normal)>$Coun0) {
				if(isset($tmpRow[$this->sUiDescription_Normal[$Coun0]['stcotName']])){
					$this->sUiDescription_Normal[$Coun0]['Value']=$tmpRow[$this->sUiDescription_Normal[$Coun0]['stcotName']];
					//Spical set
					if($this->sUiDescription_Normal[$Coun0]['stcotName']=='ssertParid'){
						$tmpSQL=' SELECT A.dptName FROM '.$this->sysTableHead.'downproduct AS A WHERE 1=1 AND A.dptID='.$tmpRow['ssertParid'].' ';
						$tmpDataCollection1=$this->sDb->Search($tmpSQL);
						if(count($tmpDataCollection1)>0){
							$this->sUiDescription_Normal[$Coun0]['ShowValue']=$tmpDataCollection1[0]['dptName'];
						}
					}
				}
				$Coun0++;
			}
		}else {}
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		if($pColumn['stcotName']=='Quick'){
			$pColumn['ControlStyle']='width:50px;';
		}else if($pColumn['stcotName']=='ssertChecked' && $pFlag=='Search'){
			$pColumn['Option']=$this->sChecked2;
		}else if($pColumn['stcotName']=='ssertChecked' && $pFlag=='Normal'){
			$pColumn['Option']=$this->sChecked1;
		}else if($pColumn['stcotName']=='ssertParid' && $pFlag=='Search'){
			$pColumn['Option']=$this->sParid2;
		}else if($pColumn['stcotName']=='ssertParid' && $pFlag=='Normal'){
			$pColumn['Option']=$this->sParid1;
		}
		return $pColumn;
	}
}
//-- ------ #Instanct ------ --
$tmpDefault=new PaDefault();
$tmpDefault->OnPage();
$tmpControls=new CustomControls();
$tmpControlPage=new CustomControlPage();
$tmpComHead->sMenuid=$tmpDefault->sMenuid;
$tmpDefault->sysMetaTitle=$tmpDefault->sMetaTitle.' - '.$tmpDefault->sysFileConfig['sysTitle'];
//-- ------ #Template ------ --
require($tmpDefault->sysFileConfig['sysCoreRoot'].$tmpDefault->sysQPlatformTemplatePath.'Component/Group_0.php'); ?>