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


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

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

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

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

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

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

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

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

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

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

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

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

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

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



        </script>

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

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


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

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

                        <?php
                        $notification = 0;

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

                                $id = $row["id"];

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

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

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

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


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

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


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

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

                                            </li>

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

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

                                                    $id = $row["id"];

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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


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

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

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


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

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

                                                    </a>
                                                </li>
                                            </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" data-select2-id="15">
                                        <div class="page-header">
                                            <div class="row align-items-end">
                                                <div class="col-lg-8">
                                                    <div class="page-header-title">
                                                        <div class="d-inline">
                                                            <h4>Water Discharge Report</h4>

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

                                        <div class="card mt-2" data-select2-id="8">
                                            <div class="card-body " data-select2-id="7">
                                                <div class="d-flex justify-content-between align-items-center">
                                                    <h3 class="mb-0">Water Discharge Report</h3>
                                                    <div>
                                                        <!--<button id="device_wise_export" style="" class="btn btn-rounded btn-success" onclick="export_device_wise_report();">Export</button>-->
                                                        <button id="date_wise_export" style="display: none;" class="btn btn-rounded btn-success" onclick="export_date_wise_report();">Export</button>
                                                        <a href="dam_home.php"><button class="btn btn-rounded btn-primary mx-2"> Back </button></a>
                                                    </div>
                                                </div>

                                                <!--                                                <div class="row ml-1">
                                                                                                    <div class="form-group col-md-4 mt-2" data-select2-id="6">
                                                                                                        <label style="font-size: 15px;">View Report</label> 
                                                                                                        <select name="report_view" id="report_view" class="form-control select2 select2-hidden-accessible" data-select2-id="report_view" tabindex="-1" aria-hidden="true">
                                                                                                            <option value="" data-select2-id="2"> Select Canal </option>
                                                                                                            <option value="device" data-select2-id="10">Water Pump</option>
                                                                                                            <option value="date" data-select2-id="11">Date</option>
                                                                                                        </select>
                                                                                                    </div>
                                                                                                    <div class="form-group col-md-4 mt-2" style="display:none;" id="filter_date">
                                                                                                        <label style="font-size: 15px;">Date</label>
                                                                                                        <input type="date" name="date" id="date" class="form-control" value="2024-09-03" onchange="get_date();get_data_table();">
                                                                                                    </div>
                                                                                                </div>-->

                                                <div class="card-body" id="device_wise_table" style="" data-select2-id="device_wise_table">
                                                    <div class="row mt-n2">

                                                        <div class="form-group col-md-4 mt-2" data-select2-id="14">
                                                            <label style="font-size: 15px;">Canal Name</label>
                                                            <select name="node_id" id="select_canal" class="form-control select2 select2-hidden-accessible" data-select2-id="node_id" tabindex="-1" aria-hidden="true">
                                                                <!-- <option value="">Select Motor</option> -->

                                                                <option name="Select" id="Select"> Select Canal Name</option>
                                                                <?php
                                                                $query = 'select * from  tbl_flow_meter where user_id=' . $_SESSION['user_id'].' and flag="1"';
                                                                mysqli_set_charset($con, 'utf8');
                                                                $result = mysqli_query($con, $query);
                                                                if (mysqli_num_rows($result) > 0) {
                                                                    while ($row = mysqli_fetch_assoc($result)) {
                                                                        ?>
                                                                        <option id="<?php echo $row["id"]; ?>"><?php echo $row["meter_name"]; ?></option>
                                                                        <?php
                                                                    }
                                                                }
                                                                ?>
                                                                <!--                                                                <option value="c9e3624d-bb7d-11ee-a49c-0ac781a0ba02" data-select2-id="4">Gandevi Chowk Pump 2</option>
                                                                                                                                <option value="9769bc5f-bb57-11ee-a49c-0ac781a0ba02" data-select2-id="23">Gandevi Chowk Pump 1</option>
                                                                                                                                <option value="fb5132b8-97f6-11ee-afe5-0ac781a0ba02" data-select2-id="24">RIP-1</option>
                                                                                                                                <option value="1f5dec58-bb5d-11ee-a49c-0ac781a0ba02" data-select2-id="25">Main office Pump 2</option>-->
                                                            </select>
                                                            <div id="msg_canal"></div>
                                                        </div>

                                                        <div class="form-group col-md-3 mt-2">
                                                            <label style="font-size: 15px;">From Date</label>
                                                            <input type="date" name="from_date" value="" id="from_date" class="form-control">
                                                            <div id="msg_start_date"></div>
                                                        </div>

                                                        <div class="form-group col-md-3 mt-2">
                                                            <label style="font-size: 15px;">To Date</label>
                                                            <input type="date" name="to_date" value="" id="to_date" class="form-control">
                                                            <div id="msg_end_date"></div>
                                                        </div>
                                                        <div class="form-group col-md-2 mt-4">
                                                            <button id="btn_search" style="margin-top: 15px" class="btn btn-rounded btn-primary"><i class="fa fa-search"></i>Search</button>
                                                            <button id="btn_print" style="margin-top: 15px" class="btn btn-rounded btn-primary" onclick="printDiv()"><i class="fa fa-print"></i>Print</button>
                                                            <!--<button type="button" style="margin-top: 30px" class="btn btn-primary"  onclick="printDiv()"><i class="fa fa-print"></i>Print</button>-->
                                                        </div>
                                                    </div>
                                                    <img src="files/assets/img/loading1.gif" alt="Computer man" id="img_loading" style="display: none;margin-left: 500px;width:180px;height:180px;">
                                                    <div class="table-responsive mt-3" id="print_div">
<!--                                                        <table class="table table-bordered" id="device_wise_export_report">
                                                            <thead>
                                                                <tr>
                                                                    <th colspan="8" class="text-center text-uppercase" style="font-size: 22px;"> Canal  monitoring system</th>
                                                                </tr>

                                                                <tr>
                                                                    <th colspan="8" class="text-center text-uppercase" style="font-size: 15px;font-weight: bolder;">Canal Wise Log Report <span id="show_from_date">03-09-2024</span> <span id="to" style="display: none;">To</span> <span id="show_to_date"></span></th>
                                                                </tr>

                                                                <tr class="text-center">
                                                                    <th style="width:10%;">Sr No.</th>
                                                                    <th>Canal Name</th>
                                                                    <th>Water Level</th>
                                                                    <th>Gate Open </th>
                                                                    <th>Water Flow </th>
                                                                    <th>Discharge Water </th>
                                                                    <th>Discharge Water </th>
                                                                    <th>Date</th>

                                                                </tr> 
                                                            </thead>
                                                            <tbody id="table_data" class="text-center">

                                                                <?php
                                                                $i = 1;
                                                                $id = 1;
                                                                $st_dt = '2024-09-20';
                                                                $en_dt = '2024-09-23';
//                                                                echo '$st_dt ' . $st_dt;
//                                                                echo '$en_dt ' . $en_dt;
//                                                              
                                                                $startDate = new DateTime($st_dt); // Start date
//                                                                $endDate = new DateTime('2024-08-16');   // End date
                                                                $endDate = new DateTime($en_dt);   // End date
//                                                                echo '$startDate ';
//                                                                print_r($startDate);
//                                                                echo '$endDate ';
//                                                                print_r($endDate);
// Create an array to store the dates between start and end date
                                                                $dateRange = [];

// Loop to add each date between the start and end date
                                                                while ($startDate <= $endDate) {
                                                                    // Add the current date to the array
                                                                    $dateRange[] = $startDate->format('Y-m-d'); // Format the date as 'YYYY-MM-DD'
                                                                    // Move to the next date
                                                                    $startDate->modify('+1 day');
                                                                }

// Display the dates
//                                                                echo "<h2>Dates between the selected range:</h2>";
                                                                $cnt_array = count($dateRange);
                                                                foreach ($dateRange as $date) {
//                                                                    echo $date . "<br>";
                                                                    $start_date = $date . " 00:00:02";
                                                                    $end_date = $date . " 23:59:59";
//                                                                    $start_date = $date;
//                                                                    $end_date = $date;
//                                                                    echo "<br>" . $start_date . "<br>" . $end_date;

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


                                                                            $now = time(); // or your date as well
                                                                            $datediff = $now - $your_date;
                                                                            $Days = round($datediff / (60 * 60 * 24));
                                                                            $check_on_off = $row1["canal_height"] - $row1["water_level"];

                                                                            $bottom_width = $row1["canal_bottom_width"];
//                                                                                            echo '<br>$bottom_width ' . $bottom_width;
                                                                            $side_slop = $row1["side_slop"];
//                                                                                            echo '<br>side_slop ' . $side_slop;
                                                                            $channel_slop = $row1["channel_slop"];
//                                                                                            echo '<br>channel_slop ' . $channel_slop;
                                                                            $m_r_coefficient = $row1["m_r_coefficient"];
//                                                                                            echo '<br>m_r_coefficient ' . $m_r_coefficient;
                                                                            $canal_top_width = $row1["canal_top_width"];
//                                                                                            echo '<br>canal_top_width  ' . $canal_top_width;

                                                                            $water_level = $row1["canal_height"] - $row1["water_level"];
//                                                                                            $water_level = 1.30;
//                                                                                            echo '<br>$water_level  ' . $water_level;

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

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

                                                                            $hydraulic_radius = $Area / $wetted_perimeter;
                                                                            $R = number_format($hydraulic_radius, 3);
//                                                                                            echo '<br>hydraulic_radius $R  ' . $R;

                                                                            $S12 = number_format(sqrt($channel_slop), 3);
//                                                                                            echo '<br>$S12  ' . $S12;

                                                                            $R23_squre = number_format($R * $R, 4);
//                                                                                            echo '<br>$R23_squre  ' . $R23_squre;

                                                                            $R23_cube_root = number_format(pow($R23_squre, 1 / 3), 4);
//                                                                                            echo '<br>$R23_cube_root  ' . $R23_cube_root;

                                                                            $Q_0 = number_format(1 / $m_r_coefficient, 3);
                                                                            $Q_1 = number_format($Q_0 * $Area, 3);
//                                                                                            echo '<br>$Q_0  ' . $Q_0;
//                                                                                            echo '<br>$Q_1  ' . $Q_1;
                                                                            $Q_2 = number_format($R * $S12, 4);
//                                                                                            echo '<br>$Q_2  ' . $Q_2;
                                                                            $Q_Flow = number_format($Q_1 * $Q_2, 4);
//                                                                                            echo '<br>$Q_Flow  ' . $Q_Flow;
//                                                                                            $Velocity=number_format($Q_Flow/$Area, 4);
//                                                                                            echo '<br>$Velocity  ' . $Velocity;

                                                                            $Cusec_1_unit = 35.3147;
                                                                            $liter_1_unit = 1000;

                                                                            $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));

//                                                                            $total_water_flow = $total_water_flow + $Q_Flow;
                                                                            $cnt_flow = $cnt_flow + 1;

                                                                            if ($check_on_off > 0.20) {
                                                                                $cnt_up_level = $cnt_up_level + 1;
                                                                                $total_water_flow = $total_water_flow + $Q_Flow;
                                                                                $water_level_up = $row1["water_level"];
                                                                                $canal_height_up = $row1["canal_height"];
                                                                            } else {
                                                                                $cnt_low_level = $cnt_low_level + 1;
                                                                            }
//                                                                            echo '<br>' . $Q_Flow . ' ' . $date;
//                                                                            echo '<br>' . $total_water_flow;

                                                                            $meter_name = $row1["meter_name"];
                                                                            $address = $row1["address"];
                                                                            $water_level = $row1["water_level"];
                                                                            $canal_height = $row1["canal_height"];
                                                                        }

                                                                        $date = new DateTime($date); // YYYY-MM-DD format
// Format the date in 'dd-mm-yyyy'
                                                                        $formattedDate = $date->format('d-m-Y');

                                                                        echo '<br>$total_water_flow ' . $total_water_flow;
                                                                        echo '<br>$cnt_flow ' . $cnt_flow;
                                                                        echo '<br>$Q_Flow ' . $Q_Flow;
                                                                        echo '<br>$cnt_low_level ' . $cnt_low_level;
                                                                        echo '<br>$cnt_up_level ' . $cnt_up_level;
                                                                        echo '<br>$canal_height ' . $canal_height . ' $water_level ' . $water_level;
                                                                        echo '<br>$canal_height ' . $canal_height - $water_level;

                                                                        if ($cnt_up_level != 0) {

                                                                            if ($total_water_flow == 0) {
                                                                                $one_second_water_flow = 0;
                                                                            } else {

//                                                                                $tf = $total_water_flow / $cnt_flow;
//                                                                                $one_second_water_flow = number_format($tf, 4);
//                                                                                $Q_Flow_up;
                                                                                
                                                                                
                                                                                $tf = $total_water_flow / $cnt_up_level;
                                                                                echo '<br>$average tf ' . $tf;
                                                                                $one_second_water_flow = number_format($tf, 4);
                                                                                echo '<br>$one_second_water_flow ' . $one_second_water_flow;

                                                                                $total_Second = 5 * $cnt_up_level * 60;   // 5 fot 5 minit interval   , 60 for second
                                                                                $total_minit=$total_Second/3600;
                                                                                echo '<br>Day Cusec ' . $one_second_water_flow.' '.$Cusec_1_unit .' '. $total_Second;
                                                                            }
                                                                            ?>
                                                                            <tr>
                                                                                <td><?php echo $i; ?></td>
                                                                                <td>

                                                                                    <div class="d-inline-block align-middle">
                                                                                        <h6><?php echo $meter_name; ?></h6>
                                                                                        <p class="text-muted m-b-0"><?php echo $address; ?></p>
                                                                                    </div>
                                                                                </td>
                                                                                <td><?php echo $canal_height_up - $water_level_up . ' Meter'; ?></td>
                                                                                <td><?php echo $total_minit . ' Hour'; ?></td>
                                                                                <td><?php echo $one_second_water_flow . ' m3/s'; ?></td>
                                                                                <td><?php echo number_format($one_second_water_flow * $Cusec_1_unit, 4) . ' Cusec/Second'; ?></td>
                                                                                <td><?php echo number_format($one_second_water_flow * $Cusec_1_unit * $total_Second, 2) . ' Cusec/Day'; ?></td>
                                                                                <td><?php echo $formattedDate; ?></td>
                                                                            </tr>
                                                                            <?php
                                                                        } else {
                                                                            ?>
                                                                            <tr>
                                                                                <td><?php echo $i; ?></td>
                                                                                <td>

                                                                                    <div class="d-inline-block align-middle">
                                                                                        <h6><?php echo $meter_name; ?></h6>
                                                                                        <p class="text-muted m-b-0"><?php echo $address; ?></p>
                                                                                    </div>
                                                                                </td>
                                                                                <td><?php echo '0 Meter'; ?></td>
                                                                                <td><?php echo '0 Hour'; ?></td>
                                                                                <td><?php echo '0 m3/s'; ?></td>
                                                                                <td><?php echo '0 Cusec/Second'; ?></td>
                                                                                <td><?php echo '0 Cusec/Day'; ?></td>
                                                                                <td><?php echo $formattedDate; ?></td>
                                                                            </tr>
                                                                            <?php
                                                                        }

                                                                        $i = $i + 1;
                                                                    }
                                                                }
                                                                ?>

                                                                <tr><td class="text-danger" style="text-align:center;" colspan="7">No Record Found !!</td></tr></tbody>

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


                                                                function printDiv() {
                                                                    var divContents = document.getElementById("print_div").innerHTML;
                                                                    var a = window.open('', '', 'height=600, width=900');
                                                                    a.document.write('<html><head><title></title>');
                                                                    a.document.write('<link rel="stylesheet" type="text/css" href="./files/bower_components/bootstrap/dist/css/bootstrap.min.css">');
                                                                    a.document.write('</head><body>');
                                                                    a.document.write(divContents);

                                                                    a.document.write('</body></html>');
                                                                    a.document.close();
                                                                    a.print();
                                                                }

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

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

                                                                $(document).ready(function () {

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

                                                                    $(document.body).on('change', '#select_canal', function () {
                                                                        debugger;
                                                                        if ($("#select_canal").val() == "Select Canal Name")
                                                                        {
                                                                            $("#msg_canal").fadeIn(500);
                                                                            $("#msg_canal").html("* Canal Name Not Selected").css({'color': 'red'});
                                                                            $("#msg_canal").focusin();
                                                                        } else
                                                                        {
                                                                            $("#msg_canal").fadeOut(1000);
                                                                        }
                                                                    });

                                                                    $(document.body).on('change', '#from_date', function () {
                                                                        debugger;
                                                                        if ($("#from_date").val() == "")
                                                                        {
                                                                            $("#msg_start_date").fadeIn(500);
                                                                            $("#msg_start_date").html("* Start Date Not Selected").css({'color': 'red'});
                                                                            $("#msg_start_date").focusin();
                                                                        } else
                                                                        {
                                                                            $("#msg_start_date").fadeOut(1000);
                                                                        }
                                                                    });

                                                                    $(document.body).on('change', '#to_date', function () {
                                                                        debugger;
                                                                        if ($("#to_date").val() == "")
                                                                        {
                                                                            $("#msg_end_date").fadeIn(500);
                                                                            $("#msg_end_date").html("* End Date Not Selected").css({'color': 'red'});
                                                                            $("#msg_end_date").focusin();
                                                                        } else
                                                                        {
                                                                            $("#msg_end_date").fadeOut(1000);
                                                                        }
                                                                    });

                                                                    $(document.body).on('click', '#btn_search', function (e) {
                                                                        //            alert('id is ' + $(this).attr('id'));
                                                                        var school_id = $('#select_canal').find('option:selected').attr('id');
                                                                        var start_date = $("#from_date").val();
                                                                        var to_date = $("#to_date").val();


                                                                        if ($("#select_canal").val() == "Select Canal Name")
                                                                        {
                                                                            $("#msg_canal").fadeIn(500);
                                                                            $("#msg_canal").html("* Canal Name Not Selected").css({'color': 'red'});
                                                                            $("#msg_canal").focusin();
                                                                        } else if ($("#from_date").val() == "")
                                                                        {
                                                                            $("#msg_start_date").fadeIn(500);
                                                                            $("#msg_start_date").html("* Start Date Not Selected").css({'color': 'red'});
                                                                            $("#msg_start_date").focusin();
                                                                        } else if ($("#to_date").val() == "")
                                                                        {
                                                                            $("#msg_end_date").fadeIn(500);
                                                                            $("#msg_end_date").html("* End Date Not Selected").css({'color': 'red'});
                                                                            $("#msg_end_date").focusin();
                                                                        } else {

                                                                            $("#img_loading").css({'display': 'block'});

                                                                            debugger;
                                                                            var data = {};
                                                                            var data = {'canal_id': school_id, 'start_date': start_date, 'to_date': to_date};
//                                                        data.user_id = user_id;
                                                                            $.ajax({
                                                                                type: 'POST',
                                                                                data: data,
                                                                                url: './PHP_Code/select_discharge_dam_report.php',
                                                                                success: function (data) {
                                                                                    debugger;
//                                                                                        alert('data '+data);
                                                                                    $('#print_div').html('');
                                                                                    $('#print_div').html(data);
                                                                                    $("#print_div").val('Select');
                                                                                    $("#img_loading").css({'display': 'none'});
//                                                                                            window.location.href = "./view_all_student_report.php";

                                                                                }, error: function (xhr, err) {
                                                                                    alert('Error ' + err.message);
                                                                                }
                                                                            });
                                                                        }
                                                                    });

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

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

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

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


    </body>
</html>