<%@ Page Title="Export csv" Language="C#" MasterPageFile="~/approve/Approve.Master" AutoEventWireup="true" CodeBehind="rptMachineCSV_filter.aspx.cs" Inherits="CheckSheet.approve.rptMachineCSV_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 model = $("#MainContent_txt_model").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', 'rptMachineCSV?filter=' + filter + '&item=' + docno + '|' + startdate + '|' + enddate + '|' + linegroupid + '|' + model + '|' + machineid + '|' + machinename + '|');



        }








 </script>


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


        <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_lamp" runat="server" CssClass="fontlabel"   Text="LAMP :" width="180px"></asp:Label>
                     <asp:TextBox ID="txt_lamp"  runat="server" Width="250" ToolTip="*Factory(Lamp)" CssClass="ctlsearchinput" style="text-transform: uppercase;">
                    </asp:TextBox>
                    <asp:Button ID="btnfil_lamp" runat="server" Text="&nbsp;" CssClass="ctlsearchbutton"  OnClientClick="JavaScript:filterpopup('MainContent_txt_lamp','MainContent_txt_lamp','lamp','lamp','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="180px"></asp:Label>
                     <asp:TextBox ID="txt_linename"  runat="server" Width="250" ToolTip="*Line name" CssClass="ctlsearchinput">
                      </asp:TextBox>
                         <asp:Button ID="btnfil_linename" runat="server" Text="&nbsp;" CssClass="ctlsearchbutton"  OnClientClick="JavaScript:filterpopup('MainContent_txt_linename','MainContent_txt_linename','linename','linename','LineGroupMaster','$and lamp =\''+$('#MainContent_txt_lamp').val()+'\'');return false;"  />
                                      <asp:TextBox ID="txt_linegroup"  runat="server" Width="1" style="border-style:none;box-shadow:none;" ></asp:TextBox>

                       
                    </label>
                    </span>
                    </div>
              </div>        

                <div class="form-row">
                <div class="frmrow">
                   
                    <span class="sp1">
                    <label>
                    <asp:Label ID="lbl_model" runat="server" CssClass="fontlabel"   Text="Model :" width="180px"></asp:Label>
                     <asp:TextBox ID="txt_model"  runat="server" Width="250" ToolTip="*Model" CssClass="ctlsearchinput" >
                    </asp:TextBox>
                    <asp:Button ID="btnfil_model" runat="server" Text="&nbsp;" CssClass="ctlsearchbutton"  OnClientClick="JavaScript:filterpopup('MainContent_txt_partnumber','MainContent_txt_model','partnumber','model','LineGroupMaster','$and linename =\''+$('#MainContent_txt_linename').val()+'\'');return false;"  />
        <%--                $and usercode =\''+$('#lbluserid').html()+'\''--%>
                           <asp:TextBox ID="txt_partnumber"  runat="server" Width="1" style="border-style:none;box-shadow:none;" >
                    </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="Machine :" 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','view_Machine','$and partnumber =\''+$('#MainContent_txt_partnumber').val()+'\'');return false;"  />
                           <asp:TextBox ID="txt_MachineID"  runat="server" Width="1" style="border:none;box-shadow:none;color:transparent;">
                    </asp:TextBox>
                    </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>



