
<?php
header("Refresh: 30;url='https://canal-monitoring.thehometown.in/Show_Flow_Meter_Data.php'");
require_once './Connection_getlark.php';
?>

<html>
    <head>
        <!-- Latest compiled and minified CSS -->
        <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">-->

        <!-- jQuery library -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

        <!-- Latest compiled JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>
    <style>
        th{
            border-top: 1px solid black !important;
            border-bottom: 1px solid black !important;
        }
        label{
            color: darkblue;
            font-size: 15px;
        }
    </style>
    <div class="app-main__outer">
        <div class="app-main__inner" style="padding-top: 30px;padding-bottom: 0px;padding-left: 0px;padding-right: 30px !important">
            <div class="tab-content">
                <div class="tab-pane tabs-animation fade show active" id="tab-content-0" role="tabpanel">
                    <div class="tab-content">
                        <div class="tab-pane tabs-animation fade active show" id="tab-content-0" role="tabpanel">
                            <div class="main-card mb-3 card">
                                <h5 class="card-title" style="float: none;text-align: center;margin-top: 10px">Canal Flow Monitoring Detail</h5>
                                <div class="card-body" id="broket_div" tabindex="6">
                                    <center>
                                        <div class="col-lg-12">
                                            <table class="mb-0 table table-hover">
                                                <thead>
                                                    <tr>
                                                        <th style="padding: 10px">#</th>
                                                        <th style="padding: 10px">id</th>
                                                        <th style="padding: 10px">Mac ID</th>
                                                        <th style="padding: 10px">Water level</th>
                                                        <th style="padding: 10px">Water Flow</th>
                                                        <th style="padding: 10px">Accumulative Water</th>
                                                        <th style="padding: 10px">Cumulative Traffic</th>
                                                        <th style="padding: 10px">Analog Output</th>
                                                        <th style="padding: 10px">Temperature</th>
                                                        <th style="padding: 10px">Date</th>
                                                        <th style="padding: 10px">recorded_at</th>
                                                    </tr>
                                                </thead>
                                                <tbody id="table_body">
                                                    <?php
                                                    $query = 'SELECT * FROM tbl_flow_meter_data ORDER BY id DESC limit 1000';
                                                    $result = mysqli_query($con, $query);
//                                                print_r($result);
                                                    if (mysqli_num_rows($result) > 0) {
                                                        $i = 1;
                                                        while ($row = mysqli_fetch_assoc($result)) {
                                                            ?>
                                                            <tr style="text-align: center">
                                                                <td scope="row" style="padding: 10px"><?php echo $i; ?></td>
                                                                <td style="padding: 5px"><?php echo $row["id"]; ?></td>
                                                                <td style="padding: 5px"><?php echo $row["device_mac"]; ?></td>
                                                                <td style="padding: 5px"><?php echo $row["water_level"] . " Meter"; ?></td>
                                                                <td style="padding: 5px"><?php echo $row["water_flow"] . " M3/H"; ?></td>
                                                                <td style="padding: 5px"><?php echo $row["accumulative_water"] . " M3"; ?></td>
                                                                <td style="padding: 5px"><?php echo $row["cumulative_traffic"]; ?></td>
                                                                <td style="padding: 5px"><?php echo $row["analog_output"]; ?></td>
                                                                <td style="padding: 5px"><?php echo $row["temperature"]; ?></td>
                                                                <td style="padding: 5px"><?php echo $row["created_date"]; ?></td>
                                                                <td style="padding: 5px"><?php echo $row["recorded_at"]; ?></td>
                                                            </tr>
                                                            <?php
                                                            $i = $i + 1;
                                                        }
                                                    } else {
                                                        ?>
                                                        <tr>
                                                            <td>0 results</td>
                                                        </tr>
                                                        <?php
                                                    }
                                                    ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </center>
                                </div>

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