<?php 
include_once(''.P.'/public/header.html');
?>

<script type="text/javascript" src="res/bootstrapplugin/jquery-bootstable.js"></script>


<script>
sid = '<?=$sid?>';
function initbody(){

	table = $('#viewshow').bootstable({
		url:'index.php?m=cog&a=upgallfile&sid='+sid+'',method:'get',checked:true,
		cellurl:'abc',fanye:false,
		columns:[{
			text:'名称',dataIndex:'filepath',align:'left'
		},{
			text:'文件大小',dataIndex:'filesize'
		},{
			text:'更新时间',dataIndex:'updatedt'
		},{
			text:'操作',dataIndex:'opt',align:'left',renderer:function(v,d){
				if(d.ishui==1){
					return '已忽略';
				}else{
					if(d.ulx==1)return '<span id="msg'+d.id+'">可更新</span>';
					if(d.ulx==0)return '<span id="msg'+d.id+'">可创建</span>';
				}
			}
		}],
		load:function(d){
			if(d.rows.length==0){
				//js.msgok('此模块已经没有文件可更新了');
			}
		}
	});
	
}
function huluess(type){
	if(gengbo){
		js.msgok('请刷新页面');
		return;
	}
	var ids = table.getchecked();
	if(!ids){
		js.msgerror('没有选中行');
		return;
	}	
	js.ajax({
		url:'index.php?m=cog&a=upghuues&sid='+sid+'',data:{ids:ids,lx:type},
		success:function(){
			table.reload();
		},
		type:'post'
	});
}
var gengbo=false;
function gengxin(o1){
	var ids = table.getchecked();
	if(!ids){
		js.msgerror('没有选中行');
		return;
	}
	uparr = [];
	var adis = ids.split(',');
	for(var i=0;i<adis.length;i++){
		if(get('msg'+adis[i]+''))uparr.push(adis[i]);
	}
	if(uparr.length==0){
		js.msgerror('选中行没有可更新的');
		return;
	}
	o1.disabled=true;
	startup(0);
}
function startup(oi){
	var len=uparr.length,wc=0;
	if(oi==len){
		js.msgok('更新完成');
		return;
	}
	if(oi==len-1)wc=1;
	gengbo = true;
	var fileid = uparr[oi];
	js.loading('更新中('+len+'/'+(oi+1)+')...',false, 60);
	js.setmsg('更新中...','', 'msg'+fileid+'');
	js.ajax({
		url:'index.php?m=cog&a=upgfile&id='+sid+'&fileid='+fileid+'&wc='+wc+'',
		success:function(res){
			if(res=='ok'){
				js.setmsg('更新成功','green', 'msg'+fileid+'');
				startup(oi+1);
			}else{
				js.setmsg(res,'red', 'msg'+fileid+'');
				js.msgerror(res);
			}
		}
	});
}
function segankey(){
	js.prompt('请输入安装key(免费模块可不设置)', function(jg,txt){
		if(jg=='yes' && txt){
			js.ajax({
				url:'index.php?m=cog&a=savekey&id='+sid+'',data:{key:txt},
				success:function(res){
					if(res=='ok'){
						table.reload();
					}
				}
			});
		}
	},'请输入');
}
</script>
<style>
.caidan{padding:10px;text-align:left;border-bottom:1px #eeeeee solid;cursor:pointer}
.caidan:hover{background-color:rgba(0,0,0,0.05)}
.caidan.active{background-color:rgba(0,0,0,0.06)}
</style>
</head>

<body style="background:#f1f1f1">

<?php 
include_once(''.P.'/public/top.html');
?>

<div align="center">

<div style="width:<?=$maxwidth?>;margin:20px 0px" align="left">
	<div style="color:#cccccc">
		<a href="?m=index" class="zhu">平台首页</a> &gt;
		<a href="" class="zhu">系统设置</a>
	</div>
	
	<div style="background-color:white;margin:20px 0px;border:1px #eeeeee solid;border-radius:5px">
	
	<table width="100%">
	<tr valign="top">
	<td>
	<div style="width:180px;background:#f9f9f9;min-height:500px;border-right:1px #f1f1f1 solid">
		
		<div class="caidan"><a href="?m=cog">◇系统设置</a></div>
		<div class="caidan active"><a href="?m=cog&type=upg">◇系统升级</a></div>
		<div class="caidan"><a href="?m=cog&type=server">◇服务端设置</a></div>
		<div class="caidan"><a href="?m=cog&type=qywx">◇企业微信设置</a></div>
		
	</div>
	</td>
	
	<td width="90%">
	

	
	<script type="text/javascript" src="res/bootstrapplugin/jquery-bootstable.js"></script>
	
	<div style="padding:10px">
		<div style="padding:5px 0px">
		<button onClick="js.back()" class="webbtn" type="button" style="border-radius:5px">&lt;返回</button>&nbsp;
		<button onClick="table.reload()" class="webbtn" type="button" style="border-radius:5px">刷新</button>&nbsp;
		<button onClick="huluess(0)" class="webbtn" type="button" style="border-radius:5px;background:gray">忽略选中文件</button>&nbsp;
		<button onClick="huluess(1)" class="webbtn" type="button" style="border-radius:5px;background:gray">取消忽略选中文件</button>&nbsp;
		<button onClick="segankey()" class="webbtn" type="button" style="border-radius:5px;background:#800000">设置安装key</button>&nbsp;
		
		<button onClick="gengxin(this)" class="webbtn" type="button" style="border-radius:5px;float:right">更新选中的文件</button>
		
		</div>
		<div class="blank10"></div>
		<div id="viewshow"></div>
		<div style="color:#aaaaaa;margin-top:5px">请根据自己情况选择对应文件升级。</div>
	</div>
	
	
	
	</td>
	</tr>	
	</table>


	</div>
</div>



<?php 
include_once(''.P.'/public/footer.html');
?>
</div>

</body>
</html>