<?php

class PaDefault extends CustomPage {
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='优惠券列表';
		$this->getUser('1,2,3,4,5,');
		
		//-- ------ #Option ------ --
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.shfgtID,A.shfgtName,A.shfgtParid
			FROM '.$this->sysTableHead.'shopfavourablegroup AS A
			WHERE 1=1 AND A.shfgtRecycle=0 AND A.shfgtChecked>1 AND A.shfgtParid={Nets.Parid}
			ORDER BY A.shfgtOrderBy DESC,A.shfgtID DESC ';
		$tmpAR0['InitialString']=2;
		$tmpAR0['Parid']='shfgtID';
		$tmpAR0['Text']='shfgtName';
		$tmpAR0['Value']='shfgtID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='Shop/options_shopfavourable_Group_A';
		$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);
		//-- ------ #Options ------ --
		//-- #Require --
		require('../../../Cache/DbCache/Zone/Cache_0.php');
		$this->sZoneCache=$netsAR_Zone;
		//-- #Zone --
		$this->sData_Zonechild=array();
		$tmpINT=$this->sApp_Zone->getZone_Child($this->sZoneid,$this->sZoneCache,$this->sData_Zonechild);
		
		
		//-- ------ #ActionType ------ --

		
		
		
	}
	public function OnList(){
		//-- ------ #LIST ------ --
		//-- ------ ### ------ --
		$tmpAR0=$this->AnalyerRequest('ID',-1,0);
		$this->sMainID=$tmpAR0[0];
		$tmpAR0=$this->AnalyerRequest('DKeyword','',0);
		$this->sKeyword=$tmpAR0[0];
		$this->sSearchAR=$this->AnalyerRequest('DSearch','-1',0);
		//-- ------ #This group ------ --
		$tmpSQL=' SELECT A.shfgtID,A.shfgtName,B.shfgctTemplateid_List 
			FROM {Nets.TableHead}shopfavourablegroup AS A 
			INNER JOIN {Nets.TableHead}shopfavourablegroupcont AS B ON B.shfgctIndexID=A.shfgtID
			WHERE 1=1 AND A.shfgtRecycle=0 AND A.shfgtChecked>1 AND A.shfgtID={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(
				'shfgtID'=>0,
				'shfgtName'=>'所有优惠券',
				'shfgtTemplateid_List'=>0,
				),);
			//return 1;
		}
		$this->sMetaTitle=$tmpData_Group[0]['shfgtName'];
		//-- ------ #Navigation ------ --
		$tmpChildidAR0=$this->sDb->getChild($this->sMainID,$this->sysTableHead.'shopfavourablegroup','shfgt');
		$this->sNavigation=$this->sDb->getParent($this->sMainID,$this->sysTableHead.'shopfavourablegroup','shfgt');
		
		//-- ------ #Datas ------ --
		$tmpListSTR0='DList0';
		$tmpListAR0=$this->AnalyerRequest($tmpListSTR0,'1,0,24,0',0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.shftID,A.shftName,A.shftNameStyle,A.shftCreateTime,A.shftPassTime,A.shftSelled,
			B.shfctSourceR00
			FROM {Nets.TableHead}shopfavourable AS A
			INNER JOIN {Nets.TableHead}shopfavourablecont AS B ON B.shfctIndexID=A.shftID
			WHERE 1=1 AND A.shftRecycle=0 AND A.shftChecked>1 AND (1=2 {Nets.IDS}) ';
		/*
		if($this->sSearchAR[0]=='-1'){
		}else {
			$tmpSQL.=' AND (B.shfctShoppings LIKE \'%'.$this->sZoneid.';%\' OR B.shfctShoppings LIKE \'%|||'.$this->sZoneid.';%\') ';
		}
		*/
		if($this->sSearchAR[0]=='-1'){
		}else {
			$tmpSQL.=' AND (B.shfctShoppings LIKE \'%'.$this->sSearchAR[0].';%\' OR B.shfctShoppings LIKE \'%|||'.$this->sSearchAR[0].';%\') ';
		}
		$tmpSQL.=' ORDER BY A.shftOrderBy DESC,A.shftID DESC ';
			
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR_0='';
		if($this->sMainID!=-1){
			foreach ($tmpChildidAR0 as $Row0) {
				$tmpSTR_0.=' OR A.shftID='.$this->sCode->Int32($Row0,0);
			}
		}else{
			$tmpSTR_0=' OR 1=1 ';
		}
		$tmpSTR=str_replace('{Nets.IDS}',$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.'&DKeyword='.$this->sKeyword.'&DSearch='.$this->sSearchAR[0];
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		
		

		return 0;
	}
public function getSearch($pValue,$pType){
/*
Parid
Keyword

Shopping
*/
		$tmpAR0=array(
			$this->sMainID,
			$this->sKeyword,
			$this->sSearchAR[0],
			);
		if($pType==0) $tmpAR0[0]=$pValue;
		if($pType==1) $tmpAR0[1]=$pValue;
		if($pType==2) $tmpAR0[2]=$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];
		return $tmpSTR;
	}








}

?>