<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>刀客建站系统   管理中心  - 软件列表 </title>
<%{include file="header.html"}%>
</head>
<body>
<h1>
<span class="action-span"><a href="index.php?act=soft.addsoft">添加新软件</a></span>
<span class="action-span1"><a href="index.php?act=index.default_page">刀客建站系统   管理中心 </a>  -  软件列表 </span>
<span style='float:right;margin-right:10px;'><img src='images/top_help.gif'><a href="http://sitepub.cn/help"> 帮助 </a></span>
<span style='float:right;margin-right:10px;'><img src='images/top_forum.gif'><a href="http://bbs.sitepub.cn"> 论坛 </a></span>
<div style="clear:both"></div>
</h1>
<div class="form-div">
  <form action="" method='GET' name="searchForm">
		<input type='hidden' name='act' value='<%{$smarty.get.act}%>'>
	 	<img src="images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />

    <select name="cat_id" id='cat_id'>
	 	<option value="0">所有分类</option>
		<%{foreach from=$out.category_res item=c_v key=c_k}%>
			<option value="<%{$c_v.parent.cat_id}%>" <%{if $smarty.get.cat_id==$c_v.parent.cat_id}%>selected=true<%{/if}%> ><%{$c_v.parent.cat_name|escape:html}%></option>
			<%{foreach from=$c_v.children item=c_v_c key=c_k_c}%>			
				<option value="<%{$c_v_c.cat_id}%>"  <%{if $smarty.get.cat_id==$c_v_c.cat_id}%>selected=true<%{/if}%> >&nbsp;&nbsp;&nbsp;&nbsp;<%{$c_v_c.cat_name|escape:html}%></option>
			<%{/foreach}%>
		<%{/foreach}%>
		</select>
		&nbsp;&nbsp;首页推荐<input type='checkbox' name='is_index_commend'  value=1 <%{if $smarty.get.is_index_commend}%>checked=true<%{/if}%> >
		分类页推荐<input type='checkbox' name='is_cat_commend'   value=1 <%{if $smarty.get.is_cat_commend}%>checked=true<%{/if}%> >
		频道页推荐<input type='checkbox' name='is_channel_commend' value=1 <%{if $smarty.get.is_channel_commend}%>checked=true<%{/if}%> >
		精品栏目推荐<input type='checkbox' name='is_elite_commend' value=1 <%{if $smarty.get.is_channel_commend}%>checked=true<%{/if}%> >
		&nbsp;&nbsp;
    软件名<input type="text" name="software_name" size="15"  value='<%{$smarty.get.software_name|escape:html}%>' id='software_name_id'/>
    <input type="submit" value=" Search " class="button" />
  </form>

</div>
<form method="post" action="index.php?act=soft.batch_handle" id='handle_form'>
  <div class="list-div" id="listDiv">
	<%{if $out.soft_arr}%>
<table >
  <tr>
    <th><input  type="checkbox" id='all_check_box'>ID<img src="images/sort_desc.gif"/></th>
    <th>软件名</th>
    <th>软件版本</th>
    <th>软件Icon</th>
    <th>软件分类</th>
    <th>首页推荐</th> 
    <th>分类页推荐</th> 
    <th>频道页推荐</th>
    <th>精品栏目推荐</th>
    <th>操作</th>
  </tr>
	  <%{foreach from=$out.soft_arr item=v key=k}%>	
		 <tr style='background-color:#FFF;' onmouseover='this.style.backgroundColor="";' onmouseout='this.style.backgroundColor="#FFF";'>
		 <td><input type="checkbox" name="checkboxes[]" value="<%{$v.software_id}%>" /><%{$v.software_id}%></td>
		 <td class="first-cell" > <span onmouseover='alert_pop_box(this,"pop_box_<%{$v.software_id}%>")' onmouseout='alert_pop_box(false,"pop_box_<%{$v.software_id}%>")'><%{$v.software_name|escape:html}%></span>
         
        <div id='pop_box_<%{$v.software_id}%>' class='pop_box'>
			<p>访问量&nbsp;:&nbsp;<b><%{$v.click_count}%></b><br>下载量&nbsp;:&nbsp;<b><%{$v.download_num}%></b></p>
            
		</div>
         
         </td>
		 <td><span><%{$v.software_version|escape:html}%></span></td>
		 <!--td align="left"><%{$v.software_brief|escape:html}%></td-->
		 <td align="center"><%{if $v.software_icon}%><img width=32 height=32 src='<%{$v.software_icon}%>'><%{else}%><span style='color:red'>暂无</span><%{/if}%></td>
		 <td align="center"><%{$v.cat_name|escape:html}%></td>
		 <td align="center"><img onclick='handle_ajax(<%{$v.software_id}%>,"is_index_commend",this)' style='cursor:pointer;' src='images/<%{if $v.is_index_commend}%>yes<%{else}%>no<%{/if}%>.gif'></td>
		 <td align="center"><img onclick='handle_ajax(<%{$v.software_id}%>,"is_cat_commend",this)' style='cursor:pointer;' src='images/<%{if $v.is_cat_commend}%>yes<%{else}%>no<%{/if}%>.gif'></td>
		 <td align="center"><img onclick='handle_ajax(<%{$v.software_id}%>,"is_channel_commend",this)' style='cursor:pointer;' src='images/<%{if $v.is_channel_commend}%>yes<%{else}%>no<%{/if}%>.gif'></td>
		 <td align="center"><img onclick='handle_ajax(<%{$v.software_id}%>,"is_elite_commend",this)' style='cursor:pointer;' src='images/<%{if $v.is_elite_commend}%>yes<%{else}%>no<%{/if}%>.gif'></td>
		 <td align="center">
		 <a href="../soft.php?software_id=<%{$v.software_id}%>" target="_blank" title="Check"><img src="images/icon_view.gif" width="16" height="16" border="0" /></a>
		 &nbsp;<a href="index.php?act=soft.updatesoft&software_id=<%{$v.software_id}%>" title="Edit"><img src="images/icon_edit.gif" width="16" height="16" border="0" /></a>
		 </td>
  		 </tr>
	<%{/foreach}%>
</table>

<table id="page-table" >
  <tr style='background-color:#FFF;' >
    <td align="right" nowrap="true">
            <div id="turn-page">
        共 <span id="totalRecords"><%{$out.page_arr.total}%></span> 款产品
        <span id="page-link">
		  <%{foreach from=$out.page_arr.thepage item=v key=k}%>	
				<%{if $k==$out.page_arr.page}%>	
					<b><%{$k}%></b>			
				<%{else}%>
				<a href="<%{$v}%>"><%{$k}%></a>			
				<%{/if}%>
			<%{/foreach}%>	
		  </span>
      </div>

    </td>
  </tr>
</table>
<%{else}%>
<div align='center'> 暂无软件</div>
<%{/if}%>

</div>

<div style="margin-left:20px">
  <input type="hidden" name="handle_value" value="" id='handle_value_id'/>
  <select name="handle_type" id="selAction" onchange="change_action(this)">
    <option value="">请选择...</option>
    <option value="is_stop">回收站</option>
    <option value="is_del">直接删除</option>
    <option value="is_index_commend">首页推荐</option>
    <option value="is_cat_commend">分类页推荐</option>
    <option value="is_channel_commend">频道页推荐</option>
    <option value="is_elite_commend">精品栏目推荐</option>
    <option value="no_is_index_commend">取消频道页推荐</option>
    <option value="no_is_cat_commend">取消分类页推荐</option>
    <option value="no_is_channel_commend">取消首页推荐</option>
    <option value="no_is_elite_commend">取消精品栏目推荐</option>
    <option value="go_cat">转移分类</option>
  </select>
  <select name="target_cat" id ='target_cat_id' style="display:none" onchange='disabled_or_en();'>
    <option value="0">请选择...</option>
	 <%{foreach from=$out.category_res item=c_v key=c_k}%>
			<option value="<%{$c_v.parent.cat_id}%>" <%{if $smarty.get.cat_id==$c_v.parent.cat_id}%>checked=true<%{/if}%> ><%{$c_v.parent.cat_name|escape:html}%></option>
			<%{foreach from=$c_v.children item=c_v_c key=c_k_c}%>			
				<option value="<%{$c_v_c.cat_id}%>"  <%{if $smarty.get.cat_id==$c_v_c.cat_id}%>checked=true<%{/if}%> >&nbsp;&nbsp;&nbsp;&nbsp;<%{$c_v_c.cat_name|escape:html}%></option>
			<%{/foreach}%>
		<%{/foreach}%>
	</select>

    <input type="submit" value=" 保存 " id="btnSubmit" name="btnSubmit" class="button" disabled="true" />
</div>
</form>
<script>
$(document).ready(function(){
	$("#all_check_box").click(
		function(){
			var _this	=	this;
			$(":checkbox").each(function(i){
				if(this.name.match('checkboxes')){
					if(_this.checked&&(!this.checked)){
						this.checked	=true;
					}else if(!(_this.checked)&&this.checked){
						this.checked	=false;
					}
				}
			});
			disabled_or_en();
		}		
	);
		
	$("#handle_form").submit(function(){
		if($("#selAction").val()=='is_del'){
			if(!window.confirm('该操作不可恢复,确定删除选中的软件?')){
				return false;	
			}		
		}
	});
});

function disabled_or_en()
{
	check_num	=	false;
	$(":checkbox").each(function(i){
		if(this.name.match('checkboxes')){
			if(this.checked){
				check_num	=	true;	
				return;
			}	
		}
	});
	check_type	=	false;
	if($("#selAction").val()){
		check_type	=	true;
	}
	if(check_type&&check_num){
			if($("#target_cat_id").css('display')=='inline'){
				if($("#target_cat_id").val()!=0){
					$("#btnSubmit")[0].disabled	=	false;	
				}else{
					$("#btnSubmit")[0].disabled	=	true;	
				}
			}else{
				$("#btnSubmit")[0].disabled	=	false;	
			}
	}else{
			$("#btnSubmit")[0].disabled	=	true;	
	}
}


$(":checkbox").each(function(i){
	if(!this.name.match('checkboxes')){
		return;
	}
	$(this).click(function(){
			disabled_or_en();
	});
});

function change_action(obj){
	$("#target_cat_id").css({display:'none'});		
	if(obj.value.match(/^no/)){
		$("#handle_value_id").val("0");
	}else if(obj.value=='go_cat'){
		$("#target_cat_id").css({display:'inline'});		
	}else if(obj.value!=''){
		$("#handle_value_id").val("1");
	}
	disabled_or_en();
}

function handle_ajax(software_id,type,obj)
{
	if(obj.src.match('yes')){
		var is_handle	=	0;
	}else{
		is_handle	=	1;
	}
	$.ajax({
		url			:	"index.php?act=soft.is_handle&software_id="+software_id+"&is_handle="+is_handle+"&handle_type="+type,
		dataType		:	"json",
		type			:	"GET",
		success		:	function(json){
					if(json=='ok'){
						if(is_handle){
							obj.src='images/yes.gif';
						}else{
							obj.src='images/no.gif';
						}
					}	
		}
	});
}
function alert_pop_box(place_obj,id)
{
		pop_box_obj	=	$("#"+id);
		if(place_obj){
			place_obj	=	$(place_obj);
		}	
		if(!place_obj){
	/*
			pop_box_obj	=	$("#pop_box_"+id);
			software_name_obj	=	$("#software_name_"+id);
			var offset		=		software_name_obj.offset();		
			pop_box_obj.animate({top:offset.top+"px",left:offset.left+'px'},{queue: false,duration: 30});	
	*/
			pop_box_obj.hide();
		}else{
			var offset		=		place_obj.offset();
			var left			=		offset.left+place_obj.width();
			left				=		left+20;
			var top			=		offset.top-11;	
			var h				=		'<div class="pop-t-l"></div><div class="pop-t-r"></div><div class="pop-b-l"></div><div class="pop-b-r"></div>';
			$(h).appendTo(pop_box_obj);
			pop_box_obj.css({top:top+"px",left:left+"px"});
			pop_box_obj.show();
//			pop_box_obj.animate({top:top+"px",left:left+"px"},{ queue: false,duration: 30});	
		}
}
</script>

</body>
</html>

