<?php
class Normal_ChildChoose extends netsControl {
	public function Normal_ChildChoose(){
		$this->netsControl();
	}
	public function Control($pColumn){
		$tmpControl=$pColumn['stcotName'].'Txt'.$pColumn['NameExtend'];
		$tmpIntroduct='';
		if(strlen($pColumn['stcoctUiIntroduct'])>0 && $pColumn['stcoctUiIntroduct']!='&nbsp;'){
			$tmpIntroduct='<div id="'.$tmpControl.'_Messagebox" class="ControlIntroduct">'.$pColumn['stcoctUiIntroduct'].'</div>';
		}else{
			$tmpIntroduct='<div id="'.$tmpControl.'_Messagebox" class="DHidden">'.$pColumn['stcoctUiIntroduct'].'</div>';
		}
		$tmpCode=new netsCode();
		$tmpDb=new netsDb($this->sConnString);
		$tmpDefaultValue=-1;
		$tmpDefaultText='未设置分类';
		
		$tmpParameter=explode($this->sysSPLIT13,$pColumn['Parameter']);
		if($tmpParameter[0]==0){
			$tmpValues=explode($this->sysSPLIT1,$tmpParameter[1]);
		}else{
			$tmpValues=explode($this->sysSPLIT1,$pColumn['Value']);
		}
		$Coun0=0;
		while(count($tmpParameter)>$Coun0){
			$tmpParameter[$Coun0]=str_replace($this->sysSPLIT4,'',$tmpParameter[$Coun0]);
			$tmpParameter[$Coun0]=str_replace($this->sysSPLIT10,'',$tmpParameter[$Coun0]);
			$Coun0++;
		}
?>
<!-- #<?php echo ($tmpControl); ?> -->
<?php if ($pColumn['stcoctSingleLine']==0) { ?><tr id="<?php echo($tmpControl); ?>_RowBox" class="<?php echo ($pColumn['LineStyle']); ?>"><?php } ?>
<td id="<?php echo ($tmpControl); ?>_Label" class="PanelTitle"><?php echo ($pColumn['stcoctUiName']); ?>：</td>
<td id="<?php echo ($tmpControl); ?>PanelBox" class="PanelBox <?php if ($pColumn['stcoctSingleLine']==1) { ?>PanelMultiColumn<?php } ?>" <?php if ($pColumn['stcoctSingleLine']==0 && $pColumn['stcoctColspan']>1) { ?>colspan="<?php echo($pColumn['stcoctColspan']); ?>"<?php } ?>>
<!--S.<?php echo ($tmpControl); ?>-->
<?php if($tmpParameter[0]==2){ ?>
<!-- ------ #Type <?php echo ($tmpParameter[0]); ?> ------ -->
<table id="<?php echo($tmpControl); ?>_OptionBox" cellpadding="0" cellspacing="0"><tr>
<?php
$tmpValues=array();
$pColumn['Value']=$tmpCode->Int32($pColumn['Value'],$tmpParameter[1]);
if($pColumn['Value']==0){
	$pColumn['Value']=$tmpParameter[1];
}
//-- ------ #Parent ------ --
$tmpFlag=0;
$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpParameter[6]);
$tmpSTR=str_replace('{Nets.ID}',$pColumn['Value'],$tmpSTR);
$tmpData0=$tmpDb->Search($tmpSTR);
$Coun0=0;
while(count($tmpData0)>0 && $tmpFlag!=2){
	//Get option
	$tmpID=$tmpData0[0][$tmpParameter[2].'ID'];
	$tmpParid=$tmpData0[0][$tmpParameter[2].'Parid'];
	$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpParameter[7]);
	$tmpSTR=str_replace('{Nets.ID}',$tmpData0[0][$tmpParameter[2].'Parid'],$tmpSTR);
	$tmpData0=$tmpDb->Search($tmpSTR);
	$Coun1=0;
	while(count($tmpData0)>$Coun1){
		$tmpSelected=0;
		if($tmpData0[$Coun1][$tmpParameter[2].'ID']==$tmpID){
			$tmpSelected=1;
		}
		$tmpValues[$Coun0][$Coun1]=array(
			'Value'=>$tmpData0[$Coun1][$tmpParameter[2].'ID'],
			'Text'=>$tmpData0[$Coun1][$tmpParameter[2].'Name'],
			'Selected'=>$tmpSelected,
			);
		$Coun1++;
	}
	//#Condition
	if ($tmpFlag==1) {
		$tmpFlag=2;
	}else {
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpParameter[6]);
		$tmpSTR=str_replace('{Nets.ID}',$tmpParid,$tmpSTR);
		$tmpData0=$tmpDb->Search($tmpSTR);
		if(count($tmpData0)>0){
			if ($tmpData0[0][$tmpParameter[2].'ID']==$tmpParameter[1]) {
				$tmpFlag=1;
			}
		}else{
			$tmpFlag=2;
		}
	}
	$Coun0++;
}
$tmpINT=krsort($tmpValues);
//-- ------ #Make ------ --
$Coun0=0;
foreach ($tmpValues as $Row0){ ?>
<td><select id="<?php echo($tmpControl.'_'.$Coun0); ?>" name="<?php echo($tmpControl.'_'.$Coun0); ?>" class="SControl1 SDropdown"
onclick="tmpControl.onControlLight(this,'SDropdown');<?php echo($pColumn['Parameter_JS_Onclick']); ?>"
onblur="tmpControl.onControlBlur(this,'SDropdown');<?php echo($pColumn['Parameter_JS_Onblur']); ?>"
onfocus="<?php echo($pColumn['Parameter_JS_Onfocus']); ?>"
onchange="tmp<?php echo($tmpControl); ?>.onChange('<?php echo($tmpControl); ?>','<?php echo ($this->sysFileConfig['sysCoreRoot'].$tmpParameter[5]); ?>',<?php echo ($Coun0); ?>,this);<?php echo($pColumn['Parameter_JS_Onchange']); ?>"
onmouseover="<?php echo($pColumn['Parameter_JS_Onmouseover']); ?>"
onmouseout="<?php echo($pColumn['Parameter_JS_Onmouseout']); ?>">
<?php
	foreach ($Row0 as $Cell){ ?>
<option value="<?php echo ($Cell['Value']); ?>" <?php if ($Cell['Selected']==1) { ?>selected="selected"<?php } ?>><?php echo ($Cell['Text']); ?></option>
<?php } ?>
</select></td>
<?php $Coun0++; } ?>
</tr></table>
<input id="<?php echo($tmpControl); ?>" name="<?php echo($tmpControl); ?>" type="hidden" value="<?php echo($pColumn['Value']); ?>" /><?php echo ($tmpIntroduct); ?>
<!-- #JSCRIPT -->
<script type="text/javascript">
var tmp<?php echo($tmpControl); ?>=new childChoose_Dropdown();
tmp<?php echo($tmpControl); ?>.sName="<?php echo($tmpControl); ?>";

function childChoose_Dropdown_callback_<?php echo($tmpControl); ?>(){
	var tmpOBJECT=tmp<?php echo($tmpControl); ?>;
	var tmpURL=tmpOBJECT.sAjax_0.sURL;
	var tmpFlag=tmpOBJECT.sAjax_0.sFlag;
	var tmpControl=document.getElementById(tmpOBJECT.sAjax_0.sPanel);
	var tmpHttpRequest=tmpOBJECT.sAjax_0.sHttpRequests;
	//alert(sHttpRequest.responseText);
	if(tmpHttpRequest.readyState==4){
		//alert(sHttpRequest.responseText);
		var tmpData=getDataByFlag(tmpHttpRequest.responseText,tmpFlag);
		//alert(tmpData);
		if(tmpData.indexOf("sendRequest")>=0 && tmpData!="<!--sendRequest-->"){
			if(tmpData.length>32){
				tmpControl.rows[0].insertCell(tmpControl.rows[0].cells.length);
				tmpControl.rows[0].cells[tmpControl.rows[0].cells.length-1].innerHTML=tmpData;
				//document.getElementById(tmpOBJECT.sName).value=tmpControl.rows[0].cells[tmpControl.rows[0].cells.length-1].childNodes[0].options[0].value;
			}
	    	tmpFrames.showLoading(1);
	    }else{
	    	tmpSTR=tmpCommon.sysError_Ajax.replace(/\{Nets.Response}/g,tmpURL);
	    	tmpFrames.showLoading(1);
	    }
	}else{
		tmpFrames.showLoading(0);
	}
}

</script>



<?php }else if($tmpParameter[0]==1){ ?>
<!-- ------ #Type <?php echo ($tmpParameter[0]); ?> ------ -->
<div id="<?php echo($tmpControl); ?>_Mainbox" class="ChildChoose_0">
<?php
$tmpValues=array();
$tmpTexts=array();
$pColumn['Value']=$tmpCode->Int32($pColumn['Value'],$tmpParameter[1]);

$tmpRows=array();
$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpParameter[6]);
$tmpSTR=str_replace('{Nets.ID}',$pColumn['Value'],$tmpSTR);
$tmpData0=$tmpDb->Search($tmpSTR);
while(count($tmpData0)>0){
	$tmpRows[]=$tmpData0[0];
	$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpParameter[6]);
	$tmpSTR=str_replace('{Nets.ID}',$tmpData0[0][$tmpParameter[2].'Parid'],$tmpSTR);
	$tmpData0=$tmpDb->Search($tmpSTR);
}

$Coun0=0;
krsort($tmpRows);
foreach($tmpRows as $Row0){ ?>
<!-- # -->
<div id="<?php echo($tmpControl); ?>_Row_<?php echo($Coun0); ?>"><ul class="ChildChoose_1">
<li class="ChildChoose_2"><img src="<?php echo($this->sysFileConfig['sysCoreRoot']); ?>Ui/m_nets/Img/Mana/19.jpg" /></li>
<li class="ChildChoose_3"><a id="<?php echo($tmpControl); ?>_RowText_<?php echo($Coun0); ?>" href="#Here" class="Link2 FWhite1" onclick="<?php echo($tmpControl); ?>_JS.onOpen(<?php echo($Coun0); ?>);"><?php echo($Row0[$tmpParameter[2].'Name']); ?></a></li>
<li class="ChildChoose_5"><a href="#Here" class="Link1 FBlack3" onclick="<?php echo($tmpControl); ?>_JS.onOpen(<?php echo($Coun0); ?>);">选取分类</a></li>
<li class="ChildChoose_4"><img src="<?php echo($this->sysFileConfig['sysCoreRoot']); ?>Ui/m_nets/Img/Mana/19.jpg" /></li>
<li class="DClear"></li></ul>
<ul id="<?php echo($tmpControl); ?>_Cellbox_<?php echo($Coun0); ?>" class="ChildChoose_6"></ul>
</div>
<?php
	$tmpValues[]=$Row0[$tmpParameter[2].'ID'];
	$tmpTexts[]=$Row0[$tmpParameter[2].'Name'];
	$Coun0++;
}
?>
<div id="<?php echo($tmpControl); ?>_Row_<?php echo($Coun0); ?>"><ul class="ChildChoose_1">
<li class="ChildChoose_2"><img src="<?php echo($this->sysFileConfig['sysCoreRoot']); ?>Ui/m_nets/Img/Mana/19.jpg" /></li>
<li class="ChildChoose_3"><a id="<?php echo($tmpControl); ?>_RowText_<?php echo($Coun0); ?>" href="#Here" class="Link2 FWhite1" onclick="<?php echo($tmpControl); ?>_JS.onOpen(<?php echo($Coun0); ?>);"><?php echo($tmpDefaultText); ?></a></li>
<li class="ChildChoose_5"><a href="#Here" class="Link1 FBlack3" onclick="<?php echo($tmpControl); ?>_JS.onOpen(<?php echo($Coun0); ?>);">选取分类</a></li>
<li class="ChildChoose_4"><img src="<?php echo($this->sysFileConfig['sysCoreRoot']); ?>Ui/m_nets/Img/Mana/19.jpg" /></li>
<li class="DClear"></li></ul>
<ul id="<?php echo($tmpControl); ?>_Cellbox_<?php echo($Coun0); ?>" class="ChildChoose_6"></ul>
</div>
<?php
$tmpValues[]=$tmpDefaultValue;
$tmpTexts[]=$tmpDefaultText;
$Coun0++;
?>
</div>
<!-- #Button -->
<ul class="ChildChoose_9">
<li class="ChildChoose_5"><a href="#Here" class="Link1 FBlack3" onclick="<?php echo($tmpControl); ?>_JS.Reset();">重置</a></li>
<li class="DClear"></li></ul>
<input id="<?php echo($tmpControl); ?>" name="<?php echo($tmpControl); ?>" type="text" value="<?php echo($pColumn['Value']); ?>" /><?php echo ($tmpIntroduct); ?>
<!-- #JScript -->
<script type="text/javascript">
var Coun0=0;
var tmpAR0=new Array();
var tmpAR1=new Array();
<?php
$Coun0=0;
while(count($tmpValues)>$Coun0){ ?>
tmpAR0[Coun0]="<?php echo($tmpValues[$Coun0]); ?>";
tmpAR1[Coun0]="<?php echo($tmpTexts[$Coun0]); ?>";
Coun0++;
<?php
	$Coun0++;
}
?>
var <?php echo($tmpControl); ?>_JS=new childChoose_Dynamic();
<?php echo($tmpControl); ?>_JS.initial("<?php echo($tmpControl); ?>","<?php echo($this->sysFileConfig['sysCoreRoot'].$tmpParameter[5]); ?>",tmpAR0,tmpAR1);

</script>




<?php }else if($tmpParameter[0]==0){ ?>
<!-- ------ #Type <?php echo ($tmpParameter[0]); ?> ------ -->
<div id="<?php echo($tmpControl); ?>_Mainbox" class="ChildChoose_0">
<?php
$tmpAR0=explode($this->sysSPLIT1,$tmpParameter[1]);
$tmpValues=explode($this->sysSPLIT1,$pColumn['Value']);
$tmpTexts=array();
if(count($tmpAR0)!=count($tmpValues)){
	$tmpValues=$tmpAR0;
}
array_pop($tmpValues);
$Coun0=0;
foreach($tmpValues as $Row0){
	$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpParameter[6]);
	$tmpSTR=str_replace('{Nets.ID}',$Row0,$tmpSTR);
	$tmpData1=$tmpDb->Search($tmpSTR);
	$tmpValue=$tmpDefaultValue;
	$tmpText=$tmpDefaultText;
	if(count($tmpData1)==1){
		$tmpValue=$tmpData1[0][$tmpParameter[2].'ID'];
		$tmpText=$tmpData1[0][$tmpParameter[2].'Name'];
	}
	$tmpTexts[]=$tmpText;
?>
<!-- # -->
<div id="<?php echo($tmpControl); ?>_Row_<?php echo($Coun0); ?>"><ul class="ChildChoose_1">
<li class="ChildChoose_2"><img src="<?php echo($this->sysFileConfig['sysCoreRoot']); ?>Ui/m_nets/Img/Mana/19.jpg" /></li>
<li class="ChildChoose_3"><a id="<?php echo($tmpControl); ?>_RowText_<?php echo($Coun0); ?>" href="#Here" class="Link2 FWhite1" onclick="<?php echo($tmpControl); ?>_JS.onOpen(<?php echo($Coun0); ?>);"><?php echo($tmpText); ?></a></li>
<li class="ChildChoose_5"><a href="#Here" class="Link1 FBlack3" onclick="<?php echo($tmpControl); ?>_JS.onOpen(<?php echo($Coun0); ?>);">选取分类</a></li>
<li class="ChildChoose_4"><img src="<?php echo($this->sysFileConfig['sysCoreRoot']); ?>Ui/m_nets/Img/Mana/19.jpg" /></li>
<li class="DClear"></li></ul>
<ul id="<?php echo($tmpControl); ?>_Cellbox_<?php echo($Coun0); ?>" class="ChildChoose_6"></ul>
</div><?php $Coun0++; } ?></div>
<!-- #Button -->
<ul class="ChildChoose_9">
<li class="ChildChoose_5"><a href="#Here" class="Link1 FBlack3" onclick="<?php echo($tmpControl); ?>_JS.Reset();">重置</a></li>
<li class="DClear"></li></ul>
<input  id="<?php echo($tmpControl); ?>" name="<?php echo($tmpControl); ?>" type="text" value="<?php
foreach($tmpValues as $Row0){
	echo($Row0.$this->sysSPLIT1);
}
?>" /><?php echo ($tmpIntroduct); ?>
<!-- #JScript -->
<script type="text/javascript">
var Coun0=0;
var tmpAR0=new Array();
var tmpAR1=new Array();
<?php
$Coun0=0;
while(count($tmpValues)>$Coun0){ ?>
tmpAR0[Coun0]="<?php echo($tmpValues[$Coun0]); ?>";
tmpAR1[Coun0]="<?php echo($tmpTexts[$Coun0]); ?>";
Coun0++;
<?php
	$Coun0++;
}
?>
var <?php echo($tmpControl); ?>_JS=new childChoose_Fixed();
<?php echo($tmpControl); ?>_JS.initial("<?php echo($tmpControl); ?>","<?php echo($this->sysFileConfig['sysCoreRoot'].$tmpParameter[5]); ?>",tmpAR0,tmpAR1);

</script>
<?php } ?><!--sendRequest--><!--E.<?php echo ($tmpControl); ?>--></td>
<td id="<?php echo ($tmpControl); ?>_ImgIntroduct" class="PanelImgIntroduct">
<?php if(strlen($pColumn['stcoctUiImgIntroduct'])>0 && $pColumn['stcoctUiImgIntroduct']!='&nbsp;'){ ?>
<a href="#Here"><img src="<?php echo($this->sysFileConfig['sysUiCoreRoot']); ?>Ui/Common/Img/Common/icon_4.jpg" title="<?php echo($pColumn['stcoctUiImgIntroduct']); ?>" /></a>
<?php }else{ ?>&nbsp;<?php } ?></td><?php if ($pColumn['stcoctSingleLine']==0) { ?></tr><?php } ?>
<?php
	}
}
?>