<?php
session_start();
include("../../php_crud/my_class.php");
$obj = new my_class();
//echo "goods management here";
$user_id = $_SESSION['LOGIN_USERID'];
$user_cols = "USR_INFO.USER_GROUP_ID,OFC_INFO.OFFICE_NAME";
//echo "<br/>";
$user_tbls = "ST_USER_INFO USR_INFO LEFT JOIN ST_OFFICE_SETTINGS OFC_INFO ON USR_INFO.OFFICE_ID=OFC_INFO.ID";
//echo "<br/>USR_INFO.USER_ID='$user_id'";
$user_info = $obj->View_column_details_By_Cond($user_tbls, $user_cols, "USR_INFO.USER_ID='$user_id'");
//print_r($station_list);
$user_group_id = $user_info['USER_GROUP_ID'];
$user_office_id = trim($user_info['OFFICE_NAME']);
// $current_mon_f_date = date("01-m-Y");
// $current_mon_l_date = date("t-m-Y");
$current_date = date("d-m-Y"); // Format the current date
$previous_date = date("d-m-Y", strtotime("-1 day")); // Format the previous date (1 day ago)

/*$current_mon_f_date = "01-01-2023";
$current_mon_l_date = "31-01-2023";*/
//echo "<br/>SELECT * FROM HYDROLOGY.GWM_TBL@HYDRO10 WHERE HYDSUBDIVCODE='$user_office_id' ORDER BY OLD_ID ASC";
?>

<style>
    input[type="text"],
    textarea,
    select {
        width: 100%;
    }
</style>

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.1/css/all.css" rel="stylesheet" media="all" type="text/css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">

<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<script src="module/mobiledatalog/js/mobile_data_log.js" type="text/javascript"></script>

<div id="cover-spin"></div>
<div class="table-header">
    <i class="fas fa-th-list"></i> Data Log
    <!-- <a class="btn btn-small btn-yellow" href="#modal_add_goods_info" data-toggle="modal" onclick="load_goods_add_form()" style="margin-right:10px;margin-top:3px;float:right;hover:cursor;">
	<i class="fa fa-plus-circle"></i> Add Goods Information</a> -->
</div>
<div class="row-fluid" style="background-color:#f5f5f5;-webkit-box-shadow: 0 8px 6px -6px black; -moz-box-shadow: 0 8px 6px -6px black; box-shadow: 0 8px 6px -6px black; padding-bottom:10px;">
    <div class="span2" style="margin-top: 5px; padding-left: 10px;">
        <div class="control-group">
            <label class="control-label" for="form-field-1"><b>From Date<font color="#FF0000"></font></b></label>
            <div class="controls">
                <div class="row-fluid input-prepend">
                    <span class="add-on">
                        <i class="icon-calendar"></i>
                    </span>
                    <input id="from_date" name="from_date" class="date-picker" type="text" data-date-format="dd-mm-yyyy" placeholder="dd-mm-yyyy" style="width: 50%;" value="<?php echo $previous_date; ?>" />
                </div>
            </div>
        </div>
    </div>
    <div class="span2" style="margin-top: 5px;">
        <div class="control-group">
            <label class="control-label" for="form-field-1"><b>To Date<font color="#FF0000"></font></b></label>
            <div class="controls">
                <div class="row-fluid input-prepend">
                    <span class="add-on">
                        <i class="icon-calendar"></i>
                    </span>
                    <input id="to_date" name="to_date" class="date-picker" type="text" data-date-format="dd-mm-yyyy" placeholder="dd-mm-yyyy" style="width: 50%;" value="<?php echo $current_date; ?>" />
                </div>
            </div>
        </div>
    </div>
    <div class="span2" style="margin-top: 5px;">
        <div class="control-group">
            <label class="control-label" for="form-field-1"><b>Status<font color="#FF0000"></font></b></label>
            <div class="controls">
                <select id="data_status" class="chosen-select" name="data_status" style="width: 70%;">
                    <option value="P">Pending</option>
                    <option value="VR">Varified</option>
                    <option value="A">Approved</option>
                    <option value="R">Rejected</option>
                    <option value="all">All</option>
                </select>
            </div>
        </div>
    </div>

    <div class="span1"></div>

    <!--new code-->
    <div class="span2" style="margin-top: 5px;">
        <div class="control-group">
            <label class="control-label" for="form-field-1"><b>Old Id (Well Id)<font color="#FF0000"></font></b></label>
            <div class="controls">
                <select name="old_id" id="old_id" class="chosen-select">
                    <?php
                    $table_name = "HYDROLOGY.GWM_TBL@HYDRO10";
                    $cols = "*";
                    if ($user_group_id == 122) {
                        $where_cond = "HYDSUBDIVCODE='$user_office_id' ORDER BY OLD_ID ASC";
                    } else {
                        $where_cond = "1=1 ORDER BY OLD_ID ASC";
                    }
                    //SELECT WELL_ID,OLD_ID FROM GWM_TBL WHERE UPAZILA_CODE IN ('4745','4751')
                    foreach ($obj->View_colmn_By_Cond($table_name, $cols, $where_cond) as $old_id) {
                        echo ' <option value=""></option>';
                        // echo '<option value="'.$old_id['WELL_ID'].'">'.$old_id['OLD_ID'].'</option>';
                        echo '<option value="' . $old_id['WELL_ID'] . '" data-station-name="' . $old_id['OLD_ID'] . '" data-data="' . $old_id['DATA'] . '">' . $old_id['OLD_ID'] . '  (' . $old_id['WELL_ID'] . ')</option>';
                    }
                    ?>
                </select>
            </div>
        </div>
    </div>
    <!--new code-->
    <div class="span1"></div>
    <div class="span2">
        <div class="control-group">
            <label class="control-label" for="form-field-1">&nbsp;&nbsp;</label>
            <div class="controls">
                <button class="btn btn-small btn-success" type="button" onclick="data_log()">
                    <i class="icon-search"></i> Search
                </button>
            </div>
        </div>
    </div>
</div>

<div id="modal_show_raw_data" class="modal hide fade" tabindex="-1" style="margin-top: 5%; margin-right: 10%; width:500px;">
    <div class="modal-header no-padding">
        <div class="table-header">
            <button type="button" class="close" data-dismiss="modal" style="opacity:1 !important"><i class="fa fa-window-close" style="font-size: 26px;font-weight: bold;color: #FFF;"></i> </button>
            <i class="fab fa-wpforms"></i> Data Log Details
        </div>
    </div>
    <div class="modal-body " id="modal_body_show_raw_data" style="padding-left: 15px; padding-right: 15px; padding-top: 30px; padding-bottom: 30px;"></div>
    <!--<div class="modal-footer">
		<div class="row-fluid">
			<div class="span6">
				<button class="btn btn-small btn-success pull-right" type="button" id="btn_save" onclick="add_sender_info()">
					<i class="fa fa-check"></i>
					Save
				</button>
			</div>
			<div class="span6" style="padding-left: 10px;">
				<button class="btn btn-small btn-danger pull-left" type="button" class="close" data-dismiss="modal" >
					<i class="icon-remove"></i>
					Close
				</button>
			</div>
		</div>
	</div>-->
</div>
<div id="modal_show_mdm_wl_graph" class="modal hide fade" style="overflow-x:show; width: 45%; margin-left: -22%;" tabindex="-1">
    <div class="modal-header no-padding">
        <div class="table-header">
            <button type="button" class="close" data-dismiss="modal" style="opacity:1 !important"><i class="fa fa-window-close" style="font-size: 26px;font-weight: bold;color: #FFF;"></i> </button>
            <i class="fa-solid fa-chart-simple"></i> Hydrology Water Table Graph
        </div>
    </div>
    <div class="modal-body" id="modal_body_mdm_wl_graph">
    </div>
</div>

<div style="margin-top: 10px;" id="data_log"></div>

<script>
    data_load()
</script>
<script type="text/javascript">
    $('.date-picker').datepicker().next().on(ace.click_event, function() {
        $(this).prev().focus();

    });
    $(".date-picker").attr("autocomplete", "off");
</script>
<script>
var mindate = new Date();
mindate.setDate(mindate.getDate() - 8);
var maxdate = new Date();
maxdate.setDate(maxdate.getDate() - 1);
$('#minMaxExample').datepicker({
    language: 'en',
    range: true,
    minDate: mindate,
    maxDate: maxdate,
    multipleDates: true,
    multipleDatesSeparator: " - "
})
</script>
<script>
var mindate = new Date();
mindate.setDate(mindate.getDate() - 8);
var maxdate = new Date();
maxdate.setDate(maxdate.getDate() - 1);
$('#maxMaxExample').datepicker({
    language: 'en',
    range: true,
    minDate: mindate,
    maxDate: maxdate,
    multipleDates: true,
    multipleDatesSeparator: " - "
})
</script>
<script type="text/javascript">
    $('.chosen-select').chosen({
        allow_single_deselect: true
    });
    //resize the chosen on window resize

    $(window)
        .off('resize.chosen')
        .on('resize.chosen', function() {
            $('.chosen-select').each(function() {
                var $this = $(this);
                $this.next().css({
                    'width': '100%'
                });
            })
        }).trigger('resize.chosen');
    //resize chosen on sidebar collapse/expand
    $(document).on('settings.ace.chosen', function(e, event_name, event_val) {
        if (event_name != 'sidebar_collapsed') return;
        $('.chosen-select').each(function() {
            var $this = $(this);
            $this.next().css({
                'width': '100%'
            });
        })
    });
</script>
<style>
    .box-from {
        padding: 0 0 2% 0;
        background: #ffffff;
        -webkit-border-radius: 10px;
        -moz-border-radius: 10px;
        border-radius: 10px;
    }

    .box-from h3 {
        /* text-align: center; */
        /* padding: 0 0 2% 0; */
        margin: 0 2% 0 1%;
    }

    .box-from .form-control {
        max-width: 18%;
        margin: 0.5% 0 0 0;
        font-weight: bold;
    }

    .datepicker {
        font-family: 'Exo 2', sans-serif;
    }

    .datepicker--cell.-range-to- {
        background: rgba(248, 266, 236, 0.4);
        border-color: rgba(248, 266, 236, 1);
    }


    .datepicker--cell.-selected-,
    .datepicker--cell.-selected-.-focus- {
        background-color: #f8ceec;
        color: #000000;
    }

    .datepicker--cell.-in-range- {
        background: rgba(248, 266, 236, 0.2);
    }

    .datepicker--cell-day {
        font-weight: 500;
        color: #000000;
    }

    .form-control {
        height: 50px;
        font-size: 16px;
        font-weight: bold;
        color: #414D64;
        background: #ffffff;
        padding: 0 15px;
        border: 2px solid #DADEEA;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-transition: all 0.3s ease-in-out;
        -moz-transition: all 0.3s ease-in-out;
        -o-transition: all 0.3s ease-in-out;
        transition: all 0.3s ease-in-out;
        text-align: center;
    }

    textarea.form-control {
        height: 126px;
        /* padding-top: 15px; */
    }

    .form-control-plaintext {
        font-size: 18px;
        color: #434343;
    }

    button.form-control {
        text-overflow: ellipsis;
        overflow: hidden;
    }

    .form-control:focus {
        border-color: #37B448;
        -webkit-box-shadow: 0px 2px 6px rgba(55, 180, 72, .15);
        -moz-box-shadow: 0px 2px 6px rgba(55, 180, 72, .15);
        box-shadow: 0px 2px 6px rgba(55, 180, 72, .15);
    }
</style>

<style>
    .box-to {
        padding: 0 0 2% 0;
        background: #ffffff;
        -webkit-border-radius: 10px;
        -moz-border-radius: 10px;
        border-radius: 10px;
    }

    .box-to h3 {
        /* text-align: center; */
        /* padding: 0 0 2% 0; */
        margin: 0 2% 0 1%;
    }

    .box-to .form-control {
        max-width: 18%;
        margin: 0.5% 0 0 0;
        font-weight: bold;
    }

    .datepicker {
        font-family: 'Exo 2', sans-serif;
    }

    .datepicker--cell.-range-to- {
        background: rgba(248, 266, 236, 0.4);
        border-color: rgba(248, 266, 236, 1);
    }


    .datepicker--cell.-selected-,
    .datepicker--cell.-selected-.-focus- {
        background-color: #f8ceec;
        color: #000000;
    }

    .datepicker--cell.-in-range- {
        background: rgba(248, 266, 236, 0.2);
    }

    .datepicker--cell-day {
        font-weight: 500;
        color: #000000;
    }

    .form-control {
        height: 50px;
        font-size: 16px;
        color: #414D64;
        background: #ffffff;
        padding: 0 15px;
        border: 2px solid #DADEEA;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-transition: all 0.3s ease-in-out;
        -moz-transition: all 0.3s ease-in-out;
        -o-transition: all 0.3s ease-in-out;
        transition: all 0.3s ease-in-out;
        text-align: center;
    }

    textarea.form-control {
        height: 126px;
        /* padding-top: 15px; */
    }

    .form-control-plaintext {
        font-size: 18px;
        color: #434343;
    }

    button.form-control {
        text-overflow: ellipsis;
        overflow: hidden;
    }

    .form-control:focus {
        border-color: #37B448;
        -webkit-box-shadow: 0px 2px 6px rgba(55, 180, 72, .15);
        -moz-box-shadow: 0px 2px 6px rgba(55, 180, 72, .15);
        box-shadow: 0px 2px 6px rgba(55, 180, 72, .15);
    }
</style>