



<!DOCTYPE html>
<html>
<head>
	<title>Export Data Ke Excel Dengan PHP - www.mitrakoperasi.com</title>
</head>
<body>
	<style type="text/css">
	body{
		font-family: sans-serif;
	}
	table{
		margin: 20px auto;
		border-collapse: collapse;
	}
	table th,
	table td{
		border: 1px solid #3c3c3c;
		padding: 3px 8px;
 
	}
	a{
		background: blue;
		color: #fff;
		padding: 8px 10px;
		text-decoration: none;
		border-radius: 2px;
	}
	</style>
 
<?php include 'header_excell.php'; ?>
    <?php 
        $tgl_s =date('Y-m-d');            
        $oleh=$_SESSION['id'];
        $kdc=$_SESSION['kdc'];
        
        $kanca = mysqli_query($koneksi,"select * from kdkanca where kd='$kdc'");
        $c = mysqli_fetch_assoc($kanca);  
        $tgl_dr=$c['tgl_dr']; 
        $tgl_sd=$c['tgl_sd'];
    ?>
	<?php
	    header("Content-type: application/vnd-ms-excel");
	    header("Content-Disposition: attachment; filename=".$kdc."_pengurus_".$tgl_s.".xls");
    ?>

	<table border="0">
            <tr>
                <th Style="text-align:center" colspan="4" bgcolor="#D3D3D3">DAFTAR PENGURUS & PENGAWAS</th>
            </tr>  
            <tr>
                <th Style="text-align:center" colspan="4" bgcolor="#D3D3D3">Periode Tanggal <?php echo date('d-m-Y', strtotime($tgl_dr)); ?> s/d <?php echo date('d-m-Y', strtotime($tgl_sd)); ?></th>
            </tr>             
            <tr>
              <th width="5%" class="text-center">No</th>
              <th width="25%" class="text-center">NAMA</th>
              <th width="50%" class="text-center">ALAMAT</th>
              <th width="20%" class="text-center">JABATAN</th>
            </tr>
                  </thead>
          <tbody>
            <?php 
            $no=1;
            $data = mysqli_query($koneksi,"SELECT * FROM karyawan WHERE hapus<>'HAPUS' and ket='PP' ORDER BY jabatan ASC");
            while($d = mysqli_fetch_array($data)){
                $id=$d['id'];
                
                $gapok = mysqli_query($koneksi,"select * from karyawan_gapok where id='$id'");
                $g = mysqli_fetch_assoc($gapok);
                
                $iden = mysqli_query($koneksi,"select * from karyawan_iden where id='$id'");
                $i = mysqli_fetch_assoc($iden);
                
                $angg = mysqli_query($koneksi,"select * from anggota where angg_no='$d[angg_no]'");
                $a = mysqli_fetch_assoc($angg);  
                    $foto_diri=$a['foto_diri'];
                $jbt = mysqli_query($koneksi,"select * from kdpengurus where kd='$d[jabatan]'");
                $j = mysqli_fetch_assoc($jbt);                  
              ?>
              <tr>
               <td><?php echo $no++; ?></td>
                <td><?php echo $a['nama']; ?></td>
                <td align='left'><?php echo $a['alamat']; ?>, RT <?php echo $a['rt']; ?>, RW <?php echo $a['rw']; ?>, Kel. <?php echo $c['kelurahan']; ?>, Kec. <?php echo $c['kecamatan']; ?>, <?php echo $c['kota']; ?></td>
                <td align='left'><?php echo $j['nama']; ?></td>
              </tr>
              <?php 
            }
            ?>
          </tbody>
        </table>
</body>
</html>