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

class PaDefault extends CustomPage {
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='商品列表';
		$this->getUser('1,2,3,4,5,');
		$this->sTemplatePath='Shop/saleList_Normal.php';
		//-- ------ #Option ------ --
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.shsgtID,A.shsgtName,A.shsgtParid
			FROM '.$this->sysTableHead.'shopsalegroup AS A
			WHERE 1=1 AND A.shsgtRecycle=0 AND A.shsgtChecked>1 AND A.shsgtParid={Nets.Parid}
			ORDER BY A.shsgtOrderBy DESC,A.shsgtID DESC ';
		$tmpAR0['InitialString']=2;
		$tmpAR0['Parid']='shsgtID';
		$tmpAR0['Text']='shsgtName';
		$tmpAR0['Value']='shsgtID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_ShopsaleList_group';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sParid1);
		$this->sParid2=$this->sParid1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='所有分类';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sParid2,$tmpAR0);
		
		//Brand
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.shbtID,A.shbtName,A.shbtParid
			FROM '.$this->sysTableHead.'shopbrand AS A
			WHERE 1=1 AND A.shbtRecycle=0 AND A.shbtChecked>1 AND 
			(A.shbtParid=3 OR A.shbtParid=4)
			ORDER BY A.shbtOrderBy DESC,A.shbtID DESC ';
		$tmpAR0['InitialString']=2;
		$tmpAR0['Parid']='shbtID';
		$tmpAR0['Text']='shbtName';
		$tmpAR0['Value']='shbtID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_ShopsaleList_brand';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sBrand1);
		$this->sBrand2=$this->sBrand1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='所有品牌';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sBrand2,$tmpAR0);
		
		//PriceRang
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=50;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_PriceRang';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sPriceRang1);
		$this->sPriceRang2=$this->sPriceRang1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='所有价格';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sPriceRang2,$tmpAR0);
		
		
		//-- #sCondition_Order --
		$this->sCondition_Order=array('按价格','按销量','按上市时间',);
		//-- #sCondition_Listtype --
		$this->sCondition_Listtype=array('图片','列表','详细',);
		//-- #OnGetCompare --
		$this->OnGetCompare();
		
	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('ID',-1,0);
		$this->sMainID=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('DKeyword','',0);
		$this->sKeyword=$tmpAR0[0];
		$this->sSearchAR=$this->AnalyerRequest('DSearch','0,0,-1,-1',0);
		//-- ------ #This group ------ --
		$tmpSQL=' SELECT A.shsgtID,A.shsgtName,B.shsgctTemplateid_List 
			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->sMainID,$tmpSTR);
		$tmpData_Group=$this->sDb->Search($tmpSTR);
		if(count($tmpData_Group)==0){
			//Error
			$tmpData_Group=array(array(
				'shsgtID'=>0,
				'shsgtName'=>'所有商品类型',
				'shsgctTemplateid_List'=>0,
				),);
			//return 1;
		}
		$this->sMetaTitle=$tmpData_Group[0]['shsgtName'];
		//-- ------ #Template ------ --
		$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}',$tmpData_Group[0]['shsgctTemplateid_List'],$tmpSTR);
		$tmpData0=$this->sDb->Search($tmpSTR);
		if(count($tmpData0)!=0){
			$this->sTemplatePath=$tmpData0[0]['stemctPath'];
		}
		//-- ------ #Navigation ------ --
		$tmpChildidAR0=$this->sDb->getChild($this->sMainID,$this->sysTableHead.'shopsalegroup','shsgt');
		$this->sNavigation=$this->sDb->getParent($this->sMainID,$this->sysTableHead.'shopsalegroup','shsgt');
		//-- ------ #Datas ------ --
		$tmpListSTR0='DList0';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,30,0',0);
		$tmpSortSTR0='DSort0';
		$tmpSortAR0=$this->AnalyerRequest($tmpSortSTR0,'shstID,2',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.shstID,A.shstName,A.shstParid,A.shstNameStyle,A.shstPrice,A.shstCode,
			B.shsctPrice0,B.shsctSourceR00,B.shsctContent
			
			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 ';

		if ($this->sKeyword!='') {
			$tmpSQL.=' AND A.shstName LIKE \'%'.$this->sKeyword.'%\' ';
		}
		if ($this->sMainID!=-1) {
			$tmpSTR_0='';
			foreach ($tmpChildidAR0 as $Cell){
				$tmpSTR_0.=' OR A.shstParid='.$Cell.' ';
			}
			$tmpSQL.=' AND (1=2 '.$tmpSTR_0.') ';
		}
		
		$tmpSQL.=' ORDER BY A.shstOrderBy DESC,A.shstID DESC ';
		
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$this->sListData=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		$this->sRecordCount=$this->sDb->sysPageInfo[3];
		//#Set page button
		$this->sPButton->resetTemlate('../../../Config/m_default/File/pageButton3.htm');
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&ID='.$this->sMainID.'&DKeyword='.$this->sKeyword.'&DSearch='.$this->sSearchAR[0].$this->sysSPLIT1.$this->sSearchAR[1].$this->sysSPLIT1.$this->sSearchAR[2].$this->sysSPLIT1.$this->sSearchAR[3];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		
	}
	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;
	}
	public function getSearch($pValue,$pType){
/*
Parid
Keyword

ListType
OrderBy
Brand
PriceRang
*/
		$tmpAR0=array(
			$this->sMainID,
			$this->sKeyword,
			$this->sSearchAR[0],
			$this->sSearchAR[1],
			$this->sSearchAR[2],
			$this->sSearchAR[3],
			);
		if($pType==0) $tmpAR0[0]=$pValue;
		if($pType==1) $tmpAR0[1]=$pValue;
		if($pType==2) $tmpAR0[2]=$pValue;
		if($pType==3) $tmpAR0[3]=$pValue;
		if($pType==4) $tmpAR0[4]=$pValue;
		if($pType==5) $tmpAR0[5]=$pValue;

		//#SPICAL
		if ($pType==100) {
			/*
			$tmpAR0[8]=0;
			$tmpAR0[9]=0;
			$tmpAR0[10]=0;
			$tmpAR0[11]=0;
			$tmpAR0[12]=0;
			*/
		}else if ($pType==101) {
		}
		//#SPELL
		$tmpSTR=$this->sysPage.'?ID='.$tmpAR0[0].'&DKeyword='.$tmpAR0[1].'&DSearch='.
			$tmpAR0[2].$this->sysSPLIT1.$tmpAR0[3].$this->sysSPLIT1.$tmpAR0[4].$this->sysSPLIT1.$tmpAR0[5];
		return $tmpSTR;
	}
	
}
?>