<?php
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsSocket.php');
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsEmail.php');
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsMobile.php');
require($netsFileConfig['sysCoreRoot_Real'].'Cache/DbDescription/netsuserdaily.php');
require($netsFileConfig['sysCoreRoot_Real'].'Cache/DbDescription/netsuserdailycont.php');


class PaDefault extends CustomPage {
	public $sMainData0=array();
	public $sConfirmStateAR=array();
	public $sDescription_local=array();
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnPInitial(){
		$this->checkUser('1,2,3,4,5,');
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'netsuserinfo','sttColumnHead'=>'uit'),
			array('sttTableName'=>$this->sysTableHead.'netsuserinfocont','sttColumnHead'=>'uict'),);
	}
	public function OnBInitial(){
		$this->sMetaTitle='用户认证';
		$this->sApp=new netsuserinfo($this->sConnString);
		$this->sDescription_local[0]=$this->sDbDescriptions[$this->sysTableHead.'netsuserinfo'];
		$this->sDescription_local[1]=$this->sDbDescriptions[$this->sysTableHead.'netsuserinfocont'];
		
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.shupttID,A.shupttName,A.shupttParid,A.shupttNameStyle 
			FROM '.$this->sysTableHead.'shopuserpaytype AS A
			WHERE 1=1 AND A.shupttRecycle=0 AND A.shupttChecked>1 AND A.shupttType=1
			ORDER BY A.shupttID DESC ';
		$tmpAR0['InitialString']=1;
		$tmpAR0['Parid']='shupttID';
		$tmpAR0['Text']='shupttName';
		$tmpAR0['Value']='shupttID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='cms/Shopsale_Paytype';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sPaytype1);
		//ConfirmState
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=48;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_ConfirmState';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sConfirmState);
		
		
		
		//-- ------ #Action ------ --
		if($this->sActionTypeF=='DConfirmEmail' || $this->sActionTypeF=='DConfirmMobile' || 
			$this->sActionTypeF=='DConfirmBank' || $this->sActionTypeF=='DConfirmPay' || $this->sActionTypeF=='DConfirmPostcode'){
			$this->OnConfirm($this->sActionTypeF);
		}else if($this->sActionTypeF=='DConfirmEmail_Callback' || $this->sActionTypeF=='DConfirmMobile_Callback' || 
			$this->sActionTypeF=='DConfirmPay_Callback' || $this->sActionTypeF=='DConfirmBank_Callback'){
			$this->OnConfirm_callback($this->sActionTypeF);
			
		}
		
		//-- ------ ### ------ --
		$this->sFormtype='';

	}
	
	public function OnConfirm($pType){
		//-- ------ # ------ --
		//uitID
		$this->sDescription_local[0]['Columns']['uitID']['Value']=
			$this->sDescription_local[1]['Columns']['uictIndexID']['Value']=
			$this->sUserInfo[0]['Columns']['uitID']['Value'];
		//-- ### --
		if($pType=='DConfirmEmail'){
			//uitEmail
			$tmpAR0=array('uitEmail',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$this->sDescription_local[0]['Columns'][$Cell]['Value']=$tmpAR1[0];
			}
		}else if($pType=='DConfirmMobile'){
			//uictCoMobile
			$tmpAR0=array('uictCo_Mobile',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$this->sDescription_local[1]['Columns'][$Cell]['Value']=$tmpAR1[0];
			}
		}else if($pType=='DConfirmBank'){
			//uictPayBank
			$tmpAR0=array('uictPayBankCode','uictPayBankName','uictPayBankUName','uictPayBankAddress','uictChecked_PayBank_Num',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$this->sDescription_local[1]['Columns'][$Cell]['Value']=$tmpAR1[0];
			}
		}else if($pType=='DConfirmPay'){
			//uictPayBank
			$tmpAR0=array('uictPayType','uictPayCode','uictChecked_Pay_Num',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$this->sDescription_local[1]['Columns'][$Cell]['Value']=$tmpAR1[0];
			}
		}else if($pType=='DConfirmPostcode'){
			//uictPostcode
			$tmpAR0=array('uictPostcode','uictPostcodeSource',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$this->sDescription_local[1]['Columns'][$Cell]['Value']=$tmpAR1[0];
			}
		}
		//-- ------ # ------ --
		$this->sApp->sDbDescriptions_Other=array(
			array($this->sysDbDescriptions[$this->sysTableHead.'netsuserdaily'],
				$this->sysDbDescriptions[$this->sysTableHead.'netsuserdailycont'],),
			);
		$tmpINT=$this->sApp->SetConfirm($this->sDescription_local,$pType);
		if ($tmpINT!=0){
			$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastError,'');
			return 1;
		}
		
		$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastMessage,'');
		return 0;
	}
	public function OnConfirm_callback($pType){
		//-- ------ # ------ --
		//uitID
		$this->sDescription_local[0]['Columns']['uitID']['Value']=
			$this->sDescription_local[1]['Columns']['uictIndexID']['Value']=
			$this->sUserInfo[0]['Columns']['uitID']['Value'];
		//-- ### --
		$tmpNum='';
		if($pType=='DConfirmEmail_Callback'){
			//DConfirmEmail_Callback
			$tmpAR0=$this->AnalyerRequest('CODE',',',0);
			$this->sDescription_local[0]['Columns']['uitID']['Value']=
				$this->sDescription_local[1]['Columns']['uictIndexID']['Value']=
				$this->sCode->Int32($tmpAR0[0],0);
			$tmpNum=$tmpAR0[1];
			
		}else if($pType=='DConfirmMobile_Callback'){
			//DConfirmMobile_Callback
			$tmpAR0=array('uictChecked_Mobile_Num',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$tmpNum=$tmpAR1[0];
			}
			
		}else if($pType=='DConfirmBank_Callback'){
			//DConfirmBank_Callback
			$tmpAR0=array('uictChecked_Bank_Num',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$tmpNum=$tmpAR1[0];
			}
		}else if($pType=='DConfirmPay_Callback'){
			//uictPayBank
			$tmpAR0=array('uictChecked_Pay_Num',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$tmpNum=$tmpAR1[0];
			}
			
		}
		$this->sDescription_local[0]['Columns']['uitCheckNum']['Value']=$tmpNum;
		//-- ------ # ------ --
		$this->sApp->sDbDescriptions_Other=array(
			array($this->sysDbDescriptions[$this->sysTableHead.'netsuserdaily'],
				$this->sysDbDescriptions[$this->sysTableHead.'netsuserdailycont'],),
			);
		$tmpINT=$this->sApp->SetConfirm_Callback($this->sDescription_local,$pType);
		if ($tmpINT!=0){
			$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastError,'');
			return 1;
		}
		
		$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastMessage,'');
		return 0;
	}
	public function OnList(){
		//-- ------ #User data ------ --
		//-- #netsuserinfo --
		$tmpSQL=' SELECT A.uitID,A.uitName,A.uitNumCode,A.uitNickname,A.uitPxd,A.uitGradeid,
			B.uictChecked_Email,B.uictChecked_Mobile,B.uictChecked_Postcode,B.uictChecked_Bank,B.uictChecked_Pay

			FROM {Nets.TableHead}netsuserinfo AS A
			INNER JOIN {Nets.TableHead}netsuserinfocont AS B ON B.uictIndexID=A.uitID
			INNER JOIN {Nets.TableHead}netsuserunit AS C ON C.uutID=A.uitUnitid
			INNER JOIN {Nets.TableHead}netsuserunitcont AS D ON D.uuctIndexID=C.uutID
			WHERE 1=1 AND A.uitID={Nets.ID}; ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sUserInfo[0]['Columns']['uitID']['Value'],$tmpSTR);
		$this->sData_Userinfo=$this->sDb->Search($tmpSTR);
		//-- #netsusergrade --
		$tmpSQL=' SELECT A.ugratID,A.ugratName
			FROM {Nets.TableHead}netsusergrade AS A
			WHERE 1=1 AND A.ugratRecycle=0 AND A.ugratChecked>1 AND A.ugratID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sData_Userinfo[0]['uitGradeid'],$tmpSTR);
		$this->sData_Usergrade=$this->sDb->Search($tmpSTR);
		if(count($this->sData_Usergrade)==0){
			$this->sData_Usergrade[0]['ugratName']='初级用户';
		}
		
		return 0;
	}
	public function OnNormal(){
		//-- ------ #User data ------ --
		//-- #netsuserinfo --
		$tmpSQL=' SELECT A.uitID,A.uitName,A.uitNumCode,A.uitNickname,A.uitPxd,A.uitGradeid,A.uitEmail,
			B.uictCo_Mobile,B.uictPayBankCode,B.uictPayBankName,B.uictPayBankUName,B.uictPayType,B.uictPayCode,
			B.uictPayBankAddress,B.uictPostcode,B.uictPostcodeSource,
			B.uictChecked_Email,B.uictChecked_Mobile,B.uictChecked_Postcode,B.uictChecked_Bank,B.uictChecked_Pay

			FROM {Nets.TableHead}netsuserinfo AS A
			INNER JOIN {Nets.TableHead}netsuserinfocont AS B ON B.uictIndexID=A.uitID
			INNER JOIN {Nets.TableHead}netsuserunit AS C ON C.uutID=A.uitUnitid
			INNER JOIN {Nets.TableHead}netsuserunitcont AS D ON D.uuctIndexID=C.uutID
			WHERE 1=1 AND A.uitID={Nets.ID}; ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sUserInfo[0]['Columns']['uitID']['Value'],$tmpSTR);
		$this->sData_Userinfo=$this->sDb->Search($tmpSTR);
		
		//-- ------ #Form ------ --
		$tmpAR0=$this->AnalyerRequest('DFormtype','',0);
		$this->sFormtype=$tmpAR0[0];
		
		$tmpUiDescriptions=array();
		$tmpSTR=$this->sUiDescriptionPath.'User/nets/user_confirm.php';
		if(file_exists($tmpSTR)){
			require($tmpSTR);
			$tmpUiDescriptions=$sysUiDescriptions['user_confirm'];
		}
		$tmpTableApp=new netssystable($this->sConnString);
		$this->sUiDescription_Custom0=$tmpTableApp->filterColumnByFlag($tmpUiDescriptions,$this->sFormtype);
		
		
		return 0;
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);
		if ($pColumn['stcotName']=='uitEmail') {
			$pColumn['Value']=$this->sData_Userinfo[0]['uitEmail'];
			
		}else if ($pColumn['stcotName']=='uictCo_Mobile') {
			$pColumn['Value']=$this->sData_Userinfo[0]['uictCo_Mobile'];
			
		}else if ($pColumn['stcotName']=='uictPayBankCode') {
			$pColumn['Value']=$this->sData_Userinfo[0]['uictPayBankCode'];
		}else if ($pColumn['stcotName']=='uictPayBankName') {
			$pColumn['Value']=$this->sData_Userinfo[0]['uictPayBankName'];
		}else if ($pColumn['stcotName']=='uictPayBankUName') {
			$pColumn['Value']=$this->sData_Userinfo[0]['uictPayBankUName'];
		}else if ($pColumn['stcotName']=='uictPayBankAddress') {
			$pColumn['Value']=$this->sData_Userinfo[0]['uictPayBankAddress'];
			
		}else if ($pColumn['stcotName']=='uictChecked_Bank_Num') {
			if ($this->sData_Userinfo[0]['uictChecked_Bank']!=1) {
				$pColumn['stcoctUiType']='Non';
			}
			//$pColumn['Value']=$this->sData_Userinfo[0]['uictChecked_PayBank_Num'];
		
		}else if ($pColumn['stcotName']=='uictPayType') {
			$pColumn['Option']=$this->sPaytype1;
			$pColumn['Value']=$this->sData_Userinfo[0]['uictPayType'];
		}else if ($pColumn['stcotName']=='uictPayCode') {
			$pColumn['Value']=$this->sData_Userinfo[0]['uictPayCode'];
			
		}else if ($pColumn['stcotName']=='uictChecked_Pay_Num') {
			if ($this->sData_Userinfo[0]['uictChecked_Pay']!=1) {
				$pColumn['stcoctUiType']='Non';
			}
			//$pColumn['Value']=$this->sData_Userinfo[0]['uictChecked_Pay_Num'];
			
		}else if ($pColumn['stcotName']=='uictPostcode') {
			$pColumn['Value']=$this->sData_Userinfo[0]['uictPostcode'];
		}else if ($pColumn['stcotName']=='uictPostcodeSource') {
			$pColumn['Value']=$this->sData_Userinfo[0]['uictPostcodeSource'];
			
		}
		return 0;
	}
	
	
}
?>