<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Add.aspx.cs" Inherits="TotCms.Web.Office.Document.Add" ValidateRequest="false" %>
<!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 id="Head1" runat="server">
  <title>发起流程</title>
  <link href="../style/global.css" rel="stylesheet" type="text/css" />
  <link href="../../js/jquery-ui-1.8.10/css/ui-lightness/jquery-ui-1.8.10.custom.css" rel="stylesheet" type="text/css" />
  <link href="../../swfupload/swfupload.css" rel="stylesheet" type="text/css" />
  <style type="text/css">
  #tabs{}
  #tabs ul{ margin:0px; padding:0px;}
  #tabs li{ float:left; list-style:none; font-weight:bold; text-align:left; margin:5px 0px 5px 0px;}
  </style>
  <script type="text/javascript" src="../js/common.js"></script>
  <script src="../../js/jquery-1.5.1.min.js" type="text/javascript"></script>
  <script src="../../js/jquery-ui-1.8.10/js/jquery-ui-1.8.10.custom.min.js" type="text/javascript"></script>
  <script src="../../js/jquery-ui-1.8.10/js/i18n/jquery.ui.datepicker-zh-CN.js" type="text/javascript"></script>
  <script src="../../swfupload/swfupload.js" type="text/javascript"></script>
  <script src="js/handlers.js" type="text/javascript"></script>   
  <script src="../ActiveX/docfun.js" type="text/javascript"></script>  
    <script type="text/javascript">
      $(function () {
        $('.dates').datepicker($.datepicker.regional["zh-CN"]);
      });
      var swfu;
      window.onload = function () {
        //swf upload
        swfu = new SWFUpload({
          // Backend Settings
          upload_url: "../Upload/UploadFiles.aspx",
          post_params: {
            "ASPSESSID": "<%=Session.SessionID %>"
          },

          // File Upload Settings
          file_size_limit: "200 MB",
          file_types: "*.*",
          file_types_description: "files",
          file_upload_limit: "0",    // Zero means unlimited

          // Event Handler Settings - these functions as defined in Handlers.js
          //  The handlers are not part of SWFUpload but are part of my website and control how
          //  my website reacts to the SWFUpload events.
          file_queue_error_handler: fileQueueError,
          file_dialog_complete_handler: fileDialogComplete,
          upload_progress_handler: uploadProgress,
          upload_error_handler: uploadError,
          upload_success_handler: uploadSuccess,
          upload_complete_handler: uploadComplete,

          // Button settings
          button_image_url: "../Upload/Images/XPButtonUploadText_61x22.png",
          button_placeholder_id: "spanButtonPlaceholder",
          button_width: 61,
          button_height: 22,
          button_text: '<span class="button"></span>',
          button_text_style: '.button { font-family: 宋体; font-size: 14px; } .buttonSmall { font-size: 12px; }',
          button_text_top_padding: 1,
          button_text_left_padding: 5,

          // Flash Settings
          flash_url: "../../swfupload/swfupload.swf", // Relative to this file

          custom_settings: {
            upload_target: "divFileProgressContainer",
            upload_returnobjid: "tbAttachment"
          },

          // Debug Settings
          debug: false
        });
      }
    </script>  
    <!-- --------------------=== 调用Weboffice初始化方法 ===--------------------- -->
<script language="javascript" event="NotifyCtrlReady" for="WebOffice1">
/****************************************************
*
*	在装载完Weboffice(执行<object>...</object>)
*	控件后执行 "WebOffice1_NotifyCtrlReady"方法
*
****************************************************/
	WebOffice1_NotifyCtrlReady()
</script>

<script language="javascript" event="NotifyWordEvent(eventname)" for="WebOffice1">
<!--
 WebOffice1_NotifyWordEvent(eventname)
//-->
</script>

<script language="javascript">
  /****************************************************
  *
  *		控件初始化WebOffice方法
  *
  ****************************************************/
  function WebOffice1_NotifyCtrlReady() {
    document.all.WebOffice1.OptionFlag |= 128;
    // 新建文档
    document.all.WebOffice1.LoadOriginalFile("<%=GetUrl() %>/Template/<%=GetTemplate() %>.doc", "doc");

  }
  var flag = false;
  function menuOnClick(id) {
    var id = document.getElementById(id);
    var dis = id.style.display;
    if (dis != "none") {
      id.style.display = "none";

    } else {
      id.style.display = "block";
    }
  }
  /****************************************************
  *
  *		接收office事件处理方法
  *
  ****************************************************/
  var vNoCopy = 0;
  var vNoPrint = 0;
  var vNoSave = 0;
  var vClose = 0;
  function no_copy() {
    vNoCopy = 1;
  }
  function yes_copy() {
    vNoCopy = 0;
  }


  function no_print() {
    vNoPrint = 1;
  }
  function yes_print() {
    vNoPrint = 0;
  }


  function no_save() {
    vNoSave = 1;
  }
  function yes_save() {
    vNoSave = 0;
  }
  function EnableClose(flag) {
    vClose = flag;
  }
  function CloseWord() {

    document.all.WebOffice1.CloseDoc(0);
  }

  function WebOffice1_NotifyWordEvent(eventname) {
    if (eventname == "DocumentBeforeSave") {
      if (vNoSave) {
        document.all.WebOffice1.lContinue = 0;
        alert("此文档已经禁止保存");
      } else {
        document.all.WebOffice1.lContinue = 1;
      }
    } else if (eventname == "DocumentBeforePrint") {
      if (vNoPrint) {
        document.all.WebOffice1.lContinue = 0;
        alert("此文档已经禁止打印");
      } else {
        document.all.WebOffice1.lContinue = 1;
      }
    } else if (eventname == "WindowSelectionChange") {
      if (vNoCopy) {
        document.all.WebOffice1.lContinue = 0;
        //alert("此文档已经禁止复制");
      } else {
        document.all.WebOffice1.lContinue = 1;
      }
    } else if (eventname == "DocumentBeforeClose") {
      if (vClose == 0) {
        document.all.WebOffice1.lContinue = 0;
      } else {
        //alert("word");
        document.all.WebOffice1.lContinue = 1;
      }
    }
    //alert(eventname); 
  }

  function SaveDoc(id, docType) {
    try {
      var webObj = document.getElementById("WebOffice1");
      var returnValue;
      if (form1.tbTitle.value == "") {
        alert("标题不可为空")
        form1.tbTitle.focus();
        return false;
      }else if (form1.tbPubDate.value == "") {
        alert("起草时间不可为空")
        form1.tbPubDate.focus();
        return false;
      }
      
      webObj.HttpInit(); 		//初始化Http引擎
      // 添加相应的Post元素
      webObj.HttpAddPostString("ddFlowId", form1.ddFlowId.value);
      webObj.HttpAddPostString("classid", form1.ddClassId.value);
      webObj.HttpAddPostString("moduleid", "45");
      webObj.HttpAddPostString("preTitle", escape("起草公文："));
      webObj.HttpAddPostString("tbTitle", escape(form1.tbTitle.value));
      webObj.HttpAddPostString("tbSubhead", escape(form1.tbSubhead.value));
      webObj.HttpAddPostString("tbCode", escape(form1.tbCode.value));
      webObj.HttpAddPostString("tbWriter", escape(form1.tbWriter.value));
      webObj.HttpAddPostString("tbPubBy", escape(form1.tbPubBy.value));
      webObj.HttpAddPostString("tbKeywords", escape(form1.tbKeywords.value));
      webObj.HttpAddPostString("tbFirstSend", escape(form1.tbFirstSend.value));
      webObj.HttpAddPostString("tbSecondSend", escape(form1.tbSecondSend.value));
      webObj.HttpAddPostString("tbCopyTo", escape(form1.tbCopyTo.value));
      webObj.HttpAddPostString("ddHuanJi", escape(form1.ddHuanJi.value));
      webObj.HttpAddPostString("ddTypes", escape(form1.ddTypes.value));
      webObj.HttpAddPostString("rbEncrypt", escape(form1.rbEncrypt.value));
      webObj.HttpAddPostString("tbPrintNum", form1.tbPrintNum.value);
      webObj.HttpAddPostString("tbAttachment", escape(form1.tbAttachment.value));
      webObj.HttpAddPostString("tbIssue", escape(form1.tbIssue.value));
      webObj.HttpAddPostString("tbOfficeCheck", escape(form1.tbOfficeCheck.value));
      webObj.HttpAddPostString("tbCheckIssue", escape(form1.tbCheckIssue.value));
      webObj.HttpAddPostString("tbTypeWord", escape(form1.tbTypeWord.value));
      webObj.HttpAddPostString("tbProof", escape(form1.tbProof.value));
      webObj.HttpAddPostString("cbIsOpen", form1.cbIsOpen.value);
      webObj.HttpAddPostString("templateid", "<%=GetTemplate() %>");
      webObj.HttpAddPostString("tbCounterSign", escape(form1.tbCounterSign.value));
      webObj.HttpAddPostString("tbPubDate", escape(form1.tbPubDate.value));      

      <%=GetGetCustomFormFields() %>
      webObj.HttpAddPostCurrFile("DocContent", ""); 	// 上传文件
      returnValue = webObj.HttpPost("<%=GetUrl() %>/SaveDoc.aspx"); // 判断上传是否成功
      if ("succeed" == returnValue) {
        //alert("文件上传成功");
      } else if ("failed" == returnValue)
        alert("文件上传失败");
      return_onclick('<%=GetUrl() %>/Issue.aspx');
    } catch (e) {
      //document.write(e.Description);
      alert("异常\r\nError:" + e + "\r\nError Code:" + e.number + "\r\nError Des:" + e.description);
    }
  }
  function GetTab(id) {
    if (id == 1) {
      document.getElementById('tabs-1').style.display = 'block';
      document.getElementById('WebOffice1').width = 1;
      document.getElementById('WebOffice1').height = 1;
      document.getElementById('btndiv').style.display = 'none';
    } else {
      document.getElementById('tabs-1').style.display = 'none';
      document.getElementById('WebOffice1').width = '100%';
      document.getElementById('WebOffice1').height = 500;
      document.getElementById('btndiv').style.display = 'block';
    }
  }

  function SetBookMarkValue(bmname,bmvalue){
    document.all.WebOffice1.SetFieldValue(bmname,bmvalue, ""); 
  }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <table style="width:100%;" border="0" cellpadding="0" cellspacing="1" class="border">
      <tr class="suphead">
        <td colspan="2">起草文件</td>
    </tr>
    </table>
    <div id="tabs">
	    <ul>
		    <li><a href="javascript:GetTab(1)" class="btn_gray">基本信息</a></li>
		    <li><a href="javascript:GetTab(2)" class="btn_gray">正文信息</a></li>
	    </ul>
	    <div id="tabs-1">		  
      <table style="width:100%;" border="0" cellpadding="0" cellspacing="1" class="border">
    <tr>
      <td width="120" class="fields_text">
          选择流程：</td>
      <td class="fields_input">
        <asp:DropDownList ID="ddFlowId" runat="server">
        </asp:DropDownList>
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          公文类别：</td>
      <td class="fields_input">
        <asp:DropDownList ID="ddClassId" runat="server">
        </asp:DropDownList>
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          标题(<span style="color:#F00;">*</span>)：</td>
      <td class="fields_input">
        <input name="tbTitle" type="text" id="tbTitle" class="input_normal" onchange="SetBookMarkValue('标题',this.value)" />
          <span id="RequiredFieldValidator1" style="visibility:hidden;">请填写标题</span>
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          副标题：</td>
      <td class="fields_input">
        <input name="tbSubhead" type="text" id="tbSubhead" class="input_normal" onchange="SetBookMarkValue('副标题',this.value)" />
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          签发：</td>
      <td class="fields_input">
        <input name="tbIssue" type="text" id="tbIssue" onchange="SetBookMarkValue('签发',this.value)"  />
          &nbsp;会签：<input name="tbCounterSign" type="text" id="tbCounterSign" onchange="SetBookMarkValue('会签',this.value)" /> 
        &nbsp;</td>
    </tr>
    <tr>
      <td class="fields_text">
          办公室审核：</td>
      <td class="fields_input">
        <input name="tbOfficeCheck" type="text" id="tbOfficeCheck" onchange="SetBookMarkValue('办公室审核',this.value)" />
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          拟稿人：</td>
      <td class="fields_input">
        <input name="tbWriter" type="text"  id="tbWriter" onchange="SetBookMarkValue('拟稿人',this.value)" />
        &nbsp;文号：<input name="tbCode" type="text"   id="tbCode" onchange="SetBookMarkValue('文号',this.value);SetBookMarkValue('文号二',this.value);" />
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          核稿人：</td>
      <td class="fields_input">
        <input name="tbCheckIssue" type="text" id="tbCheckIssue" onchange="SetBookMarkValue('核稿人',this.value)" />
&nbsp;打字：<input name="tbTypeWord" type="text" id="tbTypeWord" onchange="SetBookMarkValue('打字',this.value)" />
&nbsp;校对：<input name="tbProof" type="text" id="tbProof" onchange="SetBookMarkValue('校对',this.value)" />
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          发文机关：</td>
      <td class="fields_input">
        <input name="tbPubBy" type="text" id="tbPubBy" class="input_middle" onchange="SetBookMarkValue('发文机关',this.value)" />
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          主题词：</td>
      <td class="fields_input">
        <input name="tbKeywords" type="text" id="tbKeywords" class="input_middle" onchange="SetBookMarkValue('主题词',this.value)" />
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          主送：</td>
      <td class="fields_input">
        <input name="tbFirstSend" type="text" id="tbFirstSend" class="input_middle" onchange="SetBookMarkValue('主送',this.value)" />
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          抄送：</td>
      <td class="fields_input">
        <input name="tbSecondSend" type="text" id="tbSecondSend" class="input_middle" onchange="SetBookMarkValue('抄送',this.value)" /> 
        &nbsp;</td>
    </tr>
    <tr>
      <td class="fields_text">
          抄报：</td>
      <td class="fields_input">
        <input name="tbCopyTo" type="text" id="tbCopyTo" class="input_middle" onchange="SetBookMarkValue('抄报',this.value)" />
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          自定义字段：</td>
      <td class="fields_input">
        <asp:Literal ID="liFields" runat="server" Text=" "></asp:Literal>
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          缓急：</td>
      <td class="fields_input">
        <select name="ddHuanJi" id="ddHuanJi" onchange="SetBookMarkValue('缓急',this.options[this.selectedIndex].text)">
	<option value="1">普通</option>
	<option value="2">急件</option>
	<option value="3">特急</option>
 
</select>

&nbsp;公文种类：<asp:DropDownList ID="ddTypes" runat="server">
        </asp:DropDownList>
          </td>
    </tr>
    <tr>
      <td class="fields_text">
          密级：</td>
      <td class="fields_input">
        <select name="rbEncrypt" id="rbEncrypt" RepeatLayout="Flow" onchange="SetBookMarkValue('密级',this.options[this.selectedIndex].value)">
	<option value="公开">公开</option>
  <option value="秘密">秘密</option>
	<option value="机密">机密</option>
	<option value="绝密">绝密</option>
 
</select>
      &nbsp;份数：<input name="tbPrintNum" type="text" value="1" id="tbPrintNum" class="input_mini" onchange="SetBookMarkValue('份数',this.value)" />
&nbsp;起草时间：<input name="tbPubDate" type="text"  id="tbPubDate" class="dates" onchange="SetBookMarkValue('起草时间',this.value)" />
(<span style="color:#F00;">*</span>) </td>
    </tr>

    
    <tr>
      <td class="fields_text">
          是否公开：</td>
      <td class="fields_input">
        <select name="cbIsOpen" id="cbIsOpen" onchange="SetBookMarkValue('信息公开选项',this.options[this.selectedIndex].text)">
	        <option selected="selected" value="0">请选择</option>
          <option value="1">是</option>
	        <option value="0">否</option>
 
        </select>

        (不公开的需要申请通过后才可以查看)</td>
    </tr>    
    <tr>
      <td class="fields_text">
          附件：</td>
      <td class="fields_input">     
      <div id="swfu_container" style="margin: 0px 0px;">
        <input name="tbAttachment" type="text" id="tbAttachment" class="input_middle" onchange="SetBookMarkValue('附件',this.value)" />
        <span id="spanButtonPlaceholder"></span>
        <div id="divFileProgressContainer"></div>
      </div>      
      </td>
    </tr>

  </table> 
      </div>
      <div id="tabs-2">		   
        <!-- -----------------------------== 装载weboffice控件 ==--------------------------------- -->
        <object id="WebOffice1" height="1" width="1" style='LEFT: 0px; TOP: 0px'  classid='clsid:E77E049B-23FC-4DB8-B756-60529A35FAD5' codebase='../ActiveX/weboffice_v6.0.5.0.cab#Version=6,0,5,0'>
        <param name='_ExtentX' value='6350'><param name='_ExtentY' value='6350'>
        </object>
        <!-- --------------------------------== 结束装载控件 ==----------------------------------- --> 
        <div align="center" id="btndiv" style="display:none;">
        <asp:TextBox ID="Content" runat="server" TextMode="MultiLine" CssClass="hidden"></asp:TextBox>
                  
        </div> 
      </div>
    </div>
    <div align="center" style="margin:5px auto;">
    <input name="button93" type="button" class="button_blue" onClick="return SaveDoc('293','doc')" value="确 定">
    <input type="reset" class="button_gray" id="Button2" onclick="javascript:history.back();" value="取 消" />  
    </div>
    <script type="text/javascript">
      //$("#tabs").tabs();
    </script>
    
    </form>
</body>
</html>
