<?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/unitList_Normal.php';
		//-- ------ #Option ------ --
		//Parid
		$tmpAR0=$this->sControl->sDbInTemplate;
		$tmpAR0['Connection']=$this->sConnString;
		$tmpAR0['SQL']=' SELECT A.shugtID,A.shugtName,A.shugtParid
			FROM '.$this->sysTableHead.'shopunitgroup AS A
			WHERE 1=1 AND A.shugtRecycle=0 AND A.shugtChecked>1 AND A.shugtParid={Nets.Parid}
			ORDER BY A.shugtOrderBy DESC,A.shugtID DESC ';
		$tmpAR0['InitialString']=2;
		$tmpAR0['Parid']='shugtID';
		$tmpAR0['Text']='shugtName';
		$tmpAR0['Value']='shugtID';
		$tmpAR0['Type']=1;
		$tmpAR0['Style']='';
		$tmpAR0['Title']='';
		$tmpAR0['AddOne']='';
		$tmpCacheFlag='nets/options_ShopunitList_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);
		
		//-- #sCondition_Order --
		$this->sCondition_Order=array('按人气','按时间',);
		//-- #sCondition_Listtype --
		$this->sCondition_Listtype=array('列表','介绍',);
		
		
		
		
	}
	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',0);
		//-- ------ #This group ------ --
		$tmpSQL=' SELECT A.shugtID,A.shugtName,B.shugctTemplateid_List 
			FROM {Nets.TableHead}shopunitgroup AS A 
			INNER JOIN {Nets.TableHead}shopunitgroupcont AS B ON B.shugctIndexID=A.shugtID
			WHERE 1=1 AND A.shugtRecycle=0 AND A.shugtChecked>1 AND A.shugtID={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(
				'shugtID'=>0,
				'shugtName'=>'所有商家类型',
				'shugtTemplateid_List'=>0,
				),);
			//return 1;
		}
		$this->sMetaTitle=$tmpData_Group[0]['shugtName'];
		//-- ------ #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]['shugtTemplateid_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.'shopunitgroup','shugt');
		$this->sNavigation=$this->sDb->getParent($this->sMainID,$this->sysTableHead.'shopunitgroup','shugt');
		//-- ------ #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.shutID,A.shutName,A.shutParid,A.shutNameStyle,
			B.shuctInfo_Credit,B.shuctComName,B.shuctComIdCode,B.shuctComIdCodeSource,B.shuctComIdCodeChecked,
			B.shuctComType,B.shuctComContact,B.shuctComContactTele,B.shuctComContactTeleChecked,B.shuctComContactQQ,
			B.shuctComZoneChoose,B.shuctComZoneDetail,B.shuctComContactAddress,B.shuctComNumCode,B.shuctComContactWebsite,
			B.shuctComContactEmail,B.shuctComContactFax,B.shuctComPersonCount,B.shuctComYearMoney,B.shuctComCustomTypes,
			B.shuctComRegisterFund,B.shuctComManageSystem,B.shuctComBrand,B.shuctComRegisterPeople,B.shuctComCreateTime,
			B.shuctComProduct,B.shuctComBusinessModel,B.shuctComLogo,B.shuctComContactIntroduct,
			B.shuctSourceR00,B.shuctContent
			
			FROM {Nets.TableHead}shopunit AS A
			INNER JOIN {Nets.TableHead}shopunitcont AS B ON B.shuctIndexID=A.shutID
			WHERE 1=1 AND A.shutRecycle=0 AND A.shutChecked>1 ';

		if ($this->sKeyword!='') {
			$tmpSQL.=' AND A.shutName LIKE \'%'.$this->sKeyword.'%\' ';
		}
		if ($this->sMainID!=-1) {
			$tmpSTR_0='';
			foreach ($tmpChildidAR0 as $Cell){
				$tmpSTR_0.=' OR A.shutParid='.$Cell.' ';
			}
			$tmpSQL.=' AND (1=2 '.$tmpSTR_0.') ';
		}
		
		$tmpSQL.=' ORDER BY A.shutOrderBy DESC,A.shutID 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->sPButton->setPage($this->sDb->sysPageInfo);
		
	}
	public function getSearch($pValue,$pType){
/*
Parid
Keyword

ListType
OrderBy

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