<%@ page contentType="text/html; charset=GBK"  errorPage="../error.jsp" %>
<%@ page import = "zr.zrpower.ejb.sys.UnitService" %>
<%@ page import = "zr.zrpower.entity.sys.BPIP_UNIT"%>
<%@ page import = "zr.zrpower.ejb.sys.UIService"%>
<%@ page import = "zr.zrpower.entity.sys.SessionUser"%>


<html>
<head>
<%
SessionUser user = (SessionUser)session.getAttribute("userinfo");
UIService userUI =new UIService();
UnitService unitMgr =new UnitService();
request.setCharacterEncoding("GBK");


BPIP_UNIT[] units = null;
units = unitMgr.GetRecoveryUnitList();

String strshow_data="";
     if (units!=null && units.length>0){
        strshow_data = strshow_data + "[";
        for(int i=0;i<units.length;i++){
            strshow_data = strshow_data + "[";
            strshow_data = strshow_data + "'<input type=checkbox name=select_check value="+units[i].getUNITID()+">',";
            strshow_data = strshow_data + "'"+units[i].getUNITID()+"',";

            if (i < units.length-1 )
            {
               strshow_data = strshow_data + "'"+units[i].getUNITNAME()+"'],\r\n";
            }else
            {
               strshow_data = strshow_data + "'"+units[i].getUNITNAME()+"']";
            }
        }

        strshow_data = strshow_data + "]";
    }else
    {
        strshow_data = "null";
    }

%>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title></title>
<link REL="stylesheet" type="text/css" href="../zrsysmanage/css/<%=user.getUserCSS()%>">
<SCRIPT LANGUAGE="JavaScript" src="../zrsysmanage/script/Public.js"></SCRIPT>

<link rel="stylesheet" type="text/css" media="all" href="../ZrwebGui/sigma_grid/grid/calendar/calendar-blue.css">
<script type="text/javascript" src="../ZrwebGui/sigma_grid/grid/calendar/calendar.js"></script>
<script type="text/javascript" src="../ZrwebGui/sigma_grid/grid/calendar/calendar-setup.js"></script>
<link rel="stylesheet" type="text/css" href="../ZrwebGui/sigma_grid/grid/gt_grid.css">
<link rel="stylesheet" type="text/css" href="../ZrwebGui/sigma_grid/grid/skin/vista/skinstyle.css">
<link rel="stylesheet" type="text/css" href="../ZrwebGui/sigma_grid/grid/skin/pink/skinstyle.css">
<link rel="stylesheet" type="text/css" href="../ZrwebGui/sigma_grid/grid/skin/mac/skinstyle.css">
<script type="text/javascript" src="../ZrwebGui/sigma_grid/grid/gt_msg_en.js"></script>
<script type="text/javascript" src="../ZrwebGui/sigma_grid/grid/gt_const.js"></script>
<script type="text/javascript" src="../ZrwebGui/sigma_grid/grid/gt_grid_all.js"></script>
<%if("6".equals(user.getUserWINDOWTYPE())){ %>
<LINK type="text/css" rel="stylesheet" href="../zrsysmanage/html5/css/style_tables.css">
<SCRIPT LANGUAGE="JavaScript" src="../zrsysmanage/html5/script/jquery-2.0.3.min.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="../zrsysmanage/html5/layer/layer.js"></SCRIPT>
<%}%>
<script type="text/javascript" >
var css = "<%=user.getUserCSS()%>";
var skincss = "vista";

if (css=="Blue.css")
{skincss = "vista";}
if (css=="Public.css")
{skincss = "default";}
if (css=="Window.css" || css=="nBlue.css")
{skincss = "mac";}
if (css=="Yellow.css")
{skincss = "pink";}


var grid_demo_id = "myGrid1" ;
var show_data= <%=strshow_data%>;

var dsOption= {

	fields :[
                {name : 'SID'  },
		{name : 'UNITID'  },
		{name : 'UNITNAME'  }
	],

	recordType : 'array',
	data : show_data
}



var colsOption = [

           {id: 'SID' , header: "<center>选择</center>" , width :50 , align : 'center'  },
           {id: 'UNITID' , header: "<center>单位编号</center>" , width :150 , align : 'center'  },
           {id: 'UNITNAME' , header: "<center>单位名称</center>" , width :350,  align : 'left'  }
];

Sigma.ToolFactroy.register(
	'mybutton',
	{
		cls : 'mybutton-cls',
		toolTip : '全选',
		action : function(event,grid) {selectall(); }
	}
);

var gridOption={
	id : grid_demo_id,
	width: "99%",
	height: "85%",
	container : 'gridbox',
	replaceContainer : true,
	dataset : dsOption ,
	columns : colsOption,
	pageSize : 2000,
	toolbarContent : 'mybutton',
        skin : skincss,

       showIndexColumn : true
};


<%if(!"6".equals(user.getUserWINDOWTYPE())){ %>
var mygrid=new Sigma.Grid( gridOption );
Sigma.Util.onLoad( Sigma.Grid.render(mygrid));
<%}%>
</script>

<style type="text/css">
 .mybutton-cls {
		background : url(../ZrwebGui/sigma_grid/grid/skin/select.gif) no-repeat center center;
}
</style>



</head>
<BODY class="BodyMain">
<form name="RegForm" action="UnitDel.jsp">

<%if("6".equals(user.getUserWINDOWTYPE())){ %>
  <div id="mianRole" style="height: 300px;overflow: auto;">
  <table class="bordered" id="html5_table">

<thead>
<tr>
<th style="width:5%;">序号</th>
<th style="width:8%;">选择</th>
<th style="width:40%;">单位编号</th>
<th style="width:40%;">单位名称</th>

</tr>
</thead>

<%
if (units!=null && units.length>0){
  for(int i=0;i<units.length;i++){
     %>
     <tr onclick="click_color(this,'<%=units[i].getUNITID() %>');">
        <td style="text-align:center;"><%=i+1 %></td>
        <td style="text-align:center;"><input type=checkbox name=select_check value="<%=units[i].getUNITID() %>"></td>
        <td style="text-align:center;"><%=units[i].getUNITID() %></td>
        <td style="text-align:center;"><%=units[i].getUNITNAME() %></td>



     </tr>

     <%
  }
}

 %>
</table>
</div>
  <%}else{ %>
  <div id="gridbox" style="border:0px solid #cccccc;background-color:#f3f3f3;padding:5px;height:600px;width:800px;" ></div>
  <% }%>
             <center>
             <table cellspacing="0" cellpadding="0" border='0'><tr>
                 <%if("6".equals(user.getUserWINDOWTYPE())){ %>
                   <%=userUI.ClickButton("全选","JavaScript:selectall();","buttonReturn.gif",user.getUserImage())%>
                <%}%>
                 <%=userUI.ClickButton("清空","JavaScript:Check()","buttonDelete.gif",user.getUserImage())%>
                 <%=userUI.ClickButton("还原","JavaScript:Check1()","buttonReturn.gif",user.getUserImage())%>
               </tr></table>
              </center>


</form>
</BODY>
<script language="JavaScript" type="text/JavaScript">
<!--
<%if("6".equals(user.getUserWINDOWTYPE())){ %>
 var h=$(document.body).height();//浏览器当前窗口文档body的高度
 h=h*1-100;
 $('div').css('height',h);

var allvalue="";
function clickValue(value){
    allvalue=value;
}
<%}%>

function Check(){
 var str=document.getElementsByName("select_check");
    var objarray=str.length;
    var chestr="";
    for (i=0;i<objarray;i++)
    {
      if(str[i].checked == true)
      {
        if (chestr=="")
        {
          chestr = str[i].value;
        }else
        {chestr = chestr + "," + str[i].value;}
      }
    }

 if(chestr==""){
     <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择要清空的记录!', {icon: 7});
    <%}else{%>
        alert("请先选择要清空的记录！");
    <%}%>

 }
 else{
    if (confirm("将删除所有关联信息,确定要删除吗？"))
    {
       location.href="UnitDel.jsp?ID="+chestr+"&TYPE=Del";
    }
  }
}
function Check1(){
   var str=document.getElementsByName("select_check");
    var objarray=str.length;
    var chestr="";
    for (i=0;i<objarray;i++)
    {
      if(str[i].checked == true)
      {
        if (chestr=="")
        {
          chestr = str[i].value;
        }else
        {chestr = chestr + "," + str[i].value;}
      }
    }

  if(chestr==""){
     <%if("6".equals(user.getUserWINDOWTYPE())){ %>
        layer.alert('请先选择要还原的记录!', {icon: 7});
    <%}else{%>
        alert("请先选择要还原的记录！");
    <%}%>
  }else{

     location.href="UnitDel.jsp?ID="+chestr+"&TYPE=Restore";
  }

}
//-->
</script>
<script language="JavaScript" type="text/JavaScript">

function selectall(){
  var chkList=document.getElementsByName("select_check");
  var setcheck;

  if (chkList.length>0)
  {
    if (chkList[0].checked){
       setcheck = false;
    }else{
       setcheck = true;
    }
  }

  for(i=0;i<chkList.length;i++)
  {

    chkList[i].checked=setcheck;
  }
}

</script>
</HTML>
<%
user = null;
userUI = null;
unitMgr = null;
units = null;
%>
