<?php
require($netsFileConfig['sysCoreRoot'].'Inc/m_Shop/Sale/shopuserpay.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.'shopuserpay','sttColumnHead'=>'shupt'),
			array('sttTableName'=>$this->sysTableHead.'shopuserpaycont','sttColumnHead'=>'shupct'),);
		$this->sUiName='Platform/shop/sale_userpay';
	}
	public function OnBInitial(){
		$this->sMetaTitle='用户充值与提现';
		$this->sLimitCount=0;
		$this->sApp=new shopuserpay($this->sConnString);
		//Type
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=112;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Userpay_Type';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sType1);
		$this->sType2=$this->sType1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有类型]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sType2,$tmpAR0);
		//State_Pay
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=113;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Userpay_State_Pay';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sState_Pay1);
		$this->sState_Pay2=$this->sState_Pay1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有支付状态]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sState_Pay2,$tmpAR0);
		//State_Get
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=114;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Userpay_State_Get';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sState_Get1);
		$this->sState_Get2=$this->sState_Get1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有提现状态]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sState_Get2,$tmpAR0);
		
		
	}
	public function OnList(){
		//-- ------ #Search data ------ --
		$tmpSTR0='DList0';
		$tmpAR0=$this->getQueryString($tmpSTR0);
		$tmpSTR1='DSort0';
		$tmpAR1=$this->AnalyerRequest($tmpSTR1,'shuptID,2',0);
		$tmpSTR2='Search0';
		$this->sSearchData=$this->AnalyerRequest($tmpSTR2,',-1,-1,-1,',0);
		//#Spell sql
		$tmpSQL=' SELECT 
			A.shuptID,A.shuptName,A.shuptType,A.shuptState_Pay,A.shuptState_Get,A.shuptTotalPrice,A.shuptCreateBy
			FROM {Nets.TableHead}shopuserpay AS A 
			WHERE 1=1 
			AND A.shuptID>'.$this->sLimitCount;
		if($this->sSearchData[0]!=''){
			$tmpSQL.=' AND A.shuptName LIKE \'%'.$this->sSearchData[0].'%\' ';
		}
		if($this->sSearchData[1]!=-1){
			$tmpSQL.=' AND B.shuptType='.$this->sSearchData[1].' ';
		}
		if($this->sSearchData[2]!=-1){
			$tmpSQL.=' AND B.shuptState_Pay='.$this->sSearchData[2].' ';
		}
		if($this->sSearchData[3]!=-1){
			$tmpSQL.=' AND B.shuptState_Get='.$this->sSearchData[3].' ';
		}
		if($this->sSearchData[4]!=''){
			$tmpSQL.=' AND B.shuptTotalPrice='.$this->sCode->Decimal($this->sSearchData[4],0.00).' ';
		}
		if($tmpAR1[1]==1){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' ';
		}else if($tmpAR1[1]==2){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' DESC ';
		}
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$this->sListData=$this->sDb->SearchP($tmpSTR,$tmpAR0);
		//#Set page button
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&'.$tmpSTR2.'='.
			$this->sSearchData[0].$this->sysSPLIT1.
			$this->sSearchData[1].$this->sysSPLIT1.
			$this->sSearchData[2].$this->sysSPLIT1.
			$this->sSearchData[3].$this->sysSPLIT1.
			$this->sSearchData[4];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		$this->sPButton->setSort($tmpAR1);
		$this->sSortButton[0]=array('stcotName'=>'shuptID','stcoctUiName'=>'编号');
		$this->sSortButton[1]=array('stcotName'=>'shuptName','stcoctUiName'=>'用户充值与提现名称');
		
		return 0;
	}
	public function OnExternal_Search(){
		//-- ------ #Search data ------ --
		$tmpSTR0='DList0';
		$tmpAR0=$this->getQueryString($tmpSTR0);
		$tmpSTR1='DSort0';
		$tmpAR1=$this->AnalyerRequest($tmpSTR1,'shuptID,2',0);
		$tmpSTR2='Search0';
		$this->sSearchData=$this->AnalyerRequest($tmpSTR2,',,-1',0);
		$this->sExternal_SearchData=$this->AnalyerRequest($this->sActionType,',-1',0);
		//#Spell sql
		$tmpSQL=' SELECT A.shuptID,A.shuptName,A.shuptParid
			FROM '.$this->sysTableHead.'shopuserpay AS A 
			WHERE 1=1 
			AND A.shuptID>'.$this->sLimitCount;
		if($this->sSearchData[0]!=''){
			$tmpSQL.=' AND A.shuptName LIKE \'%'.$this->sSearchData[0].'%\' ';
		}
		if($this->sSearchData[1]!='-1'){
			$tmpSQL.=' AND A.shuptParid='.$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->sExtendParameter='&ActionType='.$this->sActionType.'&'.$this->sActionType.'='.$this->sExternal_SearchData[0].','.$this->sExternal_SearchData[1];
		$this->sysPages[0]=$this->sysPage.'?'.$this->sExtendParameter;
		
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&'.$tmpSTR2.'='.$this->sSearchData[0].$this->sExtendParameter;
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		$this->sPButton->setSort($tmpAR1);
		$this->sSortButton[0]=array('stcotName'=>'shuptID','stcoctUiName'=>'编号');
		$this->sSortButton[1]=array('stcotName'=>'shuptName','stcoctUiName'=>'用户充值与提现名称');
		
		return 0;
	}
	public function OnExternal_ChildChoose(){
		//-- ------ #Search data ------ --
		$tmpSTR0='External_ChildChoose';
		$this->sExternal_ChildChooseSData=$this->AnalyerRequest($tmpSTR0,'0,,0,0',0);
		//#Spell sql
		$tmpSQL='';
		if($this->sExternal_ChildChooseSData[0]==0 || $this->sExternal_ChildChooseSData[0]==2){
			//-- Same grade --
			$tmpSQL=' SELECT A.shuptID,A.shuptName,A.shuptParid 
				FROM '.$this->sysTableHead.'shopuserpay AS A
				WHERE 1=1 AND A.shuptRecycle=0 AND A.shuptChecked>1 AND 
				A.shuptParid=(SELECT shuptParid FROM shopuserpay WHERE 1=1 AND shuptRecycle=0 AND shuptChecked>1 AND shuptID={Nets.ID})
				ORDER BY A.shuptOrderBy DESC,A.shuptID DESC ';
		}else if($this->sExternal_ChildChooseSData[0]==1 || $this->sExternal_ChildChooseSData[0]==3){
			//-- Child grade --
			$tmpSQL=' SELECT A.shuptID,A.shuptName,A.shuptParid 
				FROM '.$this->sysTableHead.'shopuserpay AS A
				WHERE 1=1 AND A.shuptRecycle=0 AND A.shuptChecked>1 AND A.shuptParid={Nets.ID}
				ORDER BY A.shuptOrderBy DESC,A.shuptID DESC ';
		}
		$tmpSTR=str_replace('{Nets.ID}',$this->sExternal_ChildChooseSData[2],$tmpSQL);
		$this->sExternal_ChildChooseData=$this->sDb->Search($tmpSTR);
		
		return 0;
	}
	public function OnNormal(){
		$tmpINT=0;
		$tmpAR0=$this->AnalyerRequest('Normal','0,0',0);
		
		$tmpSQL=' SELECT * 
			FROM '.$this->sysTableHead.'shopuserpay AS A 
			INNER JOIN '.$this->sysTableHead.'shopuserpaycont AS B ON B.shupctIndexID=A.shuptID ';
		$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.shuptID ';
				$Coun0++;
			}
		}
		$tmpSQL.=' WHERE 1=1 AND A.shuptID='.$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']=='shuptParid'){
					}else if($this->sUiDescription_Normal[$Coun0]['stcotName']=='shuptModelid_Detail'){
						$this->sUiDescription_Normal[$Coun0]['Value']=$this->sMainTableid;
					}
				}
				$Coun0++;
			}
		}else {
			$Coun0=0;
			foreach($this->sUiDescription_Normal as $Row0){
				if($Row0['stcotName']=='shuptTableid'){
					$this->sUiDescription_Normal[$Coun0]['Value']=$this->sMainTableid;
				}
				$Coun0++;
			}
		}
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);
		if($pColumn['stcotName']=='shuptType' && $pFlag=='Search'){
			$pColumn['Option']=$this->sType2;
		}else if($pColumn['stcotName']=='shuptType' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Option']=$this->sType1;
		}else if($pColumn['stcotName']=='shuptState_Pay' && $pFlag=='Search'){
			$pColumn['Option']=$this->sState_Pay2;
		}else if($pColumn['stcotName']=='shuptState_Pay' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Option']=$this->sState_Pay1;
		}else if($pColumn['stcotName']=='shuptState_Get' && $pFlag=='Search'){
			$pColumn['Option']=$this->sState_Get2;
		}else if($pColumn['stcotName']=='shuptState_Get' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Option']=$this->sState_Get1;
			
		}
		return $pColumn;
	}
}
?>