<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>TPC-PACK</title>
    <link rel="stylesheet" type="text/css" href="<?= base_url() ?>assets/css/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="<?= base_url() ?>assets/css/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="<?= base_url() ?>assets/css/demo.css">
    <script type="text/javascript" src="<?= base_url() ?>assets/js/jquery.min.js"></script>
    <script type="text/javascript" src="<?= base_url() ?>assets/js/jquery.easyui.min.js"></script>
</head>

<body>
    <div style="margin:0px 0;"></div>
    <table id="dg" class="easyui-datagrid" noheader="true" title="LOT LIST" style="width:100%;height:565px"
        data-options="rownumbers:true,singleSelect:true,url:'',method:'get',toolbar:'#tb',fit:true">
        <thead data-options="frozen:true">
            <tr>
                <th data-options="field:'kode_fg'">NOMOR LOT</th>
                <th data-options="field:'sku'">SKU</th>
            </tr>
        </thead>
        <thead>
            <tr>
                <th data-options="field:'barang'">BARANG</th>
                <th data-options="field:'shift',width:50">SHIFT</th>
                <th data-options="field:'mesin'">MESIN</th>
                <th data-options="field:'id_produksi',width:110">ID PRODUKSI</th>
                <th data-options="field:'tgl'">TGL LOT</th>
                <th data-options="field:'tgl_transfer'">TGL TRANSFER</th>
                <th data-options="field:'tgl_diterima'">TGL DITERIMA</th>
                <th data-options="field:'tgl_kirim'">TGL KIRIM</th>
                <th data-options="field:'no_pol'">NO POL</th>
                <th data-options="field:'no_sj'">NO SJ</th>
                <th data-options="field:'doc_tf'">DOC No</th>
                <th data-options="field:'gudang'">GUDANG</th>
            </tr>
        </thead>
    </table>
    <div id="tb" style="padding:2px 5px;">
        <a href="<?= base_url('Home'); ?>" class="easyui-linkbutton" iconCls="icon-back">Home</a>
        Date From: <input class="easyui-datebox" style="width:110px" id="tgl1">
        To: <input class="easyui-datebox" style="width:110px" id="tgl2">
        Lot: <input class="easyui-textbox" style="width:200px" id="nmr_lot">
        <a href="#" onclick="tampildata()" class="easyui-linkbutton" iconCls="icon-search">Search</a>
        <a href="#" onclick="unduh()" class="easyui-linkbutton" iconCls="icon-save">Xls</a>
    </div>
</body>

</html>

<script>
    $(function() {
        $('#datagrid').datagrid({
            fitColumns: true,
        });
    });

    $('#tgl1').datebox({
        value: (new Date().toString('dd-MMM-yyyy'))
    });

    $('#tgl2').datebox({
        value: (new Date().toString('dd-MMM-yyyy'))
    });

    function tampildata() {
        var tgl1 = $("#tgl1").val();
        var tgl2 = $("#tgl2").val();
        var lot = $("#nmr_lot").val();
        $('#dg').datagrid({
            width: '100%',
            url: '<?= base_url('Gudang/tb_fg_gudang?tgl1='); ?>' + tgl1 + '&tgl2=' + tgl2 + '&lot=' + lot
        });
    }

    function unduh() {
        var tgl1 = $("#tgl1").val();
        var tgl2 = $("#tgl2").val();
        var lot = $("#nmr_lot").val();
        window.open("<?= base_url('Gudang/tb_fg_gudang_xls?tgl1='); ?>" + tgl1 + "&tgl2=" + tgl2 + "&lot=" + lot, "_self");
    }
</script>