<%@ page language="java" 
	import="java.util.*,com.zhuozhengsoft.pageoffice.*,java.sql.*,java.io.*,javax.servlet.*,javax.servlet.http.*;" 
	pageEncoding="gb2312"%>
<%@ taglib uri="http://java.pageoffice.cn" prefix="po" %>
<%
    String id=request.getParameter("id");
	String user= request.getParameter("user");
	String lz="";
    
    String fileName="";//文件名称
    String filePath="";
    String status="";//当前流程    
    
    String userName="";
    if(user.equals("ZhangSan")) userName = "张三";
    if(user.equals("LiSi")) userName = "李四";
    
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//载入驱动程序类别
	String strUrl = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=" + this.getServletContext().getRealPath("demodata/") + "\\demo.mdb";
	Connection conn = DriverManager.getConnection(strUrl);
	Statement stmt = conn.createStatement();				
    ResultSet	rs = stmt.executeQuery("select * from word where id="+id);
	if(rs.next()){
		filePath=rs.getString(2);
		fileName=rs.getString(3);
		status=rs.getString(6);
	}
	rs.close();
	stmt.close();
	conn.close();

    //******************************卓正PageOffice组件的使用*******************************
	PageOfficeCtrl poCtrl1 = new PageOfficeCtrl(request);
	poCtrl1.setServerPage("poserver.do"); //此行必须
	
	poCtrl1.setCustomMenuCaption("自定义菜单");
    poCtrl1.addCustomMenuItem("显示痕迹", "ShowRevisions", false);
    poCtrl1.addCustomMenuItem("隐藏痕迹", "HiddenRevisions", false);
    poCtrl1.addCustomMenuItem("-", "", false);
    poCtrl1.addCustomMenuItem("显示标题", "ShowTitle", true);
    poCtrl1.addCustomMenuItem("-", "", false);
    poCtrl1.addCustomMenuItem("领导圈阅", "StartHandDraw", true);
    poCtrl1.addCustomMenuItem("插入印章", "InsertSeal", false);
    poCtrl1.addCustomMenuItem("-", "", false);
    poCtrl1.addCustomMenuItem("分层显示手写批注", "ShowHandDrawDispBar", true);

    poCtrl1.addCustomToolButton("保存", "Save", 1);
    poCtrl1.addCustomToolButton("显示痕迹", "ShowRevisions", 5);
    poCtrl1.addCustomToolButton("隐藏痕迹", "HiddenRevisions", 5);
    poCtrl1.addCustomToolButton("列举所有痕迹", "jsGetAllRevisions", 0);
    poCtrl1.addCustomToolButton("领导圈阅", "StartHandDraw", 3);
    poCtrl1.addCustomToolButton("分层显示手写批注", "ShowHandDrawDispBar", 7);
    poCtrl1.addCustomToolButton("全屏/还原", "IsFullScreen", 4);
			
	poCtrl1.setSaveFilePage("savefile.jsp");
	poCtrl1.webOpen("doc/"+filePath, OpenModeType.docRevisionOnly, userName);
	poCtrl1.setTagId("PageOfficeCtrl1"); //此行必须	 																	  
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title></title>
    <link href="images/csstg.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
    //流程跳转
    function Lz(id,flag) {
    	if(flag==0){
    		location.href=encodeURI("index.jsp?id="+id+"&flg=李四批阅");
    	}
    	else 
    		location.href=encodeURI("index.jsp?id="+id+"&flg=文员清稿");	
    }
    </script>
</head>
<body>
    <form id="form2">
    <div id="header">
        <div style="float: left; margin-left: 20px;">
            <img src="images/logo.jpg" height="30" /></div>
        <ul>
            <li><a target="_blank" href="http://www.zhuozhengsoft.com">卓正网站</a></li>
            <li><a target="_blank" href="http://www.zhuozhengsoft.com/poask/index.asp">客户问吧</a></li>
            <li><a href="#">在线帮助</a></li>
            <li><a target="_blank" href="http://www.zhuozhengsoft.com/contact-us.html">联系我们</a></li>
        </ul>
    </div>
    <div id="content">
        <div id="textcontent" style="width: 1000px; height: 800px;">
            <div class="flow4">
                <a href="index.jsp">
                    <img alt="返回" src="images/return.gif" border="0" />文件列表</a> <span style="width: 100px;">
                    </span><strong>文档名称：</strong> <span style="color: Red;">
                        <span><%=fileName %></span></span> <span style="width: 100px;">
                        </span><strong>当前流程：</strong> 
                <%
                if(status.equals("张三批阅") && user.equals("ZhangSan") ){
                %>           
                        <span style="color: Red;">
                            <span><%=status %></span></span> <span style="width: 100px;">
                            </span>&nbsp;&nbsp;<strong>流转：</strong>
                <img alt="流转" src="images/arrow2.gif" border="0" />&nbsp;&nbsp;&nbsp;
                	<a href="javascript:Lz(<%=id %>,0)"><span style="color: Red;">李四批阅</span></a>
                <%
                }
                else if (status.equals("李四批阅") && user.equals("LiSi") ){
                %>
	                <span style="color: Red;">
	                            <span><%=status %></span></span> <span style="width: 100px;">
	                            </span>&nbsp;&nbsp;<strong>流转：</strong>
	                <img alt="流转" src="images/arrow2.gif" border="0" />&nbsp;&nbsp;&nbsp;
                	<a href="javascript:Lz(<%=id %>,1)"><span style="color: Red;">文员核稿</span></a>
                <%	
                }
                else{
                %>
                	<span style="color: Red;">
	                            <span>已流转到“<%=status %>”，当前是“强制留痕模式”打开文件的效果。</span>
	                            </span> 

                <%
                }
                 %>
                <span style="color: Red;"></span>
            </div>
            <!--**************   卓正 PageOffice组件 ************************-->
    <script type="text/javascript">
        function Save() {
            document.getElementById("PageOfficeCtrl1").WebSave();
        }

        //显示痕迹
        function ShowRevisions() {
            document.getElementById("PageOfficeCtrl1").ShowRevisions = true;
        }

        //隐藏痕迹
        function HiddenRevisions() {
            document.getElementById("PageOfficeCtrl1").ShowRevisions = false;
        }
        
        //领导圈阅签字
        function StartHandDraw() {
            document.getElementById("PageOfficeCtrl1").HandDraw.SetPenWidth(5);
            document.getElementById("PageOfficeCtrl1").HandDraw.Start();
        }

        //分层显示手写批注
        function ShowHandDrawDispBar() {
            document.getElementById("PageOfficeCtrl1").HandDraw.ShowLayerBar(); ;
        }

        //全屏/还原
        function IsFullScreen() {
            document.getElementById("PageOfficeCtrl1").FullScreen = !document.getElementById("PageOfficeCtrl1").FullScreen;
        }

        //显示标题
        function ShowTitle() {
            alert("该菜单的标题是：" + document.getElementById("PageOfficeCtrl1").caption);
        }

        //插入电子印章
        function InsertSeal() {
            //document.getElementById("PageOfficeCtrl1").InsertSealFromURL("images/seal02.esf");//不通过选择，直接插入指定印章
            var mDialogUrl = "images/selectSeal.htm";
            var mObject = new Object();
            mObject.SelectValue = "";
            window.showModalDialog(mDialogUrl, mObject, "dialogHeight:180px; dialogWidth:340px;center:yes;scroll:no;status:no;");
            //判断用户是否选择印章
            if (mObject.SelectValue != "") {
                document.getElementById("PageOfficeCtrl1").InsertSealFromURL("images/" + mObject.SelectValue);
            }
        }

        //获取并显示所有痕迹
        function jsGetAllRevisions() {
            var i;
            var str = "";
            for (i = 1; i <= document.getElementById("PageOfficeCtrl1").Document.Revisions.Count; i++) {
                str = str + document.getElementById("PageOfficeCtrl1").Document.Revisions.Item(i).Author;
                if (document.all("PageOfficeCtrl1").Document.Revisions.Item(i).Type == "1") {
                    str = str + ' 插入：' + document.getElementById("PageOfficeCtrl1").Document.Revisions.Item(i).Range.Text + "\r\n";
                }
                else if (document.all("PageOfficeCtrl1").Document.Revisions.Item(i).Type == "2") {
                    str = str + ' 删除：' + document.getElementById("PageOfficeCtrl1").Document.Revisions.Item(i).Range.Text + "\r\n";
                }
                else {
                    str = str + ' 调整格式或样式。';
                }
            }
            alert("当前文档的所有修改痕迹如下：\r\n" + str);
        }
    </script>
             <po:PageOfficeCtrl id="PageOfficeCtrl1" />
        </div>
    </div>
    <div id="footer">
        <hr width="1000" />
        <div>
            Copyright (c) 2012 北京卓正志远软件有限公司</div>
    </div>
    </form>
</body>
</html>
