<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="SODetail.aspx.vb" Inherits="VS4WebApp.SODetail" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link href="/Scripts/Site2.css" rel="stylesheet" type="text/css" />
    <%--'DatePicker--%>
    <link rel="stylesheet" href="/Scripts/jquery-ui-1.10.3/themes/base/jquery.ui.all.css" />
    <script src="/Scripts/jquery-ui-1.10.3/jquery-1.9.1.js"></script>
    <script src="/Scripts/jquery-ui-1.10.3/ui/jquery.ui.core.js"></script>
    <script src="/Scripts/jquery-ui-1.10.3/ui/jquery.ui.widget.js"></script>
    <%--    <script src="/Scripts/jquery-ui-1.10.3/ui/jquery.ui.datepicker.js"></script>--%>
    <link href="Scripts/jquery-ui-1.10.3/demos/demos.css" rel="stylesheet" />
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <%--    <link rel="stylesheet" href="/resources/demos/style.css" />--%>
    <link href="css/style.css" rel="stylesheet" />
    <link href="/Content/bootstrap/bootstrap.css" rel="stylesheet" />
    <script type="text/javascript">

        function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regexS = "[\\?&]" + name + "=([^&#]*)";
            var regex = new RegExp(regexS);
            var results = regex.exec(window.location.href);
            if (results == null)
                return "";
            else
                return decodeURIComponent(results[1].replace(/\+/g, " "));
        }
        $(document).ready(function () {

            var attrTitle = $(this).attr('title').split(",");
            var LastArray = attrTitle[attrTitle.length - 1];
            var LastStock = LastArray.split(" ");
            var CurrentStock = parseInt(LastStock[LastStock.length - 1]) + 1;

            if (CurrentStock == 0) {
                $("#GotoNew").hide();
            } else {
                $("#GotoNew").show();
            }


            $("#GV td:nth-child(10),th:nth-child(10)").hide();
            $("#GV td:nth-child(11),th:nth-child(11)").hide();
            $("#GV td:nth-child(12),th:nth-child(12)").hide();
            $("#GV td:nth-child(13),th:nth-child(13)").hide();
            $("#GV td:nth-child(14),th:nth-child(14)").hide();
            $("#GV td:nth-child(15),th:nth-child(15)").hide();
            $("#GV td:nth-child(16),th:nth-child(16)").hide();
            $("#DropDownList1").change(function (e) {
                var selectedOption = $("#DropDownList1 option:selected").text();
                var totalRows = $("#GV tr").length;
                var i = 0;
                $("#GV").show();
                $("#GV tr").each(function () {
                    $(this).show();
                });

                if (selectedOption === 'ยกเลิก') {
                    i = 0;
                    $("#GV tr").each(function () {
                        var vValue = $(this).closest('tr').find('td:eq(8)').text();
                        if (vValue.indexOf("Yes") !== -1) {
                            $(this).show();
                            i = i + 1;
                        }
                        if (vValue.indexOf("No") !== -1) {
                            $(this).hide();
                        }

                    });
                    if (i = 0) {
                        $("#GV").hide();
                    } else { $("#GV").show(); }
                }
                if (selectedOption === 'ส่งมอบ') {
                    i = 0;
                    $("#GV tr").each(function () {
                        var vValue = $(this).closest('tr').find('td:eq(5)').text();
                        if (vValue.indexOf("Yes") !== -1) {
                            $(this).show();
                            i = i + 1;
                        }
                        if (vValue.indexOf("No") !== -1) {
                            $(this).hide();
                        }
                    });
                    if (i = 0) {
                        $("#GV").hide();
                    } else { $("#GV").show(); }
                }
                if (selectedOption === 'ยืนยัน') {
                    $("#GV tr").each(function () {
                        var vValue = $(this).closest('tr').find('td:eq(6)').text();
                        if (vValue.indexOf("Yes") !== -1) {
                            $(this).show();
                        }
                        if (vValue.indexOf("No") !== -1) {
                            $(this).hide();
                        }
                    });
                }
                if (selectedOption === 'อนุมัติ') {
                    $("#GV tr").each(function () {
                        var vValue = $(this).closest('tr').find('td:eq(7)').text();
                        if (vValue.indexOf("Yes") !== -1) {
                            $(this).show();
                        }
                        if (vValue.indexOf("No") !== -1) {
                            $(this).hide();
                        }
                    });
                }
                if (selectedOption === 'Invoice') {
                    $("#GV tr").each(function () {
                        var vValue = $(this).closest('tr').find('td:eq(4)').text();
                        if (vValue.indexOf("Yes") !== -1) {
                            $(this).show();
                        }
                        if (vValue.indexOf("No") !== -1) {
                            $(this).hide();
                        }
                    });
                }
            });

            var totalRows = $("#<%=GV.ClientID%> tr").length;
            if (totalRows > 1) {
                $("#DivGrid").show();
                $("#ttDetail").hide();

            } else {
                $("#DivGrid").hide();
                $("#ttDetail").show();
            }

            $("#Button3").click(function () {
                $("#DivGrid").show('slow');
                $("#ttDetail").hide('slow');
                return false;
            });
            $("#<%=GV.ClientID%> tr").hover(function () {
                $(this).children().eq(0).css('cursor', 'pointer');
            });

            $("#<%=GV.ClientID%> tr").click(function () {
                $("#lSaleNo").html($(this).children().eq(0).text());
                $("#HDSoNo").val($(this).children().eq(0).text());
                $("#tPrice").val($(this).children().eq(1).text().trim());
                $("#tARCode").val($(this).children().eq(2).text().trim());
                $("#tARName").val($(this).children().eq(3).text().trim());
                $("#tDate").val($(this).children().eq(10).text().trim());
                //$("#HFDate").html($(this).children().eq(10).html());
                $("#lInvoice").html($(this).children().eq(4).html());
                $("#lDelivery").html($(this).children().eq(5).html());
                $("#lConfirm").html($(this).children().eq(6).html());
                $("#lAppove").html($(this).children().eq(7).html());
                $("#lCancel").html($(this).children().eq(8).html());

                $("#tAddress").val($(this).children().eq(11).text().trim());
                $("#tDescription").val($(this).children().eq(12).text().trim());
                $("#tPhone").val($(this).children().eq(13).text().trim());
                $("#tGrandTotal").val($(this).children().eq(14).text().trim());
                $("#tAmount").val($(this).children().eq(15).text().trim());

                $("#DivGrid").hide('slow');
                $("#ttDetail").show('slow');

                $("#Button6").show();//Cancel
                $("#Button2").show(); //confirm
                $("#Button7").hide(); //Appove
                if ($("#lCancel").html().indexOf("Yes") > 0) {
                    $("#Button6").hide();
                    $("#Button2").hide();
                    $("#Button7").hide();
                }
                if ($("#lConfirm").html().indexOf("Yes") > 0) {
                    $("#Button6").hide();
                    $("#Button2").hide();
                    $("#Button7").show();
                }
                if ($("#lAppove").html().indexOf("Yes") > 0) {
                    $("#Button6").hide();
                    $("#Button2").hide();
                    $("#Button7").hide();
                }

            });

            $("#GotoNew").click(function () {
                var sPageURL = window.location.search.substring(1);
                var url = 'SONew.aspx?' + sPageURL;
                window.location = url;
            });
        });


    </script>

    <style type="text/css">
        .centered-table
        {
            margin-left: auto;
            margin-right: auto;
        }

        .BoxDetail
        {
            /*text-align: center;
              vertical-align: middle;
              background-color: #26527C;*/
            /*color: white;*/
            height: 300px;
            width: 280px;
            float: left;
            margin-right: 2px;
            margin-bottom: 2px;
        }

        .BoxDetail2
        {
            /*text-align: center;
              vertical-align: middle;
              background-color: #26527C;*/
            /*color: white;*/
            height: 300px;
            width: 200px;
            float: left;
            margin-right: 2px;
            margin-bottom: 2px;
        }

        div.ex
        {
            width: 650px;
            padding: 10px;
            border: 1px solid gray;
            margin: 0px;
            -khtml-border-radius: 10px;
            -moz-border-radius: 10px;
            border-radius: 10px;
        }



        .UnSelectD
        {
            text-align: center;
            vertical-align: middle;
            background-color: #26527C;
            font-size: 15px;
            color: white;
            height: 50px;
            width: 50px;
            float: left;
            margin-right: 2px;
            margin-bottom: 2px;
            /*-moz-border-radius: 10px;
        border-radius: 10px;*/
        }

        .auto-style2
        {
            width: 115px;
            height: 20px;
        }

        .auto-style3
        {
            height: 20px;
        }

        </style>

</head>
<body>
    <button type="button" id="GotoNew" class="btn btn-warning" style="background-color: #4671D5">
        <span class="glyphicon glyphicon-plus"></span>เพิ่มการจองใหม่
    </button>
    <form id="form1" runat="server">
        <hr />
        <div id="DivDetail">
            <div id="ttDetail" runat="server" style="display: table; margin-right: auto; margin-left: auto; width: 100%;">
                <div class="ex" style="display: table; margin-right: auto; margin-left: auto;">
                    <div class="row">
                        <div class="col-xs-6">

                            <span style="color: #4671D5">รายละเอียด</span><br />

                            <asp:HiddenField ID="HDSoNo" runat="server" />
                            <table class="nav-justified">
                                <tr>
                                    <td class="auto-style2" style="text-align: right; color: #06266F;"><asp:TextBox ID="TextBox3" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">เลขที่ :</asp:TextBox></td>
                                    <td class="auto-style3">
                                        &nbsp;&nbsp;<asp:HyperLink ID="lSaleNo" runat="server" Target="_blank">[lSaleNo]</asp:HyperLink>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="auto-style2" style="text-align: right; color: #06266F;"><asp:TextBox ID="TextBox4" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">รหัสสินค้า :</asp:TextBox></td>
                                    <td>
                                        <asp:TextBox ID="tPdtCode" runat="server" BorderStyle="None" Width="194px" ReadOnly="True"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="auto-style2" style="text-align: right; color: #06266F;"><asp:TextBox ID="TextBox5" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">ชื่อสินค้า :</asp:TextBox></td>
                                    <td>

                                        <asp:TextBox ID="tPdtName" runat="server" BorderStyle="None" Width="194px" ReadOnly="True"></asp:TextBox>

                                    </td>
                                </tr>
                                <tr>
                                    <td class="auto-style2" style="text-align: right; color: #06266F;"><asp:TextBox ID="TextBox6" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">ราคา :</asp:TextBox></td>
                                    <td>
                                         
                                        <asp:TextBox ID="tPrice" runat="server" BorderStyle="None" Width="194px" ReadOnly="True"></asp:TextBox>

                                    </td>
                                </tr>
                                 <tr>
                                    <td class="auto-style2" style="text-align: right; color: #06266F;"><asp:TextBox ID="TextBox1" runat="server" BorderStyle="None" ReadOnly="True" Width="100px" ForeColor="#003399" style="text-align:right">จำนวนทั้งหมด :</asp:TextBox></td>
                                    <td>
                                       
                                        <asp:TextBox ID="tAmount" runat="server" BorderStyle="None" Width="194px" ReadOnly="True"></asp:TextBox>

                                    </td>
                                </tr>
                                 <tr>
                                    <td class="auto-style2" style="text-align: right; color: #06266F;"><asp:TextBox ID="TextBox2" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">ราคารวม :</asp:TextBox></td>
                                    <td>
                                        
                                        <asp:TextBox ID="tGrandTotal" runat="server" BorderStyle="None" Width="194px" ReadOnly="True"></asp:TextBox>

                                    </td>
                                </tr>
                                <tr>
                                    <td class="auto-style2" style="text-align: right; vertical-align: top; color: #06266F;"><asp:TextBox ID="TextBox7" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">รหัสลูกค้า :</asp:TextBox></td>
                                    <td class="auto-style3">
                                        <asp:TextBox ID="tARCode" runat="server" BorderStyle="None" Width="194px"   ReadOnly="True"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="auto-style2" style="text-align: right; vertical-align: top; color: #06266F;"><asp:TextBox ID="TextBox8" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">ชื่อลูกค้า :</asp:TextBox></td>
                                    <td class="auto-style3">
                                        <asp:TextBox ID="tARName" runat="server" BorderStyle="None" TextMode="MultiLine" Width="194px" ReadOnly="True"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="auto-style2" style="text-align: right; color: #06266F;"></td>
                                    <td class="auto-style3">
                                        

                                    </td>
                                </tr>
                            </table>
                            <br />

                        </div>
                        <div class="col-xs-6">
                            <br />
                            <br />
                            <table class="nav-justified">
                                <tr>
                                    <td class="auto-style2" style="text-align: right; vertical-align: top; color: #06266F;"><asp:TextBox ID="TextBox12" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">วันจอง :</asp:TextBox></td>
                                    <td>
                                        
                                        <asp:TextBox ID="tDate" runat="server" BorderStyle="None" Width="194px" ReadOnly="True"></asp:TextBox>

                                    
                                    </td>
                                </tr>
                                <tr>
                                    <td class="auto-style2" style="text-align: right; vertical-align: top; color: #06266F;"><asp:TextBox ID="TextBox11" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">ที่อยู่ :</asp:TextBox></td>
                                    <td>
                                        <asp:TextBox ID="tAddress" runat="server" TextMode="MultiLine" BorderStyle="None" Height="95px" Width="180px" ReadOnly="True"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="auto-style2" style="text-align: right; color: #06266F;"><asp:TextBox ID="TextBox10" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">โทร :</asp:TextBox></td>
                                    <td>
                                        
                                        <asp:TextBox ID="tPhone" runat="server" BorderStyle="None" Width="194px" ReadOnly="True"></asp:TextBox>

                                    </td>
                                </tr>
                                <tr>
                                    <td class="auto-style2" style="text-align: right; color: #06266F;"><asp:TextBox ID="TextBox9" runat="server" BorderStyle="None" ReadOnly="True" Width="90px" ForeColor="#003399" style="text-align:right">หมายเหตุ :</asp:TextBox></td>
                                    <td>
                                        
                                        <asp:TextBox ID="tDescription" runat="server" BorderStyle="None" Width="194px" ReadOnly="True"></asp:TextBox>

                                    

                                    </td>
                                </tr>
                            </table>
                            <br />

                        </div>

                    </div>
                </div>

                <br />
                <div class="ex" style="display: table; margin-right: auto; margin-left: auto;">



                    <span style="color: #4671D5">สถานะ</span><br />

                    <span style="color: #06266F">ใบส่งของ :</span>&nbsp;
                    <asp:Label ID="lDelivery" runat="server"></asp:Label>&nbsp;&nbsp;
                    <span style="color: #06266F">ยกเลิก :</span>&nbsp;
                    <asp:Label ID="lCancel" runat="server"></asp:Label>
                    &nbsp;&nbsp;
                    <span style="color: #06266F">ยืนยัน : </span>&nbsp;
                    <asp:Label ID="lConfirm" runat="server"></asp:Label>&nbsp;&nbsp;
                    <span style="color: #06266F">อนุมัติ : </span>&nbsp;
                    <asp:Label ID="lAppove" runat="server"></asp:Label>

                </div>
                <br />
                <div class="ex" style="display: table; margin-right: auto; margin-left: auto; text-align: center;">

                    <asp:Button ID="Button3" runat="server" Text="กลับตารางหลัก" CssClass="btn btn-primary" />&nbsp;&nbsp;
                    <asp:Button ID="Button2" runat="server" Text="ยืนยัน" CssClass="btn btn-primary" />
                    <asp:Button ID="Button6" runat="server" Text="ยกเลิก" CssClass="btn btn-primary" />
                    <asp:Button ID="Button7" runat="server" Text="อนุมัติ" CssClass="btn btn-primary" />


                </div>
            </div>
            <div id="DivGrid" class="ex" style="display: table; margin-right: auto; margin-left: auto;">
                <asp:DropDownList ID="DropDownList1" runat="server" Width="150px">
                    <asp:ListItem>ทั้งหมด</asp:ListItem>
                    <asp:ListItem>ยกเลิก</asp:ListItem>
                    <asp:ListItem>ยืนยัน</asp:ListItem>
                    <asp:ListItem>อนุมัติ</asp:ListItem>
                    <asp:ListItem>ส่งมอบ</asp:ListItem>
                    <asp:ListItem>Invoice</asp:ListItem>
                </asp:DropDownList>
                &nbsp;<span style="color: #2A4480">คลิกที่แถวเพื่อเข้าสู่รายละเอียดของแต่ละรายการ</span><br />
                
                <asp:GridView ID="GV" runat="server" AutoGenerateColumns="False" style="table-layout:fixed;" Width="640px">
                    <AlternatingRowStyle BackColor="#F0F0F0" />
                    <Columns>

                        <asp:TemplateField HeaderText="เลขที่เอกสาร" >
                            <ItemTemplate>
                                <asp:Label ID="lblNo" runat="server"></asp:Label>

                            </ItemTemplate>  
                            <HeaderStyle Width="100px" HorizontalAlign="Left" Wrap="False"></HeaderStyle>                             
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="ราคา">
                            <ItemTemplate>
                                <asp:Label ID="lblPrice" runat="server"></asp:Label>
                            </ItemTemplate>       
                            <HeaderStyle Width="80px" HorizontalAlign="right" Wrap="False"></HeaderStyle>                      
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="รหัสลูกค้า">
                            <ItemTemplate>
                                <asp:Label ID="lblARCode" runat="server"></asp:Label>
                            </ItemTemplate>   
                            <HeaderStyle Width="80px" HorizontalAlign="Left" Wrap="False"></HeaderStyle>                        
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="ชื่อลูกค้า">
                            <ItemTemplate>
                                <asp:Label ID="lblARName" runat="server"></asp:Label>
                            </ItemTemplate>   
                            <HeaderStyle Width="150px" HorizontalAlign="Left" Wrap="False"></HeaderStyle>                           
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Invoice">
                            <ItemTemplate>
                                <asp:Label ID="lblInvoice" runat="server"></asp:Label>
                            </ItemTemplate>  
                             <HeaderStyle Width="50px" HorizontalAlign="Left" Wrap="False"></HeaderStyle>                              
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="ส่งมอบ">
                            <ItemTemplate>
                                <asp:Label ID="lblDelivery" runat="server"></asp:Label>
                            </ItemTemplate>     
                             <HeaderStyle Width="50px" HorizontalAlign="Left" Wrap="False"></HeaderStyle>                  
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="ยืนยัน">
                            <ItemTemplate>
                                <asp:Label ID="lblConfirm" runat="server"></asp:Label>
                            </ItemTemplate>     
                             <HeaderStyle Width="50px" HorizontalAlign="Left" Wrap="False"></HeaderStyle>                     
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="อนุมัติ" >
                            <ItemTemplate>
                                <asp:Label ID="lblApprove" runat="server"></asp:Label>
                            </ItemTemplate> 
                             <HeaderStyle Width="50px" HorizontalAlign="Left" Wrap="False"></HeaderStyle>                             
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="ยกเลิก">
                            <ItemTemplate>
                                <asp:Label ID="lblCancel" runat="server"></asp:Label>
                            </ItemTemplate>   
                             <HeaderStyle Width="50px" HorizontalAlign="Left" Wrap="False"></HeaderStyle>                           
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="lblLn">
                            <ItemTemplate>
                                <asp:Label ID="lblLn" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="lblDate">
                            <ItemTemplate>
                                <asp:Label ID="lblDate" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="lblAddress">
                            <ItemTemplate>
                                <asp:Label ID="lblAddress" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="lblDescription">
                            <ItemTemplate>
                                <asp:Label ID="lblDescription" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="lblTel">
                            <ItemTemplate>
                                <asp:Label ID="lblTel" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="lblGrandTotal">
                            <ItemTemplate>
                                <asp:Label ID="lblGrandTotal" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                       <asp:TemplateField HeaderText="lblAmount">
                            <ItemTemplate>
                                <asp:Label ID="lblAmount" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        
                    </Columns>
                    <HeaderStyle BackColor="#2D3E5B" ForeColor="White" />
                </asp:GridView>

                <br />
            </div>
        </div>

        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>


    </form>
</body>
</html>
