<?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">

<link rel="icon" type="image/png" href="../../assets/images/favicon.png" />

<title>Aplikasi UMKM</title>
<style>
    table{
        border:solid 1px black;
        padding-right:5px;
        padding-left:5px;
        margin-top:10px;
        margin-bottom:20px;
        text-align: center;
        width:1500px;
    }
    th{
        padding-right:1px;
        padding-left:1px;
        padding-top:2px;
        padding-bottom:2px;
        border:solid 1px black;
    }
    thead{
        background-color: #ccc;
    }
    td{
        padding-right:1px;
        padding-left:1px;
        padding-top:2px;
        padding-bottom:2px;
        text-align: center;
        border:solid 1px black;
    }
    .judul{
        font-weight: bold;
        text-align: center;
        width: 1500px;
        font-size: 20px;
    }
    .spasi{
        height:40px;
        content: '&nbsp;';
        min-height: 40px;
    }
</style>
</head>
<body>  
    <?php
        header("Content-type: application/vnd-ms-excel");
        header("Content-Disposition: attachment; filename=Rekap_Data_UMKM_Kota_MGL_". $tahun.".xls");
	?>   
        <div class="spasi">&nbsp;</div>            
        <div class="judul">
            REKAP DATA UMKM TAHUN <?php echo $tahun ?> <br>
            KOTA MAGELANG
        </div>
        <div class="spasi">&nbsp;</div>
        <?php if($msg!=='empty'){?>
            <div>
                <table>
                    <thead>
                            <tr>
                                <th colspan="3">Jumlah UMKM</th>
                                <th colspan="3">Omset/Bulan</th>
                                <th colspan="3">Aset</th>
                                <th colspan="6" >Jumlah Naker</th>
                                <th colspan="9" >Klasifikasi</th>
                            </tr>

                            
                        
                            <tr>
                                <th rowspan="2">P</th>
                                <th rowspan="2">J</th>
                                <th rowspan="2">I</th>

                                <th rowspan="2">P</th>
                                <th rowspan="2">J</th>
                                <th rowspan="2">I</th>

                                <th rowspan="2">P</th>
                                <th rowspan="2">J</th>
                                <th rowspan="2">I</th>

                                <th colspan="2">P</th>
                                <th colspan="2">J</th>
                                <th colspan="2">I</th>

                                <th colspan="3">P</th>
                                <th colspan="3">J</th>
                                <th colspan="3">I</th>
                            </tr>

                            <tr>
                                <th>L</th>
                                <th>P</th>

                                <th>L</th>
                                <th>P</th>

                                <th>L</th>
                                <th>P</th>

                                <th>MK</th>
                                <th>K</th>
                                <th>MN</th>

                                <th>MK</th>
                                <th>K</th>
                                <th>MN</th>

                                <th>MK</th>
                                <th>K</th>
                                <th>MN</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><?php echo $umkm_jen1 ?></td>
                                <td><?php echo $umkm_jen2 ?></td>
                                <td><?php echo $umkm_jen3 ?></td>

                                <td><?php echo rupiah($omset_bln_jen1) ?></td>
                                <td><?php echo rupiah($omset_bln_jen2) ?></td>
                                <td><?php echo rupiah($omset_bln_jen3) ?></td>

                                <td><?php echo rupiah($aset_jen1) ?></td>
                                <td><?php echo rupiah($aset_jen2) ?></td>
                                <td><?php echo rupiah($aset_jen3) ?></td>

                                <td><?php echo $naker_jen1_l ?></td>
                                <td><?php echo $naker_jen1_p ?></td>

                                <td><?php echo $naker_jen2_l ?></td>
                                <td><?php echo $naker_jen2_p ?></td>

                                <td><?php echo $naker_jen3_l ?></td>
                                <td><?php echo $naker_jen3_p ?></td>

                                <td><?php echo $umkm_jen1_ket1?></td>
                                <td><?php echo $umkm_jen1_ket2?></td>
                                <td><?php echo $umkm_jen1_ket3?></td>
                                <td><?php echo $umkm_jen2_ket1?></td>
                                <td><?php echo $umkm_jen2_ket2?></td>
                                <td><?php echo $umkm_jen2_ket3?></td>
                                <td><?php echo $umkm_jen3_ket1?></td>
                                <td><?php echo $umkm_jen3_ket2?></td>
                                <td><?php echo $umkm_jen3_ket3?></td>

                            </tr>
                        </tbody>
                        <tfoot>
                            <tr>
                                <th colspan="3">Total</th>
                                <th colspan="3">Total</th>
                                <th colspan="3">Total</th>
                                <th colspan="6">Total</th>
                                <th colspan="3">Mikro</th>
                                <th colspan="3">Kecil</th>
                                <th colspan="3">Menengah</th>
                            </tr>
                            <?php 
                                $umkm = $umkm_jen1+$umkm_jen2+$umkm_jen3;
                                $omset = $omset_bln_jen1+$omset_bln_jen2+$omset_bln_jen3;

                                $naker = $naker_jen1_l+$naker_jen2_l+$naker_jen3_l;
                                $naker = $naker+$naker_jen1_p+$naker_jen2_p+$naker_jen3_p;
                                $aset = $aset_jen1+$aset_jen2+$aset_jen3;

                                $mikro = $umkm_jen1_ket1+$umkm_jen2_ket1+$umkm_jen3_ket1;
                                $kecil = $umkm_jen1_ket2+$umkm_jen2_ket2+$umkm_jen3_ket2;
                                $menengah = $umkm_jen1_ket3+$umkm_jen2_ket3+$umkm_jen3_ket3;
                            ?>
                            <tr>
                                <th colspan="3"><?php echo $umkm ?></th>
                                <th  colspan="3"><?php echo rupiah($omset) ?></th>
                                <th colspan="3"><?php echo rupiah($aset) ?></th>
                                <th colspan="6" ><?php echo $naker ?></th>
                                <th colspan="3"><?php echo $mikro ?></th>
                                <th colspan="3"><?php echo $kecil ?></th>
                                <th colspan="3"><?php echo $menengah ?></th>
                            </tr>
                        </tfoot>
                </table>
            </div>
            <div class="spasi">&nbsp;</div>
            <?php if(isset($tahun_0)){?>
            <div class="judul">
               PERBANDINGAN DENGAN TAHUN <?php echo $tahun_0 ?>
            </div>
            <div class="spasi">&nbsp;</div>
            <div>
                <table>
                    <thead>
                        <tr>
                            <th></th>
                            <th>Aset</th>
                            <th>Omset</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><?php echo $tahun ?></td>
                            <td><?php echo rupiah($aset_1) ?></td>
                            <td><?php echo rupiah($omset_1) ?></td>
                        </tr>
                        <tr>
                            <td><?php echo $tahun_0 ?></td>
                            <td><?php echo rupiah($aset_0) ?></td>
                            <td><?php echo rupiah($omset_0) ?></td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="spasi">&nbsp;</div>
            <div>
                <table>
                    <thead>
                        <tr>
                            <th></th>
                            <th>Jml UMKM</th>
                            <th>Tenaga Kerja</th>
                            <th>Mikro</th>
                            <th>Kecil</th>
                            <th>Menengah</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><?php echo $tahun ?></td>
                            <td><?php echo $umkm_1 ?></td>
                            <td><?php echo $naker_1 ?></td>
                            <td><?php echo $mikro_1 ?></td>
                            <td><?php echo $kecil_1 ?></td>
                            <td><?php echo $menengah_1 ?></td>
                        </tr>
                        <tr>
                            <td><?php echo $tahun ?></td>
                            <td><?php echo $umkm_0 ?></td>
                            <td><?php echo $naker_0 ?></td>
                            <td><?php echo $mikro_0 ?></td>
                            <td><?php echo $kecil_0 ?></td>
                            <td><?php echo $menengah_0 ?></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        <?php } ?>

        <?php } else {?>      
            <div>Tidak ada laporan yang sudah dibuat saat ini.</div>
        <?php } ?>


</body>
</html>