<%@ Page Title="" Language="C#" MasterPageFile="~/Dialog/DialogMaster.Master" AutoEventWireup="true"
    CodeBehind="InvoiceEdit.aspx.cs" Inherits="OAWeb.crm.orders.InvoiceEdit" ValidateRequest="false" %>

<%@ Register Src="../../UserControls/OrderNav.ascx" TagName="OrderNav" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script src="/js/jquery.form.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src='<%=ResolveUrl("~/ckeditor/ckeditor.js")%>'></script>
    <!--主体左侧-->
    <style>
        .order_State .table_form td, .order_State .table_form .right
        {
            vertical-align: middle;
        }
        .order_State .table_form .right
        {
            width: 120px;
        }
        .data_caption a
        {
            text-decoration: none;
        }
    </style>
    <div style=" padding-top:10px; width: 730px; height: 500px; overflow-y: scroll">
    <table id="plc_profile" cellpadding="0" cellspacing="0" border="0">
        <tr>
            
            <td class="main_center">
                <div class="page_main">
                    <div class="page_content">
                        <table class="data_title line_height32px" cellspacing="3">
                            <tr>
                                <td class="data_caption" style="border-bottom: none">
                                    <span class="left_title" style="float: none;"><strong class="CustomerName">发票：<asp:Literal
                                        ID="lblInvoiceNum" runat="server"></asp:Literal>
                                        [
                                        <asp:Label ForeColor="Red" ID="lblStateText" runat="server" Text=""></asp:Label>
                                        ]</strong> </span><span style="margin-left: 100px; font-weight: normal;"><a id="lbtnAudit"
                                            runat="server" href="javascript:void(0)" runat="server" style=" font-weight:bold;">审批/反审批</a> </span>
                                    <p>
                                    </p>
                                    <span style="font-size: 14px; font-weight: normal;">客户：<asp:HyperLink ID="hypCustomerName"
                                        runat="server" Target="_blank"></asp:HyperLink>
                                        &nbsp;&nbsp;&nbsp;&nbsp; 订单：<asp:HyperLink ID="hypOrderSN" runat="server" Target="_blank"></asp:HyperLink>
                                    </span>
                                </td>
                            </tr>
                        </table>
                        
                            
                            <div class="tab_contents">
                                <div class="tab_content">
                                    <div class="order_widget">
                                        <div class="order_State">
                                            <div class="form">
                                                <table border="0" cellspacing="0" cellpadding="0" class="table_form">
                                                    <tr>
                                                        <td class="right ">
                                                            发票抬头：
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="txtInvoicePayee" runat="server" CssClass="text width200">
                                                            </asp:TextBox>&nbsp;
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="right ">
                                                            发票内容：
                                                        </td>
                                                        <td>
                                                            <input type="radio" checked="checked" />
                                                            明细
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="right ">
                                                            发票金额：
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="txtInvoiceTax" runat="server" CssClass="text width40"></asp:TextBox>
                                                            <span id="AmountInfo" runat="server" style="color: Red; margin-left: 15px"></span>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="right ">
                                                            发票类型：
                                                        </td>
                                                        <td>
                                                            <asp:RadioButtonList ID="rdoInvoiceType" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
                                                                <asp:ListItem Selected="True" Value="0">普通发票</asp:ListItem>
                                                                <asp:ListItem Value="1">增值税发票</asp:ListItem>
                                                            </asp:RadioButtonList>
                                                        </td>
                                                    </tr>
                                                    <tr id="tdApt" runat="server">
                                                        <td class="right ">
                                                            增值税发票资质：
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="txtInvoiceAptitude" runat="server" CssClass="text" Width="400px"
                                                                TextMode="MultiLine" Height="100px"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="right ">
                                                            客户地址：
                                                        </td>
                                                        <td>
                                                            <asp:HyperLink ID="hypShipEdit" runat="server">[ 修改 ]</asp:HyperLink>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="right ">
                                                        </td>
                                                        <td id="tdAddress" runat="server">
                                                            <asp:Literal ID="ltlShipTo" runat="server"></asp:Literal>
                                                            <asp:Literal ID="ltlShipProvinceCity" runat="server"></asp:Literal>
                                                            <asp:Literal ID="ltlAddress" runat="server"></asp:Literal>
                                                            ( 邮编：<asp:Literal ID="ltlZipCode" runat="server"></asp:Literal>
                                                            )<br />
                                                            手机：<asp:Literal ID="ltlMobile" runat="server"></asp:Literal>
                                                            电话：<asp:Literal ID="ltlTelePhone" runat="server"></asp:Literal>
                                                            电子邮件：
                                                            <asp:Literal ID="ltlEmail" runat="server"></asp:Literal>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                    <asp:Panel ID="pnlShip" runat="server">
                                        <div class="order_widget">
                                            <div class="order_State">
                                                <table border="0" cellspacing="0" cellpadding="0" class="table_form">
                                                    <tr>
                                                        <td class="right ">
                                                            发票号码：
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="txtInvoiceNo" runat="server" CssClass="text "></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="right ">
                                                            发票时间：
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="txtInvoiceDate" runat="server" CssClass="text_box" ></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="right ">
                                                            备注：
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="txtRemark" runat="server" CssClass="text" TextMode="MultiLine" Width="250" Height="80"></asp:TextBox>
                                                            
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="right ">
                                                        </td>
                                                        <td>
                                                            <asp:Literal ID="ltlCreateUserInfo" runat="server"></asp:Literal>
                                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <asp:Literal ID="ltlTrackUserInfo" runat="server"></asp:Literal>
                                                        </td>
                                                    </tr>
                                                </table>
                                                <div style="text-align: center; margin-top: 15px;">
                                                    <asp:HiddenField ID="hdfCustomerId" runat="server" />
                                                    <asp:HiddenField ID="hdfCustomerName" runat="server" />
                                                    <asp:HiddenField ID="hdfOrderId" runat="server" />
                                                    <asp:HiddenField ID="hdfOrderSN" runat="server" />
                                                    <input id="btnSave" type="button" value=" 保 存 " class="btn_77px" />
                                                    <input id="btnClose" type="button" value=" 返 回 " onclick="art.dialog.close();"
                                                        class="btn_77px" />
                                                </div>
                                            </div>
                                        </div>
                                    </asp:Panel>
                                </div>
                            </div>
                        
                    </div>
                </div>
            </td>
        </tr>
    </table>
    </div>
    <script type="text/javascript">

        var InvTypeList = document.getElementsByName("ctl00$ContentPlaceHolder1$rdoInvoiceType");
       
        for (var i = 0; i < InvTypeList.length; i++) {
            
            $(InvTypeList[i]).click(function () {

                if ($(this).val() == "1")
                    $("#<%=tdApt.ClientID %>").show();
                else
                    $("#<%=tdApt.ClientID %>").hide();

            })
        }

        $(document).ready(function () {
            $(".tab_handles span").click(function () {
                var hideIndex = $(".tab_handles .current").index();
                $(".tab_handles span").removeClass("current");
                $(this).addClass("current");
                $(".tab_contents .tab_content:eq(" + hideIndex + ")").hide();
                $(".tab_contents .tab_content:eq(" + $(this).index() + ")").show();
            })

            //客户选择
            $(".SelectCustomer").click(function () {
                OpenRadioDialog('/Dialog/CustomerDialog.aspx', '选择客户', function (text, value) {
                    $("#<%=hypCustomerName.ClientID %>").text(text);
                    $("#<%=hypCustomerName.ClientID %>").attr("href", "/crm/customer/CustomerView.aspx?CustomerID=" + value);
                    $("#<%=hdfCustomerId.ClientID %>").val(value);
                    $("#<%=hdfCustomerName.ClientID %>").val(text);
                    $(".CustomerName").text(text);
                });
            });
            //订单选择
            $(".SelectOrder").click(function () {
                OpenRadioDialog('/Dialog/OrderSelectDialog.aspx', '选择订单', function (text, value) {
                    $("#<%=hypOrderSN.ClientID %>").text(text);
                    $("#<%=hypOrderSN.ClientID %>").attr("href", "/crm/orders/OrderView.aspx?Id=" + value);
                    $("#<%=hdfOrderId.ClientID %>").val(value);
                    $("#<%=hdfOrderSN.ClientID %>").val(text);
                });
            });

            //保存
            $("#btnSave").click(function () {
                //把编辑值赋值到实际文本框，编辑器只在有post动作时才把值赋值给实际文本框。

                return FormPostAjax("/crm/orders/InvoiceEdit.aspx?op=Save&Id=<%=Id %>&OrderId=<%=OrderID %>", "ok", function () { CloseReload(); }); 
            });

            $("#<%=lbtnAudit.ClientID %>").click(function () {
               var str="";
               if($("#<%=lblStateText.ClientID %>").html()=="待审批")
               str="确定要审批该发票？";
               else
               str="该发票已经审批过，要设置为未审批？";
               
               if(confirm(str))
                   return FormPostAjax("/crm/orders/InvoiceEdit.aspx?op=Audit&Id=<%=Id %>", "ok", function () { CloseReload(); }); 
                
            });
        })
    </script>
</asp:Content>
