<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Main.master" AutoEventWireup="true"
    CodeFile="MonitorRecon.aspx.cs" Inherits="MonitorRecon" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <!-- DataTables -->
    <link rel="stylesheet" href="../plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
    <link rel="stylesheet" href="../plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
    <link rel="stylesheet" href="../plugins/datatables-buttons/css/buttons.bootstrap4.min.css">

    <style type="text/css">
        .header-center {
            text-align: center;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
	  <div class="container-fluid">
		<div class="row mb-2">
		  <div class="col-sm-6">
			<h1>Job Monitor (Recon)</h1>
		  </div>
		  <div class="col-sm-6">
			<ol class="breadcrumb float-sm-right">
			  <li class="breadcrumb-item"><a href="#">Home</a></li>
			  <li class="breadcrumb-item active">Administration</li>
			  <li class="breadcrumb-item active">Job Monitor</li>
			</ol>
		  </div>
		</div>
	  </div><!-- /.container-fluid -->
	</section>
        <!-- /.content-header -->
        <!-- Main content -->
        <section class="content">
	    <div class="container-fluid">

            <asp:Panel ID="pnlFileLoading" runat="server">
                <div class="card card-info color-palette-box">
                    <div class="card-header">
                        <h3 class="card-title">Start Reconciliation Job</h3>
                        <div class="card-tools">
                            <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                                <i class="fas fa-minus"></i>
                            </button>
                        </div>
                    </div>
                    <!-- /.card-header -->
                    <div class="card-body">

                        <div class="row">
                            <div class="col-sm-3">
                                <div class="form-group">
                                    <label>Channel</label>
                                    <asp:DropDownList ID="ddlChannels" runat="server" DataTextField="channel_name" DataValueField="rc_code"
                                        class="form-control select" AutoPostBack="True" OnSelectedIndexChanged="ddlChannels_SelectedIndexChanged">
                                    </asp:DropDownList>
                                </div>
                            </div>
                            <div class="col-sm-2">
                                <div class="form-group">
                                    <label>&nbsp;</label><br />
                                    <asp:CheckBox ID="chkAll" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged" Text="&nbsp;&nbsp;All events" />
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="form-group">
                                    <label>Event</label>
                                    <asp:DropDownList ID="ddlEvents" runat="server" DataTextField="evant_name" DataValueField="re_code"
                                        class="form-control select" AutoPostBack="True" OnSelectedIndexChanged="ddlEvents_SelectedIndexChanged">
                                    </asp:DropDownList>
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="form-group">
                                    <label>Date</label>
                                    <div class="input-group date" id="sjdate" data-target-input="nearest">
                                        <asp:TextBox ID="txtjdate" data-target="#sjdate" runat="server" AutoPostBack="false" class="form-control datetimepicker-input"></asp:TextBox>
                                        <div class="input-group-append" data-target="#sjdate" data-toggle="datetimepicker">
                                            <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-1">
                                <div class="form-group">
                                    <label>&nbsp;</label><br />
                                    <asp:Button ID="btnStart" runat="server" Text="Start" CssClass="btn btn-primary" OnClick="btnStart_Click" OnClientClick="$('#cover-spin').show();" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- /.card-body -->
                </div>
            </asp:Panel>

		<!-- Default box -->
		<div class="card card-warning">
			<div><asp:Label ID="lblError" runat="server" Text=""></asp:Label></div>
			<div class="card-body ">
                <div class="row">
                    <ul class="nav nav-tabs mb-3" id="myTab" role="tablist">
                        <li class="nav-item">
                            <asp:Button ID="btnftab" runat="server" Text="File Loading" CssClass="nav-link active" OnClick="btnftab_Click" OnClientClick="$('#cover-spin').show();" />
                        </li>
                        <li>
                            &nbsp;&nbsp;
                        </li>
                        <li class="nav-item">
                          <asp:Button ID="btnrtab" runat="server" Text="Reconciliation" CssClass="nav-link btn-info" OnClick="btnrtab_Click" OnClientClick="$('#cover-spin').show();" />
                        </li>
                        <li>
                            &nbsp;&nbsp;
                        </li>
                        <li class="nav-item">
                            <asp:Button ID="btnhtab" runat="server" Text="History" CssClass="nav-link active" OnClick="btnhtab_Click" OnClientClick="$('#cover-spin').show();" />
                        </li>
                      </ul>
                </div>
                <div class="row" style="display: none">
                    <div class="col-12">
                        <div <%--class="btn-group btn-group-toggle" data-toggle="buttons"--%>>
                            <label class="btn btn-secondary bg-info active">
                                <asp:RadioButton ID="rdF1" Text="File Loading" GroupName="1" AutoPostBack="False" runat="server" Checked="True" />
                            </label>
                            <label class="btn bg-info">
                                <asp:RadioButton ID="rdR1" Text="Reconcilliation" GroupName="1" AutoPostBack="False" runat="server" Checked="False" />
                            </label>
                            <label class="btn bg-info">
                                <asp:RadioButton ID="rdS1" Text="Settlement" GroupName="1" AutoPostBack="False" runat="server" Checked="False" />
                            </label>
                            <label class="btn bg-info">
                                <asp:RadioButton ID="rdV1" Text="Revert" GroupName="1" AutoPostBack="False" Visible="false" runat="server" Checked="False" />
                            </label>
                        </div>
                    </div>
                </div>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:UpdateProgress ID="UpdateProgress1" runat="server" 
                                        AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="0">
                                        <ProgressTemplate>
                                        Refreshing...
                                        </ProgressTemplate>
                                    </asp:UpdateProgress>
                        <div style="width: 100%; display: inline-block; vertical-align: top; overflow-x: auto;">
                            <asp:GridView ID="GridView1" class="table table-striped table-bordered table-sm" BorderStyle="None" BorderWidth="0"
                                GridLines="None" runat="server" AutoGenerateColumns="false" EmptyDataText="There are no Records"
                                OnRowDataBound="GridView1_RowDataBound" OnPreRender="GridView1_PreRender">
                                <Columns>
                                    <%--<asp:HyperLinkField DataTextField="channel_name" DataNavigateUrlFields="LeadID" DataNavigateUrlFormatString="ReconSummary.aspx?LeadID={0}" Text="Lead ID" />--%>
                                    <asp:BoundField DataField="display_name" HeaderText="Job&nbsp;Name" HeaderStyle-CssClass="header-center" />
                                    <asp:BoundField DataField="last_run_date" HeaderText="Last&nbsp;Run&nbsp;Date" HeaderStyle-CssClass="header-center" />
                                    <asp:BoundField DataField="start_method" HeaderText="Start&nbsp;Method" HeaderStyle-CssClass="header-center" />
                                    <asp:BoundField DataField="started_by" HeaderText="Started&nbsp;By" HeaderStyle-CssClass="header-center" />
                                    <asp:BoundField DataField="end_date" HeaderText="End&nbsp;Date" HeaderStyle-CssClass="header-center" />

                                    <%--<asp:BoundField DataField="channel_name" HeaderText="Channel&nbsp;Name" HeaderStyle-CssClass="header-center" />--%>
                                    <asp:TemplateField HeaderText="Channel&nbsp;Name" HeaderStyle-CssClass="header-center">
                                        <ItemTemplate>
                                            <asp:HyperLink ID="HyperLink1" runat="server" Target="_blank" Text='<%# Bind("channel_name") %>' NavigateUrl='<%# string.Format("ReconSummary.aspx?CName={0}&EName={1}&RDate={2}", Eval("channel_name"), Eval("event_name"), Eval("recon_date")) %>'></asp:HyperLink>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:BoundField DataField="event_name" HeaderText="Event&nbsp;Name" HeaderStyle-CssClass="header-center" />
                                    <asp:BoundField DataField="recon_date" HeaderText="Recon&nbsp;Date" HeaderStyle-CssClass="header-center" />
                                    <asp:BoundField DataField="status" HeaderText="Status" HeaderStyle-CssClass="header-center" />
                                    <asp:BoundField DataField="response" HeaderText="Response" HeaderStyle-VerticalAlign="Middle" HeaderStyle-CssClass="header-center" ItemStyle-VerticalAlign="Middle" ItemStyle-HorizontalAlign="Center" />
                                </Columns>
                            </asp:GridView>
                        </div>
                        <asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="Timer1_Tick">
                        </asp:Timer>
                    </ContentTemplate>
                </asp:UpdatePanel>
            
            </div>
					
			<!-- /.card-body -->

            
		</div>
		<!-- /.card -->
		
	</div><!-- /.container-fluid -->
	</section>
        <!-- /.content -->
    </div>
    <!-- Toastr -->
    <!-- jQuery -->
    <script src="../plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap 4 -->
    <script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- SweetAlert2 -->
    <script src="../plugins/sweetalert2/sweetalert2.min.js"></script>
    <!-- Toastr -->
    <script src="../plugins/toastr/toastr.min.js"></script>
    <!-- AdminLTE App -->
    <script src=".../dist/js/adminlte.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="../plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
    <script src="../plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
    <script src="../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
    <script src="../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
    <script src="../plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
    <script src="../plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
    <script src="../plugins/jszip/jszip.min.js"></script>
    <script src="../plugins/pdfmake/pdfmake.min.js"></script>
    <script src="../plugins/pdfmake/vfs_fonts.js"></script>
    <script src="../plugins/datatables-buttons/js/buttons.html5.min.js"></script>
    <script src="../plugins/datatables-buttons/js/buttons.print.min.js"></script>
    <script src="../plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
    <!-- AdminLTE App -->
    <script src="../dist/js/adminlte.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="../dist/js/demo.js"></script>
    <script src="../plugins/select2/js/select2.full.min.js"></script>
    <!-- Bootstrap4 Duallistbox -->
    <script src="../plugins/bootstrap4-duallistbox/jquery.bootstrap-duallistbox.min.js"></script>
    <!-- InputMask -->
    <script src="../plugins/moment/moment.min.js"></script>
    <script src="../plugins/inputmask/jquery.inputmask.min.js"></script>
    <!-- date-range-picker -->
    <script src="../plugins/daterangepicker/daterangepicker.js"></script>
    <!-- bootstrap color picker -->
    <script src="../plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.min.js"></script>
    <!-- Tempusdominus Bootstrap 4 -->
    <script src="../plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
    <!-- Bootstrap Switch -->
    <script src="../plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
    <!-- BS-Stepper -->
    <script src="../plugins/bs-stepper/js/bs-stepper.min.js"></script>
    <!-- dropzonejs -->
    <script src="../plugins/dropzone/min/dropzone.min.js"></script>
    <!-- /.content-wrapper -->
    <script>
        $(function () {

            $('#ContentPlaceHolder1_GridView1').DataTable({
                "responsive": true, "lengthChange": false, "autoWidth": false,
                "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');

            $('#reservationdate').datetimepicker({
                //format: 'L'
                format: 'DD/MM/YYYY'
            });

            $('#reservationdate2').datetimepicker({
                //format: 'L'
                format: 'DD/MM/YYYY'
            });

            $('#dateform').datetimepicker({
                //format: 'L'
                format: 'DD/MM/YYYY'
            });

            $('#sjdate').datetimepicker({
                //format: 'L'
                format: 'DD-MM-YYYY'
            });

            $('#<%= ddlChannels.ClientID %>' + ',#<%= ddlEvents.ClientID %>').change(function () {
                $("#cover-spin").show();
            });
        });
    </script>
</asp:Content>
