<?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/codeList_Normal.php';
		
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.shcsgtID,A.shcsgtName,A.shcsgtParid 
			FROM '.$this->sysTableHead.'shopcodesalegroup AS A
			WHERE 1=1 AND A.shcsgtRecycle=0 AND A.shcsgtChecked>1 AND A.shcsgtParid={Nets.Parid}
			ORDER BY A.shcsgtOrderBy DESC,A.shcsgtID DESC ';
		$tmpAR0['SQL0']=' SELECT A.shcsgtID,A.shcsgtName,A.shcsgtParid 
			FROM '.$this->sysTableHead.'shopcodesalegroup AS A
			WHERE 1=1 AND A.shcsgtRecycle=0 AND A.shcsgtChecked>1 AND A.shcsgtID={Nets.Parid}
			ORDER BY A.shcsgtOrderBy DESC,A.shcsgtID DESC ';
		$tmpAR0['InitialString']=3;
		$tmpAR0['Parid']='shcsgtID';
		$tmpAR0['Text']='shcsgtName';
		$tmpAR0['Value']='shcsgtID';
		$tmpAR0['Type']=0;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$this->sParid1=$this->sParid2=$this->sControl->bindDropdown($tmpAR0);
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有分类]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sParid2,$tmpAR0);

	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('ID',1,0);
		$this->sMainID=$tmpAR0[0];
		//-- ------ #This group ------ --
		$tmpSQL=' SELECT A.shcsgtID,A.shcsgtName,B.shcsgCtTemplateid_List
			FROM {Nets.TableHead}shopcodesalegroup AS A 
			INNER JOIN {Nets.TableHead}shopcodesalegroupcont AS B ON B.shcsgctIndexID=A.shcsgtID
			WHERE 1=1 AND A.shcsgtRecycle=0 AND A.shcsgtChecked>1 AND A.shcsgtID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$tmpData_ThisGroup=$this->sDb->Search($tmpSTR);
		if(count($tmpData_ThisGroup)==0){
			//Error
			$tmpData_ThisGroup[0]=array(
				'shcsgtID'=>1,
				'shcsgtName'=>'所有积分商品',
				'shcsgCtTemplateid_List'=>0,
				);
		}
		$this->sMetaTitle=$tmpData_ThisGroup[0]['shcsgtName'];
		//-- ------ #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_ThisGroup[0]['shcsgCtTemplateid_List'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.ID}',0,$tmpSTR);
		$tmpData0=$this->sDb->Search($tmpSTR);
		if(count($tmpData0)!=0){
			$this->sTemplatePath=$tmpData0[0]['stemctPath'];
		}
		//-- ------ #Navigation ------ --
		$tmpChildidAR0=$this->sDb->getChild($tmpData_ThisGroup[0]['shcsgtID'],$this->sysTableHead.'shopcodesalegroup','shcsgt');
		$this->sNavigation=$this->sDb->getParent($tmpData_ThisGroup[0]['shcsgtID'],$this->sysTableHead.'shopcodesalegroup','shcsgt');
		//-- ------ #Datas ------ --
		$tmpListSTR0='DList0';
		$tmpListAR0=$this->getQueryString($tmpListSTR0);
		$tmpSortSTR0='DSort0';
		$tmpSortAR0=$this->AnalyerRequest($tmpSortSTR0,'shcstID,2',0);
		//Keyword,Type,OrderBy
		$tmpSearchSTR='DSearch';
		$this->sSearchAR=$this->AnalyerRequest($tmpSearchSTR,',0,ID',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.shcstID,A.shcstName,A.shcstParid,A.shcstCreateTime,A.shcstPrice,A.shcstCount,
			B.shcsctContent,B.shcsctSourceR00
			FROM {Nets.TableHead}shopcodesale AS A
			INNER JOIN {Nets.TableHead}shopcodesalecont AS B ON B.shcsctIndexID=A.shcstID
			WHERE 1=1 AND A.shcstRecycle=0 AND A.shcstChecked>1 AND (1=2 {Nets.Parids}) ';
		//#Condition
		if($this->sSearchAR[0]!=''){
			$tmpSQL.=' AND A.shcstName LIKE \'%'.$this->sSearchAR[0].'%\' ';
		}
		//#Order
		if($this->sSearchAR[2]=='ID'){
			$tmpSQL.=' ORDER BY A.shcstOrderBy DESC,A.shcstID DESC ';

		}else {
			$tmpSQL.=' ORDER BY A.shcstOrderBy DESC,A.shcstID DESC ';
		}
		
		$tmpSTR_0='';
		foreach ($tmpChildidAR0 as $Cell){
			$tmpSTR_0.=' OR A.shcstParid='.$Cell.' ';
		}
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Parids}',$tmpSTR_0,$tmpSTR);
		$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.'&'.$tmpSearchSTR.'='.$this->sSearchAR[0].$this->sysSPLIT1.$this->sSearchAR[1].$this->sysSPLIT1.$this->sSearchAR[2];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		
	}
	public function getSearch($pValue,$pType){
		$tmpAR0=array(
			$this->sMainID,
			$this->sSearchAR[0],
			$this->sSearchAR[1],
			$this->sSearchAR[2],
			);
		if($pType==0) $tmpAR0[0]=$pValue;
		if($pType==1) $tmpAR0[1]=$pValue;
		if($pType==2) $tmpAR0[2]=$pValue;
		if($pType==3) $tmpAR0[3]=$pValue;

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

?>