<?php
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsSocket.php');
require($netsFileConfig['sysCoreRoot'].'Inc/netsFunc/Func/netsEmail.php');
require($netsFileConfig['sysCoreRoot_Real'].'Inc/netsFunc/Func/netsMobile.php');

require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/shopfavourable.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/shopfavourablecont.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Shop/Sale/shopfavourable.php');



class PaDefault extends CustomPage {
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnBInitial(){
		$this->sMetaTitle='优惠券详细内容';
		$this->getUser('1,2,3,4,5,');
		$this->sApp=new shopfavourable($this->sConnString);
		
		//-- ------ #Share link ------ --
		//-- #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;
		}
		
		//-- ------ #ActionType ------ --
		if($this->sActionType=='DPrint_Normal'){
			$this->OnPrint_Normal();
		}else if($this->sActionType=='DPrint_Mobile'){
			$this->OnPrint_Mobile();
		}

	}
	public function OnPrint_Normal(){
		$tmpAR0=$this->AnalyerRequest('ID',1,0);
		$this->sMainID=$tmpAR0[0];
		//-- ------ #Initial ------ --
		//$tmpINT=$this->sApp->initialObject($this->sMainID);
		//-- ------ #Datas ------ --
		$tmpSQL=' SELECT *
			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 A.shftID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$this->sDetailData=$this->sDb->Search($tmpSTR);
		if(count($this->sDetailData)==0){
			//#Error
			//#Other
			$tmpSQL=' SELECT A.shftID,A.shftName,A.shftParid,A.shftCreateTime
				FROM {Nets.TableHead}shopfavourable AS A 
				WHERE 1=1 AND A.shftRecycle=0 AND A.shftChecked>1
				ORDER BY A.shftOrderBy DESC,A.shftID DESC LIMIT 0,8 ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$this->sOtherData=$this->sDb->Search($tmpSTR);
			return 1;
		}
		$this->sMainID=$this->sDetailData[0]['shftID'];
		$this->sMetaTitle=$this->sDetailData[0]['shftName'];
		$this->sParid=$this->sDetailData[0]['shftParid'];
		
		//-- ------ ### ------ --
		
		
		
		
		return 0;
	}
	public function OnPrint_Mobile(){
		$tmpAR0=$this->AnalyerRequest('ID',1,0);
		$this->sMainID=$tmpAR0[0];
		//-- ------ #Initial ------ --
		//$tmpINT=$this->sApp->initialObject($this->sMainID);
		//-- ------ #Datas ------ --
		$tmpSQL=' SELECT *
			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 A.shftID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$this->sDetailData=$this->sDb->Search($tmpSTR);
		if(count($this->sDetailData)==0){
			//#Error
			//#Other
			$tmpSQL=' SELECT A.shftID,A.shftName,A.shftParid,A.shftCreateTime
				FROM {Nets.TableHead}shopfavourable AS A 
				WHERE 1=1 AND A.shftRecycle=0 AND A.shftChecked>1
				ORDER BY A.shftOrderBy DESC,A.shftID DESC LIMIT 0,8 ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$this->sOtherData=$this->sDb->Search($tmpSTR);
			return 1;
		}
		$this->sMainID=$this->sDetailData[0]['shftID'];
		$this->sMetaTitle=$this->sDetailData[0]['shftName'];
		$this->sParid=$this->sDetailData[0]['shftParid'];
		
		//-- ------ ### ------ --
		$tmpMobile=new netsMobile(array($this->sysFileConfig['MobileUName'],
			$this->sysFileConfig['MobilePxd'],
			$this->sysFileConfig['MobileSendURL'],
			$this->sysFileConfig['MobileReceiveURL'],
			$this->sysFileConfig['MobileCountURL'],));
		
		$tmpSTR='{Nets.STR_0}；优惠券编号：{Nets.STR_1}；用户名：{Nets.STR_2}；用户编号：{Nets.STR_3}。';
		$tmpSTR=str_replace('{Nets.STR_0}',$this->sDetailData[0]['shftName'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.STR_1}',$this->sDetailData[0]['shftNumCode'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.STR_2}',$this->sUserInfo[0]['Columns']['uitName']['Value'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.STR_3}',$this->sUserInfo[0]['Columns']['uitNumCode']['Value'],$tmpSTR);
		
		$this->sPrint_Mobile_Message=$tmpSTR;
		$tmpINT=$tmpMobile->sendCSMS($this->sUserInfo[0]['Columns']['uitMobile']['Value'],$this->sPrint_Mobile_Message);
		
		
		return 0;
	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('ID',1,0);
		$this->sMainID=$tmpAR0[0];
		//-- ------ #Initial ------ --
		//$tmpINT=$this->sApp->initialObject($this->sMainID);
		//-- ------ #Datas ------ --
		$tmpSQL=' SELECT *
			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 A.shftID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$this->sMainID,$tmpSTR);
		$this->sDetailData=$this->sDb->Search($tmpSTR);
		if(count($this->sDetailData)==0){
			//#Error
			//#Other
			$tmpSQL=' SELECT A.shftID,A.shftName,A.shftParid,A.shftCreateTime
				FROM {Nets.TableHead}shopfavourable AS A 
				WHERE 1=1 AND A.shftRecycle=0 AND A.shftChecked>1
				ORDER BY A.shftOrderBy DESC,A.shftID DESC LIMIT 0,8 ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$this->sOtherData=$this->sDb->Search($tmpSTR);
			return 1;
		}
		$this->sMainID=$this->sDetailData[0]['shftID'];
		$this->sMetaTitle=$this->sDetailData[0]['shftName'];
		$this->sParid=$this->sDetailData[0]['shftParid'];
		
		//-- ------ #Group ------ --
		$tmpSQL=' SELECT A.shfgtID,A.shfgtName,B.shfgctTemplateid_Detail
			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->sParid,$tmpSTR);
		$this->sData_Group=$this->sDb->Search($tmpSTR);
		if(count($this->sData_Group)==0){
			//#Non group
			//#Other
			$this->sData_Group[0]=array(
				'shfgtID'=>0,
				'shfgtName'=>$this->sysFileConfig['bussinessName'],
				'shfgctTemplateid_Detail'=>0,
				);
		}
		//-- ------ #Template ------ --
		//#List
		$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}',$this->sData_Group[0]['shfgctTemplateid_Detail'],$tmpSTR);
		$tmpData0=$this->sDb->Search($tmpSTR);
		if(count($tmpData0)!=0){
			$this->sTemplatePath=$tmpData0[0]['stemctPath'];
		}
		//#Detail
		$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}',$this->sDetailData[0]['shfctTemplateid_Detail'],$tmpSTR);
		$tmpData0=$this->sDb->Search($tmpSTR);
		if(count($tmpData0)!=0){
			$this->sTemplatePath=$tmpData0[0]['stemctPath'];
		}
		//-- ------ #Evaluation ------ --
		//-- ------ #Navigation ------ --
		$this->sNavigation=$this->sDb->getParent($this->sDetailData[0]['shftParid'],$this->sysTableHead.'shopfavourablegroup','shfgt');
		//-- ------ #Other ------ --
		
		//-- ------ #Discuss form ------ --
		$this->sUiDescription_0=array();
		$tmpSTR=$this->sUiDescriptionPath.'Plus/shop/sale_discuss.php';
		if(file_exists($tmpSTR)){
			require($tmpSTR);
			$this->sUiDescription_0=$sysUiDescriptions['sale_discuss'];
			$sysUiDescriptions=array();
		}
		
		
		return 0;
	}
	
	
	
	
}

?>