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

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script language="javascript" src="../lodop/LodopFuncs.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div class="subheader">
        <div class="title">
            <%=GetText("箱子收据") %>
        </div>
        <div class="command">
            <a href="~/Freight/TransferAccount.aspx" id="btnTransfer" runat="server"><%=GetText("转账")%></a>
        </div>
        <div style="clear: both;">
        </div>
    </div>
    <yee:MessageBox ID="msg" runat="server">
    </yee:MessageBox>
    <div class="query">
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>

                <td>
                    <%=GetText("收据流水号") %>
                </td>
                <td>
                    <asp:TextBox ID="txtInvoicesNo" runat="server"></asp:TextBox>
                </td>
                <td>
                    <%=GetText("客户代号") %>
                </td>
                <td>
                    <asp:TextBox ID="txtCustomerCode" runat="server"></asp:TextBox>
                </td>
                <td>

                    <%=GetText("箱子号") %>
                </td>
                <td>
                    <asp:TextBox ID="txtBoxSerialNo" runat="server"></asp:TextBox>
                </td>

                <td>
                    <%=GetText("仓储中心") %>
                </td>
                <td>
                    <yee:UserWarehousesDropDownList ID="ddlWarehouse" runat="server"
                        WarehouseType="海外仓储">
                    </yee:UserWarehousesDropDownList>
                </td>
                <td>
                    <yee:Button ID="btnSearch" runat="server" CssClass="button" OnClick="btnSearch_Click" />
                </td>
            </tr>
            <tr>
                <td class="queryLeft">
                    <%=GetText("日期") %>：
                </td>
                <td class="queryRigth" colspan="3">
                    <yee:DatePicker ID="dpFrom" runat="server" CssClass="input-small" IsRequired="false" />
                    -
                    <yee:DatePicker ID="dpTo" runat="server" CssClass="input-small" IsRequired="false" />
                </td>
            </tr>
        </table>
    </div>
    <div class="print" id="div_2">
        <asp:Repeater ID="InvoRpt" runat="server" OnItemDataBound="InvoRpt_ItemDataBound" OnItemCommand="InvoRpt_ItemCommand">
            <HeaderTemplate>
                <table cellpadding="0" cellspacing="0" border="0" class="table" id="table">
                    <thead>
                        <tr>
                            <td class="tbheader">
                                <%=GetText("收据流水号") %>
                            </td>
                            <td class="tbheader">
                                <%=GetText("用户代号") %>
                            </td>
                            <td class="tbheader">
                                <%=GetText("费用") %>
                            </td>
                            <td class="tbheader">
                                <%=GetText("币种") %>
                            </td>
                            <td class="tbheader">
                                <%=GetText("开据时间") %>
                            </td>
                            <td class="tbheader">
                                <%=GetText("开据人") %>
                            </td>
                            <td class="tbheader">
                                <%=GetText("操作") %>
                            </td>

                            <td style="display: none"></td>
                        </tr>
                    </thead>
                    <tbody>
            </HeaderTemplate>
            <ItemTemplate>
                <tr class="tbrow">
                    <td class="tbpost">
                        <asp:HiddenField ID="hfInvoiceId" Value='<%#Eval("InvoiceId") %>' runat="server" />
                        <asp:Literal ID="lblInvoiceNo" runat="server" Text='<%#Eval("InvoiceNo") %>'></asp:Literal>
                    </td>
                    <td class="tbpost">
                        <asp:Literal ID="litCustomerCode" runat="server" Text='<%#Eval("CustomerCode") %>'></asp:Literal>
                    </td>
                    <td class="tbpost">
                        <asp:Literal ID="litBoxCost" runat="server" Text='<%#Eval("TotalFreightAmount") %>'></asp:Literal>
                    </td>
                    <td class="tbpost">
                        <asp:Literal ID="litCurrencyCode" runat="server" Text='<%#Eval("CurrencyCode") %>'></asp:Literal>
                    </td>
                    <td class="tbpost">
                        <asp:Literal ID="litCreatedOn" runat="server" Text='<%#Eval("CreatedOn") %>'></asp:Literal>
                    </td>
                    <td class="tbpost">
                        <asp:Literal ID="litCreatedName" runat="server" Text='<%#Eval("CreatedName") %>'></asp:Literal>
                    </td>
                    <td class="tbpost">
                        <asp:LinkButton ID="lbnDetail" CommandArgument='<%#Eval("InvoiceId") %>' CommandName="detail" runat="server"><%=GetText("收费详情") %></asp:LinkButton>
                        <asp:LinkButton ID="lbtnPreview" runat="server"><%=GetText("打印预览") %></asp:LinkButton>
                        <asp:LinkButton ID="lbtnprint" runat="server"><%=GetText("直接打印") %></asp:LinkButton>
                        <asp:LinkButton ID="lbtnprintA" runat="server"><%=GetText("选择打印机") %></asp:LinkButton>
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </tbody>
        </table>
            </FooterTemplate>
        </asp:Repeater>

        <asp:HiddenField ID="hfWebsite" runat="server" ClientIDMode="Static" />
    </div>

    <yee:Pager ID="Pager1" runat="server" PageSize="20" PagerType="1" OnPageIndex_Changed="Pager1_PageIndex_Changed"
        PageIndex="0" />
    <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>
    <script type="text/javascript">
        var LODOP; //声明为全局变量

        function prn2_print(ids) {

            $.post("../Ajax/InvoicesPage.aspx", { invoid: ids, print: "1" }, function (result) {
                CreateNormalFormPageNew(result);
                LODOP.PRINT();
            });
        };

        function prn2_printA(ids) {
            $.post("../Ajax/InvoicesPage.aspx", { invoid: ids }, function (result) {
                CreateNormalFormPageNew(result);
                LODOP.PRINTA();
            });
        };

        function prn2_preview(ids) {

            $.post("../Ajax/InvoicesPage.aspx", { invoid: ids }, function (result) {
                CreateNormalFormPageNew(result);
                LODOP.PREVIEW();
                //LODOP.PRINT_DESIGN();
            });

        };

        function CreateNormalFormPageNew(data) {

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

            var arr = eval(data);
            var len = parseInt(arr.length);
            var total = 0;
            var customerCode;
            var currencyCode;
            var invoiceNo;
            var invoiceDate;
            var invoiceName;
            var host = $("#hfWebsite").val();
            var htmlstr = "<table border=\"1\" width=\"700mm\"> <tr><td width=\"2%\">NO</td><td width=\"7%\">BoxNo</td><td width=\"8%\">Global Freight</td><td width=\"8%\"> Local Freight</td><td width=\"8%\">Freight Insurance</td><td width=\"5%\">Others</td><td width=\"8%\">Total Freight</td><td width=\"5%\">Remark</td></tr>";
            for (var i = 0; i < len; i++) {
                htmlstr += "<tr><td>" + (i + 1) + "</td><td >" + arr[i].BoxSerialNo + "</td><td>" + formatFloat(arr[i].CurrencyCode, arr[i].InterFreight) + "</td><td>" + formatFloat(arr[i].CurrencyCode, arr[i].LocalFreight) + "</td><td>" + formatFloat(arr[i].CurrencyCode, arr[i].InsureanceFreight) + "</td><td>" + formatFloat(arr[i].CurrencyCode, arr[i].Other) + "</td><td>" + formatFloat(arr[i].CurrencyCode, arr[i].TotalFreight) + "</td><td></td></tr>";
                total = parseFloat(arr[i].AllTotalFreight);
                customerCode = arr[i].CustomerCode;
                currencyCode = arr[i].CurrencyCode;
                invoiceDate = arr[i].InvoiceDate;
                invoiceNo = arr[i].InvoiceNo;
                invoiceName = arr[i].InvoiceName;
            }
            htmlstr += "</table>";

            var strStyle = "<style> table,td,th {border:solid 1px black;border-collapse: collapse;text-align:center} table{}</style>"

            LODOP.PRINT_INITA(0, 0, 816, 354, "打印控件");
            LODOP.SET_PRINT_PAGESIZE(1, 2100, 980, "");
            LODOP.ADD_PRINT_TEXT(12, 280, 191, 45, "Cash Receipt");
            LODOP.SET_PRINT_STYLEA(0, "FontSize", 20);
            LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
            LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
            //LODOP.ADD_PRINT_TEXT(22, 642, 100, 20, "Page #/&");
            //LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
            LODOP.ADD_PRINT_TEXT(42, 629, 123, 20, "No: " + invoiceNo);
            LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
            LODOP.ADD_PRINT_TEXT(58, 628, 128, 20, "Date: " + invoiceDate);
            LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
            LODOP.ADD_PRINT_TEXT(316, 28, 457, 20, "Note: Page 1/3 for accouting, Page 2/3 for delivery, Page 3/3 for customer");
            LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
            LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
            LODOP.ADD_PRINT_TABLE("21.96mm", 28, "189.89mm", 198, strStyle + htmlstr);
            LODOP.SET_PRINT_STYLEA(0, "ItemType", 4);
            LODOP.ADD_PRINT_TEXT(64, 30, 141, 20, "Customer:" + customerCode);
            LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
            LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
            LODOP.ADD_PRINT_TEXT(63, 416, 105, 20, "Currency:" + currencyCode);
            LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
            LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
            LODOP.ADD_PRINT_TEXT(18, 27, 193, 20, host);
            LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
            LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
            LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
            LODOP.ADD_PRINT_TEXT(286, 532, 180, 30, "Total Freight:" + formatFloat(currencyCode, total));
            LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
            LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
            LODOP.SET_PRINT_STYLEA(0, "PageIndex", "last");
            LODOP.ADD_PRINT_TEXT(315, 511, 115, 20, "Payee:" + invoiceName);
            LODOP.SET_PRINT_STYLEA(0, "PageIndex", "last");
            LODOP.ADD_PRINT_TEXT(315, 626, 126, 20, "Customer:");
            LODOP.SET_PRINT_STYLEA(0, "PageIndex", "last");
            LODOP.SET_PRINTER_INDEXA("outPrinterAB58GK");

        };

        function formatFloat(currency, amount) {
            var newAmount;
            if (currency == "IDR" || currency == "VND") {
                newAmount = amount.toFixed(0);
            }
            else {
                newAmount = amount.toFixed(2);
            }
            return newAmount;
        }
    </script>
</asp:Content>