<%@ Page Language="C#" AutoEventWireup="true" CodeFile="IOTypeSummary.aspx.cs" Inherits="Stock_Report_IOTypeSummary" %>
<%@ Register Src="~/Scripts/AWGridRuntime/UserControl/ListHeader.ascx" TagPrefix="uc1" TagName="ListHeader" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <uc1:ListHeader runat="server" ID="ListHeader" />
    <script type="text/javascript">
        //搜索
        function search_grid() {
            var fg = document.getElementById("frame_grid");
            var keyword = $("#keyword").val();
            var begin_date = $("#begin_date").val();
            var end_date = $("#end_date").val();
            if (begin_date == "" || end_date == "") {
                AlertOK("必须填写起始日期与截止日期!");
                return;
            }

            var wh_ids = document.getElementsByName("wh_id");
            var wh_id = "";
            for (var i = 0; i < wh_ids.length; i++) {
                if (wh_ids[i].checked) {
                    wh_id += wh_ids[i].value + ",";
                }
            }
            if(wh_id != ""){
                wh_id = wh_id.substr(0, wh_id.length - 1);
            }

            var ic_id = $("#ic_id").val();
            var ic_code = $("#ic_code").val();
            var ic_name = $("#ic_name").val();
            if (ic_name == "") {
                ic_id = "";
                ic_code = "";
            }
            var i_code = $("#i_code").val();
            var i_name = $("#i_name").val();
            var standard = $("#standard").val();
            var free1 = $("#free1").val();
            var free2 = $("#free2").val();
            var batch = $("#batch").val();
            var layer = $("#layer").val();
            var group_by_warehouse = 0; //默认不汇总仓库
            if ($F("group_by_warehouse").checked) group_by_warehouse = 1;

            var group_by_free = 0; //默认不汇总自由项
            if ($F("group_by_free").checked) group_by_free = 1;

            var url = "IOTypeSummary_Grid.aspx?keyword=" + escape(keyword)
                    + "&begin_date=" + begin_date + "&end_date=" + end_date
                    + "&wh_id=" + wh_id + "&layer=" + layer
                    + "&group_by_warehouse=" + group_by_warehouse + "&group_by_free=" + group_by_free
                    + "&ic_id=" + ic_id + "&ic_code=" + ic_code
                    + "&i_code=" + escape(i_code) + "&i_name=" + escape(i_name) + "&standard=" + escape(standard)
                    + "&free1=" + escape(free1) + "&free2=" + escape(free2) + "&batch=" + escape(batch);
            /*
            var money_DaYu_0 = "0";
            if ($F("money_DaYu_0").checked) { money_DaYu_0 = "1"; }
            var money_DengYu_0 = "0";
            if ($F("money_DengYu_0").checked) money_DengYu_0 = "1";
            var money_XiaoYu_0 = "0";
            if ($F("money_XiaoYu_0").checked) money_XiaoYu_0 = "1";
            url += "&money_DaYu_0=" + money_DaYu_0 + "&money_DengYu_0=" + money_DengYu_0 + "&money_XiaoYu_0=" + money_XiaoYu_0;
            */
            var quan_DaYu_0 = "0";
            if ($F("quan_DaYu_0").checked) { quan_DaYu_0 = "1"; }
            var quan_DengYu_0 = "0";
            if ($F("quan_DengYu_0").checked) quan_DengYu_0 = "1";
            var quan_XiaoYu_0 = "0";
            if ($F("quan_XiaoYu_0").checked) quan_XiaoYu_0 = "1";
            url += "&quan_DaYu_0=" + quan_DaYu_0 + "&quan_DengYu_0=" + quan_DengYu_0 + "&quan_XiaoYu_0=" + quan_XiaoYu_0;

            fg.src = url;
        }
        //联查
        function modify() {
            return;
            var begin_date = $("#begin_date").val();
            var end_date = $("#end_date").val();
            var fg = document.getElementById("frame_grid"); //得到grid控件所在iframe
            var cw = fg.contentWindow;
            var wh_id = cw.aw_GetSelectRows(cw._wh_id);
            var i_id = cw.aw_GetSelectRows(cw._i_id);
            var i_code = cw.aw_GetSelectRows(cw._i_code);
            var free1 = cw.aw_GetSelectRows(cw._free1);
            var free2 = cw.aw_GetSelectRows(cw._free2);
            var batch = cw.aw_GetSelectRows(cw._batch);
            if (i_id.length == 0) {
                AlertNO('请选择要查看的记录!');
                return;
            }
            if (i_id.length > 1) {
                AlertNO('一次只可以查看一条记录!');
                return;
            }
            if (i_id == "")
                return;
            var url = '../../Stock/Report/InventoryBook_Flow.aspx?wh_id=' + wh_id
            + '&i_id=' + i_id + '&free1=' + escape(free1) + '&free2=' + escape(free2)
            + '&batch=' + escape(batch)
            + "&begin_date=" + begin_date + "&end_date=" + end_date;
            var tab_id ='Stock_IOTypeSummary_Flow_' + wh_id + i_id + escape(free1) + escape(free2) + escape(batch);
            top.OpenWindow('Activate', tab_id, i_code, url);
        }
        //选择打印模板
        function grf_print() {
            var fg = document.getElementById("frame_grid"); //得到grid控件所在iframe
            var cw = fg.contentWindow;
            choice_print_template('<%=xview["auth_code"]%>', "", cw.sql_print_detail_session_id);
        }
        //全选仓库
        function SelectAllWarehouse(val) {
            var wh_ids = document.getElementsByName("wh_id");
            for (var i = 0; i < wh_ids.length; i++) {
                wh_ids[i].checked = val;
            }
        }

    </script>
</head>
<body>
    <!--工具栏-->
    <div style="height:30px;" class="list_menu_bar">
        <input type="text" class="keyword_box" id="keyword"/>
        <a plain="true" class="easyui-linkbutton" onclick="search_grid()">搜索</a>
        <a plain="true" class="easyui-linkbutton" onclick="$('#search_win').window('open')" iconcls="icon-search">高级搜索</a>
        <a plain="true" class="easyui-linkbutton" onclick="modify()" style='display:none'>联查</a>
        <a plain="true" class="easyui-linkbutton" id="btn_print" onclick='grf_print()'>打印</a>
    </div>
    <!--Grid控件所在的iframe-->
    <%=xview["grid_frame"]%>
    <!--搜索窗口-->  
	<div id="search_win" class="easyui-dialog" title="搜索"
        data-options="modal:true,closed:false,closable: false,iconCls:'icon-search'"
        style="width:650px;height:380px;padding:10px;">
        <div style='width:620px;height:150px;border:solid 0px red;'>
            <div style='float:left;width:150px;height:120px;overflow:auto;border:solid 0px green'>
                选择仓库:
                <a href='javascript:SelectAllWarehouse(true)' style="color:green">全选</a>
                <a href='javascript:SelectAllWarehouse(false)' style="color:green">不选</a><br/>
                <%=xview["wh_box"]%>
            
            </div>
            <div style='float:left;width:420px;border:solid 0px blue;'>
		        <table style="margin:auto;">
                    <tr>
                        <td style="text-align:right">起始日期:</td>
                        <td>
                            <input type="text" class="edit_text_box" id="begin_date" style='width:120px' onclick='ShowDateControl()' value='<%=xview["begin_date"]%>'/></td>
                        <td style="text-align:right">截止日期:</td>
                        <td>
                            <input type="text" class="edit_text_box" id="end_date" style='width:120px' onclick='ShowDateControl()' value='<%=xview["end_date"]%>'/></td>
                    </tr>
                    <tr>
                        <td style="text-align:right">存货编码:</td>
                        <td>
                            <input type="hidden" class="edit_text_box" id="i_id"/>
                            <input type="text" class="edit_text_box" id="i_code" style='width:98px'/></td>
                        <td style="text-align:right">存货名称:</td>
                        <td><input type="text" class="edit_text_box" id="i_name"/></td>
                    </tr>
                    <tr>
                        <td style="text-align:right">存货分类:</td>
                        <td>
                            <input type="hidden" class="edit_text_box" id="ic_id"/>
                            <input type='hidden' class='edit_text_box' id='ic_code' value=''/>
                            <input type='text' class='edit_text_box' id='ic_name' value='' style='width:103px;'/>
                            <div class='combobox_trigger'><a href='#' id='trigger_ic_name'></a></div></td>
                        <td style="text-align:right">规格型号:</td>
                        <td><input type="text" class="edit_text_box" id="standard"/></td>
                    </tr>
                    <tr style="<%=cfg.DisplayFree1()%>">
                        <td style="text-align:right"><%=cfg.Free1Title()%>:</td>
                        <td colspan='3'>
                            <input type="text" class="edit_text_box" id="free1"/></td>
                    </tr>
                    <tr style="<%=cfg.DisplayFree2()%>">
                        <td style="text-align:right"><%=cfg.Free2Title()%>:</td>
                        <td colspan='3'>
                            <input type="text" class="edit_text_box" id="free2"/></td>
                    </tr>
                    <tr>
                        <td style="text-align:right">批次:</td>
                        <td colspan='3'>
                            <input type="text" class="edit_text_box" id="batch"/></td>
                    </tr>
		        </table>
            </div>
        </div><!-- end of 540px-->
      <br/><hr style='color:#F7F4F4;'/>
      <div style='margin-top:10px;'>
          汇总方式:
          <input type='checkbox' id='group_by_warehouse'>按仓库汇总
          <input type='checkbox' id='group_by_free'>按自由项汇总
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <span style='color:green'>收发级次:</span>
            <select id='layer'>
            <%=xview["layer_options"]%>
            </select>


      </div>
      <div style='margin-top:10px;'>
          <!--结存金额:
          <input type='checkbox' id='money_DaYu_0' checked>&gt;0
          <input type='checkbox' id='money_DengYu_0' checked>=0
          <input type='checkbox' id='money_XiaoYu_0' checked>&lt;0
          &nbsp;&nbsp;&nbsp;&nbsp;-->
          结存数量:
          <input type='checkbox' id='quan_DaYu_0' checked>&gt;0
          <input type='checkbox' id='quan_DengYu_0' checked>=0
          <input type='checkbox' id='quan_XiaoYu_0' checked>&lt;0
      </div>
        <div style="margin-top:20px;text-align:center">
            <a href="javascript:search_grid()" class="easyui-linkbutton" onclick="javascript:$('#search_win').dialog('close')">搜索</a>
        </div>
    </div>



	</div>
    <!--end of 搜索窗口--> 
    <script type="text/javascript">
        $(document).ready(function () {
            FastSearch_Warehouse(); //仓库
            FastSearch_Inventory(); //查询存货
            //查询存货分类
            $F("trigger_ic_name").onclick = function () {
                AdvancedSearch_InventoryClass($("#ic_name").val());
            };

            $F("keyword").focus();
            $F("keyword").onkeypress = function (evt) {
                evt = evt ? evt : (window.event ? window.event : null);
                if (evt.keyCode == "13") {
                    search_grid();
                }
            }
        });
    </script>
</body>
</html>
