<?php
header('Access-Control-Allow-Origin: *');
require_once './Mobile_Api/connection.php';
// var_dump($_SESSION);
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
if (!isset($_SESSION['username'])) {
    header("Location: ./login.php");
    exit;
}
?>


<html lang="en" class=" js flexbox flexboxlegacy canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers no-applicationcache svg inlinesvg smil svgclippaths">
    <head>
        <title>Canal Monitoring </title>


        <!--[if lt IE 10]>
              <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
              <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
              <![endif]-->

        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="description" content="#">
        <meta name="keywords" content="Admin , Responsive, Landing, Bootstrap, App, Template, Mobile, iOS, Android, apple, creative app">
        <meta name="author" content="#">

        <link rel="icon" href="./files/assets/images/favicon.ico" type="image/x-icon">

        <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600" rel="stylesheet">

        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

        <link rel="stylesheet" type="text/css" href="./files/bower_components/bootstrap/dist/css/bootstrap.min.css">

        <link rel="stylesheet" type="text/css" href="./files/assets/icon/feather/css/feather.css">

        <link rel="stylesheet" type="text/css" href="./files/assets/css/style.css">
        <link rel="stylesheet" type="text/css" href="./files/assets/css/jquery.mCustomScrollbar.css">

        <style type="text/css">/* Chart.js */
            /*
             * DOM element rendering detection
             * https://davidwalsh.name/detect-node-insertion
             */
            @keyframes chartjs-render-animation {
                from {
                    opacity: 0.99;
                }
                to {
                    opacity: 1;
                }
            }

            .chartjs-render-monitor {
                animation: chartjs-render-animation 0.001s;
            }

            /*
             * DOM element resizing detection
             * https://github.com/marcj/css-element-queries
             */
            .chartjs-size-monitor,
            .chartjs-size-monitor-expand,
            .chartjs-size-monitor-shrink {
                position: absolute;
                direction: ltr;
                left: 0;
                top: 0;
                right: 0;
                bottom: 0;
                overflow: hidden;
                pointer-events: none;
                visibility: hidden;
                z-index: -1;
            }

            .chartjs-size-monitor-expand > div {
                position: absolute;
                width: 1000000px;
                height: 1000000px;
                left: 0;
                top: 0;
            }

            .chartjs-size-monitor-shrink > div {
                position: absolute;
                width: 200%;
                height: 200%;
                left: 0;
                top: 0;
            }





            /*            body {
                        background-image: url("./files/assets/img/aquarius.gif"), url("./files/assets/img/river1.gif");
                        background-color: #cccccc;
                        }*/
        </style>

        <script>
            setInterval(function () {
//                window.location.reload();
            }, 10000);
//            $(document).ready(function () {
//                feather.replace()
//            })



        </script>

        <!--<script src="https://kit.fontawesome.com/2bc8cc4aed.js" crossorigin="anonymous"></script>-->

        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">


    </head>
    <body themebg-pattern="pattern4">

        <div id="pcoded" class="pcoded iscollapsed" nav-type="st6" theme-layout="vertical" vertical-placement="left" vertical-layout="wide" pcoded-device-type="desktop" vertical-nav-type="expanded" vertical-effect="shrink" vnavigation-view="view1" fream-type="theme1" sidebar-img="false" sidebar-img-type="img1" layout-type="light">
            <div class="pcoded-overlay-box"></div>
            <div class="pcoded-container navbar-wrapper">
                <nav class="navbar header-navbar pcoded-header iscollapsed" header-theme="theme1" pcoded-header-position="fixed">
                    <div class="navbar-wrapper">
                        <div class="navbar-logo" logo-theme="theme1">
                            <a class="mobile-menu" id="mobile-collapse" href="#!">
                                <i class="fa fa-sliders"></i>
                            </a>
                            <a href="index.php">
                                <img class="img-fluid" src="./files/assets/img/aquarius.gif" height="50px" width="50px" alt="Theme-Logo"> Canal Monitoring
                            </a>
                            <a class="mobile-options">
                                <i class="feather icon-more-horizontal"></i>
                            </a>
                        </div>

                        <?php
                        $notification = 0;

                        $query = 'SELECT MAX(id) as id FROM `tbl_flow_meter_data` WHERE flag=1 GROUP BY user_id ORDER by id asc';
                        mysqli_set_charset($con, 'utf8');
                        $result = mysqli_query($con, $query);
                        if (mysqli_num_rows($result) > 0) {
                            $i = 1;
                            while ($row = mysqli_fetch_assoc($result)) {

                                $id = $row["id"];

                                $query1 = 'SELECT tfmd.*,DATE_FORMAT(tfmd.created_date,"%d-%m-%Y %H:%i:%s") AS created_date_new,DATE_FORMAT(tfmd.created_date,"%Y-%m-%d") AS days_date,tfm.meter_name,tfm.address FROM `tbl_flow_meter_data` as tfmd LEFT join tbl_flow_meter as tfm on tfm.user_id=tfmd.user_id WHERE tfmd.id=' . $id . ' and tfmd.flag=1 ORDER by tfmd.id DESC LIMIT 0,1';
//                                $query1 = 'SELECT twts.id,twts.user_id,twts.freez_temperature,twts.freez_humidity,twts.comment,DATE_FORMAT(twts.created_date,"%d-%m-%Y %H:%i:%s") AS created_date,DATE_FORMAT(twts.created_date,"%Y-%m-%d") AS days_date,tsu.full_name,tsu.mobile_no,ts.school_name,tv.village,tv.village_hindi,tv.village_guj FROM `tbl_freez_status` as twts LEFT join tbl_school_user as tsu on twts.user_id=tsu.id left join tbl_school as ts on tsu.school_id=ts.id left join tbl_village as tv on ts.village_id=tv.id where twts.flag=1 and twts.id=' . $id . ' order by twts.id DESC LIMIT 0,1';
//                                echo '$query1 ' . $query1;
                                mysqli_set_charset($con, 'utf8');
                                $result1 = mysqli_query($con, $query1);
                                if (mysqli_num_rows($result) > 0) {
                                    $i = 1;
                                    while ($row1 = mysqli_fetch_assoc($result1)) {

                                        $now = time(); // or your date as well
                                        $your_date = strtotime($row1["days_date"]);
                                        $datediff = $now - $your_date;

//                                                                                            echo round($datediff / (60 * 60 * 24));
                                        $Days = round($datediff / (60 * 60 * 24));

                                        if ($Days > 1) {
                                            $notification = $notification + 1;
                                        }


                                        if ($row1['water_level'] < 0) {
                                            $notification = $notification + 1;
                                        }
//                                        else if ($row1['water_level'] < - 20) {
//                                            $notification = $notification + 1;
//                                        }
                                    }
                                }
                            }
                        }
                        ?>

                        <div class="navbar-container">
                            <ul class="nav-right">
                                <li class="header-notification">
                                    <div class="dropdown-primary dropdown">
                                        <div class="dropdown-toggle" data-toggle="dropdown">
                                            <i class="fa fa-bell"></i>
                                            <!--<span class="badge bg-c-pink"><?php echo $notification; ?></span>-->
                                        </div>
                                        <ul class="show-notification notification-view dropdown-menu" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut" style="max-height: 550px;background: #b4cee7;overflow: auto">
                                            <li>


                                                <?php
                                                if ($_SESSION['User_language'] == 'ENGLISH') {
                                                    ?>
                                                    <h6>Notifications</h6>
                                                    <label class="label label-danger">New</label>
                                                    <?php
                                                }

                                                if ($_SESSION['User_language'] == 'GUJARATI') {
                                                    ?>
                                                    <h6>સૂચનાઓ</h6>
                                                    <label class="label label-danger">નવી</label>
                                                    <?php
                                                }
                                                ?>

                                            </li>

                                            <?php
                                            $offline = 0;
                                            $online = 0;

                                            $query = 'SELECT MAX(id) as id FROM `tbl_flow_meter_data` WHERE flag=1 GROUP BY user_id ORDER by id asc';
                                            mysqli_set_charset($con, 'utf8');
                                            $result = mysqli_query($con, $query);
//                                             if (mysqli_num_rows($result) > 0) {
//                                                 $i = 1;
//                                                 while ($row = mysqli_fetch_assoc($result)) {

//                                                     $id = $row["id"];

//                                                     $query1 = 'SELECT tfmd.*,DATE_FORMAT(tfmd.created_date,"%d-%m-%Y %H:%i:%s") AS created_date_new,DATE_FORMAT(tfmd.created_date,"%Y-%m-%d") AS days_date,tfm.meter_name,tfm.address FROM `tbl_flow_meter_data` as tfmd LEFT join tbl_flow_meter as tfm on tfm.user_id=tfmd.user_id WHERE tfmd.id=' . $id . ' and tfmd.flag=1 ORDER by tfmd.id DESC LIMIT 0,1';
//                                                     mysqli_set_charset($con, 'utf8');
//                                                     $result1 = mysqli_query($con, $query1);
//                                                     if (mysqli_num_rows($result) > 0) {
//                                                         $i = 1;
//                                                         while ($row1 = mysqli_fetch_assoc($result1)) {

//                                                             $now = time(); // or your date as well
//                                                             $your_date = strtotime($row1["days_date"]);
//                                                             $datediff = $now - $your_date;

// //                                                                                            echo round($datediff / (60 * 60 * 24));
//                                                             $Days = round($datediff / (60 * 60 * 24));

//                                                             if ($Days > 1) {
//                                                                 $offline = $offline + 1;
//                                                                 ?>

<!--//                                                                 <li style="padding: 10px">-->
<!--//                                                                     <div class="media view_school_tank_status" id="<?php echo $row1["user_id"]; ?>">-->
<!--//                                                                         <img class="d-flex align-self-center img-radius" src="files/assets/img/aquarius.gif" alt="Generic placeholder image">-->
<!--//                                                                         <div class="media-body">-->
<!--//                                                                             <h5 class="notification-user"><?php echo $row1["meter_name"]; ?></h5>-->


                                                                            <?php
//                                                                             if ($_SESSION['User_language'] == 'ENGLISH') {
//                                                                                 ?>
<!--//                                                                                 <p class="notification-msg view_school_tank_status" id="<?php echo $row1["user_id"]; ?>"><?php echo $row1["meter_name"]; ?> stop working last <?php echo $Days . " Days."; ?>-->
<!--//                                                                                 </p>-->
                                                                                <?php
//                                                                             }

//                                                                             if ($_SESSION['User_language'] == 'GUJARATI') {
//                                                                                 ?>
<!--//                                                                                 <p class="notification-msg view_school_tank_status" id="<?php echo $row1["user_id"]; ?>"><?php echo $row1["meter_name"]; ?> નું ફ્રિઝર છેલ્લા <?php echo $Days; ?> દિવસથી બંધ છે.-->
<!--//                                                                                 </p>-->
                                                                                 <?php
//                                                                             }
//                                                                             ?>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         <!--<span class="notification-time">30 minutes ago</span>-->
<!--//                                                                         </div>-->
<!--//                                                                     </div>-->
<!--//                                                                 </li>-->

                                                                 <?php
//                                                             } else {
//                                                                 $online = $online + 1;
//                                                             }
//                                                         }
//                                                     }
//                                                 }
//                                             }
                                            ?>
                                        </ul>
                                    </div>
                                </li>

                                <li class="header-notification">
                                    <div class="dropdown-primary dropdown">
                                        <div class="dropdown-toggle" data-toggle="dropdown">
                                            <i class="icon text-primary fa fa-language" style="font-size:26px;"></i>

                                            <?php
                                            if ($_SESSION['User_language'] == 'ENGLISH') {
                                                ?>
                                                <span>Change Language</span>
                                                <?php
                                            }
                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                ?>
                                                <span>ભાષા બદલો</span>
                                                <?php
                                            }
                                            ?>
                                        </div>

                                        <ul class="show-notification notification-view dropdown-menu" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut">
                                            <li>

                                                <?php
                                                if ($_SESSION['User_language'] == 'ENGLISH') {
                                                    ?>
                                                    <h6>Choose Language </h6>
                                                    <?php
                                                }

                                                if ($_SESSION['User_language'] == 'GUJARATI') {
                                                    ?>
                                                    <h6>ભાષા પસંદ કરો</h6>
                                                    <?php
                                                }
                                                ?>
                                                <label class="icon text-primary fa fa-language"></label>
                                            </li>
                                            <li>
                                                <div class="media">
                                                    <button onclick="btn_english()" type="button" tabindex="0" class="dropdown-item">
                                                        <span class="mr-3 opacity-8 flag large IND"></span><b> English </b>
                                                    </button>
                                                </div>
                                            </li>
                                            <li>
                                                <div class="media">
                                                    <button onclick="btn_gujarati()" type="button" tabindex="0" class="dropdown-item" id="btn-gujarati">
                                                        <span class="mr-3 opacity-8 flag large CH"></span><b> GUJARATI </b>
                                                    </button>
                                                </div>
                                            </li>
                                        </ul>
                                    </div>
                                </li>

                                <!--                                <div class="dropdown show">
                                                                    <button type="button" data-toggle="dropdown" class="p-0 mr-2 btn btn-link" aria-expanded="true">
                                                                        <span class="icon-wrapper icon-wrapper-alt rounded-circle">
                                                                            <span class="icon-wrapper-bg bg-focus"></span>
                                                                            <i class="icon text-primary fa fa-language"></i>
                                                                            <span class="language-icon opacity-8 large fa fa-globe"></span>
                                                                        </span>
                                                                    </button>
                                                                    <div tabindex="-1" role="menu" aria-hidden="true" class="rm-pointers dropdown-menu dropdown-menu-right show" x-placement="bottom-end" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(-198px, 46px, 0px);">
                                                                        <div class="dropdown-menu-header">
                                                                            <div class="dropdown-menu-header-inner pt-4 pb-4 bg-focus">
                                                                                <div class="menu-header-image opacity-05"></div>
                                                                                <div class="menu-header-content text-center text-white">
                                
                                
                                                                                    <h6 class="menu-header-subtitle mt-0"> Choose Language</h6>
                                
                                
                                
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                        <h6 tabindex="-1" class="dropdown-header"> Popular Languages</h6>
                                                                                                            <a onclick="btn_english()" class="nav-link">
                                                                                                                English 1
                                                                                                            </a>
                                                                        <a  class="nav-link">
                                                                        <button onclick="btn_english()" type="button" tabindex="0" class="dropdown-item">
                                                                            <span class="mr-3 opacity-8 flag large IND"></span> English
                                                                        </button>
                                                                        </a>
                                                                        <button onclick="btn_gujarati()" type="button" tabindex="0" class="dropdown-item" id="btn-gujarati">
                                                                            <span class="mr-3 opacity-8 flag large CH"></span> ગુજરાતી
                                                                        </button>
                                                                                                                <button onclick="btn_hindi()" type="button" tabindex="0" class="dropdown-item" id="btn-hindi">
                                                                                                                    <span class="mr-3 opacity-8 flag large FR"></span> हिन्दी
                                                                                                                </button>
                                                                    </div>
                                                                </div>-->

                                <li class="user-profile header-notification">
                                    <div class="dropdown-primary dropdown">
                                        <div class="dropdown-toggle" data-toggle="dropdown">
                                            <img src="./files/assets/images/profile.png" class="img-radius" alt="User-Profile-Image">
                                            <span><?php echo $_SESSION['username']; ?></span>
                                            <i class="fa fa-chevron-down"></i>
                                        </div>
                                        <ul class="show-notification profile-notification dropdown-menu" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut">


                                            <?php
                                            if ($_SESSION['User_language'] == 'ENGLISH') {
                                                ?>
                                                <li>
                                                    <a href="javascript:void(0)" id="btn-logout">
                                                        <i class="fa fa-lock"></i> Logout
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                ?>
                                                <li>
                                                    <a href="javascript:void(0)" id="btn-logout">
                                                        <i class="fa fa-lock"></i> લૉગઆઉટ
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                            ?>

                                        </ul>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </nav>

                <div class="pcoded-main-container" style='margin-top: 56px;background-image: url("<?php echo $_SESSION['bg_img_url']; ?>");background-size: contain;'>

                    <!--<div class="pcoded-main-container" style='margin-top: 56px;background-image: url("./files/assets/img/vyara_canal.jpeg");image-orientation: revert'>-->
                    <div class="pcoded-wrapper">
                        <nav class="pcoded-navbar" navbar-theme="theme1" active-item-theme="theme1" sub-item-theme="theme2" active-item-style="style0" pcoded-navbar-position="fixed">
                            <div class="pcoded-inner-navbar main-menu mCustomScrollbar _mCS_1" id="" style="height: calc(100% - 80px);"><div id="mCSB_1" class="mCustomScrollBox mCS-light mCSB_vertical_horizontal mCSB_inside" style="max-height: none;" tabindex="0"><div id="mCSB_1_container_wrapper" class="mCSB_container_wrapper mCS_x_hidden mCS_no_scrollbar_x"><div id="mCSB_1_container" class="mCSB_container" style="position: relative; top: -10px; left: 0px; width: 100%;" dir="ltr">
                                            <div class="pcoded-navigatio-lavel" menu-title-theme="theme5">Navigation</div>
                                            <ul class="pcoded-item pcoded-left-item" item-border="true" item-border-style="none" subitem-border="true">                                                
                                                <li class="">
                                                    <a href="./index.php">
                                                        <span class="pcoded-micon"><i class="fa fa-home"></i></span>


                                                        <?php
                                                        if ($_SESSION['User_language'] == 'ENGLISH') {
                                                            ?>
                                                            <span class="pcoded-mtext">Dashboard</span>
                                                            <?php
                                                        }

                                                        if ($_SESSION['User_language'] == 'GUJARATI') {
                                                            ?>
                                                            <span class="pcoded-mtext">ડેશબોર્ડ</span>
                                                            <?php
                                                        }
                                                        ?>

                                                    </a>
                                                </li>
                                                <li class="pcoded-hasmenu" dropdown-icon="style1" subitem-icon="style1">
                                                    <a href="javascript:void(0)">
                                                        <span class="pcoded-micon"><i class="fa fa-navicon"></i></span>
                                                        <span class="pcoded-mtext">Reports</span>
                                                    </a>
                                                    <ul class="pcoded-submenu">
                                                        <li class="">
                                                            <a href="water_discharge_report.php">
                                                                <span class="pcoded-mtext">Water Discharge Report</span>
                                                            </a>
                                                        </li>
                                                        <!--<li class="">-->
                                                        <!--    <a href="http://13.234.254.166/gms/Mis_Report_c">-->
                                                        <!--        <span class="pcoded-mtext">Genset Mis Report</span>-->
                                                        <!--    </a>-->
                                                        <!--</li>-->
                                                    </ul>
                                                </li>
                                            </ul>
                                        </div></div><div id="mCSB_1_scrollbar_vertical" class="mCSB_scrollTools mCSB_1_scrollbar mCS-light mCSB_scrollTools_vertical" style="display: block;"><div class="mCSB_draggerContainer"><div id="mCSB_1_dragger_vertical" class="mCSB_dragger" style="position: absolute; min-height: 30px; display: block; height: 167px; max-height: 667px; top: 2px;"><div class="mCSB_dragger_bar" style="line-height: 30px;"></div></div><div class="mCSB_draggerRail"></div></div></div><div id="mCSB_1_scrollbar_horizontal" class="mCSB_scrollTools mCSB_1_scrollbar mCS-light mCSB_scrollTools_horizontal" style="display: none;"><div class="mCSB_draggerContainer"><div id="mCSB_1_dragger_horizontal" class="mCSB_dragger" style="position: absolute; min-width: 30px; width: 0px; left: 0px;"><div class="mCSB_dragger_bar"></div></div><div class="mCSB_draggerRail"></div></div></div></div></div>
                        </nav>
                        <div class="pcoded-content">
                            <div class="pcoded-inner-content">
                                <div class="main-body">
                                    <div class="page-wrapper">
                                        <div class="page-body">

                                            <!--                                            <div class="row">
                                                                                            <div class="col-sm-12">
                                                                                                <div class="card" style="height:50px;background-color: cadetblue">
                                                                                                    <h3 class="text-center m-auto text-uppercase" style="font-weight: bold;font-size: 25px;font-family:Helvetica;color:white;">Canal Monitoring System</h3>
                                                                                                </div>
                                                                                            </div>
                                                                                        </div>-->

                                            <div class="row">


                                                <div class="col-xl-3 col-md-6">
                                                    <div class="card bg-c-blue update-card">
                                                        <div class="card-block">
                                                            <div class="row align-items-end">

                                                                <?php
                                                                $query = 'SELECT count(id) as id FROM `tbl_flow_meter` WHERE flag=1 and user_id=' . $_SESSION['user_id'];
                                                                mysqli_set_charset($con, 'utf8');
                                                                $result = mysqli_query($con, $query);
                                                                if (mysqli_num_rows($result) > 0) {
                                                                    $i = 1;
                                                                    while ($row = mysqli_fetch_assoc($result)) {

                                                                        $id = $row["id"];
                                                                        ?>

                                                                        <div class="col-8">
                                                                            <h4 class="text-white"><?php echo $row["id"]; ?></h4>

                                                                            <?php
                                                                            if ($_SESSION['User_language'] == 'ENGLISH') {
                                                                                ?>
                                                                                <h6 class="text-white m-b-0">All Canal </h6>
                                                                                <?php
                                                                            }

                                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                                ?>
                                                                                <h6 class="text-white m-b-0">કુલ નહેર</h6>
                                                                                <?php
                                                                            }
                                                                            ?>

                                                                        </div>
                                                                        <div class="col-4 text-right">
                                                                            <img src="files/assets/img/locations.gif" height="50" width="50" style="border-radius: 25%;">
                                                                        </div>

                                                                        <?php
                                                                    }
                                                                }
                                                                ?>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

                                                <?php
                                                $offline = 0;
                                                $online = 0;

                                                $query = 'SELECT MAX(id) as id FROM `tbl_flow_meter_data` WHERE flag=1 and user_id=' . $_SESSION['user_id'] . ' GROUP BY user_id ORDER by id asc';
                                                mysqli_set_charset($con, 'utf8');
                                                $result = mysqli_query($con, $query);
                                                if (mysqli_num_rows($result) > 0) {
                                                    $i = 1;
                                                    while ($row = mysqli_fetch_assoc($result)) {

                                                        $id = $row["id"];

                                                        $query1 = 'SELECT tfmd.*,DATE_FORMAT(tfmd.created_date,"%d-%m-%Y %H:%i:%s") AS created_date_new,DATE_FORMAT(tfmd.created_date,"%Y-%m-%d") AS days_date,tfm.meter_name,tfm.address,tfm.canal_height,tfm.side_slop,tfm.channel_slop,tfm.m_r_coefficient,tfm.canal_bottom_width,tfm.canal_top_width FROM `tbl_flow_meter_data` as tfmd LEFT join tbl_flow_meter as tfm on tfm.user_id=tfmd.user_id WHERE tfmd.id=' . $id . ' and tfmd.flag=1 ORDER by tfmd.id DESC LIMIT 0,1';
//                                                        $query1 = 'SELECT tfmd.*,DATE_FORMAT(tfmd.created_date,"%d-%m-%Y %H:%i:%s") AS created_date_new,DATE_FORMAT(tfmd.created_date,"%Y-%m-%d") AS days_date,tfm.meter_name,tfm.address FROM `tbl_flow_meter_data` as tfmd LEFT join tbl_flow_meter as tfm on tfm.user_id=tfmd.user_id WHERE tfmd.id=' . $id . ' and tfmd.flag=1 ORDER by tfmd.id DESC LIMIT 0,1';
                                                        mysqli_set_charset($con, 'utf8');
                                                        $result1 = mysqli_query($con, $query1);
                                                        if (mysqli_num_rows($result) > 0) {
                                                            $i = 1;
                                                            while ($row1 = mysqli_fetch_assoc($result1)) {

                                                                $now = time(); // or your date as well
                                                                $your_date = strtotime($row1["days_date"]);
                                                                $datediff = $now - $your_date;

//                                                                                            echo round($datediff / (60 * 60 * 24));
                                                                $Days = round($datediff / (60 * 60 * 24));

//                                                                $check_on_off = $row1["canal_height"] - $row1["water_level"];
                                                                // if ($check_on_off < 0.20 || $Days > 1) {
                                                                //     $offline = $offline + 1;
                                                                // } else {
                                                                //     if ($check_on_off > 0.20) {
                                                                //         $online = $online + 1;
                                                                //     }
                                                                // }

                                                                if ($row1["water_level"] >= 0.20) {
                                                                    $online = $online + 1;
                                                                } else {
                                                                    $offline = $offline + 1;
                                                                }
//                                                                if ($Days > 1) {
//                                                                    $offline = $offline + 1;
//                                                                } else {
//                                                                    $online = $online + 1;
//                                                                }
//                                                                if ($Days > 1) {
//                                                                    $offline = $offline + 1;
//                                                                } else {
//                                                                    $online = $online + 1;
//                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                ?>

                                                <div class="col-xl-3 col-md-6">
                                                    <div class="card bg-c-green update-card">
                                                        <div class="card-block">
                                                            <div class="row align-items-end">
                                                                <div class="col-8">
                                                                    <h4 class="text-white"><?php echo $online; ?></h4>


                                                                    <?php
                                                                    if ($_SESSION['User_language'] == 'ENGLISH') {
                                                                        ?>
                                                                        <h6 class="text-white m-b-0">Total Open Gate Canal</h6>
                                                                        <?php
                                                                    }

                                                                    if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                        ?>
                                                                        <h6 class="text-white m-b-0">કુલ ઓપન ગેટ નહેર</h6>
                                                                        <?php
                                                                    }
                                                                    ?>

                                                                </div>
                                                                <div class="col-4 text-right">
                                                                    <img src="files/assets/img/aquarius.gif" height="50" width="50" style="border-radius: 25%;">
                                                                </div>

                                                            </div>
                                                        </div>

                                                    </div>
                                                </div>
                                                <div class="col-xl-3 col-md-6">
                                                    <div class="card bg-c-pink update-card">
                                                        <div class="card-block">
                                                            <div class="row align-items-end">
                                                                <div class="col-8">
                                                                    <h4 class="text-white"><?php echo $offline; ?></h4>

                                                                    <?php
                                                                    if ($_SESSION['User_language'] == 'ENGLISH') {
                                                                        ?>
                                                                        <h6 class="text-white m-b-0">Total Close Gate Canal</h6>
                                                                        <?php
                                                                    }

                                                                    if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                        ?>
                                                                        <h6 class="text-white m-b-0">કુલ બંધ ગેટ નહેર</h6>
                                                                        <?php
                                                                    }
                                                                    ?>

                                                                </div>
                                                                <div class="col-4 text-right">
                                                                    <img src="files/assets/img/river2.gif" height="50" width="50" style="border-radius: 25%;">
                                                                </div>
                                                            </div>
                                                        </div>

                                                    </div>
                                                </div>

                                                <div class="col-xl-12 col-md-12">
                                                    <div class="row">
                                                        <div class="col-xl-12 col-md-12">
                                                            <div class="card-header bg-c-green d-flex justify-content-between  align-items-center" style="height: 50px;">
                                                                <div>
                                                                    <h5 class="text-white text-uppercase" style="font-size: 18px;"><b>All Open Gate Canal</b></h5>
                                                                </div>
                                                                <div>
                                                                    <img src="files/assets/img/aquarius.gif" width="30" style="border-radius: 25%;">
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="col-xl-12 col-md-12">
                                                    <div class="card table-card">
                                                        <!--                                                        <div class="row">
                                                                                                                    <div class="card-header col-md-3" >
                                                        
                                                        <?php
                                                        if ($_SESSION['User_language'] == 'ENGLISH') {
                                                            ?>
                                                                                                                                                                                                                                <h5>Canal List</h5>
                                                            <?php
                                                        }

                                                        if ($_SESSION['User_language'] == 'GUJARATI') {
                                                            ?>
                                                                                                                                                                                                                                <h5>નહેરની યાદી</h5>
                                                            <?php
                                                        }
                                                        ?>
                                                                                                                    </div>
                                                        
                                                                                                                </div>-->
                                                        <hr style="margin-bottom: 0px;margin-top: 0px">
                                                        <div class="card-block">
                                                            <div class="table-responsive">
                                                                <table class="table table-hover  table-borderless">
                                                                    <thead>
                                                                        <tr>
                                                                            <?php
                                                                            if ($_SESSION['User_language'] == 'ENGLISH') {
                                                                                ?>
                                                                                <th>No.</th>
                                                                                <th>
                                                                                    Canal Name
                                                                                </th>
                                                                                <th>Water Level</th>
                                                                                <th>Water Flow</th>
                                                                                <th>Water Velocity</th>
                                                                                <th>Discharge Water</th>
                                                                                <!--<th>Temperature</th>-->
                                                                                <th>Last Update</th>
                                                                                <!--<th>Status</th>-->
                                                                                <?php
                                                                            }

                                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                                ?>
                                                                                <th>નં.</th>
                                                                                <th>
                                                                                    નહેરનું નામ
                                                                                </th>
                                                                                <th>વોટર લેવલ</th>
                                                                                <th>પાણીનો પ્રવાહ</th>
                                                                                <th>Water Velocity</th>
                                                                                <th>ડિસ્ચાર્જ પાણી</th>
                                                                                <!--<th>તાપમાન</th>-->
                                                                                <th>છેલ્લું અપડેટ</th>
                                                                                <!--<th>સ્થિતિ</th>-->
                                                                                <?php
                                                                            }
                                                                            ?>

                                                                        </tr>
                                                                    </thead>
                                                                    <tbody id="school_list">

                                                                        <?php

                                                                        function metersToFeet($meters) {
                                                                            $feet = $meters * 3.28084; // Convert meters to feet
                                                                            return $feet;
                                                                        }

                                                                        $query = 'SELECT MAX(id) as id FROM `tbl_flow_meter_data` WHERE flag=1 and user_id=' . $_SESSION['user_id'] . ' GROUP BY flow_meter_id ORDER by id asc';
                                                                        mysqli_set_charset($con, 'utf8');
                                                                        $result = mysqli_query($con, $query);
                                                                        if (mysqli_num_rows($result) > 0) {
                                                                            $i = 1;
                                                                            while ($row = mysqli_fetch_assoc($result)) {

                                                                                $id = $row["id"];
//                                                                                print_r($result);

                                                                                $query1 = 'SELECT tfmd.*,DATE_FORMAT(tfmd.created_date,"%d-%m-%Y %H:%i:%s") AS created_date_new,DATE_FORMAT(tfmd.created_date,"%Y-%m-%d") AS days_date,tfm.velocity_calibration,tfm.canal_type,tfm.meter_name,tfm.address,tfm.canal_height,tfm.side_slop,tfm.channel_slop,tfm.m_r_coefficient,tfm.canal_bottom_width,tfm.canal_top_width FROM `tbl_flow_meter_data` as tfmd LEFT join tbl_flow_meter as tfm on tfm.id=tfmd.flow_meter_id WHERE tfmd.id=' . $id . ' and tfmd.flag=1 ORDER by tfmd.id DESC LIMIT 0,1';
//                                                                                echo '<br>$query1 ' . $query1;
                                                                                mysqli_set_charset($con, 'utf8');
                                                                                $result1 = mysqli_query($con, $query1);
//                                                                                print_r($result1);
                                                                                if (mysqli_num_rows($result) > 0) {
                                                                                    while ($row1 = mysqli_fetch_assoc($result1)) {

                                                                                        $now = time(); // or your date as well
                                                                                        $your_date = strtotime($row1["days_date"]);
                                                                                        $datediff = $now - $your_date;

//                                                                                            echo round($datediff / (60 * 60 * 24));
                                                                                        $Days = round($datediff / (60 * 60 * 24));
//                                                                                        echo 'canal_height '.$row1["canal_height"];
//                                                                                        echo '<br>water_level '.$row1["water_level"];

                                                                                        $check_on_off = $row1["canal_height"] - $row1["water_level"];

                                                                                        if ($Days > 2) {
                                                                                            
                                                                                        } else {
//                                                                                            echo '<br>water_level ' . $row1["water_level"].' 0.20';
                                                                                            if ($row1["water_level"] >= 0.20) {   //1 days
                                                                                                ?>
                                                                                                <tr id="<?php echo $row1["flow_meter_id"]; ?>" class="view_school_tank_status">
                                                                                                    <td><?php echo $i; ?></td>
                                                                                                    <td>

                                                                                                        <div class="d-inline-block align-middle">
                                                                                                            <h6><?php echo $row1["meter_name"]; ?></h6>
                                                                                                            <p class="text-muted m-b-0"><?php echo $row1["address"]; ?></p>
                                                                                                        </div>
                                                                                                    </td>

                                                                                                    <?php
                                                                                                    $bottom_width = $row1["canal_bottom_width"];
//                                                                                            echo '<br>$bottom_width ' . $bottom_width;
                                                                                                    $side_slop = $row1["side_slop"];
//                                                                                                    $side_slop = 1.5; //for canal messurement wise
//                                                                                            echo '<br>side_slop ' . $side_slop;
                                                                                                    $channel_slop = $row1["channel_slop"];
//                                                                                                    $channel_slop = 0.000055; //for canal messurement wise
//                                                                                            echo '<br>channel_slop ' . $channel_slop;
                                                                                                    $m_r_coefficient = $row1["m_r_coefficient"];
//                                                                                                    $m_r_coefficient = 0.015; //for canal messurement wise
//                                                                                            echo '<br>m_r_coefficient ' . $m_r_coefficient;
                                                                                                    $canal_top_width = $row1["canal_top_width"];
//                                                                                            echo '<br>canal_top_width  ' . $canal_top_width;
                                                                                                    //$water_level = $row1["canal_height"] - $row1["water_level"];
                                                                                                    // if($row1["water_level"] >0.25 && $row1["water_level"] <= 0.70){
                                                                                                    $water_level = $row1["water_level"];
                                                                                                    // }else if($row1["water_level"] <= 0.25){
                                                                                                    //     $water_level=2.08;
                                                                                                    // }
//                                                                                            $water_level = 1.30;
//                                                                                            echo '<br>$bottom_width  ' . $bottom_width;

                                                                                                    if ($bottom_width != "" && $bottom_width != 0) {

                                                                                                        $a1 = $water_level * $bottom_width;
                                                                                                        $flow_level_squre = $water_level * $water_level;
                                                                                                        $a2 = $side_slop * $flow_level_squre;
                                                                                                        $Area = $a1 + $a2;
//                                                                                            echo '<br><br>$Area  ' . $Area;
//                                                                                                    $z1 = 1.5;
                                                                                                        $z12 = $water_level * $side_slop;
                                                                                                        $z3 = $bottom_width + $z12;
                                                                                                        $Area = $z3 * $water_level;
//                                                                                                     echo '<br><br>$Area  ' . $Area;

                                                                                                        $pw0 = $bottom_width;
                                                                                                        $pw1 = 2 * $water_level;
                                                                                                        $pw_side_slop = $side_slop * $side_slop;
//                                                                                                    $pw_side_slop = $channel_slop * $channel_slop;
//                                                                                            echo '<br>$pw_side_slop  ' . $pw_side_slop;
                                                                                                        $pw2 = 1 + $pw_side_slop;
//                                                                                            echo '<br>$pw2  ' . $pw2;
//                                                                                            $pw2_squre= sqrt($pw2);
                                                                                                        $pw2_squre = number_format(sqrt($pw2), 4);
//                                                                                            echo '<br>$pw2_squre  ' . $pw2_squre;
                                                                                                        $pw1_squre = number_format($pw1 * $pw2_squre, 4);
//                                                                                            echo '<br>$pw1_squre  ' . $pw1_squre;
                                                                                                        $wetted_perimeter = $pw0 + $pw1_squre;
//                                                                                            echo '<br>$wetted_perimeter  ' . $wetted_perimeter;
//                                                                                            echo '<br>$wetted_perimeter  ' .number_format($wetted_perimeter, 4); // 2.50

                                                                                                        $hydraulic_radius = $Area / $wetted_perimeter;
                                                                                                        $R = number_format($hydraulic_radius, 3);
//                                                                                            echo '<br>hydraulic_radius $R  ' . $R;
//                                                                                                    $S12 = number_format(sqrt($channel_slop), 3);
////                                                                                            echo '<br>$S12  ' . $S12;
//
//                                                                                                    $R23_squre = number_format($R * $R, 4);
////                                                                                            echo '<br>$R23_squre  ' . $R23_squre;
//
//                                                                                                    $R23_cube_root = number_format(pow($R23_squre, 1 / 3), 4);
////                                                                                            echo '<br>$R23_cube_root  ' . $R23_cube_root;
//
//                                                                                                    $Q_0 = number_format(1 / $m_r_coefficient, 3);
//                                                                                                    $Q_1 = number_format($Q_0 * $Area, 3);
////                                                                                            echo '<br>$Q_0  ' . $Q_0;
////                                                                                            echo '<br>$Q_1  ' . $Q_1;
//                                                                                                    $Q_2 = number_format($R * $S12, 4);
////                                                                                            echo '<br>$Q_2  ' . $Q_2;
//                                                                                                    $Q_Flow = number_format($Q_1 * $Q_2, 4);
////                                                                                            echo '<br>$Q_Flow  ' . $Q_Flow;
//                                                                                                    $Velocity = number_format($Q_Flow / $Area, 2);
//                                                                                                    // echo '<br>$Velocity  ' . $Velocity;
//                                                                                                    $m_r_coefficient = 0.015; // Manning's roughness coefficient
//$R = 0.54;  // m (hydraulic radius)
                                                                                                        $S = $channel_slop; // slope
// Manning's formula for velocity
                                                                                                        $V = (1 / $m_r_coefficient) * pow($R, 2 / 3) * sqrt($S);

// Discharge formula Q = A * V
                                                                                                        $Q = $Area * $V;

//                                                                                                    echo "<br>Velocity (V): " . $V . " m/s\n";
//                                                                                                    echo "<br>Discharge (Q): " . $Q . " m^3/s\n";

                                                                                                        $Q_Flow = number_format($Q, 4);
                                                                                            // echo '<br>$Q_Flow  ' . $Q_Flow;
                                                                                                        $Velocity = number_format($V, 2);

                                                                                                        $Cusec_1_unit = 35.3147;
                                                                                                        $liter_1_unit = 1000;

                                                                                                        $meters = $water_level; // Example value in meters
                                                                                                        $feet = metersToFeet($meters);
                                                                                                        // echo "<br>$meters meters is equal to " . $feet . " feet.";
//// Output the result
                                                                                                        // echo "<br>$meters meters is equal to " . number_format($feet, 2) . " feet.";
                                                                                                        $water_level_check = $feet;

                                                                                                        $cusec = 0;

                                                                                                        $location_id = $row1["flow_meter_id"];
//                                                                                print_r($result);

                                                                                                        $query21 = 'SELECT * FROM `tbl_canal_measure_data` WHERE location=' . $location_id . ' and flag=1 ORDER by id DESC LIMIT 0,1';
//                                                                                echo '$query21 ' . $query21;
                                                                                                        mysqli_set_charset($con, 'utf8');
                                                                                                        $result21 = mysqli_query($con, $query21);
                                                                                                        if (mysqli_num_rows($result21) > 0) {
                                                                                                            while ($row21 = mysqli_fetch_assoc($result21)) {

//                                                                                                            echo $row21["0_1"];

                                                                                                                if ($water_level_check >= 0.15 && $water_level_check <= 0.25) {
                                                                                                                    $cusec = $row21["0_1"];
                                                                                                                } else if ($water_level_check >= 0.25 && $water_level_check <= 0.35) {
                                                                                                                    $cusec = $row21["0_2"];
                                                                                                                } else if ($water_level_check >= 0.35 && $water_level_check <= 0.45) {
                                                                                                                    $cusec = $row21["0_3"];
                                                                                                                } else if ($water_level_check >= 0.45 && $water_level_check <= 0.55) {
                                                                                                                    $cusec = $row21["0_4"];
                                                                                                                } else if ($water_level_check >= 0.55 && $water_level_check <= 0.65) {
                                                                                                                    $cusec = $row21["0_5"];
                                                                                                                } else if ($water_level_check >= 0.65 && $water_level_check <= 0.75) {
                                                                                                                    $cusec = $row21["0_6"];
                                                                                                                } else if ($water_level_check >= 0.75 && $water_level_check <= 0.85) {
                                                                                                                    $cusec = $row21["0_7"];
                                                                                                                } else if ($water_level_check >= 0.85 && $water_level_check <= 0.95) {
                                                                                                                    $cusec = $row21["0_8"];
                                                                                                                } else if ($water_level_check >= 0.95 && $water_level_check <= 1.05) {
                                                                                                                    $cusec = $row21["0_9"];
                                                                                                                } else if ($water_level_check >= 1.05 && $water_level_check <= 1.15) {
                                                                                                                    $cusec = $row21["1_0"];
                                                                                                                } else if ($water_level_check >= 1.15 && $water_level_check <= 1.25) {
                                                                                                                    $cusec = $row21["1_1"];
                                                                                                                } else if ($water_level_check >= 1.25 && $water_level_check <= 1.35) {
                                                                                                                    $cusec = $row21["1_2"];
                                                                                                                } else if ($water_level_check > 1.35 && $water_level_check <= 1.45) {
                                                                                                                    $cusec = $row21["1_3"] + 3;
                                                                                                                } else if ($water_level_check > 1.45 && $water_level_check <= 1.55) {
                                                                                                                    $cusec = $row21["1_4"] + 3;
                                                                                                                } else if ($water_level_check > 1.55 && $water_level_check <= 1.65) {
                                                                                                                    $cusec = $row21["1_5"] + 3;
                                                                                                                } else if ($water_level_check > 1.65 && $water_level_check <= 1.75) {
                                                                                                                    $cusec = $row21["1_6"] + 3;
                                                                                                                } else if ($water_level_check > 1.75 && $water_level_check <= 1.85) {
                                                                                                                    $cusec = $row21["1_7"] + 3;
                                                                                                                } else if ($water_level_check > 1.85 && $water_level_check <= 1.95) {
                                                                                                                    $cusec = $row21["1_8"] + 3;
                                                                                                                } else if ($water_level_check > 1.95 && $water_level_check <= 2.05) {
                                                                                                                    $cusec = $row21["1_9"] + 3;
                                                                                                                } else if ($water_level_check > 2.05 && $water_level_check <= 2.15) {
                                                                                                                    $cusec = $row21["2_0"] + 3;
                                                                                                                } else if ($water_level_check > 2.15 && $water_level_check <= 2.25) {
                                                                                                                    $cusec = $row21["2_1"] + 3;
                                                                                                                } else if ($water_level_check > 2.25 && $water_level_check <= 2.35) {
                                                                                                                    $cusec = $row21["2_2"] + 3;
                                                                                                                } else if ($water_level_check > 2.35 && $water_level_check <= 2.45) {
                                                                                                                    $cusec = $row21["2_3"] + 3;
                                                                                                                } else if ($water_level_check > 2.45 && $water_level_check <= 2.55) {
                                                                                                                    $cusec = $row21["2_4"] + 3;
                                                                                                                } else if ($water_level_check > 2.55 && $water_level_check <= 2.65) {
                                                                                                                    $cusec = $row21["2_5"] + 3;
                                                                                                                } else if ($water_level_check > 2.65 && $water_level_check <= 2.75) {
                                                                                                                    $cusec = $row21["2_6"] + 3;
                                                                                                                } else if ($water_level_check > 2.75 && $water_level_check <= 2.85) {
                                                                                                                    $cusec = $row21["2_7"] + 3;
                                                                                                                } else if ($water_level_check > 2.85 && $water_level_check <= 2.95) {
                                                                                                                    $cusec = $row21["2_8"] + 3;
                                                                                                                } else if ($water_level_check > 2.95 && $water_level_check <= 3.05) {
                                                                                                                    $cusec = $row21["2_9"] + 3;
                                                                                                                } else if ($water_level_check > 3.05 && $water_level_check <= 3.15) {
                                                                                                                    $cusec = $row21["3_0"] + 3;
                                                                                                                } else if ($water_level_check > 3.15 && $water_level_check <= 3.25) {
                                                                                                                    $cusec = $row21["3_1"] + 3;
                                                                                                                } else if ($water_level_check > 3.25 && $water_level_check <= 3.35) {
                                                                                                                    $cusec = $row21["3_2"] + 3;
                                                                                                                } else if ($water_level_check > 3.35 && $water_level_check <= 3.45) {
                                                                                                                    $cusec = $row21["3_3"] + 3;
                                                                                                                } else if ($water_level_check > 3.45 && $water_level_check <= 3.55) {
                                                                                                                    $cusec = $row21["3_4"] + 3;
                                                                                                                } else if ($water_level_check > 3.55 && $water_level_check <= 3.65) {
                                                                                                                    $cusec = $row21["3_5"] + 3;
                                                                                                                } else if ($water_level_check > 3.65 && $water_level_check <= 3.75) {
                                                                                                                    $cusec = $row21["3_6"] + 3;
                                                                                                                } else if ($water_level_check > 3.75 && $water_level_check <= 3.85) {
                                                                                                                    $cusec = $row21["3_7"] + 3;
                                                                                                                } else if ($water_level_check > 3.85 && $water_level_check <= 3.95) {
                                                                                                                    $cusec = $row21["3_8"] + 3;
                                                                                                                } else if ($water_level_check > 3.95 && $water_level_check <= 4.05) {
                                                                                                                    $cusec = $row21["3_9"] + 3;
                                                                                                                } else if ($water_level_check > 4.05 && $water_level_check <= 4.15) {
                                                                                                                    $cusec = $row21["4_0"] + 3;
                                                                                                                } else if ($water_level_check > 4.15 && $water_level_check <= 4.25) {
                                                                                                                    $cusec = $row21["4_1"] + 3;
                                                                                                                } else if ($water_level_check > 4.25 && $water_level_check <= 4.35) {
                                                                                                                    $cusec = $row21["4_2"] + 3;
                                                                                                                } else if ($water_level_check > 4.35 && $water_level_check <= 4.45) {
                                                                                                                    $cusec = $row21["4_3"] + 3;
                                                                                                                } else if ($water_level_check > 4.45 && $water_level_check <= 4.55) {
                                                                                                                    $cusec = $row21["4_4"] + 3;
                                                                                                                } else if ($water_level_check > 4.55 && $water_level_check <= 4.65) {
                                                                                                                    $cusec = $row21["4_5"] + 3;
                                                                                                                } else if ($water_level_check > 4.65 && $water_level_check <= 4.75) {
                                                                                                                    $cusec = $row21["4_6"] + 3;
                                                                                                                } else if ($water_level_check > 4.72 && $water_level_check <= 4.85) {
                                                                                                                    $cusec = $row21["4_7"] + 3;
                                                                                                                } else if ($water_level_check > 4.82 && $water_level_check <= 4.95) {
                                                                                                                    $cusec = $row21["4_8"] + 3;
                                                                                                                } else if ($water_level_check > 4.92 && $water_level_check <= 5.05) {
                                                                                                                    $cusec = $row21["4_9"] + 3;
                                                                                                                } else if ($water_level_check > 5.02 && $water_level_check <= 5.15) {
                                                                                                                    $cusec = $row21["5_0"] + 3;
                                                                                                                } else if ($water_level_check > 5.15 && $water_level_check <= 5.25) {
                                                                                                                    $cusec = $row21["5_1"] + 3;
                                                                                                                } else if ($water_level_check > 5.25 && $water_level_check <= 5.35) {
                                                                                                                    $cusec = $row21["5_2"] + 3;
                                                                                                                } else if ($water_level_check > 5.35 && $water_level_check <= 5.45) {
                                                                                                                    $cusec = $row21["5_3"] + 3;
                                                                                                                } else if ($water_level_check > 5.45 && $water_level_check <= 5.55) {
                                                                                                                    $cusec = $row21["5_4"] + 3;
                                                                                                                } else if ($water_level_check > 5.55 && $water_level_check <= 5.65) {
                                                                                                                    $cusec = $row21["5_5"] + 3;
                                                                                                                } else if ($water_level_check > 5.65 && $water_level_check <= 5.75) {
                                                                                                                    $cusec = $row21["5_6"] + 3;
                                                                                                                } else if ($water_level_check > 5.75 && $water_level_check <= 5.85) {
                                                                                                                    $cusec = $row21["5_7"] + 3;
                                                                                                                } else if ($water_level_check > 5.85 && $water_level_check <= 5.95) {
                                                                                                                    $cusec = $row21["5_8"] + 3;
                                                                                                                } else if ($water_level_check > 5.95 && $water_level_check <= 6.05) {
                                                                                                                    $cusec = $row21["5_9"] + 3;
                                                                                                                } else if ($water_level_check > 6.05 && $water_level_check <= 6.15) {
                                                                                                                    $cusec = $row21["6_0"] + 3;
                                                                                                                } else if ($water_level_check > 6.15 && $water_level_check <= 6.25) {
                                                                                                                    $cusec = $row21["6_1"] + 3;
                                                                                                                } else if ($water_level_check > 6.25 && $water_level_check <= 6.35) {
                                                                                                                    $cusec = $row21["6_2"] + 3;
                                                                                                                } else if ($water_level_check > 6.35 && $water_level_check <= 6.45) {
                                                                                                                    $cusec = $row21["6_3"] + 3;
                                                                                                                } else if ($water_level_check > 6.45 && $water_level_check <= 6.55) {
                                                                                                                    $cusec = $row21["6_4"] + 3;
                                                                                                                } else if ($water_level_check > 6.55 && $water_level_check <= 6.65) {
                                                                                                                    $cusec = $row21["6_5"] + 3;
                                                                                                                } else if ($water_level_check > 6.65 && $water_level_check <= 6.75) {
                                                                                                                    $cusec = $row21["6_6"] + 3;
                                                                                                                } else if ($water_level_check > 6.75 && $water_level_check <= 6.85) {
                                                                                                                    $cusec = $row21["6_7"] + 3;
                                                                                                                } else if ($water_level_check > 6.85) {
                                                                                                                    $cusec = $row21["6_8"] + 3;
                                                                                                                }
                                                                                                            }
                                                                                                        } else {
                                                                                                            $cusec = number_format($Q_Flow * $Cusec_1_unit, 2);
                                                                                                        }
                                                                                                        $water_level = number_format($row1["water_level"], 2) . ' Meter';
                                                                                                    } else { //Kakarapar Dem
                                                                                                        $location_id = $row1["flow_meter_id"];
//                                                                                print_r($result);

                                                                                                        $meters = $water_level; // Example value in meters
//                                                                                                        echo '$meters ' . $meters;
                                                                                                        $feet = metersToFeet($meters);
                                                                                                        // echo "<br>$meters meters is equal to " . $feet . " feet.";
//// Output the result
                                                                                                        // echo "<br>$meters meters is equal to " . number_format($feet, 2) . " feet.";
                                                                                                        $water_level_check = $feet;
//                                                                                                        echo '<br>$water_level_check ' . $water_level_check;

                                                                                                        $query21 = 'SELECT * FROM `tbl_canal_kakarapar_mesure` WHERE location_id=' . $location_id . ' and flag=1 ORDER by id asc LIMIT 0,1';
                                                                                                        // echo '<br>$query21 ' . $query21;
                                                                                                        mysqli_set_charset($con, 'utf8');
                                                                                                        $result21 = mysqli_query($con, $query21);
                                                                                                        if (mysqli_num_rows($result21) > 0) {
                                                                                                            while ($row21 = mysqli_fetch_assoc($result21)) {


                                                                                                                if ($water_level_check <= 159.95) {
                                                                                                                    $cusec = 0;
                                                                                                                } else if ($water_level_check > 159.95 && $water_level_check <= 160.05) {
                                                                                                                    $cusec = $row21["160_0"];
                                                                                                                } else if ($water_level_check > 160.05 && $water_level_check <= 160.15) {
                                                                                                                    $cusec = $row21["160_10"];
                                                                                                                } else if ($water_level_check > 160.15 && $water_level_check <= 160.25) {
                                                                                                                    $cusec = $row21["160_20"];
                                                                                                                } else if ($water_level_check > 160.25 && $water_level_check <= 160.35) {
                                                                                                                    $cusec = $row21["160_30"];
                                                                                                                } else if ($water_level_check > 160.35 && $water_level_check <= 160.45) {
                                                                                                                    $cusec = $row21["160_40"];
                                                                                                                } else if ($water_level_check > 160.45 && $water_level_check <= 160.55) {
                                                                                                                    $cusec = $row21["160_50"];
                                                                                                                } else if ($water_level_check > 160.55 && $water_level_check <= 160.65) {
                                                                                                                    $cusec = $row21["160_60"];
                                                                                                                } else if ($water_level_check > 160.65 && $water_level_check <= 160.75) {
                                                                                                                    $cusec = $row21["160_70"];
                                                                                                                } else if ($water_level_check > 160.75 && $water_level_check <= 160.85) {
                                                                                                                    $cusec = $row21["160_80"];
                                                                                                                } else if ($water_level_check > 160.85 && $water_level_check <= 160.95) {
                                                                                                                    $cusec = $row21["160_90"];
                                                                                                                } else if ($water_level_check > 160.95 && $water_level_check <= 161.05) {
                                                                                                                    $cusec = $row21["161_0"];
                                                                                                                } else if ($water_level_check > 161.05 && $water_level_check <= 161.15) {
                                                                                                                    $cusec = $row21["161_10"];
                                                                                                                } else if ($water_level_check > 161.15 && $water_level_check <= 161.25) {
                                                                                                                    $cusec = $row21["161_20"];
                                                                                                                } else if ($water_level_check > 161.25 && $water_level_check <= 161.35) {
                                                                                                                    $cusec = $row21["161_30"];
                                                                                                                } else if ($water_level_check > 161.35 && $water_level_check <= 161.45) {
                                                                                                                    $cusec = $row21["161_40"] + 3;
                                                                                                                } else if ($water_level_check > 161.45 && $water_level_check <= 161.55) {
                                                                                                                    $cusec = $row21["161_50"] + 3;
                                                                                                                } else if ($water_level_check > 161.55 && $water_level_check <= 161.65) {
                                                                                                                    $cusec = $row21["161_60"] + 3;
                                                                                                                } else if ($water_level_check > 161.65 && $water_level_check <= 161.75) {
                                                                                                                    $cusec = $row21["161_70"] + 3;
                                                                                                                } else if ($water_level_check > 161.75 && $water_level_check <= 161.85) {
                                                                                                                    $cusec = $row21["161_80"] + 3;
                                                                                                                } else if ($water_level_check > 161.85 && $water_level_check <= 161.95) {
                                                                                                                    $cusec = $row21["161_90"] + 3;
                                                                                                                } else if ($water_level_check > 161.95 && $water_level_check <= 162.05) {
                                                                                                                    $cusec = $row21["162_0"] + 3;
                                                                                                                } else if ($water_level_check > 162.05 && $water_level_check <= 162.15) {
                                                                                                                    $cusec = $row21["162_10"] + 3;
                                                                                                                } else if ($water_level_check > 162.15 && $water_level_check <= 162.25) {
                                                                                                                    $cusec = $row21["162_20"] + 3;
                                                                                                                } else if ($water_level_check > 162.25 && $water_level_check <= 162.35) {
                                                                                                                    $cusec = $row21["162_30"] + 3;
                                                                                                                } else if ($water_level_check > 162.35 && $water_level_check <= 162.45) {
                                                                                                                    $cusec = $row21["162_40"] + 3;
                                                                                                                } else if ($water_level_check > 162.45 && $water_level_check <= 162.55) {
                                                                                                                    $cusec = $row21["162_50"] + 3;
                                                                                                                } else if ($water_level_check > 162.55 && $water_level_check <= 162.65) {
                                                                                                                    $cusec = $row21["162_60"] + 3;
                                                                                                                } else if ($water_level_check > 162.65 && $water_level_check <= 162.75) {
                                                                                                                    $cusec = $row21["162_70"] + 3;
                                                                                                                } else if ($water_level_check > 162.75 && $water_level_check <= 162.85) {
                                                                                                                    $cusec = $row21["162_80"] + 3;
                                                                                                                } else if ($water_level_check > 162.85 && $water_level_check <= 162.95) {
                                                                                                                    $cusec = $row21["162_90"] + 3;
                                                                                                                } else if ($water_level_check > 162.95 && $water_level_check <= 163.05) {
                                                                                                                    $cusec = $row21["163_0"] + 3;
                                                                                                                } else if ($water_level_check > 163.05 && $water_level_check <= 163.15) {
                                                                                                                    $cusec = $row21["163_10"] + 3;
                                                                                                                } else if ($water_level_check > 163.15 && $water_level_check <= 163.25) {
                                                                                                                    $cusec = $row21["163_20"] + 3;
                                                                                                                } else if ($water_level_check > 163.25 && $water_level_check <= 163.35) {
                                                                                                                    $cusec = $row21["163_30"] + 3;
                                                                                                                } else if ($water_level_check > 163.35 && $water_level_check <= 163.45) {
                                                                                                                    $cusec = $row21["163_40"] + 3;
                                                                                                                } else if ($water_level_check > 163.45 && $water_level_check <= 163.55) {
                                                                                                                    $cusec = $row21["163_50"] + 3;
                                                                                                                } else if ($water_level_check > 163.55 && $water_level_check <= 163.65) {
                                                                                                                    $cusec = $row21["163_60"] + 3;
                                                                                                                } else if ($water_level_check > 163.65 && $water_level_check <= 163.75) {
                                                                                                                    $cusec = $row21["163_70"] + 3;
                                                                                                                } else if ($water_level_check > 163.75 && $water_level_check <= 163.85) {
                                                                                                                    $cusec = $row21["163_80"] + 3;
                                                                                                                } else if ($water_level_check > 163.85 && $water_level_check <= 163.95) {
                                                                                                                    $cusec = $row21["163_90"] + 3;
                                                                                                                } else if ($water_level_check > 163.95 && $water_level_check <= 164.05) {
                                                                                                                    $cusec = $row21["164_0"] + 3;
                                                                                                                } else if ($water_level_check > 164.05 && $water_level_check <= 164.15) {
                                                                                                                    $cusec = $row21["164_10"] + 3;
                                                                                                                } else if ($water_level_check > 164.15 && $water_level_check <= 164.25) {
                                                                                                                    $cusec = $row21["164_20"] + 3;
                                                                                                                } else if ($water_level_check > 164.25 && $water_level_check <= 164.35) {
                                                                                                                    $cusec = $row21["164_30"] + 3;
                                                                                                                } else if ($water_level_check > 164.35 && $water_level_check <= 164.45) {
                                                                                                                    $cusec = $row21["164_40"] + 3;
                                                                                                                } else if ($water_level_check > 164.45 && $water_level_check <= 164.55) {
                                                                                                                    $cusec = $row21["164_50"] + 3;
                                                                                                                } else if ($water_level_check > 164.55 && $water_level_check <= 164.65) {
                                                                                                                    $cusec = $row21["164_60"] + 3;
                                                                                                                } else if ($water_level_check > 164.65 && $water_level_check <= 164.75) {
                                                                                                                    $cusec = $row21["164_70"] + 3;
                                                                                                                } else if ($water_level_check > 164.75 && $water_level_check <= 164.85) {
                                                                                                                    $cusec = $row21["164_80"] + 3;
                                                                                                                } else if ($water_level_check > 164.85 && $water_level_check <= 164.95) {
                                                                                                                    $cusec = $row21["164_90"] + 3;
                                                                                                                } else if ($water_level_check > 164.95 && $water_level_check <= 165.05) {
                                                                                                                    $cusec = $row21["165_0"] + 3;
                                                                                                                } else if ($water_level_check > 165.05 && $water_level_check <= 165.15) {
                                                                                                                    $cusec = $row21["165_10"] + 3;
                                                                                                                } else if ($water_level_check > 165.15 && $water_level_check <= 165.25) {
                                                                                                                    $cusec = $row21["165_20"] + 3;
                                                                                                                } else if ($water_level_check > 165.25 && $water_level_check <= 165.35) {
                                                                                                                    $cusec = $row21["165_30"] + 3;
                                                                                                                } else if ($water_level_check > 165.35 && $water_level_check <= 165.45) {
                                                                                                                    $cusec = $row21["165_40"] + 3;
                                                                                                                } else if ($water_level_check > 165.45 && $water_level_check <= 165.55) {
                                                                                                                    $cusec = $row21["165_50"] + 3;
                                                                                                                } else if ($water_level_check > 165.55 && $water_level_check <= 165.65) {
                                                                                                                    $cusec = $row21["165_60"] + 3;
                                                                                                                } else if ($water_level_check > 165.65 && $water_level_check <= 165.75) {
                                                                                                                    $cusec = $row21["165_70"] + 3;
                                                                                                                } else if ($water_level_check > 165.75 && $water_level_check <= 165.85) {
                                                                                                                    $cusec = $row21["165_80"] + 3;
                                                                                                                } else if ($water_level_check > 165.85 && $water_level_check <= 165.95) {
                                                                                                                    $cusec = $row21["165_90"] + 3;
                                                                                                                } else if ($water_level_check > 165.95 && $water_level_check <= 166.05) {
                                                                                                                    $cusec = $row21["166_0"] + 3;
                                                                                                                } else if ($water_level_check > 166.05 && $water_level_check <= 166.15) {
                                                                                                                    $cusec = $row21["166_10"] + 3;
                                                                                                                } else if ($water_level_check > 166.15 && $water_level_check <= 166.25) {
                                                                                                                    $cusec = $row21["166_20"] + 3;
                                                                                                                } else if ($water_level_check > 166.25 && $water_level_check <= 166.35) {
                                                                                                                    $cusec = $row21["166_30"] + 3;
                                                                                                                } else if ($water_level_check > 166.35 && $water_level_check <= 166.45) {
                                                                                                                    $cusec = $row21["166_40"] + 3;
                                                                                                                } else if ($water_level_check > 166.45 && $water_level_check <= 166.55) {
                                                                                                                    $cusec = $row21["166_50"] + 3;
                                                                                                                } else if ($water_level_check > 166.55 && $water_level_check <= 166.65) {
                                                                                                                    $cusec = $row21["166_60"] + 3;
                                                                                                                } else if ($water_level_check > 166.65 && $water_level_check <= 166.75) {
                                                                                                                    $cusec = $row21["166_70"] + 3;
                                                                                                                } else if ($water_level_check > 166.75 && $water_level_check <= 166.85) {
                                                                                                                    $cusec = $row21["166_80"] + 3;
                                                                                                                } else if ($water_level_check > 166.85 && $water_level_check <= 166.95) {
                                                                                                                    $cusec = $row21["166_90"] + 3;
                                                                                                                } else if ($water_level_check > 166.95 && $water_level_check <= 167.05) {
                                                                                                                    $cusec = $row21["167_0"] + 3;
                                                                                                                } else if ($water_level_check > 167.05 && $water_level_check <= 167.15) {
                                                                                                                    $cusec = $row21["167_10"] + 3;
                                                                                                                } else if ($water_level_check > 167.15 && $water_level_check <= 167.25) {
                                                                                                                    $cusec = $row21["167_20"] + 3;
                                                                                                                } else if ($water_level_check > 167.25 && $water_level_check <= 167.35) {
                                                                                                                    $cusec = $row21["167_30"] + 3;
                                                                                                                } else if ($water_level_check > 167.35 && $water_level_check <= 167.45) {
                                                                                                                    $cusec = $row21["167_40"] + 3;
                                                                                                                } else if ($water_level_check > 167.45 && $water_level_check <= 167.55) {
                                                                                                                    $cusec = $row21["167_50"] + 3;
                                                                                                                } else if ($water_level_check > 167.55 && $water_level_check <= 167.65) {
                                                                                                                    $cusec = $row21["167_60"] + 3;
                                                                                                                } else if ($water_level_check > 167.65 && $water_level_check <= 167.75) {
                                                                                                                    $cusec = $row21["167_70"] + 3;
                                                                                                                } else if ($water_level_check > 167.75 && $water_level_check <= 167.85) {
                                                                                                                    $cusec = $row21["167_80"] + 3;
                                                                                                                } else if ($water_level_check > 167.85 && $water_level_check <= 167.95) {
                                                                                                                    $cusec = $row21["167_90"] + 3;
                                                                                                                } else if ($water_level_check > 167.95 && $water_level_check <= 168.05) {
                                                                                                                    $cusec = $row21["168_0"] + 3;
                                                                                                                } else if ($water_level_check > 168.05 && $water_level_check <= 168.15) {
                                                                                                                    $cusec = $row21["168_10"] + 3;
                                                                                                                } else if ($water_level_check > 168.15 && $water_level_check <= 168.25) {
                                                                                                                    $cusec = $row21["168_20"] + 3;
                                                                                                                } else if ($water_level_check > 168.25 && $water_level_check <= 168.35) {
                                                                                                                    $cusec = $row21["168_30"] + 3;
                                                                                                                } else if ($water_level_check > 168.35 && $water_level_check <= 168.45) {
                                                                                                                    $cusec = $row21["168_40"] + 3;
                                                                                                                } else if ($water_level_check > 168.45 && $water_level_check <= 168.55) {
                                                                                                                    $cusec = $row21["168_50"] + 3;
                                                                                                                } else if ($water_level_check > 168.55 && $water_level_check <= 168.65) {
                                                                                                                    $cusec = $row21["168_60"] + 3;
                                                                                                                } else if ($water_level_check > 168.65 && $water_level_check <= 168.75) {
                                                                                                                    $cusec = $row21["168_70"] + 3;
                                                                                                                } else if ($water_level_check > 168.75 && $water_level_check <= 168.85) {
                                                                                                                    $cusec = $row21["168_80"] + 3;
                                                                                                                } else if ($water_level_check > 168.85 && $water_level_check <= 169.95) {
                                                                                                                    $cusec = $row21["168_90"] + 3;
                                                                                                                } else if ($water_level_check > 169.95 && $water_level_check <= 169.05) {
                                                                                                                    $cusec = $row21["169_0"] + 3;
                                                                                                                } else if ($water_level_check > 169.05 && $water_level_check <= 169.15) {
                                                                                                                    $cusec = $row21["169_10"] + 3;
                                                                                                                } else if ($water_level_check > 169.15 && $water_level_check <= 169.25) {
                                                                                                                    $cusec = $row21["169_20"] + 3;
                                                                                                                } else if ($water_level_check > 169.25 && $water_level_check <= 169.35) {
                                                                                                                    $cusec = $row21["169_30"] + 3;
                                                                                                                } else if ($water_level_check > 169.35 && $water_level_check <= 169.45) {
                                                                                                                    $cusec = $row21["169_40"] + 3;
                                                                                                                } else if ($water_level_check > 169.45 && $water_level_check <= 169.55) {
                                                                                                                    $cusec = $row21["169_50"] + 3;
                                                                                                                } else if ($water_level_check > 169.55 && $water_level_check <= 169.65) {
                                                                                                                    $cusec = $row21["169_60"] + 3;
                                                                                                                } else if ($water_level_check > 169.65 && $water_level_check <= 169.75) {
                                                                                                                    $cusec = $row21["169_70"] + 3;
                                                                                                                } else if ($water_level_check > 169.75 && $water_level_check <= 169.85) {
                                                                                                                    $cusec = $row21["169_80"] + 3;
                                                                                                                } else if ($water_level_check > 169.85 && $water_level_check <= 169.95) {
                                                                                                                    $cusec = $row21["169_90"] + 3;
                                                                                                                } else if ($water_level_check > 169.95 && $water_level_check <= 170.05) {
                                                                                                                    $cusec = $row21["170_0"] + 3;
                                                                                                                } else if ($water_level_check > 170.05 && $water_level_check <= 170.15) {
                                                                                                                    $cusec = $row21["170_10"] + 3;
                                                                                                                } else if ($water_level_check > 170.15 && $water_level_check <= 170.25) {
                                                                                                                    $cusec = $row21["170_20"] + 3;
                                                                                                                } else if ($water_level_check > 170.25 && $water_level_check <= 170.35) {
                                                                                                                    $cusec = $row21["170_30"] + 3;
                                                                                                                } else if ($water_level_check > 170.35 && $water_level_check <= 170.45) {
                                                                                                                    $cusec = $row21["170_40"] + 3;
                                                                                                                } else if ($water_level_check > 170.45 && $water_level_check <= 170.55) {
                                                                                                                    $cusec = $row21["170_50"] + 3;
                                                                                                                } else if ($water_level_check > 170.55 && $water_level_check <= 170.65) {
                                                                                                                    $cusec = $row21["170_60"] + 3;
                                                                                                                } else if ($water_level_check > 170.65 && $water_level_check <= 170.75) {
                                                                                                                    $cusec = $row21["170_70"] + 3;
                                                                                                                } else if ($water_level_check > 170.75 && $water_level_check <= 170.85) {
                                                                                                                    $cusec = $row21["170_80"] + 3;
                                                                                                                } else if ($water_level_check > 170.85 && $water_level_check <= 170.95) {
                                                                                                                    $cusec = $row21["170_90"] + 3;
                                                                                                                } else if ($water_level_check > 170.95 && $water_level_check <= 171.05) {
                                                                                                                    $cusec = $row21["171_0"] + 3;
                                                                                                                } else if ($water_level_check > 171.05 && $water_level_check <= 171.15) {
                                                                                                                    $cusec = $row21["171_10"] + 3;
                                                                                                                } else if ($water_level_check > 171.15 && $water_level_check <= 171.25) {
                                                                                                                    $cusec = $row21["171_20"] + 3;
                                                                                                                } else if ($water_level_check > 171.25 && $water_level_check <= 171.35) {
                                                                                                                    $cusec = $row21["171_30"] + 3;
                                                                                                                } else if ($water_level_check > 171.35 && $water_level_check <= 171.45) {
                                                                                                                    $cusec = $row21["171_40"] + 3;
                                                                                                                } else if ($water_level_check > 171.45 && $water_level_check <= 171.55) {
                                                                                                                    $cusec = $row21["171_50"] + 3;
                                                                                                                } else if ($water_level_check > 171.55 && $water_level_check <= 171.65) {
                                                                                                                    $cusec = $row21["171_60"] + 3;
                                                                                                                } else if ($water_level_check > 171.65 && $water_level_check <= 171.75) {
                                                                                                                    $cusec = $row21["171_70"] + 3;
                                                                                                                } else if ($water_level_check > 171.75 && $water_level_check <= 171.85) {
                                                                                                                    $cusec = $row21["171_80"] + 3;
                                                                                                                } else if ($water_level_check > 171.85 && $water_level_check <= 171.95) {
                                                                                                                    $cusec = $row21["171_90"] + 3;
                                                                                                                } else if ($water_level_check > 171.95 && $water_level_check <= 172.05) {
                                                                                                                    $cusec = $row21["172_0"] + 3;
                                                                                                                } else if ($water_level_check > 172.05 && $water_level_check <= 172.15) {
                                                                                                                    $cusec = $row21["172_10"] + 3;
                                                                                                                } else if ($water_level_check > 172.15 && $water_level_check <= 172.25) {
                                                                                                                    $cusec = $row21["172_20"] + 3;
                                                                                                                } else if ($water_level_check > 172.25 && $water_level_check <= 172.35) {
                                                                                                                    $cusec = $row21["172_30"] + 3;
                                                                                                                } else if ($water_level_check > 172.35 && $water_level_check <= 172.45) {
                                                                                                                    $cusec = $row21["172_40"] + 3;
                                                                                                                } else if ($water_level_check > 172.45 && $water_level_check <= 172.55) {
                                                                                                                    $cusec = $row21["172_50"] + 3;
                                                                                                                } else if ($water_level_check > 172.55 && $water_level_check <= 172.65) {
                                                                                                                    $cusec = $row21["172_60"] + 3;
                                                                                                                } else if ($water_level_check > 172.65 && $water_level_check <= 172.75) {
                                                                                                                    $cusec = $row21["172_70"] + 3;
                                                                                                                } else if ($water_level_check > 172.75 && $water_level_check <= 172.85) {
                                                                                                                    $cusec = $row21["172_80"] + 3;
                                                                                                                } else if ($water_level_check > 172.85 && $water_level_check <= 172.95) {
                                                                                                                    $cusec = $row21["172_90"] + 3;
                                                                                                                } else if ($water_level_check > 172.95 && $water_level_check <= 173.05) {
                                                                                                                    $cusec = $row21["173_0"] + 3;
                                                                                                                } else if ($water_level_check > 173.05 && $water_level_check <= 173.15) {
                                                                                                                    $cusec = $row21["173_10"] + 3;
                                                                                                                } else if ($water_level_check > 173.15 && $water_level_check <= 173.25) {
                                                                                                                    $cusec = $row21["173_20"] + 3;
                                                                                                                } else if ($water_level_check > 173.25 && $water_level_check <= 173.35) {
                                                                                                                    $cusec = $row21["173_30"] + 3;
                                                                                                                } else if ($water_level_check > 173.35 && $water_level_check <= 173.45) {
                                                                                                                    $cusec = $row21["173_40"] + 3;
                                                                                                                } else if ($water_level_check > 173.45 && $water_level_check <= 173.55) {
                                                                                                                    $cusec = $row21["173_50"] + 3;
                                                                                                                } else if ($water_level_check > 173.55 && $water_level_check <= 173.65) {
                                                                                                                    $cusec = $row21["173_60"] + 3;
                                                                                                                } else if ($water_level_check > 173.65 && $water_level_check <= 173.75) {
                                                                                                                    $cusec = $row21["173_70"] + 3;
                                                                                                                } else if ($water_level_check > 173.75 && $water_level_check <= 173.85) {
                                                                                                                    $cusec = $row21["173_80"] + 3;
                                                                                                                } else if ($water_level_check > 173.85 && $water_level_check <= 173.95) {
                                                                                                                    $cusec = $row21["173_90"] + 3;
                                                                                                                } else if ($water_level_check > 173.95 && $water_level_check <= 174.05) {
                                                                                                                    $cusec = $row21["174_0"] + 3;
                                                                                                                } else if ($water_level_check > 174.05 && $water_level_check <= 174.15) {
                                                                                                                    $cusec = $row21["174_10"] + 3;
                                                                                                                } else if ($water_level_check > 174.15 && $water_level_check <= 174.25) {
                                                                                                                    $cusec = $row21["174_20"] + 3;
                                                                                                                } else if ($water_level_check > 174.25 && $water_level_check <= 174.35) {
                                                                                                                    $cusec = $row21["174_30"] + 3;
                                                                                                                } else if ($water_level_check > 174.35 && $water_level_check <= 174.45) {
                                                                                                                    $cusec = $row21["174_40"] + 3;
                                                                                                                } else if ($water_level_check > 174.45 && $water_level_check <= 174.55) {
                                                                                                                    $cusec = $row21["174_50"] + 3;
                                                                                                                } else if ($water_level_check > 174.55 && $water_level_check <= 174.65) {
                                                                                                                    $cusec = $row21["174_60"] + 3;
                                                                                                                } else if ($water_level_check > 174.65 && $water_level_check <= 174.75) {
                                                                                                                    $cusec = $row21["174_70"] + 3;
                                                                                                                } else if ($water_level_check > 174.75 && $water_level_check <= 174.85) {
                                                                                                                    $cusec = $row21["174_80"] + 3;
                                                                                                                } else if ($water_level_check > 174.85 && $water_level_check <= 174.95) {
                                                                                                                    $cusec = $row21["174_90"] + 3;
                                                                                                                } else if ($water_level_check > 174.95 && $water_level_check <= 175.05) {
                                                                                                                    $cusec = $row21["175_0"] + 3;
                                                                                                                } else if ($water_level_check > 175.05 && $water_level_check <= 175.15) {
                                                                                                                    $cusec = $row21["175_10"] + 3;
                                                                                                                } else if ($water_level_check > 175.15 && $water_level_check <= 175.25) {
                                                                                                                    $cusec = $row21["175_20"] + 3;
                                                                                                                } else if ($water_level_check > 175.25 && $water_level_check <= 175.35) {
                                                                                                                    $cusec = $row21["175_30"] + 3;
                                                                                                                } else if ($water_level_check > 175.35 && $water_level_check <= 175.45) {
                                                                                                                    $cusec = $row21["175_40"] + 3;
                                                                                                                } else if ($water_level_check > 175.45 && $water_level_check <= 175.55) {
                                                                                                                    $cusec = $row21["175_50"] + 3;
                                                                                                                } else if ($water_level_check > 175.55 && $water_level_check <= 175.65) {
                                                                                                                    $cusec = $row21["175_60"] + 3;
                                                                                                                } else if ($water_level_check > 175.65 && $water_level_check <= 175.75) {
                                                                                                                    $cusec = $row21["175_70"] + 3;
                                                                                                                } else if ($water_level_check > 175.75 && $water_level_check <= 175.85) {
                                                                                                                    $cusec = $row21["175_80"] + 3;
                                                                                                                } else if ($water_level_check > 175.85 && $water_level_check <= 175.95) {
                                                                                                                    $cusec = $row21["175_90"] + 3;
                                                                                                                } else if ($water_level_check > 175.95 && $water_level_check <= 176.05) {
                                                                                                                    $cusec = $row21["176_0"] + 3;
                                                                                                                } else if ($water_level_check > 176.05 && $water_level_check <= 176.15) {
                                                                                                                    $cusec = $row21["176_10"] + 3;
                                                                                                                } else if ($water_level_check > 176.15 && $water_level_check <= 176.25) {
                                                                                                                    $cusec = $row21["176_20"] + 3;
                                                                                                                } else if ($water_level_check > 176.25 && $water_level_check <= 176.35) {
                                                                                                                    $cusec = $row21["176_30"] + 3;
                                                                                                                } else if ($water_level_check > 176.35 && $water_level_check <= 176.45) {
                                                                                                                    $cusec = $row21["176_40"] + 3;
                                                                                                                } else if ($water_level_check > 176.45 && $water_level_check <= 176.55) {
                                                                                                                    $cusec = $row21["176_50"] + 3;
                                                                                                                } else if ($water_level_check > 176.55 && $water_level_check <= 176.65) {
                                                                                                                    $cusec = $row21["176_60"] + 3;
                                                                                                                } else if ($water_level_check > 176.65 && $water_level_check <= 176.75) {
                                                                                                                    $cusec = $row21["176_70"] + 3;
                                                                                                                } else if ($water_level_check > 176.75 && $water_level_check <= 176.85) {
                                                                                                                    $cusec = $row21["176_80"] + 3;
                                                                                                                } else if ($water_level_check > 176.85 && $water_level_check <= 176.95) {
                                                                                                                    $cusec = $row21["176_90"] + 3;
                                                                                                                } else if ($water_level_check > 176.95 && $water_level_check <= 177.05) {
                                                                                                                    $cusec = $row21["177_0"] + 3;
                                                                                                                } else if ($water_level_check > 177.05 && $water_level_check <= 177.15) {
                                                                                                                    $cusec = $row21["177_10"] + 3;
                                                                                                                } else if ($water_level_check > 177.15 && $water_level_check <= 177.25) {
                                                                                                                    $cusec = $row21["177_20"] + 3;
                                                                                                                } else if ($water_level_check > 177.25 && $water_level_check <= 177.35) {
                                                                                                                    $cusec = $row21["177_30"] + 3;
                                                                                                                } else if ($water_level_check > 177.35 && $water_level_check <= 177.45) {
                                                                                                                    $cusec = $row21["177_40"] + 3;
                                                                                                                } else if ($water_level_check > 177.45 && $water_level_check <= 177.55) {
                                                                                                                    $cusec = $row21["177_50"] + 3;
                                                                                                                } else if ($water_level_check > 177.55 && $water_level_check <= 177.65) {
                                                                                                                    $cusec = $row21["177_60"] + 3;
                                                                                                                } else if ($water_level_check > 177.65 && $water_level_check <= 177.75) {
                                                                                                                    $cusec = $row21["177_70"] + 3;
                                                                                                                } else if ($water_level_check > 177.75 && $water_level_check <= 177.85) {
                                                                                                                    $cusec = $row21["177_80"] + 3;
                                                                                                                } else if ($water_level_check > 177.85 && $water_level_check <= 177.95) {
                                                                                                                    $cusec = $row21["177_90"] + 3;
                                                                                                                } else if ($water_level_check > 177.95 && $water_level_check <= 178.05) {
                                                                                                                    $cusec = $row21["178_0"] + 3;
                                                                                                                } else if ($water_level_check > 178.05 && $water_level_check <= 178.15) {
                                                                                                                    $cusec = $row21["178_10"] + 3;
                                                                                                                } else if ($water_level_check > 178.15 && $water_level_check <= 178.25) {
                                                                                                                    $cusec = $row21["178_20"] + 3;
                                                                                                                } else if ($water_level_check > 178.25 && $water_level_check <= 178.35) {
                                                                                                                    $cusec = $row21["178_30"] + 3;
                                                                                                                } else if ($water_level_check > 178.35 && $water_level_check <= 178.45) {
                                                                                                                    $cusec = $row21["178_40"] + 3;
                                                                                                                } else if ($water_level_check > 178.45 && $water_level_check <= 178.55) {
                                                                                                                    $cusec = $row21["178_50"] + 3;
                                                                                                                } else if ($water_level_check > 178.55 && $water_level_check <= 178.65) {
                                                                                                                    $cusec = $row21["178_60"] + 3;
                                                                                                                } else if ($water_level_check > 178.65 && $water_level_check <= 178.75) {
                                                                                                                    $cusec = $row21["178_70"] + 3;
                                                                                                                } else if ($water_level_check > 178.75 && $water_level_check <= 178.85) {
                                                                                                                    $cusec = $row21["178_80"] + 3;
                                                                                                                } else if ($water_level_check > 178.85 && $water_level_check <= 179.95) {
                                                                                                                    $cusec = $row21["178_90"] + 3;
                                                                                                                } else if ($water_level_check > 179.95 && $water_level_check <= 179.05) {
                                                                                                                    $cusec = $row21["179_0"] + 3;
                                                                                                                } else if ($water_level_check > 179.05 && $water_level_check <= 179.15) {
                                                                                                                    $cusec = $row21["179_10"] + 3;
                                                                                                                } else if ($water_level_check > 179.15 && $water_level_check <= 179.25) {
                                                                                                                    $cusec = $row21["179_20"] + 3;
                                                                                                                } else if ($water_level_check > 179.25 && $water_level_check <= 179.35) {
                                                                                                                    $cusec = $row21["179_30"] + 3;
                                                                                                                } else if ($water_level_check > 179.35 && $water_level_check <= 179.45) {
                                                                                                                    $cusec = $row21["179_40"] + 3;
                                                                                                                } else if ($water_level_check > 179.45 && $water_level_check <= 179.55) {
                                                                                                                    $cusec = $row21["179_50"] + 3;
                                                                                                                } else if ($water_level_check > 179.55 && $water_level_check <= 179.65) {
                                                                                                                    $cusec = $row21["179_60"] + 3;
                                                                                                                } else if ($water_level_check > 179.65 && $water_level_check <= 179.75) {
                                                                                                                    $cusec = $row21["179_70"] + 3;
                                                                                                                } else if ($water_level_check > 179.75 && $water_level_check <= 179.85) {
                                                                                                                    $cusec = $row21["179_80"] + 3;
                                                                                                                } else if ($water_level_check > 179.85 && $water_level_check <= 179.95) {
                                                                                                                    $cusec = $row21["179_90"] + 3;
                                                                                                                } else if ($water_level_check > 179.95 && $water_level_check <= 180.05) {
                                                                                                                    $cusec = $row21["180_0"] + 3;
                                                                                                                } else if ($water_level_check > 180.05 && $water_level_check <= 180.15) {
                                                                                                                    $cusec = $row21["180_10"] + 3;
                                                                                                                } else if ($water_level_check > 180.15 && $water_level_check <= 180.25) {
                                                                                                                    $cusec = $row21["180_20"] + 3;
                                                                                                                } else if ($water_level_check > 180.25 && $water_level_check <= 180.35) {
                                                                                                                    $cusec = $row21["180_30"] + 3;
                                                                                                                } else if ($water_level_check > 180.35 && $water_level_check <= 180.45) {
                                                                                                                    $cusec = $row21["180_40"] + 3;
                                                                                                                } else if ($water_level_check > 180.45 && $water_level_check <= 180.55) {
                                                                                                                    $cusec = $row21["180_50"] + 3;
                                                                                                                } else if ($water_level_check > 180.55 && $water_level_check <= 180.65) {
                                                                                                                    $cusec = $row21["180_60"] + 3;
                                                                                                                } else if ($water_level_check > 180.65 && $water_level_check <= 180.75) {
                                                                                                                    $cusec = $row21["180_70"] + 3;
                                                                                                                } else if ($water_level_check > 180.75 && $water_level_check <= 180.85) {
                                                                                                                    $cusec = $row21["180_80"] + 3;
                                                                                                                } else if ($water_level_check > 180.85 && $water_level_check <= 180.95) {
                                                                                                                    $cusec = $row21["180_90"] + 3;
                                                                                                                } else if ($water_level_check > 180.95 && $water_level_check <= 181.05) {
                                                                                                                    $cusec = $row21["181_0"] + 3;
                                                                                                                } else if ($water_level_check > 181.05 && $water_level_check <= 181.15) {
                                                                                                                    $cusec = $row21["181_10"] + 3;
                                                                                                                } else if ($water_level_check > 181.15 && $water_level_check <= 181.25) {
                                                                                                                    $cusec = $row21["181_20"] + 3;
                                                                                                                } else if ($water_level_check > 181.25 && $water_level_check <= 181.35) {
                                                                                                                    $cusec = $row21["181_30"] + 3;
                                                                                                                } else if ($water_level_check > 181.35 && $water_level_check <= 181.45) {
                                                                                                                    $cusec = $row21["181_40"] + 3;
                                                                                                                } else if ($water_level_check > 181.45 && $water_level_check <= 181.55) {
                                                                                                                    $cusec = $row21["181_50"] + 3;
                                                                                                                } else if ($water_level_check > 181.55 && $water_level_check <= 181.65) {
                                                                                                                    $cusec = $row21["181_60"] + 3;
                                                                                                                } else if ($water_level_check > 181.65 && $water_level_check <= 181.75) {
                                                                                                                    $cusec = $row21["181_70"] + 3;
                                                                                                                } else if ($water_level_check > 181.75 && $water_level_check <= 181.85) {
                                                                                                                    $cusec = $row21["181_80"] + 3;
                                                                                                                } else if ($water_level_check > 181.85 && $water_level_check <= 181.95) {
                                                                                                                    $cusec = $row21["181_90"] + 3;
                                                                                                                } else if ($water_level_check > 181.95 && $water_level_check <= 182.05) {
                                                                                                                    $cusec = $row21["182_0"] + 3;
                                                                                                                } else if ($water_level_check > 182.05 && $water_level_check <= 182.15) {
                                                                                                                    $cusec = $row21["182_10"] + 3;
                                                                                                                } else if ($water_level_check > 182.15 && $water_level_check <= 182.25) {
                                                                                                                    $cusec = $row21["182_20"] + 3;
                                                                                                                } else if ($water_level_check > 182.25 && $water_level_check <= 182.35) {
                                                                                                                    $cusec = $row21["182_30"] + 3;
                                                                                                                } else if ($water_level_check > 182.35 && $water_level_check <= 182.45) {
                                                                                                                    $cusec = $row21["182_40"] + 3;
                                                                                                                } else if ($water_level_check > 182.45 && $water_level_check <= 182.55) {
                                                                                                                    $cusec = $row21["182_50"] + 3;
                                                                                                                } else if ($water_level_check > 182.55 && $water_level_check <= 182.65) {
                                                                                                                    $cusec = $row21["182_60"] + 3;
                                                                                                                } else if ($water_level_check > 182.65 && $water_level_check <= 182.75) {
                                                                                                                    $cusec = $row21["182_70"] + 3;
                                                                                                                } else if ($water_level_check > 182.75 && $water_level_check <= 182.85) {
                                                                                                                    $cusec = $row21["182_80"] + 3;
                                                                                                                } else if ($water_level_check > 182.85 && $water_level_check <= 182.95) {
                                                                                                                    $cusec = $row21["182_90"] + 3;
                                                                                                                } else if ($water_level_check > 182.95 && $water_level_check <= 183.05) {
                                                                                                                    $cusec = $row21["183_0"] + 3;
                                                                                                                } else if ($water_level_check > 183.05 && $water_level_check <= 183.15) {
                                                                                                                    $cusec = $row21["183_10"] + 3;
                                                                                                                } else if ($water_level_check > 183.15 && $water_level_check <= 183.25) {
                                                                                                                    $cusec = $row21["183_20"] + 3;
                                                                                                                } else if ($water_level_check > 183.25 && $water_level_check <= 183.35) {
                                                                                                                    $cusec = $row21["183_30"] + 3;
                                                                                                                } else if ($water_level_check > 183.35 && $water_level_check <= 183.45) {
                                                                                                                    $cusec = $row21["183_40"] + 3;
                                                                                                                } else if ($water_level_check > 183.45 && $water_level_check <= 183.55) {
                                                                                                                    $cusec = $row21["183_50"] + 3;
                                                                                                                } else if ($water_level_check > 183.55 && $water_level_check <= 183.65) {
                                                                                                                    $cusec = $row21["183_60"] + 3;
                                                                                                                } else if ($water_level_check > 183.65 && $water_level_check <= 183.75) {
                                                                                                                    $cusec = $row21["183_70"] + 3;
                                                                                                                } else if ($water_level_check > 183.75 && $water_level_check <= 183.85) {
                                                                                                                    $cusec = $row21["183_80"] + 3;
                                                                                                                } else if ($water_level_check > 183.85 && $water_level_check <= 183.95) {
                                                                                                                    $cusec = $row21["183_90"] + 3;
                                                                                                                } else if ($water_level_check > 183.95 && $water_level_check <= 184.05) {
                                                                                                                    $cusec = $row21["184_0"] + 3;
                                                                                                                } else if ($water_level_check > 184.05 && $water_level_check <= 184.15) {
                                                                                                                    $cusec = $row21["184_10"] + 3;
                                                                                                                } else if ($water_level_check > 184.15 && $water_level_check <= 184.25) {
                                                                                                                    $cusec = $row21["184_20"] + 3;
                                                                                                                } else if ($water_level_check > 184.25 && $water_level_check <= 184.35) {
                                                                                                                    $cusec = $row21["184_30"] + 3;
                                                                                                                } else if ($water_level_check > 184.35 && $water_level_check <= 184.45) {
                                                                                                                    $cusec = $row21["184_40"] + 3;
                                                                                                                } else if ($water_level_check > 184.45 && $water_level_check <= 184.55) {
                                                                                                                    $cusec = $row21["184_50"] + 3;
                                                                                                                } else if ($water_level_check > 184.55 && $water_level_check <= 184.65) {
                                                                                                                    $cusec = $row21["184_60"] + 3;
                                                                                                                } else if ($water_level_check > 184.65 && $water_level_check <= 184.75) {
                                                                                                                    $cusec = $row21["184_70"] + 3;
                                                                                                                } else if ($water_level_check > 184.75 && $water_level_check <= 184.85) {
                                                                                                                    $cusec = $row21["184_80"] + 3;
                                                                                                                } else if ($water_level_check > 184.85 && $water_level_check <= 184.95) {
                                                                                                                    $cusec = $row21["184_90"] + 3;
                                                                                                                } else if ($water_level_check > 184.95 && $water_level_check <= 185.05) {
                                                                                                                    $cusec = $row21["185_0"] + 3;
                                                                                                                } else if ($water_level_check > 185.05 && $water_level_check <= 185.15) {
                                                                                                                    $cusec = $row21["185_10"] + 3;
                                                                                                                } else if ($water_level_check > 185.15 && $water_level_check <= 185.25) {
                                                                                                                    $cusec = $row21["185_20"] + 3;
                                                                                                                } else if ($water_level_check > 185.25 && $water_level_check <= 185.35) {
                                                                                                                    $cusec = $row21["185_30"] + 3;
                                                                                                                } else if ($water_level_check > 185.35 && $water_level_check <= 185.45) {
                                                                                                                    $cusec = $row21["185_40"] + 3;
                                                                                                                } else if ($water_level_check > 185.45 && $water_level_check <= 185.55) {
                                                                                                                    $cusec = $row21["185_50"] + 3;
                                                                                                                } else if ($water_level_check > 185.55 && $water_level_check <= 185.65) {
                                                                                                                    $cusec = $row21["185_60"] + 3;
                                                                                                                } else if ($water_level_check > 185.65 && $water_level_check <= 185.75) {
                                                                                                                    $cusec = $row21["185_70"] + 3;
                                                                                                                } else if ($water_level_check > 185.75 && $water_level_check <= 185.85) {
                                                                                                                    $cusec = $row21["185_80"] + 3;
                                                                                                                } else if ($water_level_check > 185.85 && $water_level_check <= 185.95) {
                                                                                                                    $cusec = $row21["185_90"] + 3;
                                                                                                                } else if ($water_level_check > 185.95 && $water_level_check <= 186.05) {
                                                                                                                    $cusec = $row21["186_0"] + 3;
                                                                                                                } else if ($water_level_check > 186.05 && $water_level_check <= 186.15) {
                                                                                                                    $cusec = $row21["186_10"] + 3;
                                                                                                                } else if ($water_level_check > 186.15 && $water_level_check <= 186.25) {
                                                                                                                    $cusec = $row21["186_20"] + 3;
                                                                                                                } else if ($water_level_check > 186.25 && $water_level_check <= 186.35) {
                                                                                                                    $cusec = $row21["186_30"] + 3;
                                                                                                                } else if ($water_level_check > 186.35 && $water_level_check <= 186.45) {
                                                                                                                    $cusec = $row21["186_40"] + 3;
                                                                                                                } else if ($water_level_check > 186.45 && $water_level_check <= 186.55) {
                                                                                                                    $cusec = $row21["186_50"] + 3;
                                                                                                                } else if ($water_level_check > 186.55 && $water_level_check <= 186.65) {
                                                                                                                    $cusec = $row21["186_60"] + 3;
                                                                                                                } else if ($water_level_check > 186.65 && $water_level_check <= 186.75) {
                                                                                                                    $cusec = $row21["186_70"] + 3;
                                                                                                                } else if ($water_level_check > 186.75 && $water_level_check <= 186.85) {
                                                                                                                    $cusec = $row21["186_80"] + 3;
                                                                                                                } else if ($water_level_check > 186.85 && $water_level_check <= 186.95) {
                                                                                                                    $cusec = $row21["186_90"] + 3;
                                                                                                                } else if ($water_level_check > 186.95 && $water_level_check <= 187.05) {
                                                                                                                    $cusec = $row21["187_0"] + 3;
                                                                                                                } else if ($water_level_check > 187.05 && $water_level_check <= 187.15) {
                                                                                                                    $cusec = $row21["187_10"] + 3;
                                                                                                                } else if ($water_level_check > 187.15 && $water_level_check <= 187.25) {
                                                                                                                    $cusec = $row21["187_20"] + 3;
                                                                                                                } else if ($water_level_check > 187.25 && $water_level_check <= 187.35) {
                                                                                                                    $cusec = $row21["187_30"] + 3;
                                                                                                                } else if ($water_level_check > 187.35 && $water_level_check <= 187.45) {
                                                                                                                    $cusec = $row21["187_40"] + 3;
                                                                                                                } else if ($water_level_check > 187.45 && $water_level_check <= 187.55) {
                                                                                                                    $cusec = $row21["187_50"] + 3;
                                                                                                                } else if ($water_level_check > 187.55 && $water_level_check <= 187.65) {
                                                                                                                    $cusec = $row21["187_60"] + 3;
                                                                                                                } else if ($water_level_check > 187.65 && $water_level_check <= 187.75) {
                                                                                                                    $cusec = $row21["187_70"] + 3;
                                                                                                                } else if ($water_level_check > 187.75 && $water_level_check <= 187.85) {
                                                                                                                    $cusec = $row21["187_80"] + 3;
                                                                                                                } else if ($water_level_check > 187.85 && $water_level_check <= 187.95) {
                                                                                                                    $cusec = $row21["187_90"] + 3;
                                                                                                                } else if ($water_level_check > 187.95 && $water_level_check <= 188.05) {
                                                                                                                    $cusec = $row21["188_0"] + 3;
                                                                                                                } else if ($water_level_check > 188.05 && $water_level_check <= 188.15) {
                                                                                                                    $cusec = $row21["188_10"] + 3;
                                                                                                                } else if ($water_level_check > 188.15 && $water_level_check <= 188.25) {
                                                                                                                    $cusec = $row21["188_20"] + 3;
                                                                                                                } else if ($water_level_check > 188.25 && $water_level_check <= 188.35) {
                                                                                                                    $cusec = $row21["188_30"] + 3;
                                                                                                                } else if ($water_level_check > 188.35 && $water_level_check <= 188.45) {
                                                                                                                    $cusec = $row21["188_40"] + 3;
                                                                                                                } else if ($water_level_check > 188.45 && $water_level_check <= 188.55) {
                                                                                                                    $cusec = $row21["188_50"] + 3;
                                                                                                                } else if ($water_level_check > 188.55 && $water_level_check <= 188.65) {
                                                                                                                    $cusec = $row21["188_60"] + 3;
                                                                                                                } else if ($water_level_check > 188.65 && $water_level_check <= 188.75) {
                                                                                                                    $cusec = $row21["188_70"] + 3;
                                                                                                                } else if ($water_level_check > 188.75 && $water_level_check <= 188.85) {
                                                                                                                    $cusec = $row21["188_80"] + 3;
                                                                                                                } else if ($water_level_check > 188.85 && $water_level_check <= 189.95) {
                                                                                                                    $cusec = $row21["188_90"] + 3;
                                                                                                                } else if ($water_level_check > 189.95 && $water_level_check <= 189.05) {
                                                                                                                    $cusec = $row21["189_0"] + 3;
                                                                                                                } else if ($water_level_check > 189.05 && $water_level_check <= 189.15) {
                                                                                                                    $cusec = $row21["189_10"] + 3;
                                                                                                                } else if ($water_level_check > 189.15 && $water_level_check <= 189.25) {
                                                                                                                    $cusec = $row21["189_20"] + 3;
                                                                                                                } else if ($water_level_check > 189.25 && $water_level_check <= 189.35) {
                                                                                                                    $cusec = $row21["189_30"] + 3;
                                                                                                                } else if ($water_level_check > 189.35 && $water_level_check <= 189.45) {
                                                                                                                    $cusec = $row21["189_40"] + 3;
                                                                                                                } else if ($water_level_check > 189.45 && $water_level_check <= 189.55) {
                                                                                                                    $cusec = $row21["189_50"] + 3;
                                                                                                                } else if ($water_level_check > 189.55 && $water_level_check <= 189.65) {
                                                                                                                    $cusec = $row21["189_60"] + 3;
                                                                                                                } else if ($water_level_check > 189.65 && $water_level_check <= 189.75) {
                                                                                                                    $cusec = $row21["189_70"] + 3;
                                                                                                                } else if ($water_level_check > 189.75 && $water_level_check <= 189.85) {
                                                                                                                    $cusec = $row21["189_80"] + 3;
                                                                                                                } else if ($water_level_check > 189.85 && $water_level_check <= 189.95) {
                                                                                                                    $cusec = $row21["189_90"] + 3;
                                                                                                                } else if ($water_level_check > 189.95 && $water_level_check <= 190.05) {
                                                                                                                    $cusec = $row21["190_0"] + 3;
                                                                                                                } else if ($water_level_check > 190.05) {
                                                                                                                    $cusec = $row21["190_10"] + 3;
                                                                                                                }
                                                                                                            }

                                                                                                            if ($cusec != 0) {
                                                                                                                $Q_Flow = number_format($cusec * 0.0283168, 2);
                                                                                                                $Velocity = 0;
                                                                                                            } else {
                                                                                                                $Q_Flow = 0;
                                                                                                                $Velocity = 0;
                                                                                                            }
                                                                                                        } else {
                                                                                                            $cusec = number_format($Q_Flow * $Cusec_1_unit, 2);
                                                                                                        }

                                                                                                        $water_level = number_format($feet, 2) . " Foot";
                                                                                                        // echo '<br>$query21 ' . $query21;
                                                                                                    }
                                                                                                    ?>

                                                                                                    <td><?php echo $water_level; ?></td>
                                                                                                    <?php
//                                                                                                    echo '$row1["canal_type"] '.$row1["canal_type"];
                                                                                                    if ($row1["canal_type"] == "Canal") {
                                                                                                        ?>
                                                                                                        <td><?php echo $Q_Flow . ' m3/s'; ?></td>

                                                                                                        <?php
                                                                                                        if ($_SESSION['user_id'] == 3) {    // Vyara Main Canal Measurement
                                                                                                            $a = $Velocity / 10;
                                                                                                            $final_velocity = $a + 1 - 0.025;
                                                                                                            ?>
                                                                                                                                                                <!--<td><?php echo $Velocity + $row1['velocity_calibration'] . ' m/s'; ?></td>-->
                                                                                                            <td><?php echo $final_velocity . ' m/s'; ?></td>
                                                                                                            <?php
                                                                                                        } else {
                                                                                                            ?>
                                                                                                            <td><?php echo $Velocity . ' m/s'; ?></td>
                                                                                                            <?php
                                                                                                        }
                                                                                                    } else if ($row1["canal_type"] == "Dam") {
                                                                                                        ?>
                                                                                                        <td></td>
                                                                                                        <td></td>
                                                                                                        <?php
                                                                                                    }
                                                                                                    ?>                                                                                                                                                                                                                                                                                                                       <!--<td><?php echo number_format($row1["canal_height"], 2) . ' Meter'; ?></td>-->

                                                                                                    <td><?php echo $cusec . ' Cusec/Second'; ?></td>
                                                                                                    <td><?php echo $row1["created_date_new"]; ?></td>

                                                                                                    <?php
                                                                                                    $now = time(); // or your date as well
                                                                                                    $your_date = strtotime($row1["days_date"]);
                                                                                                    $datediff = $now - $your_date;

//                                                                                            echo round($datediff / (60 * 60 * 24));
                                                                                                    $Days = round($datediff / (60 * 60 * 24));
                                                                                                    ?>

                                                                                                    <td class="text-c-blue">
                                                                                                        <!--<div class="btn-group " role="group" data-toggle="tooltip" data-placement="top" data-original-title=".btn-xlg">-->
                                                                                                        <?php
//                                                                                                if ($Days > 3) {
                                                                                                        ?>
                                                                                                    </td>
                                                                                                </tr>
                                                                                                <?php
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                                $i = $i + 1;
                                                                            }
                                                                        }
                                                                        ?>

                                                                    </tbody>
                                                                </table>
                                                                <!--                                                                <div class="text-center">
                                                                                                                                    <a href="#!" class=" b-b-primary text-primary">View all
                                                                                                                                        Projects</a>
                                                                                                                                </div>-->
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>


                                                <div class="col-xl-12 col-md-12">
                                                    <div class="row">
                                                        <div class="col-xl-12 col-md-12">
                                                            <div class="card-header bg-c-pink d-flex justify-content-between  align-items-center" style="height: 50px;">
                                                                <div>
                                                                    <h5 class="text-white text-uppercase" style="font-size: 18px;"><b>All Close Gate Canal</b></h5>
                                                                </div>
                                                                <div>
                                                                    <img src="files/assets/img/river2.gif" width="30" style="border-radius: 25%;">
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="col-xl-12 col-md-12">
                                                    <div class="card table-card">
                                                        <!--                                                        <div class="row">
                                                                                                                    <div class="card-header col-md-3" >
                                                        
                                                        <?php
                                                        if ($_SESSION['User_language'] == 'ENGLISH') {
                                                            ?>
                                                                                                                                                                                                                                    <h5>Canal List</h5>
                                                            <?php
                                                        }

                                                        if ($_SESSION['User_language'] == 'GUJARATI') {
                                                            ?>
                                                                                                                                                                                                                                    <h5>નહેરની યાદી</h5>
                                                            <?php
                                                        }
                                                        ?>
                                                                                                                    </div>
                                                        
                                                                                                                </div>-->
                                                        <hr style="margin-bottom: 0px;margin-top: 0px">
                                                        <div class="card-block">
                                                            <div class="table-responsive">
                                                                <table class="table table-hover  table-borderless">
                                                                    <thead>
                                                                        <tr>
                                                                            <?php
                                                                            if ($_SESSION['User_language'] == 'ENGLISH') {
                                                                                ?>
                                                                                <th>No.</th>
                                                                                <th>
                                                                                    Canal Name
                                                                                </th>
                                                                                <th>Water Level</th>
                                                                                <th>Water Flow</th>
                                                                                <th>Water Velocity</th>
                                                                                <th>Discharge Water</th>
                                                                                <!--<th>Temperature</th>-->
                                                                                <th>Last Update</th>
                                                                                <!--<th>Status</th>-->
                                                                                <?php
                                                                            }

                                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                                ?>
                                                                                <th>નં.</th>
                                                                                <th>
                                                                                    નહેરનું નામ
                                                                                </th>
                                                                                <th>વોટર લેવલ</th>
                                                                                <th>પાણીનો પ્રવાહ</th>
                                                                                <th>Water Velocity</th>
                                                                                <th>ડિસ્ચાર્જ પાણી</th>
                                                                                <!--<th>તાપમાન</th>-->
                                                                                <th>છેલ્લું અપડેટ</th>
                                                                                <!--<th>સ્થિતિ</th>-->
                                                                                <?php
                                                                            }
                                                                            ?>

                                                                        </tr>
                                                                    </thead>
                                                                    <tbody id="school_list">

                                                                        <?php
                                                                        $query = 'SELECT MAX(id) as id FROM `tbl_flow_meter_data` WHERE flag=1 and user_id=' . $_SESSION['user_id'] . ' GROUP BY flow_meter_id ORDER by id asc';
// $query = 'SELECT MAX(id) as id FROM `tbl_flow_meter_data` WHERE flag=1 GROUP BY user_id ORDER by id asc';
                                                                        mysqli_set_charset($con, 'utf8');
                                                                        $result = mysqli_query($con, $query);
                                                                        if (mysqli_num_rows($result) > 0) {
                                                                            $i = 1;
                                                                            while ($row = mysqli_fetch_assoc($result)) {

                                                                                $id = $row["id"];
//                                                                                print_r($result);

                                                                                $query1 = 'SELECT tfmd.*,DATE_FORMAT(tfmd.created_date,"%d-%m-%Y %H:%i:%s") AS created_date_new,DATE_FORMAT(tfmd.created_date,"%Y-%m-%d") AS days_date,tfm.meter_name,tfm.address,tfm.canal_height,tfm.side_slop,tfm.channel_slop,tfm.m_r_coefficient,tfm.canal_bottom_width,tfm.canal_top_width FROM `tbl_flow_meter_data` as tfmd LEFT join tbl_flow_meter as tfm on tfm.user_id=tfmd.user_id WHERE tfmd.id=' . $id . ' and tfmd.flag=1 ORDER by tfmd.id DESC LIMIT 0,1';
//                                                                                echo '$query1 ' . $query1;
                                                                                mysqli_set_charset($con, 'utf8');
                                                                                $result1 = mysqli_query($con, $query1);
                                                                                if (mysqli_num_rows($result) > 0) {
                                                                                    while ($row1 = mysqli_fetch_assoc($result1)) {

                                                                                        $now = time(); // or your date as well
                                                                                        $your_date = strtotime($row1["days_date"]);
                                                                                        $datediff = $now - $your_date;

//                                                                                            echo round($datediff / (60 * 60 * 24));
                                                                                        $Days = round($datediff / (60 * 60 * 24));
                                                                                        $check_on_off = $row1["canal_height"] - $row1["water_level"];
//                                                                                        echo '$check_on_off '.$check_on_off;
//                                                                                        if ($Days > 1) {   //1 days

                                                                                        if ($row1["water_level"] < 0.20) {
//                                                                                        if ($Days > 1) {   //1 days
                                                                                            ?>
                                                                                            <tr id="<?php echo $row1["user_id"]; ?>" class="view_school_tank_status">
                                                                                                <td><?php echo $i; ?></td>
                                                                                                <td>

                                                                                                    <div class="d-inline-block align-middle">
                                                                                                        <h6><?php echo $row1["meter_name"]; ?></h6>
                                                                                                        <p class="text-muted m-b-0"><?php echo $row1["address"]; ?></p>
                                                                                                    </div>
                                                                                                </td>

                                                                                                <td><?php echo $row1["water_level"] . ' Meter'; ?></td>
                    <!--                                                                                                <td><?php // echo $Q_Flow . ' m3/s';                      ?></td>-->
                                                                                                <td><?php echo '0 m3/s'; ?></td>
                                                                                                <td><?php echo '0 m/s'; ?></td>
                                                                                                <td><?php echo '0 Cusec/Second'; ?></td>
                                                                                                <td><?php echo $row1["created_date_new"]; ?></td>

                                                                                                <?php
                                                                                                $now = time(); // or your date as well
                                                                                                $your_date = strtotime($row1["days_date"]);
                                                                                                $datediff = $now - $your_date;

//                                                                                            echo round($datediff / (60 * 60 * 24));
                                                                                                $Days = round($datediff / (60 * 60 * 24));
                                                                                                ?>

                                                                                                <td class="text-c-blue">
                                                                                                    <!--<div class="btn-group " role="group" data-toggle="tooltip" data-placement="top" data-original-title=".btn-xlg">-->
                                                                                                    <?php
//                                                                                                    }
                                                                                                    ?>



                                                                                                    <!--</div>-->
                                                                                                </td>
                                                                                            </tr>
                                                                                            <?php
                                                                                        } else {
                                                                                            
                                                                                        }
                                                                                    }
                                                                                }
                                                                                $i = $i + 1;
                                                                            }
                                                                        }
                                                                        ?>

                                                                    </tbody>
                                                                </table>
                                                                <!--                                                                <div class="text-center">
                                                                                                                                    <a href="#!" class=" b-b-primary text-primary">View all
                                                                                                                                        Projects</a>
                                                                                                                                </div>-->
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

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

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


        <!--[if lt IE 10]>
        <div class="ie-warning">
            <h1>Warning!!</h1>
            <p>You are using an outdated version of Internet Explorer, please upgrade <br/>to any of the following web browsers to access this website.</p>
            <div class="iew-container">
                <ul class="iew-download">
                    <li>
                        <a href="http://www.google.com/chrome/">
                            <img src="./files/assets/images/browser/chrome.png" alt="Chrome">
                            <div>Chrome</div>
                        </a>
                    </li>
                    <li>
                        <a href="https://www.mozilla.org/en-US/firefox/new/">
                            <img src="./files/assets/images/browser/firefox.png" alt="Firefox">
                            <div>Firefox</div>
                        </a>
                    </li>
                    <li>
                        <a href="http://www.opera.com">
                            <img src="./files/assets/images/browser/opera.png" alt="Opera">
                            <div>Opera</div>
                        </a>
                    </li>
                    <li>
                        <a href="https://www.apple.com/safari/">
                            <img src="./files/assets/images/browser/safari.png" alt="Safari">
                            <div>Safari</div>
                        </a>
                    </li>
                    <li>
                        <a href="http://windows.microsoft.com/en-us/internet-explorer/download-ie">
                            <img src="./files/assets/images/browser/ie.png" alt="">
                            <div>IE (9 & above)</div>
                        </a>
                    </li>
                </ul>
            </div>
            <p>Sorry for the inconvenience!</p>
        </div>
        <![endif]-->





        <script type="text/javascript" src="./files/bower_components/jquery/dist/jquery.min.js"></script>
        <script type="text/javascript" src="./files/bower_components/jquery-ui/jquery-ui.min.js"></script>
        <script type="text/javascript" src="./files/bower_components/popper.js/dist/umd/popper.min.js"></script>
        <script type="text/javascript" src="./files/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

        <script type="text/javascript" src="./files/bower_components/jquery-slimscroll/jquery.slimscroll.js"></script>

        <script type="text/javascript" src="./files/bower_components/modernizr/modernizr.js"></script>

        <script type="text/javascript" src="./files/bower_components/chart.js/dist/Chart.js"></script>

        <script src="./files/assets/pages/widget/amchart/amcharts.js"></script>
        <script src="./files/assets/pages/widget/amchart/serial.js"></script>
        <script src="./files/assets/pages/widget/amchart/light.js"></script>
        <script src="./files/assets/js/jquery.mCustomScrollbar.concat.min.js"></script>
        <script type="text/javascript" src="./files/assets/js/SmoothScroll.js"></script>
        <script src="./files/assets/js/pcoded.min.js"></script>

        <script src="./files/assets/js/vartical-layout.min.js"></script>
        <!--<script type="text/javascript" src="./files/assets/pages/dashboard/custom-dashboard.min.js"></script>-->
        <script type="text/javascript" src="./files/assets/js/script.js"></script>

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

        <script type="text/javascript">

                                                        var User_lang;
                                                        function btn_english() {
//                        alert('function btn-english');
                                                            User_lang = "ENGLISH";
                                                            $.myjQuery(User_lang);
                                                        }

                                                        function btn_gujarati() {
//                        alert('function btn_gujarati');
                                                            User_lang = "GUJARATI";
                                                            $.myjQuery(User_lang);
                                                        }
                                                        function btn_hindi() {
//                        alert('function btn_hindi');
                                                            User_lang = "HINDI";
                                                            $.myjQuery(User_lang);
                                                        }

                                                        $(document).ready(function () {

                                                            $.myjQuery = function (User_lang) {
//                                                    alert("jQuery " + User_lang);
                                                                if (User_lang == " ") {
//                                alert('Project Id Not Found! ');
                                                                } else {
                                                                    debugger;
                                                                    var send = {'Language_User': User_lang};
                                                                    $.ajax({
                                                                        type: 'POST',
                                                                        data: send,
                                                                        url: './PHP_Code/set_session_user_language.php',
                                                                        success: function (data) {
                                                                            debugger;
//                                                                alert('data ' + data);
                                                                            location.reload();
//                                        window.location.href = "/project_progress/project_detail";
                                                                        }, error: function (xhr, err) {
                                                                            alert('Error ' + err.message);
                                                                        }
                                                                    });
                                                                }
                                                            };
                                                        });
                                                        $(document).ready(function () {

                                                            $(document.body).on('change', '#select_taluka', function () {
                                                                debugger;
                                                                if ($("#select_taluka").val() == "Select")
                                                                {
//                                                                    $("#msg_select_milk_type").fadeIn(500);
//                                                                    $("#msg_select_milk_type").html("* Milk Type Not Selected").css({'color': 'red'});
//                                                                    $("#msg_select_milk_type").focusin();
                                                                } else
                                                                {
//                                                                    $("#msg_select_milk_type").fadeOut(1000);
                                                                    debugger;
                                                                    var taluka_id = $('#select_taluka').find('option:selected').attr('id');
//                                                                    var a = $("#select_taluka").val();

                                                                    var data = {};
                                                                    data.taluka_id = taluka_id;
                                                                    $.ajax({
                                                                        type: 'POST',
                                                                        data: data,
                                                                        url: './PHP_Code/select_school_list.php',
                                                                        success: function (data) {
//                        alert('data '+data);
                                                                            debugger;
                                                                            $('#school_list').html('');
                                                                            $('#school_list').html(data);
                                                                            $("#school_list").val('Select');
                                                                        }, error: function (xhr, err) {
                                                                            alert('Error ' + err.message);
                                                                        }
                                                                    });
                                                                }
                                                            });
                                                            $(document.body).on('click', '.view_school_tank_status', function (e) {

//                                                                            alert('id is ' + $(this).attr('id'));
                                                                var flow_meter_id = $(this).attr('id');
                                                                if (flow_meter_id == " ") {
                                                                    alert('User Id Not Found! ');
                                                                } else {
                                                                    debugger;
                                                                    var data = {};
                                                                    var data = {'flow_meter_id': flow_meter_id};
// //                                                        data.user_id = user_id;
                                                                    $.ajax({
                                                                        type: 'POST',
                                                                        data: data,
                                                                        url: './PHP_Code/select_water_tank_detail.php',
                                                                        success: function (data) {
                                                                            debugger;
//                                                                                        alert('data '+data);
                                                                            window.location.href = "./view_canal_detail.php";
                                                                        }, error: function (xhr, err) {
                                                                            alert('Error ' + err.message);
                                                                        }
                                                                    });
                                                                }

                                                            });
                                                            $('#btn-logout').click(function () {
//                alert('logout');
                                                                var send = {'logout': 'logout'};
                                                                $.ajax({
                                                                    url: './PHP_Code/session_destroy.php',
                                                                    type: 'POST',
                                                                    data: send,
                                                                    success: function (data)
                                                                    {
                                                                        debugger;
//                        alert('data ' + data);
                                                                        window.location.href = "./login.php";
                                                                    },
                                                                    error: function (err) {
                                                                        alert('error ' + err);
                                                                    }
                                                                });
                                                            });
                                                        });
        </script>


    </body></html>