<%@ Page Title="" Language="C#" MasterPageFile="~/Master/MasterPage.master" AutoEventWireup="true" CodeBehind="TicketListAdmin.aspx.cs" Inherits="PirTickets.TicketListAdmin" EnableViewStateMac="false" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
    </asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <asp:Label ID="Label1" runat="server" Text="These are the repairs you have outstanding:"></asp:Label>
    <br />
    <br />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" 
            SelectedIndex="0">
    <Tabs>
    <telerik:RadTab runat="server" PageViewID="RadPageView1" Text="Repairs"></telerik:RadTab>
    <telerik:RadTab runat="server" PageViewID="RadPageView3" Text="Customers"></telerik:RadTab>
    <telerik:RadTab runat="server" PageViewID="RadPageView4" Text="Employees"></telerik:RadTab>     
    <telerik:RadTab runat="server" PageViewID="RadPageView5" Text="Unassigned"></telerik:RadTab>    
    <telerik:RadTab runat="server" PageViewID="RadPageView6" Text="Unlisted Makes/Models"></telerik:RadTab>
            
        
        </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0">
        <telerik:RadPageView ID="RadPageView1" runat="server"><asp:GridView ID="GridView1" 
                runat="server" DataKeyNames="OrderID" 
        Width="750px" onselectedindexchanged="GridView1_SelectedIndexChanged" 
        OnPreRender="gridview1_onprerender" OnPageIndexChanging="Gridview1_onPaging"
        OnPageIndexChanged="Gridview1_onPaging"
        AutoGenerateColumns="False" DataSourceID="SqlDataRepairs" 
    AllowPaging="True" AllowSorting="True" AutoGenerateSelectButton="True" 
                EnableSortingAndPagingCallbacks="True" CellPadding="4" ForeColor="#333333" EmptyDataText="No items to view" 
                ShowFooter="True"><RowStyle BackColor="#F7F6F3" ForeColor="#333333" /><Columns><asp:BoundField DataField="OrderID" HeaderText="ID" ReadOnly="True" 
                SortExpression="OrderID" /><asp:BoundField DataField="manufacturer" HeaderText="Make" 
                SortExpression="manufacturer" NullDisplayText="Unlisted" />
                <asp:templatefield HeaderText="Model" ItemStyle-Width="110px" SortExpression="ModelName" >
                <itemtemplate><asp:label runat="server" ID="mod"
                    text='<%# Eval("ModelName") %>' 
                    tooltip='<%# "S/No. " +  Eval ("SerialNumber") %>'/>
                 </itemtemplate>
                    <ItemStyle Width="110px" />
                </asp:templatefield>
                   
                <asp:BoundField DataField="Received" HeaderText="Received" 
                SortExpression="Received" /><asp:BoundField DataField="priority_name" HeaderText="Priority" 
                SortExpression="priority_name" />
                <asp:templatefield HeaderText="Status/Ass.to" ItemStyle-Width="90px" SortExpression="status_name">
                <itemtemplate><asp:label runat="server" ID="stat"
                    text='<%# Eval ( "statusname") %>' 
                    tooltip='<%# Eval ( "status_name" ) %>'/>
                 </itemtemplate>
                    <ItemStyle Width="90px" />
                </asp:templatefield>
                 <asp:templatefield HeaderText="Customer" ItemStyle-Width="90px" SortExpression="cust">
                   <itemtemplate><asp:label runat="server" 
                    text='<%# Eval ( "cust") %>' 
                    tooltip='<%# Eval ( "firstname" ) + " " + Eval ( "lastname" ) %>'/>
                 </itemtemplate>
                     <ItemStyle Width="90px" />
                </asp:templatefield>                 
                 
                    
                    <asp:BoundField DataField="sitename" HeaderText="Site" 
                      SortExpression="sitename" />
                <asp:BoundField DataField="externalref" HeaderText="Ref" ReadOnly="True" 
                    SortExpression="externalref" />
            </Columns><FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                      <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /><SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /><HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><EditRowStyle BackColor="#999999" /><AlternatingRowStyle BackColor="White" CssClass="altrow" ForeColor="#284775" /></asp:GridView><table border="0"><tr><td><strong>Search - </strong></td><td colspan="4" align="right">Show rows:<asp:DropDownList 
                    ID="ddrows" runat="server" onselectedindexchanged="ddrows_SelectedIndexChanged" AutoPostBack="true"><asp:ListItem Selected="True">10</asp:ListItem><asp:ListItem>20</asp:ListItem><asp:ListItem>50</asp:ListItem><asp:ListItem>100</asp:ListItem></asp:DropDownList></td></tr><tr><td><asp:RadioButtonList ID="rbComplete" runat="server" 
                onselectedindexchanged="rbComplete_SelectedIndexChanged" 
                RepeatDirection="Horizontal" AutoPostBack="true"><asp:ListItem Value="0">All</asp:ListItem><asp:ListItem Value="1">Completed</asp:ListItem><asp:ListItem Selected="True" Value="2">In Progress</asp:ListItem></asp:RadioButtonList></td><td>&nbsp;&nbsp;&nbsp;Site: 
                        <asp:DropDownList ID="ddSites" runat="server" DataSourceID="SqlDataSites" 
                    DataTextField="sitename" DataValueField="id" 
                onselectedindexchanged="ddSites_SelectedIndexChanged" AutoPostBack="True" 
                            Height="22px" Width="55px"></asp:DropDownList></td><td>&nbsp; S.No/Ref:<asp:TextBox ID="txtserial" runat="server" AutoPostBack="True" 
                MaxLength="30" ontextchanged="txtserial_TextChanged" Width="78px"></asp:TextBox></td><td>&nbsp; Customer: <asp:TextBox ID="txtCustomer" runat="server" AutoPostBack="true" 
                ontextchanged="txtCustomer_TextChanged" Width="94px" ToolTip="Searches for part of customers name or organisation name"></asp:TextBox> </td><td><asp:Button ID="btClear" runat="server" onclick="btClear_Click" Text="Reset" /></td></tr></table><asp:SqlDataSource ID="SqlDataSites" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:PirTickets %>" 
                    SelectCommand="SELECT [id], [sitename] FROM [sites]" 
                ></asp:SqlDataSource></telerik:RadPageView>
                   
<telerik:RadPageView ID="RadPageView3" runat="server"><asp:GridView ID="GridView3" 
        runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="CustomerID" 
        DataSourceID="SqlDataCustswithRepairs" Width="750px" CellPadding="4" 
        ForeColor="#333333" GridLines="Both" 
        OnSelectedIndexChanged="GridView3_SelectedIndexChanged" 
        EmptyDataText="No Customers have pending repairs" ShowFooter="True" 
        onpageindexchanged="Gridview3_onPaging" onprerender="GridView3_PreRender"><RowStyle BackColor="#F7F6F3" ForeColor="#333333" /><Columns><asp:CommandField ShowSelectButton="True" /><asp:BoundField DataField="CustomerID" HeaderText="ID" ReadOnly="True" 
                SortExpression="CustomerID" /><asp:BoundField DataField="OrganizationName" HeaderText="Company" 
                SortExpression="OrganizationName" /><asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                SortExpression="FirstName" /><asp:BoundField DataField="LastName" HeaderText="Surname" 
                SortExpression="LastName" /><asp:BoundField DataField="repairs" HeaderText="Repairs" ReadOnly="True" 
                SortExpression="repairs" /></Columns><FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /><SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /><HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><EditRowStyle BackColor="#999999" /><AlternatingRowStyle BackColor="White" ForeColor="#284775" /></asp:GridView><strong>Search -</strong> 
                <table border="0" cellpadding="0" cellspacing="0"><tr><td>
                    &nbsp;</td><td>
     
                        &nbsp;&nbsp; Name:&nbsp; </td><td><asp:TextBox ID="txtCustSearch" runat="server" MaxLength="50" 
                        ontextchanged="txtCustSearch_TextChanged" AutoPostBack="true"  ToolTip="Searches for any part of customers name or organisation name"></asp:TextBox></td><td>&nbsp;&nbsp;Tel No.:&nbsp; </td><td><asp:TextBox ID="txtphonesearch" runat="server" MaxLength="20" 
                            ontextchanged="txtphonesearch_TextChanged"  AutoPostBack="true"  ToolTip="Searches for customers phone or mobile. Partial searches are allowed."></asp:TextBox></td><td><asp:Button ID="btCustClear" runat="server" Text="Reset" 
                                    onclick="btCustClear_Click" /></td></tr></table><asp:SqlDataSource ID="SqlDataCustswithRepairs" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PirTickets %>" 
        SelectCommand="SELECT [CustomerID], [OrganizationName], [FirstName], [LastName], [repairs], PhoneNumber, MobilePhone, EmailName FROM [vwCustswithRepairs]"></asp:SqlDataSource></telerik:RadPageView>  
    <telerik:RadPageView ID="RadPageView4" runat="server"><asp:GridView ID="GridView2" 
            runat="server" DataSourceID="SqlDataTechCount" 
        Width="750px" AllowPaging="True" AllowSorting="True" 
        AutoGenerateColumns="False" DataKeyNames="EmployeeID" 
        onselectedindexchanged="GridView2_SelectedIndexChanged" CellPadding="4" 
            ForeColor="#333333" GridLines="Both" 
            EmptyDataText="No Technicians have outstanding repairs" ShowFooter="True"><RowStyle BackColor="#F7F6F3" ForeColor="#333333" /><Columns><asp:CommandField ShowSelectButton="True" /><asp:BoundField DataField="EmployeeID" HeaderText="ID" InsertVisible="False" 
                ReadOnly="True" SortExpression="EmployeeID" ><HeaderStyle HorizontalAlign="Left" /></asp:BoundField><asp:BoundField DataField="FirstName" HeaderText="First Name" 
                SortExpression="FirstName" ><HeaderStyle HorizontalAlign="Left" /></asp:BoundField><asp:BoundField DataField="LastName" HeaderText="Last Name" 
                SortExpression="LastName" ><HeaderStyle HorizontalAlign="Left" /></asp:BoundField><asp:BoundField DataField="repairs" HeaderText="Repairs in Progress" 
                ReadOnly="True" SortExpression="repairs"  ><HeaderStyle HorizontalAlign="Left" /></asp:BoundField></Columns><FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /><SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /><HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><EditRowStyle BackColor="#999999" /><AlternatingRowStyle BackColor="White" ForeColor="#284775" /></asp:GridView></telerik:RadPageView>
    <telerik:RadPageView  ID="RadPageView5" runat="server"><asp:GridView ID="gridunasigned" runat="server" AutoGenerateSelectButton="True" 
        DataKeyNames="OrderID" onselectedindexchanged="gridunasigned_SelectedIndexChanged" 
        Width="750px" AllowPaging="True" AllowSorting="True" 
            AutoGenerateColumns="False" DataSourceID="SqlDataUnassigned" 
            ShowFooter="True" CellPadding="4" ForeColor="#333333" GridLines="Both"
            EmptyDataText="No Unassigned Repairs"><RowStyle BackColor="#F7F6F3" ForeColor="#333333" /><Columns><asp:BoundField DataField="OrderID" HeaderText="OrderID" ReadOnly="True" 
                SortExpression="OrderID" /><asp:BoundField DataField="manufacturer" HeaderText="Manufacturer" 
                SortExpression="manufacturer" /><asp:BoundField DataField="ModelName" HeaderText="Model" 
                SortExpression="ModelName" /><asp:BoundField DataField="DateReceived" DataFormatString="{0:dd/MM/yyyy}" 
                HeaderText="Received" SortExpression="DateReceived" /><asp:CheckBoxField DataField="RepairCompleted" HeaderText="Complete" 
                SortExpression="RepairCompleted" /><asp:BoundField DataField="priority_name" HeaderText="Priority" 
                SortExpression="priority_name" /></Columns><FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /><SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /><HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><EditRowStyle BackColor="#999999" /><AlternatingRowStyle BackColor="White" ForeColor="#284775" /></asp:GridView><asp:SqlDataSource ID="SqlDataUnassigned" runat="server" 
            ConnectionString="<%$ ConnectionStrings:PirTickets %>" 
            SelectCommand="SELECT [OrderID], [manufacturer], [ModelName], [DateReceived], [RepairCompleted], [priority_name] FROM [vwRepairsUnassigned]"></asp:SqlDataSource></telerik:RadPageView>
        <telerik:RadPageView  ID="RadPageView6" runat="server"><asp:GridView ID="GVUnlisted" runat="server" AutoGenerateSelectButton="True" 
        DataKeyNames="OrderID" onselectedindexchanged="GVUnlisted_SelectedIndexChanged" 
        Width="750px" CellPadding="4" ForeColor="#333333" GridLines="Both" 
                EmptyDataText="No Repairs with Unlisted Makes / Models" ShowFooter="True"><RowStyle BackColor="#F7F6F3" ForeColor="#333333" /><FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /><SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /><HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><EditRowStyle BackColor="#999999" /><AlternatingRowStyle BackColor="White" ForeColor="#284775" /></asp:GridView></telerik:RadPageView>
    </telerik:RadMultiPage>



    <asp:SqlDataSource ID="SqlDataTechCount" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PirTickets %>" 
        SelectCommand="SELECT [EmployeeID], [FirstName], [LastName], [repairs] FROM [vwTechswithRepairs] order by repairs desc">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataTechs" runat="server"></asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataRepairs" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PirTickets %>" 
        SelectCommand="SELECT [OrderID], [manufacturer], [ModelName], [Received], [RepairCompleted], [priority_name],[status_name],case when assignedtechnician is not null and [Status] < convert(varchar(3),(SELECT [value] FROM [configuration] where confid =21)) then empname else [status_name] end as statusname,[cust],[FirstName], [LastName],[site],[sitename],[SerialNumber],[externalref] FROM [vwRepairsAll]"
        
        >
    </asp:SqlDataSource>
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
