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

    <div class="container">
        <asp:Button ID="btnAdd" runat="server" CssClass="btn btn-primary float-right" Text="Add Accident" />
        <h1>Accidents</h1>
        
        <div class="table-responsive">
            <asp:GridView ID="gvAccidents" runat="server" DataSourceID="dsAccidents" AutoGenerateColumns="false" AllowSorting="true"
                CssClass="table clickable-rows table-hover floating-hscroll" CellSpacing="-1" GridLines="None" data-fixed-columns="true" data-fixed-right-number="2" data-fixed-number="4">
                <HeaderStyle CssClass="thead-light" />
                <Columns>
                    <asp:BoundField HeaderText="Date" SortExpression="AccidentDate" DataField="AccidentDate" DataFormatString="{0:d}" />
                    <asp:BoundField HeaderText="Driver" SortExpression="DriverName" DataField="DriverName" />
                    <asp:BoundField HeaderText="Vehicle" SortExpression="VehicleDesc" DataField="VehicleDesc" />
                    <asp:BoundField HeaderText="City/State" SortExpression="CityState" DataField="CityState" />
                    <asp:BoundField HeaderText="Injured" SortExpression="NumberInjured" DataField="NumberInjured" />
                    <asp:BoundField HeaderText="Fatal" SortExpression="NumberFatal" DataField="NumberFatal" />
                    <asp:CheckBoxField HeaderText="Towed" SortExpression="VehicleTowed" DataField="VehicleTowed" />
                    <asp:CheckBoxField HeaderText="HazMat" SortExpression="HazMatRelease" DataField="HazMatRelease" />
                    <asp:CheckBoxField HeaderText="Accident Report" SortExpression="AccidentReport" DataField="AccidentReport" />
                    <asp:CheckBoxField HeaderText="Cited" SortExpression="Cited" DataField="Cited" />
                    <asp:CheckBoxField HeaderText="Post Acc. Doc." SortExpression="PostAccidentDocumentation" DataField="PostAccidentDocumentation" />
                    <asp:BoundField HeaderText="Description" SortExpression="Description" DataField="Description" />
                    <asp:TemplateField HeaderText="">
                        <ItemTemplate>
                            <div class="text-right">
                                <a href="DocumentsNew.aspx?ctx=Accident&id=<%# Eval("id") %>&cid=<%# Eval("ContractID") %>" >
                                    <i class="fa fa-fw fa-file"></i>
                                </a>
                            </div>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="">
                        <ItemTemplate>
                            <div class="text-right">
                                <a href="RemoveAccident.aspx?id=<%# Eval("id") %>&cid=<%# Eval("ContractID") %>" class="btn btn-outline-danger">
                                    <i class="fa fa-trash-alt fa-fw" title="delete"></i>
                                </a>
                            </div>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                    <p>There are no accidents entered.</p>
                </EmptyDataTemplate>
            </asp:GridView>
            <asp:SqlDataSource ID="dsAccidents" runat="server" SelectCommand="
                SELECT ID,AccidentDate,DriverName,VehicleDesc,CityState,NumberInjured,NumberFatal,VehicleTowed,HazMatRelease,AccidentReport,Cited,PostAccidentDocumentation,Description,ContractID
                FROM Accident WHERE ContractID=@contractId
                ORDER BY AccidentDate DESC, ID">
                <SelectParameters>
                    <asp:Parameter Name="contractId" />
                </SelectParameters>
            </asp:SqlDataSource>
        </div>

    </div>

</asp:Content>
