<?php
/*
	[Phpup.Net!] (C)2009-2011 Phpup.net.
	This is NOT a freeware, use is subject to license terms

	$Id: admin.class.php 2010-08-24 10:42 $
*/

if(!defined('IN_PHPUP')) {
	exit('Access Denied');
}
?>
<?php include ROOT_PATH.'/views/admin/header.php';?>
<body>
<SCRIPT LANGUAGE="JavaScript">

	function get_bizgroup()
	{
        
		var cityid = $("#city").val();
		var url ="index.php?con="+adminpath+"&act=get_bizgroup&cityid="+cityid;
		$.getJSON(url,function(data){

				var node ="";

				<?php  if($updateid){ ?>

				var  bizgroup = '<?php  echo $tempsite_info['bizgroup']; ?>';

				for(i = 0;i<data.length;i++)
				{
					if(data[i]['id'] == bizgroup )
					{
						node +="<option value="+data[i]['id']+" selected >"+data[i]['bizname']+"</option>";
					}else{
						node +="<option value="+data[i]['id']+" >"+data[i]['bizname']+"</option>";
					}
				}

				<?php   }else{  ?>

				for(i = 0;i<data.length;i++)
				{
					node +="<option value="+data[i]['id']+">"+data[i]['bizname']+"</option>";
				}

				<?php  }?>

				$("#bizgroup").html(node);
        })
	}

	function get_catelist()
	{
		var id = $("#big_catelist").val();
		var url ="index.php?con="+adminpath+"&act=get_catelist&parentid="+id;
		$.getJSON(url,function(data){

				var node ="";

				<?php  if($updateid){ ?>

				var small_catelist = '<?php  echo $tempsite_info['small_catelist']; ?>';
				for(i = 0;i<data.length;i++)
				{
					if(small_catelist == data[i]['id'])
					{
						node +="<option value="+data[i]['id']+"  selected >"+data[i]['catename']+"</option>";
					}else{
						node +="<option value="+data[i]['id']+">"+data[i]['catename']+"</option>";
					}	
				}

				<?php   }else{  ?>

				for(i = 0;i<data.length;i++)
				{
					node +="<option value="+data[i]['id']+">"+data[i]['catename']+"</option>";
				}

				<?php  }?>


				$("#small_catelist").html(node);
        })
	}
	function checkform(theform)
	{
		if(theform.subject.value=='')
		{
			alert('团购项目不能为空');
			return false;
		}
		if(theform.starttime.value=='')
		{
			alert('开始日期不能为空');
			return false;
		}
		if(theform.lasttime.value=='')
		{
			alert('结束日期不能为空');
			return false;
		}
		if(theform.siteid.value=='')
		{
			alert('所属网站不能为空');
			return false;
		}
		if(theform.big_catelist.value=='')
		{
			alert('所属分类不能为空');
			return false;
		}
		if(theform.city.value=='')
		{
			alert('所属城市不能为空');
			return false;
		}
	}

</SCRIPT>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <A HREF="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listgroup"class="on"><em>团购管理</em></A>
	</div>
</div>
<div id="man_zone">
  <form action="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=tempsitemodify"  onsubmit="return checkform(this);"  enctype="multipart/form-data"  method="post">
  <INPUT TYPE="hidden" NAME="commit" value="1">
  <INPUT TYPE="hidden" NAME="updateid" value="<?php echo $tempsite_info['id'];?>">
  <table width="100%" class="table_form">
		<tbody>
		<tr>
			<td width="80">团购项目：</td> 
			<td><input type="text" size="30"  id="subject" value="<?php echo $tempsite_info['subject'];?>" class="input-text" name="subject"></td>
		</tr>
		<tr>
			<td>短标题：</td> 
			<td><input type="text" size="30"  value="<?php echo $tempsite_info['shortsubject'];?>" id="shortsubject" class="input-text" name="shortsubject"></td>
		</tr>
		<tr>
			<td>开始日期：</td> 
			<td><input type="text" size="30"  value="<?php  if($tempsite_info['starttime'] >0) { echo $tempsite_info['starttime']; } ?>" onfocus="HS_setDate(this);"  id="starttime" class="input-text" name="starttime"></td>
		</tr>
		<tr>
			<td>结束日期：</td> 
			<td><input type="text" size="30"  value="<?php if($tempsite_info['starttime'] >0) { echo $tempsite_info['lasttime']; } ?>" onfocus="HS_setDate(this);"  id="lasttime" class="input-text" name="lasttime"></td>
		</tr>
		<tr>
			<td>所属网站：</td>
			<td>
				<select name="siteid"  id="siteid" >
					<?php  foreach($GLOBALS['site'] AS $key => $val){  ?>	
					<option value="<?php  echo  $key; ?>" <?php  if($key == $tempsite_info['siteid']){ echo "selected";  }  ?>   ><?php  echo  $val['sitename']; ?></option>
					<?php  }  ?>
				</select>
		</tr>

		<tr>
			<td>所属城市：</td>
			<td>
				<select name="city" id="city"  onchange="get_bizgroup();" >
					<option value="0">请选择</option>
					<?php  foreach($GLOBALS['city'] AS $key => $val){  ?>	
					<option value="<?php  echo  $key; ?>"  <?php  if($key == $tempsite_info['cityid']){ echo "selected";}   ?>   ><?php  echo  $key; ?>-<?php  echo  $val['cityname']; ?></option>
					<?php  }  ?>
				</select>		
			</td>
		</tr>

		<tr>
			<td>所属商圈：</td>
			<td>
				<select name="bizgroup" id="bizgroup" >
					<option value="0">请选择城市</option>
				</select><?php echo $tempsite_info['bizname'];?>	
			</td>
		</tr>

		<tr>
			<td>大分类：</td>
			<td>
				<select name="big_catelist"  id="big_catelist" onchange="get_catelist();"  > 
					<option value="0">请选择</option>
					<?php  foreach($GLOBALS['cate'] AS $key => $val){  ?>	
					<option value="<?php  echo  $key; ?>"  <?php  if( $key ==  $tempsite_info['big_catelist']){ echo "selected";}   ?>  ><?php  echo  $val['catename']; ?></option>
					<?php  }  ?>
				</select>
			</td>
		</tr>
		<tr>
			<td>小分类：</td>
			<td>
				<select name="small_catelist" id="small_catelist" >	
					<option value="0">请选择大分类</option>
				</select>		
			</td>
		</tr>

		<tr>
			<td>缩略图：</td>
			<td>
            <input type="file" name="thumb">
			<?php
			
				if($tempsite_info['thumb'])
				{
                     echo "<img src='".$tempsite_info['thumb']."' height='100px'>";
				}
			?>
			</td>
		</tr>

		<tr>
			<td>访问地址：</td>
			<td><input type="text" size="30" id="url" class="input-text" value="<?php echo $tempsite_info['url'];?>" name="url" ></td>
		</tr>
		

		<tr>
			<td>原价：</td>
			<td><input type="text" size="30" id="oldprice" class="input-text" value="<?php echo $tempsite_info['oldprice'];?>" name="oldprice"></td>
		</tr>

		<tr>
			<td>现价：</td>
			<td><input type="text" size="30" id="nowprice" class="input-text" value="<?php echo $tempsite_info['nowprice'];?>" name="nowprice"></td>
		</tr>

		<tr>
			<td>当前购买人数：</td>
			<td><input type="text" size="30" id="nowpeople" class="input-text" value="<?php echo $tempsite_info['nowpeople'];?>" name="nowpeople"></td>
		</tr>

		<tr>
			<td>人气：</td>
			<td><input type="text" size="30" id="hits" class="input-text" value="<?php echo $tempsite_info['hits'];?>" name="hits"></td>
		</tr>

		<tr>
			<td>关键字：</td>
			<td><input type="text" size="30" id="keyword" class="input-text" value="<?php echo $tempsite_info['keyword'];?>" name="keyword"></td>
		</tr>

		<tr>
			<td>排序：</td>
			<td><input type="text" size="30" id="sortorder" class="input-text" value="<?php echo $tempsite_info['sortorder'];?>" name="sortorder"></td>
		</tr>

		<tr>
			<td>通过审核?：</td>
			<td><input type="radio" checked="" value="1" name="ispassed">通过&nbsp;<input type="radio" value="0" name="ispassed">不通过</td>
		</tr>

		<tr>
			<td>是否推荐?：</td>
			<td><input type="radio" checked="" value="1" name="recommend">通过&nbsp;<input type="radio" value="0" name="recommend">不通过</td>
		</tr>

		<tr>
			<td></td>
			<td>
			<INPUT TYPE="submit" class="button" value="提交">
			</td>
		</tr>
	</tbody></table>
  </FORM>
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--


	<?php  if($updateid){ ?>

		get_bizgroup();
		get_catelist();  

	<?php } ?>

//-->
</SCRIPT>
<DIV id="user_area" style="display:none;border:2px solid #ccc;width:300px;position:absolute;left:330px;top:60px;height:220px;background:#fff;z-index:10px;"></DIV>
</body>
</html>
