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

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


<script>
function initbody(){
	<?php if($type=='upg'){?>
	
	table = $('#viewshow').bootstable({
		url:'index.php?m=cog&a=upgdata',method:'get',
		cellurl:'abc',fanye:false,
		columns:[{
			text:'名称',dataIndex:'name'
		},{
			text:'说明',dataIndex:'explain',align:'left'
		},{
			text:'更新时间',dataIndex:'updatedt'
		},{
			text:'价格',dataIndex:'price',renderer:function(v){
				var s='<font color=#ff6600>免费</font>';
				if(v>0)s=v+'元';
				return s;
			}
		},{
			text:'详情',dataIndex:'view'
		},{
			text:'操作',dataIndex:'opt',align:'left',renderer:function(v,d){
				if(d.isaz=='0')return '<font color=#888888>无需安装</font>';
				var s='';
				if(v==1)s='<font color=green>已安装</font> <a href="?m=cog&a=upg&sid='+jm.base64encode(d.id)+'">文件</a>';
				if(v==2)s='<a class="webbtn" href="?m=cog&a=upg&sid='+jm.base64encode(d.id)+'" class="webbtn" type="button" style="background:#800000">升级</a>';
				if(v==0)s='<a class="webbtn" href="?m=cog&a=upg&sid='+jm.base64encode(d.id)+'">安装</a>';
				return '<span id="msgshow'+d.id+'">'+s+'</span>';
			}
		}]	
	});
	<?php }?>
}
function save(o1){
	var da = js.getformdata();
	js.setmsg('保存中...');
	o1.disabled=true;
	js.ajax({
		type:'post',
		url:'?m=cog&a=savecheck',
		data:da,
		success:function(res){
			o1.disabled=false;
			if(res=='ok'){
				js.setmsg('保存成功','green');
			}else{
				js.setmsg(res);
			}
		}
	});
}

function shezhis(){
	js.prompt('请输入您服务器IP', function(jg,txt){
		if(jg=='yes' && txt){
			form('server_host').value='ws://'+txt+':6552/';
			form('server_push').value='http://127.0.0.1:6553/';
			form('server_recid').value='rockkefu';
		}
	},'服务端设置');
}
</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<?php if(isempt($type))echo ' active';?>"><a href="?m=cog">◇系统设置</a></div>
		<div class="caidan<?php if($type=='upg')echo ' active';?>"><a href="?m=cog&type=upg">◇系统升级</a></div>
		<div class="caidan<?php if($type=='server')echo ' active';?>"><a href="?m=cog&type=server">◇服务端设置</a></div>
		<div class="caidan<?php if($type=='qywx')echo ' active';?>"><a href="?m=cog&type=qywx">◇企业微信设置</a></div>
		
	</div>
	</td>
	
	<td width="90%">
	
	<?php if(isempt($type)){?>
	<div style="padding:30px 30px">
		<form name="myform">
		<table>
		<tr><td align="right" style="color:gray">系统版本：</td>
		<td ><b style="font-size:18px;color:red">开源版</b>
		
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">系统名称：</td><td><input name="title" type="text" value="<?=getconfig('title')?>" style="width:260px" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray"><font color=red>*</font>信呼官网key：</td>
		<td >
		<input placeholder="必须，否则无法升级" type="text" value="<?=$xinhukey?>" name="xinhukey" style="width:260px" class="input">
		<span style="color:#aaaaaa;">看帮助获取</span>
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">文档预览方式：</td>
		<td>
		<select name="officebj_fan" style="width:260px" class="input">
		<option value="0">编辑平台WPS</option>
		<option value="1"<?php if(getconfig('officebj_fan')=='1')echo' selected';?>>编辑平台onlyoffice</option>
		<option value="2"<?php if(getconfig('officebj_fan')=='2')echo' selected';?>>微软服务(需要域名80端口)</option>
		<option value="3"<?php if(getconfig('officebj_fan')=='3')echo' selected';?>>明道服务(需要域名80端口)</option>
		</select></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">编辑平台key：</td><td>
		<input placeholder="从文档编辑平台上获取" type="text" value="<?=getconfig('officebj_key')?>" name="officebj_key" style="width:260px" class="input">
		<span style="color:#aaaaaa;">从编辑平台获取</span>
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right"></td><td>
		<button type="button" onClick="save(this)" style="padding:8px 20px;border-radius:5px" class="webbtn" >保存</button>&nbsp;<span id="msgview"></span>
		</td></tr>
		
		</table>
		<div style="color:#aaaaaa;margin-top:10px">更多请到配置文件：webmain/webmainConfig.php下设置</div>
		</form>
	</div>
	<?php }?>
	
	
	
	<?php if($type=='upg'){?>
	<script type="text/javascript" src="res/bootstrapplugin/jquery-bootstable.js"></script>
	
	<div style="padding:10px">
		<div style="padding:5px 0px"><button onClick="table.reload()" class="webbtn" type="button" style="border-radius:5px">刷新</button></div>
		<div class="blank10"></div>
		<div id="viewshow"></div>
		<div style="color:#aaaaaa;margin-top:5px">请根据自己情况安装升级。</div>
	</div>
	<?php }?>
	
	
	
	
	<?php if($type=='server'){?>
	<div style="padding:30px 30px">
		<form name="myform">
		<input value="<?=$type?>" name="type" type="hidden">
		<table>
		
		<tr><td align="right" style="color:gray"></td><td>
		
		<input type="button" value="快速设置" onclick="shezhis()" style="background:gray;border-radius:5px" class="webbtn">
		
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">通信地址：</td><td><input name="server_host" type="text" value="<?=getconfig('server_host')?>" style="width:260px" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">服务端推送地址：</td>
		<td >
		<input type="text" value="<?=getconfig('server_push')?>" name="server_push" style="width:260px" class="input">
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">recID号：</td>
		<td >
		<input type="text" value="<?=getconfig('server_recid')?>" name="server_recid" style="width:260px" class="input">
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right"></td><td>
		<button type="button" onClick="save(this)" style="padding:8px 20px;border-radius:5px" class="webbtn" >保存</button>&nbsp;<span id="msgview"></span>
		</td></tr>
		
		</table>
		</form>
	</div>
	<?php }?>
	
	
	<?php if($type=='qywx'){?>
	<div style="padding:30px 30px">
		<form name="myform">
		<input value="<?=$type?>" name="type" type="hidden">
		<table>

		
		<tr><td align="right" style="color:gray">企业微信corpid：</td><td><input name="qywx_corpid" type="text" value="<?=getconfig('qywx_corpid')?>" style="width:260px" class="input"></td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">通讯录secret：</td>
		<td >
		<input type="text" value="<?=getconfig('qywx_secret')?>" name="qywx_secret" style="width:260px" class="input"><br>
		<font color="#888888">请到<a class="zhu" href="http://work.weixin.qq.com/" target="_blank">[企业微信]</a>个管理后台下获取[管理工具→通讯录同步助手]下获取。</font>
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right" style="color:gray">顶级部门Id：</td>
		<td >
		<input type="text" placeholder="可不设置，默认是1" value="<?=getconfig('qywx_deptid')?>" name="qywx_deptid" style="width:260px" class="input">
		</td></tr>
		<tr><td height="10"></td></tr>
		
		<tr><td align="right"></td><td>
		<button type="button" onClick="save(this)" style="padding:8px 20px;border-radius:5px" class="webbtn" >保存</button>&nbsp;<span id="msgview"></span>
		</td></tr>
		
		</table>
		</form>
	</div>
	<?php }?>
	
	
	</td>
	</tr>	
	</table>


	</div>
</div>



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

</body>
</html>