<?php
class PaDefault extends CustomPage {
	public $ssetParid=0;
	
	public function PaDefault(){
		$this->ComPage();
	}
	public function OnPInitial(){
		$this->checkUser('1,2,3,4,5,');
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'oamessagegroup','sttColumnHead'=>'omgt'),
			array('sttTableName'=>$this->sysTableHead.'oamessagegroupcont','sttColumnHead'=>'omgct'),);
		$this->sUiName='Mana/my/my_messagegroup';
	}
	public function OnBInitial(){
		$this->sMetaTitle='短信分组';
		$this->sLimitCount=0;
		$this->sApp=new oamessagegroup($this->sConnString);
		$this->sSpicalValue=array();
		$this->sSpicalValue=array(0,$this->sTable[0]['sttColumnHead'].'CreateBy',$this->sUserInfo[0]['Columns']['uitID']['Value']);
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT 
			A.omgtID,A.omgtName,A.omgtParid 
			FROM '.$this->sysTableHead.'oamessagegroup AS A
			WHERE 1=1 AND A.omgtChecked>1 AND A.omgtParid={Nets.Parid}
			AND A.omgtCreateBy='.$this->sUserInfo[0]['Columns']['uitID']['Value'].'
			ORDER BY A.omgtOrderBy DESC,A.omgtID DESC ';
		$tmpAR0['InitialString']=$this->ssetParid;
		$tmpAR0['Parid']='omgtID';
		$tmpAR0['Text']='omgtName';
		$tmpAR0['Value']='omgtID';
		$tmpAR0['Type']=0;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sParid1=$this->sParid2=$this->sControl->bindDropdown($tmpAR0);
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[根目录]';
		$tmpAR0['Value']=0;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sParid2,$tmpAR0);
	}
	public function OnList(){
		//-- ------ #Search data ------ --
		$tmpSTR0='DList0';
		$tmpAR0=$this->getQueryString($tmpSTR0);
		$tmpSTR1='DSort0';
		$tmpAR1=$this->AnalyerRequest($tmpSTR1,'omgtID,2',0);
		$tmpSTR2='Search0';
		$this->sSearchData=$this->AnalyerRequest($tmpSTR2,',0',0);
		//#Spell sql
		$tmpSQL=' SELECT 
			A.omgtID,A.omgtName,A.omgtParid
			FROM '.$this->sysTableHead.'oamessagegroup AS A 
			WHERE 1=1 
			AND A.omgtCreateBy='.$this->sUserInfo[0]['Columns']['uitID']['Value'].'
			AND A.omgtID>'.$this->sLimitCount;
		if($this->sSearchData[0]!=''){
			$tmpSQL.=' AND A.omgtName LIKE \'%'.$this->sSearchData[0].'%\' ';
		}
		if($this->sSearchData[1]!='-1'){
			$tmpSQL.=' AND A.omgtParid='.$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'=>'omgtID','stcoctUiName'=>'编号');
		$this->sSortButton[1]=array('stcotName'=>'omgtName','stcoctUiName'=>'短信分组名');
		
		return 0;
	}
	public function OnNormal(){
		$tmpAR0=$this->AnalyerRequest('Normal','0,0',0);
		
		$tmpSQL=' SELECT 
			* 
			FROM '.$this->sysTableHead.'oamessagegroup AS A 
			INNER JOIN '.$this->sysTableHead.'oamessagegroupcont AS B ON B.omgctIndexID=A.omgtID
			WHERE 1=1 AND A.omgtID='.$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']];
				}
				$Coun0++;
			}
		}else {}
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);
		if($pColumn['stcotName']=='omgtParid'){
			$pColumn['Option']=$this->sParid2;
		}
		return $pColumn;
	}
}
?>