<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../Include/system_language.asp" -->
<!--#include file="../Include/Version.Asp" -->
<!--#include file="CheckAdmin.Asp"-->
<!--#include file="../Html/html_Config.Asp"-->
<!--#include file="../Html/html_Function.Asp"-->
<!--#include file="../Html/html_To_Team.Asp"-->
<%
'*******************************************************
'软件名称：科蚁企业网站内容管理系统（KEYICMS）
'软件开发：成都神笔天成网络科技有限公司
'网   址：http://www.keyicms.com
'本信息不会影响您网站的正常使用，无论免费用户或是收费用户请保留这里的信息.
'神笔(15)天成网络享有软件著作权，如果您擅自删除这里的版权信息,我们将追究法律责任.
'未经公司同意禁止更改以下代码.
'*******************************************************
dim Result
Result = request.QueryString("Result")
dim ID, TeamName, ViewFlag, CommendFlag, Specialty, TeamBrief, Professional, MobileFlag, ClassSeo, SortName, SortID, SortPath
dim SeoKeywords, SeoDescription, SeoTitle
dim BigPic, Sequence, Content, OtherPic, ClickNumber, OtherDes
ID = request.QueryString("ID")
call TeamEdit()
call SiteInfo
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="<%=Keyicms_Lang_Copyright(13)%>">
<meta name="author" content="<%=Keyicms_Lang_Copyright(3)%>">
<title><%=Keyicms_Lang_Copyright(1)%> <%=Str_Soft_Version%></title>
<!--#Include file="Keyicms_css.Asp"-->
<link rel="stylesheet" href="KEditor_keyicms/themes/default/default.css" />
<script charset="utf-8" src="KEditor_keyicms/kindeditor.js"></script>
<script charset="utf-8" src="KEditor_keyicms/lang/zh_CN.js"></script>
<script>
KindEditor.ready(function(K) {
	var editor = K.create('textarea[name="Content"]', {
		cssPath : 'KEditor_keyicms/plugins/code/prettify.css',
		uploadJson : 'KEditor_keyicms/asp/upload_json.asp',
		fileManagerJson : 'KEditor_keyicms/asp/file_manager_json.asp',
		allowFileManager : true,
		afterBlur : function() {
		this.sync();
		K.ctrl(document, 13, function() {
		K('form[name=editForm]')[0].submit();
		});
		K.ctrl(this.edit.doc, 13, function() {
		K('form[name=editForm]')[0].submit();
		});
		}
	});
	K('#SmallImage').click(function() {
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				imageUrl : K('#SmallPic').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#SmallPic').val(url);
					editor.hideDialog();
				}
			});
		});
	});
	K('#BigImage').click(function() {
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				imageUrl : K('#BigPic').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#BigPic').val(url);
					$('#Pic').attr("src", url)
					editor.hideDialog();
				}
			});
		});
	});
	
	K('#selectImage').click(function() {
		editor.loadPlugin('multiimage', function() {
			var aVal=""
			editor.plugin.multiImageDialog({
				clickFn : function(urlList) {
					var div = K('#OtherPic');
					aVal = div.val()
					K.each(urlList, function(i, data) {    
                        o = '<div class="col-sm-1 col-xs-6 Otpic">'
                        o = o + '<div class="img-thumbnail">'
                        o = o + '<img src="' + data.url + '">'
                        o = o + '</div>'
                        o = o + '<input id="appendedPrependedInput" class="form-control" type="text" name="OtherPic" value="' + data.url + '"  readonly>'
                        o = o + '<input id="appendedPrependedInput" class="form-control" type="text" name="OtherDes" value="" placeholder="alt">'
                        o = o + '<div class="otsc"><div class="btn btn-default btn-xs"><i class="fa fa-arrow-circle-up"></i> 填写图片简介</div><a href="JavaScript:;" name="DelPic" class="btn btn-danger btn-xs" style=" float:right">删除</a></div>'
                        o = o + '</div>'
						K('#selectImage').before(o)
						/*if (div.val() == "")
							aVal =aVal + data.url
						else
							aVal =aVal + "|" +  data.url
					
						div.val(aVal);*/
					});
					editor.hideDialog();
				}
			});
		});
	});
});
$(function(){
	$("[name=DelPic]").live("click", function(){
		$(this).parents(".Otpic").remove()
	})
})
</script>
</head>
<body>
<!--#Include file="Keyicms_Top.Asp"-->
<div id="wrap">
	<!--#Include file="Keyicms_Meun.Asp"-->
	<%
	If InStr(CompanyAdminPurview, "|8,") = 0 Then
		response.Write ("<br /><br /><div style='height:100%; text-align:center' class='main'><font style=""color:red; font-size:14px;"")>"&Keyicms_Lang_System(26)&"</font></div>")
		response.End
	End If
	%>
    <div class="main">
        <div class="row ">
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i> <%=Keyicms_Lang_Copyright(14)%></li>
                <li class="active"><a href="">功能模块</a></li>
                <li class="active">团队管理</li>
            </ol>	
        </div>	
     	<div class="row">
            <div class="col-lg-12 hideInIE8">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h2><i class="fa fa-edit"></i><span class="break"></span><strong>团队管理</strong></h2> 
                    </div>
                    <div class="panel-body">
                        <a class="ShortCut1" href="Ky_TeamEdit.Asp?Result=Add">  
                            <i class="fa fa-group"></i>
                            <div class="title">添加团队</div>
                        </a>					
                        <a class="ShortCut2" href="Ky_Team.Asp">  
                            <i class="fa fa-th-large"></i>
                            <div class="title">团队列表</div>
                        </a>	
                        <a class="ShortCut3" href="Ky_TeamSort.Asp">  
                            <i class="fa fa-sitemap"></i>
                            <div class="title">团队分类</div>
                        </a>													
                    </div>
                </div>
            </div>
        </div>
		<div class="row">
			<div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h2><i class="fa fa-gears"></i><span class="break"></span><strong><%If Result = "Add" then%>添加<%ElseIf Result = "Modify" then%>修改<%End If%>团队信息</strong></h2>
                    </div>
                    <div class="panel-body">
                    <form name="editForm" method="post" action="?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-md-2 control-label">团队名称：</label>
                            <div class="col-md-4">
                                <input name="TeamName" type="text" id="TeamName"  class="form-control"  value="<%=TeamName%>" >
                                <label class="checkbox-inline" for="ViewFlag">
                                    <input type="checkbox" id="ViewFlag" name="ViewFlag" value="1" <%if ViewFlag then response.write ("checked")%>> 显示
                                </label>                           
                                <label class="checkbox-inline" for="CommendFlag">
                                    <input type="checkbox" id="CommendFlag" name="CommendFlag" value="1" <%if CommendFlag then response.write ("checked")%>> 推荐
                                </label>
                                <%If mStatus Then%>
                                <label class="checkbox-inline" for="MobileFlag">
                                    <input type="checkbox" id="MobileFlag" name="MobileFlag" value="1" <%if MobileFlag then response.write ("checked")%>> 手机显示
                                </label>
                                <%End If%>
                            </div>
                        </div> 
                        <div class="form-group">
                            <label class="col-md-2 control-label">静态文件名：</label>
                            <div class="col-md-4">
                                <%If Result = "Add" then%>
                                <input name="ClassSeo" type="text" id="ClassSeo" class="form-control">
                                <div class="radio">
                                    <label class="radio-inline" for="oAutopinyin_1">
                                        <input name="oAutopinyin" type="radio" id="oAutopinyin_1" value="1" checked="checked"> 自动生成系统默认静态文件名<font color="red">（已填写“静态文件名”则该功能无效）</font>
                                    </label>
                                </div>
                                <%If ClassSeoISPY = True Then%>
                                <div class="radio">
                                    <label class="radio-inline" for="oAutopinyin_2">
                                        <input name="oAutopinyin" type="radio" id="oAutopinyin_2" value="2"> 将标题转换为拼音<font color="red">（已填写“静态文件名”则该功能无效）</font>
                                    </label>
                                </div>
                                <%End If%>
                                <%elseif Result = "Modify" then%>
                                <input type="text" value="<%= ClassSeo %>" class="form-control" readonly>
                                <%end if%>
                             <span class="help-block"></span>
                            </div>
                        </div> 
<!--                        <%If EnableSeo = True Then%>
                        <div class="form-group">
                            <label class="col-md-2 control-label">团队关键词：</label>
                            <div class="col-md-6">
                            <input name="SeoKeywords" type="text" id="SeoKeywords" class="form-control" value="<%=SeoKeywords%>" maxlength="250">
                                 <span class="help-block">SEO：多个关键词请用“,”半角逗号分开</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">团队描述：</label>
                            <div class="col-md-6">
                            <input name="SeoDescription" type="text" id="SeoDescription" class="form-control" value="<%=SeoDescription%>" maxlength="250">
                                 <span class="help-block">SEO：请填写团队描述</span>
                            </div>
                        </div>
                        <%End If%>-->
                        <div class="form-group">
                            <label class="col-md-2 control-label">团队类别：</label>
                            <div class="col-md-4">
                                <select size="1" class="form-control" name="SortSelect" id="SortSelect" onChange="AddSort()">
                                <option value="" valuepath="">请选择...</option>
                                <%Call TeamSort(0, 0)%>
                                </select>
                                <span class="help-block">
                                    <input name="SortID" type="hidden" id="SortID" value="<%=SortID%>" readonly class="form-control">
                                    <input name="SortPath" type="hidden" id="SortPath" value="<%=SortPath%>" readonly class="form-control">
                                </span>
                            </div>
                        </div> 
						<div class="form-group">
                            <label class="col-md-2 control-label">职位：</label>
                            <div class="col-md-2">
                                <input name="Professional" type="text" id="Professional" class="form-control" value="<%=Professional%>" maxlength="250">
                                <span class="help-block"></span>
                            </div>
                        </div>
						<div class="form-group">
                            <label class="col-md-2 control-label">特长：</label>
                            <div class="col-md-4">
                                <input name="Specialty" type="text" id="Specialty" class="form-control" value="<%=Specialty%>" maxlength="250">
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">团队图片：</label>
                            <div class="col-md-7">
                                <div class="bigpic">
									<div class="bigpicl">
                                    <div class="pickyc">
									<img src="<%=BigPic%>" onerror="this.src='ke01/img/noimg_big.gif'" id="Pic">
                                    </div>
								</div>
									<div class="bigpicr">
									<div class="Uanniu">
                                    <button type="button" id="BigImage" class="btn btn-danger btn-sm">上传图片</button>
                                    </div>
                                    <div class="Srkpic"><input type="text" id="BigPic" name="BigPic" class="form-control" value="<%=BigPic%>" readonly></div>
									 <div class="help-block">团队图片可上传团队成员的照片</div>
                                    </div>
								</div>
                            </div>
                        </div>                     

                        <div class="form-group">
                            <label class="col-md-2 control-label">更多团队图片：</label>
                            <div id="OtherPic" class="OtherPic">
                            	<%
								If OtherPic <> "" Then
								arrPic = split(OtherPic, "|")
								arrDes = split(OtherDes, "|")
								For i = 0 to ubound(arrPic)
								%>
                                <div class="col-sm-1 col-xs-6 Otpic">
                                <div class="img-thumbnail">
                                <img src="<%=arrPic(i)%>" alt="<%=arrDes(i)%>">
                                </div>
                                <input id="appendedPrependedInput" class="form-control" type="text" name="OtherPic" value="<%=arrPic(i)%>"  readonly>
                                <input id="appendedPrependedInput" class="form-control" type="text" name="OtherDes" value="<%=arrDes(i)%>" placeholder="alt">
                                <div class="otsc"><div class="btn btn-default btn-xs"><i class="fa fa-arrow-circle-up"></i> 填写图片简介</div><a href="JavaScript:;" name="DelPic" class="btn btn-danger btn-xs" style=" float:right">删除</a></div>
                                </div>
                                <%
								Next
								End If
								%>
                                <button type="button" id="selectImage" class="btn btn-info" style=" margin-left:10px;">点击增加图片</button>
                            </div>
                        </div> 
                         <div class="form-group">
                            <label class="col-md-2 control-label">简介：</label>
                            <div class="col-md-5">
                                <textarea rows="5" cols="80" name="TeamBrief" id="TeamBrief" class="form-control"><%=TeamBrief%></textarea>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">团队详细介绍：</label>
                            <div class="col-md-10">
                                <textarea name="Content" style="width:95%;height:400px;visibility:hidden;" class="form-control"><%=Server.HTMLEncode(Content)%></textarea>
                                <span class="help-block"></span>
                            </div>
                        </div>
                        <%If EnableViews = True Then%>  
                        <div class="form-group">
                            <label class="col-md-2 control-label">团队浏览数：</label>
                            <div class="col-md-3">
                                <input type="text" name="ClickNumber" id="ClickNumber" class="form-control" value="<%=ClickNumber%>" onKeyDown="OnKeyDown()" onChange="OnChange(this, <%=ClickNumber%>)" />
                                <span class="help-block">可以手动输入团队的浏览数量，不输入则为默认</span>
                            </div>
                        </div> 
                        <%End If%>
                        <div class="form-group">
                            <label class="col-md-2 control-label">团队排序：</label>
                            <div class="col-md-3">
                                <input name="Sequence" type="text" id="Sequence" class="form-control" value="<%=Sequence%>" onKeyDown="OnKeyDown()" onChange="OnChange(this, <%=ClickNumber%>)" />
                                
                                <span class="help-block">数字越小排名越靠前</span>
                            </div>
                        </div>
                        <div class="form-group button-container">
                            <div class="col-md-2 control-label"></div>
                            <div class="col-md-10">
                                <input name="submitSaveEdit" type="submit" id="submitSaveEdit" class="btn btn-danger" value="保存团队信息">
                                <input type="button" class="btn btn-success" value="<%=Keyicms_Lang_System(32)%>" onClick="history.back(-1)">
                            </div>	
                        </div>
                    </form>
                    </div>
				</div>		
			</div>
        </div>
    </div>
    <!-- end: Content -->

	<!--#Include file="Keyicms_End.Asp"-->				
</div>
<!--#Include file="Keyicms_js.Asp"-->
</body>
</html>

<%
Sub TeamEdit()
dim Action, rs, sql
Action = request.QueryString("Action")
if Action = "SaveEdit" then
	set rs = server.createobject("adodb.recordset")
	if len(trim(request.Form("TeamName")))<1 then
		Call SweetAlert("warning", "友情提示", "请填写团队名称！", "false", "history.back(-1)")
		response.end
	end If
	if Request.Form("SortID")="" and Request.Form("SortPath")="" then
		Call SweetAlert("warning", "友情提示", "请选择所属分类！", "false", "history.back(-1)")
		response.End
	end If
	if ltrim(request.Form("BigPic")) = "" then
		Call SweetAlert("warning", "友情提示", "请上传团队缩略图！", "false", "history.back(-1)")
		response.end
	end If
	if ltrim(request.Form("Content")) = "" then
		Call SweetAlert("warning", "友情提示", "请填写团队详细介绍！", "false", "history.back(-1)")
		response.end
	end If

    If Result="Add" Then
		sql="select * from keyicms_Team"
		rs.open sql,conn,1,3
		rs.addnew
		rs("TeamName") = trim(Request.Form("TeamName"))
		if Request.Form("ViewFlag") = 1 then
			rs("ViewFlag") = Request.Form("ViewFlag")
		else
			rs("ViewFlag") = 0
		end if
		if Request.Form("CommendFlag") = 1 then
			rs("CommendFlag") = Request.Form("CommendFlag")
		else
			rs("CommendFlag") = 0
		end if
		if Request.Form("MobileFlag") = 1 then
			rs("MobileFlag") = Request.Form("MobileFlag")
		else
			rs("MobileFlag") = 0
		end if
		If Request.Form("ClassSeo") = "" then
			If Request.Form("oAutopinyin") = "1" then rs("ClassSeo") = TimeToName()
			If Request.Form("oAutopinyin") = "2" then rs("ClassSeo") = Left(Pinyin(trim(request.form("TeamName"))),200)
		Else
			rs("ClassSeo") = trim(Request.form("ClassSeo"))
		End If
		rs("SortID")=Request.Form("SortID")
		rs("SortPath")=Request.Form("SortPath")
		rs("Specialty")=trim(Request.Form("Specialty"))
		rs("TeamBrief")=trim(Request.Form("TeamBrief"))
		rs("Professional")=trim(Request.Form("Professional"))
		rs("BigPic")=trim(Request.Form("BigPic"))
		rs("OtherPic")=replace(replace(Request.Form("OtherPic"), " ", ""), ",", "|")
		rs("OtherDes") = replace(replace(replace(Request.Form("OtherDes"), " ", ""), "|", ""), ",", "|")
		rs("Content") = rtrim(Request.Form("Content"))
		rs("AddTime") = now()
		rs("UpdateTime") = now()
		rs("SeoTitle") = trim(Request.Form("SeoTitle"))
		rs("SeoKeywords") = trim(Request.Form("SeoKeywords"))
		rs("SeoDescription") = trim(Request.Form("SeoDescription"))

		If EnableViews Then rs("ClickNumber") = trim(Request.Form("ClickNumber"))
		rs("Sequence") = trim(Request.Form("Sequence"))
		rs.update
		rs.close : set rs = nothing
		
		set rs = server.createobject("adodb.recordset")
		sql="select top 1 ID,ClassSeo from keyicms_Team order by ID desc"
		rs.open sql,conn,1,1
		ID = rs("ID")
		rs.close : set rs = nothing
	End If
	If Result="Modify" Then
		sql="select * from keyicms_Team where ID="&ID
		rs.open sql,conn,1,3
		rs("TeamName") = trim(Request.Form("TeamName"))
		if Request.Form("ViewFlag") = 1 then
			rs("ViewFlag") = Request.Form("ViewFlag")
		else
			rs("ViewFlag") = 0
		end if
		if Request.Form("CommendFlag") = 1 then
			rs("CommendFlag") = Request.Form("CommendFlag")
		else
			rs("CommendFlag") = 0
		end if
		if Request.Form("MobileFlag") = 1 then
			rs("MobileFlag") = Request.Form("MobileFlag")
		else
			rs("MobileFlag") = 0
		end if
		rs("SortID") = Request.Form("SortID")
		rs("SortPath") = Request.Form("SortPath")
		rs("Specialty") = trim(Request.Form("Specialty"))
		rs("TeamBrief")=trim(Request.Form("TeamBrief"))
		rs("Professional")=trim(Request.Form("Professional"))
		rs("BigPic") = trim(Request.Form("BigPic"))
		rs("OtherPic") = replace(replace(Request.Form("OtherPic"), " ", ""), ",", "|")
		rs("OtherDes") = replace(replace(replace(Request.Form("OtherDes"), " ", ""), "|", ""), ",", "|")
		rs("Content") = rtrim(Request.Form("Content"))
		rs("UpdateTime") = now()
		rs("SeoTitle") = trim(Request.Form("SeoTitle"))
		rs("SeoKeywords") = trim(Request.Form("SeoKeywords"))
		rs("SeoDescription") = trim(Request.Form("SeoDescription"))

		If EnableViews Then rs("ClickNumber") = trim(Request.Form("ClickNumber"))
		rs("Sequence") = trim(Request.Form("Sequence"))

		ID = rs("ID")
		rs.update
		rs.close : set rs = nothing
	End If

	Call HtmlEdit("Team", ID)
	Call SweetAlert("success", "操作成功", "设置成功，相关静态页面已更新！", "false", "location.replace('Ky_Team.Asp')")
else
  	if Result = "Modify" then
		set rs = server.createobject("adodb.recordset")
		sql = "select * from keyicms_Team where ID="& ID
		rs.open sql, conn, 1, 1
		if rs.bof and rs.eof then
			response.write ("<center>数据库记录读取错误！</center>")
			response.end
		end if
		TeamName = rs("TeamName")
		ViewFlag = rs("ViewFlag")
		MobileFlag = rs("MobileFlag")
		CommendFlag = rs("CommendFlag")
		Sequence = rs("Sequence")
		ClassSeo = rs("ClassSeo")&Separated&rs("ID")
		SortName=SortText(rs("SortID"))
		SortID = rs("SortID")
		SortPath = rs("SortPath")
		Specialty = rs("Specialty")
		TeamBrief = rs("TeamBrief")
		Professional = rs("Professional")
		BigPic = rs("BigPic")
		OtherPic = rs("OtherPic")
		OtherDes = rs("OtherDes")
		Content = rs("Content")
		ClickNumber = rs("ClickNumber")
		Sequence = rs("Sequence")
		SeoTitle = rs("SeoTitle")
		SeoKeywords = rs("SeoKeywords")
		SeoDescription = rs("SeoDescription")
		rs.close : set rs = nothing
	else
		ClickNumber = 10
		Sequence = 10
    end if
end if
End Sub

Function SortText(ID)
	Dim rs,sql
	set rs = Server.CreateObject("adodb.recordset")
	sql = "Select * From keyicms_TeamSort where ID="&ID
	rs.open sql, conn, 1, 1
	SortText = rs("SortName")
	rs.close : set rs = nothing
End Function

Function TeamSort(ID, ClassNum)
	Dim rs
	set rs = Server.CreateObject("adodb.recordset")
	rs.open "select * from keyicms_TeamSort where ParentID="&ID&" Order by ID asc", conn, 1, 2
	Do Until rs.eof
		If SortID = rs("ID") Then
			response.Write "<option value='"&rs("ID")&"' valuepath='"&rs("SortPath")&"' selected>"
		Else
			response.Write "<option value='"&rs("ID")&"' valuepath='"&rs("SortPath")&"'>"
		End If
		For ClassN = 1 to ClassNum
			response.Write "│"
		Next
		response.Write "│├ "&rs("SortName")
		response.Write "</option>"
		Call TeamSort(rs("ID"), ClassNum + 1)
		rs.movenext
	Loop
	rs.close : set rs = nothing
End Function
%>