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


        $(document).ready(function () {

            setTimeout(function () {
                getweek();
                $("#MainContent_ddlxrchart").hide();
            }, 500);
        });
        function showddlpoint()
        {
            let val = $("#MainContent_ddl_type").val();
        
            if(val=="4")
            {
                $("#MainContent_ddlxrchart").show();

            }
            else
            {
                $("#MainContent_ddlxrchart").hide();

            }

        }
        function getweek() {
            let month = $("#MainContent_txt_checkmonth").val();
            let year = $("#MainContent_txt_checkyear").val();
            $('#MainContent_ddl_week').html("");
            $.ajax({
                type: "POST",
                url: "rptReport_filter.aspx/getweek",
                data: '{year:"' + year + '",month:"'+month+'"}',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    var xmlDoc = $.parseXML(response.d);
                    var xml = $(xmlDoc);
                    var customers = xml.find("Table");

                    $.each(customers, function () {
                        var customer = $(this);
                        try {
                            



                            $('#MainContent_ddl_week').append('<option value="' + $(this).find("weekid").text() + '">' + $(this).find("weektext").text() + '</option>');

                           


                        } catch (err) { } finally { };
                    });


                },
                failure: function (response) {
                    alert(response.d);
                },
                error: function (response) {
                    alert(response.d);
                }
            });


        }

        function printpdf(ctl) {


            swal({
                title: "Loading",
                type: 'info',
                text: "Please wait...",
                timer: 10000,
                imageUrl: '../loader.gif',
                showConfirmButton: false,
                timerProgressBar: true
            })

   .then(() => {
       swal({ 
           title: 'Finished!',
           type: 'success',
           timer: 1000,
           showConfirmButton: false
       })
   })
            
            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 month = $("#MainContent_txt_checkmonth").val();
            let year = $("#MainContent_txt_checkyear").val();
            let model = $("#MainContent_txt_model").val();
            let lamp = $("#MainContent_txt_lamp").val();
            let xrtype = $("#MainContent_ddlxrchart").val();
            
            let week = $("#MainContent_ddl_week").val();
            let type = $("#MainContent_ddl_type").val();
           
            if (linegroupname.length > 0) {
                filter = filter + " and b.linename='" + linegroupname + "'";
            }
            if (partnumber.length > 0) {
                filter = filter + " and b.partnumber='" + partnumber + "'";

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

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

            }
          

            let filtedate = "";
            if(type=="4")
            {
                if (xrtype.length > 0) {
                    filter = filter + " and chart_type='" +xrtype + "'";

                }

                filtedate = " and month(a.xr_date)=" + month + " and year(a.xr_date)=" + year;

            }
            else
            {
                filtedate = " and month(a.inspectiondate)=" + month + " and year(a.inspectiondate)=" + year;


            }
            
            filter = filter + filtedate;


       


            $('#iframe').attr('src', 'rptReport?filter=' + filter + "&type=" + type + "&week=" + week+"&point="+xrtype+"&month="+month+"&year="+year);



        }








 </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="Inspection report"  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="150px"></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="150px"></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;"  />
           
                       
                    </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="150px"></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="lbl_month" runat="server" CssClass="fontlabel"   Text="Month :" width="60px"></asp:Label>
                     <asp:DropDownList ID="txt_checkmonth"  runat="server" Width="60" onchange="javascript:getweek();return false;">
                        
                     </asp:DropDownList>
                    </label>
                    <label>
                    <asp:Label ID="lbl_year" runat="server" CssClass="fontlabel"   Text="Year :" width="60px" onchange="javascript:getweek();return false;"></asp:Label>
                     <asp:DropDownList ID="txt_checkyear"  runat="server" Width="60">
                       
                     </asp:DropDownList>
                    </label>
                         <label>
                    <asp:Label ID="lbl_week" runat="server" CssClass="fontlabel"   Text="Week :" width="60px"></asp:Label>
                     <asp:DropDownList ID="ddl_week"  runat="server" Width="60">
                        
                     </asp:DropDownList>
                    </label>
                   
                   
                  </span>
                   
                    
                </div>
            </div>


             <div class="form-row">
                <div class="frmrow">
                   
                    <span class="sp1">
                    <label>
                    <asp:Label ID="lbltype" runat="server" CssClass="fontlabel"   Text="Report Type :" width="60px"></asp:Label>
                     <asp:DropDownList ID="ddl_type"  runat="server" Width="70%" onchange="javascript:showddlpoint();return false;">
                        <asp:ListItem Value="1" Text="DUMMY SAMPLE CHECK SHEET">DUMMY SAMPLE CHECK SHEET</asp:ListItem>
                        <asp:ListItem Value="2" Text="CONDITION STANDARD FOR PRODUCTION CONFIRMATION SHEET">CONDITION STANDARD FOR PRODUCTION CONFIRMATION SHEET</asp:ListItem>
                        <asp:ListItem Value="3" Text="CHECK THE ACCUMULATION OF STATIC ELECTRIC">CHECK THE ACCUMULATION OF STATIC ELECTRIC</asp:ListItem>
                        <asp:ListItem Value="4" Text="แผนภูมิควบคุมสำหรับข้อมูลชนิดแปรผัน (XR Chart)">แผนภูมิควบคุมสำหรับข้อมูลชนิดแปรผัน (XR Chart)</asp:ListItem>
                        <asp:ListItem Value="5" Text="JIG INSPECTION STANDARD EVALUATION RESULT SHEET"> JIG INSPECTION STANDARD EVALUATION RESULT SHEET</asp:ListItem>
                        <asp:ListItem Value="6" Text="ตรวจสอบเครื่องมือวัดประจำวัน">ตรวจสอบเครื่องมือวัดประจำวัน</asp:ListItem>

<%--                        <asp:ListItem Value="6" Text="JIG INSPECTION FORM">JIG INSPECTION FORM</asp:ListItem>--%>
                        <asp:ListItem Value="7" Text="TORQUE CHECK SHEET">TORQUE CHECK SHEET</asp:ListItem>
                        <asp:ListItem Value="8" Text="DAILY & WEEKLY  MACHINE MAINTENANCE CHECK SHEET">DAILY & WEEKLY  MACHINE MAINTENANCE CHECK SHEET</asp:ListItem>
<%--                        <asp:ListItem Value="9" Text="MARKING CHECK SHEET">MARKING CHECK SHEET</asp:ListItem>
                        <asp:ListItem Value="10" Text="APPROVEL FOR MASS PRODUCTION">APPROVEL FOR MASS PRODUCTION</asp:ListItem>--%>
                        <asp:ListItem Value="11" Text="บันทึกการควบคุมจุดเปลี่ยนแปลง (4M CHANGE)">บันทึกการควบคุมจุดเปลี่ยนแปลง (4M CHANGE)</asp:ListItem>

                     </asp:DropDownList>
                    </label>
                  

                    </span>

                   
                   
                    
                </div>
            </div>


             <div class="form-row">
                <div class="frmrow">
                   
                    <span class="sp2">
                    <label>
                     <asp:DropDownList ID="ddlxrchart"  runat="server" Width="100%">
                        <asp:ListItem Value="" Text="SELECT TYPE"></asp:ListItem>
                        <asp:ListItem Value="POINT A" Text="POINT A">POINT A</asp:ListItem>
                        <asp:ListItem Value="POINT B" Text="POINT B">POINT B</asp:ListItem>
                        <asp:ListItem Value="POINT C" Text="POINT C">POINT C</asp:ListItem>
                        <asp:ListItem Value="POINT D" Text="POINT D">POINT D</asp:ListItem>
                        <asp:ListItem Value="R" Text="RHD">RHD</asp:ListItem>
                        <asp:ListItem Value="L" Text="LHD">LHD</asp:ListItem>
                     </asp:DropDownList>
                    </label>
                  

                    </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:window.location.href = '../Mainmenu';return false;" />

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

    </asp:Panel>

</asp:Content>



