
<?php
// memanggil library FPDF
require('../library/fpdf185/fpdf.php');

include '../koneksi.php';

// intance object dan memberikan pengaturan halaman PDF
// asline // $pdf=new FPDF('L','mm', array(200,104));
// $pdf=new FPDF('P','mm', 'A6');

$pdf=new FPDF('P','mm','A4');
 

// asline //$pdf->SetMargins(7,8,0,0);
$pdf->SetMargins(19,10,0,0);
$pdf->AddPage();

function penyebut($nilai) {
  $nilai = abs($nilai);
  $huruf = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
  $temp = "";
  if ($nilai < 12) {
    $temp = "". $huruf[$nilai];
  } else if ($nilai <20) {
    $temp = penyebut($nilai - 10). " belas";
  } else if ($nilai < 100) {
    $temp = penyebut($nilai/10)." puluh ". penyebut($nilai % 10);
  } else if ($nilai < 200) {
    $temp = " seratus " . penyebut($nilai - 100);
  } else if ($nilai < 1000) {
    $temp = penyebut($nilai/100) . " ratus " . penyebut($nilai % 100);
  } else if ($nilai < 2000) {
    $temp = " seribu " . penyebut($nilai - 1000);
  } else if ($nilai < 1000000) {
    $temp = penyebut($nilai/1000) . " ribu " . penyebut($nilai % 1000);
  } else if ($nilai < 1000000000) {
    $temp = penyebut($nilai/1000000) . " juta " . penyebut($nilai % 1000000);
  } else if ($nilai < 1000000000000) {
    $temp = penyebut($nilai/1000000000) . " milyar " . penyebut(fmod($nilai,1000000000));
  } else if ($nilai < 1000000000000000) {
    $temp = penyebut($nilai/1000000000000) . " trilyun " . penyebut(fmod($nilai,1000000000000));
  }     
  return $temp;
}

function terbilang($nilai) {
  if($nilai<0) {
    $hasil = "minus ". trim(penyebut($nilai));
  } else {
    $hasil = trim(penyebut($nilai));
  }         
  return $hasil . " rupiah";
}
        $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'];
        
$logo_kop=$c['gambar'] ;


$gambar='../gambar/'.$logo_kop.'';

$pdf->Image(‘foto/’ . $gambar,20,10,70);

$pdf->SetFont('Arial','B',12);

$pdf->Cell(20,15,'','0',1,'C');
$pdf->Cell(200,8,'DAFTAR PENGURUS & PENGAWAS',0,1,'C');

$pdf->SetFont('Arial','I',10);
$pdf->Cell(200,5,'Periode : '.date('d-m-Y', strtotime($tgl_dr)).' s/d '.date('d-m-Y', strtotime($tgl_sd)).'',0,1,'C');

$pdf->SetFont('Arial','',9);
$pdf->Cell(60,4,'',0,0,'C');
$pdf->Cell(10,4,'',0,1);  

// Atur warna latar belakang sel
$pdf->SetFillColor(220, 220, 220); // Warna abu-abu

// Atur warna teks
$pdf->SetTextColor(0, 0, 0); // Warna hitam


$pdf->SetFont('Arial','B',12);
$pdf->Cell(10,9,'A.',0,0,'C');
$pdf->Cell(100,9,'PENGURUS',0,0,'L');
$pdf->Cell(35,9,'',0,0,'C');
$pdf->Cell(35,9,'',0,0,'C');
$pdf->Cell(5,9,'',0,1);

$pdf->SetFont('Arial','B',11);
$pdf->Cell(10,9,'No.',1,0,'C', true);
$pdf->Cell(50,9,'Nama',1,0,'C', true);
$pdf->Cell(70,9,'Alamat',1,0,'C', true);
$pdf->Cell(40,9,'Jabatan ',1,0,'C', true);
$pdf->Cell(5,9,'',0,1);
$pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0, 0, 0); // Warna hitam

$no=1;
            $data = mysqli_query($koneksi,"SELECT * FROM karyawan WHERE hapus<>'HAPUS' and ket='PP' and jabatan<'10' 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);      
            $alamat=''.$a['alamat'].', RT '.$a['rt'].', RW '.$a['rw'].' Kel. '.$c['kelurahan'].', Kec. '.$a['kecamatan'].', '.$a['kota'].'';
            
$pdf->SetFont('Arial','',10);
  $pdf->Cell(10,7, $no++,1,0,'C');

$current_y = $pdf->GetY();
$current_x = $pdf->GetX();
$pdf->MultiCell(50,7, $a['nama'],1,0,'L');
$current_x+7;
$pdf->SetXY($current_x, $current_y);

$pdf->Cell(30,7,'',0,0);
$pdf->Cell(2,7,' ',0,0,'C');


$current_y = $pdf->GetY();
$current_x = $pdf->GetX();
$pdf->MultiCell(70,7, $alamat,1,0,'L');
$current_x+7;
$pdf->SetXY($current_x, $current_y);


$pdf->Cell(30,7,'',0,0);
$pdf->Cell(2,7,' ',0,0,'C');
$pdf->Cell(10,7,' ',0,1);

$current_y = $pdf->GetY();
$current_x = $pdf->GetX();
$pdf->MultiCell(50,5, $j['nama'],0);
$current_x+5;
$pdf->SetXY($current_x, $current_y);

$pdf->Cell(30,5,'',0,0);
$pdf->Cell(2,5,' ',0,0,'C');
$pdf->Cell(10,5,' ',0,1);

$pdf->Cell(5,7,'',0,1);  
}



$tgl_skr=date('Y-m-d');
  
$pdf->SetFont('Arial','',9);
$pdf->Cell(60,3,'',0,0,'C');
$pdf->Cell(10,3,'',0,1);  

$pdf->Cell(60,5,'',0,0,'C');
$pdf->Cell(67,5,$kc['kota'],0,0,'R');
$pdf->Cell(20,5,date('d-m-Y', strtotime($tgl_skr)),0,0,'R');
$pdf->Cell(27,5,'',0,0,'C');
$pdf->Cell(10,5,'',0,1);  

$pdf->Cell(90,5,'',0,0,'C');
$pdf->Cell(40,5,Superviser,0,0,'C');
$pdf->Cell(40,5,Kasir,0,0,'C');
$pdf->Cell(27,5,'',0,1,'C');

$pdf->Cell(60,17,'',0,0,'C');
$pdf->Cell(10,17,'',0,1);  

$pdf->Cell(90,5,'',0,0,'C');
$pdf->Cell(40,5,$kc['supervisor'],0,0,'C');
$pdf->Cell(40,5,$kc['kasir'],0,0,'C');
$pdf->Cell(27,5,'',0,1,'C');
$pdf->Output();

?>