<?php
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsSocket.php');
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsEmail.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/netsuserunit.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/netsuserunitcont.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Nets/User/netsuserunit.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,');
	}
	public function OnBInitial(){
		$this->sMetaTitle='企业认证';
		$this->sApp=new netsuserunit($this->sConnString);
		$this->sDescription_local[0]=$this->sDbDescriptions[$this->sysTableHead.'netsuserunit'];
		$this->sDescription_local[1]=$this->sDbDescriptions[$this->sysTableHead.'netsuserunitcont'];
		//-- ------ #Action ------ --
		if($this->sActionTypeF=='DConfirmEmail' || $this->sActionTypeF=='DConfirmMobile' || 
			$this->sActionTypeF=='DConfirmBank' || $this->sActionTypeF=='DConfirmPostcode'){
			$this->OnDConfirm($this->sActionTypeF);
		}elseif($this->sActionTypeF=='DConfirmBank_callback'){
			$this->OnDConfirmPayBank_callback();
		}
		if($this->sActionType=='ConfirmEmail' || $this->sActionType=='ConfirmMobile' || 
			$this->sActionType=='ConfirmBank' || $this->sActionType=='ConfirmPostcode'){
		}
		$this->OnConfirm($this->sActionType);
		
		
		
	}
	
	public function OnDConfirm($pType){
		//-- ------ # ------ --
		$tmpMessage='';
		$tmpType='';
		//uitID
		$this->sDescription_local[0]['Columns']['uutCreateBy']['Value']=
			$this->sUserInfo[0]['Columns']['uitID']['Value'];
		if($pType=='DConfirmEmail'){
			$tmpMessage='电子邮箱认证提交成功，请到填写的邮箱里查收认证邮件。';
			$tmpType='uuctEmailChecked';
			//uuctComContactEmail
			$tmpAR0=array('uuctComContactEmail',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$this->sDescription_local[1]['Columns'][$Cell]['Value']=$tmpAR1[0];
			}
		}else if($pType=='DConfirmMobile'){
			$tmpMessage='联系方式认证提交成功，请等待管理员审核。';
			$tmpType='uuctComContactTeleChecked';
			//uictCoMobile
			$tmpAR0=array('uuctComContact','uuctComContactTele',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$this->sDescription_local[1]['Columns'][$Cell]['Value']=$tmpAR1[0];
			}
		}else if($pType=='DConfirmBank'){
			$tmpMessage='银行帐号认证提交成功，请等待管理员审核。';
			$tmpType='uuctPayBankChecked';
			//uictPayBank
			$tmpAR0=array('uuctPayBankCode','uuctPayBankName','uuctPayBankUName','uuctPayBankAddress',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$this->sDescription_local[1]['Columns'][$Cell]['Value']=$tmpAR1[0];
			}
		}else if($pType=='DConfirmPostcode'){
			$tmpMessage='营业执照认证提交成功，请等待管理员审核。';
			$tmpType='uuctComIdCodeChecked';
			//uictPostcode
			$tmpAR0=array('uuctComName','uuctComIdCode','uuctComIdCodeSource',);
			foreach ($tmpAR0 as $Cell){
				$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
				$this->sDescription_local[1]['Columns'][$Cell]['Value']=$tmpAR1[0];
			}
		}
		//-- ------ # ------ --
		$tmpINT=$this->sApp->setConfirm($this->sDescription_local,$tmpType,$this->sysPage);
		if($tmpINT!=0){
			$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastError,'');
			return 1;
		}
		if($pType=='DConfirmEmail'){
			$tmpMessageEmail=new oamessageemail($this->sConnString);
			$tmpSTR='用户电子邮箱认证邮件 - '.$this->sysFileConfig['bussinessMetaTitle'];
			$this->sApp->sysLastMessage=str_replace('{Nets.Page}','../../../Plus/Common/c_callback/s_email_confirm.php',$this->sApp->sysLastMessage);
			$tmpINT=$tmpMessageEmail->sendmessage($this->sDescription_local[1]['Columns']['uuctComContactEmail']['Value'],$tmpSTR,$this->sApp->sysLastMessage);
			if($tmpINT!=0){
				$this->sJscript=$this->Message('SUCCESS','','发送企业电子邮箱认证邮件错误。','');
				return 1;
			}
		}
		
		$tmpApp=new netsuserinfo($this->sConnString);
		$this->sUserInfo[0]['Columns']['uitTypeid']['Value']='1,2,3,4,5,';
		$tmpINT=$tmpApp->Relogin($this->sUserInfo);
		$this->sJscript=$this->Message('ERROR','',$tmpMessage,'');
		return 0;
	}
	public function OnDConfirmPayBank_callback(){
		//uitID
		$this->sDescription_local[0]['Columns']['uutCreateBy']['Value']=
			$this->sUserInfo[0]['Columns']['uitID']['Value'];
		//uictPayBankChecked
		$tmpAR0=array('uuctPayBankCheckedNum',);
		foreach ($tmpAR0 as $Cell){
			$tmpAR1=$this->AnalyerRequest($Cell.'Txt','',1);
			$this->sDescription_local[1]['Columns'][$Cell]['Value']=$tmpAR1[0];
		}
		//-- ------ # ------ --
		$tmpINT=$this->sApp->setConfirm($this->sDescription_local,'uuctPayBankChecked_callback',$this->sysPage);
		if($tmpINT!=0){
			$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastError,'');
			return 1;
		}
		
		$this->sJscript=$this->Message('SUCCESS','','银行帐号认证成功。','');
		return 0;
	}
	
	public function OnConfirm($pType){
		//State array
		$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']='';
		$this->sConfirmStateAR=$this->sControl->bindDropdown($tmpAR0);
		//
		$this->sDescription_local[0]['Columns']['uutCreateBy']['Value']=$this->sUserInfo[0]['Columns']['uitID']['Value'];
		$this->sMainData0=array();
		$tmpINT=$this->sApp->getConfirm($this->sDescription_local,$this->sMainData0);
		//Define UiDescription
		$tmpAR0=array();
		if($pType=='ConfirmEmail'){
			$tmpAR0[]=array('uuctComContactEmail','电子邮箱','Text',$this->sMainData0[0]['uuctComContactEmail'],'',);
		}else if($pType=='ConfirmMobile'){
			$tmpAR0[]=array('uuctComContact','联系人','Text',$this->sMainData0[0]['uuctComContact'],'',);
			$tmpAR0[]=array('uuctComContactTele','联系电话','Text',$this->sMainData0[0]['uuctComContactTele'],'',);
		}else if($pType=='ConfirmBank'){
			$tmpAR0[]=array('uuctPayBankCode','银行帐号','Text',$this->sMainData0[0]['uuctPayBankCode'],'',);
			$tmpAR0[]=array('uuctPayBankName','银行名称','Text',$this->sMainData0[0]['uuctPayBankName'],'',);
			$tmpAR0[]=array('uuctPayBankUName','开户人','Text',$this->sMainData0[0]['uuctPayBankUName'],'',);
			$tmpAR0[]=array('uuctPayBankAddress','开户行所在地','Text',$this->sMainData0[0]['uuctPayBankAddress'],'',);
			if($this->sMainData0[0]['uuctPayBankChecked']==1){
				$tmpAR0[]=array('uuctPayBankCheckedNum','请输入打款金额','Text','','',);
			}
		}else if($pType=='ConfirmPostcode'){
			$tmpAR0[]=array('uuctComName','企业名称','Text',$this->sMainData0[0]['uuctComName'],'',);
			$tmpAR0[]=array('uuctComIdCode','营业证号','Text',$this->sMainData0[0]['uuctComIdCode'],'',);
			$tmpAR0[]=array('uuctComIdCodeSource','营业证照截图','Source',$this->sMainData0[0]['uuctComIdCodeSource'],'../../../Uploadfiles/User/Postcode/',);
		}
		
		$Coun0=0;
		$this->sUiDescription_Normal=array();
		foreach ($tmpAR0 as $Cell){
			$this->sUiDescription_Normal[$Coun0]=$this->sysUiDescriptionModel;
			$this->sUiDescription_Normal[$Coun0]['stcotName']=$Cell[0];
			$this->sUiDescription_Normal[$Coun0]['stcoctUiName']=$Cell[1];
			$this->sUiDescription_Normal[$Coun0]['stcoctUiType']=$Cell[2];
			$this->sUiDescription_Normal[$Coun0]['Value']=$Cell[3];
			$this->sUiDescription_Normal[$Coun0]['Parameter']=$Cell[4];
			$Coun0++;
		}
	}
}
?>