<?php
include "koneksi.php";
if (!isset($_SESSION["UserID"])) {
	header("location:login.php?p=3");
}

// memanggil library FPDF
require('fpdf/fpdf.php');
// intance object dan memberikan pengaturan halaman PDF
$pdf = new FPDF('p','mm','A4');
// membuat halaman baru
$pdf->AddPage();
// setting jenis font yang akan digunakan
$pdf->SetFont('Arial','B',22);
// mencetak string 
$pdf->Cell(190,7,'PT.MULTI HIDRACHROME BALIKPAPAN',0,1,'C');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(190,7,'___________________________________________________________________________',0,1,'C');
$pdf->Cell(190,7,'PERMOHONAN CUTI KARYAWAN',0,1,'C');
$pdf->Cell(190,7,'Balikpapan',0,1,'C');

$timezone = time() + (60 * 60 * 1);
date_default_timezone_set('Asia/Jakarta');
$pdf->Cell(190,7,date('d / M / yy / H:i:s a',$timezone),0,1,'C');


$idcuti = mysqli_real_escape_string($conn, $_GET["id"]);
//echo "idcutinya bang : " . $idcuti . "</br>";

$q = "SELECT ck.id AS id, ck.alamat AS alamat, ck.sisa_cuti AS sisa_cuti, ck.tanggal_awal_cuti AS tanggal_awal_cuti, ck.tanggal_akhir_cuti AS tanggal_akhir_cuti, ck.tanggal_pengajuan_cuti AS tanggal_pengajuan_cuti, ck.alasan_cuti AS alasan_cuti, ck.tanggal_lapor_cuti AS tanggal_lapor_cuti, ck.id_jenis_cuti AS id_jenis_cuti,
                                      dk.nik AS nik, dk.nama_karyawan AS nama_karyawan, dk.jabatan AS jabatan, dk.departement AS departement, dk.status_kepegawaian AS status_kepegawaian, dk.asal_penerimaan AS asal_penerimaan, dk.sisa_cuti_tahun AS sisa_cuti_tahun						  
	  FROM cuti_karyawan ck INNER JOIN data_karyawan dk ON ck.id_data_karyawan = dk.id
	  WHERE ck.id = $idcuti";
$res = mysqli_query($conn, $q);

//$s = "UPDATE data_karyawan SET sisa_cuti_besar = '1' WHERE id=" . $row['id']; 


//$no = 1;
//$pdf->Ln();
$row = mysqli_fetch_array($res);


$s = "SELECT * FROM jenis_cuti WHERE id=" .$row['id_jenis_cuti'];
$resi = mysqli_query($conn,$s);

$rowi = mysqli_fetch_array($resi);

$pdf->Cell(190,7,'',0,1,'C');
$pdf->Cell(130 , 5, 'Nik                   ',1,0,'c'); 
$pdf->Cell(59,5,$row['nik'],1,1,'C');

$pdf->Cell(130 , 5, 'Nama                  ',1,0,'c');
$pdf->Cell(59,5,$row['nama_karyawan'],1,1,'C');

$pdf->Cell(130 , 5, 'Status                ',1,0,'c');
$pdf->Cell(59,5,$row['status_kepegawaian'],1,1,'C');

$pdf->Cell(130 , 5, 'Jabatan               ',1,0,'c');
$pdf->Cell(59,5,$row['jabatan'],1,1,'C');

$pdf->Cell(130 , 5, 'Devisi/Dept/Bag/Seksi ',1,0,'c');
$pdf->Cell(59,5,$row['departement'],1,1,'C');

$pdf->Cell(130 , 5, 'Asal Penerimaan        ',1,0,'c');
$pdf->Cell(59,5,$row['departement'],1,1,'C');

$pdf->Cell(130 , 5, 'Alamat Tujuan Cuti          ',1,0,'c');
$pdf->Cell(59,5,$row['alamat'],1,1,'C');

$pdf->Cell(130 , 5, 'Sisa Cuti Saat Ini    ',1,0,'c');
$pdf->Cell(59,5,$row['sisa_cuti_tahun'],1,1,'C');

$pdf->Cell(130 , 5, 'Tanggal Mulai Kerja   ',1,0,'c');
$pdf->Cell(59,5,$row['tanggal_akhir_cuti'],1,1,'C');

$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, 'Dengan ini mengajukan permohonan          :',0,1,'c');

$pdf->Cell(130 , 5, 'Jenis Cuti                      ',1,0,'c');
$pdf->Cell(59,5,$rowi['nama'],1,1,'C');

$pdf->Cell(130 , 5, 'Tanggal Mulai Cuti   ',1,0,'c');
$pdf->Cell(59,5,$row['tanggal_awal_cuti'],1,1,'C');

$pdf->Cell(130 , 5, 'Alasan          ',1,0,'c');
$pdf->Cell(59,5,$row['alasan_cuti'],1,1,'C');

$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, 'CATATAN                                   :',0,1,'c');

$pdf->Cell(130 , 5, 'Masuk Kembali Tanggal ',1,0,'c');
$pdf->Cell(59,5,$row['tanggal_akhir_cuti'],1,1,'C');

$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, 'Agar melapor ke HCGA setelah selesai cuti :',0,1,'c');

$pdf->Cell(130 , 5, 'Tanggal Lapor  ',1,0,'c');
$pdf->Cell(59,5,$row['tanggal_lapor_cuti'],1,1,'C');


$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, ' Pemohon,                Diperiksa,                  Diketahui,              Disetujui,               Disetujui,',0,1,'c');

$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '     .........               HCGA Officer             HCGA Manager          Direktur          Atasan langsung',0,1,'c');

$no = 1;
$pdf->Ln();
$row = mysqli_fetch_array($res);
$pdf->SetFont('Arial','B',20);
$pdf->Cell(190,7,$row['alamat'],0,1,'C');

// Memberikan space kebawah agar tidak terlalu rapat
//$pdf->Cell(10,7,'',0,1);

//$pdf->SetFont('Arial','B',10);
//$pdf->Cell(15,6,'No',1,0,'C');
//$pdf->Cell(40,6,'NRP',1,0,'C');
//$pdf->Cell(85,6,'NAMA MAHASISWA',1,0,'C');
//$pdf->Cell(47,6,'TTD',1,0,'C');





//$mahasiswa = mysqli_query($link, "SELECT mk.nrp AS nrp, m.nama AS nama, k.nama_kelas AS namakelas, mt.nama AS namamatkul
//FROM 
//mahasiswa_kelas mk
//INNER JOIN kelas k ON mk.kode_kelas = k.kode_kelas 
//INNER JOIN mahasiswa m ON m.nrp = mk.nrp
//INNER JOIN matakuliah mt ON k.kode_mk = mt.kode_mk
//");

$no = 1;
$pdf->Ln();
while ($row = mysqli_fetch_array($res)){
	//$pdf->SetFont('Arial','B',10);
	//$pdf->SetFillColor(255,255,255);
	//$pdf->Cell(15,6,$no++,1,0,'C',true);
	//$pdf->Cell(40,6,$row['nik'],1,0,'C');
	//$pdf->Cell(85,6,$row['nama_karyawan'],1,0,'L');
	//$pdf->Cell(47,6,"",1,0,'C');
	//$pdf->Ln();
}

$pdf->Output();


?>