<?php
session_start();
/*
try {
    if (isset($_COOKIE["session"])) { 
        //echo 'Cookie is active!';
        $lifetime=60*60;
        setcookie("session", "1", time() + $lifetime, "/");
    } else{ 
        //echo 'Cookie is NOT active!';
        header("Location: /login.php"); 
    }
    $auth = $_SESSION["auth"];
    if (!$auth){
        header("Location: /login.php"); 
    }
} catch(Exception $e){
    header("Location: /login.php"); 
}
*/
?>

<div class="container-fluid">

    <div class="row">
        <div class="col-md-12">
            <div class="card card-plain">
                <div class="header">
                    <p class="category">Jumlah Rekod: <span id="totalrow">0</span></p>
                </div>
                <div class="content table-responsive table-full-width">
                    <table id="products" class="table table-hover">
                        <thead>
                            <th>#</th>
                            <th><b>Tarikh Laporan</b></th>
                            <th><b>No. Kes</b></th>
                            <th><b>Industri</b></th>
                            <th><b>Negeri</b></th>
                            <th>[Tindakan]</th>
                        </thead>
                        <tbody>
                            <!-- jquery to fill -->
                        </tbody>
                    </table>

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

    <!--   Core JS Files   -->
    <script src="/assets/js/jquery-1.10.2.js" type="text/javascript"></script>
	<script src="/assets/js/bootstrap.min.js" type="text/javascript"></script>

	<!--  Checkbox, Radio & Switch Plugins -->
	<script src="/assets/js/bootstrap-checkbox-radio.js"></script>

    <!--  Notifications Plugin    -->
    <script src="/assets/js/bootstrap-notify.js"></script>

    <!-- Paper Dashboard Core javascript and methods for Demo purpose -->
	<script src="/assets/js/paper-dashboard.js"></script>

	<script src="/assets/js/app.js"></script>

<script type="text/javascript">
    $(document).ready(function(){

        //globals
        var url = "";
        //url = url + "http://myori.afxtechnologies.com/";
        url = getBase();
        //console.log(url);

        //app starts here...
        getData();


        function getData(){
            $.ajax({
                type: "get",
                url: url + "/k/ws/get_reports.php"
                }).done(function(json) { 
                //console.log(json);
                var data = $.parseJSON(json);
                //console.log('data...', data);

                if (data && data.length > 0) {

                    var loop = 0;
                    $.each(data, function(k, v) {
                        //console.log('loop...', loop);
                        //console.log('val...', v);
                        var tr = "";
                        loop++;
                        tr = tr + "<tr>";
                        tr = tr + "    <td>" +loop+ "</td>";
                        tr = tr + "    <td>" +v.rpt_txn+ "</td>";
                        tr = tr + "    <td>" +v.id+ "</td>";
                        tr = tr + "    <td>" +(v.type?v.type:'')+  "</td>";
                        tr = tr + "    <td>" +""+ "</td>";
                        tr = tr + "    <td>";
                        tr = tr + "        <span style='cursor:pointer;'>";
                        tr = tr + "        <i class='ti-info-alt show-case' data1='" + v.id + "' title='Paparan Kes'></i>&nbsp;&nbsp;&nbsp;";
                        tr = tr + "        </span>";
                        tr = tr + "    </td>";
                        tr = tr + "</tr>";
                        $("#products tbody").append(tr);
                    });
                    $("#totalrow").html(loop).change();
                }        
            });	
        }


        $(document).on('click', '.show-case' , function() {
            event.preventDefault();
			$(document).off('click', '.show-case');
            var data1 = $(this).attr('data1');
			//console.log('data1:', data1);
			setPage(this, 'Paparan Kes (Baru)', './show_kes.php?id='+data1);
        }); 

    });
</script>


