<%@ Page Language="vb" title="All Sent Messages" MasterPageFile="~/Root.Master" AutoEventWireup="false" CodeBehind="AllSent.aspx.vb" Inherits="MessageManager.AllSent" %>
<%@ Register Assembly="DevExpress.Web.v24.2, Version=24.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v24.2, Version=24.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Data.Linq" TagPrefix="dx" %>

<asp:Content ID="Content5" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table Width="100%">
        <tr>
            <td><asp:Button ID="btnRefresh" runat="server" BackColor="#00ffff" Text="Refresh Page" Width="100" /></td>
            <td><dx:ASPxLabel for="StartDate" runat="server" Text="Start Date:"></dx:ASPxLabel></td>
            <td>&nbsp;<input type="date" id="StartDate" name="StartDate" runat="server"></td>
            <td>&nbsp;<dx:ASPxLabel for="EndtDate" runat="server" Text="End Date:"></dx:ASPxLabel></td>
            <td>&nbsp;<input type="date" id="EndDate" name="EndDate" runat="server"></td>
            <td>&nbsp;<dx:ASPxLabel ID="ASPxLblMbrs" runat="server" Text="Created By: "></dx:ASPxLabel></td>
            <td>&nbsp;<asp:DropDownList ID="cboMembers" AutoPostBack="True" DataTextField="Me_Name" DataValueField="Me_Username" runat="server" Width="200px" DataSourceID="SqlDataSource2" >
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:MMConnectionString %>" SelectCommand="SELECT DISTINCT MBR.Me_Username, MBR.Me_Name FROM tab_Members MBR JOIN tab_Messages MSG ON MSG.Msg_Username = MBR.Me_Username WHERE MBR.Me_Active = 'Yes' ORDER BY MBR.Me_Name;">
                </asp:SqlDataSource>
            </td>
            <td>&nbsp;<dx:ASPxLabel ID="ASPxLabel" runat="server" Text="Assigned To: "></dx:ASPxLabel></td>
            <td>&nbsp;<asp:DropDownList ID="cboAssignees" AutoPostBack="True" DataTextField="Me_Name" DataValueField="Me_Username" runat="server" Width="200px" DataSourceID="SqlDataSource4" >
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:MMConnectionString %>" SelectCommand="SELECT DISTINCT MBR.Me_Username, MBR.Me_Name FROM tab_Members MBR JOIN tab_Messages MSG ON MSG.Msg_Assigned = MBR.Me_Username ORDER BY MBR.Me_Name;">
                </asp:SqlDataSource>
            </td>
            <td>&nbsp;&nbsp;<asp:Button ID="BtnHome" runat="server" BackColor="#00ffff" Text="Home" Width="80" /></td>
        </tr>
    </table>
    <br />
    <dx:ASPxGridView ID="ASPxGridView1" CssClass="grid-view" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" KeyFieldName="Msg_Index" Width="100%" EnableTheming="True" OnBeforeExport="grid_BeforeExport" Theme="Default" Settings-UseFixedTableLayout="true">
        <SettingsExport EnableClientSideExportAPI="true" FileName="All Sent Messages" Landscape="True" PaperKind="Legal" ReportFooter="Report Footer" ReportHeader="Report Header" ExcelExportMode="WYSIWYG" MaxColumnWidth="200">
            <PageHeader Center="All Sent Messages">
            </PageHeader>
            <PageFooter Center="All Sent Messages">
            </PageFooter>
        </SettingsExport>
        <Toolbars>
            <dx:GridViewToolbar>
                <SettingsAdaptivity Enabled="true" EnableCollapseRootItemsToIcons="true" />
                <Items>
                    <dx:GridViewToolbarItem Command="ExportToPdf" />
                    <dx:GridViewToolbarItem Command="ExportToXls" />
                    <dx:GridViewToolbarItem Command="ExportToXlsx" />
                    <dx:GridViewToolbarItem Command="ExportToDocx" />
                    <dx:GridViewToolbarItem Command="ExportToRtf" />
                    <dx:GridViewToolbarItem Command="ExportToCsv" />
                </Items>
            </dx:GridViewToolbar>
        </Toolbars>
        <SettingsPager PageSize="1000" Visible="False">
        </SettingsPager>
        <Settings ShowGroupPanel="True" ShowFooter="True" ShowGroupFooter="VisibleAlways" />

        <SettingsPopup>
            <FilterControl AutoUpdatePosition="True"></FilterControl>
        </SettingsPopup>

        <SettingsDataSecurity AllowDelete="False" AllowEdit="False" AllowInsert="False" />

        <SettingsSearchPanel Visible="True" />  
        <Columns>
            <dx:GridViewDataTextColumn FieldName="Index" ReadOnly="True" VisibleIndex="1" Width="80px">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Created By" ReadOnly="True" VisibleIndex="2">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Site" ReadOnly="True" VisibleIndex="3" Width="40px">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Location" ReadOnly="True" VisibleIndex="4">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Team" ReadOnly="True" VisibleIndex="5">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Reason" ReadOnly="True" VisibleIndex="6">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Cr.Dt"  ReadOnly="True" VisibleIndex="7" Width="80px">
                <PropertiesTextEdit DisplayFormatString="d MMM yyyy">
                </PropertiesTextEdit>
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Cr.Tm" ReadOnly="True" VisibleIndex="8" Width="60px">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Medication" ReadOnly="True" VisibleIndex="9">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Done" ReadOnly="True" VisibleIndex="10" Width="40px">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Pr.Tm" ReadOnly="True" VisibleIndex="11" Width="100px">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Assignee" ReadOnly="True" VisibleIndex="12" Width="200px">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
        </Columns>
         <TotalSummary>
            <dx:ASPxSummaryItem FieldName="Index" SummaryType="Count" Tag="TotalMessages" />
        </TotalSummary>
        <GroupSummary>
            <%-- Group Summary Item 1 --%>
            <dx:ASPxSummaryItem FieldName="Index" ShowInColumn="Index" SummaryType="Count" />
            <dx:ASPxSummaryItem FieldName="Index" ShowInGroupFooterColumn="Index" SummaryType="Count" Tag="GroupMessages" />
        </GroupSummary>
        <Styles>
            <Cell Wrap="false" />
            <Footer BackColor="Aqua">
            </Footer>
            <PagerBottomPanel CssClass="pager" />
                 <AlternatingRow BackColor="#E4E4E4">
                 </AlternatingRow>
            <FocusedRow CssClass="focused" BackColor="#FFFF99" ForeColor="Black" />
                 <CommandColumn ForeColor="Black">
                 </CommandColumn>
                 <CommandColumnItem ForeColor="#3399FF">
                 </CommandColumnItem>
        </Styles>    
    </dx:ASPxGridView>

    <dx:ASPxGridView ID="ASPxGridView2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3" KeyFieldName="Adm_Username" Visible="False">
        <Columns>
            <dx:GridViewDataTextColumn FieldName="Adm_Username" ReadOnly="True" VisibleIndex="0">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Adm_Name" VisibleIndex="1">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Adm_SiteNum" VisibleIndex="2">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Adm_Sites" VisibleIndex="3">
            </dx:GridViewDataTextColumn>
        </Columns>
    </dx:ASPxGridView>
    <dx:ASPxLabel ID="ASPxLblUser" Visible="false" runat="server" ForeColor="#3399FF" Text=""></dx:ASPxLabel>
    <dx:ASPxLabel ID="ASPxLblAdm_Sites" Visible="false" runat="server" ForeColor="#3399FF" Text=""></dx:ASPxLabel>
    <dx:ASPxLabel ID="ASPxLblAssignee" Visible="false" runat="server" ForeColor="#3399FF" Text=""></dx:ASPxLabel>
    <dx:ASPxLabel ID="ASPxLblStartDate" Visible="false" runat="server" BackColor="#FF0000" ForeColor="#000000" Text=""></dx:ASPxLabel>
    <dx:ASPxLabel ID="ASPxLblEndDate" Visible="false" runat="server" BackColor="#FF0000" ForeColor="#000000" Text=""></dx:ASPxLabel>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:MMConnectionString %>" SelectCommand="SELECT tab_Messages.Msg_Index AS [Index], tab_Messages.Msg_Username AS [Created By], tab_Messages.Msg_Completed AS [Done], 
tab_Messages.Msg_Assigned AS [Assignee], tab_Messages.Msg_SiteNum AS [Site], tab_Locations.Lo_Name AS [Location], 
tab_Teams.Te_Name AS [Team], tab_Messages.Msg_Reason AS [Reason], tab_Messages.Msg_Dt [Cr.Dt], 
tab_Messages.Msg_Tm [Cr.Tm], tab_Messages.Msg_MedName [Medication] 
FROM ((tab_Messages LEFT JOIN tab_Locations ON tab_Messages.Msg_LocationIndex = tab_Locations.Lo_Index)
LEFT JOIN tab_Teams ON tab_Messages.Msg_TeamIndex = tab_Teams.Te_Index)
WHERE ([Msg_Username] = @Username AND [Msg_Dt] BETWEEN @Start_Date AND @End_Date) AND Msg_SiteNum IN (SELECT * FROM STRING_SPLIT(@Adm_Sites,',')) ORDER BY tab_Messages.Msg_Index DESC" >
    <SelectParameters>
        <asp:ControlParameter ControlID="ASPxLblUser" Name="Username" PropertyName="Text" Type="String" />
    </SelectParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="ASPxLblStartDate" Name="Start_Date" PropertyName="Text" Type="DateTime" />
    </SelectParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="ASPxLblEndDate" Name="End_Date" PropertyName="Text" Type="DateTime" />
    </SelectParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="ASPxLblAdm_Sites" Name="Adm_Sites" PropertyName="Text" Type="String" />
    </SelectParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="ASPxLblAssignee" Name="Assignee" PropertyName="Text" Type="String" />
    </SelectParameters>
    </asp:SqlDataSource>
    <dx:ASPxLabel ID="ASPxLblLogin" Visible="false" runat="server" ForeColor="#3399FF" Text=""></dx:ASPxLabel>
    <br />
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:MMConnectionString %>" SelectCommand="SELECT * FROM [tab_Admins] WHERE ([Adm_Username] = @Adm_Username)">
    <SelectParameters>
        <asp:ControlParameter ControlID="ASPxLblLogin" Name="Adm_Username" PropertyName="Text" Type="String" />
    </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
<asp:Content ID="Content6" runat="server" contentplaceholderid="head">
    <style type="text/css">
        .grid-view {}
    </style>
</asp:Content>
