<?php
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/cmsfeedback.php');
require($netsFileConfig['sysCoreRoot'].'Cache/DbDescription/cmsfeedbackcont.php');
require($netsFileConfig['sysCoreRoot'].'Inc/m_Cms/Other/cmsfeedback.php');

class PaDefault extends CustomPage {
	public $sCmsdoc=array();
	
	public function PaDefault(){
		$this->CustomPage();
	}
	public function OnPInitial(){
		$this->sTable=array(
			array('sttTableName'=>$this->sysTableHead.'cmsfeedback','sttColumnHead'=>'cfbt'),
			array('sttTableName'=>$this->sysTableHead.'cmsfeedbackcont','sttColumnHead'=>'cfbct'),);
		$this->sUiName='cms/u_feedback';
	}
	public function OnBInitial(){
		$this->sMetaTitle='在线留言';
		$this->getUser('1,2,3,4,5,');
		$this->sApp=new cmsfeedback($this->sConnString);
		$this->sTemplatePath='Cms/Feedback_Normal.php';
		
	}
	public function OnAdd(){
		$tmpDbDescriptions=array();
		foreach ($this->sTable as $tableCell){
			$tmpDbDescriptions[]=$this->sDbDescriptions[$tableCell['sttTableName']];
		}
		$tmpMainid=$this->AnalyerRequest('mainID','0',1);
		$tmpMainUserid=$this->AnalyerRequest('mainUserid',0,1);
		$tmpMainTableid=$this->AnalyerRequest('mainTableid',0,1);
		//-- ------ #Submit limit check ------ --
		$tmpINT=$this->submitLimitWrite($this->sysPage,-1,-1,-1);
		if($tmpINT!=0){
			$this->sJscript=$this->Message('SUCCESS','','对不起，您提交得太快了，请'.$this->sysFileConfig['SubmitLimitFreeze'].'秒后再提交。','');
			return 1;
		}
		//-- ------ #Add ------ --
		$this->sApp->TransStart();
		//#Get numCode
		$tmpSTR=$this->sTable[0]['sttColumnHead'].'NumCode';
		$tmpDbDescriptions[0]['TableDescription']['SearchColumn']=$tmpSTR;
		$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']='N_'.date('YmdHis');
		$this->sApp->numCode($tmpDbDescriptions[0]);
		//#Set value
		$tmpDbDescription0=$tmpDbDescriptions;
		$Coun0=0;
		foreach ($tmpDbDescription0 as $tableCell){
			foreach ($tableCell['Columns'] as $Column){
				if($Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'ID' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'NumCode' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'CreateBy' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'CreateTime' &&
					$Column['stcotName']!=$this->sTable[$Coun0]['sttColumnHead'].'IndexID'){
					$tmpAR0=$this->AnalyerRequest($Column['stcotName'].'Txt',$Column['stcoctDefaultValue'],1);
					$tmpDbDescriptions[$Coun0]['Columns'][$Column['stcotName']]['Value']=$tmpAR0[0];
				}
			}
			$Coun0++;
		}
		//-- #Set conventional --
		if(isset($tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value'])){
			$tmpDbDescription[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value']=$tmpMainUserid[0];
		}
		if(isset($tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateTime'])){
			$tmpDbDescription[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateTime']['Value']=date($this->sysTimeFormat);
		}
		//DB name,Condition,User index,User column name
		$tmpFlag=0;
		foreach ($this->AnonymousUserData as $Row0){
			if (count($tmpDbDescriptions)>1) {
				if(isset($tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]])){
					if ($tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]]['Value']==$Row0[1]) {
						$tmpFlag=1;
					}
				}
			}
			if ($this->sUserInfo[0]['Columns']['uitID']['Value']==0 && $tmpFlag==1) {
				$tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]]['Value']=$Row0[4];
			}else if ($tmpFlag==1) {
				$tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].$Row0[0]]['Value']=$this->sUserInfo[$Row0[2]]['Columns'][$Row0[3]]['Value'];
			}
		}
		//Spical value array
		foreach ($this->sSpicalValue as $Cell){
			if(isset($tmpDbDescription[$Cell[0]]['Columns'][$Cell[1]]['Value'])){
				$tmpDbDescription[$Cell[0]]['Columns'][$Cell[1]]['Value']=$Cell[2];
			}
		}
		//-- #Set spical --
		$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'Name']['Value']=$this->sCode->SubString($tmpDbDescriptions[1]['Columns'][$this->sTable[1]['sttColumnHead'].'Content']['Value'],0,24);
		$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateTime']['Value']=date($this->sysTimeFormat);
		if ($tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value']==0) {
			$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'CreateBy']['Value']=2;
		}
		//#Add
		$tmpINT=$this->sApp->Check($tmpDbDescriptions,array(),array());
		if($tmpINT!=0){
			$this->sApp->TransRollback();
			$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastError,'');
			return 1;
		}
		$Coun0=0;
		while (count($tmpDbDescriptions)>$Coun0){
			if($Coun0==0){
				$tmpDbDescriptions[$Coun0]['TableDescription']['SearchColumn']=$this->sTable[$Coun0]['sttColumnHead'].'NumCode,'.$this->sTable[$Coun0]['sttColumnHead'].'ID';
			}else {
				$tmpDbDescriptions[$Coun0]['TableDescription']['SearchColumn']=$this->sTable[$Coun0]['sttColumnHead'].'IndexID';
			}
			$Coun0++;
		}
		$tmpINT=$this->sApp->add($tmpDbDescriptions);
		if($tmpINT!=0){
			$this->sApp->TransRollback();
			$this->sJscript=$this->Message('ERROR','',$this->sApp->sysLastError,'');
			return 1;
		}
		foreach ($this->sDb->sysDbCacheClear as $Cell){
			$this->clearCache($Cell);
		}
		foreach ($this->sysPageCacheClear as $Cell){
			$this->clearCache($Cell);
		}
		$this->sApp->TransCommit();
		$this->sJscript=$this->Message('SUCCESS','','添加成功',$this->sysPage.'?DType='.$tmpDbDescriptions[0]['Columns'][$this->sTable[0]['sttColumnHead'].'Type']['Value'].$this->sysSPLIT1);
		return 0;
	}
	public function OnList(){
		$tmpAR0=$this->AnalyerRequest('DType','0,',0);
		$this->sType=$tmpAR0[0];
		$this->sContent=$tmpAR0[1];
		//-- ------ #Other ------ --
		if ($this->sType==1) {
			$this->sMetaTitle='举报';
			$this->sTemplatePath='Cms/Feedback_Complaints.php';
		}
		//-- ------ #Datas ------ --
		$tmpListSTR0='DList0';
		$tmpListAR0=$this->getQueryString($tmpListSTR0);
		//-- #Spell SQL --
		$tmpSQL=' SELECT A.cfbtID,A.cfbtName,A.cfbtCreateBy,A.cfbtCreateTime,
			B.cfbctPublisher_Name,B.cfbctPublisher_Tele,B.cfbctPublisher_Email,B.cfbctContent,B.cfbctBackContent,B.cfbctBackTime
			FROM {Nets.TableHead}cmsfeedback AS A 
			INNER JOIN {Nets.TableHead}cmsfeedbackcont AS B ON B.cfbctIndexID=A.cfbtID
			WHERE 1=1 AND A.cfbtRecycle=0 AND A.cfbtChecked>1
			ORDER BY A.cfbtOrderBy DESC,A.cfbtID DESC ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$this->sListData=$this->sDb->SearchP($tmpSTR,$tmpListAR0);
		$this->sDataCount=$this->sDb->sysPageInfo[3];
		//#Set page button
		$this->sPButton->resetTemlate('../../../Config/m_default/File/pageButton3.htm');
		$this->sPButton->sPage=$this->sysPage;
		$this->sPButton->sExtendParameter='';
		$this->sPButton->setPage($this->sDb->sysPageInfo);
		//-- ------ #Discuss form ------ --
		$this->sUiDescription_0=array();
		$tmpName='other_feedback_normal';
		if ($this->sType==1) {
			$tmpName='other_feedback_complaints';
		}
		$tmpSTR=$this->sUiDescriptionPath.'Plus/cms/'.$tmpName.'.php';
		if(file_exists($tmpSTR)){
			require($tmpSTR);
			$this->sUiDescription_0=$sysUiDescriptions[$tmpName];
			$sysUiDescriptions=array();
		}
		
	}
	public function DefUiPanel(&$pColumn,$pFlag){
		if($pColumn['stcotName']=='cfbctContent' && $pFlag=='Normal'){
			$pColumn['Value']=$this->sContent;
			$pColumn['ControlStyle']='width:250px;height:40px;';
			$pColumn['Parameter_JS_Onfocus']="tmpMCommon.OnDiscussInput(this.name,0);CCodeTxt_ShowCACode(0);";
		}else if($pColumn['stcotName']=='cfbctPublisher_Name' && $pFlag=='Normal'){
			$pColumn['Value']=$this->sUserInfo[0]['Columns']['uitNickname']['Value'];
		}else if($pColumn['stcotName']=='cfbctPublisher_Email' && $pFlag=='Normal'){
			$pColumn['Value']=$this->sUserInfo[0]['Columns']['uitEmail']['Value'];
			
		}else if($pColumn['stcotName']=='cfbctPublisher_Mobile' && $pFlag=='Normal'){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_Mobile']['Value'];
		}else if($pColumn['stcotName']=='cfbctPublisher_Tele' && $pFlag=='Normal'){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_Tele']['Value'];
		}else if($pColumn['stcotName']=='cfbctPublisher_Software' && $pFlag=='Normal'){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_Software']['Value'];
		}else if($pColumn['stcotName']=='cfbctPublisher_Homepage' && $pFlag=='Normal'){
			$pColumn['Value']=$this->sUserInfo[1]['Columns']['uictCo_Website']['Value'];
		
		}else if($pColumn['stcotName']=='cfbtType' && $pFlag=='Normal'){
			$pColumn['Value']=$this->sType;
			
		}
		if($pColumn['stcoctUiType']=='Text' && $pFlag=='Normal'){
			$pColumn['ControlStyle']='width:250px;';
		}
	}

}
?>