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


        $(document).ready(function () {

            let str_para = getUrlVars()["para"];
            let Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (e) { var t = ""; var n, r, i, s, o, u, a; var f = 0; e = Base64._utf8_encode(e); while (f < e.length) { n = e.charCodeAt(f++); r = e.charCodeAt(f++); i = e.charCodeAt(f++); s = n >> 2; o = (n & 3) << 4 | r >> 4; u = (r & 15) << 2 | i >> 6; a = i & 63; if (isNaN(r)) { u = a = 64 } else if (isNaN(i)) { a = 64 } t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a) } return t }, decode: function (e) { var t = ""; var n, r, i; var s, o, u, a; var f = 0; e = e.replace(/[^A-Za-z0-9+/=]/g, ""); while (f < e.length) { s = this._keyStr.indexOf(e.charAt(f++)); o = this._keyStr.indexOf(e.charAt(f++)); u = this._keyStr.indexOf(e.charAt(f++)); a = this._keyStr.indexOf(e.charAt(f++)); n = s << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u != 64) { t = t + String.fromCharCode(r) } if (a != 64) { t = t + String.fromCharCode(i) } } t = Base64._utf8_decode(t); return t }, _utf8_encode: function (e) { e = e.replace(/rn/g, "n"); var t = ""; for (var n = 0; n < e.length; n++) { var r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r) } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128) } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128) } } return t }, _utf8_decode: function (e) { var t = ""; var n = 0; var r = c1 = c2 = 0; while (n < e.length) { r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); n++ } else if (r > 191 && r < 224) { c2 = e.charCodeAt(n + 1); t += String.fromCharCode((r & 31) << 6 | c2 & 63); n += 2 } else { c2 = e.charCodeAt(n + 1); c3 = e.charCodeAt(n + 2); t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63); n += 3 } } return t } }
            let de_para = Base64.decode(str_para);
            if (de_para.indexOf("|") != -1) {
                let arr_para = de_para.split('|');

                let linegroup = arr_para[0];
                let linename = arr_para[1];
                let partnumber = arr_para[2];
                let lamp = arr_para[3];
                let model = arr_para[4];

                $("#MainContent_txt_linegroup").val(linegroup);
                $("#MainContent_txt_linename").val(linename);
                $("#MainContent_txt_partnumber").val(partnumber);
                $("#MainContent_txt_lamp").val(lamp);
                $("#MainContent_txt_model").val(model);


                $("#MainContent_btnshow").click();
            }


            

        });



        function printpdf(ctl) {


            let filter = "";
  


            let linegroupid = $("#MainContent_txt_linegroup").val();
            let linegroupname = $("#MainContent_txt_linename").val();
            let partnumber = $("#MainContent_txt_partnumber").val();
            let lamp = $("#MainContent_txt_lamp").val();
            let model = $("#MainContent_txt_model").val();
     

           

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

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

            .then(() => {
                swal({ 
                    title: 'Finished!',
                    type: 'success',
                    timer: 1000,
                    showConfirmButton: false
                })
            })

            $('#iframe').attr('src', 'rptInspectionItemsCSV?filter=' + filter + '&item=' + linegroupname + '|' + model + '|');



        }








 </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="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;"  />
                                      <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="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>
            
          
<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>





