<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>

<style>
    #myTable a {
        font-size: 14px;
        font-weight: 500;
    }
</style>
<?php //var_dump($date_present) ?>

<?php 
    $date = $date_present ;
    // echo $date ."<br>";echo "<br>";
    $year = substr($date,0 ,strpos($date, "-") );    
    // echo $year;echo "<br>";echo "<br>";

    $month = substr($date,5, strpos($date, "-")-2);    
    // echo $month;echo "<br>";echo "<br>";

    $day = substr($date,8 ,strpos($date, "-") );    
    // echo $day;echo "<br>";echo "<br>";
    $udate_present = $day."/".$month."/".$year;
    // echo $date;
?> 

<div class="row">
    <div class="col-md">
        <div class="card gradient-1">
            <div class="card-body">
                <h3 class="card-title text-white">จำนวนไก่ทั้งหมดในฟาร์ม</h3>
                <div class="d-inline-block">
                    <h2 class="text-white"><?php echo $countAll." ตัว" ?></h2>
                    <p class="text-white mb-0"><?php echo $udate_present ?></p>
                </div>
                <span class="float-right display-5 opacity-5"><i class="fa fa-shopping-cart"></i></span>
            </div>
        </div>
    </div>
    <div class="col-md">
        <div class="card gradient-2">
            <div class="card-body">
                <h3 class="card-title text-white">จำนวนไก่ที่มีอาการปกติ</h3>
                <div class="d-inline-block">
                    <h2 class="text-white"><?php echo $countStatusGood." ตัว" ?></h2>
                    <p class="text-white mb-0"><?php echo $udate_present ?></p>
                </div>
                <span class="float-right display-5 opacity-5"><i class="fa fa-money"></i></span>
            </div>
        </div>
    </div>
    <div class="col-md">
        <div class="card gradient-3">
            <div class="card-body">
                <h3 class="card-title text-white">จำนวนไก่ที่มีอาการผิดปกติ</h3>
                <div class="d-inline-block">
                    <h2 class="text-white"><?php echo $countStatusBad." ตัว" ?></h2>
                    <p class="text-white mb-0"><?php echo $udate_present ?></p>
                </div>
                <span class="float-right display-5 opacity-5"><i class="fa fa-users"></i></span>
            </div>
        </div>
    </div>
    <!-- <div class="col-lg-3 col-sm-6">
        <div class="card gradient-4">
            <div class="card-body">
                <h3 class="card-title text-white">Customer Satisfaction</h3>
                <div class="d-inline-block">
                    <h2 class="text-white">99%</h2>
                    <p class="text-white mb-0">Jan - March 2019</p>
                </div>
                <span class="float-right display-5 opacity-5"><i class="fa fa-heart"></i></span>
            </div>
        </div>
    </div> -->
</div>
<!-- <div class="row">

    <div class="col-md-6 ">
        <div class="card">
            <div class="card-body ">
                <h5 class="card-title"><b>กราฟแสดง...</b></h5>
                <div>
                    <canvas id="Chart" height="100%"></canvas>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-6 ">
        <div class="card">
            <div class="card-body ">
                <h5 class="card-title"><b>กราฟแสดง...</b></h5>
                <div>
                    <canvas id="myChart" height="100%"></canvas>
                </div>
            </div>
        </div>
    </div>
</div> -->
<div class="row">
    <div class="col-lg-12">
        <div class="card">             
            <div class="card-body">
                <div class="active-member">                          
                    <div class="table-responsive">
                        <table id="myTable" class="table table-bordered zero-configuration">              
                            <center> <h4> ตารางข้อมูลไก่ในฟาร์ม</h4></center>
  
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>ไก่ตัวที่</th>
                                    <th>อุณหภูมิ</th>
                                    <!-- <th>การขยับ</th> -->
                                    <th>สถานะ</th>
                                    <th>เวลาที่อัปเดต</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>1</td>
                                    <td> <a href="<?php echo site_url().'/All_chick_controller/chick_information/1'?>"> <?php echo $getData[0]->ck_name ?> </a></td>
                                    <td>
                                        <span><?php echo $getData[0]->mov_temperature." °C" ?></span>
                                    </td>
                                    <!-- <td>
                                        <div>
                                            <div class="progress" style="height: 6px">
                                                <div class="progress-bar bg-danger" style="width: 80%"></div>
                                            </div>
                                        </div>
                                    </td> -->
                                    <?php if($getData[0]->bhv_name=="ปกติ"){ ?>
                                        <td><i class="fa fa-circle-o text-success  mr-2"></i> ปกติ</td>
                                    <?php }else{ ?>
                                        <td><i class="fa fa-circle-o text-danger  mr-2"></i> ผิดปกติ</td>
                                    <?php } ?>    
                                    <?php 
                                            $date = $getData[0]->mov_date_check ;
                                            // echo "<br>";echo "<br>";
                                            $date = substr($date,0 ,strpos($date, " ") );    
                                            // echo $date;echo "<br>";echo "<br>";
                                            $year = substr($date,0 ,strpos($date, "-") );    
                                            // echo $year;echo "<br>";echo "<br>";

                                            $month = substr($date,5, strpos($date, "-")-2);    
                                            // echo $month;echo "<br>";echo "<br>";

                                            $day = substr($date,8 ,strpos($date, "-") );    
                                            // echo $day;echo "<br>";echo "<br>";
                                            $date = $day."/".$month."/".$year;
                                            // echo $date;
                                        ?> 
                                    <td>
                                        <span class="m-0 "><?php echo $date ?></span>
                                        <!-- 21-1-2564 3:18 น. -->
                                    </td>
                                </tr>


                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>




<script>
    // $(document).ready(function() {
    //     $('#myTable').DataTable();
    // });

    var xValues = ["ปกติ", "ผิดปกติ"];
    var yValues = [55, 49];
    var barColors = ["powderblue", "darkred"];
    var x = ["ปกติ", "ผิดปกติ"];
    var y = [55, 49];

    new Chart("myChart", {
        type: "bar",
        data: {
            labels: x,
            datasets: [{
                backgroundColor: barColors,
                data: y
            }]
        },
        options: {
            legend: {
                display: false
            },
            title: {
                display: true,
                text: "อาการไก่รายวัน"
            }
        }
    });

    new Chart("Chart", {
        type: 'pie',
        data: {
            labels: x,
            datasets: [{
                backgroundColor: barColors,
                data: y
            }]
        },
        options: {
            legend: {
                position: 'right',
                labels: {
                    boxWidth: 13
                }
            },
            title: {
                text: "อาการไก่รายวัน"
            }
        }
    });
</script>