<?php header('Access-Control-Allow-Origin: *');
?>

<?php
require_once './Mobile_Api/connection.php';
?>

<?php
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>Smart Freezer </title>


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

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

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

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

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

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

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

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

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

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

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

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

        <script>
            setInterval(function () {
                window.location.reload();
            }, 10000);

//            $(document).ready(function () {
//                feather.replace()
//            })

        </script>

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

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


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

        <div id="pcoded" class="pcoded iscollapsed" nav-type="st6" theme-layout="vertical" vertical-placement="left" vertical-layout="wide" pcoded-device-type="desktop" vertical-nav-type="expanded" vertical-effect="shrink" vnavigation-view="view1" fream-type="theme1" sidebar-img="false" sidebar-img-type="img1" layout-type="light">
            <div class="pcoded-overlay-box"></div>
            <div class="pcoded-container navbar-wrapper">
                <nav class="navbar header-navbar pcoded-header iscollapsed" header-theme="theme1" pcoded-header-position="fixed">
                    <div class="navbar-wrapper">
                        <div class="navbar-logo" logo-theme="theme1">
                            <a class="mobile-menu" id="mobile-collapse" href="#!">
                                <i class="fa fa-sliders"></i>
                            </a>
                            <a href="index.php">
                                <img class="img-fluid" src="./files/assets/img/freezer.png" height="50px" width="50px" alt="Theme-Logo"> Smart Freezer
                            </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_freez_status` 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 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';
                                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 > 3) {
                                            $notification = $notification + 1;
                                        }


                                        if ($row1['freez_temperature'] > -11) {
                                            $notification = $notification + 1;
                                        } else if ($row1['freez_temperature'] < -19) {
                                            $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_freez_status` 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 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';
                                                    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 > 3) {
                                                                $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/freezerlogo.png" alt="Generic placeholder image">
                                                                        <div class="media-body">
                                                                            <h5 class="notification-user"><?php echo $row1["school_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["school_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["school_name"]; ?> નું ફ્રિઝર છેલ્લા <?php echo $Days; ?> દિવસથી બંધ છે.
                                                                                </p>
                                                                                <?php
                                                                            }
                                                                            ?>

                                                                                                                                                                                <!--<span class="notification-time">30 minutes ago</span>-->
                                                                        </div>
                                                                    </div>
                                                                </li>

                                                                <?php
                                                            } else {
                                                                $online = $online + 1;
                                                            }


                                                            if ($row1['freez_temperature'] > -11) {
                                                                ?>
                                                                
                                                                <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/freezerlogo.png" alt="Generic placeholder image">
                                                                        <div class="media-body">
                                                                            <h5 class="notification-user"><?php echo $row1["school_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["school_name"]; ?> Freezer temperature very high. 
                                                                                </p>
                                                                                <?php
                                                                            }

                                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                                ?>
                                                                                <p class="notification-msg view_school_tank_status" id="<?php echo $row1["user_id"]; ?>"><?php echo $row1["school_name"]; ?>ના ફ્રિઝરનું તાપમાન વધુ પ્રમાણમાં <?php echo $row1["freez_temperature"]; ?> છે.
                                                                                </p>
                                                                                <?php
                                                                            }
                                                                            ?>

                                                                                                                                                                                <!--<span class="notification-time">30 minutes ago</span>-->
                                                                        </div>
                                                                    </div>
                                                                </li>

                                                                <?php
                                                                
                                                            } else if ($row1['freez_temperature'] < -19) {
                                                                ?>
                                                                <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/freezerlogo.png" alt="Generic placeholder image">
                                                                        <div class="media-body">
                                                                            <h5 class="notification-user"><?php echo $row1["school_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["school_name"]; ?> Freezer temperature very low. 
                                                                                </p>
                                                                                <?php
                                                                            }

                                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                                ?>
                                                                                <p class="notification-msg view_school_tank_status" id="<?php echo $row1["user_id"]; ?>"><?php echo $row1["school_name"]; ?>ના ફ્રિઝરનું તાપમાન ઓછા પ્રમાણમાં <?php echo $row1["freez_temperature"]; ?> છે.
                                                                                </p>
                                                                                <?php
                                                                            }
                                                                            ?>

                                                                                                                                                                                <!--<span class="notification-time">30 minutes ago</span>-->
                                                                        </div>
                                                                    </div>
                                                                </li>
                                                                <?php
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            ?>
                                        </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/avatar-4.jpg" class="img-radius" alt="User-Profile-Image">
                                            <span>Admin</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="#!">
                                                                                                        <i class="fa fa-gear"></i> Settings
                                                                                                    </a>
                                                                                                </li>
                                                                                                <li>
                                                                                                    <a href="./default/user-profile.html">
                                                                                                        <i class="fa fa-user"></i> Profile
                                                                                                    </a>
                                                                                                </li>-->
                                                <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="#!">
                                                                                                        <i class="fa fa-gear"></i> સેટિંગ્સ
                                                                                                    </a>
                                                                                                </li>
                                                                                                <li>
                                                                                                    <a href="./default/user-profile.html">
                                                                                                        <i class="fa fa-user"></i> પ્રોફાઇલ
                                                                                                    </a>
                                                                                                </li>-->
                                                <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;">
                    <div class="pcoded-wrapper">
                        <nav class="pcoded-navbar" navbar-theme="theme1" active-item-theme="theme1" sub-item-theme="theme2" active-item-style="style0" pcoded-navbar-position="fixed">
                            <div class="pcoded-inner-navbar main-menu mCustomScrollbar _mCS_1" id="" style="height: calc(100% - 80px);"><div id="mCSB_1" class="mCustomScrollBox mCS-light mCSB_vertical_horizontal mCSB_inside" style="max-height: none;" tabindex="0"><div id="mCSB_1_container_wrapper" class="mCSB_container_wrapper mCS_x_hidden mCS_no_scrollbar_x"><div id="mCSB_1_container" class="mCSB_container" style="position: relative; top: -10px; left: 0px; width: 100%;" dir="ltr">
                                            <div class="pcoded-navigatio-lavel" menu-title-theme="theme5">Navigation</div>
                                            <ul class="pcoded-item pcoded-left-item" item-border="true" item-border-style="none" subitem-border="true">                                                
                                                <li class="">
                                                    <a href="./index.php">
                                                        <span class="pcoded-micon"><i class="fa fa-home"></i></span>


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

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

                                                    </a>
                                                </li>

                                            </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">

                                                <?php
                                                $offline = 0;
                                                $online = 0;
                                                $last_ph_level = 0;
                                                $last_tds_level = 0;
                                                $last_date = 0;

                                                $id = $_SESSION['user_id'];

                                                $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.user_id=' . $id . ' order by twts.id DESC LIMIT 0,1';
                                                mysqli_set_charset($con, 'utf8');
                                                $result1 = mysqli_query($con, $query1);
                                                if (mysqli_num_rows($result1) > 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;

                                                        $last_ph_level = $row1["freez_temperature"];
                                                        $last_tds_level = $row1["freez_humidity"];
                                                        $last_date = $row1["created_date"];

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

                                                        if ($Days > 3) {
                                                            $offline = $offline + 1;
                                                        } else {
                                                            $online = $online + 1;
                                                        }
                                                    }
                                                }
                                                ?>

                                                <?php
                                                if ($online == 1) {
                                                    ?>

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


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

                                                                        if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                            ?>
                                                                            <h4 class="text-white m-b-0">ઓનલાઈન</h4>
                                                                            <?php
                                                                        }
                                                                        ?>

                                                                    </div>
                                                                    <div class="col-4 text-right"><div class="chartjs-size-monitor"><div class="chartjs-size-monitor-expand"><div class=""></div></div><div class="chartjs-size-monitor-shrink"><div class=""></div></div></div>
                                                                        <canvas id="update-chart-3" height="50" width="65" style="display: block; width: 65px; height: 50px;" class="chartjs-render-monitor"></canvas>
                                                                    </div>

                                                                </div>
                                                            </div>
                                                            <div class="card-footer">
                                                                <p class="text-white m-b-0"><i class="fa fa-clock-o text-white f-14 m-r-10"></i>update
                                                                    : <?php echo $last_date; ?></p>
                                                            </div>
                                                        </div>
                                                    </div>
                                                <?php } ?>

                                                <?php
                                                if ($offline == 1) {
                                                    ?>

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

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

                                                                        if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                            ?>
                                                                            <h4 class="text-white m-b-0">ઑફલાઇન</h4>
                                                                            <?php
                                                                        }
                                                                        ?>

                                                                    </div>
                                                                    <div class="col-4 text-right"><div class="chartjs-size-monitor"><div class="chartjs-size-monitor-expand"><div class=""></div></div><div class="chartjs-size-monitor-shrink"><div class=""></div></div></div>
                                                                        <canvas id="update-chart-4" height="50" width="65" style="display: block; width: 65px; height: 50px;" class="chartjs-render-monitor"></canvas>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="card-footer">
                                                                <p class="text-white m-b-0"><i class="fa fa-clock-o text-white f-14 m-r-10"></i>update
                                                                    : <?php echo $last_date; ?></p>
                                                            </div>

                                                        </div>
                                                    </div>

                                                <?php } ?>


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


                                                                <div class="col-8">
                                                                    <h4 class="text-white"><?php echo $last_ph_level; ?></h4>


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

                                                                    if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                        ?>
                                                                        <h6 class="text-white m-b-0">ફ્રિઝર તાપમાન</h6>
                                                                        <?php
                                                                    }
                                                                    ?>

                                                                </div>
                                                                <div class="col-4 text-right"><div class="chartjs-size-monitor"><div class="chartjs-size-monitor-expand"><div class=""></div></div><div class="chartjs-size-monitor-shrink"><div class=""></div></div></div>
                                                                    <img src="./files/assets/img/thermometer.png" class="img-radius" alt="User-Profile-Image">

                                                                    <canvas id="update-chart-1" height="50" style="display: block; width: 65px; height: 50px;" width="65" class="chartjs-render-monitor"></canvas>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="card-footer">
                                                            <p class="text-white m-b-0"><i class="fa fa-clock-o text-white f-14 m-r-10"></i>update
                                                                : <?php echo $last_date; ?></p>
                                                        </div>
                                                        <!--                                                        <div class="card-footer">
                                                                                                                    <p class="text-white m-b-0"><i class="feather icon-clock text-white f-14 m-r-10"></i>update
                                                                                                                        : 2:15 am</p>
                                                                                                                </div>-->
                                                    </div>
                                                </div>
                                                <div class="col-xl-3 col-md-6">
                                                    <div class="card bg-c-lite-green update-card">
                                                        <div class="card-block">
                                                            <div class="row align-items-end">


                                                                <div class="col-8">
                                                                    <h4 class="text-white"><?php echo $last_tds_level; ?></h4>


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

                                                                    if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                        ?>
                                                                        <h6 class="text-white m-b-0">ફ્રિઝર ભેજ</h6>
                                                                        <?php
                                                                    }
                                                                    ?>

                                                                </div>
                                                                <div class="col-4 text-right"><div class="chartjs-size-monitor"><div class="chartjs-size-monitor-expand"><div class=""></div></div><div class="chartjs-size-monitor-shrink"><div class=""></div></div></div>
                                                                    <img src="./files/assets/img/humidity.png" class="img-radius" alt="User-Profile-Image">
                                                                    <canvas id="update-chart-2" height="50" width="65" style="display: block; width: 65px; height: 50px;" class="chartjs-render-monitor"></canvas>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="card-footer">
                                                            <p class="text-white m-b-0"><i class="fa fa-clock-o text-white f-14 m-r-10"></i>update
                                                                : <?php echo $last_date; ?></p>
                                                        </div>
                                                    </div>
                                                </div>



                                                <div class="col-xl-12 col-md-12">
                                                    <div class="card table-card">
                                                        <div class="card-header">

                                                            <?php
                                                            if ($_SESSION['User_language'] == 'ENGLISH') {
                                                                ?>
                                                                <h5>School Detail</h5>
                                                                <?php
                                                            }

                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                ?>
                                                                <h5>શાળાની વિગત</h5>
                                                                <?php
                                                            }
                                                            ?>
                                                        </div>


                                                        <div class="card-block">
                                                            <div class="table-responsive">
                                                                <table class="table table-hover  table-borderless">
                                                                    <thead>
                                                                        <tr>
                                                                            <?php
                                                                            if ($_SESSION['User_language'] == 'ENGLISH') {
                                                                                ?>
                                                                                <th>
                                                                                    Teacher Name
                                                                                </th>
                                                                                <th>
                                                                                    School Name
                                                                                </th>
                                                                                <th>Temperature</th>
                                                                                <th>Humidity</th>
                                                                                <th>Last Update</th>
                                                                                <th>Status</th>
                                                                                <?php
                                                                            }

                                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                                ?>
                                                                                <th>
                                                                                    શિક્ષકની વિગત
                                                                                </th>
                                                                                <th>
                                                                                    શાળાનું નામ
                                                                                </th>
                                                                                <th>ફ્રિઝર તાપમાન</th>
                                                                                <th>ફ્રિઝર ભેજ</th>
                                                                                <th>છેલ્લું અપડેટ</th>
                                                                                <th>સ્થિતિ</th>
                                                                                <?php
                                                                            }
                                                                            ?>

                                                                        </tr>
                                                                    </thead>
                                                                    <tbody>

                                                                        <?php
                                                                        $id = $id = $_SESSION['user_id'];

                                                                        $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.user_id=' . $id . ' order by twts.id DESC LIMIT 0,1';
                                                                        mysqli_set_charset($con, 'utf8');
                                                                        $result1 = mysqli_query($con, $query1);
                                                                        if (mysqli_num_rows($result1) > 0) {
                                                                            while ($row1 = mysqli_fetch_assoc($result1)) {
                                                                                ?>
                                                                                <tr id="<?php echo $row1["user_id"]; ?>" class="view_school_tank_status">

                                                                                    <td>

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

                                                                                    <td>

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

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

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

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


                                                                                            <?php
                                                                                            if ($_SESSION['User_language'] == 'ENGLISH') {
                                                                                                ?>
                                                                                                <label class="btn-danger btn-sm">Offline</label>
                                                                                                <?php
                                                                                            }

                                                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                                                ?>
                                                                                                <label class="btn-danger btn-sm">ઑફલાઇન</label>
                                                                                                <?php
                                                                                            }
                                                                                            ?>

                                                                                            <?php
                                                                                        } else {
                                                                                            ?>


                                                                                            <?php
                                                                                            if ($_SESSION['User_language'] == 'ENGLISH') {
                                                                                                ?>
                                                                                                <label class=" btn-success btn-sm">Online</label>
                                                                                                <?php
                                                                                            }

                                                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                                                ?>
                                                                                                <label class=" btn-success btn-sm">ઓનલાઈન</label>
                                                                                                <?php
                                                                                            }
                                                                                            ?>
                                                                                            <?php
                                                                                        }
                                                                                        ?>



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

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


                                                <?php
                                                $id = $_SESSION['user_id'];
                                                $chartQuery = '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.user_id=' . $id . ' order by twts.id Asc limit 0,30';
                                                $chartQueryRecords = mysqli_query($con, $chartQuery);

                                                $data1 = "";
                                                $data_30 = "";
                                                $k = 1;
                                                $rowcount = mysqli_num_rows($chartQueryRecords);
                                                while ($row = mysqli_fetch_assoc($chartQueryRecords)) {

                                                    if ($rowcount >= 15) {

                                                        $tt = $rowcount - 15;
//                                                    echo 'tt '. $tt;

                                                        if ($k >= $tt) {
                                                            $data1 .= "['" . $row['days_date'] . "'," . $row['freez_temperature'] . "," . $row['freez_humidity'] . "],";
                                                        }
                                                        $data_30 .= "['" . $row['days_date'] . "'," . $row['freez_temperature'] . "," . $row['freez_humidity'] . "],";

                                                        $k = $k + 1;
                                                    } else {
                                                        $data1 .= "['" . $row['days_date'] . "'," . $row['freez_temperature'] . "," . $row['freez_humidity'] . "],";

                                                        $data_30 .= "['" . $row['days_date'] . "'," . $row['freez_temperature'] . "," . $row['freez_humidity'] . "],";
                                                    }
                                                }

//                                                print_r($data1);
                                                ?>

                                                <?php
                                                if ($_SESSION['User_language'] == 'ENGLISH') {
                                                    $title = 'Freezer Temperature and Humidity Status';
                                                    $date = 'Date';
                                                    $ph = 'Temperature';
                                                    $tds = 'Humidity';
                                                    $level = 'Level';
                                                }

                                                if ($_SESSION['User_language'] == 'GUJARATI') {
                                                    $title = 'ફ્રિઝર તાપમાન અને ભેજ ની સ્થિતિ';
                                                    $date = 'તારીખ';
                                                    $ph = 'ફ્રિઝર તાપમાન';
                                                    $tds = 'ફ્રિઝર ભેજ';
                                                    $level = 'પ્રમાણ ';
                                                }
                                                ?>

                                                <style>
                                                    /*                                                    body {
                                                                                                            font-family: Arial;
                                                                                                        }*/

                                                    /* Style the tab */
                                                    .tab {
                                                        overflow: hidden;
                                                        border: 1px solid #ccc;
                                                        background-color: #f1f1f1;
                                                    }

                                                    /* Style the buttons inside the tab */
                                                    .tab button {
                                                        background-color: inherit;
                                                        float: right;
                                                        border: none;
                                                        outline: none;
                                                        cursor: pointer;
                                                        padding: 7px 8px;
                                                        transition: 0.3s;
                                                        font-size: 17px;
                                                    }

                                                    /* Change background color of buttons on hover */
                                                    .tab button:hover {
                                                        background-color: #ddd;
                                                    }

                                                    /* Create an active/current tablink class */
                                                    .tab button.active {
                                                        background-color: #ccc;
                                                    }

                                                    /* Style the tab content */
                                                    .tabcontent {
                                                        display: none;
                                                        padding: 6px 12px;
                                                        border: 1px solid #ccc;
                                                        border-top: none;
                                                    }
                                                </style>
                                                <div class="col-xl-6 col-md-12">
                                                    <div class="card">
                                                        <div class="card-block">
                                                            <div id="sales-analytics" style="height: 410px; overflow: hidden; text-align: left;">
                                                                <div class="amcharts-main-div" style="position: relative;">

                                                                    <div class="tab">
                                                                        <h5 style="float: left;padding-top: 7px;padding-left: 10px"><?php echo $title; ?></h5>
                                                                        <button class="tablinks" onclick="openCity(event, 'London')">Last 15 Day</button>
                                                                        <button class="tablinks" onclick="openCity(event, 'Paris')">Last 30 Day</button>
                                                                        <!--<button class="tablinks" onclick="openCity(event, 'Tokyo')">Year</button>-->
                                                                    </div>

                                                                    <div id="London" class="tabcontent active" style="display: block">
                                                                        <div id="chart_div" style=" height: 350px;"></div>

                                                                        <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
                                                                        <script type="text/javascript">
                                                                            google.charts.load('current', {'packages': ['corechart']});
                                                                            google.charts.setOnLoadCallback(drawVisualization);

                                                                            function drawVisualization() {
                                                                                // Some raw data (not necessarily accurate)
                                                                                var data = google.visualization.arrayToDataTable([
                                                                                    ['<?php echo $date; ?>', '<?php echo $ph; ?>', '<?php echo $tds; ?>'],

<?php echo $data1; ?>
                                                                                ]);

                                                                                var options = {
                                                                                    title: '<?php echo $title; ?>',
                                                                                    vAxis: {title: '<?php echo $level; ?>'},
                                                                                    hAxis: {title: '<?php echo $date; ?>'},
                                                                                    seriesType: 'bars',
                                                                                    series: {2: {type: 'line'}}
                                                                                };

                                                                                var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
                                                                                chart.draw(data, options);
                                                                            }
                                                                        </script>
                                                                    </div>

                                                                    <div id="Paris" class="tabcontent active" style="display: block">
                                                                        <div id="chart_div_30" style=" height: 350px;"></div>

                                                                        <script type="text/javascript">
                                                                            google.charts.load('current', {'packages': ['corechart']});
                                                                            google.charts.setOnLoadCallback(drawVisualization);

                                                                            function drawVisualization() {
                                                                                // Some raw data (not necessarily accurate)
                                                                                var data = google.visualization.arrayToDataTable([
                                                                                    ['<?php echo $date; ?>', '<?php echo $ph; ?>', '<?php echo $tds; ?>'],

<?php echo $data_30; ?>
                                                                                ]);

                                                                                var options = {
                                                                                    title: '<?php echo $title; ?>',
                                                                                    vAxis: {title: '<?php echo $level; ?>'},
                                                                                    hAxis: {title: '<?php echo $date; ?>'},
                                                                                    seriesType: 'bars',
                                                                                    series: {2: {type: 'line'}}
                                                                                };

                                                                                var chart = new google.visualization.ComboChart(document.getElementById('chart_div_30'));
                                                                                chart.draw(data, options);
                                                                            }
                                                                        </script>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>

                                                <script>
                                                    function openCity(evt, cityName) {
                                                        var i, tabcontent, tablinks;
                                                        tabcontent = document.getElementsByClassName("tabcontent");
                                                        for (i = 0; i < tabcontent.length; i++) {
                                                            tabcontent[i].style.display = "none";
                                                        }
                                                        tablinks = document.getElementsByClassName("tablinks");
                                                        for (i = 0; i < tablinks.length; i++) {
                                                            tablinks[i].className = tablinks[i].className.replace(" active", "");
                                                        }
                                                        document.getElementById(cityName).style.display = "block";
                                                        evt.currentTarget.className += " active";
                                                    }
                                                </script>



                                                <div class="col-xl-6 col-md-12">
                                                    <div class="card">
                                                        <div class="card-block">
                                                            <div id="sales-analytics" style="height: 410px; overflow: hidden; text-align: left;">
                                                                <div class="amcharts-main-div" style="position: relative;">

                                                                    <div class="tab">
                                                                        <h5 style="float: left;padding-top: 7px;padding-left: 10px"><?php echo $title; ?></h5>
                                                                        <button class="tablinks1" onclick="openCity123(event, 'London1')">Last 15 Day</button>
                                                                        <button class="tablinks1" onclick="openCity123(event, 'Paris1')">Last 30 Day</button>
                                                                        <!--<button class="tablinks" onclick="openCity(event, 'Tokyo')">Year</button>-->
                                                                    </div>

                                                                    <div id="London1" class="tabcontent1 active" style="display: block">
                                                                        <div id="chart_div123" style=" height: 350px;"></div>

                                                                        <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
                                                                        <script type="text/javascript">
                                                                            google.charts.load('current', {
                                                                                'packages': ['corechart'],
                                                                                'mapsApiKey': ''   // her eyou can put you google map key
                                                                            });
                                                                            google.charts.setOnLoadCallback(drawRegionsMap);


                                                                            function drawRegionsMap() {
                                                                                var data = google.visualization.arrayToDataTable([
                                                                                    ['<?php echo $date; ?>', '<?php echo $ph; ?>', '<?php echo $tds; ?>'],
<?php echo $data1; ?>
                                                                                ]);

                                                                                var options = {

                                                                                };

                                                                                var options = {
                                                                                    title: '<?php echo $title; ?>',
                                                                                    vAxis: {title: '<?php echo $level; ?>'},
                                                                                    hAxis: {title: '<?php echo $date; ?>'},
                                                                                    curveType: 'function',
                                                                                    legend: {position: 'bottom'}
                                                                                };

                                                                                var chart = new google.visualization.LineChart(document.getElementById('chart_div123'));
                                                                                chart.draw(data, options);
                                                                            }
                                                                        </script>
                                                                    </div>

                                                                    <div id="Paris1" class="tabcontent1 active" style="display: block">
                                                                        <div id="chart_div123_30" style=" height: 350px;"></div>

                                                                        <script type="text/javascript">
                                                                            google.charts.load('current', {
                                                                                'packages': ['corechart'],
                                                                                'mapsApiKey': ''   // her eyou can put you google map key
                                                                            });
                                                                            google.charts.setOnLoadCallback(drawRegionsMap);


                                                                            function drawRegionsMap() {
                                                                                var data = google.visualization.arrayToDataTable([
                                                                                    ['<?php echo $date; ?>', '<?php echo $ph; ?>', '<?php echo $tds; ?>'],
<?php echo $data_30; ?>
                                                                                ]);

                                                                                var options = {

                                                                                };

                                                                                var options = {
                                                                                    title: '<?php echo $title; ?>',
                                                                                    vAxis: {title: '<?php echo $level; ?>'},
                                                                                    hAxis: {title: '<?php echo $date; ?>'},
                                                                                    curveType: 'function',
                                                                                    legend: {position: 'bottom'}
                                                                                };

                                                                                var chart = new google.visualization.LineChart(document.getElementById('chart_div123_30'));
                                                                                chart.draw(data, options);
                                                                            }
                                                                        </script>
                                                                    </div>

                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <script>
                                                    function openCity123(evt, cityName) {
                                                        var i, tabcontent, tablinks;
                                                        tabcontent = document.getElementsByClassName("tabcontent1");
                                                        for (i = 0; i < tabcontent.length; i++) {
                                                            tabcontent[i].style.display = "none";
                                                        }
                                                        tablinks = document.getElementsByClassName("tablinks1");
                                                        for (i = 0; i < tablinks.length; i++) {
                                                            tablinks[i].className = tablinks[i].className.replace(" active", "");
                                                        }
                                                        document.getElementById(cityName).style.display = "block";
                                                        evt.currentTarget.className += " active";
                                                    }
                                                </script>






                                                <div class="col-xl-12 col-md-12">
                                                    <div class="card table-card">
                                                        <div class="card-header">

                                                            <?php
                                                            if ($_SESSION['User_language'] == 'ENGLISH') {
                                                                ?>
                                                                <h5>School Detail</h5>
                                                                <?php
                                                            }

                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                ?>
                                                                <h5>શાળાની વિગત</h5>
                                                                <?php
                                                            }
                                                            ?>
                                                        </div>
                                                        <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>
                                                                                    School Name
                                                                                </th>
                                                                                <th>Temperature</th>
                                                                                <th>Humidity</th>
                                                                                <th>Date</th>
                                                                                <?php
                                                                            }

                                                                            if ($_SESSION['User_language'] == 'GUJARATI') {
                                                                                ?>
                                                                                <th>નં.</th>
                                                                                <th>
                                                                                    શાળાનું નામ
                                                                                </th>
                                                                                <th>ફ્રિઝર તાપમાન</th>
                                                                                <th>ફ્રિઝર ભેજ</th>
                                                                                <th>તારીખ</th>
                                                                                <?php
                                                                            }
                                                                            ?>

                                                                        </tr>
                                                                    </thead>
                                                                    <tbody>

                                                                        <?php
                                                                        $id = $id = $_SESSION['user_id'];

                                                                        $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.user_id=' . $id . ' order by twts.id DESC';
                                                                        mysqli_set_charset($con, 'utf8');
                                                                        $result1 = mysqli_query($con, $query1);
                                                                        $i = 1;
                                                                        if (mysqli_num_rows($result1) > 0) {
                                                                            while ($row1 = mysqli_fetch_assoc($result1)) {
                                                                                ?>
                                                                                <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["school_name"]; ?></h6>
                                                                                            <p class="text-muted m-b-0"><?php echo $row1["village_guj"]; ?></p>
                                                                                        </div>
                                                                                    </td>
                                                                                    <td><?php echo $row1["freez_temperature"]; ?></td>
                                                                                    <td><?php echo $row1["freez_humidity"]; ?></td>
                                                                                    <td><?php echo $row1["created_date"]; ?></td>

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

//                                                                                            echo round($datediff / (60 * 60 * 24));
                                                                                    $Days = round($datediff / (60 * 60 * 24));
                                                                                    ?>
                                                                                </tr>
                                                                                <?php
                                                                                $i = $i + 1;
                                                                            }
                                                                        }
                                                                        ?>

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

                                            </div>
                                        </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('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_freezer_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 = "./index.php";

                                                                },
                                                                error: function (err) {
                                                                    alert('error ' + err);
                                                                }
                                                            });
                                                        });

                                                    });
        </script>

        <!--<div id="fatkun-drop-panel">-->
<!--            <a id="fatkun-drop-panel-close-btn">×</a>
            <div id="fatkun-drop-panel-inner">
                <div class="fatkun-content">
                    <svg class="fatkun-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5892"><path d="M494.933333 782.933333c2.133333 2.133333 4.266667 4.266667 8.533334 6.4h8.533333c6.4 0 10.666667-2.133333 14.933333-6.4l2.133334-2.133333 275.2-275.2c8.533333-8.533333 8.533333-21.333333 0-29.866667-8.533333-8.533333-21.333333-8.533333-29.866667 0L533.333333 716.8V128c0-12.8-8.533333-21.333333-21.333333-21.333333s-21.333333 8.533333-21.333333 21.333333v588.8L249.6 475.733333c-8.533333-8.533333-21.333333-8.533333-29.866667 0-8.533333 8.533333-8.533333 21.333333 0 29.866667l275.2 277.333333zM853.333333 874.666667H172.8c-12.8 0-21.333333 8.533333-21.333333 21.333333s8.533333 21.333333 21.333333 21.333333H853.333333c12.8 0 21.333333-8.533333 21.333334-21.333333s-10.666667-21.333333-21.333334-21.333333z" p-id="5893"></path></svg>
                    <div class="fatkun-title">Drag and Drop</div>
                    <div class="fatkun-desc">The image will be downloaded</div>
                </div>
            </div>-->
        <!--</div>-->
    </body></html>