<html>
<head> 
<title>Formulir Permohonan Sewa Gedung</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;
$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: 1px 0 0 0;
}
hr.style-three {
    border: 0;
    border-bottom: 1px dashed #000;
    background: #999;
}
@media  hr.style-one {
border-color: black;border-width: 2px 0 0 0;
}
hr.style-three {
    border: 0;
    border-bottom: 1px dashed #000;
    background: #999;
}
@media print{
   .noprint{
       display:none;
   }
}
@media  .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>
<body style="font-family: Verdana, Geneva, sans-serif;">
<table border="0" cellpadding="0" cellspacing="0" style="width:650px;margin-left: auto;margin-right: auto; font-size:12px;" class="noprint">
		<tr>
			<td style="text-align: center;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button onclick="myFunction()" class="button">Cetak</button></td>
		</tr>
		<tr>
			<td style="text-align: center;">&nbsp;</td>
		</tr>		
	</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="width:1300px;margin-left: auto;margin-right: auto; font-size:12px;">	
	<tbody>
		<tr align="center">
			<td rowspan="5" align="center" style="width:10%"><img src="<?php echo base_url();?>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>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> 
<table border="0" cellpadding="0" cellspacing="0" style="width:1300px;margin-left: auto;margin-right: auto; font-size:12px;">	
		<tr>
			<td style="text-align: center;"><hr class="style-one"></td>
		</tr>		
	</tbody>
</table>
<table border="1" cellpadding="0" cellspacing="0" style="width:1300px;margin-left: auto;margin-right: auto; font-size:12px;">	
	<tbody>
		<tr>
			<td style="text-align: center;background-color: #349467; color: #FFF;">No</td>
			<td style="text-align: center;background-color: #349467; color: #FFF;">Nama Pemakai</td>
			<td style="text-align: center;background-color: #349467; color: #FFF;">Hp&nbsp;</td>
			<td style="text-align: center;background-color: #349467; color: #FFF;">Alamat</td>
			<td style="text-align: center;background-color: #349467; color: #FFF;">Tgl Pakai</td>
			<td style="text-align: center;background-color: #349467; color: #FFF;">Tgl Selesai</td>
			<td style="text-align: center;background-color: #349467; color: #FFF;">Tgl.Dp1</td>
			<td style="text-align: center;background-color: #349467; color: #FFF;">Tgl.Dp2</td>
			<td style="text-align: center;background-color: #349467; color: #FFF;">Status Pembayaran</td>
		</tr>
<?php 
$no=0;
foreach($tampil->result() as $row){ 
$no++;
$idpesan = $row->idpesan;
$namapesan = $row->namapesan;
$namapemakai = $row->namapemakai;
$alamat = $row->alamat;
$hppakai = $row->hppakai;
$keperluan = $row->keperluan;
$status = $row->status;
$tglpakai = $row->tglpakai;
$tglselesai = $row->tglselesai;
$jampakai = $row->jampakai;
$tanggal = new DateTime($tglpakai); 
$sekarang = new DateTime($tglselesai);
$selisihhari = $tanggal->diff($sekarang);
$tgldp1 = $row->tgldp1;
$tgldp2 = $row->tgldp2;
//bayar
$dp1 = $row->dp1;
$dp2 = $row->dp2;
$pemkot = $row->pemkot;
$statusdp = $row->statusdp;
?>		
		<tr>
			<td  style="text-align: center;"><?php echo $no;?></td>
			<td><?php echo ucwords($namapemakai);?></td>
			<td style="text-align: center;"><?php echo ucwords($hppakai);?></td>
			<td><?php echo ucwords($alamat);?></td>
			<td style="text-align: center;"><?php echo date('d F Y', strtotime($tglpakai)) ;?></td>
			<td style="text-align: center;"><?php echo date('d F Y', strtotime($tglselesai));  ?></td>
			<td style="text-align: center;"><?php  if($tgldp1!='0000-00-00'){ echo date('d F Y', strtotime($tgldp1));}else{ echo '-' ;}?></td>
			<td style="text-align: center;"><?php  if($tgldp2!='0000-00-00'){  echo date('d F Y', strtotime($tgldp2));} else{ echo '-' ;}?></td>
			<td style="text-align: center; <?php if($statusdp==0){ echo 'background-color: #e04646; color: #FFF;';}else{ echo 'background-color: #737171; color: #FFF;'; } ?>"><?php if($statusdp==0){ echo 'Belum Lunas' ;}else{ echo 'Lunas' ;}?></td>
		</tr>
		<tr>
			<td style="text-align: center;background-color: #349467; color: #FFF;">&nbsp;</td>
			<td style="text-align: center;background-color: #349467; color: #FFF;">Fasilitas</td>
			<td style="text-align: center;background-color: #349467; color: #FFF;">Harga</td>
			<td  style="text-align: center;background-color: #349467; color: #FFF;">Jumlah</td>
			<td  style="text-align: center;background-color: #349467; color: #FFF;">Hari</td>
			<td colspan="6" rowspan="1"  style="text-align: center;background-color: #349467; color: #FFF;">Subtotal</td>
		</tr>
<?php
$x = 0;
$tampil2 = $this->m_laporan-> tampillaporandetail($idpesan);
$no2=0;  
$x = 0;
foreach($tampil2->result() as $row2){
$no2++;
$subtotal[] = $row2->subtotal;
$x = 0;
$x = array_sum($subtotal);


?>
		<tr>
			<td style="text-align: center;">&nbsp;</td>
			<td><?php  echo $no2.') '.$row2->namafasilitas; ?></td>
			<td style="text-align: center;"><?php echo  number_format($row2->harga); ?></td>
			<td style="text-align: center;"><?php echo $row2->jumlah; ?></td>
			<td style="text-align: center;"><?php echo ($selisihhari->d+1);?></td>
			<td colspan="6" rowspan="1" style="text-align: right;"><?php $sub[] = (($selisihhari->d)+1) * $row2->harga * $row2->jumlah; echo number_format( (($selisihhari->d)+1) *  $row2->harga * $row2->jumlah);?></td>
		</tr>
<?php }?>	
		<tr>
			<td>&nbsp;</td>
			<td style="text-align: left;background-color: #349467; color: #FFF;">Total</td>
			<td colspan="9" rowspan="1" style="text-align: right;"><?php $tot=$x ;echo number_format($tot);?></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td style="text-align: left;background-color: #349467; color: #FFF;">Potongan</td>
			<td colspan="9" rowspan="1" style="text-align: right;"><?php if($pemkot ==1){   $pot =  ($tot * 50/100) ; echo number_format($pot); }else{ echo '0';} ?></td>
		</tr>		
		<tr>
			<td>&nbsp;</td>
			<td style="text-align: left;background-color: #349467; color: #FFF;">Grand Total</td>
			<td colspan="9" rowspan="1" style="text-align: right;"><?php if($pemkot ==1){  $totok = $tot - ($tot * 50/100) ; echo number_format($totok); }else{ echo number_format($tot); }?></td>
		</tr>		
		<tr>
			<td>&nbsp;</td>
			<td style="text-align: left;background-color: #349467; color: #FFF;">D.P</td>
			<td colspan="9" style="text-align: right;"><?php echo number_format ($dp1+$dp2);?></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td style="text-align: left;background-color: #349467; color: #FFF;">Kekurangan</td>
			<td colspan="9" style="text-align: right;"><?php  if($pemkot ==1){ echo number_format ($totok-($dp1+$dp2)); }else{ echo number_format ($tot-($dp1+$dp2));}?></td>
		</tr>
<?php $x = 0;} $x = 0;?>		
	</tbody>
</table>
<p>&nbsp;</p>
</body>
</html>