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

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

    <link href="../Scripts/jqueryUI/bootstrap.css" rel="stylesheet" />
    <script src="../Scripts/jqueryUI/bootstrap.js" type="text/javascript"></script>
     <link href="../Scripts/bootstrap_3.3.7_css_bootstrap.min[1].css" rel="stylesheet" />
 <link href="../Scripts/bootstrap-select.min.css" rel="stylesheet" />

 <script src="../Scripts/jquery-3.3.1.min.js"></script>
 <script src="../Scripts/bootstrap_3.3.7_js_bootstrap.min.js"></script>
 <script src="../Scripts/bootstrap-select.min.js"></script>
    <script type="text/javascript">
        function check_all_not() {
            var check = document.getElementById("checkboxAll").checked;

            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;
            var totalOther = 0;
            var totalWeight = 0;
            var totalVolume = 0;
            $(".set-bk").each(function () {

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

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

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

                    var other = $(this).next().next().val();
                    if (other == "") {
                        other = 0;
                    }
                    var weight = $(this).next().next().next().val();
                    if (weight == "") {
                        weight = 0;
                    }
                    var volume = $(this).next().next().next().next().val();
                    if (volume == "") {
                        volume = 0;
                    }
                    totalOther += changeTwoDecimal(parseFloat(other));
                    totalCredit += changeTwoDecimal(parseFloat(credit));
                    totalWeight += changeTwoDecimal(parseFloat(weight));
                    totalVolume += changeTwoDecimal(parseFloat(volume));
                    count += 1;
                }

            })
            totalCredit = changeTwoDecimal(totalCredit);
            totalOther = changeTwoDecimal(totalOther);
            totalWeight = changeTwoDecimal(totalWeight);
            totalVolume = changeTwoDecimal(totalVolume);

            $("#labTotalSettlement").text(number_format(totalCredit, 3, ".", ","));
            $("#labOther").text(number_format(totalOther, 3, ".", ","));
            $("#labWeight").text(number_format(totalWeight, 3, ".", ","));
            $("#labVolume").text(number_format(totalVolume, 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);
        }

        function btnsendclick() {
            var count = 0; 
            var feeAmount=0;
            $(".set-bk").each(function () {

                var a = $(this).is(":checked");
                if (a) {
                    count += 1;
                    var fee = $(this).next().next().next().next().next().next().next().val();
                    if (fee == "") {
                        fee = 0;
                    }
                    feeAmount += changeTwoDecimal(parseFloat(fee));
                }

            })
 
            $("#hfFeeAmount").val(number_format(feeAmount, 3, ".", ","));
            $("#txtAmount").val(number_format(feeAmount, 3, ".", ","));
            if (count !== 0) {
                $("#myModal").modal("show");
            }
         
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <yee:PageTitle ID="title" runat="server">
    </yee:PageTitle>
    <yee:MessageBox ID="msg" runat="server">
    </yee:MessageBox>

    <div class="query">
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>

                <td class="queryLeft"><%=GetText("日期")%>:
                </td>
                <td class="queryLeft">
                    <yee:DatePicker ID="dtFrom" runat="server"  IsRequired />
                    -
                    <yee:DatePicker ID="dtTo" runat="server" />
                </td>
                
                <td class="queryLeft"><%=GetText("日期类型")%>:
                </td>
                <td class="queryLeft">
                     <asp:RadioButtonList ID="rblDateTypeId" runat="server"  RepeatDirection="Horizontal">
                         <asp:ListItem Value="1"  Text="创建日期" Selected="True"></asp:ListItem>
                         <asp:ListItem Value="2"  Text="收货日期"></asp:ListItem>
                     </asp:RadioButtonList>
                </td>
               
                <td>
                    <%=GetText("目标仓库") %>
                </td>
                <td>
                    <yee:UserWarehousesDropDownList ID="ddlWare" runat="server" WarehouseType="海外仓储" data-live-search="true" CssClass="selectpicker" IsShowAllAtFirst="true" OnSelectedIndexChanged="ddlWare_SelectedIndexChanged" AutoPostBack="true"  >
                    </yee:UserWarehousesDropDownList>
                </td>
                <td>
                    <yee:Button ID="btnSearch" runat="server" Width="100px" ToolTip="Search" CssClass="button" OnClick="btnSearch_Click" />
                </td>
            </tr>
            <tr>
                <td>
                    <%=GetText("运输方式") %>
                </td>
                <td>
                    <yee:DictionaryRadios ID="rblTypeId" runat="server" Dictionary="TransnationalFreightTypes" RepeatDirection="Horizontal" IsFirstSelected="true" IsShowAllAtFirst="true"></yee:DictionaryRadios>
                </td>
                <td class="queryLeft">
                    <%=GetText("Svip编码")%>：
                </td>
                <td class="queryRight">
                    <asp:TextBox ID="txtVipCode" runat="server"></asp:TextBox>
                </td>
                <td class="queryLeft">
                    <%=GetText("状态")%>：
                </td>
                <td class="queryRight" colspan="2">
                    <asp:RadioButtonList ID="rblIsPay" runat="server" RepeatDirection="Horizontal">
                        <asp:ListItem Value="10" Text="全部"></asp:ListItem>
                        <asp:ListItem Value="0" Text="未付款" Selected="True"></asp:ListItem>
                        <asp:ListItem Value="1" Text="已付款未发货"></asp:ListItem>
                        <asp:ListItem Value="2" Text="已发货"></asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr>
                 <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="txtAbroadOrderNo" runat="server"></asp:TextBox>
                </td>
                  <td class="queryLeft">
                      <%=GetText("集包号")%>：
                  </td>
                  <td class="queryRight">
 
                      <asp:TextBox ID="txtCollectNo" runat="server"></asp:TextBox>
                  </td>
                 <td class="queryLeft">
                     <%=GetText("分页")%>：
                 </td>
                 <td class="queryRight">
                
                     <asp:TextBox ID="txtPage" runat="server" Width="80px"></asp:TextBox>
                 </td>
            </tr>
        </table>
    </div>

    <%=GetText("勾选笔数")%>：<asp:Label ID="litSureCount" runat="server" ClientIDMode="Static" Font-Size="XX-Large"></asp:Label>
    <%=GetText("代理金额")%>：<asp:Label ID="labTotalSettlement" Text="0.00" runat="server" ClientIDMode="Static" Font-Size="X-Large"></asp:Label>
    <%=GetText("其他金额")%>：<asp:Label ID="labOther" Text="0.00" runat="server" ClientIDMode="Static" Font-Size="X-Large"></asp:Label>
    <%=GetText("重量")%>：<asp:Label ID="labWeight" Text="0.00" runat="server" ClientIDMode="Static" Font-Size="X-Large"></asp:Label>
    <%=GetText("体积")%>：<asp:Label ID="labVolume" 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">
                            <input type="checkbox" id="checkboxAll" onclick="check_all_not()" />
                        </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 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>
                    </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="hfSettlement" Value='<%#Eval("SettlementCost") %>' runat="server" ClientIDMode="Static" />
                        <asp:HiddenField ID="hfOther" Value='<%#Eval("OtherCost") %>' runat="server" ClientIDMode="Static" />
                        <asp:HiddenField ID="hfBoxWeight" Value='<%#Eval("BoxWeight") %>' runat="server" ClientIDMode="Static" />
                        <asp:HiddenField ID="hfBoxVolume" Value='<%#Eval("BoxVolume") %>' runat="server" ClientIDMode="Static" />
                        <asp:HiddenField ID="hfUniqueId" Value='<%#Eval("UniqueId") %>' runat="server" />
                        <asp:HiddenField ID="hfCollectId" Value='<%# Eval("CollectId")%>' runat="server" />
                        <asp:HiddenField ID="hfFeeAmount" Value='<%#Eval("FeeAmount") %>' runat="server" ClientIDMode="Static" />
</td>
                    <td class="tbpost">
                        <%# Eval("CTWOrderNo")%>
                    </td>

                    <td class="tbpost">

                        <%#Eval("ReceivedOn","{0:d}")%>
                    </td>

                    <td class="tbpost">
                        <%# Eval("TargetName")%>
                    </td>

                    <td class="tbpost">
                        <%#Eval("CollectSerialNo")%>
                    </td>
                     <td class="tbpost">
                        <%#Eval("AbroadOrderNo")%>
                     </td>
                    <td class="tbpost">
                        <%# Eval("BoxWeight")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("BoxVolume")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("SettlementCost")%>
                        <asp:LinkButton ID="lbnGeneratePrice" runat="server" CommandName="GeneratePrice" CommandArgument='<%# Eval("CollectSerialNo")%>' Text="集包报价"></asp:LinkButton>
                    </td>
                    <td class="tbpost">
                        <%# Eval("OtherCost")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("FreightTypeName")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("PayFreightOn","{0:d}")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("TransnationalCreatedOn")%>
                    </td>
                    <td class="tbpost">
                        <asp:LinkButton ID="lbnDetail" runat="server" CommandName="detail" CommandArgument='<%# Eval("UniqueId")%>' Text="详情"></asp:LinkButton>
                    </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="hfSettlement" Value='<%#Eval("SettlementCost") %>' runat="server" ClientIDMode="Static" />
                        <asp:HiddenField ID="hfOther" Value='<%#Eval("OtherCost") %>' runat="server" ClientIDMode="Static" />
                        <asp:HiddenField ID="hfBoxWeight" Value='<%#Eval("BoxWeight") %>' runat="server" ClientIDMode="Static" />
                        <asp:HiddenField ID="hfBoxVolume" Value='<%#Eval("BoxVolume") %>' runat="server" ClientIDMode="Static" />
                        <asp:HiddenField ID="hfUniqueId" Value='<%#Eval("UniqueId") %>' runat="server" />
                        <asp:HiddenField ID="hfCollectId" Value='<%# Eval("CollectId")%>' runat="server" />
 <asp:HiddenField ID="hfFeeAmount" Value='<%#Eval("FeeAmount") %>' runat="server" ClientIDMode="Static" />
                    </td>
                    <td class="tbpost">
                        <%# Eval("CTWOrderNo")%>
                    </td>

                    <td class="tbpost">

                        <%#Eval("ReceivedOn","{0:d}")%>
                    </td>

                    <td class="tbpost">
                        <%# Eval("TargetName")%>
                    </td>

                    <td class="tbpost">
                        <%#Eval("CollectSerialNo")%>
                    </td>
                     <td class="tbpost">
                       <%#Eval("AbroadOrderNo")%>
                     </td>
                    <td class="tbpost">
                        <%# Eval("BoxWeight")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("BoxVolume")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("SettlementCost")%>
                        <asp:LinkButton ID="lbnGeneratePrice" runat="server" CommandName="GeneratePrice" CommandArgument='<%# Eval("CollectSerialNo")%>' Text="集包报价"></asp:LinkButton>
                    </td>
                    <td class="tbpost">
                        <%# Eval("OtherCost")%>
                    </td>
                    <td class="tbpost">
                        <%# Eval("FreightTypeName")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("PayFreightOn","{0:d}")%>
                    </td>
                    <td class="tbpost">
                        <%#Eval("TransnationalCreatedOn")%>
                    </td>
                    <td class="tbpost">
                        <asp:LinkButton ID="lbnDetail" runat="server" CommandName="detail" CommandArgument='<%# Eval("UniqueId")%>' Text="详情"></asp:LinkButton>
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    <asp:Button ID="btnCutFreight" runat="server" CssClass="button" OnClick="btnCutFreight_Click" />
    <input type="button" id="btnsend" runat="server" visible="false" class="button"  onclick="btnsendclick()"/>
    <yee:Pager ID="Pager1" PageIndex="0" PagerType="1" PageSize="20" runat="server" OnPageIndex_Changed="Pager1_PageIndex_Changed" />

    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel"><%=GetText("出库信息") %>
                    </h4>
                </div>
                <div class="modal-body">
                    <table class="table table-bordered">
                        <tr>
                            <td><%=GetText("快递公司") %></td>
                            <td>
                                <asp:DropDownList ID="drCompanyId" runat="server"></asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td><%=GetText("快递单号") %></td>
                            <td>
                                <asp:TextBox ID="txtexpress" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td><%=GetText("收货地址") %></td>
                            <td>
                                <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td><%=GetText("收件人") %></td>
                            <td>
                                <asp:TextBox ID="txtReceiverName" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td><%=GetText("电话") %></td>
                            <td>
                                <asp:TextBox ID="txttel" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td><%=GetText("移动电话") %></td>
                            <td>
                                <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td><%=GetText("备注") %></td>
                            <td>
                                <asp:TextBox ID="txtRemark" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td><%=GetText("付款方式") %></td>
                            <td>
                                <yee:DictionaryRadioList runat="server" ID="rdlPay" IsShowAllAtFirst="false" TypeId="ExpressPayTypes" RepeatDirection="Horizontal"></yee:DictionaryRadioList>
                            </td>
                        </tr>
                        <tr>
                            <td><%=GetText("运费金额") %></td>
                            <td>
                                <asp:TextBox ID="txtAmount" runat="server"   ClientIDMode="Static" ></asp:TextBox>
                                <asp:hiddenField ID="hfFeeAmount" runat="server"   ClientIDMode="Static" ></asp:hiddenField>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        <%=GetText("关闭") %>
                    </button>
                    <asp:Button ID="btnIn" runat="server" CssClass="btn btn-default" OnClick="btnIn_Click" />
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal -->
    </div>
</asp:Content>