<?php

class PaDefault extends CustomPage {
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='商品对比';
		$this->getUser('1,2,3,4,5,');
		
		//-- ------ #ActionType ------ --
		if ($this->sActionType=='DCompare') {
			$this->OnCompare();
			$this->OnList();
		}
	}
	public function OnCompare(){
		//-- #ID,Operation(0.Add,1.Sub) --
		$tmpDCompare=$this->AnalyerRequest('DCompare','0,0',0);
		$tmpAR0=$this->AnalyerRequest($this->sysCookieHead.'CompareIDS','',2);
		$tmpAR0=explode($this->sysSPLIT2,$tmpAR0[0]);
		//-- ### --
		if ($this->sCode->Int32($tmpDCompare[0],0)<=0) {
			$this->sMessage='对比参数格式不正确,1';
			return 1;
		}
		//-- ### --
		$tmpCompareSTR='';
		$tmpFlag=0;
		foreach ($tmpAR0 as $Row0) {
			if ($tmpDCompare[0]==$Row0) {
				if ($tmpDCompare[1]==0) {
					$tmpCompareSTR.=$Row0.$this->sysSPLIT2;
				}else if ($tmpDCompare[1]==1) {
				}
				$tmpFlag=1;
			}else if ($Row0=='') {
			}else {
				$tmpCompareSTR.=$Row0.$this->sysSPLIT2;
			}
		}
		if ($tmpFlag==0) {
			if ($tmpDCompare[1]==0) {
				$tmpCompareSTR.=$tmpDCompare[0].$this->sysSPLIT2;
			}
		}
		//-- #Write cookie --
		$this->writeCookie($this->sysNormalCookiePath,$this->sysCookieHead.'CompareIDS',$tmpCompareSTR);
		
		$this->sMessage='您的所要对比的商品已加入到您的对比列表里了,0';
		//-- ------ #Datas ------ --
		$tmpAR0=explode($this->sysSPLIT2,$tmpCompareSTR);
		
		$tmpListSTR0='DList_Compare';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,6,0',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.shstID,A.shstName,A.shstNameStyle,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})
			ORDER BY A.shstOrderBy DESC,A.shstID DESC ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR_0='';
		foreach ($tmpAR0 as $Row0) {
			$tmpSTR_0.=' OR A.shstID='.$this->sCode->Int32($Row0,0);
		}
		$tmpSTR=str_replace('{Nets.IDS}',$tmpSTR_0,$tmpSTR);
		$this->sData_Comparelist=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		//#Set page button
		$this->sPAjaxButton->resetTemlate('../../../Config/m_default/File/pageButton3.htm');
		$this->sPAjaxButton->sPage=$this->sysPage;
		$this->sPAjaxButton->setPage($this->sDb->sysPageInfo);
		
		return 0;
	}
	public function OnList(){
		//-- ------ #LIST ------ --
		$tmpAR0=$this->AnalyerRequest($this->sysCookieHead.'CompareIDS','',2);
		$tmpAR0=explode($this->sysSPLIT2,$tmpAR0[0]);
		//-- ------ #Datas ------ --
		$tmpListSTR0='DList_Compare';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,6,0',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.shstID,A.shstName,A.shstNameStyle,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})
			ORDER BY A.shstOrderBy DESC,A.shstID DESC ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR_0='';
		foreach ($tmpAR0 as $Row0) {
			$tmpSTR_0.=' OR A.shstID='.$this->sCode->Int32($Row0,0);
		}
		$tmpSTR=str_replace('{Nets.IDS}',$tmpSTR_0,$tmpSTR);
		$this->sData_List=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		//#Set page button
		$this->sPAjaxButton->resetTemlate('../../../Config/m_default/File/pageButton3.htm');
		$this->sPAjaxButton->sPage=$this->sysPage;
		$this->sPAjaxButton->setPage($this->sDb->sysPageInfo);
		//-- #OnGetCompare --
		$this->OnGetCompare();
		
		return 0;
	}
	public function OnGetCompare(){
		$tmpAR0=$this->AnalyerRequest($this->sysCookieHead.'CompareIDS','',2);
		$tmpAR0=explode($this->sysSPLIT2,$tmpAR0[0]);
		//-- ------ #Datas ------ --
		$tmpListSTR0='DList_Compare';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,6,0',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.shstID,A.shstName,A.shstNameStyle,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})
			ORDER BY A.shstOrderBy DESC,A.shstID DESC ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR_0='';
		foreach ($tmpAR0 as $Row0) {
			$tmpSTR_0.=' OR A.shstID='.$this->sCode->Int32($Row0,0);
		}
		$tmpSTR=str_replace('{Nets.IDS}',$tmpSTR_0,$tmpSTR);
		$this->sData_Comparelist=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		//#Set page button
		$this->sPAjaxButton->resetTemlate('../../../Config/m_default/File/pageButton3.htm');
		$this->sPAjaxButton->sPage=$this->sysPage;
		$this->sPAjaxButton->setPage($this->sDb->sysPageInfo);
		
		return 0;
	}
	
}

?>