<?php
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/shopsaleorder.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/shopsaleordercont.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/shopsaleorderdiscuss.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/shopsaleorderdiscusscont.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Shop/Sale/shopsaleorder.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Shop/Sale/shopsaleorderdiscuss.php');


class PaDefault extends CustomPage {
	public $ssetParid=2;
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='订单详细信息';
		$this->getUser('1,2,3,4,5,');
		$this->sApp=new shopsaleorder($this->sConnString);
		$this->sTemplatePath='shop/orderDetail_Normal.php';

		//-- ------ #Option ------ --
		//State
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=110;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/option_Shoporder_state';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sState1);
		$this->sState2=$this->sState1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有状态]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sState2,$tmpAR0);
		
		//-- ------ #ActionType ------ --


	}
	public function OnAdd(){
		$tmpApp=new shopsaleorderdiscuss($this->sConnString);
		$tmpTable=array(
			array('sttTableName'=>$this->sysTableHead.'shopsaleorderdiscuss','sttColumnHead'=>'shsodt'),
			array('sttTableName'=>$this->sysTableHead.'shopsaleorderdiscusscont','sttColumnHead'=>'shsodct'),);
		
		$tmpDbDescriptions=array();
		foreach ($tmpTable as $tableCell){
			$tmpDbDescriptions[]=$this->sDbDescriptions[$tableCell['sttTableName']];
		}
		$tmpMainid=$this->AnalyerRequest('mainID',0,1);
		$this->sMainID=$tmpMainid[0];
		$tmpMainUserid=$this->AnalyerRequest('mainUserid',0,1);
		$this->sMainUserid=$tmpMainid[0];
		$tmpMainTableid=$this->AnalyerRequest('mainTableid',0,1);
		$this->sMainTableid=$tmpMainid[0];
		//-- ------ #Submit limit check ------ --
		$tmpINT=$this->submitLimitRead($this->sysPage,-1,-1,-1);
		if($tmpINT!=0){
			$this->sJscript=$this->Message('SUCCESS','','对不起，您登陆次数过多，请'.$this->sysFileConfig['SubmitLimitFreeze'].'秒后再尝试登陆。','');
			return 1;
		}
		//-- ------ #CCode ------ --
		$tmpSTR='CCode_B';
		$tmpAR0=$this->AnalyerRequest($tmpSTR.'Txt','',1);
		$tmpCCode=$tmpAR0[0];
		$tmpSTR=$tmpSTR.'Txt_IFrame';
		if(!array_key_exists($tmpSTR,$_SESSION)){
			$this->submitLimitWrite($this->sysPage,-1,-1,-1);
			$this->sJscript=$this->Message('ERROR','提交失败','验证码错误','');
			return 1;
		}
		if($_SESSION[$tmpSTR]=='' || $_SESSION[$tmpSTR]!=$tmpCCode){
			$this->submitLimitWrite($this->sysPage,-1,-1,-1);
			$this->sJscript=$this->Message('ERROR','提交失败','验证码错误','');
			return 1;
		}
		//-- ------ #Add ------ --
		$tmpApp->TransStart();
		//#Get numCode
		$tmpSTR=$tmpTable[0]['sttColumnHead'].'NumCode';
		$tmpDbDescriptions[0]['TableDescription']['SearchColumn']=$tmpSTR;
		$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']='N'.$this->sysSPLIT11.date('YmdHis');
		$tmpApp->numCode($tmpDbDescriptions[0]);
		//#Set value
		$tmpAR0=$this->AnalyerRequest('mainID','',1);
		$tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'Parid']['Value']=$this->sCode->Int32($tmpAR0[0],0);
		$tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'CreateBy']['Value']=$this->sCode->Int32($this->sUserInfo[0]['Columns']['uitID']['Value'],0);
		
		$tmpAR0=$this->AnalyerRequest('shsodtParentid_BTxt','',1);
		$tmpDbDescriptions[0]['Columns']['shsodtParentid']['Value']=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('shsodtType_BTxt','',1);
		$tmpDbDescriptions[0]['Columns']['shsodtType']['Value']=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('shsodctContent_BTxt','',1);
		$tmpDbDescriptions[1]['Columns']['shsodctContent']['Value']=$tmpAR0[0];

		//-- #Set conventional --
		if(isset($tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'CreateBy']['Value'])){
			$tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'CreateBy']['Value']=$tmpMainUserid[0];
		}
		if(isset($tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'CreateTime'])){
			$tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'CreateTime']['Value']=date($this->sysTimeFormat);
		}
		//DB name,Condition,User index,User column name
		$tmpFlag=0;
		foreach ($this->AnonymousUserData as $Row0){
			if (count($tmpDbDescriptions)>1) {
				if(isset($tmpDbDescriptions[1]['Columns'][$tmpTable[1]['sttColumnHead'].$Row0[0]])){
					$tmpFlag=1;
				}
			}
			if ($this->sUserInfo[0]['Columns']['uitID']['Value']==0 && $tmpFlag==1) {
				$tmpDbDescriptions[1]['Columns'][$tmpTable[1]['sttColumnHead'].$Row0[0]]['Value']=$Row0[4];
			}else if ($tmpFlag==1) {
				$tmpDbDescriptions[1]['Columns'][$tmpTable[1]['sttColumnHead'].$Row0[0]]['Value']=$this->sUserInfo[$Row0[2]]['Columns'][$Row0[3]]['Value'];
			}
		}
		//Spical value array
		foreach ($this->sSpicalValue as $Cell){
			if(isset($tmpDbDescription[$Cell[0]]['Columns'][$Cell[1]]['Value'])){
				$tmpDbDescription[$Cell[0]]['Columns'][$Cell[1]]['Value']=$Cell[2];
			}
		}
		//-- #Set spical --
		$tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'Name']['Value']=$this->sCode->SubString($tmpDbDescriptions[1]['Columns'][$tmpTable[1]['sttColumnHead'].'Content']['Value'],0,60);
		$tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'CreateTime']['Value']=date($this->sysTimeFormat);
		$tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'Checked']['Value']=$this->sysFileConfig['CheckCmsDocDiscuss'];
		if ($tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'CreateBy']['Value']==0) {
			$tmpDbDescriptions[0]['Columns'][$tmpTable[0]['sttColumnHead'].'CreateBy']['Value']=2;
		}
		//#Add
		$tmpDbDescriptions[1]['Columns'][$tmpTable[1]['sttColumnHead'].'Content']['Value']=$this->sCode->FilterINPUT($tmpDbDescriptions[1]['Columns'][$tmpTable[1]['sttColumnHead'].'Content']['Value'],3);
		$tmpINT=$tmpApp->Check($tmpDbDescriptions,array(),array());
		if($tmpINT!=0){
			$tmpApp->TransRollback();
			$this->sJscript=$this->Message('ERROR','',$tmpApp->sysLastError,'');
			return 1;
		}
		$Coun0=0;
		while (count($tmpDbDescriptions)>$Coun0){
			if($Coun0==0){
				$tmpDbDescriptions[$Coun0]['TableDescription']['SearchColumn']=$tmpTable[$Coun0]['sttColumnHead'].'NumCode,'.$tmpTable[$Coun0]['sttColumnHead'].'ID';
			}else {
				$tmpDbDescriptions[$Coun0]['TableDescription']['SearchColumn']=$tmpTable[$Coun0]['sttColumnHead'].'IndexID';
			}
			$Coun0++;
		}
		$tmpINT=$tmpApp->add($tmpDbDescriptions);
		if($tmpINT!=0){
			$tmpApp->TransRollback();
			$this->sJscript=$this->Message('ERROR','',$tmpApp->sysLastError,'');
			return 1;
		}
		
		$this->submitLimitWrite($this->sysPage,-1,-1,-1);
		$tmpApp->TransCommit();
		$this->sJscript=$this->Message('SUCCESS','','评论成功',$this->sysPage.'?ID='.$this->sMainID);
		/*
		$this->sJscript=$this->Message_Frame('A,0',
			$this->sysFileConfig['sysCoreRoot'].$this->sysFileConfig['PathManaFrameMessage'],
			$this->sCode->URL_MakeParameter('添加成功',0),
			$this->sCode->URL_MakeParameter($this->sApp->sysLastError,0),
			$this->sCode->URL_MakeParameter($this->sysFileConfig['sysCoreRoot'].'Mana/m_cms/doc/doc.php',0));
		*/
		return 0;
	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('ID',1,0);
		$this->sMainID=$tmpAR0[0];
		//-- ------ #Initial ------ --
		//$tmpINT=$this->sApp->initialObject($this->sMainID);
		//-- ------ #Datas ------ --
		$tmpSQL=' SELECT *
			FROM {Nets.TableHead}shopsaleorder AS A 
			INNER JOIN {Nets.TableHead}shopsaleordercont AS B ON B.shsoctIndexID=A.shsotID

			WHERE 1=1 AND A.shsotID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$this->sDetailData=$this->sDb->Search($tmpSTR);
		if(count($this->sDetailData)==0){
			//#Error
			//#Other
			$tmpSQL=' SELECT A.shsotID,A.shsotName,A.shsotCreateTime
				FROM {Nets.TableHead}shopsaleorder AS A 
				WHERE 1=1 
				ORDER BY A.shsotID DESC LIMIT 0,8 ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$this->sOtherData=$this->sDb->Search($tmpSTR);
			return 1;
		}
		$this->sMainID=$this->sDetailData[0]['shsotID'];
		$this->sMetaTitle=$this->sDetailData[0]['shsotName'];
		
		//-- ------ #Evaluation ------ --
		//-- ------ #Other ------ --
		//Next
		$tmpSQL=' SELECT A.shsotID,A.shsotName,A.shsotCreateTime
			FROM {Nets.TableHead}shopsaleorder AS A 
			WHERE 1=1 AND shsotID>{Nets.ID} 
			ORDER BY A.shsotID DESC LIMIT 0,1 ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sDetailData[0]['shsotID'],$tmpSTR);
		$this->sNextData=$this->sDb->Search($tmpSTR);
		//Previous
		$tmpSQL=' SELECT A.shsotID,A.shsotName,A.shsotCreateTime
			FROM {Nets.TableHead}shopsaleorder AS A 
			WHERE 1=1 AND shsotID<{Nets.ID} 
			ORDER BY A.shsotID DESC LIMIT 0,1 ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sDetailData[0]['shsotID'],$tmpSTR);
		$this->sPreviousData=$this->sDb->Search($tmpSTR);
		//Other
		$tmpSQL=' SELECT A.shsotID,A.shsotName,A.shsotCreateTime
			FROM {Nets.TableHead}shopsaleorder AS A 
			WHERE 1=1 
			ORDER BYA.shsotID DESC LIMIT 0,8 ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSTR);
		$this->sOtherData=$this->sDb->Search($tmpSTR);
		//-- ------ #Discuss_B ------ --
		$tmpSearchSTR0='DSearch_DiscussB';
		$tmpSearchAR0=$this->AnalyerRequest($tmpSearchSTR0,-1,0);
		$tmpListSTR0='DList_DiscussA';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,12,0',0);
		$tmpSortSTR0='DSort0';
		$tmpSortAR0=$this->AnalyerRequest($tmpSortSTR0,'cddtID,2',0);
		//Data
		$tmpSQL=' SELECT A.shsodtID,A.shsodtCreateTime,
			B.shsodctCode_Positive,B.shsodctPublisher_Name,B.shsodctContent
			FROM {Nets.TableHead}shopsaleorderdiscuss AS A
			INNER JOIN {Nets.TableHead}shopsaleorderdiscusscont AS B ON B.shsodctIndexID=A.shsodtID
			WHERE 1=1 AND A.shsodtRecycle=0 AND A.shsodtChecked>1 AND A.shsodtParid={Nets.ID} ';
		if ($tmpSearchAR0[0]!=-1) {
			$tmpSQL.=' AND A.shsodtType='.$tmpSearchAR0[0].' ';
		}
		$tmpSQL.=' ORDER BY A.shsodtOrderBy DESC,A.shsodtID ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$this->sData_Discuss_B=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		$this->sCount_Discuss_B=$this->sDb->sysPageInfo[3];
		//#Set page button
		$this->sPButton_Ajax_B=new netsPAjaxButton();
		$this->sPButton_Ajax_B->resetTemlate('../../../Config/m_default/File/pageAjaxButton3.htm');
		$this->sPButton_Ajax_B->sFlag='discussBox_B';
		$this->sPButton_Ajax_B->sPanel='discussBox_B';
		$this->sPButton_Ajax_B->sPage=$this->sysPage;
		$this->sPButton_Ajax_B->sExtendParameter='&ID='.$this->sMainID.'&'.$tmpSearchSTR0.'='.$tmpSearchAR0[0];
		$this->sPButton_Ajax_B->setPage($this->sDb->sysPageInfo);
		
		//-- ------ #Discuss form ------ --
		$this->sUiDescription_0=array();
		$tmpSTR=$this->sUiDescriptionPath.'Plus/shop/sale_discuss.php';
		if(file_exists($tmpSTR)){
			require($tmpSTR);
			$this->sUiDescription_0=$sysUiDescriptions['sale_discuss'];
			$sysUiDescriptions=array();
		}
		//-- ------ ### ------ --
		$this->sURL_Cache=$this->sysFileConfig['PathRoot'].$this->sysFileConfig['sysDbFlagPath'].'Shop/auction_bid_'.$this->sMainID.'.php';
		
		
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		if($pColumn['stcotName']=='shsodctContent_B' && $pFlag=='Normal'){
			$pColumn['ControlStyle']='width:500px;height:40px;';
			$pColumn['Parameter_JS_Onfocus']="tmpMCommon.OnDiscussInput(this.name,0);CCode_BTxt_ShowCACode(0);";
		}else if($pColumn['stcotName']=='shsodtType_B' && $pFlag=='Normal'){
			$pColumn['Option']=$this->sType_Question1;
			
		}else if($pColumn['stcotName']=='shsodctContent_C' && $pFlag=='Normal'){
			$pColumn['ControlStyle']='width:500px;height:40px;';
			$pColumn['Parameter_JS_Onfocus']="tmpMCommon.OnDiscussInput(this.name,0);CCode_CTxt_ShowCACode(0);";
			
			
		}
	}
	
}


?>