<%@ Page Title="" Language="C#" MasterPageFile="~/Freight/Freight.Master" AutoEventWireup="true" CodeBehind="CustomerOrderFreightDelayChargeDetail.aspx.cs" Inherits="GxHub.Wms.Abroad.Web.Freight.CustomerOrderFreightDelayChargeDetail" %>
<%@ Register src="FreightDelayChargeDetail.ascx" tagname="FreightDelayChargeDetail" tagprefix="uc1" %>
<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();
                GetTotalCount();
            }
            else {
                checkReverse();
                GetTotalCount();
            }

        }


        function checkAll() {
            $(".check ").each(function () {
                var able = $(this).attr("disabled");
                if (able != 'disabled') {
                    $(this).attr("checked", true);
                }
            });
        }
        //反选
        function checkReverse() {
            $(".check ").each(function () {
                var able = $(this).attr("disabled");
                if (able != 'disabled') {
                    $(this).attr("checked", !($(this).attr("checked")));
                }
            });
        }
        function checkRemove() {
            $(".check ").each(function () {
                var able = $(this).attr("disabled");
                if (able != 'disabled') {
                    $(this).attr("checked", false);
                }
            });
        }


        function CheckTotal(obj) {
            var check = $(obj).attr("checked");

            if (check == 'undefined') {
                $(obj).attr("checked", true);
            }
            else {
                //  $(obj).attr("checked", !($(obj).attr("checked")));
            }
            GetTotalCount();
        }

        function GetTotalCount() {
            var weight = 0;
            var size = 0;
            var cn2th = 0;
            var th2th = 0;

            $(".check ").each(function () {

                var check = $(this).attr("checked");

                if (check == "checked") {
                    weight += parseFloat($(this).next().next().val());
                    size += parseFloat($(this).next().next().next().val());
                    cn2th += parseFloat($(this).next().next().next().next().val());
                    th2th += parseFloat($(this).next().next().next().next().next().val());
                }
            });
            $("#labTotalWeight").text(weight.toFixed(3));
            $("#labTotalVolume").text(size.toFixed(3));
            $("#labTotalCN2TH").text(cn2th.toFixed(4));
            $("#labTotalTH2TH").text(th2th.toFixed(4));
        }



        function CutBoxesFreight() {

            var result = false;
            //先判断是否为同一个会员的入库单
            var count = 0;
            var num = 0;
            var number = 0;
            var code = "";
            var source = "";
            $(".check:checked").each(function () {
                count++;
                if (code == $(this).next().val()) {
                    num++;
                }
                code = $(this).next().val();

            });


            if (count - 1 != num) {
                alert("请选择同一个会员");
                return false;
            }

            var ids = "";
            $(".check:checked").each(function () {
                ids += $(this).val() + ",";
            });

            $("#EditIframe").attr("src", "CutBoxesFreight.aspx?ids=" + ids + "&customerCode=" + code);

            $("#iframeEdit").dialog({
                autoOpen: true,
                resizable: false,
                width: 1000,
                modal: true,
                title: "扣取箱子费用",
                buttons: {
                    "确认": function () {
                        $("#hfType").val("2");
                        SetCoupon();
                        $("#form1").submit();

                    },
                    "取消": function () {
                        setEmpty();
                        result = false;
                        $(this).dialog("close");
                    }
                }
            });
            //alert(result);
            return result;
        }

        function CutSingleBoxFreight(id, code) {

            var ids = id + ",";
            $("#hfUniqueId").val(id);

            $("#EditIframe").attr("src", "CutBoxesFreight.aspx?ids=" + ids + "&customerCode=" + code);

            $("#iframeEdit").dialog({
                autoOpen: true,
                resizable: false,
                width: 1000,
                modal: true,
                title: "扣取箱子费用",
                buttons: {
                    "确认": function () {
                        $("#hfType").val("1");
                        SetCoupon();
                        $("#form1").submit();

                    },
                    "取消": function () {
                        setEmpty();
                        $(this).dialog("close");
                    }
                }
            });

            return false;
        }

        function SetCoupon() {
            var uniqueid = $("#EditIframe").contents().find(".rblCoupon:checked").val();

            $("#hfCouponUniqueId").val(uniqueid);

        }

        function setEmpty() {
            $("#hfCouponUniqueId").val("");
            $("#hfUniqueId").val("");
            $("#hfType").val("");

        }

</script>
<style type="text/css">
    .small_txt {
        width:100px;
    }
    #EditIframe
    {
        width: 1000px;
        height: 300px;
    }
 
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     <yee:CustomerOrderTabs ID="FreightDelayChargeTabs" runat="server"></yee:CustomerOrderTabs>

     <yee:MessageBox ID="msg" runat="server">
</yee:MessageBox>
<asp:HiddenField ID="hfCouponUniqueId" runat="server"  ClientIDMode="Static"/>
<asp:HiddenField ID="hfUniqueId" runat="server" ClientIDMode="Static" />
<asp:HiddenField ID="hfType" runat="server" ClientIDMode="Static" />
<asp:Repeater ID="rptFreight" runat="server" ClientIDMode="Static" 
    OnItemCommand="rptFreight_ItemCommand" 
    onitemdatabound="rptFreight_ItemDataBound">
    <HeaderTemplate>
        <table class="table" width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td class="tbheader" width="20px" 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" 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" colspan="5">
                    <%=GetText("运费") %>
                </td>
                <td class="tbheader" align="center" rowspan="2">
                    <%=GetText("操作")%>
                </td>
            </tr>
            <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>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
        <tr class="tbrow">
            <td class="tbpost">
                <input id="cbItem" type="checkbox" class="check" runat="server" value='<%#Eval("UniqueId") %>' onclick="CheckTotal(this)" />
                <asp:HiddenField ID="hfCustomerCode" runat="server" Value='<%#Eval("CustomerCode") %>' />
                <input type="hidden" class="hfWeight" value='<%#Eval("Weight") %>' />
                <input type="hidden" class="hfSize" value='<%#Eval("Size") %>' />
                <input type="hidden" class="hfCN2TH" value='<%#Eval("ShouldIncomeCN2THFreightAmount") %>' />
                <input type="hidden" class="hfTH2TH" value='<%#Eval("ShouldIncomeTH2THFreightAmount") %>' />
            </td>
            <td class="tbpost">
                <%#Eval("Serail")%>
            </td>
            <td class="tbpost">
                <%#Eval("CustomerCode")%>
            </td>
            <td class="tbpost">
                <%#Eval("CustomerRank")%>
            </td>
            <td class="tbpost">
                <asp:Literal ID="litOrderNo" runat="server" ></asp:Literal>
                <asp:HiddenField ID="hfOrderNo" runat="server" Value='<%#Eval("OrderNo") %>' />
            </td>
            <td class="tbpost">
                <%#Eval("CTWOrderNo")%>
            </td>
            <td class="tbpost">
                <%#Eval("CabinetNo")%>
            </td>
            <td class="tbpost">
                <%#Eval("InStockStatus") %>
            </td>
            <td class="tbpost">
                <%#Eval("Weight")%>
               
            </td>
            <td class="tbpost">
                <%#Eval("Size")%>
                 
            </td>

           <td class="tbpost">
                <%=GetText("国际运费")%>：<asp:TextBox ID="txtcn2thFreight" Text='<%#Eval("ShouldIncomeCN2THFreightAmount") %>' runat="server" CssClass="small_txt"></asp:TextBox>
                
           </td>
            <td class="tbpost">
                  <asp:LinkButton ID="lbnAuditCn2Th" runat="server"  CommandArgument='<%# Eval("UniqueId") %>'
                    CommandName="auditCn2Th" OnClientClick='return confirm("确认审核国际运费？")'><%=GetText("审核国际运费")%></asp:LinkButton>
                  <asp:LinkButton ID="lbnReleaseCn2Th" runat="server" CommandArgument='<%#Eval("UniqueId") %>' CommandName="ReleaseCn2Th" OnClientClick='return confirm("确认释放国际运费审核")' ><%=GetText("释放审核国际运费") %></asp:LinkButton>
            </td>
            <td class="tbpost">
                <%=GetText("海外运费")%>：<asp:TextBox ID="txtth2thFreight" Text='<%#Eval("ShouldIncomeTH2THFreightAmount") %>' runat="server" CssClass="small_txt"></asp:TextBox>
                 
             
            </td>
         
            <td class="tbpost">
              <asp:LinkButton ID="lbnAuditTh2Th" runat="server"  CommandArgument='<%# Eval("UniqueId") %>'
                    CommandName="auditTh2Th" OnClientClick='return confirm("确认审核海外运费？")'><%=GetText("审核海外运费")%></asp:LinkButton> 
                 <asp:LinkButton ID="lbnReleaseTh2Th" runat="server" CommandArgument='<%#Eval("UniqueId") %>' CommandName="ReleaseTh2Th" OnClientClick='return confirm("确认释放海外运费审核")' ><%=GetText("释放审核海外运费") %></asp:LinkButton>
            </td>
             <td class="tbpost">
               <%#Eval("PayFreightOn") %>
             </td>
            <td class="tbpost">
              
                <asp:LinkButton ID="lbnFreight" runat="server" CommandArgument='<%# Eval("UniqueId") %>'
                    CommandName="freight" ><%=GetText("补扣运费")%></asp:LinkButton>
                <asp:LinkButton ID="lbnEmail" runat="server" CommandArgument='<%# Eval("UniqueId") %>'
                    CommandName="email"><%=GetText("发送邮件")%></asp:LinkButton>
            </td>
        </tr>
    </ItemTemplate>
    <AlternatingItemTemplate>
        <tr class="tbrowalter">
            <td class="tbpost">
                <input id="cbItem" type="checkbox" class="check" runat="server" value='<%#Eval("UniqueId") %>' onclick="CheckTotal(this)" />
                <asp:HiddenField ID="hfCustomerCode" runat="server" Value='<%#Eval("CustomerCode") %>' />
                <input type="hidden" class="hfWeight" value='<%#Eval("Weight") %>' />
                <input type="hidden" class="hfSize" value='<%#Eval("Size") %>' />
                <input type="hidden" class="hfCN2TH" value='<%#Eval("ShouldIncomeCN2THFreightAmount") %>' />
                <input type="hidden" class="hfTH2TH" value='<%#Eval("ShouldIncomeTH2THFreightAmount") %>' />
            </td>
            <td class="tbpost">
                <%#Eval("Serail")%>
            </td>
            <td class="tbpost">
                <%#Eval("CustomerCode")%>
            </td>
             <td class="tbpost">
                <%#Eval("CustomerRank")%>
            </td>
            <td class="tbpost">
                <asp:Literal ID="litOrderNo" runat="server" ></asp:Literal>
                <asp:HiddenField ID="hfOrderNo" runat="server" Value='<%#Eval("OrderNo") %>' />
            </td>
            <td class="tbpost">
                <%#Eval("CTWOrderNo")%>
            </td>
            <td class="tbpost">
                <%#Eval("CabinetNo")%>
            </td>
            <td class="tbpost">
                <%#Eval("InStockStatus") %>
            </td>
            <td class="tbpost">
                <%#Eval("Weight")%>
               
            </td>
            <td class="tbpost">
                <%#Eval("Size")%>
                 
            </td>

           <td class="tbpost">
                <%=GetText("国际运费")%>：<asp:TextBox ID="txtcn2thFreight" Text='<%#Eval("ShouldIncomeCN2THFreightAmount") %>' runat="server" CssClass="small_txt"></asp:TextBox>
                
           </td>
            <td class="tbpost">
                  <asp:LinkButton ID="lbnAuditCn2Th" runat="server"  CommandArgument='<%# Eval("UniqueId") %>'
                    CommandName="auditCn2Th" OnClientClick='return confirm("确认审核国际运费？")'><%=GetText("审核国际运费")%></asp:LinkButton>
                  <asp:LinkButton ID="lbnReleaseCn2Th" runat="server" CommandArgument='<%#Eval("UniqueId") %>' CommandName="ReleaseCn2Th" OnClientClick='return confirm("确认释放国际运费审核")' ><%=GetText("释放审核国际运费") %></asp:LinkButton>
            </td>
            <td class="tbpost">
                <%=GetText("海外运费")%>：<asp:TextBox ID="txtth2thFreight" Text='<%#Eval("ShouldIncomeTH2THFreightAmount") %>' runat="server" CssClass="small_txt"></asp:TextBox>
                 
             
            </td>
            <td class="tbpost">
              <asp:LinkButton ID="lbnAuditTh2Th" runat="server"  CommandArgument='<%# Eval("UniqueId") %>'
                    CommandName="auditTh2Th" OnClientClick='return confirm("确认审核海外运费？")'><%=GetText("审核海外运费")%></asp:LinkButton> 
                 <asp:LinkButton ID="lbnReleaseTh2Th" runat="server" CommandArgument='<%#Eval("UniqueId") %>' CommandName="ReleaseTh2Th" OnClientClick='return confirm("确认释放海外运费审核")' ><%=GetText("释放审核海外运费") %></asp:LinkButton>
            </td>
            <td class="tbpost">
               <%#Eval("PayFreightOn") %>
           </td>
             <td class="tbpost">
              
                <asp:LinkButton ID="lbnFreight" runat="server" CommandArgument='<%# Eval("UniqueId") %>'
                    CommandName="freight" ><%=GetText("补扣运费")%></asp:LinkButton>
                <asp:LinkButton ID="lbnEmail" runat="server" CommandArgument='<%# Eval("UniqueId") %>'
                    CommandName="email"><%=GetText("发送邮件")%></asp:LinkButton>
            </td>
        </tr>
    </AlternatingItemTemplate>
    <FooterTemplate>
       
    </FooterTemplate>
</asp:Repeater>
    </asp:Repeater>
    <tr>
        <td colspan="7" class="tbfooter">
           
        </td>
        <td  class="tbfooter">
            <%=GetText("统计") %>
        </td>
        <td class="tbfooter">
            <asp:Label ID="labTotalWeight" runat="server" ClientIDMode="Static" ></asp:Label>
        </td>
        <td class="tbfooter">
            <asp:Label ID="labTotalVolume" runat="server" ClientIDMode="Static" ></asp:Label>
        </td>
        <td class="tbfooter">
            <asp:Label ID="labTotalCN2TH" runat="server" ClientIDMode="Static" ></asp:Label>
        </td>
        <td class="tbfooter"></td>
        <td class="tbfooter">
            <asp:Label ID="labTotalTH2TH" runat="server" ClientIDMode="Static" ></asp:Label>
        </td>
        <td class="tbfooter"></td>
        <td class="tbfooter"></td>
    </tr>
 </table>
<asp:Button ID="btnCN2THAudit" runat="server" CssClass="button" OnClientClick="return confirm('确认批量审核国际运费么？')" OnClick="btnCN2THAudit_Click" />
<asp:Button ID="btnTH2THAudit" runat="server" CssClass="button" OnClientClick="return confirm('确认批量审核海外运费么？')" OnClick="btnTH2THAudit_Click" />

<%--<asp:Button ID="btSave" runat="server" CssClass="button" OnClientClick="return confirm('确定批量扣取费用么？')" OnClick="return CutBoxFreight()" />--%>
 <asp:Button ID="btSave" CssClass="button" runat="server"  
            OnClientClick="if(!CutBoxesFreight()){return false;}" />

<asp:Button ID="btnReleaseCN2THAudit" runat="server" CssClass="button"  OnClientClick="return confirm('确认批量释放国际运费么？')" OnClick="btnReleaseCN2THAudit_Click"/>
<asp:Button ID="btnReleaseTH2THAudit" runat="server" CssClass="button"  OnClientClick="return confirm('确认批量释放海外运费么？')" OnClick="btnReleaseTH2THAudit_Click"/>
<div id="iframeEdit" class="iframeEdit">
    <iframe id="EditIframe" frameborder="0" class="EditIframe"></iframe>
</div>
</asp:Content>
