<?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>Dam Dashboard </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">

        <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">

        <link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.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;
            }

            .stat-card:hover {
                transform: translateY(-5px);
                box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            }

            .dashboard {
                padding: 20px;
                max-width: 1400px;
                /*margin: 0 auto;*/
            }




            :root {
                --primary-blue: #3498db;
                --primary-green: #2ecc71;
                --primary-pink: #e74c3c;
                --primary-purple: #9b59b6;
                --primary-purple1: #cd84d5;
                --dark-blue: #2980b9;
                --dark-green: #27ae60;
                --dark-pink: #c0392b;
                --light-gray: #ecf0f1;
                --dark-gray: #7f8c8d;
                --white: #ffffff;
                --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
                --transition: all 0.3s ease;
            }

            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
                font-family: 'Poppins', sans-serif;
            }

            /*        body {
                        background-color: #f5f7fa;
                        color: #333;
                        line-height: 1.6;
                    }*/

            /*            .dashboard {
                            padding: 20px;
                            max-width: 1400px;
                            margin: 0 auto;
                        }*/

            .header {
                text-align: center;
                margin-bottom: 30px;
            }

            .header h1 {
                color: var(--primary-blue);
                font-size: 2.5rem;
                margin-bottom: 10px;
            }

            .header p {
                color: var(--dark-gray);
                font-size: 1.1rem;
            }

            .stats-container {
                display: grid;
                grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
                gap: 20px;
                margin-bottom: 30px;
            }

            /*            .stat-card {
                            background: var(--white);
                            border-radius: 10px;
                            padding: 20px;
                            box-shadow: var(--shadow);
                            transition: var(--transition);
                            position: relative;
                            overflow: hidden;
                            border-top: 4px solid;
                        }*/

            .stat-card:hover {
                transform: translateY(-5px);
                box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            }

            .stat-card.blue {
                border-color: var(--primary-blue);
            }

            .stat-card.green {
                border-color: var(--primary-green);
            }

            .stat-card.pink {
                border-color: var(--primary-pink);
            }

            .stat-card.purple {
                border-color: var(--primary-purple);
            }

            .stat-card .stat-content {
                display: flex;
                justify-content: space-between;
                align-items: center;
            }

            .stat-card .stat-value {
                font-size: 2.5rem;
                font-weight: 600;
                margin: 10px 0;
            }

            .stat-card.blue .stat-value {
                color: var(--primary-blue);
            }

            .stat-card.green .stat-value {
                color: var(--primary-green);
            }

            .stat-card.pink .stat-value {
                color: var(--primary-pink);
            }

            .stat-card .stat-label {
                color: var(--dark-gray);
                font-size: 1rem;
            }

            .stat-card .stat-icon {
                font-size: 3rem;
                opacity: 0.2;
                position: absolute;
                right: 20px;
                top: 20px;
            }

            .section-title {
                display: flex;
                align-items: center;
                justify-content: space-between;
                background: linear-gradient(135deg, var(--primary-purple1), var(--primary-blue));
                color: white;
                padding: 15px 20px;
                border-radius: 10px 10px 0 0;
                margin-bottom: 0;
            }

            .section-title h2 {
                font-size: 1.3rem;
                font-weight: 600;
                margin: 0;
            }

            .section-title img {
                height: 30px;
                width: 30px;
                border-radius: 50%;
            }

            .section-title2 {
                display: flex;
                align-items: center;
                justify-content: space-between;
                background: linear-gradient(135deg, var(--primary-pink), var(--primary-purple));
                color: white;
                padding: 15px 20px;
                border-radius: 10px 10px 0 0;
                margin-bottom: 0;
            }

            .section-title2 h2 {
                font-size: 1.3rem;
                font-weight: 600;
                margin: 0;
            }

            .section-title2 img {
                height: 30px;
                width: 30px;
                border-radius: 50%;
            }

            .data-table {
                background: var(--white);
                border-radius: 0 0 10px 10px;
                box-shadow: var(--shadow);
                overflow: hidden;
                margin-bottom: 30px;
            }

            table {
                width: 100%;
                border-collapse: collapse;
            }

            th {
                background-color: var(--light-gray);
                padding: 15px;
                text-align: left;
                font-weight: 600;
                color: #333;
            }

            td {
                padding: 15px;
                border-bottom: 1px solid var(--light-gray);
            }

            tr:last-child td {
                border-bottom: none;
            }

            tr:hover {
                background-color: rgba(52, 152, 219, 0.05);
            }

            .meter-info {
                display: flex;
                flex-direction: column;
            }

            .meter-name {
                font-weight: 600;
                color: #333;
            }

            .meter-address {
                color: var(--dark-gray);
                font-size: 0.9rem;
            }

            .status {
                display: inline-block;
                padding: 5px 10px;
                border-radius: 20px;
                font-size: 0.8rem;
                font-weight: 500;
            }

            .status.online {
                background-color: rgba(46, 204, 113, 0.2);
                color: var(--dark-green);
            }

            .status.offline {
                background-color: rgba(231, 76, 60, 0.2);
                color: var(--dark-pink);
            }

            .water-level {
                font-weight: 600;
            }

            /* Map Styles */
            .map-container {
                margin-bottom: 30px;
            }

            #flowMeterMap {
                height: 55vh;
                width: 100%;
                border-radius: 10px;
                box-shadow: var(--shadow);
                margin-top: 10px;
            }

            /*            #flowMeterMap {
                            height: 100vh;
                            width: 100%;
                        }*/

            .map-title {
                display: flex;
                align-items: center;
                justify-content: space-between;
                background: linear-gradient(135deg, var(--primary-green), var(--primary-blue));
                color: white;
                padding: 15px 20px;
                border-radius: 10px 10px 0 0;
            }

            .map-title h2 {
                font-size: 1.3rem;
                font-weight: 600;
                margin: 0;
            }

            .map-title img {
                height: 30px;
                width: 30px;
                border-radius: 50%;
            }

            /* Custom Marker Styles */
            .custom-marker {
                background-color: var(--primary-blue);
                width: 24px;
                height: 24px;
                display: block;
                left: -12px;
                top: -12px;
                position: relative;
                border-radius: 24px 24px 0;
                transform: rotate(45deg);
                border: 1px solid #FFFFFF;
            }

            .custom-marker.online {
                background-color: var(--primary-green);
            }

            .custom-marker.offline {
                background-color: var(--primary-pink);
            }

            .custom-marker::after {
                content: '';
                width: 10px;
                height: 10px;
                margin: 6px 0 0 6px;
                background-color: #FFFFFF;
                position: absolute;
                border-radius: 10px;
            }

            @media (max-width: 768px) {
                .stats-container {
                    grid-template-columns: 1fr;
                }

                th, td {
                    padding: 10px;
                    font-size: 0.9rem;
                }

                /*                #flowMeterMap {
                                    height: 300px;
                                }*/
            }


        </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="dam_home.php">
                                <img class="img-fluid" src="./files/assets/img/aquarius.gif" height="50px" width="50px" alt="Theme-Logo"> Dam Dashboard
                            </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("./files/assets/img/kkr1.jpeg");background-size: contain;'>
                    <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="./dam_home.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="dam_report.php">-->
                                                    <!--            <span class="pcoded-mtext">Dam 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 stat-card">
                                                    <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 Dam </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>                                                

                                                <div class="col-xl-12 col-md-12 stat-card">
                                                    <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 section-title" style="height: 50px;">
                                                                <div>
                                                                    <h5 class="text-white text-uppercase" style="font-size: 18px;"><b>Dam Detail</b></h5>
                                                                </div>
                                                                <div>
                                                                    <img src="files/assets/img/aquarius.gif" width="30" style="border-radius: 25%;">
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

                                                <?php
                                                $created_date_new = "";
                                                $level_water = "";
                                                ?>


                                                <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>
                                                                                    Dam Name
                                                                                </th>
                                                                                <th>Water Level</th>       
                                                                                <th>Discharge</th>       
                                                                                <th>Last Update</th>
                                                                                <?php
                                                                            }

                                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                                ?>
                                                                                <th>નં.</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.meter_name,tfm.address FROM `tbl_flow_meter_data` as tfmd LEFT join tbl_flow_meter as tfm on tfm.id=tfmd.flow_meter_id WHERE tfmd.flow_meter_id=' . $_SESSION['user_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';
//                                                                                $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.pipe_diameter,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 '$query1 ' . $query1;
                                                                                mysqli_set_charset($con, 'utf8');
                                                                                $result1 = mysqli_query($con, $query1);
                                                                                if (mysqli_num_rows($result1) > 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 '<br>water_level ' . $row1["water_level"].' 0.20';
                                                                                        if ($row1["water_level"] >= 48.768) {   //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>

                                                                                                <?php
                                                                                                $water_level = $row1["water_level"];

                                                                                                $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"];

                                                                                        $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";
                                                                                                
                                                                                                
                                                                                                ?>
                                                                                                <td>
                                                                                                    <div class="d-inline-block align-middle">
                                                                                                        <h6><?php echo number_format($feet, 3); ?></h6>
                                                                                                        <p class="text-muted m-b-0"><?php echo $water_level; ?></p>
                                                                                                        
                                                                                                        <!--<h6><?php echo $water_level . ' Meter'; ?></h6>-->
                                                                                                        <!--<p class="text-muted m-b-0"><?php echo number_format($feet, 3) . ' Foot'; ?></p>-->
                                                                                                    </div>
                                                                                                </td>
                                                                                                <td><?php echo $cusec.' Cusec/Second'; ?></td>
                                                                                                <td><?php echo $row1["created_date_new"]; ?></td>
                                                                                            </tr>
                                                                                            <?php
                                                                                        } else {
                                                                                            ?>
                                                                                            <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>

                                                                                                <?php
                                                                                                $water_level = $row1["water_level"];

                                                                                                $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"];
                                                                                                ?>
                                                                                                <td>
                                                                                                    <div class="d-inline-block align-middle">
                                                                                                        <h6><?php echo number_format($feet, 3) . ' Foot'; ?></h6>
                                                                                                        <p class="text-muted m-b-0"><?php echo $water_level . ' Meter'; ?></p>
                                                                                                    </div>
                                                                                                </td>
                                                                                                <td><?php echo '0 Cusec/Second'; ?></td>
                                                                                                <td><?php echo $row1["created_date_new"]; ?></td>
                                                                                            </tr>
                                                                                            <?php
                                                                                        }
                                                                                        $created_date_new = $row1["created_date_new"];
                                                                                        $level_water = $water_level;
                                                                                    }
                                                                                }
                                                                                $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="dashboard col-xl-4 col-md-4">
                                                    <!-- Map Section -->
                                                    <div class="map-container">
                                                        <div class="map-title stat-card">
                                                            <h2>Dam Location</h2>
                                                            <img src="files/assets/img/locations.gif">
                                                        </div>
                                                        <div id="flowMeterMap"></div>
                                                    </div>
                                                </div>

                                                <?php
                                                $level = 48.25;
                                                $date = "27-5-2025";
                                                ?>

                                                <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
                                                <script>
                                                        // Initialize the map
//                                                        const map = L.map('flowMeterMap').setView([21.268282988819895, 73.36458836489439], 5); // Centered on India
                                                        const map = L.map('flowMeterMap', {
                                                            minZoom: 3,
                                                            maxZoom: 18
                                                        }).setView([21.268282988819895, 73.36458836489439], 4);


                                                        // Add OpenStreetMap tiles
                                                        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
                                                            attribution: '&copy; Dam Location'
                                                        }).addTo(map);

                                                        // Sample flow meter locations (latitude, longitude)
                                                        const flowMeters = [
                                                            {
                                                                name: "Kakarapar Dam",
                                                                location: [21.268282988819895, 73.36458836489439], // Mumbai
                                                                status: "Online",
                                                                waterLevel: "<?php echo $level_water . ' M'; ?>",
                                                                lastUpdate: "<?php echo $created_date_new; ?>"
                                                            }
//                                                            {
//                                                                name: "",
//                                                                location: [21.268282988819895, 73.36458836489439], // Delhi
//                                                                status: "",
//                                                                waterLevel: "0.95 m",
//                                                                lastUpdate: "05-04-2025 14:25:30"
//                                                            }
//                                                            {
//                                                                name: "Kadod",
//                                                                location: [21.190385, 73.186219], // Kolkata
//                                                                status: "offline",
//                                                                waterLevel: "0.15 m",
//                                                                lastUpdate: "04-04-2025 18:45:12"
//                                                            }
//                                                            {
//                                                                name: "Bhatpur Vyara",
//                                                                location: [21.108687, 73.377718], // Hyderabad
//                                                                status: "online",
//                                                                waterLevel: "0.82 m",
//                                                                lastUpdate: "05-04-2025 14:15:22"
//                                                            }
//                                                            {
//                                                                name: "South Distribution Meter",
//                                                                location: [13.0827, 80.2707], // Chennai
//                                                                status: "offline",
//                                                                waterLevel: "0.12 m",
//                                                                lastUpdate: "04-04-2025 17:30:05"
//                                                            }
                                                        ];

                                                        // Custom icon creation function
                                                        function createCustomIcon(status) {
                                                            return L.divIcon({
                                                                className: 'custom-marker-icon',
                                                                html: `<div class="custom-marker ${status}"></div>`,
                                                                iconSize: [24, 24],
                                                                iconAnchor: [12, 12]
                                                            });
                                                        }

                                                        // Add markers for each flow meter
                                                        flowMeters.forEach(meter => {
                                                            const marker = L.marker(meter.location, {
                                                                icon: createCustomIcon(meter.status)
                                                            }).addTo(map);

                                                            // Add popup with meter information
                                                            marker.bindPopup(`
                                                            <b>${meter.name}</b><br>
                                                            Status: <span class="${meter.status}">${meter.status.toUpperCase()}</span><br>
                                                            Water Level: ${meter.waterLevel}<br>
                                                            Last Update: ${meter.lastUpdate}
                                                        `);

                                                            // Open popup for the first marker
                                                            if (meter.name === "Larsen & Toubro Limited") {
                                                                marker.openPopup();
                                                            }
                                                        });

                                                        // Fit map to markers bounds
                                                        const group = new L.featureGroup(flowMeters.map(meter => L.marker(meter.location)));
                                                        map.fitBounds(group.getBounds().pad(0.2));
//                                                        map.setZoom(Math.max(map.getZoom(), 4)); // don't zoom in more than level 4
                                                        if (map.getZoom() > 4) {
                                                            map.setZoom(12);
                                                        }
                                                </script>

                                            </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 user_id = $(this).attr('id');
                                                                if (user_id == " ") {
                                                                    alert('User Id Not Found! ');
                                                                } else {
                                                                    debugger;
                                                                    var data = {};
                                                                    var data = {'user_id': user_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_dam_detail.php";
//                                                                            window.location.href = "./view_flow_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>