<?php
include "config/conn.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))) ;
}
$sql="SELECT * FROM m_lokasi_detail WHERE manual_inputtipe = 'genangan'";
$query=mysql_query($sql);

if($_POST['simpan']=="Simpan"){
		$id_debit=strip_tags($_POST['id_debit']);
		$tahun_debit=$_POST['tahun_debit'];
		$ibbws=trim($_POST['ibbws']);
		$id_lokasi=strip_tags($_POST['id_lokasi']);
		$nilai_a=strip_tags($_POST['nilai_a']);
		$nilai_b=strip_tags($_POST['nilai_b']);
		$nilai_c=strip_tags($_POST['nilai_c']);

		if ($id_debit=="") {
			$sqlinsertmdebit="INSERT INTO m_debit values('','$ibbws','$id_lokasi','$tahun_debit','$nilai_a','$nilai_b','$nilai_c')";
		    $query=mysql_query($sqlinsertmdebit);
			if($query){
				echo "<script>alert('Input hasil debit berhasil disimpan!');history.go(-1);</script>";
			}
		} else {
		$sql="UPDATE m_debit SET id_bbws='$ibbws', id_lokasi='$id_lokasi',tahun_debit='$tahun_debit',nilai_a='$nilai_a',nilai_b='$nilai_b',nilai_c='$nilai_c' WHERE id_debit='$id_debit'";			
		$query=mysql_query($sql);
			if($query){
				echo"<script>alert('Update data debit berhasil !');history.go(-1);</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">Laporan Genangan </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">

                                    </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-12 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">Show</th>
					                                            <th class="mc">Tanggal</th>
					                                            <th class="mc">Foto</th>
					                                            <th class="mc">Ketinggian (cm)</th>
					                                            <th class="mc">Lokasi</th>
					                                            <th class="mc">Updated By</th>
					                                            <th class="mc">Keterangan</th>
					                                        </tr>
					                                    </thead>
					                                    <tbody>
				                                    	<?php
					                                    while($row=mysql_fetch_array($query)){
					                                    	if($row['manual_publish'] == 'Y'){
					                                    		$checked = 'checked';
					                                    	}else{
					                                    		$checked = '';
					                                    	}
					                                    	if(file_exists('cdn/manual/'.$row['manual_foto'])){
																$img = CDN.'manual/'.$row['manual_foto'];
															}else{
																$img = CDN2.'manual/'.$row['manual_foto'];
															}
					                                    ?>
					                                        <tr>
					                                            <td class="tl"><input class="form-check-input" type="checkbox" id="flexSwitchCheckDefault" <?php echo $checked; ?>></td>
					                                            <td class="tl"><?php echo $row['credate']; ?></td>
					                                            <td class="tc"><img src="<?php echo $img; ?>" style="height: 160px;" /></td>
					                                            <td class="tc"><?php echo $row['manual_tg']; ?></td>
					                                            <td class="tc"><a href="https://www.google.com/maps/search/<?php echo $row['manual_lat'].','.$row['manual_lng']; ?>" target="_blank"><?php echo number_format($row['manual_lat'],6,'.',',').', '.number_format($row['manual_lng'],6,'.',','); ?></td>
					                                            <td class="tc"><?php echo substr($row['creperson'], 0, 16); ?></td>
					                                            <td class="tl" style="word-wrap: break-word;"><p><?php echo trim($row['manual_keterangan']); ?></p></td>
					                                        </tr>
					                                    <?php  
					                                	}
					                                    ?>
					                                    </tbody>
					                                </table>
					                            </div>
					                            <!-- New Modal -->
					                            <div class="modal fade" id="newform" data-bs-backdrop="static"
	                                                data-bs-keyboard="false" tabindex="-1"
	                                                aria-labelledby="newformLabel" aria-hidden="true">
	                                                <div class="modal-dialog modal-lg">
	                                                    <div class="modal-content">
	                                                        <div class="modal-header">
	                                                            <h5 class="modal-title" id="editformLabel">Tambah Data Daerah Aliran Sungai</h5>
	                                                            <button type="button" class="btn-close"
	                                                                data-bs-dismiss="modal" aria-label="Close"></button>
	                                                        </div>
	                                                        <div class="modal-body">
	                                                            <div class="row">
	                                                            	<div class="col-6">
	                                                            		<div class="row">
	                                                            			<div class="col-12 mb-3">
	                                                            				<label for="new-namadas" class="form-label">Nama DAS</label>
                                                  								<input type="text" class="form-control" id="new-namadas" name="new-namadas">
	                                                            			</div>
	                                                            			<div class="col-12 mb-3">
	                                                            				<label for="new-namasungai" class="form-label">Nama Sungai</label>
                                                  								<input type="text" class="form-control" id="new-namasungai" name="new-namasungai">
	                                                            			</div>
	                                                            		</div>
	                                                            	</div>
	                                                            	<div class="col-6">
	                                                            		<div class="row">
	                                                            			<div class="col-6 mb-3">
	                                                            				<label for="new-kodedas" class="form-label">Kode DAS</label>
                                                  								<input type="text" class="form-control" id="new-kodedas" name="new-kodedas">
	                                                            			</div>
	                                                            			<div class="col-6 mb-3">
	                                                            				<label for="new-luasdas" class="form-label">Luas Darah Aliran</label>
                                                  								<input type="text" class="form-control" id="new-luasdas" name="new-luasdas" style="text-align: right;">
	                                                            			</div>
	                                                            		</div>
	                                                            	</div>
	                                                            </div>
	                                                        </div>
	                                                        <div class="modal-footer">
	                                                            <button type="button" class="btn btn-secondary"
	                                                                data-bs-dismiss="modal">Close</button>
	                                                            <button type="button"
	                                                                class="btn btn-info">Save</button>
	                                                        </div>
	                                                    </div>
	                                                </div>
	                                            </div>
					                            <!-- Edit Modal -->
	                                            <div class="modal fade" id="editform" data-bs-backdrop="static"
	                                                data-bs-keyboard="false" tabindex="-1"
	                                                aria-labelledby="editformLabel" aria-hidden="true">
	                                                <div class="modal-dialog modal-lg">
	                                                    <div class="modal-content">
	                                                        <div class="modal-header">
	                                                            <h5 class="modal-title" id="editformLabel">Ubah Data Daerah Aliran Sungai</h5>
	                                                            <button type="button" class="btn-close"
	                                                                data-bs-dismiss="modal" aria-label="Close"></button>
	                                                        </div>
	                                                        <div class="modal-body">
	                                                            <div class="row">
	                                                            	<div class="col-6">
	                                                            		<div class="row">
	                                                            			<div class="col-12 mb-3">
	                                                            				<label for="edit-namadas" class="form-label">Nama DAS</label>
                                                  								<input type="text" class="form-control" id="edit-namadas" name="edit-namadas">
	                                                            			</div>
	                                                            			<div class="col-12 mb-3">
	                                                            				<label for="edit-namasungai" class="form-label">Nama Sungai</label>
                                                  								<input type="text" class="form-control" id="edit-namasungai" name="edit-namasungai">
	                                                            			</div>
	                                                            		</div>
	                                                            	</div>
	                                                            	<div class="col-6">
	                                                            		<div class="row">
	                                                            			<div class="col-6 mb-3">
	                                                            				<label for="edit-kodedas" class="form-label">Kode DAS</label>
                                                  								<input type="text" class="form-control" id="edit-kodedas" name="edit-kodedas">
	                                                            			</div>
	                                                            			<div class="col-6 mb-3">
	                                                            				<label for="edit-luasdas" class="form-label">Luas Darah Aliran</label>
                                                  								<input type="text" class="form-control" id="edit-luasdas" name="edit-luasdas" style="text-align: right;">
	                                                            			</div>
	                                                            		</div>
	                                                            	</div>
	                                                            </div>
	                                                        </div>
	                                                        <div class="modal-footer">
	                                                            <button type="button" class="btn btn-secondary"
	                                                                data-bs-dismiss="modal">Close</button>
	                                                            <button type="button"
	                                                                class="btn btn-info">Save</button>
	                                                        </div>
	                                                    </div>
	                                                </div>
	                                            </div>
                                            </div>
                                        </div>
                                    </div>
                                    

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