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

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>代理在线扣费箱子列表
    </title>
    <script type="text/javascript">
        function check_all_not() {
            var check = document.getElementById("checkboxAll").checked;
            //alert(check);
            if (check == true) {
                checkAll();
            }
            else {
                checkReverse();
            }
            click_cbitem();
        }

        function checkAll() {
            $(".set-bk ").each(function () {
                var able = $(this).attr("disabled");
                if (able != 'disabled') {
                    $(this).attr("checked", "checked");
                    $(this).parent().parent().find("td").attr("style", "background-color: #C6E0B4;");
                }
            });
        }
        //反选
        function checkReverse() {
            $(".set-bk ").each(function () {
                var able = $(this).attr("disabled");
                if (able != 'disabled') {
                    $(this).attr("checked", !($(this).attr("checked")));
                    $(this).parent().parent().find("td").removeAttr("style");
                }
            });
        }
        function checkRemove() {
            $(".set-bk ").each(function () {
                var able = $(this).attr("disabled");
                if (able != 'disabled') {
                    $(this).attr("checked", false);
                    $(this).parent().parent().find("td").removeAttr("style");
                }
            });
        }

        function setRowColor(cbo) {
            if ($(cbo).is(":checked")) {
                $(cbo).parent().parent().find("td").attr("style", "background-color: #C6E0B4;");
            } else {
                $(cbo).parent().parent().find("td").removeAttr("style");
            }
            click_cbitem();

        }
        function click_cbitem() {
            var totalCredit = 0;
            var count = 0;
            $(".set-bk").each(function () {

                var a = $(this).is(":checked");

                if ($(this).is(":checked") == true) {
                    var credit = $(this).next().val();

                    if (credit == "") {
                        credit = 0;
                    }

                    totalCredit += changeTwoDecimal(parseFloat(credit));
                    count += 1;
                }

            })
            totalCredit = changeTwoDecimal(totalCredit);

            $("#labTotalSettlement").text(number_format(totalCredit, 3, ".", ","));

            $("#litSureCount").text(count);

        }
        function changeTwoDecimal(x) {
            var f_x = parseFloat(x);
            if (isNaN(f_x)) {
                alert('function:changeTwoDecimal->parameter error');
                return false;
            }
            var f_x = Math.round(x * 100) / 100;
            return f_x;
        }
        function number_format(number, decimals, dec_point, thousands_sep) {

            number = (number + '').replace(/[^0-9+-Ee.]/g, '');
            var n = !isFinite(+number) ? 0 : +number,
                  prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
                  sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
                  dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
                  s = '',
            toFixedFix = function (n, prec) {
                var k = Math.pow(10, prec);
                return '' + Math.ceil(n * k) / k;
            };
            s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
            var re = /(-?\d+)(\d{3})/;
            while (re.test(s[0])) {
                s[0] = s[0].replace(re, "$1" + sep + "$2");
            }

            if ((s[1] || '').length < prec) {
                s[1] = s[1] || '';
                s[1] += new Array(prec - s[1].length + 1).join('0');
            }
            return s.join(dec);
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <yee:PageTitle ID="pgTitle" runat="server" Title="代理在线扣费箱子列表">
    </yee:PageTitle>
    <yee:MessageBox ID="msg" runat="server">
    </yee:MessageBox>

    <div class="query">
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td>
                    <%=GetText("代理仓库") %>
                </td>
                <td>
                    <yee:UserWarehousesDropDownList ID="ddlWare" runat="server" WarehouseType="代理仓">
                    </yee:UserWarehousesDropDownList>
                </td>
                <td class="queryLeft" title="日期">到货日期:
                </td>
                <td class="queryLeft">
                    <yee:DatePicker ID="dtFrom" runat="server" IsRequired="false" />
                    -
                    <yee:DatePicker ID="dtTo" runat="server" IsRequired="false" />
                </td>

                <td class="queryLeft">
                    <%=GetText("国际单号")%>：
                </td>
                <td class="queryRight">

                    <asp:TextBox ID="txtOrderNo" runat="server"></asp:TextBox>
                </td>
                <td class="queryLeft">
                    <%=GetText("分页")%>：
                </td>
                <td class="queryRight">

                    <asp:TextBox ID="txtPage" runat="server"></asp:TextBox>
                </td>
                <td colspan="5">
                    <yee:Button ID="btnSearch" runat="server" Width="100px" ToolTip="Search" Text="查询" CssClass="button" OnClick="btnSearch_Click" />
                </td>
            </tr>
            <tr>
                <td>
                    <%=GetText("运输方式") %>
                </td>
                <td colspan="3">
                    <yee:DictionaryRadios ID="rblTypeId" runat="server" Dictionary="TransnationalFreightTypes" RepeatDirection="Horizontal" IsFirstSelected="true" IsShowAllAtFirst="true"></yee:DictionaryRadios>
                </td>
                <td class="queryLeft">
                    <%=GetText("状态")%>：
                </td>
                <td class="queryRight">
                    <asp:RadioButtonList ID="rblIsPay" runat="server" RepeatDirection="Horizontal">
                        <asp:ListItem Value="2" Text="全部"></asp:ListItem>
                        <asp:ListItem Value="1" Text="已结算"></asp:ListItem>
                        <asp:ListItem Value="0" Text="未结算" Selected="True"></asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
        </table>
    </div>

    勾选笔数：<asp:Label ID="litSureCount" runat="server" ClientIDMode="Static" Font-Size="XX-Large"></asp:Label>
    合计金额：<asp:Label ID="labTotalSettlement" Text="0.00" runat="server" ClientIDMode="Static" Font-Size="X-Large"></asp:Label>
    <div>
        <asp:Repeater ID="rptList" runat="server" OnItemDataBound="rptList_ItemDataBound" OnItemCommand="rptList_ItemCommand">
            <HeaderTemplate>
                <table cellpadding="0" cellspacing="0" border="0" class="table" style="width: 100%;">
                    <tr>
                        <td class="tbheader" style="width: 5px" rowspan="2">
                            <input type="checkbox" id="checkboxAll" onclick="check_all_not()" />
                        </td>
                        <td class="tbheader" rowspan="2">
                            <%= GetText("箱子号")%>
                        </td>
                        <td class="tbheader" rowspan="2">
                            <%=GetText("客户代号")%>
                        </td>
                        <td class="tbheader" rowspan="2">
                            <%=GetText("付款日期")%>
                        </td>
                        <td class="tbheader" colspan="2">
                            <%=GetText("国际运费")%>
                        </td>
                        <td class="tbheader" rowspan="2">
                            <%=GetText("打木箱费")%>
                        </td>
                        <td class="tbheader" rowspan="2">
                            <%=GetText("到付运费")%>
                        </td>
                        <td class="tbheader" rowspan="2">
                            <%=GetText("到付货款")%>
                        </td>
                        <td class="tbheader" rowspan="2">
                            <%=GetText("国内叉车费")%>
                        </td>
                        <td class="tbheader" rowspan="2">
                            <%=GetText("国外叉车费")%>
                        </td>
                        <td class="tbheader" rowspan="2">
                            <%=GetText("结算小计")%>
                        </td>

                        <td class="tbheader" rowspan="2">
                            <%=GetText("运输方式")%>
                        </td>
                        <td class="tbheader" rowspan="2">
                            <%=GetText("结算日期")%>
                        </td>
                    </tr>
                    <tr>
                        <td class="tbheader">
                            <%=GetText("代理报价")%>
                        </td>
                        <td class="tbheader">
                            <%=GetText("客户报价")%>
                        </td>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr class="tbrow">
                    <td class="tbpost">
                        <input type="checkbox" id="cbitem" class="set-bk" runat="server" clientidmode="Static" onclick="setRowColor(this)" />
                        <asp:HiddenField ID="hfAmount" Value='<%#Eval("TotalAmount") %>' runat="server" ClientIDMode="Static" />
                        <asp:HiddenField ID="hfUniqueId" Value='<%#Eval("UniqueId") %>' runat="server" />
                    </td>
                    <td class="tbpost">
                        <%# Eval("BoxSerialNo")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("CustomerCode")%>
                    </td>
                    <td class="tbpost">

                        <%#Eval("PayFreightOn","{0:d}")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("SettlementCost")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("CN2THFreightAmount")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("BoxCost")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("BoxFreight")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("BoxGoodPayment")%>
                    </td>

                    <td class="tbpost">
                        <%# Eval("CNForkliftFee")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("KHForkliftFee")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("totalAmount")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("freightTypeName")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("SettlementOn","{0:d}")%>
                    </td>
                </tr>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <tr class="tbrowalter">
                    <td class="tbpost">
                        <input type="checkbox" id="cbitem" class="set-bk" runat="server" clientidmode="Static" onclick="setRowColor(this)" />
                        <asp:HiddenField ID="hfAmount" Value='<%#Eval("TotalAmount") %>' runat="server" ClientIDMode="Static" />
                        <asp:HiddenField ID="hfUniqueId" Value='<%#Eval("UniqueId") %>' runat="server" />
                    </td>
                    <td class="tbpost">
                        <%# Eval("BoxSerialNo")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("CustomerCode")%>
                    </td>
                    <td class="tbpost">

                        <%#Eval("PayFreightOn","{0:d}")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("SettlementCost")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("CN2THFreightAmount")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("BoxCost")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("BoxFreight")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("BoxGoodPayment")%>
                    </td>

                    <td class="tbpost">
                        <%# Eval("CNForkliftFee")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("KHForkliftFee")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("totalAmount")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("freightTypeName")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("SettlementOn","{0:d}")%>
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    <asp:Button ID="btnCutFreight" runat="server" Text="批量结算" CssClass="button" OnClick="btnCutFreight_Click" />

    <yee:Pager ID="Pager1" PageIndex="0" PagerType="1" PageSize="20" runat="server" OnPageIndex_Changed="Pager1_PageIndex_Changed" />
</asp:Content>