<?php

require_once ("../../koneksi/koneksi.php");
if(isset($_GET['id_paket']))
{
	$rs=mysql_query("Select * from paket where id_paket='".$_GET['id_paket']."'");
	$aa=mysql_fetch_array($rs);
	$pak=$aa['id_paket'];

}

//Array Hari
$array_hari = array(1=>"Senin","Selasa","Rabu","Kamis","Jumat", "Sabtu","Minggu");
$hari = $array_hari[date("N")];
//Format Tanggal
$tanggal = date ("j");
//Array Bulan
$array_bulan = array(1=>"Januari","Februari","Maret", "April", "Mei", "Juni","Juli","Agustus","September","Oktober", "November","Desember");
$bulan = $array_bulan[date("n")];
//Format Tahun
$tahun = date("Y");


require_once ("../../asset/fpdf/fpdf.php");
$pdf = new FPDF();
$pdf->AddPage();

$pdf->SetFont('Arial','B','16'); 
$pdf->text(67,28,'Laporan Pemenang Tender');

//tampilan Judul Laporan
//Font Arial, Tebal/Bold, ukuran font 16
$pdf->SetFont('Arial','','9'); 

$pdf->text(10,43,"Nama Paket      : ".$aa['nama_paket']);

$pdf->text(10,47,"Nama Proyek    : ".$aa['nama_proyek']);

$pdf->text(10,51,"HPS                  : Rp. ".number_format($aa['hps']));

$pdf->text(10,55,"Keterangan       : ".$aa['kecamatan']);


$yi = 65;
$ya = 60;
$pdf->setFont('Arial','',9);
$pdf->setFillColor(222,222,222);
$pdf->setXY(10,$ya);
$pdf->CELL(6,6,'N0',1,0,'C',1);
$pdf->CELL(40,6,'Nama Perusahaan',1,0,'C',1);
$pdf->CELL(29,6,'Harga Penawaran',1,0,'C',1);
$pdf->CELL(20,6,'Kualifikasi',1,0,'C',1);
$pdf->CELL(20,6,'Administrasi',1,0,'C',1);
$pdf->CELL(11,6,'Teknis',1,0,'C',1);
$pdf->CELL(11,6,'Harga',1,0,'C',1);
$pdf->CELL(12,6,'Total',1,0,'C',1);
$pdf->CELL(20,6,'Nilai BCR',1,0,'C',1);
$pdf->CELL(20,6,'Keterangan',1,0,'C',1);
$row = 6;
$ya = $yi + $row;
$sql = mysql_query("select * from pemenang where id_paket='$pak' order by nilai_bcr DESC,harga_penawaran ASC ");
$i = 1;
$no = 1;
$max = 31;

while($data = mysql_fetch_array($sql)){
	 $nn=mysql_query("select min(harga_penawaran) AS min from pemenang where status='lulus'");
        $ff=mysql_fetch_array($nn);

$pdf->setXY(10,$ya);
$pdf->setFont('arial','',9);
$pdf->setFillColor(255,255,255);
$pdf->cell(6,6,$no,1,0,'C',1);
$pdf->cell(40,6,$data['nama_perusahaan'],1,0,'L',1);
$pdf->cell(29,6,"Rp. ".number_format($data['harga_penawaran']),1,0,'L',1);
$pdf->CELL(20,6,$data['jumlah_kual'],1,0,'C',1);
$pdf->CELL(20,6,$data['jumlah_adm'],1,0,'C',1);
$pdf->CELL(11,6,$data['jumlah_teknis'],1,0,'C',1);
$pdf->CELL(11,6,$data['jumlah_harga'],1,0,'C',1);
$pdf->CELL(12,6,number_format($data['jumlah_total']),1,0,'C',1);
$pdf->CELL(20,6,number_format($data['nilai_bcr'],5),1,0,'C',1);
if($data['status']=='lulus' and $ff['min']==$data['harga_penawaran']){
    $pdf->CELL(20,6,'Pemenang',1,0,'C',1);
      }else if($data['status']=='lulus'){
 $pdf->CELL(20,6,'-',1,0,'C',1);
      }else { $pdf->CELL(20,6,'GUGUR',1,0,'C',1);
      }

$ya = $ya+$row;
$no++;
$i++;

}
$pdf->text(140,$ya+6,"SEMARANG , ".$tanggal." ".$bulan." ".$tahun);
$pdf->text(140,$ya+25,"PIMPINAN");


//output file pdf
$pdf->Output();
?>