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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">

    <link rel="stylesheet" href="demoValidators/css/validationEngine.jquery.css" type="text/css" />
    <link rel="stylesheet" href="demoValidators/css/template.css" type="text/css" />
    <script src="demoValidators/js/jquery-1.6.min.js" type="text/javascript">	</script>
    <script src="demoValidators/js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
    <script src="demoValidators/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
        var JValid = jQuery.noConflict(true);
    </script>

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link href="Scripts/Site2.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/redmond/jquery-ui.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="themes/ui.jqgrid.css" />
    <%--<script src="Scripts/jquery-2.0.3.min.js" type="text/javascript"></script>--%><%--    <script src="/Scripts/trirand/i18n/grid.locale-th.js" type="text/javascript"></script>
    <script src="/Scripts/trirand/jquery.jqGrid.min.js" type="text/javascript"></script>--%>

    <script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
    <script type="text/javascript" src="Scripts/jquery-1.4.1-vsdoc.js"></script>
    <script type="text/javascript" src="Scripts/thickbox.js"></script>
    <link rel="stylesheet" href="Scripts/thickbox.css" type="text/css" media="screen" />
    <%-- <link type="text/css" rel="stylesheet" href="css/style.css" />--%>
    <link href="css/style.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/jquery.cookie.js"></script>
    <link href="Content/bootstrap/bootstrap.css" rel="stylesheet" />
    <style type="text/css">
        .centered-table
        {
            margin-left: auto;
            margin-right: auto;
        }

        body
        {
            overflow: hidden;
        }

        .SelectD
        {
            text-align: center;
            vertical-align: middle;
            background-color: #ffb100;
            font-size: 15px;
            color: black;
            height: 50px;
            width: 50px;
            float: left;
            margin-right: 2px;
            margin-bottom: 2px;
            /*-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;*/
        }


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

        .header
        {
            height: 50px;
            background: #F0F0F0;
            border: 1px solid #CCC;
            width: 960px;
            margin: 0px auto;
        }

        .auto-style6
        {
            width: 419px;
        }

        .auto-style7
        {
            width: 77px;
        }

        .auto-style8
        {
            width: 78px;
        }
    </style>

    <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, " "));
        }

        function formatDollar(num) {
            var p = num.toFixed(2).split(".");
            return p[0].split("").reverse().reduce(function (acc, num, i, orig) {
                return num + (i && !(i % 3) ? "," : "") + acc;
            }, "") + "." + p[1];
        }

        function PushMoney(Cnntrl, Price, Amount, CurrentVal) {
            var aa1 = $("#txtDateArr").val();
            var aa2 = $("#txtNCol").val();
            //var StartCol = 0;
            //CurrentVal = (parseInt(StartCol) + 1)
            if ($("#" + Cnntrl).hasClass('UnSelectD')) {
                //aa2 = 'UnSelectD'
                var things = aa2.split(',');
                aa2 = '';
                aa1 = '';
                for (var i = 0; i < things.length; i++) {
                    if (things[i] != CurrentVal) {
                        if (things[i].length > 0) {
                            if (aa2 === '') {
                                aa2 = things[i];
                                aa1 = 'D' + things[i];
                            } else {
                                aa2 = aa2 + ',' + things[i];
                                aa1 = aa1 + ',D' + things[i];
                            }
                        }
                    }
                }

                var Amount2 = parseInt(Amount.replace(/[$,]+/g, ""));
                var Price2 = parseFloat(Price.replace(/[$,]+/g, ""));
                Amount2 = Amount2 - 1;
                var GrandTotal = Price2 * Amount2;

            }

            if ($("#" + Cnntrl).hasClass('SelectD')) {
                //aa2 = 'SelectD'
                if (aa2 === '') {
                    aa2 = CurrentVal;
                    aa1 = 'D' + CurrentVal;
                } else {
                    aa2 = aa2 + "," + CurrentVal;
                    aa1 = aa1 + "," + 'D' + CurrentVal;
                }

                var Amount2 = parseInt(Amount.replace(/[$,]+/g, ""));
                var Price2 = parseFloat(Price.replace(/[$,]+/g, ""));
                Amount2 = Amount2 + 1;

                var GrandTotal = Price2 * Amount2;

            }
            $("#txtAmountDay").val(Amount2);
            $("#HdAmountDay").val(Amount2);
            $("#HdGrandTotal").val(GrandTotal)

            $("#txtNCol").val(aa2);
            $("#HF1").val(aa2);
            $("#txtDateArr").val(aa1);
            $("#HFtxtArray").val(aa1);

            return formatDollar(GrandTotal);

        }

        $(document).ready(function () {

            if (getParameterByName('Mode') === 'New') {
                $("#GotoNew").hide();
            }

            JValid("#FormSONew").validationEngine();

            $("#DivDate div").hover(function () {
                $(this).css('cursor', 'pointer');
                //$(this).toggleClass("SelectD UnSelectD");
            });


            $("#DivDate div").click(function () {

                $(this).toggleClass("SelectD UnSelectD");
                var currentId = $(this).attr('id');
                var CurrentVal = currentId.substring(1);

                $("#txtGrandTotal").val(PushMoney(currentId, $("#txtPrice").val(), $("#txtAmountDay").val(), CurrentVal));
                $("#HdGrandTotal").val($("#txtGrandTotal").val());
          
            });

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


        });

    </script>
    <title></title>

</head>
<body>
    <div class="panel panel-default">
        <div class="panel-heading">
            <button type="button" id="GotoNew" class="btn btn-warning" style="background-color: #4671D5">
                <span class="glyphicon glyphicon-fast-backward"></span>กลับไปหน้ารายละเอียดการจอง</button>
        </div>
        <div class="panel-body">

            <form id="FormSONew" runat="server">
                <div id="DAll" class="ex" runat="server" style="display: table; margin-right: auto; margin-left: auto;">
                    <div class="panel-heading"><span style="color: #4671D5" class="glyphicon glyphicon-check"><strong>เลือกวัน</strong></span></div>
                    <div id="DivDate">
                        <div id='D1' runat="server" class="UnSelectD"></div>
                        <div id='D2' runat="server" class="UnSelectD"></div>
                        <div id='D3' runat="server" class="UnSelectD"></div>
                        <div id='D4' runat="server" class="UnSelectD"></div>
                        <div id='D5' runat="server" class="UnSelectD"></div>
                        <div id='D6' runat="server" class="UnSelectD"></div>
                        <div id='D7' runat="server" class="UnSelectD"></div>
                        <div id='D8' runat="server" class="UnSelectD"></div>
                        <div id='D9' runat="server" class="UnSelectD"></div>
                        <div id='D10' runat="server" class="UnSelectD"></div>
                        <div id='D11' runat="server" class="UnSelectD"></div>
                        <div id='D12' runat="server" class="UnSelectD"></div>
                        <div id='D13' runat="server" class="UnSelectD"></div>
                        <div id='D14' runat="server" class="UnSelectD"></div>
                        <div id='D15' runat="server" class="UnSelectD"></div>
                        <div id='D16' runat="server" class="UnSelectD"></div>
                        <div id='D17' runat="server" class="UnSelectD"></div>
                        <div id='D18' runat="server" class="UnSelectD"></div>
                        <div id='D19' runat="server" class="UnSelectD"></div>
                        <div id='D20' runat="server" class="UnSelectD"></div>
                        <div id='D21' runat="server" class="UnSelectD"></div>
                        <div id='D22' runat="server" class="UnSelectD"></div>
                        <div id='D23' runat="server" class="UnSelectD"></div>
                        <div id='D24' runat="server" class="UnSelectD"></div>
                        <div id='D25' runat="server" class="UnSelectD"></div>
                        <div id='D26' runat="server" class="UnSelectD"></div>
                        <div id='D27' runat="server" class="UnSelectD"></div>
                        <div id='D28' runat="server" class="UnSelectD"></div>
                        <div id='D29' runat="server" class="UnSelectD"></div>
                        <div id='D30' runat="server" class="UnSelectD"></div>
                        <div id='D31' runat="server" class="UnSelectD"></div>
                    </div>
                    <br />
                    <br />
                    <br />
                    <br />
                    <br />
                    <br />
                    <br />
                </div>
                <br />

                <div id="DSelect" runat="server" class="ex" style="display: table; margin-right: auto; margin-left: auto;">

                    <table class="nav-justified">
                        <tr>
                            <td class="auto-style6">

                                <table>
                                    <tr>
                                        <td style="text-align: right" class="auto-style8">ผู้จอง :&nbsp; </td>
                                        <td>
                                            <asp:TextBox ID="txtARName" runat="server" CssClass="validate[required] text-input" Width="200px" TextMode="MultiLine" ReadOnly="True"></asp:TextBox>
                                            <asp:HyperLink ID="HyperLink1" runat="server" CssClass="btn btn-success">เลือกลูกค้า</asp:HyperLink>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: right" class="auto-style8">ที่อยู่ :&nbsp; </td>
                                        <td>
                                            <asp:TextBox ID="txtAddress" runat="server" Width="200px" TextMode="MultiLine" ReadOnly="True"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: right" class="auto-style8">โทร :&nbsp; </td>
                                        <td>
                                            <asp:TextBox ID="txtPhone" runat="server" Width="200px" ReadOnly="True"></asp:TextBox>

                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: right" class="auto-style8">โน๊ต :&nbsp; </td>
                                        <td>
                                            <asp:TextBox ID="txtDescription" runat="server" Width="200px" TextMode="MultiLine"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>


                            </td>
                            <td>
                                <table class="nav-justified">
                                    <tr>
                                        <td class="auto-style7">&nbsp;</td>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td class="auto-style7" style="text-align: right">ราคา : </td>
                                        <td>
                                            <asp:TextBox ID="txtPrice" runat="server" ReadOnly="True" Width="70px" Style="text-align: right">0.00</asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="auto-style7" style="text-align: right">จำนวนวัน :&nbsp; </td>
                                        <td>
                                            <asp:TextBox ID="txtAmountDay" runat="server" ReadOnly="True" Width="70px" Style="text-align: right">0</asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="auto-style7" style="text-align: right">รวม :&nbsp; </td>
                                        <td>

                                            <asp:TextBox ID="txtGrandTotal" runat="server" ReadOnly="True" Width="70px" Style="text-align: right">0.00</asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <br />


                </div>

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

                    <asp:Button ID="save" runat="server" Text="บันทึกการจอง" CssClass="btn btn-primary" />

                    <br />
                    <asp:Label ID="lblMessage" runat="server" Visible="False"></asp:Label>

                    <asp:HiddenField ID="HdARName" runat="server" />
                    <asp:HiddenField ID="HdAddress" runat="server" />

                    <asp:HiddenField ID="HdPhone" runat="server" />
                    <asp:HiddenField ID="HdPrice" runat="server" />
                    <asp:HiddenField ID="HdGrandTotal" runat="server" />
                    <asp:HiddenField ID="HdAmountDay" runat="server" />

                </div>



                <div style="display:none">
                    <asp:TextBox ID="txtNPdtCode" runat="server" ReadOnly="True"></asp:TextBox>
                    <asp:TextBox ID="txtSaleNo" runat="server" BackColor="#CCFFCC" ReadOnly="True"></asp:TextBox>
                    <asp:TextBox ID="txtSaleDate" runat="server" ReadOnly="True"></asp:TextBox>
                    <br />
                    <asp:TextBox ID="txtNPdtName" runat="server" ReadOnly="True"></asp:TextBox>
                    <asp:TextBox ID="txtARCode" runat="server" Height="16px" Width="65px"></asp:TextBox>
                    <br />
                    <asp:TextBox ID="txtNPdtUnit" runat="server" ReadOnly="True"></asp:TextBox>
                    <asp:TextBox ID="txtDateArr" runat="server" ReadOnly="True"></asp:TextBox>
                    <asp:HiddenField ID="HF1" runat="server" />
                    <asp:HiddenField ID="HFtxtArray" runat="server" />
                    <br />
                    <asp:TextBox ID="txtNCol" runat="server" BackColor="#FF9933" ReadOnly="True"></asp:TextBox>
                    <br />
                    <asp:TextBox ID="txtNRow" runat="server" BackColor="#FF9933" ReadOnly="True"></asp:TextBox>
                    <br />
                    <asp:TextBox ID="txtNYear" runat="server" ReadOnly="True"></asp:TextBox>
                    <br />
                    <asp:TextBox ID="txtNMonth" runat="server" ReadOnly="True"></asp:TextBox>
                    <br />
                    <asp:TextBox ID="txtNDay" runat="server" ReadOnly="True"></asp:TextBox>
                </div>

            </form>
        </div>
    </div>


</body>
</html>
