<?php 
//error_reporting(0);
ob_start();
session_start();
include("admin/layout/tanggal-indo.php");
?>
<html>
<head> 
<title>Tanda Bukti Pemesanan</title>
</head>
<body style="font-family: Times, Times New Roman, Georgia, serif;">
<?php 

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;
$disetujui = $row->disetujui;
$siangmalam = $row->siangmalam;
$tanggal = new DateTime($tglpakai); 
$sekarang = new DateTime($tglselesai);
$selisihhari = $tanggal->diff($sekarang);

}

//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: 1px dashed #000;
    background: #999;
}

</style>
<?php if($status==0){ ?>
 <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>TANDA BUKTI PEMESANAN</strong></td> 
		</tr>
		<tr>
			<td style="text-align: center;font-size:12pt;color:#00468e;width:85%"><strong>GEDUNG DIKLAT PEMERINTAH KOTA MADIUN </strong></td>
		</tr>
		<tr>
			<td style="text-align: center;font-size:9pt;width:85%"><strong>Jalan Duku No 1 Kota Madiun</strong></td>
		</tr>		
		<tr>
			<td style="text-align: center;font-size:9pt;width:85%">Telp : (0351)  465095, 081 335 125 111</td>
		</tr>					
	</tbody>
</table> 
<?php }else{?>
 <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> 
<?php }?>
 <table  align="center" cellspacing="0" style="font-size: 11pt;">
		<tr>
		<td style="width:95%"><hr></td>
		</tr>
</table> 
 <table  align="center" cellspacing="0" style="font-size: 11pt;">
		<tr>
		<td style="text-align: center;font-size:11pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>BUKTI SEMENTARA</strong></td>
		</tr>
</table>
<table  align="left" cellspacing="5"  border="0" style="font-size: 11pt;margin-top:5;margin-left:15;width:100%" >
	<tbody>
		<tr>
			<td style="width:28%">NOMOR REGISTRASI</td>
			<td style="width:50%">: <?php echo $idpesan;?></td>
		</tr>
		<tr>
			<td>NAMA PEMESAN</td>
			<td>: <?php echo strtoupper($namapesan);?></td>
		</tr>
		<tr>
			<td>KEPALA INSTANSI</td>
			<td>: <?php echo strtoupper($namapemakai);?></td>
		</tr>		
		<tr>
			<td>ALAMAT PEMAKAI</td>
			<td>: <?php echo strtoupper($alamat);?></td>
		</tr>		
		<tr>
			<td>KEGIATAN/ACARA</td>
			<td>: <?php echo strtoupper($keperluan);?></td>
		</tr>
		<tr>
			<td>TGL MULAI </td>
			<td>: <?php echo date('d F Y', strtotime($tglpakai));?></td>
		</tr>
		<tr>
			<td>TGL SELESAI </td>
			<td>: <?php echo date('d F Y', strtotime($tglselesai));?></td>
		</tr>
		<tr>
			<td>WAKTU </td>
			<td>: <?php
			if($siangmalam==0){ echo 'SIANG' ;}
			if($siangmalam==1){ echo 'MALAM' ;}		
			if($siangmalam==2){ echo 'FULL DAY' ;}		
			?></td>
		</tr>					
		<tr>
			<td><strong>STATUS</strong></td>
			<td>: <strong><?php
			if($status==0){ echo 'BARU' ;}
			if($status==1){ echo 'DITERIMA' ;}
			if($status==2){ echo 'DITOLAK' ;}
			
			?></strong></td>
		</tr>		
	</tbody>
</table>
<table  align="left" cellspacing="0"  border="0.5" style="font-size: 11pt;margin-top:5;margin-left:20;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="2" rowspan="1" style="text-align:center;">Perincian</td>
			<td colspan="1" rowspan="3" style="text-align:center;" width="100">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;" width="100">Penggunaan</td>
		</tr>
		<tr>
			<td style="text-align:center;">Jumlah</td>
			<td style="text-align:center;">Hari</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;


?>		
		<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:right;"><?php  echo number_format($harga);?></td>
			<td style="text-align:right;"><?php  $tot[] = ($jumlah * $harga * (( $selisihhari->d)+1 )) ; echo number_format($jumlah * (( $selisihhari->d)+1 ) * $harga );?></td>
		</tr>
<?php }?>	
		<tr>
			<td style="text-align:center;" colspan="5">Grand Total</td>
			<td style="text-align:right;"  width="100"> <?php $gr=array_sum($tot) ;echo number_format($gr);?></td>
		</tr>
	</tbody>
</table>
<table  align="left" cellspacing="0"  border="0" style="font-size: 10pt;margin-top:2;margin-left:20;width:100%" >
	<tbody>
		<tr>
			<td width="75%"><p style="font-style: italic;"><?php
			if($status==0 OR $status==1){ ?>
			* Batas waktu konfirmasi maksimal 3 hari  <?php $currentDate = date('Y-m-d'); echo date('d-m-Y', strtotime('3'.'days', strtotime($currentDate)));?>, pemesan wajib datang ke kantor BKPSDM Kota Madiun dengan<br />&nbsp;&nbsp;&nbsp;membawa tanda 
bukti  pemesanan ini.<br /> 
			
			<?php }?></p></td>
		</tr>				
	</tbody>
</table>

<table  align="left" cellspacing="0"  border="0" style="font-size: 10pt;margin-top:2;margin-left:20;width:100%" >
	<tbody>
		<tr>
			<td width="75%" ><p style="font-style: italic;">*Pemesanan Tanpa Uang Muka Dan Pembayaran Non Tunai Transfer ke "RET PAD BANGUNAN BKPSDM"   <br/> <strong>Bank Jatim, No. Rekening 0059666665</strong></p></td>
		</tr>						
	</tbody>
</table>
<?php
//Diterima
if($status==1 AND $disetujui==1){ 
?>
<table  align="left" cellspacing="0"  border="0" style="font-size: 11pt;margin-top:5;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, '. tgl_indo(date('Y-m-d')); // 21 Oktober 2017;?></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>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>		
		<tr>
			<td></td>
			<td style="text-align:center;"><?php echo $nama?></td>
		</tr>
		<tr>
			<td></td>
			<td style="text-align:center;">___________________</td>
		</tr>			
		<tr>
			<td></td>
			<td style="text-align:center;"><?php echo $nip?></td>
		</tr>			
	</tbody>
</table>
<?php }else{?>
			
<table  align="left" cellspacing="0"  border="0" style="font-size: 11pt;margin-top:50;margin-left:550;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, '. tgl_indo(date('Y-m-d')); // 21 Oktober 2017;?></td>
		</tr>
		<tr>
			<td></td>
			<td style="text-align:center;"><?php echo 'Pemesan';?></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>		
		<tr>
			<td></td>
			<td style="text-align:center;"><?php echo $namapesan;?></td>
		</tr>
		<tr>
			<td></td>
			<td style="text-align:center;">___________________</td>
		</tr>				
	</tbody>
</table>
<?php }?>
</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('PESAN-'.$idpesan.''.$title.'.pdf', 'D'); 

?>
