<?php
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/shopsale.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/shopsalecont.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/shopsalediscuss.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/shopsalediscusscont.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Shop/Sale/shopsale.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Shop/Sale/shopsalediscuss.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Shop/Sale/shopsaleorder.php');

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

		//-- ------ #Options ------ --
		//Type_Question
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.sotID,A.sotName,A.sotValue,A.sotParid,A.sotIntroduct,A.sotSourceR00
			FROM '.$this->sysTableHead.'netssysoption AS A
			WHERE 1=1 AND A.sotRecycle=0 AND A.sotChecked>1 AND A.sotParid={Nets.Parid} AND 
			(A.sotValue LIKE \'10\' OR A.sotValue LIKE \'11\' OR A.sotValue LIKE \'12\' OR 
			A.sotValue LIKE \'13\' OR A.sotValue LIKE \'14\' OR A.sotValue LIKE \'15\')
			ORDER BY A.sotOrderBy DESC,A.sotID DESC ';
		$tmpAR0['InitialString']=132;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Salediscuss_type_question';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sType_Question1);
		$this->sType_Question2=$this->sType_Question1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='所有类型';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sType_Question2=array($tmpAR0);
		foreach ($this->sType_Question1 as $Row0){
			$this->sType_Question2[]=$Row0;
		}
		
		//-- ------ #ActionType ------ --
		if($this->sActionType=='DEvaluation_Discuss'){
			$this->OnEvaluation_Discuss();

		}
		//-- ------ #ActionTypeF ------ --
		if($this->sActionTypeF=='DAdd_B'){
			$this->OnAdd_B();
			$this->OnList();
		}else if($this->sActionTypeF=='DAdd_C'){
			$this->OnAdd_C();
			$this->OnList();
		}
		
		
	}
	public function OnAdd_B(){
		$tmpApp=new shopsalediscuss($this->sConnString);
		$tmpTable=array(
			array('sttTableName'=>$this->sysTableHead.'shopsalediscuss','sttColumnHead'=>'shsdt'),
			array('sttTableName'=>$this->sysTableHead.'shopsalediscusscont','sttColumnHead'=>'shsdct'),);
		
		$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('shsdtParentid_BTxt','',1);
		$tmpDbDescriptions[0]['Columns']['shsdtParentid']['Value']=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('shsdtType_BTxt','',1);
		$tmpDbDescriptions[0]['Columns']['shsdtType']['Value']=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('shsdctContent_BTxt','',1);
		$tmpDbDescriptions[1]['Columns']['shsdctContent']['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 OnAdd_C(){
		$tmpApp=new shopsalediscuss($this->sConnString);
		$tmpTable=array(
			array('sttTableName'=>$this->sysTableHead.'shopsalediscuss','sttColumnHead'=>'shsdt'),
			array('sttTableName'=>$this->sysTableHead.'shopsalediscusscont','sttColumnHead'=>'shsdct'),);
		
		$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_C';
		$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('shsdtParentid_CTxt','',1);
		$tmpDbDescriptions[0]['Columns']['shsdtParentid']['Value']=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('shsdctCode_Positive_CTxt','',1);
		$tmpDbDescriptions[1]['Columns']['shsdctCode_Positive']['Value']=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('shsdtType_CTxt','',1);
		$tmpDbDescriptions[0]['Columns']['shsdtType']['Value']=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('shsdctContent_CTxt','',1);
		$tmpDbDescriptions[1]['Columns']['shsdctContent']['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 OnEvaluation_Discuss(){
		$tmpApp=new shopsalediscuss($this->sConnString);
		$tmpAR0=$this->AnalyerRequest('DEvaluation_Discuss','0,0',0);
		$tmpEvaluation=0;
		
		$tmpINT=$tmpApp->onEvaluation($tmpAR0[0],$tmpAR0[1],$tmpEvaluation);
		if($tmpINT!=0){
			$this->sMessage=$tmpApp->sysLastError;
			$this->sJscript=$this->Message('ERROR','',$this->sMessage,'');
			return 1;
		}
		
		$this->sMessage='打分成功，谢谢您的打分。'.$this->sysSPLIT1.$tmpEvaluation;
		$this->sJscript=$this->Message('SUCCESS','',$this->sMessage,'');
		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}shopsale AS A 
			INNER JOIN {Nets.TableHead}shopsalecont AS B ON B.shsctIndexID=A.shstID
			WHERE 1=1 AND A.shstRecycle=0 AND A.shstChecked>1 AND A.shstID={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.shstID,A.shstName,A.shstParid,A.shstCreateTime
				FROM {Nets.TableHead}shopsale AS A 
				WHERE 1=1 AND A.shstRecycle=0 AND A.shstChecked>1
				ORDER BY A.shstOrderBy DESC,A.shstID 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]['shstID'];
		$this->sMetaTitle=$this->sDetailData[0]['shstName'];
		$this->sParid=$this->sDetailData[0]['shstParid'];
		
		//-- ------ #Group ------ --
		$tmpSQL=' SELECT A.shsgtID,A.shsgtName,B.shsgctTemplateid_Detail
			FROM {Nets.TableHead}shopsalegroup AS A
			INNER JOIN {Nets.TableHead}shopsalegroupcont AS B ON B.shsgctIndexID=A.shsgtID
			WHERE 1=1 AND A.shsgtRecycle=0 AND A.shsgtChecked>1 AND A.shsgtID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sParid,$tmpSTR);
		$this->sData_Group=$this->sDb->Search($tmpSTR);
		if(count($this->sData_Group)==0){
			//#Non group
			//#Other
			$this->sData_Group[0]=array(
				'shsgtID'=>0,
				'shsgtName'=>$this->sysFileConfig['bussinessName'],
				'shsgctTemplateid_Detail'=>0,
				);
		}
		//-- ------ #Template ------ --
		//#List
		$tmpSQL=' SELECT A.stemtID,A.stemtName,B.stemctPath 
			FROM {Nets.TableHead}netssystemplate AS A
			INNER JOIN {Nets.TableHead}netssystemplatecont AS B ON B.stemctIndexID=A.stemtID
			WHERE 1=1 AND A.stemtRecycle=0 AND A.stemtChecked>1 AND A.stemtID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sData_Group[0]['shsgctTemplateid_Detail'],$tmpSTR);
		$tmpData0=$this->sDb->Search($tmpSTR);
		if(count($tmpData0)!=0){
			$this->sTemplatePath=$tmpData0[0]['stemctPath'];
		}
		//#Detail
		$tmpSQL=' SELECT A.stemtID,A.stemtName,B.stemctPath 
			FROM {Nets.TableHead}netssystemplate AS A
			INNER JOIN {Nets.TableHead}netssystemplatecont AS B ON B.stemctIndexID=A.stemtID
			WHERE 1=1 AND A.stemtRecycle=0 AND A.stemtChecked>1 AND A.stemtID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sDetailData[0]['shsctTemplateid_Detail'],$tmpSTR);
		$tmpData0=$this->sDb->Search($tmpSTR);
		if(count($tmpData0)!=0){
			$this->sTemplatePath=$tmpData0[0]['stemctPath'];
		}
		//-- ------ #shstClassid ------ --
		$tmpSQL=' SELECT A.shstID,A.shstName,A.shstNameStyle
			FROM {Nets.TableHead}shopsale AS A
			WHERE 1=1 AND A.shstRecycle=0 AND A.shstChecked>1 AND 
			((A.shstClassid={Nets.Classid} AND A.shstClassid>0) OR (A.shstID={Nets.ID})) ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Classid}',$this->sDetailData[0]['shstClassid'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$this->sSale_Classids=$this->sDb->Search($tmpSTR);
		
		//-- ------ #shsctInventorys ------ --
		$this->sSale_Inventorysid=$this->sZoneid;
		$this->sSale_InventorysName=$this->sZoneName;
		$this->sSale_InventorysCount=$this->sDetailData[0]['shsctCount_Total'];
		$this->sSale_InventorysZones=array();
		$tmpAR0=explode($this->sysSPLIT5,$this->sDetailData[0]['shsctInventorys']);
		foreach($tmpAR0 as $Row0){
			$tmpAR1=explode($this->sysSPLIT2,$Row0);
			if(count($tmpAR1)==4){
				$this->sSale_InventorysZones[]=$tmpAR1;
				if ($this->sSale_Inventorysid==$tmpAR1[0]) {
					$this->sSale_Inventorysid=$tmpAR1[0];
					$this->sSale_InventorysName=$tmpAR1[1];
					$this->sSale_InventorysCount=$tmpAR1[2];
				}
			}
		}
		$this->sSale_InventorysZones[]=array(
			$this->sZoneid,
			$this->sZoneName,
			$this->sDetailData[0]['shsctCount_Total'],
			);
		//-- ------ #shsctAccessories ------ --
		$this->sSale_Accessories=array();
		$tmpAR0=explode($this->sysSPLIT5,$this->sDetailData[0]['shsctAccessories']);
		foreach($tmpAR0 as $Row0){
			$tmpAR1=explode($this->sysSPLIT2,$Row0);
			if(count($tmpAR1)==3){
				$this->sSale_Accessories[]=$tmpAR1;
			}
		}
		//-- ------ #shsctAccessoriesP ------ --
		$this->sSale_AccessoriesP=array();
		$tmpAR0=explode($this->sysSPLIT5,$this->sDetailData[0]['shsctAccessoriesP']);
		foreach($tmpAR0 as $Row0){
			$tmpAR1=explode($this->sysSPLIT2,$Row0);
			if(count($tmpAR1)==4){
				$this->sSale_AccessoriesP[]=$tmpAR1;
			}
		}
		//-- ------ #shsctPesents ------ --
		$this->sSale_Pesents=array();
		$tmpAR0=explode($this->sysSPLIT5,$this->sDetailData[0]['shsctPesents']);
		foreach($tmpAR0 as $Row0){
			$tmpAR1=explode($this->sysSPLIT2,$Row0);
			if(count($tmpAR1)==3){
				$this->sSale_Pesents[]=$tmpAR1;
			}
		}
		//-- ------ #Sets ------ --
		$this->sSale_Sets=array();
		//-- ### --
		$tmpSQL=' SELECT A.shssetID,A.shssetName,
			B.shssectSales,B.shssectSets
			FROM {Nets.TableHead}shopsaleset AS A
			INNER JOIN {Nets.TableHead}shopsalesetcont AS B ON B.shssectIndexID=A.shssetID
			WHERE 1=1 AND A.shssetRecycle=0 AND A.shssetChecked>1 AND 
			(B.shssectSales LIKE \'{Nets.ID};%\' OR B.shssectSales LIKE \'%|||{Nets.ID};%\')
			ORDER BY A.shssetOrderBy DESC,A.shssetID DESC LIMIT 0,6 ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$tmpData0=$this->sDb->Search($tmpSTR);
		$Coun0=0;
		foreach ($tmpData0 as $Row_Set){
			$this->sSale_Sets[$Coun0]['Set']=$Row_Set;
			$this->sSale_Sets[$Coun0]['Sales']=array();
			//-- ### --
			$tmpIDS_AR=array();
			$tmpSTR=$Row_Set['shssectSets'].' ';
			$tmpAR0=explode($this->sysSPLIT5,$tmpSTR);
			foreach ($tmpAR0 as $Row0){
				$tmpAR1=explode($this->sysSPLIT2,$Row0);
				if (count($tmpAR1)==4) {
					$tmpIDS_AR[]=$tmpAR1;
				}
			}
			//-- ### --
			$tmpIDS='';
			foreach ($tmpIDS_AR as $Row0){
				$tmpIDS.=' OR A.shstID='.$Row0[0];
			}
			$tmpSQL=' SELECT A.shstID,A.shstName,A.shstPrice,
				B.shsctSourceR00
				FROM {Nets.TableHead}shopsale AS A
				INNER JOIN {Nets.TableHead}shopsalecont AS B ON B.shsctIndexID=A.shstID
				WHERE 1=1 AND A.shstRecycle=0 AND A.shstChecked>1 AND (1=2 {Nets.IDS}) ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$tmpSTR=str_replace('{Nets.IDS}',$tmpIDS,$tmpSTR);
			$tmpData0=$this->sDb->Search($tmpSTR);
			$this->sSale_Sets[$Coun0]['Set']['Count_Info']=count($tmpData0);
			foreach ($tmpData0 as $Row0){
				foreach ($tmpIDS_AR as $Row1){
					if ($Row0['shstID']==$Row1[0]) {
						$this->sSale_Sets[$Coun0]['Sales'][]=array(
							'shstID'=>$Row0['shstID'],
							'shstName'=>$Row0['shstName'],
							'shstPrice'=>$Row1[2],
							'shstPriceOld'=>$Row0['shstPrice'],
							'shsctSourceR00'=>$Row0['shsctSourceR00'],
							);
					}
				}
			}
			
			$Coun0++;
		}
		//-- ------ #Evaluation ------ --
		//-- ------ #Navigation ------ --
		$this->sNavigation=$this->sDb->getParent($this->sDetailData[0]['shstParid'],$this->sysTableHead.'shopsalegroup','shsgt');
		//-- ------ #Other ------ --
		//Next
		$tmpSQL=' SELECT A.shstID,A.shstName,A.shstCreateTime
			FROM {Nets.TableHead}shopsale AS A 
			WHERE 1=1 AND A.shstRecycle=0 AND A.shstChecked>1 AND shstID>{Nets.ID} AND A.shstParid={Nets.Parid}
			ORDER BY A.shstOrderBy DESC,A.shstID DESC LIMIT 0,1 ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sDetailData[0]['shstID'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.Parid}',$this->sDetailData[0]['shstParid'],$tmpSTR);
		$this->sNextData=$this->sDb->Search($tmpSTR);
		//Previous
		$tmpSQL=' SELECT A.shstID,A.shstName,A.shstCreateTime
			FROM {Nets.TableHead}shopsale AS A 
			WHERE 1=1 AND A.shstRecycle=0 AND A.shstChecked>1 AND shstID<{Nets.ID} AND A.shstParid={Nets.Parid}
			ORDER BY A.shstOrderBy DESC,A.shstID DESC LIMIT 0,1 ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sDetailData[0]['shstID'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.Parid}',$this->sDetailData[0]['shstParid'],$tmpSTR);
		$this->sPreviousData=$this->sDb->Search($tmpSTR);
		//Other
		$tmpSQL=' SELECT A.shstID,A.shstName,A.shstCreateTime
			FROM {Nets.TableHead}shopsale AS A 
			WHERE 1=1 AND A.shstOrderBy=0 AND A.shstChecked>1 AND A.shstParid={Nets.Parid}
			ORDER BY A.shstOrderBy DESC,A.shstID DESC LIMIT 0,8 ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSTR);
		$tmpSTR=str_replace('{Nets.Parid}',$this->sDetailData[0]['shstParid'],$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.shsdtID,A.shsdtCreateTime,
			B.shsdctCode_Positive,B.shsdctPublisher_Name,B.shsdctContent
			FROM {Nets.TableHead}shopsalediscuss AS A
			INNER JOIN {Nets.TableHead}shopsalediscusscont AS B ON B.shsdctIndexID=A.shsdtID
			WHERE 1=1 AND A.shsdtRecycle=0 AND A.shsdtChecked>1 AND A.shsdtParentid=0 AND A.shsdtParid={Nets.ID} AND A.shsdtType>9 ';
		if ($tmpSearchAR0[0]!=-1) {
			$tmpSQL.=' AND A.shsdtType='.$tmpSearchAR0[0].' ';
		}
		$tmpSQL.=' ORDER BY A.shsdtOrderBy DESC,A.shsdtID ';
		$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_C ------ --
		$tmpSearchSTR0='DSearch_DiscussC';
		$tmpSearchAR0=$this->AnalyerRequest($tmpSearchSTR0,-1,0);
		$tmpListSTR0='DList_DiscussC';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,12,0',0);
		$tmpSortSTR0='DSort0';
		$tmpSortAR0=$this->AnalyerRequest($tmpSortSTR0,'cddtID,2',0);
		//Data
		$tmpSQL=' SELECT A.shsdtID,A.shsdtCreateTime,
			B.shsdctCode_Positive,B.shsdctPublisher_Name,B.shsdctContent,B.shsdctCode_BePositive,B.shsdctCode_BeNegative
			FROM {Nets.TableHead}shopsalediscuss AS A
			INNER JOIN {Nets.TableHead}shopsalediscusscont AS B ON B.shsdctIndexID=A.shsdtID
			WHERE 1=1 AND A.shsdtRecycle=0 AND A.shsdtChecked>1 AND A.shsdtParentid=0 AND A.shsdtParid={Nets.ID} AND A.shsdtType=0 ';
		if ($tmpSearchAR0[0]!=-1) {
			$tmpSQL.=' AND B.shsdctCode_Positive>='.$tmpSearchAR0[0].' ';
		}
		$tmpSQL.=' ORDER BY A.shsdtOrderBy DESC,A.shsdtID ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$this->sData_Discuss_C=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		$this->sCount_Discuss_C=$this->sDb->sysPageInfo[3];
		//#Set page button
		$this->sPButton_Ajax_C=new netsPAjaxButton();
		$this->sPButton_Ajax_C->resetTemlate('../../../Config/m_default/File/pageAjaxButton3.htm');
		$this->sPButton_Ajax_C->sFlag='discussBox_C';
		$this->sPButton_Ajax_C->sPanel='discussBox_C';
		$this->sPButton_Ajax_C->sPage=$this->sysPage;
		$this->sPButton_Ajax_C->sExtendParameter='&ID='.$this->sMainID.'&'.$tmpSearchSTR0.'='.$tmpSearchAR0[0];
		$this->sPButton_Ajax_C->setPage($this->sDb->sysPageInfo);
		//-- ------ #Discuss_B CODE ------ --
		$tmpGood=0;
		$tmpNormal=0;
		$tmpBad=0;
		$this->sDiscuss_B_Good=0;
		$this->sDiscuss_B_Normal=0;
		$this->sDiscuss_B_Bad=0;
		$this->sDiscuss_B_Total=0;
		$Coun0=0;
		foreach ($this->sData_Discuss_C as $Row0){
			if($Row0['shsdctCode_Positive']>=8){
				$tmpGood+=$Row0['shsdctCode_Positive'];
			}else if($Row0['shsdctCode_Positive']>=5){
				$tmpNormal+=$Row0['shsdctCode_Positive'];
			}else if($Row0['shsdctCode_Positive']>=0){
				$tmpBad+=$Row0['shsdctCode_Positive'];
			}
			$this->sDiscuss_B_Total+=$Row0['shsdctCode_Positive'];
			$Coun0++;
		}
		if($this->sDiscuss_B_Total==0){
			$this->sDiscuss_B_Total=1;
		}
		$this->sDiscuss_B_Good=$tmpGood/$this->sDiscuss_B_Total*100;
		$tmpAR0=explode('.',$this->sDiscuss_B_Good);
		$this->sDiscuss_B_Good=$tmpAR0[0];
		$this->sDiscuss_B_Normal=$tmpNormal/$this->sDiscuss_B_Total*100;
		$tmpAR0=explode('.',$this->sDiscuss_B_Normal);
		$this->sDiscuss_B_Normal=$tmpAR0[0];
		$this->sDiscuss_B_Bad=$tmpBad/$this->sDiscuss_B_Total*100;
		$tmpAR0=explode('.',$this->sDiscuss_B_Bad);
		$this->sDiscuss_B_Bad=$tmpAR0[0];
		
		//-- ------ #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();
		}
		
		
	}
	public function DefUiPanel(&$pColumn,$pFlag){
		if($pColumn['stcotName']=='shsdctContent_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']=='shsdtType_B' && $pFlag=='Normal'){
			$pColumn['Option']=$this->sType_Question1;
			
		}else if($pColumn['stcotName']=='shsdctContent_C' && $pFlag=='Normal'){
			$pColumn['ControlStyle']='width:500px;height:40px;';
			$pColumn['Parameter_JS_Onfocus']="tmpMCommon.OnDiscussInput(this.name,0);CCode_CTxt_ShowCACode(0);";
			
			
		}
	}
	
}


?>