<%@ Page Title="Export csv" Language="C#" MasterPageFile="~/approve/Approve.Master" AutoEventWireup="true" CodeBehind="rptXRCSV_filter.aspx.cs" Inherits="CheckSheet.approve.rptXRCSV_filter" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">


        $(document).ready(function () {

        });



        function printpdf(ctl) {


            let filter = "";
            let docno = "";

            let linegroupid = $("#MainContent_txt_linegroup").val();
            let linegroupname = $("#MainContent_txt_linename").val();
            let partnumber = $("#MainContent_txt_partnumber").val();
            let machineid = $("#MainContent_txt_MachineID").val();
            let machinename = $("#MainContent_txt_MachineName").val();

            let dstart = $('#d_RDate').val();
            let mstart = $('#m_RDate').val();
            let ystart = $('#y_RDate').val();

            let dend = $('#d_RDate1').val();
            let mend = $('#m_RDate1').val();
            let yend = $('#y_RDate1').val();

            let startdate = '';
            if (dstart == '') {

                startdate = '';

            } else {

                if (parseFloat(ystart.replace(/,/g, '')) >= 2500) {
                    ystart = parseFloat(ystart.replace(/,/g, '')) - 543;
                }

                startdate = ystart.toString() + "-" + mstart.toString() + "-" + dstart.toString();

            }

            let enddate = '';
            if (dend == '') {

                enddate = '';

            } else {

                if (parseFloat(yend.replace(/,/g, '')) >= 2500) {
                    yend = parseFloat(yend.replace(/,/g, '')) - 543;
                }

                enddate = yend.toString() + "-" + mend.toString() + "-" + dend.toString();

            }

            let filtedate = ''
            if (dstart != '' && dend != '') {

                filtedate = " and a.inspectiondate between '" + startdate + "' and '" + enddate + " 23:59:59'";

            } else if (dstart.length > 0) {
                filtedate = " and a.inspectiondate between '" + startdate + "' and '" + startdate + " 23:59:59'";

            }

            else {

                filtedate = "";
            }

            if (linegroupid.length > 0)
            {
                filter = filter + " and d.linegroupid='" + linegroupid + "'";
            }
            if (partnumber.length > 0)
            {
                filter = filter + " and d.partnumber='" + partnumber + "'";

            }
            if (machineid.length > 0)
            {
                filter = filter + " and b.machineid='" + machineid + "'";

            }

            filter = filter + filtedate;

            $('#iframe').attr('src', 'rptXRCSV?filter=' + filter + '&item=' + docno + '|' + startdate + '|' + enddate + '|' + linegroupid + '|' + partnumber + '|' + machineid + '|' + machinename + '|');




        }








 </script>


<asp:Panel ID="Panel1" runat="server" style="overflow:no-display;" Width="100%" Height="600px"> 


        <div id="g1" class="grouplist">

            
             <div class="form-row">
                <div class="frmrow">
                     <span class="sp1">
                    <label>
                    <asp:Label ID="lblPageName" runat="server"  CssClass="frmheader"  Text="Export data"  width="120px"></asp:Label>
                   
                    </label>
                    </span>
                   
                </div>
            </div>

            <div class="form-row">
                <div class="frmrow">
                   
                    <span class="sp1">
                    <label>
                    <asp:Label ID="lbl_linegroup" runat="server" CssClass="fontlabel"   Text="Line group :" width="150px"></asp:Label>
                     <asp:TextBox ID="txt_linegroup"  runat="server" Width="250" CssClass="ctlsearchinput">
                    </asp:TextBox>
                    <asp:Button ID="btnfil_linegroup" runat="server" Text="&nbsp;" CssClass="ctlsearchbutton"  OnClientClick="JavaScript:filterpopup('MainContent_txt_linegroup','MainContent_txt_linename','linegroupid','linename','LineGroupMaster','');return false;"  />

                    </label>
                    </span>
                </div>
            </div>
             <div class="form-row">
                <div class="frmrow">
                   
                    <span class="sp1">
                    <label>
                    <asp:Label ID="lbl_linename" runat="server" CssClass="fontlabel"   Text="Line name :" width="150px"></asp:Label>
                     <asp:TextBox ID="txt_linename"  runat="server" Width="250" CssClass="ctlsearchinput">
                    </asp:TextBox>
                    <asp:Button ID="btnfil_linename" runat="server" Text="&nbsp;" CssClass="ctlsearchbutton"  OnClientClick="JavaScript:filterpopup('MainContent_txt_linegroup','MainContent_txt_linename','linegroupid','linename','LineGroupMaster','');return false;"  />

                    </label>
                    </span>
                </div>
            </div>
            <div class="form-row">
                <div class="frmrow">
                   
                    <span class="sp1">
                    <label>
                    <asp:Label ID="lbl_partnumber" runat="server" CssClass="fontlabel"   Text="Part number :" width="150px"></asp:Label>
                     <asp:TextBox ID="txt_partnumber"  runat="server" Width="250" CssClass="ctlsearchinput">
                    </asp:TextBox>
                    <asp:Button ID="btnfil_partnumber" runat="server" Text="&nbsp;" CssClass="ctlsearchbutton"  OnClientClick="JavaScript:filterpopup('MainContent_txt_partnumber','MainContent_txt_partnumber','partnumber','partnumber','EquipmentList','');return false;"  />


                    </label>
                    </span>
                </div>
            </div>
              <div class="form-row">
                <div class="frmrow">
                   
                    <span class="sp1">
                    <label>
                    <asp:Label ID="lbl_machineid" runat="server" CssClass="fontlabel"   Text="Machine:" width="150px"></asp:Label>
                     <asp:TextBox ID="txt_MachineID"  runat="server" Width="250" CssClass="ctlsearchinput">
                    </asp:TextBox>

                    </label>
                    </span>

                   
                   
                    
                </div>
            </div>
             <div class="form-row">
                <div class="frmrow">
                   
                    <span class="sp1">
                    <label>
                    <asp:Label ID="Label1" runat="server" CssClass="fontlabel"   Text="" width="150px"></asp:Label>
                     <asp:TextBox ID="txt_MachineName"  runat="server" Width="250" CssClass="ctlsearchinput">
                    </asp:TextBox>
                    <asp:Button ID="btnfil_machine" runat="server" Text="&nbsp;" CssClass="ctlsearchbutton"  OnClientClick="JavaScript:filterpopup('MainContent_txt_MachineID','MainContent_txt_MachineName','machineid','machinename','MachineMaster','');return false;"  />

                    </label>
                    </span>

                   
                   
                    
                </div>
            </div>

     <div class="form-row">
<div class="frmrow">                    
<span class="sp1">
    
    
    <div class="column">
 <label> 
<div class="column"><lbl id="lbl_RDate" class="fontlabel" style="width:195px;">Date</lbl></div> 
<div class="column"><input type="text" placeholder="DD" id="d_RDate" class="inputcss" style="width:40px;"></div>
<div class="column"><input type="text" placeholder="MM" id="m_RDate" class="inputcss" style="width:40px;"></div>
<div class="column"><input type="text" placeholder="YYYY" id="y_RDate" class="inputcss" style="width:60px;">
</div>
<div class="column"><asp:ImageButton ID="imb_RDate" runat="server"  CssClass="ctldatebutton" ImageUrl="~/image/calendar.png" Height="30"  OnClientClick="Javascript:date('d_RDate','m_RDate','y_RDate');return false;"/>
</div></label>

</div>
            
                                
   </span>


    <span  class="sp3">
 
        
<div class="column">
 <label> 
<div class="column"><lbl id="lbl_RDate1" class="fontlabel" style="width:195px;">To Date</lbl></div> 
<div class="column"><input type="text" placeholder="DD" id="d_RDate1" class="inputcss" style="width:40px;"></div>
<div class="column"><input type="text" placeholder="MM" id="m_RDate1" class="inputcss" style="width:40px;"></div>
<div class="column"><input type="text" placeholder="YYYY" id="y_RDate1" class="inputcss" style="width:60px;">
</div>
<div class="column"><asp:ImageButton ID="imb_RDate1" runat="server"  CssClass="ctldatebutton" ImageUrl="~/image/calendar.png" Height="30"  OnClientClick="Javascript:date('d_RDate1','m_RDate1','y_RDate1');return false;"/>
</div></label>

</div>
            
                                
   </span>



</div></div>    
<br />
       </div>

      <asp:Button ID="btnshow" CssClass="buttonmsg" runat="server" Text="View" OnClientClick="JavaScript:printpdf(this);return false;" />
     <asp:Button ID="btnreload" CssClass="buttonmsg" runat="server" Text="Cancel" OnClientClick="JavaScript:location.reload();" />

    <br />
    <iframe id="iframe" name="myIframe" width="95%" height="500"></iframe>

    </asp:Panel>

</asp:Content>



