<?php
include '../../inc/inc.koneksi.php';
include '../../inc/fungsi_tanggal.php';

$sql2 = mysql_query("SELECT nama1 FROM company");
$r2	  = mysql_fetch_assoc($sql2);
$kop1 = $r2[nama1];

$bulan= $_GET['bulan'];
$tahun= $_GET['tahun'];
$nik1 = $_GET['nik1'];
$nik2 = $_GET['nik2'];
$thn  = $tahun-2000;
$bln  = sprintf("%02s",$bulan);

if($bulan==1)
	$cbulan='Januari';
else if($bulan==2)
	$cbulan='Februari';
else if($bulan==3)
	$cbulan='Maret';
else if($bulan==4)
	$cbulan='April';
else if($bulan==5)
	$cbulan='Mei';
else if($bulan==6)
	$cbulan='Juni';
else if($bulan==7)
	$cbulan='Juli';
else if($bulan==8)
	$cbulan='Agustus';
else if($bulan==9)
	$cbulan='September';
else if($bulan==10)
	$cbulan='Oktober';
else if($bulan==11)
	$cbulan='November';
else if($bulan==12)
	$cbulan='Desember';
else{
	$sql = "SELECT * FROM gaji WHERE bulan='$bulan' AND tahun='$tahun' ORDER BY kode_gj";
	$query = mysql_query($sql);
	$r=mysql_fetch_assoc($query);
	$bulan1=substr($r[tanggal],5,2);
		
	if($bulan1==1) $nbulan='JANUARI';
	else if($bulan1==2) $cbulan='FEBRUARI';
	else if($bulan1==3) $cbulan='MARET';
	else if($bulan1==4) $cbulan='APRILI';
	else if($bulan1==5) $cbulan='MEI';
	else if($bulan1==6) $cbulan='JUNI';
	else if($bulan1==7) $cbulan='JULI';
	else if($bulan1==8) $cbulan='AGUSTUS';
	else if($bulan1==9) $cbulan='SEPTEMBER';
	else if($bulan1==10) $cbulan='OKTOBER';
	else if($bulan1==11) $cbulan='NOVEMBER';
	else $cbulan='DESEMBER';
}
	
if($bulan==13) $judul='TANDA TERIMA THR';
else $judul='TANDA TERIMA GAJI';

mysql_query("DELETE FROM slip_gaji");

if(!($nik2==''))
	$sql = "SELECT * FROM gaji WHERE bulan='$bulan' AND tahun='$tahun' AND nik BETWEEN '$nik1' AND '$nik2' ORDER BY kode_gj";
else
	$sql = "SELECT * FROM gaji WHERE bulan='$bulan' AND tahun='$tahun' ORDER BY kode_gj";
$query = mysql_query($sql);

$content = "<table width='300' style='font-size:10px'>";

while($r=mysql_fetch_array($query)){	
	
	$content .= "<tr>
			<td width='15%' style='border-bottom:double 2px'>$kop1</td>
			<td width='1%' style='border-bottom:double 2px'></td>
			<td width='8%' style='border-bottom:double 2px'></td>
			<td width='1%'></td>
			<td width='15%' style='border-bottom:double 2px'>$kop1</td>
			<td width='1%' style='border-bottom:double 2px'></td>
			<td width='8%' style='border-bottom:double 2px'></td>
		</tr>
		<tr>
			<td></td>
		</tr>
		<tr>
			<td>TANDA TERIMA GAJI</td>
			<td></td>
			<td></td>
			<td></td>
			<td>TANDA TERIMA GAJI</td>
			<td></td>
			<td></td>
		</tr>
		<tr>
			<td></td><td></td><td></td><td></td><td></td><td></td><td></td>
		</tr>
		<tr>
			<td>Nama  : $r[nama]</td>
			<td></td>
			<td></td>
			<td></td>
			<td>Nama  : $r[nama]</td>
			<td></td>
			<td></td>
		</tr>
		<tr>
			<td style='border-bottom:double 2px'>Bulan : $cbulan $tahun</td>
			<td style='border-bottom:double 2px'></td>
			<td style='border-bottom:double 2px'></td>
			<td></td>
			<td style='border-bottom:double 2px'>Bulan : $cbulan $tahun</td>
			<td style='border-bottom:double 2px'></td>
			<td style='border-bottom:double 2px'></td>
		</tr>
		<tr>
			<td>PENERIMAAN :</td>
			<td></td>
			<td></td>
			<td></td>
			<td>PENERIMAAN :</td>
			<td></td>
			<td></td>
		</tr>
		<tr>
			<td>1. Gaji Pokok</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[gapok],0)."</td>
			<td></td>
			<td>1. Gaji Pokok</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[gapok],0)."</td>
		</tr>
		<tr>
			<td>2. Tunjangan Makan</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[tunj_mak],0)."</td>
			<td></td>
			<td>2. Tunjangan Makan</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[tunj_mak],0)."</td>
		</tr>
		<tr>
			<td>3. Tunjangan BPJS</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[tunj_bpjs],0)."</td>
			<td></td>
			<td>3. Tunjangan BPJS</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[tunj_bpjs],0)."</td>
		</tr>
		<tr>
			<td>4. Tunjangan Jabatan</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[tunj_jab],0)."</td>
			<td></td>
			<td>4. Tunjangan Jabatan</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[tunj_jab],0)."</td>
		</tr>
		<tr>
			<td>5. Tunjangan $r[nama_tl]</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[jumlah_tl],0)."</td>
			<td></td>
			<td>5. Tunjangan $r[nama_tl]</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[jumlah_tl],0)."</td>
		</tr>
		<tr>
			<td>   Total Penerimaan</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[tot_gaji],0)."</td>
			<td></td>
			<td>   Total Penerimaan</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[tot_gaji],0)."</td>
		</tr>
		<tr>
			<td></td><td></td><td></td><td></td><td></td><td></td><td></td>
		</tr>
		<tr>
			<td>POTONGAN :</td>
			<td></td>
			<td></td>
			<td></td>
			<td>POTONGAN :</td>
			<td></td>
			<td></td>
		</tr>
		<tr>
			<td>1. Potongan BPJS</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[pot_bpjs],0)."</td>
			<td></td>
			<td>1. Potongan BPJS</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[pot_bpjs],0)."</td>
		</tr>
		<tr>
			<td>2. Uang Muka Gaji</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[um_gaji],0)."</td>
			<td></td>
			<td>2. Uang Muka Gaji</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[um_gaji],0)."</td>
		</tr>
		<tr>
			<td>3. Angsuran Pinjaman</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[angsuran],0)."</td>
			<td></td>
			<td>3. Angsuran Pinjaman</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[angsuran],0)."</td>
		</tr>
		<tr>
			<td>4. Absen $r[alpa] hari</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[pot_absen],0)."</td>
			<td></td>
			<td>4. Absen $r[alpa] hari</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[pot_absen],0)."</td>
		</tr>
		<tr>
			<td>5. PPh Pasal 21</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[pot_pph21],0)."</td>
			<td></td>
			<td>5. PPh Pasal 21</td>
			<td>Rp</td>
			<td align='right'>".number_format($r[pot_pph21],0)."</td>
		</tr>
		<tr>
			<td style='border-bottom'>6. Potongan $r[nama_pl]</td>
			<td style='border-bottom'>Rp</td>
			<td style='border-bottom' align='right'>".number_format($r[jumlah_pl],0)."</td>
			<td></td>
			<td style='border-bottom'>6. Potongan $r[nama_pl]</td>
			<td style='border-bottom'>Rp</td>
			<td style='border-bottom' align='right'>".number_format($r[jumlah_pl],0)."</td>
		</tr>
		<tr>
			<td style='border-bottom:double 2px'>   Gaji Bersih</td>
			<td style='border-bottom:double 2px'>Rp</td>
			<td style='border-bottom:double 2px' align='right'>".number_format($r[gaber],0)."</td>
			<td></td>
			<td style='border-bottom:double 2px'>   Gaji Bersih</td>
			<td style='border-bottom:double 2px'>Rp</td>
			<td style='border-bottom:double 2px' align='right'>".number_format($r[gaber],0)."</td>
		</tr>
		<tr>
			<td></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td>Purwokerto, ".jin_date_str($r[tanggal])."</td>
			<td></td>
			<td></td>
			<td></td>
			<td>Purwokerto, ".jin_date_str($r[tanggal])."</td>
		</tr>
		<tr>
			<td></td>
		</tr>
		<tr>
			<td></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td style='border-bottom:double 2px'>$r[nama]</td>
			<td></td>
			<td></td>
			<td></td>
			<td style='border-bottom:double 2px'>$r[nama]</td>
		</tr>
		<tr>
			<td></td>
		</tr>
		<tr>
			<td></td>
		</tr>";
}
$content .= "</table>";

header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=slip$thn$bln.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $content;
?>