<%@ Page Title="" Language="C#" MasterPageFile="~/StockOut/Site1.Master" AutoEventWireup="true" CodeBehind="BatchRleaseCargo.aspx.cs" Inherits="GxHub.Wms.Abroad.Web.StockOut.BatchRleaseCargo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title><%=GetText("批量放货") %></title>
    <script type="text/javascript">
        //使用checkbox当做全选反选
        function check_all_not() {
            var check = document.getElementById("checkboxAll").checked;
            //alert(check);
            if (check == true) {
                checkAll();
            }
            else {
                checkReverse();
            }
        }

        //选择
        function checkAll() {
            $(".check ").each(function () {
                $(this).attr("checked", true);
            });
        }
        //反选
        function checkReverse() {
            $(".check ").each(function () {
                $(this).attr("checked", !($(this).attr("checked")));
            });
        }
        function checkRemove() {
            $(".check ").each(function () {
                $(this).attr("checked", false);
            });
        }
    </script>
    <script language="javascript" src="../lodop/LodopFuncs.js"></script>
    <object id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width="0"
        height="0">
        <embed id="LODOP_EM" type="application/x-print-lodop" width="0" height="0" pluginspage="../lodop/install_lodop.exe"></embed>
    </object>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <yee:MessageBox ID="msg" runat="server"></yee:MessageBox>
    <div class="subheader">
        <div class="title">
            <%=GetText("批量放货") %>
        </div>
        <div class="command">
        </div>
        <div style="clear: both;">
        </div>
    </div>
    <div class="query">
        <td>
            <%=GetText("仓储中心") %>：
        </td>
        <td>
            <yee:UserWarehousesDropDownList ID="UserWarehousesDropDownList" runat="server" WarehouseType="海外仓储">
            </yee:UserWarehousesDropDownList>
        </td>
        <td>
            <%=GetText("客户代号") %>：
        </td>
        <td>
            <asp:TextBox runat="server" ID="txtCode"></asp:TextBox>
        </td>
        <td>
            <%=GetText("箱子号") %>：
        </td>
        <td>
            <asp:TextBox runat="server" ID="txtBoxserialNo"></asp:TextBox>
        </td>
        <td>
            <asp:Button runat="server" ID="btnQuery" OnClick="btnQuery_Click" Text="搜索" CssClass="button"></asp:Button>
        </td>
    </div>
    <yee:Button ID="btnPiCut" runat="server" Text="批量扣费" OnClick="btnPiCut_Click" />
    <asp:Repeater runat="server" ID="rptBoxList" OnItemDataBound="rptBoxList_ItemDataBound" OnItemCommand="rptBoxList_ItemCommand">
        <HeaderTemplate>
            <table cellpadding="0" cellspacing="0" class="table">
                <tr>
                    <td class="tbheader" width="15px">
                        <input type="checkbox" id="checkboxAll" onclick="check_all_not()" />
                    </td>
                    <td class="tbheader" style="width: 15px">序号</td>
                    <td class="tbheader" style="width: 100px">箱子流水号</td>
                    <td class="tbheader">提货码</td>
                    <td class="tbheader">操作</td>
                </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr class="tbrow">
                <td class="tbpost">
                    <input type="checkbox" runat="server" id="cbItem" class="check" value='<%# Eval("BoxId") %>' />
                    <asp:HiddenField ID="hfBoxId" runat="server" Value='<%#Eval("BoxId") %>' />
                </td>
                <td class="tbpost">
                    <asp:Literal ID="litSort" runat="server"></asp:Literal>
                </td>
                <td class="tbpost">
                    <asp:Label ID="labBoxNo" runat="server" Text='<%# Eval("Serail") %> '></asp:Label>
                </td>
                <td class="tbpost">
                    <asp:TextBox ID="txtVerificationCode" runat="server" Text='<%# Eval("VerificationCode") %> '></asp:TextBox><a href="" target="_blank" id="hfWait" runat="server">未付款，请先支付</a>
                </td>
                <td class="tbpost">
                    <asp:LinkButton ID="lbnRemove" runat="server" Text="移除" CommandArgument='<%# Eval("BoxId") %> ' CommandName="remove"></asp:LinkButton>
                </td>
            </tr>
        </ItemTemplate>
        <AlternatingItemTemplate>
            <tr class="tbrowalter">
                <td class="tbpost">
                    <input type="checkbox" runat="server" id="cbItem" class="check" value='<%# Eval("BoxId") %>' />
                    <asp:HiddenField ID="hfBoxId" runat="server" Value='<%#Eval("BoxId") %>' />
                </td>
                <td class="tbpost">
                    <asp:Literal ID="litSort" runat="server"></asp:Literal>
                </td>
                <td class="tbpost">
                    <asp:Label ID="labBoxNo" runat="server" Text='<%# Eval("Serail") %> '></asp:Label>
                </td>
                <td class="tbpost">
                    <asp:TextBox ID="txtVerificationCode" runat="server" Text='<%# Eval("VerificationCode") %> '></asp:TextBox><a href="" target="_blank" id="hfWait" runat="server">未付款，请先支付</a>
                </td>
                <td class="tbpost">
                    <asp:LinkButton ID="lbnRemove" runat="server" Text="移除" CommandArgument='<%# Eval("BoxId") %> ' CommandName="remove"></asp:LinkButton>
                </td>
            </tr>
        </AlternatingItemTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>

    <div class="query">
        <asp:Repeater ID="rptList" runat="server" OnItemDataBound="rptList_ItemDataBound">
            <HeaderTemplate>
                <table cellpadding="0" cellspacing="0" style="text-align: center;" class="table">
                    <tr>
                        <td class="tbheader">
                            <%=GetText("库区") %>
                        </td>
                        <td class="tbheader">
                            <%=GetText("箱子流水号") %>
                        </td>
                        <td class="tbheader">
                            <%=GetText("客户代号") %>
                        </td>
                        <td class="tbheader">
                            <%=GetText("重量") %> (KG)
                        </td>
                        <td class="tbheader">
                            <%=GetText("体积") %> (m³)
                        </td>
                        <td class="tbheader">
                            <%=GetText("国际运费") %>
                        </td>
                        <td class="tbheader">
                            <%=GetText("类型") %>
                        </td>
                        <td class="tbheader">
                            <%=GetText("放货时间") %>
                        </td>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>

                <tr class="tbrow">
                    <td class="tbpost">
                        <asp:Label ID="labStorage" runat="server"></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="lblSerialno" runat="server" Text='<%#Eval("BoxSerialNo") %>'></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="lblcustomercode" runat="server" Text='<%#Eval("CustomerCode") %>'></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="lblweight" runat="server" Text='<%#Eval("AbroadBoxWeight") %>'></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="lblvolume" runat="server" Text='<%#Eval("AbroadBoxVolume") %>'></asp:Label>
                    </td>

                    <td class="tbpost">
                        <asp:Label ID="lblcn2th" runat="server" Text='<%#Eval("CN2THFreightAmount") %>'></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="labType" runat="server"></asp:Label>
                    </td>

                    <td class="tbpost">
                        <asp:Label ID="lblPayFreightOn" runat="server" Text='<%#Eval("StockOutOn") %>'></asp:Label>
                    </td>
                </tr>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <tr class="tbrowalter">
                    <td class="tbpost">
                        <asp:Label ID="labStorage" runat="server"></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="lblSerialno" runat="server" Text='<%#Eval("BoxSerialNo") %>'></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="lblcustomercode" runat="server" Text='<%#Eval("CustomerCode") %>'></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="lblweight" runat="server" Text='<%#Eval("AbroadBoxWeight") %>'></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="lblvolume" runat="server" Text='<%#Eval("AbroadBoxVolume") %>'></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="lblcn2th" runat="server" Text='<%#Eval("CN2THFreightAmount") %>'></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="labType" runat="server"></asp:Label>
                    </td>
                    <td class="tbpost">
                        <asp:Label ID="lblPayFreightOn" runat="server" Text='<%#Eval("StockOutOn") %>'></asp:Label>
                    </td>
                </tr>
            </AlternatingItemTemplate>

            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
        <yee:Button ID="btnCheck" runat="server" CssClass="button" Text="批量放货" OnClick="btnCheck_Click" />

        <asp:HiddenField ID="hfBoxIds" runat="server" ClientIDMode="Static" />
        <asp:HiddenField ID="hfLanguage" runat="server" ClientIDMode="Static" />
        <a runat="server" class="button" onclick="loda_huo_preview()" id="hyPrint">发货打印</a>
    </div>
    <script language="javascript" type="text/javascript">
        var LODOP; //声明为全局变量

        function loda_huo_preview() {
            var id = $("#hfBoxIds").val();

            $.get("../Ajax/GetBoxDetails.ashx", { id: id }, function (data) {
                CreateNormalFormPageByLoda(data);
                //LODOP.PRINT_DESIGN();
                LODOP.PREVIEW();
                //LODOP.PRINT();
            });
        }

        function loda_huo_print(id) {

            $.get("../Ajax/GetBoxDetails.ashx", { id: id }, function (data) {
                CreateNormalFormPageByLoda(data);

                LODOP.PRINT();
            });
        }

        function CreateNormalFormPageByLoda(data) {

            LODOP = getLodop(document.getElementById('LODOP'), document.getElementById('LODOP_EM'));

            var arr = eval(data);
            var len = parseInt(arr.length);
            var orderNo = "";
            var customer = "";
            var name = "";
            var warehouse = "";
            var stockouton = "";
            var stockoutname = "";
            var language = $("#hfLanguage").val();//语言版本

            var boxTitle = "箱子号";
            var codeTitle = "提货码";
            var typeTitle = "运输类型";
            var volumeTitle = "体积";
            var freightTitle = "运费";
            var customerTitle = "客户签名处";
            var adminTitle = "操作员";
            var stockTitle = "提货时间";
            var nameTitle = "客户名称";
            var customerCodeTitle = "客户代号";
            var boxInfoTitle = "箱子信息";
            if (language != "CN") {
                boxTitle = "Box number";
                codeTitle = "Code";
                typeTitle = "Type";
                volumeTitle = "Volume";
                freightTitle = "Freight";
                customerTitle = "Customer signature";
                adminTitle = "Operator";
                stockTitle = "Pickup time";
                nameTitle = "Customer Name";
                customerCodeTitle = "CustomerCode";
                boxInfoTitle = "Box information";
            }

            //PMingLiU  SimSun
            var htmlstr = "<table style=\"font-size:12px;text-align:center;font-family:SimSun;font-weight:100\"><tr><td >" + boxTitle + "</td><td >" + codeTitle + "&nbsp;</td><td >" + typeTitle + "</td></tr>";
            htmlstr += "<tr><td colspan=\"3\">（" + volumeTitle + " &nbsp;&nbsp;&nbsp;&nbsp;" + freightTitle + "）</td></tr>";
            for (var i = 0; i < len; i++) {
                htmlstr += "<tr><td >" + arr[i].Serail + "&nbsp;" + arr[i].StorageCode + "</td><td >" + arr[i].VerificationCode + "</td><td >" + arr[i].FreightType + "</td></tr>";
                htmlstr += "<tr><td colspan=\"3\">（" + arr[i].PostalCode + "&nbsp;&nbsp;&nbsp;&nbsp;" + arr[i].CN2THFreightAmount + "）</td></tr>";

                if (customer == "") {
                    customer = arr[i].CustomerCode;
                }
                if (name == "") {
                    name = arr[i].CustomerName;
                }

                if (stockouton == "") {
                    stockouton = arr[i].PrintStockOutOn;
                }
                if (stockoutname == "") {
                    stockoutname = arr[i].VerificationByName;
                }
            }
            htmlstr += "</table>";

            LODOP.PRINT_INITA(-5, -5, 197, 667, "");
            LODOP.SET_PRINT_PAGESIZE(3, 520, 0, "CreateCustomPage");
            LODOP.ADD_PRINT_HTM("101.49mm", "3.604%", "55.01mm", "744.798%", htmlstr);
            LODOP.ADD_PRINT_TEXT(20, 28, 144, 25, customerTitle);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(92, 56, 75, 20, adminTitle);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(111, 25, 137, 20, stockoutname);
            LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(65, 21, 165, 29, "_ _ _ _ _ _ _ _ _ _");
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(137, 42, 100, 20, stockTitle);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(163, 20, 154, 20, stockouton);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(184, 15, 165, 29, "  _ _ _ _ _ _ _ _ _ \n");
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(219, 43, 100, 20, nameTitle);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(241, 21, 140, 25, name);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(266, 45, 100, 20, customerCodeTitle);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(286, 47, 97, 25, customer);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(339, 27, 133, 35, boxInfoTitle);
            LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
            LODOP.ADD_PRINT_TEXT(308, 16, 161, 25, "  _ _ _ _ _ _ _ _ _ \n");
            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
        };
    </script>
</asp:Content>