<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Client/ClientMaster.master" CodeBehind="EditAccident.aspx.vb" Inherits="Web.EditAccident" %>
<%@ MasterType VirtualPath="ClientMaster.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="phContent" runat="server">

    <div class="container">
        <h1><%= If(accidentId, "Edit Accident", "Add Accident") %></h1>

        <ul id="tabList" class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link active" href="#general" data-toggle="tab">General Information</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#docs" data-toggle="tab">Documents</a>
            </li>
        </ul>

        <div class="tab-content bg-white border border-top-0 p-3 mb-3">


            <!-- General information tab -->
            <div id="general" class="tab-pane show active">

                <div class="form-group">
                    <asp:RequiredFieldValidator runat="server" ControlToValidate="txtDate"
                        Text="required" Display="Dynamic" CssClass="required" />
                    <asp:Label runat="server" AssociatedControlID="txtDate" Text="Date" />
                    <asp:TextBox ID="txtDate" runat="server" TextMode="Date" CssClass="form-control" />
                    <asp:RequiredFieldValidator runat="server" ControlToValidate="txtDate"
                        Text="required" Display="Dynamic" CssClass="text-danger" />
                </div>
                <div class="form-group">
                    <asp:Label runat="server" AssociatedControlID="ddlDriver" Text="Driver" />
                    <asp:DropDownList ID="ddlDriver" runat="server" CssClass="form-control" />
                    <asp:RequiredFieldValidator runat="server" ControlToValidate="ddlDriver"
                        Text="required" Display="Dynamic" CssClass="text-danger" />
                </div>
                <div class="form-group">
                    <asp:Label runat="server" AssociatedControlID="ddlVehicle1" Text="Vehicle 1" />
                    <asp:DropDownList ID="ddlVehicle1" runat="server" CssClass="form-control" />
                </div>
                <div class="form-group">
                    <asp:Label runat="server" AssociatedControlID="ddlVehicle2" Text="Vehicle 2" />
                    <asp:DropDownList ID="ddlVehicle2" runat="server" CssClass="form-control" />
                </div>
                <div class="form-group">
                    <asp:Label runat="server" AssociatedControlID="ddlVehicle3" Text="Vehicle 3" />
                    <asp:DropDownList ID="ddlVehicle3" runat="server" CssClass="form-control" />
                </div>
                <div class="form-group">
                    <asp:Label runat="server" AssociatedControlID="txtCityState" Text="City/State" />
                    <asp:TextBox ID="txtCityState" runat="server" MaxLength="200" CssClass="form-control" />
                </div>
                <div class="form-group">
                    <asp:Label runat="server" AssociatedControlID="txtInjured" Text="Number Injured" />
                    <asp:TextBox ID="txtInjured" runat="server" TextMode="Number" CssClass="form-control" />
                </div>
                <div class="form-group">
                    <asp:Label runat="server" AssociatedControlID="txtFatal" Text="Number Fatal" />
                    <asp:TextBox ID="txtFatal" runat="server" TextMode="Number" CssClass="form-control" />
                </div>
                <div class="form-group">
                    <asp:CheckBox ID="chkTowed" runat="server" Text="Vehicle Towed" />
                </div>
                <div class="form-group">
                    <asp:CheckBox ID="chkHazmat" runat="server" Text="HAZMAT" />
                </div>
                <div class="form-group">
                    <asp:CheckBox ID="chkAccident" runat="server" Text="Accident Report" />
                </div>
                <div class="form-group">
                    <asp:CheckBox ID="chkCited" runat="server" Text="Cited" />
                </div>
                <div class="form-group">
                    <asp:CheckBox ID="chkPostAccident" runat="server" Text="Post-Accident Documentation" />
                </div>
                <script>
                    $(document).ready(function () {
                        var chkCited = $('#<%= chkCited.ClientID %>');
                        var chkPostAccident = $('#<%= chkPostAccident.ClientID %>');
                        chkCited.change(function () {
                            chkPostAccident.prop('checked', false);
                            chkPostAccident.prop('disabled', !chkCited.prop('checked'));
                        });
                    });
                </script>

                <div class="form-group">
                    <asp:Label runat="server" AssociatedControlID="txtDescription" Text="Description" />
                    <asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" MaxLength="1000" CssClass="form-control" />
                </div>
           </div>

            <!-- Documents tab -->
            <div id="docs" class="tab-pane">
                <div class="table-responsive">
                    <asp:GridView ID="gvDocs" runat="server" DataSourceID="dsDocs" AutoGenerateColumns="false" AllowSorting="true"
                        CssClass="table clickable-rows table-hover floating-hscroll" CellSpacing="-1" GridLines="None" data-fixed-columns="true" data-fixed-number="2">
                        <HeaderStyle CssClass="thead-light" />
                        <Columns>
                            <asp:BoundField HeaderText="Document Type" SortExpression="DocSubCategory" DataField="DocSubCategory" />
                            <asp:BoundField HeaderText="File name" SortExpression="DocName" DataField="DocName" />
                            <asp:BoundField HeaderText="Date" SortExpression="EnteredDate" DataField="EnteredDate" DataFormatString="{0:d}" />
                            <asp:HyperLinkField DataNavigateUrlFields="ContractID,ID,Ctx,ItemID" DataNavigateUrlFormatString="DocumentEdit.aspx?cid={0}&docid={1}&ctx={2}&id={3}" Text="Edit" />
                            <asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="/_assets/Document.aspx?context=DocumentNew&id={0}" Target="_blank" Text="view" />
                        </Columns>
                        <EmptyDataTemplate>
                            <p>There are no note entries.</p>
                        </EmptyDataTemplate>
                    </asp:GridView>
                    <asp:SqlDataSource ID="dsDocs" runat="server"
                        SelectCommand ="
                            SELECT DocumentsNew.ContractID,ISNULL(DocumentsNew.ItemID,0) AS ItemID,'AccidentEdit' as Ctx,DocumentsNew.ID,DocumentsNew.DocName,DocumentsNew.EnteredDate,ISNULL(DocumentsSubCategory.Name,'') AS DocSubCategory,DocumentsNew.UploadNotes
                            FROM DocumentsNew LEFT JOIN DocumentsSubCategory ON DocumentsNew.SubCategoryID=DocumentsSubCategory.Id
                            WHERE DocumentsNew.ItemID=@ItemId AND DocumentsNew.CategoryID=@CatID AND (ISNULL(DocumentsNew.Deleted,0) = 0) ORDER BY ISNULL(DocumentsSubCategory.Name,''),DocumentsNew.DocName,DocumentsNew.ID">
                        <SelectParameters>
                            <asp:Parameter Name="CatID" />
                            <asp:Parameter Name="ItemId" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </div>
            </div>

        </div>

        <div class="row">
            <div class="col">
                <asp:Button ID="btnCancel" runat="server" CssClass="btn btn-secondary" Text="Cancel" CausesValidation="false" />
            </div>
            <div class="col text-right">
                <asp:Button ID="btnDownloadAll" runat="server" CssClass="btn btn-primary" Text="Download All" CausesValidation="false" Width="150px" />
                <asp:Button ID="btnUploadDoc" runat="server" CssClass="btn btn-primary" Text="Upload Document" CausesValidation="false"  Width="150px" />
                <asp:Button ID="btnSave" runat="server" CssClass="btn btn-primary" Text="Save" Width="150px" />
            </div>
        </div>

    </div>

</asp:Content>
