<?php
class PaDefault extends CustomPage {
	public $ssetParid=1;
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnPInitial(){
		$this->checkUser('1,2,3,4,5,');
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'cmsfeedback','sttColumnHead'=>'cfbt'),
			array('sttTableName'=>$this->sysTableHead.'cmsfeedbackcont','sttColumnHead'=>'cfbct'),);
		$this->sUiName='User/cms/other_feedback';
	}
	public function OnBInitial(){
		$this->sMetaTitle='留言';
		$this->sLimitCount=0;
		$this->sApp=new cmsfeedback($this->sConnString);
	}
	public function OnList(){
		//-- ------ #Search data ------ --
		$tmpSTR0='DList0';
		$tmpAR0=$this->getQueryString($tmpSTR0);
		$tmpSTR1='DSort0';
		$tmpAR1=$this->AnalyerRequest($tmpSTR1,'cfbtID,2',0);
		$tmpSTR2='Search0';
		$this->sSearchData=$this->AnalyerRequest($tmpSTR2,',-1',0);
		//#Spell sql
		$tmpSQL=' SELECT 
			A.cfbtID,A.cfbtName,A.cfbtType
			FROM '.$this->sysTableHead.'cmsfeedback AS A 
			WHERE 1=1 
			AND A.cfbtCreateBy='.$this->sUserInfo[0]['Columns']['uitID']['Value'].'
			AND A.cfbtID>'.$this->sLimitCount;
		if($this->sSearchData[0]!=''){
			$tmpSQL.=' AND A.cfbtName LIKE \'%'.$this->sSearchData[0].'%\' ';
		}
		if($this->sSearchData[1]!='-1'){
			$tmpSQL.=' AND A.cfbtType='.$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'=>'cfbtID','stcoctUiName'=>'编号');
		$this->sSortButton[1]=array('stcotName'=>'cfbtName','stcoctUiName'=>'留言标题');
		
		return 0;
	}
	public function OnNormal(){
		$tmpAR0=$this->AnalyerRequest('Normal','0,0',0);
		
		$tmpSQL=' SELECT 
			* 
			FROM '.$this->sysTableHead.'cmsfeedback AS A 
			INNER JOIN '.$this->sysTableHead.'cmsfeedbackcont AS B ON B.cfbctIndexID=A.cfbtID
			WHERE 1=1 AND A.cfbtID='.$tmpAR0[0].'
			AND A.cfbtCreateBy='.$this->sUserInfo[0]['Columns']['uitID']['Value'].' ';
		$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']];
				}
				$Coun0++;
			}
		}else {}
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		if($pColumn['stcotName']=='Quick'){
			$pColumn['ControlStyle']='width:50px;';
		}else if($pColumn['stcotName']=='cfbtChecked' && $pFlag=='Search'){
			$pColumn['Option']=$this->sChecked2;
		}else if($pColumn['stcotName']=='cfbtChecked' && $pFlag=='Normal'){
			$pColumn['Option']=$this->sChecked1;
		}
		return $pColumn;
	}
}
?>