<?php 
//error_reporting(0);
ob_start();
session_start();
include("admin/layout/tanggal-indo.php");
?>
<html>
<head> 
<title>Formulir Permohonan Sewa Gedung</title>
</head>
<body style="font-family: Times, Times New Roman, Georgia, serif;">
<?php 
function penyebut($nilai) {
		$nilai = abs($nilai);
		$huruf = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
		$temp = "";
		if ($nilai < 12) {
			$temp = " ". $huruf[$nilai];
		} else if ($nilai <20) {
			$temp = penyebut($nilai - 10). " belas";
		} else if ($nilai < 100) {
			$temp = penyebut($nilai/10)." puluh". penyebut($nilai % 10);
		} else if ($nilai < 200) {
			$temp = " seratus" . penyebut($nilai - 100);
		} else if ($nilai < 1000) {
			$temp = penyebut($nilai/100) . " ratus" . penyebut($nilai % 100);
		} else if ($nilai < 2000) {
			$temp = " seribu" . penyebut($nilai - 1000);
		} else if ($nilai < 1000000) {
			$temp = penyebut($nilai/1000) . " ribu" . penyebut($nilai % 1000);
		} else if ($nilai < 1000000000) {
			$temp = penyebut($nilai/1000000) . " juta" . penyebut($nilai % 1000000);
		} else if ($nilai < 1000000000000) {
			$temp = penyebut($nilai/1000000000) . " milyar" . penyebut(fmod($nilai,1000000000));
		} else if ($nilai < 1000000000000000) {
			$temp = penyebut($nilai/1000000000000) . " trilyun" . penyebut(fmod($nilai,1000000000000));
		}     
		return $temp;
	}
	function terbilang($nilai) {
		if($nilai<0) {
			$hasil = "minus ". trim(penyebut($nilai));
		} else {
			$hasil = trim(penyebut($nilai));
		}     		
		return $hasil;
	}
foreach($tampil->result() as $row){ 
$idpesan = $row->idpesan;
$namapesan = $row->namapesan;
$namapemakai = $row->namapemakai;
$alamat = $row->alamat;
$keperluan = $row->keperluan;
$status = $row->status;
$tglpakai = $row->tglpakai;
$tglselesai = $row->tglselesai;
$jampakai = $row->jampakai;
$pemkot = $row->pemkot;
$siangmalam = $row->siangmalam;
$tanggal = new DateTime($tglpakai); 
$sekarang = new DateTime($tglselesai);
$selisihhari = $tanggal->diff($sekarang);
//bayar
$dp1 = $row->dp1;
$dp2 = $row->dp2;
$tgldp1 = $row->tgldp1;
$tgldp2 = $row->tgldp2;
if($tgldp2  == "0000-00-00"){
	$dpok = $row->dp1;
	$tglok = $tgldp1;
}
if($tgldp1  == "0000-00-00"){
	$dpok = $row->dp2;
	$tglok = $tgldp2;
}
if($tgldp1  != "0000-00-00"  AND  $tgldp2  != "0000-00-00" ){
	$dpok = $row->dp2;
	$tglok = $tgldp2;
}

}
//ttd 
?>
<style type="text/css">
hr.style-one {
border-color: black;border-width: 0.5px 0 0 0;
}
hr.style-three {
    border: 0;
    border-bottom: 0.5px dashed #000;
    background: #999;
}
@media print{
   .noprint{
       display:none;
   }
}
.button {
  background-color: #4CAF50;
  border: none;
  color: white;
  padding: 10px 14px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 12px;
  margin: 4px 2px;
  cursor: pointer;
}
</style>
 <table  align="center" cellspacing="0" style="font-size: 11pt;margin-top:5%;width:100%" >
	<tbody>
		<tr align="center">
			<td rowspan="5" align="center" style="width:10%"><img src="images/logokotamadiun.jpg" alt="logokotamadiun" width="80" height="90"></td>
			<td style="text-align: center;font-size:14pt;width: 140mm;color:#00468e; width:85%"><strong>PEMERINTAH KOTA MADIUN</strong></td> 
		</tr>
		<tr> 
			<td style="text-align: center;font-size:12pt;color:#00468e;width:85%"><strong>BADAN KEPEGAWAIAN DAN PENGEMBANGAN SUMBER DAYA MANUSIA </strong></td>
		</tr>
		<tr>
			<td style="text-align: center;font-size:9pt;width:85%"><strong>Jalan Mastrip Nomor 25 Madiun, Kode Pos: 63132 Jawa Timur</strong></td>
		</tr>		
		<tr>
			<td style="text-align: center;font-size:9pt;width:85%">Telephon (0351) 462230 Fax (0351) 496964 </td>
		</tr>		
		<tr>
			<td style="text-align: center;font-size:9pt;width:85%">Website : bkd.madiunkota.go.id</td>
		</tr>			
	</tbody>
</table> 
 <table  align="center" cellspacing="0" style="font-size: 11pt;margin-top:5%;width:100%" >
	<tbody>
		<tr>
			<td colspan="3" style="text-align: center;font-size:11pt;"><hr class="style-one"/></td>
		</tr>	
		<tr>
			<td colspan="3" style="text-align: center;font-size:11pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>BUKTI KWITANSI PEMBAYARAN</u></strong></td>
		</tr>
		<tr>
			<td  style="width:35%;"></td>
			<td style="width:65%;text-align: right;font-size:11pt;"></td>
		</tr>		
	</tbody>
</table>
 <table   border="0" cellspacing="0" style="font-size: 11pt;margin-top:5%;width:100%" >
	<tbody>
		<tr>
			<td ><b>Telah terima dari</b></td>
			<td width="300">: <?php echo strtoupper($namapemakai);?> </td>
			<td rowspan="1" width="347" align="right"><strong>No. Registrasi </strong>: <?php echo $idpesan;?></td>
		</tr>
		<tr>
			<td></td>
			<td colspan="2" width="347" align="right"><em>&nbsp; <strong>Terbilang</strong> : <?php echo terbilang($dpok) .' rupiah'; ?> </em></td>
		</tr>	
	</tbody>
</table>
<hr class="style-one">
<table  align="left" cellspacing="0"  border="0.5" style="font-size: 11pt;margin-top:5;width:100%" >
	<tbody>
		<tr>
			<td colspan="1" rowspan="3" style="text-align:center;">No</td>
			<td colspan="1" rowspan="3" style="text-align:center;width:50%;">Uraian</td>
			<td colspan="4" rowspan="1" style="text-align:center;">Perincian</td>
			<td colspan="1" rowspan="3" style="text-align:center;">Harga Satuan</td>
			<td colspan="1" rowspan="3" style="text-align:center;">Jumlah</td>
		</tr>
		<tr>
			<td colspan="2" rowspan="1" style="text-align:center;">Penggunaan</td>
			<td colspan="2" rowspan="1" style="text-align:center;">Waktu</td>
		</tr>
		<tr>
			<td style="text-align:center;">Jumlah</td>
			<td style="text-align:center;">Hari</td>
			<td style="text-align:center;">Siang</td>
			<td style="text-align:center;">Sore</td>
		</tr>
<?php 
//tanggal cetak
$tgl=date('d');
$tahun=date('Y');
$bulan=date('m');
$no=0; 
foreach($tampil2->result() as $row2){ 
$no++;
$namafasilitas = $row2->namafasilitas;
$harga = $row2->harga;
$jumlah = $row2->jumlah;
$subtotal = $row2->subtotal;
$pemkot = $row2->pemkot;
?>		
		<tr>
			<td style="text-align:center;"><?php echo $no;?></td>
			<td style="text-align:left;"><?php echo $namafasilitas ;?></td>
			<td style="text-align:center;"><?php echo $jumlah ;?></td>
			<td style="text-align:center;"><?php echo ($selisihhari->d)+1;?></td>
			<td style="text-align:center;"><?php if($siangmalam=='0'){ echo 'v' ;}  if($siangmalam=='2'){ echo 'v' ;} ?></td>
			<td style="text-align:center;"><?php  if($siangmalam=='1'){ echo 'v' ;} if($siangmalam=='2'){ echo 'v' ;} ?></td>
			<td style="text-align:right;"><?php  echo number_format($harga);?></td>
			<td style="text-align:right;"><?php $sub[] = ($jumlah * $harga * (( $selisihhari->d)+1 )) ; echo number_format($jumlah * (( $selisihhari->d)+1 ) * $harga );;?></td>
		</tr>
<?php }?>	
		<tr>
			<td style="text-align:left;" colspan="7">Total Harga</td>
			<td style="text-align:right;" width="138"><?php  $totalharga = array_sum($sub); echo number_format($totalharga);?></td>
		</tr>
		<tr>
			<td style="text-align:left;" colspan="7">Potongan Instansi Pemerintah Kota Madiun</td>
			<td style="text-align:right;" width="138"><?php if($pemkot==1){  $pot = (array_sum($sub)-array_sum($sub) * 50/100); }else{ $pot = 0; ;} echo '-'. number_format($pot) ;?></td>
		</tr>
		<tr>
			<td style="text-align:left;" colspan="7">Grand Total</td>
			<td style="text-align:right;" width="138"><?php $tot=array_sum($sub) - $pot ;echo number_format($tot);?></td>
		</tr>
		<!--
		<tr>
			<td style="text-align:left;" colspan="7">D.P</td>
			<td style="text-align:right;" width="138"><?php  number_format ($dp1+$dp2);?></td>
		</tr>		
		<tr>
			<td style="text-align:left;" colspan="7">Kekurangan</td>
			<td style="text-align:right;" width="138"><?php  number_format ($tot-($dp1+$dp2));?></td>
		</tr>-->	
	</tbody>
</table>

<table  align="left" cellspacing="0"  border="0" style="font-size: 11pt;margin-top:10;" >	
	<tbody>		
		<tr>
			<td>Kegiatan / Acara :</td>
			<td style="text-align:left; width: 350px;"><?php echo $keperluan;?></td>
		</tr>							
	</tbody>
</table>


<table  align="left" cellspacing="0"  border="0" style="font-size: 11pt;margin-top:10;" >	
	<tbody>
		<tr>
			<td>Tanggal Mulai </td>
			<td style="text-align:left;">&nbsp;&nbsp;: <?php echo tgl_indo(date($tglpakai));?></td>
		</tr>
		<tr>
			<td>Tanggal Selesai </td>
			<td style="text-align:left;">&nbsp;&nbsp;: <?php echo tgl_indo(date($tglselesai));?></td>
		</tr>									
	</tbody>
</table>

<table  align="left" cellspacing="0"  border="0" style="font-size: 11pt;margin-top:-65;margin-left:435;width:100%" >	
	<tbody>
		<tr>
			<td width="75%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td width="25%" style="text-align:center;"><?php echo 'Madiun, ' ;?>&nbsp;<span style="color:white">AAAAAAAAA</span></td>
		</tr>
		<tr>
			<td></td>
			<td style="text-align:center;"><?php echo $headerttd?></td>
		</tr>
		<tr>
			<td></td>
			<td style="text-align:center;"><?php echo $sebagai?></td>
		</tr>	
		<tr>
			<td><p style="margin-bottom:30px"><br /><br /><br /></p></td>
		</tr>		
		<tr>
			<td></td>
			<td style="text-align:center;">
			<?php echo $nama?>
			<p style="margin-top:-10px">___________________ </p>
			<p style="margin-top:-10px"><?php echo $nip?></p></td>
		</tr>						
	</tbody>
</table>
<table  align="left" cellspacing="0"  style="font-size: 10pt;margin-top:5;width:100%" >
	<tbody>
		<tr>
			<td width="75%">*Kwitansi untuk :<b> Administrasi</b> </td>
		</tr>	
	</tbody>
</table>
<hr class="style-three">
<table  align="center" cellspacing="0" style="font-size: 11pt;margin-top:5%;width:100%" >
	<tbody>
		<tr align="center">
			<td rowspan="5" align="center" style="width:10%"><img src="images/logokotamadiun.jpg" alt="logokotamadiun" width="80" height="90"></td>
			<td style="text-align: center;font-size:14pt;width: 140mm;color:#00468e; width:85%"><strong>PEMERINTAH KOTA MADIUN</strong></td> 
		</tr>
		<tr> 
			<td style="text-align: center;font-size:12pt;color:#00468e;width:85%"><strong>BADAN KEPEGAWAIAN DAN PENGEMBANGAN SUMBER DAYA MANUSIA </strong></td>
		</tr>
		<tr>
			<td style="text-align: center;font-size:9pt;width:85%"><strong>Jalan Mastrip Nomor 25 Madiun, Kode Pos: 63132 Jawa Timur</strong></td>
		</tr>		
		<tr>
			<td style="text-align: center;font-size:9pt;width:85%">Telephon (0351) 462230 Fax (0351) 496964 </td>
		</tr>		
		<tr>
			<td style="text-align: center;font-size:9pt;width:85%">Website : bkd.madiunkota.go.id</td>
		</tr>			
	</tbody>
</table> 
 <table  align="center" cellspacing="0" style="font-size: 11pt;margin-top:5%;width:100%" >
	<tbody>
		<tr>
			<td colspan="3" style="text-align: center;font-size:11pt;"><hr class="style-one"/></td>
		</tr>	
		<tr>
			<td colspan="3" style="text-align: center;font-size:11pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong><u>BUKTI KWITANSI PEMBAYARAN</u></strong></td>
		</tr>
		<tr>
			<td  style="width:35%;"></td>
			<td style="width:65%;text-align: right;font-size:11pt;"></td>
		</tr>		
	</tbody>
</table>
 <table   border="0" cellspacing="0" style="font-size: 11pt;margin-top:5%;width:100%" >
	<tbody>
		<tr>
			<td ><b>Telah terima dari</b></td>
			<td width="300">: <?php echo strtoupper($namapemakai);?> </td>
			<td rowspan="1" width="347" align="right"><strong>No. Registrasi </strong>: <?php echo $idpesan;?></td>
		</tr>
		<tr>
			<td></td>
			<td colspan="2" width="347" align="right"><em>&nbsp; <strong>Terbilang</strong> : <?php echo terbilang($dpok) .' rupiah'; ?> </em></td>
		</tr>	
	</tbody>
</table>
<hr class="style-one">
<table  align="left" cellspacing="0"  border="0.5" style="font-size: 11pt;margin-top:5;width:100%" >
	<tbody>
		<tr>
			<td colspan="1" rowspan="3" style="text-align:center;">No</td>
			<td colspan="1" rowspan="3" style="text-align:center;width:50%;">Uraian</td>
			<td colspan="4" rowspan="1" style="text-align:center;">Perincian</td>
			<td colspan="1" rowspan="3" style="text-align:center;">Harga Satuan</td>
			<td colspan="1" rowspan="3" style="text-align:center;">Jumlah</td>
		</tr>
		<tr>
			<td colspan="2" rowspan="1" style="text-align:center;">Penggunaan</td>
			<td colspan="2" rowspan="1" style="text-align:center;">Waktu</td>
		</tr>
		<tr>
			<td style="text-align:center;">Jumlah</td>
			<td style="text-align:center;">Hari</td>
			<td style="text-align:center;">Siang</td>
			<td style="text-align:center;">Sore</td>
		</tr>
<?php 
//tanggal cetak
$tgl=date('d');
$tahun=date('Y');
$bulan=date('m');
$no=0; 
foreach($tampil2->result() as $row1){ 
$no++;
$namafasilitas = $row1->namafasilitas;
$harga = $row1->harga;
$jumlah = $row1->jumlah;
$subtotal = $row1->subtotal;
$pemkot = $row1->pemkot;
?>		
		<tr>
			<td style="text-align:center;"><?php echo $no;?></td>
			<td style="text-align:left;"><?php echo $namafasilitas ;?></td>
			<td style="text-align:center;"><?php echo $jumlah ;?></td>
			<td style="text-align:center;"><?php echo ($selisihhari->d)+1;?></td>
			<td style="text-align:center;"><?php if($siangmalam=='0'){ echo 'v' ;}  if($siangmalam=='2'){ echo 'v' ;} ?></td>
			<td style="text-align:center;"><?php  if($siangmalam=='1'){ echo 'v' ;} if($siangmalam=='2'){ echo 'v' ;} ?></td>
			<td style="text-align:right;"><?php  echo number_format($harga);?></td>
			<td style="text-align:right;"><?php $sub2[] = ($jumlah * $harga * (( $selisihhari->d)+1 )) ; echo number_format($jumlah * (( $selisihhari->d)+1 ) * $harga );;?></td>
		</tr>
<?php }?>	
		<tr>
			<td style="text-align:left;" colspan="7">Total Harga</td>
			<td style="text-align:right;" width="138"><?php  $totalharga2 = array_sum($sub2); echo number_format($totalharga2);?></td>
		</tr>
		<tr>
			<td style="text-align:left;" colspan="7">Potongan Instansi Pemerintah Kota Madiun</td>
			<td style="text-align:right;" width="138"><?php if($pemkot==1){  $pot2 = (array_sum($sub2)-array_sum($sub2) * 50/100); }else{ $pot = 0; ;} echo '-'. number_format($pot2) ;?></td>
		</tr>
		
		<tr>
			<td style="text-align:left;" colspan="7">Grand Total</td>
			<td style="text-align:right;" width="138"><?php $tot2=array_sum($sub2) - $pot2 ;echo number_format($tot2);?></td>
		</tr>
		<!--
		<tr>
			<td style="text-align:left;" colspan="7">D.P</td>
			<td style="text-align:right;" width="138"><?php echo number_format ($dp1+$dp2);?></td>
		</tr>		
		<tr>
			<td style="text-align:left;" colspan="7">Kekurangan</td>
			<td style="text-align:right;" width="138"><?php echo number_format ($tot2-($dp1+$dp2));?></td>
		</tr>-->	
	</tbody>
</table>


<table  align="left" cellspacing="0"  border="0" style="font-size: 11pt;margin-top:10;" >	
	<tbody>		
		<tr>
			<td>Kegiatan / Acara :</td>
			<td style="text-align:left; width: 350px;"><?php echo $keperluan;?></td>
		</tr>							
	</tbody>
</table>


<table  align="left" cellspacing="0"  border="0" style="font-size: 11pt;margin-top:10;" >	
	<tbody>
		<tr>
			<td>Tanggal Mulai </td>
			<td style="text-align:left;">&nbsp;&nbsp;: <?php echo tgl_indo(date($tglpakai));?></td>
		</tr>
		<tr>
			<td>Tanggal Selesai </td>
			<td style="text-align:left;">&nbsp;&nbsp;: <?php echo tgl_indo(date($tglselesai));?></td>
		</tr>									
	</tbody>
</table>

<table  align="left" cellspacing="0"  border="0" style="font-size: 11pt;margin-top:-65;margin-left:435;width:100%" >	
	<tbody>
		<tr>
			<td width="75%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td width="25%" style="text-align:center;"><?php echo 'Madiun, ' ;?>&nbsp;<span style="color:white">AAAAAAAAA</span></td>
		</tr>
		<tr>
			<td></td>
			<td style="text-align:center;"><?php echo $headerttd?></td>
		</tr>
		<tr>
			<td></td>
			<td style="text-align:center;"><?php echo $sebagai?></td>
		</tr>	
		<tr>
			<td><p style="margin-bottom:30px"><br /><br /><br /></p></td>
		</tr>		
		<tr>
			<td></td>
			<td style="text-align:center;">
			<?php echo $nama?>
			<p style="margin-top:-10px">___________________ </p>
			<p style="margin-top:-10px"><?php echo $nip?></p></td>
		</tr>						
	</tbody>
</table>
<table  align="left" cellspacing="0"  style="font-size: 10pt;margin-top:5;width:100%" >
	<tbody>
		<tr>
			<td width="75%">*Kwitansi untuk :<b> Pemesan</b> </td>
		</tr>	
	</tbody>
</table>
<hr class="style-three">
</body>
</html>
<?php
$html = ob_get_contents();
ob_end_clean();
require_once('html2pdf/html2pdf.class.php');
//new HTML2PDF('P','A4','fr', false, 'ISO-8859-15',array(30, 0, 20, 0)); //setting ukuran kertas dan margin pada dokumen anda
/*$width_in_inches = 8,27;
$height_in_inches = 12,99;
$width_in_mm = $width_in_inches * 25.4; 
$height_in_mm = $height_in_inches * 25.4; 
$pdf= new HTML2PDF('P', array($width_in_mm,$height_in_mm), 'en', true, 'UTF-8', array(0, 0, 0, 0));*/
//$pdf = new HTML2PDF('P','F4','en');
$pdf = new HTML2PDF('P','Legal','fr', false, 'ISO-8859-15',array(5, 10, 5, 5)); //setting ukuran kertas dan margin pada dokumen anda
$pdf->WriteHTML($html);
$pdf->Output('KWITANSI-'.$idpesan.''.$title.'.pdf', 'D'); 
?>
