<?php
if($_POST['btncari']=="Search") {
	$tglf=$_POST['tglf'];
	$tgls=$_POST['tgls'];
} else { 
	$tglf= date('Y-m-d');
	$tgls = date('Y-m-d',strtotime('-1 day',strtotime($tglf))) ;
}
?>
        <link rel="stylesheet" href="Highcharts/nesw2/images/style.css" type="text/css">
	    <link type="text/css" href="css/jquery-ui-1.8.6.custom.css" rel="stylesheet" />	
		<script type="text/javascript" src="js/jquery.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>

		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script>
		<script type="text/javascript">
		jQuery(function($){
		$.datepicker.regional['vi'] = {
			closeText: 'Tutup',
			prevText: 'Sebelum',
			nextText: 'Sesudah',
			currentText: 'Sekarang',
			monthNames: ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni',
			'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'],
			monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun',
			'Jul', 'Ags', 'Sep', 'Okt', 'Nov', 'Des'],
			dayNames: ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jum&acute;at', 'Sabtu'],
			dayNamesShort: ['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sbt'],
			dayNamesMin: ['Mg', 'Sn', 'Sl', 'Rb', 'Km', 'Jm', 'Sb' ],
			dateFormat: 'yy-mm-dd',
			firstDay: 0,
			isRTL: false,
			showMonthAfterYear: false,
			changeMonth: true,
			changeYear: true,
			yearSuffix: ''};
		$.datepicker.setDefaults($.datepicker.regional['vi']);
	  	$(function(){
				$('#tgl').datepicker({
					inline: true
				});
	    });
		$(function(){
				$('#tglf').datepicker({
					inline: true
				});
	    });
       });
		
var htmlobjek;
$(document).ready(function(){
  //apabila terjadi event onchange terhadap object <select id=propinsi>
  $("#tipepos").change(function(){
    var tipepos = $("#tipepos").val();
    	$.ajax({
        	url: "data/masterpos.php",
        	data: "tipepos="+tipepos,
        	cache: false,
        	success: function(msg){$("#idpos").html(msg);}
    	});
	});
});

var htmlobjek;
$(document).ready(function(){
  //apabila terjadi event onchange terhadap object <select id=propinsi>
  $("#tipepos").change(function(){
  $("#idpos").change(function(){
  $("#tgl").change(function(){
    var tipepos = $("#tipepos").val();
    var idpos = $("#idpos").val();
    var tgl = $("#tgl").val();
    	$.ajax({
        	url: "data/hasilukur.php",
        	data: "idpos="+idpos+"&tgl="+tgl+"&tipepos="+tipepos,
        	cache: false,
        	success: function(msg){$("#hasildata").html(msg);}
    	});
	});
	});
	});
});

//proses simpan
function BtnSimpan() {
		var tipepos = $("#tipepos").val();
		var idpos = $("#idpos").val();
		var tgl = $("#tgl").val();
		var jam = $("#jam").val();
		var pda = $("#pda").val();
		var pch = $("#pch").val();
		if(tipepos=="") { alert('Tipe Pos belum diisi'); } else {
		$.ajax({
	        url: "data/ControllerInputPiket.php?a=addupdate",
			data : "tipepos="+tipepos+"&idpos="+idpos+"&tgl="+tgl+"&jam="+jam+"&pda="+pda+"&pch="+pch,
	        cache: false,
			type: "POST",
				success: function(msg){
					alert('Input data piket berhasil Disimpan!');
					Rload(idpos,tgl);
			}
		   });
		}
}

function Rload(idpos,tgl) {
		$.get("data/hasilukur.php?idpos="+idpos+"&tgl="+tgl, 
			  function(msg){
				$("#hasildata").html(msg);
		});
}
</script>
									<link rel="stylesheet" href="https://cdn.datatables.net/1.11.0/css/dataTables.bootstrap5.min.css">
									<!--//Page Toolbar//-->
                    <div class="toolbar pt-4 px-4 px-lg-8">
                        <div class="position-relative container-fluid px-0">
                            <div class="row align-items-center position-relative">
                                <div class="col-md-7">
                                    <h3 class="mb-2">Input Piket Manual</h3>

                                    <!--nav aria-label="breadcrumb">
                                        <ol class="breadcrumb mb-0">
                                            <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                                            <li class="breadcrumb-item active">UI Components</li>
                                            <li class="breadcrumb-item active">Feather Icons</li>
                                        </ol>
                                    </nav-->
                                </div>
                                <div class="col-md-5 text-md-end">
                                  <div class="d-flex justify-content-sm-end align-items-center">
                                    <div class="d-flex align-items-center">
                                      <button type="button" class="btn btn-success mb-2 me-2" data-bs-toggle="modal" data-bs-target="#newform"><i data-feather="download"></i>&nbsp; Export Data</button>
                                    </div>
                                  </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--//Page Toolbar End//-->

                    <!--//Page content//-->
                    <div class="content pt-4 px-4 px-lg-8 d-flex flex-column-fluid">
                        <div class="container-fluid px-0">
                            <div class="row">
                                <div class="col-7 mb-4">
                                    <div class="row">
                                        <div class="col-12 mb-4">
                                            <div class="card">
                                            	
                                                <div class="table-responsive">
									                                <table id="datatable" class="table mt-0 table-striped table-card table-nowrap">
									                                    <thead class="text-uppercase small text-muted">
									                                        <tr>
									                                            <th class="mc">Tanggal</th>
									                                            <th class="mc">Jam</th>
									                                            <th class="mc" id="data-column">Curah Hujan /<br/>Tinggi Muka Air</th>
									                                        </tr>
									                                    </thead>
									                                    <tbody id="data-result">
								                                    	
									                                    </tbody>
									                                </table>
					                            					</div>
                                            	
					                          				</div>
					                            
                                    		</div>
                                  	</div>
                                    

                                </div>
                                <div class="col-5 mb-4">
                                		<div class="row">
                                        <div class="col-12 mb-4">
                                            <div class="card">
                                            	<div class="card-body">
                                                <div class="alert alert-danger d-flex align-items-center" role="alert">
                                                <i data-feather="alert-triangle" class="fe-2x me-2 flex-shrink-0"></i> 
                                                 <div>
                                                   Silahkan gunakan Form ini hanya digunakan untuk pos pengukuran manual, atau pos telemetry yang pada tanggal dan jam tersebut tidak mengirimkan data.
                                                 </div>
                                               </div>
                                               <div class="row">
																									<div class="col-4 mb-3">
                                                		<label for="new-tipepos" class="form-label">Tipe POS</label>
                                    								<select class="form-select" aria-label="" id="new-tipepos" name="new-tipepos">
			                                                <option value="PCH">PCH</option>
			                                                <option value="PDA">PDA</option>
		                                            		</select>
                                          				</div>
                                          				<div class="col-8 mb-3">
                                                		<label for="new-namapos" class="form-label">Nama POS</label>
                                    								<select class="form-select" aria-label="" id="new-namapos" name="new-namapos">
			                                                <option value="0">Pilih POS</option>
		                                            		</select>
                                          				</div>
                                          				<div class="col-7 mb-3">
                                                		<label for="new-tanggal" class="form-label">Tanggal</label>
                                    								<input type="text" class="form-control" id="new-tanggal" name="new-tanggal" placeholder="YYYY-MM-DD">
                                          				</div>
                                          				<div class="col-5 mb-3">
                                                		<label for="new-jam" class="form-label">Jam</label>
                                    								<select class="form-select" aria-label="" id="new-jam" name="new-jam">
                                    								<?php for ($i=7; $i <= 24; $i++) { if($i > 9){ $h = $i.':00'; }else{ $h = '0'.$i.':00'; } ?> 
			                                                <option value="<?php echo $h; ?>"><?php echo $h; ?></option>                                    									
                                    								<?php } ?>
                                    								<?php for ($i=1; $i <= 6; $i++) { if($i > 9){ $h = $i.':00'; }else{ $h = '0'.$i.':00'; } ?> 
			                                                <option value="<?php echo $h; ?>"><?php echo $h; ?></option>                                    									
                                    								<?php } ?>
		                                            		</select>
                                          				</div>
                                          				<div class="col-6 mb-3">
                                                		<label for="new-tma" class="form-label">Tinggi Muka Air</label>
                                    								<input type="text" class="form-control" id="new-tma" name="new-tma" style="text-align: right;" placeholder="0">
                                          				</div>
                                          				<div class="col-6 mb-5">
                                                		<label for="new-ch" class="form-label">Curah Hujan</label>
                                    								<input type="text" class="form-control" id="new-ch" name="new-ch" style="text-align: right;" placeholder="0">
                                          				</div>
                                          				<div class="col-12 mb-3">
                                          					<button class="btn btn-info" style="width: 100%;">Simpan Data</button>
                                          				</div>
                                          			</div>
                                          		</div>
					                          				</div>
					                            
                                    		</div>
                                  	</div>
                                </div>
                            </div>
                        </div>
                    </div>      