<?php
require('../../../QPlatform/Common/Component/ComInitialHead.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/m_Gsnavigation/Gsnavigation/gsnavigationactive.php');


class PaDefault extends CustomPage {
	public $ssetParid=1;
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnPInitial(){
		$this->checkUser('1,2,3,');
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'gsnavigationactive','sttColumnHead'=>'gsnat'),
			array('sttTableName'=>$this->sysTableHead.'gsnavigationactivecont','sttColumnHead'=>'gsnact'),);
		$this->sUiName='Platform/gsnavigation/gsnavigationactive';
		
	}
	public function OnBInitial(){
		$this->sMetaTitle='团购活动';
		$this->sLimitCount=0;
		$this->sApp=new gsnavigationactive($this->sConnString);
		//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['SQL0']=' 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.gsnagtID={Nets.Parid}
			ORDER BY A.gsnagtOrderBy DESC,A.gsnagtID DESC ';
		$tmpAR0['InitialString']=$this->ssetParid;
		$tmpAR0['Parid']='gsnagtID';
		$tmpAR0['Text']='gsnagtName';
		$tmpAR0['Value']='gsnagtID';
		$tmpAR0['Type']=0;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/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);
		//Zone
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.sztID,A.sztName
			FROM '.$this->sysTableHead.'netssyszone AS A
			WHERE 1=1 AND A.sztRecycle=0 AND A.sztChecked>1 AND A.sztType=3
			ORDER BY A.sztOrderBy DESC,A.sztID DESC ';
		$tmpAR0['InitialString']=0;
		$tmpAR0['Parid']='sztID';
		$tmpAR0['Text']='sztName';
		$tmpAR0['Value']='sztID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Zone_City';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sZone1);
		$this->sZone2=$this->sZone1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有地区]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sZone2,$tmpAR0);
		//State
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=81;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Groupsale_State';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sState1);
		$this->sState2=$this->sState1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有状态]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sState2,$tmpAR0);
		
		//Alphabet
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=$this->sOptionSQL;
		$tmpAR0['InitialString']=84;
		$tmpAR0['Parid']='sotID';
		$tmpAR0['Text']='sotName';
		$tmpAR0['Value']='sotValue';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_Alphabet';
		$this->sControl->getOptions($tmpAR0,$tmpCacheFlag,$this->sControl->sDpReturnTemplate,$this->sAlphabet1);
		$this->sAlphabet2=$this->sAlphabet1;
		$tmpAR0=$this->sControl->sDpReturnTemplate;
		$tmpAR0['Text']='[所有字母]';
		$tmpAR0['Value']='-1';
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		array_push($this->sAlphabet2,$tmpAR0);
		
	}
	public function OnList(){
		//-- ------ #Search data ------ --
		$tmpSTR0='DList0';
		$tmpAR0=$this->getQueryString($tmpSTR0);
		$tmpSTR1='DSort0';
		$tmpAR1=$this->AnalyerRequest($tmpSTR1,'gsnatID,2',0);
		$tmpSTR2='Search0';
		$this->sSearchData=$this->AnalyerRequest($tmpSTR2,',-1,,-1,-1',0);
		//#Spell sql
		$tmpSQL=' SELECT A.gsnatID,A.gsnatName,A.gsnatParid,A.gsnatUnitid,
			A.gsnatZoneid,A.gsnatState
			FROM '.$this->sysTableHead.'gsnavigationactive AS A 
			WHERE 1=1 
			AND A.gsnatID>'.$this->sLimitCount;
		if($this->sSearchData[0]!=''){
			$tmpSQL.=' AND A.gsnatName LIKE \'%'.$this->sSearchData[0].'%\' ';
		}
		if($this->sSearchData[1]!='-1'){
			$tmpSQL.=' AND A.gsnatParid='.$this->sSearchData[1].' ';
		}
		if($this->sSearchData[2]!=''){
			$tmpSQL.=' AND A.gsnatName LIKE \'%'.$this->sSearchData[2].'%\' ';
		}
		if($this->sSearchData[3]!='-1'){
			$tmpSQL.=' AND A.gsnatZoneid='.$this->sSearchData[3].' ';
		}
		if($this->sSearchData[4]!='-1'){
			$tmpSQL.=' AND A.gsnatState='.$this->sSearchData[4].' ';
		}
		if($tmpAR1[1]==1){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' ';
		}else if($tmpAR1[1]==2){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' DESC ';
		}
		$this->sListData=$this->sDb->SearchP($tmpSQL,$tmpAR0);
		//#Set page button
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&'.$tmpSTR2.'='.$this->sSearchData[0].$this->sysSPLIT1.$this->sSearchData[1].$this->sysSPLIT1.$this->sSearchData[2].$this->sysSPLIT1.$this->sSearchData[3].$this->sysSPLIT1.$this->sSearchData[4];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		$this->sPButton->setSort($tmpAR1);
		$this->sSortButton[0]=array('stcotName'=>'gsnatID','stcoctUiName'=>'编号');
		$this->sSortButton[1]=array('stcotName'=>'gsnatName','stcoctUiName'=>'团购活动名称');
		
		return 0;
	}
	public function OnExternal_Search(){
		//-- ------ #Search data ------ --
		$tmpSTR0='DList0';
		$tmpAR0=$this->getQueryString($tmpSTR0);
		$tmpSTR1='DSort0';
		$tmpAR1=$this->AnalyerRequest($tmpSTR1,'gsnatID,2',0);
		$tmpSTR2='Search0';
		$this->sSearchData=$this->AnalyerRequest($tmpSTR2,',,-1',0);
		$this->sExternal_SearchData=$this->AnalyerRequest($this->sActionType,',-1',0);
		//#Spell sql
		$tmpSQL=' SELECT A.gsnatID,A.gsnatName,A.gsnatParid
			FROM '.$this->sysTableHead.'gsnavigationactive AS A 
			WHERE 1=1 
			AND A.gsnatID>'.$this->sLimitCount;
		if($this->sSearchData[0]!=''){
			$tmpSQL.=' AND A.gsnatName LIKE \'%'.$this->sSearchData[0].'%\' ';
		}
		if($this->sSearchData[1]!='-1'){
			$tmpSQL.=' AND A.gsnatParid='.$this->sSearchData[1].' ';
		}
		if($tmpAR1[1]==1){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' ';
		}else if($tmpAR1[1]==2){
			$tmpSQL.=' ORDER BY '.$tmpAR1[0].' DESC ';
		}
		$this->sListData=$this->sDb->SearchP($tmpSQL,$tmpAR0);
		//#Set page button
		$this->sExtendParameter='&ActionType='.$this->sActionType.'&'.$this->sActionType.'='.$this->sExternal_SearchData[0].','.$this->sExternal_SearchData[1];
		$this->sysPages[0]=$this->sysPage.'?'.$this->sExtendParameter;
		
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='&'.$tmpSTR2.'='.$this->sSearchData[0].$this->sExtendParameter;
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		$this->sPButton->setSort($tmpAR1);
		$this->sSortButton[0]=array('stcotName'=>'gsnatID','stcoctUiName'=>'编号');
		$this->sSortButton[1]=array('stcotName'=>'gsnatName','stcoctUiName'=>'团购活动名称');
		
		return 0;
	}
	public function OnExternal_ChildChoose(){
		//-- ------ #Search data ------ --
		$tmpSTR0='External_ChildChoose';
		$this->sExternal_ChildChooseSData=$this->AnalyerRequest($tmpSTR0,'0,,0,0',0);
		//#Spell sql
		$tmpSQL='';
		if($this->sExternal_ChildChooseSData[0]==0 || $this->sExternal_ChildChooseSData[0]==2){
			//-- Same grade --
			$tmpSQL=' SELECT A.gsnatID,A.gsnatName,A.gsnatParid 
				FROM '.$this->sysTableHead.'gsnavigationactive AS A
				WHERE 1=1 AND A.gsnatRecycle=0 AND A.gsnatChecked>1 AND 
				A.gsnatParid=(SELECT gsnatParid FROM groupsalenavigationactive WHERE 1=1 AND gsnatRecycle=0 AND gsnatChecked>1 AND gsnatID={Nets.ID})
				ORDER BY A.gsnatOrderBy DESC,A.gsnatID DESC ';
		}else if($this->sExternal_ChildChooseSData[0]==1 || $this->sExternal_ChildChooseSData[0]==3){
			//-- Child grade --
			$tmpSQL=' SELECT A.gsnatID,A.gsnatName,A.gsnatParid 
				FROM '.$this->sysTableHead.'gsnavigationactive AS A
				WHERE 1=1 AND A.gsnatRecycle=0 AND A.gsnatChecked>1 AND A.gsnatParid={Nets.ID}
				ORDER BY A.gsnatOrderBy DESC,A.gsnatID DESC ';
		}
		$tmpSTR=str_replace('{Nets.ID}',$this->sExternal_ChildChooseSData[2],$tmpSQL);
		$this->sExternal_ChildChooseData=$this->sDb->Search($tmpSTR);
		
		return 0;
	}
	public function OnNormal(){
		$tmpINT=0;
		$tmpAR0=$this->AnalyerRequest('Normal','0,0',0);
		
		$tmpSQL=' SELECT * 
			FROM '.$this->sysTableHead.'gsnavigationactive AS A 
			INNER JOIN '.$this->sysTableHead.'gsnavigationactivecont AS B ON B.gsnactIndexID=A.gsnatID ';
		$Coun0=2;
		foreach ($this->sTable as $Row0){
			if (count($this->sTable)>2) {
				$tmpSQL.=' INNER JOIN '.$Row0['sttTableName'].' AS '.$this->sysTableMark[$Coun0].' ON '.$this->sysTableMark[$Coun0].'.'.$Row0['sttColumnHead'].'IndexID=A.gsnatID ';
				$Coun0++;
			}
		}
		$tmpSQL.=' WHERE 1=1 AND A.gsnatID='.$tmpAR0[0].' ';
		$tmpDataCollection0=$this->sDb->Search($tmpSQL);
		if(count($tmpDataCollection0)>0){
			$tmpRow=$tmpDataCollection0[0];
			$this->sMainID=$tmpRow[$this->sTable[0]['sttColumnHead'].'ID'];
			//-- #Get value --
			$Coun0=0;
			while (count($this->sUiDescription_Normal)>$Coun0) {
				if(isset($tmpRow[$this->sUiDescription_Normal[$Coun0]['stcotName']])){
					$this->sUiDescription_Normal[$Coun0]['Value']=$tmpRow[$this->sUiDescription_Normal[$Coun0]['stcotName']];
					//-- ------ #Spical set ------ --
					if($this->sUiDescription_Normal[$Coun0]['stcotName']=='gsnatParid'){
					}else if($this->sUiDescription_Normal[$Coun0]['stcotName']=='gsnatModelid_Detail'){
						$this->sUiDescription_Normal[$Coun0]['Value']=$this->sMainTableid;
					}else if($this->sUiDescription_Normal[$Coun0]['stcotName']=='gsnactPrice_EndTime'){
						$this->sUiDescription_Normal[$Coun0]['ShowValue']=$this->sUiDescription_Normal[$Coun0]['Value'];
						
					}
				}
				$Coun0++;
			}
		}else {
			$Coun0=0;
			foreach($this->sUiDescription_Normal as $Row0){
				if($Row0['stcotName']=='gsnatTableid'){
					$this->sUiDescription_Normal[$Coun0]['Value']=$this->sMainTableid;
				}
				$Coun0++;
			}
		}
	}
	
	public function DefUiPanel(&$pColumn,$pFlag){
		parent::DefUiPanel($pColumn,$pFlag);
		if($pColumn['stcotName']=='gsnatParid' && $pFlag=='Search'){
			$pColumn['Option']=$this->sParid2;
		}else if($pColumn['stcotName']=='gsnatParid' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Option']=$this->sParid1;
		
		}else if($pColumn['stcotName']=='gsnatState' && $pFlag=='Search'){
			$pColumn['Option']=$this->sState2;
		}else if($pColumn['stcotName']=='gsnatState' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Option']=$this->sState1;
		}else if($pColumn['stcotName']=='gsnatAlphabet' && $pFlag=='Search'){
			$pColumn['Option']=$this->sAlphabet2;
		}else if($pColumn['stcotName']=='gsnatAlphabet' && ($pFlag=='Normal' || $pFlag=='List')){
			$pColumn['Option']=$this->sAlphabet1;
		}else if($pColumn['stcotName']=='gsnactPrice_EndTime' && $pFlag=='Normal'){
			$tmpParameters=$this->sControl->textChooseParameter_Template;
			$tmpParameters['Type']='chooseDay';
			$tmpParameters['ExtendType']='External_Day';
			$tmpParameters['Controlname']=$pColumn['stcotName'];
			$tmpParameters['URL']=$this->sysFileConfig['sysCoreRoot'].'Component/Nets/netsJscript/chooseDay.php?ID=A';
			$pColumn['Parameter']=$tmpParameters;
		}else if($pColumn['stcotName']=='gsnactMapX' && $pFlag=='Normal'){
			if($pColumn['Value']=='0' || $pColumn['Value']==''){
				$pColumn['Value']=$this->sysFileConfig['MapPositionX'];
			}
		}else if($pColumn['stcotName']=='gsnactMapY' && $pFlag=='Normal'){
			if($pColumn['Value']=='0' || $pColumn['Value']==''){
				$pColumn['Value']=$this->sysFileConfig['MapPositionY'];
			}
		}else if($pColumn['stcotName']=='gsnactMapControl' && $pFlag=='Normal'){
			$pColumn['Parameter']='gsnactMapIntroductTxt/*-- #SPLIT1 --*/gsnactMapXTxt/*-- #SPLIT1 --*/gsnactMapYTxt/*-- #SPLIT1 --*/XXXXXXXXXXX/*-- #SPLIT1 --*/';


		}else if(($pColumn['stcotName']=='gsnatZoneid' || $pColumn['stcotName']=='gsnatShoppingid') && ($pFlag=='Normal' || $pFlag=='List' || $pFlag=='Search')){
			$tmpParameters=$this->sControl->textChooseParameter_Template;
			$tmpParameters['Controlname']=$pColumn['stcotName'];
			$tmpParameters['URL']=$this->sysFileConfig['sysCoreRoot'].'QPlatform/m_nets/system/zone.php';
			$pColumn['Parameter']=$tmpParameters;
			
			//gsnatZoneid
			$tmpSQL=' SELECT A.sztID,A.sztName AS tName
				FROM {Nets.TableHead}netssyszone AS A
				WHERE 1=1 AND A.sztRecycle=0 AND A.sztChecked>1 AND A.sztID={Nets.ID} ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$tmpSTR=str_replace('{Nets.ID}',$this->sCode->Int32($pColumn['Value'],0),$tmpSTR);
			$tmpData0=$this->sDb->Search($tmpSTR);
			if(count($tmpData0)>0){
				$pColumn['ShowValue']=$tmpData0[0]['tName'];
			}
		}else if($pColumn['stcotName']=='gsnatUnitid' && ($pFlag=='Normal' || $pFlag=='List' || $pFlag=='Search')){
			$tmpParameters=$this->sControl->textChooseParameter_Template;
			$tmpParameters['Controlname']=$pColumn['stcotName'];
			$tmpParameters['URL']=$this->sysFileConfig['sysCoreRoot'].'QPlatform/m_gsnavigation/gsnavigation/gsnavigationunit.php';
			$pColumn['Parameter']=$tmpParameters;
			//gsnatUnitid
			$tmpSQL=' SELECT A.gsnutID,A.gsnutName AS tName
				FROM {Nets.TableHead}gsnavigationunit AS A
				WHERE 1=1 AND A.gsnutRecycle=0 AND A.gsnutChecked>1 AND A.gsnutID={Nets.ID} ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$tmpSTR=str_replace('{Nets.ID}',$this->sCode->Int32($pColumn['Value'],0),$tmpSTR);
			$tmpData0=$this->sDb->Search($tmpSTR);
			if(count($tmpData0)>0){
				$pColumn['ShowValue']=$tmpData0[0]['tName'];
			}
		}else if(($pColumn['stcotName']=='gsnactZones' || $pColumn['stcotName']=='gsnactShoppings') && ($pFlag=='Normal' || $pFlag=='List' || $pFlag=='Search')){
			$tmpParameters=$this->sControl->textChooseParameter_Template;
			$tmpParameters['Controlname']=$pColumn['stcotName'];
			$tmpParameters['URL']=$this->sysFileConfig['sysCoreRoot'].'QPlatform/m_nets/system/zone.php';
			$pColumn['Parameter']=$tmpParameters;

		}else if($pColumn['stcotName']=='gsnactBrands' && ($pFlag=='Normal' || $pFlag=='List')){
			$tmpParameters=$this->sControl->textChooseParameter_Template;
			$tmpParameters['Controlname']=$pColumn['stcotName'];
			$tmpParameters['URL']=$this->sysFileConfig['sysCoreRoot'].'QPlatform/m_shop/sale/brand.php';
			$pColumn['Parameter']=$tmpParameters;
		}else if($pColumn['stcotName']=='gsnactRealshops' && ($pFlag=='Normal' || $pFlag=='List')){
			$tmpParameters=$this->sControl->textChooseParameter_Template;
			$tmpParameters['Controlname']=$pColumn['stcotName'];
			$tmpParameters['URL']=$this->sysFileConfig['sysCoreRoot'].'QPlatform/m_shop/sale/realshop.php';
			$pColumn['Parameter']=$tmpParameters;


		}
		return $pColumn;
	}
}
//-- ------ #Instanct ------ --
$tmpDefault=new PaDefault();
$tmpDefault->OnPage();
$tmpControls=new CustomControls();
$tmpControlPage=new CustomControlPage();
$tmpComHead->sMenuid=$tmpDefault->sMenuid;
$tmpDefault->sysMetaTitle=$tmpDefault->sMetaTitle.' - '.$tmpDefault->sysFileConfig['sysTitle'];
//-- ------ #Template ------ --
require($tmpDefault->sysFileConfig['sysCoreRoot_Real'].$tmpDefault->sysQPlatformTemplatePath.'Component/Group_0.php'); ?>