<%@page import="com.zky.para.Para"%>
<%@ page import="com.zky.bjca.SM4" %>
<%@ page import="cn.org.bjca.utils.Base64" %>
<%@include file="/auth.jsp"%>
<%@page language="java" contentType="text/html;charset=utf-8"%>
<jsp:useBean id="getPara" scope="application" class="com.zky.para.SyncPara"/>
<%
HashFmlBuf buf = (HashFmlBuf) request.getAttribute("indenture_buf");
    String productcode       = Common.convertNull(request.getParameter("productcode"));
    String productstate    = request.getParameter("productstate");
    String producttype     = Common.convertNull(request.getParameter("producttype"));
    String operate = (String)request.getParameter("operate");
    String qj = Common.convertNull(request.getParameter("qj"));
    Login login = (Login) request.getSession().getAttribute("login");
%>
<html>
<head>
<title>维修单位管理</title>
<link rel="stylesheet" type="text/css" href="../../css/font.css">
<script src="../../js/check.js"></script>
<link rel="stylesheet" type="text/css" href="../../js/2k3Grid.css">
<link rel="stylesheet" type="text/css" href="../../js/2k3Menu.css">
<link rel="stylesheet" type="text/css" href="../../js/2k3Dialog.css">
<style type="text/css">
select
{
   width:155px;
}
</style>
<script>
function setValue() {
<%
	if (!Common.isNull(productstate)) {
		out.println("form1.productstate.value='" + productstate + "';");
	}
	if (!Common.isNull(operate)) {
		out.println("form1.operate.value='" + operate + "';");
	}
    if (!Common.isNull(qj)) {
		out.println("form1.schoolid.value='" + qj + "';");
	}
%>	
}
function check(operate,indentureId) {
	form1.operate.value=operate;
	if (operate == "updateIndentureState") {
		var Infos = form1.Infos;
		var count = 0;
		if (Infos) {
			if (Infos.length) {
				for ( var i = 0; i < Infos.length; i++) {
					if (Infos[i].checked == true) {
						count++;
					}
				}
			} else {
				if (Infos.checked == true) {
					count++;
				}
			}
		} else {
			alert("请查询单位后进行注销!");
			return false;
		}
		if (count == 0) {
			alert("请选择要注销的维修单位!");
			return false;
		}
		if (!confirm("确定要注销已经选择的维修单位吗?")) {
			return false;
		}
		return true;
	}
	if (operate == "addIndenture") {
		form1.action = "/zhyw/wxs/addIndenture.jsp";
	}
	if (operate == "queryproductbyId") {
		form1.action = "/servlet/ProductManage?operate=queryproductbyId&productcode=" + productcode;
	}	
	if(operate=="editIndenture")
	{
		form1.action="/servlet/IndentureManage?operate=toEditIndenture&indentureId="+indentureId;
	}
	form1.button1.disabled=true;
	form1.submit();
}
function selectChange(i)
{
	form1.action = "/zhyw/wxs/indentureManage.jsp";
	form1.submit();
}
</script>
</head>
<body onload="setValue();" scroll="no">
<form name="form1" method="post" action="/servlet/IndentureManage">
<input type="hidden" name="operate" value=""/>
<table width="99%"  border="0" align="center" cellpadding="0" cellspacing="1" class="box">
  <tr>
    <td valign="top"><table width="100%" height="23"  border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="25%" background="/images/tab_search_01.jpg"><table width="100%" height="23" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td width="6%" align="right"><img src="/images/little_red.jpg" width="12" height="12"></td>
                <td width="94%" class="font12b">&nbsp;<b>维修单位管理</b></td>
              </tr>
          </table></td>
          <td width="82%" background="/images/tab_search_03.jpg"><img src="/images/tab_search_02.jpg" width="12" height="23"></td>
        </tr>
      </table> 
      <table width="100%"  border="0" align="center" cellpadding="2" cellspacing="1" class="table02">
		<tr bgcolor="#FFFFFF">		
		<td class="cell1">维修单位编号</td>
		<td class="cell2">
		<input type="text" name="indentureId" id="indentureId">
		</td>		
		<td class="cell1">维修单位名称</td>
		<td class="cell2">
			<input type="text" name="indentureName" id="indentureName">
		</td>
		<td class="cell1">联系人名称</td>
		<td class="cell2">
			<input type="text" name="indentureLinkman" id="indentureName">
		</td>
		<td class="cell1">维修单位状态</td>
		<td class="cell2">
			<select class='aselect' name="indentureState" id="indentureState">
		   		<%=Para.getProductState(getPara,"PROVIDERSTATE")%>            					
			</select> 
		</td>
		<td class="cell1">
		   <input type="image" name="button1" src="../../images1/cx.png" onClick="check('queryIndenture');"/>
		</td>
		<td class="cell2"></td>
	</tr>
</table>
</td>
</tr>
</table> 
<table width="99%" align="center">
	<tr align="left">
		<td>
			<%if(login.getSanyuan().equals("0")){ %>
			<input name="button1"  onclick="check('addIndenture');" type="image"  alt="添加" src="../../images1/tj.png"/> 
			<input name="button1"  onclick="check('updateIndentureState');" type="image"  alt="注销" src="../../images1/zx.png"/> 
	<%}else if(login.getSanyuan().equals("1")){ %>
			<input name="button1"  onclick="check('updateIndentureState');" type="image"  alt="注销" src="../../images1/zx.png"/> 
	<%}else { %>
	<input name="button1"  onclick="check('addIndenture');" type="image"  alt="添加" src="../../images1/tj.png"/> 
	<%} %>
		
		</td>
	</tr>
</table>
<%
	if (buf != null) {
		int rowcount = buf.getRowCount();
%>
<table width="99%"  border="0" align="center" cellpadding="0" cellspacing="1" class="box">
    <tr>
       <td>
			<div style="width:100%; height:385px;overflow: auto;">
  				<div id="myGrid" class="2k3Grid" borderWidth="0" contextMenu="mnuGridContextMenu" altRowColor="oldLace">
    				<div class="gridHead">
    				 <!--div align="left"><span width="5%">共检索到<%=rowcount%>条记录</span></div-->
          				<div class="gridRow">
		<span width="5px" style="text-align: center;">序号</span>
				<span width="5px" style="text-align: center;">选择项</span>
		<span>维修单位编号</span>
		<span>维修单位状态</span>
		<span>维修单位名称</span>
		<span >维修单位地址</span>
		<span>维修单位座机</span>
		<span>维修单位手机</span>
		<span>维修单位联系人</span>
		<span>联系人座机</span>
		<span>联系人手机</span>
		<span width="10px">管理</span>
		</div>
    </div>
		<div class="gridBody"> 
<%	
		for (int i=0; i<rowcount; i++) {
			String tempstate = buf.fget("indenture_state",i);
			
			String disabled = "";
			if (tempstate.equals("1")) {
				tempstate = "正常";
				disabled = "";
			} else {
				tempstate = "注销";
				disabled = "disabled";
			}
			
%>	
		<div class="gridRow">
		<span width="5px" style="text-align: center;"><%=i+1%></span>
			<span style="text-align: center;width:2px;"><input type="checkbox" name="Infos" value="<%=buf.fget("indenture_id",i)%>"></span>
		<span><%=buf.fget("indenture_id",i)%></span>
		<span><%if(tempstate.equals("注销")){ %><font color="red"><%=tempstate%></font><%} else{%><font color="green"><%=tempstate%></font><%} %></span>
		<span><%=SM4.SM4Decrypt(Base64.decode(buf.fget("indenture_name",i)))%></span>
		<span><%=buf.fget("indenture_address",i)%></span>
		<span><%=buf.fget("indenture_phone",i)%></span>
		<span><%=buf.fget("indenture_mobile",i)%></span>
		<span><%=buf.fget("indenture_linkman",i)%></span>
		<span><%=buf.fget("linkman_phone",i)%></span>
		<span><%=buf.fget("linkman_mobile",i)%></span>
		<span> 
			<%if(login.getSanyuan().equals("0")){ %>
			<a href="	/servlet/IndentureManage?operate=showIndenture&indentureId=<%=buf.fget("indenture_id",i)%>"><img border="0" src="../../images1/read_document.png" ALT="查看" style="cursor: pointer;"></a> &nbsp;&nbsp; 
		<a href="	/servlet/IndentureManage?operate=toEditIndenture&indentureId=<%=buf.fget("indenture_id",i)%>"><img border="0" src="../../images1/edit.gif" ALT="修改" style="cursor: pointer;"></a>&nbsp;&nbsp;
	   <a href="	/servlet/IndentureManage?operate=IndentureBydelete&indentureId=<%=buf.fget("indenture_id",i)%>" onclick="return confirm('确定将此记录删除?')"><img border="0" src="../../images1/delete.gif" ALT="删除" style="cursor: pointer;"/></a>&nbsp;&nbsp;
	<%}else if(login.getSanyuan().equals("1")){ %>
	<a href="	/servlet/IndentureManage?operate=showIndenture&indentureId=<%=buf.fget("indenture_id",i)%>"><img border="0" src="../../images1/read_document.png" ALT="查看" style="cursor: pointer;"></a> &nbsp;&nbsp; 
	<%}else { %>
	<a href="	/servlet/IndentureManage?operate=showIndenture&indentureId=<%=buf.fget("indenture_id",i)%>"><img border="0" src="../../images1/read_document.png" ALT="查看" style="cursor: pointer;"></a> &nbsp;&nbsp; 
		<a href="	/servlet/IndentureManage?operate=toEditIndenture&indentureId=<%=buf.fget("indenture_id",i)%>"><img border="0" src="../../images1/edit.gif" ALT="修改" style="cursor: pointer;"></a>&nbsp;&nbsp;
	   <a href="	/servlet/IndentureManage?operate=IndentureBydelete&indentureId=<%=buf.fget("indenture_id",i)%>" onclick="return confirm('确定将此记录删除?')"><img border="0" src="../../images1/delete.gif" ALT="删除" style="cursor: pointer;"/></a>&nbsp;&nbsp;
	<%} %>
		
	    </span>
		</div>
<%
		}
%>	
	                 </div>
					<!-- gridBody end -->
				</div>
				<!-- myGrid end -->
    		</div>
    <tag:PageLinkTag operate="queryIndenture"  scope="request" width="100%" align="center"/>

<%	
	}
%>	
   </td>
  </tr>
</table>
</form>			          
<%@include file="/foot.jsp"%>
</body>
</html>