<!DOCTYPE html>

<?php 
	session_start();
	@ob_start();
	include "../../config/koneksi.php";
	include "../../config/fungsi_rupiah.php";
	include "../../config/fungsi_indotgl.php";
	include "../head.php";

	
	if ($_SESSION['nama'] == ''){
		header('Location:index.php');
	}
	else{
		$blnx = date('M');
		$thnx = date('Y');
		$harini = date('d-m-Y');
		$awal = $_GET['awal'];
		$akhir = $_GET['akhir'];
		$awal2 = date('d-m-Y', strtotime($awal));
		$akhir2 = date('d-m-Y', strtotime($akhir));
?>
<html>

  <body class="hold-transition skin-blue sidebar-mini layout-boxed">
                  <h3 class="box-title"><center>Data Customer from <?php echo "$awal2 s/d $akhir2 , tgl cetak : $harini"; ?></center></h3><br>
				  <?php					
					header("Content-type: application/vnd-ms-excel");
					header("Content-Disposition: attachment; filename=Laporan-Bulan-$blnx-$thnx.xls");
					?>
                  <table id="example1" class="table table-bordered table-striped" border="1">
                    <thead>
                      <tr>
						<th>Nama</th>						
						<th>ID</th>	
						<th>HP</th>		
						<th>TGL LAHIR</th>								
						<th>Alamat</th>	
                      </tr>
                    </thead>
                    <tbody>
					<?php
						$cek = mysql_query("Select * from customer where dateadded >= '$awal' and dateadded <= '$akhir' order by nama asc");
						while ($r=mysql_fetch_array($cek))
						{	
							if ($r['tgllahir'] =="0000-00-00"){
								$tgllahir = "";
							}else{
								$tgllahir = date('d-M-Y', strtotime($r['tgllahir']));
							}
							echo "<tr>";
							echo "<td>".$r['nama']."</td>";
							echo "<td>".$r['tipe'].str_pad($r['id'], 7, '0', STR_PAD_LEFT)."</td>";	
							echo "<td>'".$r['hp']."</td>";	
							echo "<td>".$tgllahir."</td>";	
							echo "<td>".$r['alamat']."</td>";
							echo "</tr>";
						}
					?>
                        
                     
                    </table>
                </div><!-- /.row -->
  </body>
</html>
<?php 
	}
	echo "<script>window.close();</script>";
	#header("Location: laporan1.php");
	#exit;
?>