umkm-app/application/views/kelurahan.php

498 lines
31 KiB
PHP

<?php
function rupiah($angka){
$hasil_rupiah = "Rp " . number_format($angka,2,',','.');
return $hasil_rupiah;
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="<?php echo base_url()?>assets/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="<?php echo base_url()?>assets/css/dataTables.bootstrap4.min.css">
<link data-require="sweet-alert@*" data-semver="0.4.2" rel="stylesheet" href="<?php echo base_url()?>assets/css/sweetalert.min.css" />
<link rel="icon" type="image/png" href="../../assets/images/favicon.png" />
<title>Aplikasi UMKM</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-success">
<div class="container">
<a class="navbar-brand" href="#">
<img src="<?php echo base_url()?>assets/images/logo-white.png" width="100" alt="">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="<?php echo base_url()?>index.php">Beranda <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo base_url()?>index.php/umkm">Umkm</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo base_url()?>index.php/produk">Produk</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle active" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Data <span class="sr-only">(current)</span>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="<?php echo base_url()?>index.php/tahunan">Tahunan</a>
<a class="dropdown-item" href="<?php echo base_url()?>index.php/bulanan">Bulanan</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo base_url()?>index.php/kecamatan">Kecamatan</a>
<a class="dropdown-item active" href="<?php echo base_url()?>index.php/kelurahan">Kelurahan <span class="sr-only">(current)</span></a>
</div>
</li>
</ul>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
</ul>
<form methode="POST" action="<?php echo base_url('index.php/')?>login/logout" class="form-inline my-2 my-lg-0" >
<button class="btn btn-outline-light btn-sm my-2 my-sm-0" type="submit">Login</button>
</form>
</div>
</div>
</nav>
<div class="container">
<div class="row mt-3">
<div class="col col-md-12 col-lg-12 col-sm-12 col-12">
<div class="card">
<h5 class="card-header">Laporan</h5>
<div class="card-body">
<div>
<div class="mt-3">
<div>
<form action="" method="POST" class="needs-validation">
<div class="form-group">
<label for="kelurahan">Pilih Kelurahan</label>
<select name="kelurahan" class="form-control" id="kelurahan" onchange="this.form.submit()" required>
<?php foreach($kelurahan_list as $list) {?>
<option value="<?php echo $list->kelurahan ?>" <?php if($list->kelurahan===$kelurahan){echo "selected";}?>>
<?php echo $list->kelurahan ?>
</option>
<?php } ?>
</select>
</div>
</form>
</div>
<?php if($msg!=='empty'){?>
<div class="card">
<div class="card-header bg-primary text-white">
<div class="row">
<div class="col col-12 col-sm-12 col-md-8 col-lg-8">
<h6>Data UMKM Kota Magelang Kelurahan <?php echo $kelurahan ?> <?php echo $tahun ?></h6>
</div>
</div>
</div>
<div class="card-body">
<div class="row">
<table class="table table-bordered table-sm text-center text-nowrap table-responsive table-striped">
<thead>
<tr>
<th class="align-middle" rowspan="3"><small>No</small></th>
<th class="align-middle" rowspan="3"><small>kelurahan</small></th>
<th class="align-middle" rowspan="2" colspan="3"><small>Jml Umkm</small></th>
<th class="align-middle" rowspan="2" colspan="3"><small>Omset/Bulan</small></th>
<th class="align-middle" rowspan="2" colspan="3"><small>Aset</small></th>
<th class="align-middle" rowspan="1" colspan="6"><small>Jml Naker</small></th>
<th class="align-middle" rowspan="1" colspan="9"><small>Klasifikasi</small></th>
</tr>
<tr>
<th colspan="2"><small>P</small></th>
<th colspan="2"><small>J</small></th>
<th colspan="2"><small>I</small></th>
<th colspan="3"><small>P</small></th>
<th colspan="3"><small>J</small></th>
<th colspan="3"><small>I</small></th>
</tr>
<tr>
<th><small>P</small></th>
<th><small>J</small></th>
<th><small>I</small></th>
<th><small>P</small></th>
<th><small>J</small></th>
<th><small>I</small></th>
<th><small>P</small></th>
<th><small>J</small></th>
<th><small>I</small></th>
<th><small>L</small></th>
<th><small>P</small></th>
<th><small>L</small></th>
<th><small>P</small></th>
<th><small>L</small></th>
<th><small>P</small></th>
<th><small>M</small></th>
<th><small>K</small></th>
<th><small>MN</small></th>
<th><small>M</small></th>
<th><small>K</small></th>
<th><small>MN</small></th>
<th><small>M</small></th>
<th><small>K</small></th>
<th><small>MN</small></th>
</tr>
</thead>
<tbody>
<?php
$no=0;
foreach($listlaporan as $laporan){
$no++;
?>
<tr>
<td><small><?php echo $no ?></small></td>
<td class="text-left"><small><?php echo $laporan['kelurahan'] ?></small></td>
<td><small><?php echo $laporan['umkm_jenis1'] ?></small></td>
<td><small><?php echo $laporan['umkm_jenis2'] ?></small></td>
<td><small><?php echo $laporan['umkm_jenis3'] ?></small></td>
<td><small><?php echo rupiah($laporan['omset_jenis1']) ?></small></td>
<td><small><?php echo rupiah($laporan['omset_jenis2']) ?></small></td>
<td><small><?php echo rupiah($laporan['omset_jenis3']) ?></small></td>
<td><small><?php echo rupiah($laporan['aset_jenis1']) ?></small></td>
<td><small><?php echo rupiah($laporan['aset_jenis2']) ?></small></td>
<td><small><?php echo rupiah($laporan['aset_jenis3']) ?></small></td>
<td><small><?php echo $laporan['karyawan_jen1_l'] ?></small></td>
<td><small><?php echo $laporan['karyawan_jen1_p'] ?></small></td>
<td><small><?php echo $laporan['karyawan_jen2_l'] ?></small></td>
<td><small><?php echo $laporan['karyawan_jen2_p'] ?></small></td>
<td><small><?php echo $laporan['karyawan_jen3_l'] ?></small></td>
<td><small><?php echo $laporan['karyawan_jen3_p'] ?></small></td>
<td><small><?php echo $laporan['umkm_jen1_kat1']?></small></td>
<td><small><?php echo $laporan['umkm_jen1_kat2']?></small></td>
<td><small><?php echo $laporan['umkm_jen1_kat3']?></small></td>
<td><small><?php echo $laporan['umkm_jen2_kat1']?></small></td>
<td><small><?php echo $laporan['umkm_jen2_kat2']?></small></td>
<td><small><?php echo $laporan['umkm_jen2_kat3']?></small></td>
<td><small><?php echo $laporan['umkm_jen3_kat1']?></small></td>
<td><small><?php echo $laporan['umkm_jen3_kat2']?></small></td>
<td><small><?php echo $laporan['umkm_jen3_kat3']?></small></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<th colspan="2"><small>Total</small></th>
<th><small><?php echo $umkm_jenis1 ?></small></th>
<th><small><?php echo $umkm_jenis2 ?></small></th>
<th><small><?php echo $umkm_jenis3 ?></small></th>
<th><small><?php echo rupiah($omset_jenis1) ?></small></th>
<th><small><?php echo rupiah($omset_jenis2) ?></small></th>
<th><small><?php echo rupiah($omset_jenis3) ?></small></th>
<th><small><?php echo rupiah($aset_jenis1) ?></small></th>
<th><small><?php echo rupiah($aset_jenis2) ?></small></th>
<th><small><?php echo rupiah($aset_jenis3) ?></small></th>
<th><small><?php echo $karyawan_jen1_l ?></small></th>
<th><small><?php echo $karyawan_jen1_p ?></small></th>
<th><small><?php echo $karyawan_jen2_l ?></small></th>
<th><small><?php echo $karyawan_jen2_p ?></small></th>
<th><small><?php echo $karyawan_jen3_l ?></small></th>
<th><small><?php echo $karyawan_jen3_p ?></small></th>
<th><small><?php echo $umkm_jen1_kat1 ?></small></th>
<th><small><?php echo $umkm_jen1_kat2 ?></small></th>
<th><small><?php echo $umkm_jen1_kat3 ?></small></th>
<th><small><?php echo $umkm_jen2_kat1 ?></small></th>
<th><small><?php echo $umkm_jen2_kat2 ?></small></th>
<th><small><?php echo $umkm_jen2_kat3 ?></small></th>
<th><small><?php echo $umkm_jen3_kat1 ?></small></th>
<th><small><?php echo $umkm_jen3_kat2 ?></small></th>
<th><small><?php echo $umkm_jen3_kat3 ?></small></th>
</tr>
<tr>
<th colspan="26" style="height:1px;">&nbsp;</th>
</tr>
<tr>
<th colspan="2" rowspan="2"><badge>Total</badge></th>
<th colspan="3"><badge>Jml Umkm</badge></th>
<th colspan="3"><badge>Omset/Bln</badge></th>
<th colspan="3"><badge>Aset</badge></th>
<th colspan="6"><badge>Naker</badge></th>
<th colspan="3"><badge>Mikro</badge></th>
<th colspan="3"><badge>Kecil</badge></th>
<th colspan="3"><badge>Menengah</badge></th>
</tr>
<tr>
<th colspan="3"><badge><?php echo $umkm ?></badge></th>
<th colspan="3"><badge><?php echo rupiah($omset) ?></badge></th>
<th colspan="3"><badge><?php echo rupiah($aset) ?></badge></th>
<th colspan="6"><badge><?php echo $karyawan ?></badge></th>
<th colspan="3"><badge><?php echo $umkm_kat1 ?></badge></th>
<th colspan="3"><badge><?php echo $umkm_kat2 ?></badge></th>
<th colspan="3"><badge><?php echo $umkm_kat3 ?></badge></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div class="card">
<div class="card-header bg-primary text-white">
<div class="row">
<div class="col col-12 col-sm-12 col-md-8 col-lg-8">
<h6>Daftar UMKM <?php echo $kelurahan ?> Tahun <?php echo $tahun ?></h6>
</div>
</div>
</div>
<div class="card-body">
<div class="row mt-3 table-responsive">
<table id="tabeldata" class="table table-sm table-bordered table-striped text-center">
<thead>
<tr>
<th class="align-middle" rowspan="2"><small>No</small></th>
<th class="align-middle" rowspan="2"><small>Nama UMKM</small></th>
<th class="align-middle" rowspan="2"><small>Pemilik</small></th>
<th class="align-middle" rowspan="2"><small>Kelurahan</small></th>
<th class="align-middle" rowspan="2"><small>Alamat</small></th>
<th class="align-middle" rowspan="2"><small>Telp</small></th>
<th class="align-middle" rowspan="2"><small>Deskripsi</small></th>
<th class="align-middle" rowspan="2"><small>Jenis</small></th>
<th class="align-middle" rowspan="2"><small>Omset/Bulan</small></th>
<th class="align-middle" rowspan="2"><small>Aset</small></th>
<th class="align-middle" colspan="2"><small>Naker</small></th>
<th class="align-middle" rowspan="2"><small>Skala Usaha</small></th>
</tr>
<tr>
<th><small>L</small></th>
<th><small>P</small></th>
</tr>
</thead>
<tbody>
<?php
$no=0;
foreach($umkmlist as $umkm){
$no++;
$usaha = $this->UmkmModel->getUmkmsById($umkm->id_umkm);
$jenis = $this->JenisModel->getJenisById($umkm->id_jenis);
$kategori = $this->KategoriModel->getKategoriById($umkm->id_kategori);
$listomset = $this->AbsensiModel->getAbsensiByTahunAndUmkmId($umkm->tahun,$umkm->id_umkm);
$ttl_omset=0;
foreach($listomset as $oms){
$ttl_omset = $ttl_omset+$oms->omset;
}
$r_omset = $ttl_omset/12;
?>
<tr>
<td><small><?php echo $no ?></small></td>
<td class="text-left text-nowrap"><small><?php echo $usaha->nama?></small></td>
<td class="text-left text-nowrap"><small><?php echo $umkm->nama?></small></td>
<td class="text-left"><small><?php echo $umkm->kelurahan ?></small></td>
<td class="text-left"><small><?php echo $usaha->alamat ?></small></td>
<td><small><?php echo $usaha->telp ?></small></td>
<td class="text-left"><small><?php echo $usaha->deskripsi ?></small></td>
<td><small><?php echo $jenis->jenis ?></small></td>
<td class="text-left"><small><?php echo rupiah($r_omset) ?></small></td>
<td class="text-left"><small><?php echo rupiah($umkm->aset) ?></small></td>
<td><small><?php echo $umkm->karyawan_l ?></small></td>
<td><small><?php echo $umkm->karyawan_p ?></small></td>
<td><small><?php echo $kategori->kategori ?></small></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<?php } else {?>
<div class="row-container text-center mt-3">
<img src="<?php echo base_url()?>assets/images/search.png" width="150" /><br>
<div class="alert alert-warning" role="alert">
Tidak ada <strong>laporan yang sudah dibuat</strong> saat ini.
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="<?php echo base_url()?>assets/js/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="<?php echo base_url()?>assets/js/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="<?php echo base_url()?>assets/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="<?php echo base_url()?>assets/js/jquery.dataTables.min.js"></script>
<script src="<?php echo base_url()?>assets/js/dataTables.bootstrap4.min.js"></script>
<script src="<?php echo base_url()?>assets/js/sweetalert.min.js"></script>
<script src="<?php echo base_url()?>assets/js/chart.js"></script>
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Aset', 'Omset'],
datasets: [
{
label: '<?php echo $tahun ?>',
data: [<?php echo $aset_1 ?>, <?php echo $omset_1 ?>],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(255, 99, 132, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(255, 99, 132, 1)'
],
borderWidth: 1
},
{
label: '<?php echo $tahun_0 ?>',
data: [<?php echo $aset_0 ?>, <?php echo $omset_0 ?>],
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
'rgba(54, 162, 235, 0.2)'
],
borderColor: [
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)'
],
borderWidth: 1
}
]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
<script>
var ctx = document.getElementById('myChart2').getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Jml UMKM', 'Tenaga Kerja', 'Mikro', 'Kecil','Menengah'],
datasets: [
{
label: '<?php echo $tahun ?>',
data: [<?php echo $umkm_1 ?>, <?php echo $naker_1 ?>, <?php echo $mikro_1 ?>, <?php echo $kecil_1 ?>, <?php echo $menengah_1 ?>],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(255, 99, 132, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(255, 99, 132, 1)'
],
borderWidth: 1
},
{
label: '<?php echo $tahun_0 ?>',
data: [<?php echo $umkm_0 ?>, <?php echo $naker_0 ?>, <?php echo $mikro_0 ?>, <?php echo $kecil_0 ?>, <?php echo $menengah_0 ?>],
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
'rgba(54, 162, 235, 0.2)'
],
borderColor: [
'rgba(54, 162, 235, 1)',
'rgba(54, 162, 235, 1)'
],
borderWidth: 1
}
]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>
<script>
$(document).ready(function() {
$('#tabeldata').DataTable();
} );
</script>
<script>
const element = document.querySelectorAll('#btn_hapus')
element.forEach(function(el){
el.addEventListener('click', function (e) {
e.preventDefault();
var urlToRedirect = e.currentTarget.getAttribute('href'); //use currentTarget because the click may be on the nested i tag and not a tag causing the href to be empty
console.log(urlToRedirect); // verify if this is the right URL
swal({
title: "Kamu yakin ?",
text: "Data yang dihapus tidak bisa dikembalikan.",
icon: "warning",
buttons: [
'Batal',
'Hapus'
],
dangerMode: true,
}).then(function(isConfirm) {
if (isConfirm) {
swal({
title: 'Berhasil',
text: 'Data berhasil terhapus',
icon: 'success'
}).then(function() {
window.location.href = urlToRedirect;
});
} else {
swal("Batal", "Data tidak terhapus.)", "error");
}
});
});
});
</script>
</body>
</html>