<?php

class PaDefault extends CustomPage {
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='团购地图';
		$this->getUser('1,2,3,4,5,');
		$this->sTemplatePath='Gsnavigation/gsnavigationMap.php';
		//-- #Share link --
		$this->sData_LinkShare=array();
		$tmpCacheFlag='nets/options_LinkShare_Groupsale';
		$tmpAR_Cache=$this->sDb->readCache($tmpCacheFlag);
		if(count($tmpAR_Cache)==0){
			$tmpParid=20;
			$tmpSQL=' SELECT A.cltID,A.cltName,A.cltURL,A.cltTarget,B.clctSourceR00
				FROM {Nets.TableHead}cmslink AS A
				INNER JOIN {Nets.TableHead}cmslinkcont AS B ON B.clctIndexID=A.cltID
				WHERE 1=1 AND A.cltRecycle=0 AND A.cltChecked>1 AND A.cltParid={Nets.Parid}
				ORDER BY A.cltOrderBy DESC,A.cltID DESC ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$tmpSTR=str_replace('{Nets.Parid}',$tmpParid,$tmpSTR);
			$this->sData_LinkShare=$this->sDb->Search($tmpSTR);
			
			if($this->sysFileConfig['CacheDbAble']==1){
				$this->sDb->writeCache($tmpCacheFlag,$this->sData_LinkShare);
			}
		}else {
			$this->sData_LinkShare=$tmpAR_Cache;
		}
		//-- ------ #Option ------ --
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.gsnagtID,A.gsnagtName,A.gsnagtParid FROM '.$this->sysTableHead.'gsnavigationactivegroup AS A
			WHERE 1=1 AND A.gsnagtRecycle=0 AND A.gsnagtChecked>1 AND A.gsnagtParid={Nets.Parid}
			ORDER BY A.gsnagtOrderBy DESC,A.gsnagtID DESC ';
		$tmpAR0['InitialString']=2;
		$tmpAR0['Parid']='gsnagtID';
		$tmpAR0['Text']='gsnagtName';
		$tmpAR0['Value']='gsnagtID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='Gsnavigation/options_Groupsalenavigation_Activegroup';
		$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);
		//-- #Zoneid --
		$this->sData_Zonechild=array();
		$tmpINT=$this->sApp_Zone->getZone_Child($this->sZoneid,$this->sZoneCache,$this->sData_Zonechild);
		
		
		
	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('ID','',0);
		//$this->sMainID=$tmpAR0[0];
		$this->sParidSTR=$tmpAR0[0];
		if ($this->sParidSTR=='') {
			$this->sParidAR=array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,);
		}else {
			$this->sParidAR=explode($this->sysSPLIT2,$this->sParidSTR);
		}
		$tmpAR0=$this->AnalyerRequest('DKeyword','',0);
		$this->sKeyword=$tmpAR0[0];
		$this->sSearchAR=$this->AnalyerRequest('DSearch','-1,-1,-1',0);
		
		//-- ------ #Datas ------ --
		$tmpListSTR0='DList0';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,24,0',0);
		$tmpSortSTR0='DSort0';
		$tmpSortAR0=$this->AnalyerRequest($tmpSortSTR0,'cdtID,2',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.gsnatID,A.gsnatName,A.gsnatParid,A.gsnatState,
			B.gsnactPrice_EndTime,B.gsnactPrice_Origin,B.gsnactPrice_Now,B.gsnactPrice_Sale,
			B.gsnactMapIntroduct,B.gsnactMapX,B.gsnactMapY,
			B.gsnactCount_Order,B.gsnactSourceR00,
			C.gsnutID,C.gsnutName
			FROM {Nets.TableHead}gsnavigationactive AS A
			INNER JOIN {Nets.TableHead}gsnavigationactivecont AS B ON B.gsnactIndexID=A.gsnatID
			INNER JOIN {Nets.TableHead}gsnavigationunit AS C ON C.gsnutID=A.gsnatUnitid
			WHERE 1=1 AND A.gsnatRecycle=0 AND A.gsnatChecked>1 ';

		if ($this->sKeyword!='') {
			$tmpSQL.=' AND A.gsnatName LIKE \'%'.$this->sKeyword.'%\' ';
		}
		$tmpSTR_0='';
		foreach ($this->sParidAR as $Row0){
			$tmpSTR_0.=' OR A.gsnatParid='.$this->sCode->Int32($Row0,$this->sParidAR[0]).' ';
		}
		if ($this->sParidSTR!='') {
			$tmpSQL.=' AND (1=2 '.$tmpSTR_0.') ';
		}
		if ($this->sSearchAR[0]!=-1) {
			$tmpSQL.=' AND A.gsnatState='.$this->sSearchAR[0].' ';
		}
		if ($this->sZoneid!=-1) {
			$tmpSQL.=' AND A.gsnatZoneid='.$this->sZoneid.' ';
		}
		$tmpSQL.=' ORDER BY A.gsnatOrderBy DESC,A.gsnatID 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/pageButton_gsnavigation_map.htm');
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&ID='.$this->sParidSTR.'&DKeyword='.$this->sKeyword.'&DSearch='.$this->sSearchAR[0].$this->sysSPLIT1.$this->sSearchAR[1].$this->sysSPLIT1.$this->sSearchAR[2];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		
	}
	public function getSearch($pValue,$pType){
/*
Parid
Keyword
State
Zoneid
OrderBy

*/
		$tmpAR0=array(
			$this->sParidSTR,
			$this->sKeyword,
			$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;
		if($pType==4) $tmpAR0[4]=$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].
			'&DKeyword='.$tmpAR0[1].
			'&DSearch='.$tmpAR0[2].$this->sysSPLIT1.$tmpAR0[3].$this->sysSPLIT1.$tmpAR0[4];
		return $tmpSTR;
	}
	public function getGroupCode($pID){
		$tmpSTR='A';
		if ($pID==3) {
			$tmpSTR='A';
		}else if ($pID==4) {
			$tmpSTR='B';
		}else if ($pID==5) {
			$tmpSTR='C';
		}else if ($pID==6) {
			$tmpSTR='D';
		}else if ($pID==8) {
			$tmpSTR='E';
		}else if ($pID==9) {
			$tmpSTR='F';
		}else if ($pID==10) {
			$tmpSTR='G';

		}
		
		return $tmpSTR;
	}


}

?>