<?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',18);
// mencetak string 
$pdf->Cell(190,3,'PT.MULTI HIDRACHROME BALIKPAPAN',0,1,'C');
$pdf->SetFont('Arial','B',10);
$pdf->Cell(190,7,'',0,1,'C');
$pdf->Cell(190,2,'FORMULIR PERINTAH LEMBUR',0,1,'C');	
$timezone = time() + (60 * 60 * 1);
date_default_timezone_set('Asia/Jakarta');
$pdf->Cell(190,6,'Balikpapan,  '.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>";

//////query cuti
//////$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);

////$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);

//query untuk pengambilan data gaji
$q = "SELECT * FROM data_karyawan WHERE id=".$idcuti;
$res = mysqli_query($conn, $q);
$row = mysqli_fetch_array($res);



$pdf->SetFont('Arial','',9);
$pdf->Cell(130 , 1, '______________________________________________________________________________________________',0,1,'c');
$pdf->Cell(130 , 1, '',0,1,'c');

$pdf->Cell(100 , 5, 'KEPADA'.'           : '.$row['nama_karyawan'],1,0,'c');
$pdf->Cell(100,5,'Hari / Tanggal'.'                   : '.date('l / d - M - yy '),0,1,'c');

$pdf->Cell(100 , 5, 'NIK'.'                    : '.$row['nik'],1,0,'c');
$pdf->Cell(100,5,'',0,1,'c');

$pdf->Cell(100 , 5, 'JABATAN'.'          : '.$row['jabatan'],1,0,'c');
$pdf->SetFont('Arial','U',9);
$pdf->Cell(100,5,'Cause Of Overtime'.'           : '.$row['jabatan'],0,1,'c');

$pdf->SetFont('Arial','',9);
$pdf->Cell(100 , 5, 'Diperintahkan untuk kerja lembur dari jam : '.  'Sampai jam :',1,0,'c');
$pdf->Cell(100,5,'Atas project / pekerjaan sebagai berikut :',0,1,'c');

$pdf->Cell(130 , 3, '_______________________________________________________________________________________________',0,1,'c');

$pdf->SetFont('Arial','B',10);
$pdf->Cell(8,6,'N0',1,0);
$pdf->Cell(50,6,'        URAIAN KEGIATAN',1,0);
$pdf->Cell(25,6,'MHB JOB NO',1,0);
$pdf->Cell(15,6,' INPUT',1,0);
$pdf->Cell(18,6,'OUTPUT',1,0);
$pdf->Cell(35,6,' % AWAL KERJA',1,0);
$pdf->Cell(35,6,'% SETELAH KERJA',1,1);

$pdf->SetFont('Arial','',10);
//1
$pdf->Cell(8,6,'1',1,0);
$pdf->Cell(50,6,'',1,0);
$pdf->Cell(25,6,'',1,0);
$pdf->Cell(15,6,'',1,0);
$pdf->Cell(18,6,'',1,0);
$pdf->Cell(35,6,'',1,0);
$pdf->Cell(35,6,'',1,1);

//2
$pdf->Cell(8,6,'2',1,0);
$pdf->Cell(50,6,'',1,0);
$pdf->Cell(25,6,'',1,0);
$pdf->Cell(15,6,'',1,0);
$pdf->Cell(18,6,'',1,0);
$pdf->Cell(35,6,'',1,0);
$pdf->Cell(35,6,'',1,1);


//3
$pdf->Cell(8,6,'3',1,0);
$pdf->Cell(50,6,'',1,0);
$pdf->Cell(25,6,'',1,0);
$pdf->Cell(15,6,'',1,0);
$pdf->Cell(18,6,'',1,0);
$pdf->Cell(35,6,'',1,0);
$pdf->Cell(35,6,'',1,1);

//4
$pdf->Cell(8,6,'4',1,0);
$pdf->Cell(50,6,'',1,0);
$pdf->Cell(25,6,'',1,0);
$pdf->Cell(15,6,'',1,0);
$pdf->Cell(18,6,'',1,0);
$pdf->Cell(35,6,'',1,0);
$pdf->Cell(35,6,'',1,1);

//5
$pdf->Cell(8,6,'5',1,0);
$pdf->Cell(50,6,'',1,0);
$pdf->Cell(25,6,'',1,0);
$pdf->Cell(15,6,'',1,0);
$pdf->Cell(18,6,'',1,0);
$pdf->Cell(35,6,'',1,0);
$pdf->Cell(35,6,'',1,1);






$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '   Diketahui,                                                        '.'Disetujui,'.'    Diajukan,'.'                                                   Paraf.PPC / QC       ',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');

$pdf->Cell(130 , 5, 'Opr. Manager                                                 '.'Supervisor    '.'    Foreman'.'                                                        '.'Foreman',0,1,'c');
$pdf->Cell(130 , 5, '',0,1,'c');
$pdf->SetFont('Arial','I',10);
$pdf->Cell(130 , 5, 'Note : * Diperiksa Oleh PPC dan / QC, Sebelum mulai kerja dan setelah barang dikerjakan',0,1,'c');
$pdf->Cell(186,6,'Kerja lembur (over time) bukan menambah penghasilan tetapi merupakan bentuk tanggung jawab pekerjaan',1,0);


$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();


?>