<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="net.sz600.basicdata.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.tool.SzDateHelp" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.organize.*" %>
<%@ include file="/sessionInfo.jsp"%>
<% 
  String strLevel = "../../"; 
%> 
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
</head>
<%
    //获取提交的参数
    String sType = SzConvert.toZeroStr(request.getParameter("type"));
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String sPKEY = SzConvert.toZeroStr(request.getParameter("PKEY"));
    String sTable_type = "SZKC_CPFL";
%>
<%
    SzData szData = null;
    SzDataInfo szDataInfo = null;

    String sOPERATOR = request.getParameter("OPERATOR");
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    String sReadonly = "";
    boolean bReadonly = false;
    if (sOPERATOR.equals("detail")) {
        sReadonly = "readonly";
        bReadonly = true;
    }
    //读取数据
    SzCompanyInfo szCompanyInfo = null;
    SzCompany szCompany = new SzCompany();
    if (!sKEY.equals("0")) {
        szCompanyInfo = (SzCompanyInfo)szCompany.getInfoByKey(Integer.parseInt(sKEY));
    }
    if (szCompanyInfo == null) {
        szCompanyInfo = new SzCompanyInfo();
        //申请日期默认
        szCompanyInfo.setGSSQRQ(SzDateHelp.getTimeStr());
    } else {
    }
    String GSBH_SJ = SzLevelNumber.getParentNumber(szCompanyInfo.getGSBH());
    //一级公司只允许有一个
%>

<body>
<!-----上面的工具栏------>
<form name="formUpdate" method="post">
  <input type="hidden" name="PKEY" value="<%=sPKEY%>">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
  <input type="hidden" name="KEY" value="<%=sKEY%>">
  <input type="hidden" name="GSID" value="<%=szCompanyInfo.getGSID()%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="GSBH" value="<%=szCompanyInfo.getGSBH()%>">  
<%@ include file="title.jsp"%>
<table width="100%">
  <tr>
    <td>
    <% if (!bReadonly) { %>
      <%=SzPageHelp.saveButton()%>
    <% } %>
      <%=SzPageHelp.backButton()%>
    </td>
  </tr>
</table>

<!-----信息维护------>
<table width="650" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
  <tr>
    <td class="tdClassTitle">上级公司</td>
    <td colspan="3">
      <%=SzPageHelp.numberSelectTree("SZXT_JTGS","GSID","GSMC","GSBH", "1=1", "GSBH_SJ", GSBH_SJ, "txtClass2")%>    
    </td>
  </tr>  
  <tr>
    <td class="tdClassTitle">公司名称</td>
    <td colspan="3"><input type="text" name="GSMC" class="txtClass2" value="<%=szCompanyInfo.getGSMC()%>" <%=sReadonly%> ></td>
  </tr>
  <tr>
    <td class="tdClassTitle">公司地址</td>
    <td colspan="3"><input type="text" name="GSDZ" class="txtClass2" value="<%=szCompanyInfo.getGSDZ()%>" <%=sReadonly%> ></td>
  </tr>  
  <tr>
    <td class="tdClassTitle">注册资本</td>
    <td><input type="text" name="GSZB" class="txtClass1" value="<%=szCompanyInfo.getGSZB()%>" <%=sReadonly%> ></td>

    <td class="tdClassTitle">状态</td>
    <td>
      <input type="radio" name="GSZT" value="0" <% if(szCompanyInfo.getGSZT() == 0 ) { %> checked <% } %> >可用&nbsp;
      <input type="radio" name="GSZT" value="1" <% if(szCompanyInfo.getGSZT() == 1 ) { %> checked <% } %> >禁止&nbsp;
      <input type="radio" name="GSZT" value="2" <% if(szCompanyInfo.getGSZT() == 2 ) { %> checked <% } %> >待批&nbsp;    
    </td>
  </tr>
  <tr>
    <td class="tdClassTitle">申请日期</td>
    <td><input type="text" name="GSSQRQ" class="txtClass" value="<%=szCompanyInfo.getGSSQRQ()%>" <%=sReadonly%> >
    <% if (!bReadonly) { %>
        <%=SzPageHelp.calendarSelect2("formUpdate.GSSQRQ")%>
    <% } %>    
    </td>
    
    <td class="tdClassTitle">结束日期</td>
    <td><input type="text" name="GSJSRQ" class="txtClass1" value="<%=szCompanyInfo.getGSJSRQ()%>" <%=sReadonly%> >
    <% if (!bReadonly) { %>
        <%=SzPageHelp.calendarSelect2("formUpdate.GSJSRQ")%>
    <% } %>      
    </td>
  </tr>  
  <tr>
    <td class="tdClassTitle">联系人</td>
    <td><input type="text" name="GSFR" class="txtClass" value="<%=szCompanyInfo.getGSFR()%>" <%=sReadonly%> ></td>
    
    <td class="tdClassTitle">联系电话</td>
    <td><input type="text" name="GSDH" class="txtClass1" value="<%=szCompanyInfo.getGSDH()%>" <%=sReadonly%> ></td>
  </tr>
  
  <tr>
    <td class="tdClassTitle">电子邮件</td>
    <td><input type="text" name="GSYJ" class="txtClass" value="<%=szCompanyInfo.getGSYJ()%>" <%=sReadonly%> ></td>
    
    <td class="tdClassTitle">QQ或MSN</td>
    <td><input type="text" name="GSQQ" class="txtClass1" value="<%=szCompanyInfo.getGSQQ()%>" <%=sReadonly%> ></td>
  </tr>  
  <tr>
    <td class="tdClassTitle">其他说明</td>
    <td colspan="3"><input type="text" name="GSBZ" class="txtClass2" value="<%=szCompanyInfo.getGSBZ()%>" <%=sReadonly%> ></td>
  </tr> 
  <tr>
    <td class="tdClassTitle">权限标志</td>
    <td  colspan="3">
      <input type="radio" name="GSQZ" value="0" <% if(szCompanyInfo.getGSQZ() == 0 ) { %> checked <% } %> >允许总部统计数据&nbsp;
      <input type="radio" name="GSQZ" value="1" <% if(szCompanyInfo.getGSQZ() == 1 ) { %> checked <% } %> >不允许总部统计数据&nbsp;    
    </td>
  </tr>  
  <tr>
    <td class="tdClassTitle">登陆图片</td>
    <td colspan="3"><input type="text" name="GSDLTP" class="txtClass2" value="<%=szCompanyInfo.getGSDLTP()%>" <%=sReadonly%> ></td>
  </tr> 
  <tr>
    <td class="tdClassTitle">logo图片</td>
    <td colspan="3"><input type="text" name="GSLGTP" class="txtClass2" value="<%=szCompanyInfo.getGSLGTP()%>" <%=sReadonly%> ></td>
  </tr>    

  <tr>
  </tr>
  
</table>
<table width="650" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
  <tr>
    <td class="tdClassTitle">可用的模块
    
    <br><input type="checkbox" name="checkAll" value="1" OnClick="javascript:CheckAll(formUpdate, checkAll, 'QXMKID');">
      全选 
    </td>
    <td>
      <table border="0">
<%
    //读出已经设置的模块
    SzCompanyModule szCompanyModule = new SzCompanyModule();
    SzCompanyModuleInfo szCompanyModuleInfo = null;
    szCompanyModuleInfo = (SzCompanyModuleInfo)szCompanyModule.getInfoByKey(Integer.parseInt(sKEY));
    String str_MKID = "0";
    if ( szCompanyModuleInfo != null) {
    	str_MKID = "," + szCompanyModuleInfo.getQXMKID() + ",";
    }

	//读取数据
	SzModule szModule = new SzModule();
    SzModuleInfo szModuleInfo = null;    
    String sCond = "len(MKBH) <=" + 2 * SzLevelNumber.I_NUMBER_LEN;
    String sSortField = "MKBH";
    int iSortOrder = SzProperties.I_SortOrder_ASC;    
    Iterator iter = szModule.getArrayList(sCond, sSortField, iSortOrder, sSearch).iterator();
    int i = 0;
    int j = 0;
    boolean flag = false;
    while (iter != null && iter.hasNext()) {
        szModuleInfo = (SzModuleInfo)iter.next();
        
        if (szModuleInfo.getMKBH().length() == SzLevelNumber.I_NUMBER_LEN) {
        	flag = true;
        }
        //s = szModule.getPropertyName(szModuleInfo.getMKQX());
        //s2 = szModule.getPopedomName(szModuleInfo.getMKSX());
		if ( szModuleInfo.getMKMC().indexOf("集团版本") >  -1) {
			flag = false;
			continue;
		}
		if (!flag) {
			continue;
		}
		
        i++;  
/*
		if (szModuleInfo.getMKBH().length() == SzLevelNumber.I_NUMBER_LEN) {    	
			if (j>0) {
				out.println("</td>");
			}
			if (j==3) {
				out.println("</tr>");
				j = 0;
			}        	
		}        
        
        if (szModuleInfo.getMKBH().length() == SzLevelNumber.I_NUMBER_LEN) {
            if (j==0) {
            	out.println("<tr>");
            }        	
        	out.println("<td valign='top'>");
        	j++;       	
        }
*/
%>  
  <input type="checkbox" name="QXMKID", id="QXMKID" value="<%=szModuleInfo.getMKID()%>" title="<%=i%>" <% if (str_MKID.indexOf("," + szModuleInfo.getMKID() + ",") >=0) { %>checked<% } %> >
  <%=SzLevelNumber.getLevelSpace(szModuleInfo.getMKBH())%><%=szModuleInfo.getMKMC()%><br>
<%
    }
%>
      </table>
    </td>
  </tr>
</table>

</form>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="GSBH" value="<%=szCompanyInfo.getGSBH()%>">  
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">

  function FormSave(formName, url) {
    //检查是否可以保存
    if (!notSpace(formName.GSMC, "公司名称")) {
      return false;
    }
    if (!notPrice(formName.GSZB, "注册资本")) {
      return false;
    }
    //模块不能不选
    if (NumberOfCheck(formName.QXMKID) == 0) {
	  alert("至少选择一个模块");
	  return false;
    }
    
    formName.action = url;
    formName.submit();
  }
</script>
</body>
<%
    ////如果要使用日历控件，必须输出这个calendarFrame
    out.println(SzPageHelp.calendarFrame2());
%>
