Skip to content

Instantly share code, notes, and snippets.

@nurulimamnotes
Created August 10, 2016 17:10
Show Gist options
  • Save nurulimamnotes/45605e5d24ed958ce3807a2dd8f94484 to your computer and use it in GitHub Desktop.
Save nurulimamnotes/45605e5d24ed958ce3807a2dd8f94484 to your computer and use it in GitHub Desktop.
<div class="panel-heading">Grafik Data Rawan Bencana</div>
<div class="panel-body">
<div id="kecamatan"></div>
</div>
<script type="text/javascript">
Morris.Bar({
element: 'kecamatan',
data: [
<?php $idkec = $_GET['id']; foreach (lihat("SELECT `data`.id, count(data.jenis) AS jenis, data.kecamatan, kecamatan.nama FROM `data` INNER JOIN kecamatan ON `data`.kecamatan = kecamatan.id WHERE data.kecamatan = $idkec GROUP BY `data`.kecamatan") as $data) {
$namakecamatan = cari("kecamatan", "id", $data['kecamatan']);
echo "{nama: '";
echo $namakecamatan[0]['nama']."', ";
echo "jenis: ".$data['jenis'];
echo "},";
}
?>
],
xkey: 'nama',
ykeys: ['jenis'],
labels: ['Jumlah Area Rawan Bencana'],
barRatio: 0.4,
xLabelAngle: 35,
hideHover: 'auto'
});
</script>
<div class="clearfix"></div>
<table class="table table-bordered" data-toggle="table" data-pagination="true" data-search="true" data-page-size="5" data-page-list="[5,10,25,50,100]">
<thead>
<tr>
<th>No</th>
<th>Kecamatan</th>
<th>Desa / Kelurahan</th>
<th>Jenis Bencana</th>
<th>Tingkat Resiko</th>
<th>Kelas</th>
<th>Luas Ancaman</th>
<th>Jiwa Terpapar</th>
<th>Potensi Kerugian (Dalam Rupiah)</th>
<th>Lingkungan</th>
</tr>
</thead>
<tbody>
<?php $nom = 1; foreach (lihat("SELECT * FROM data WHERE kecamatan = $idkec ORDER BY desa, kecamatan ASC") as $data) { ?>
<tr>
<td><?php echo $nom; ?></td>
<td><?php foreach (cari("kecamatan", "id", $data['kecamatan']) as $kecamatan) { echo $kecamatan['nama']; } ?></td>
<td><?php foreach (cari("desa", "id", $data['desa']) as $desa) { echo $desa['nama']; } ?></td>
<td><?php echo $data['jenis']; ?></td>
<td><?php echo $data['resiko']; ?></td>
<td><?php echo $data['kelas']; ?></td>
<td><?php echo $data['luas']; ?></td>
<td><?php echo $data['jiwa']; ?></td>
<td><?php echo $data['kerugian']; ?></td>
<td><?php echo $data['lingkungan']; ?></td>
</tr>
<?php $nom++; } ?>
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment