<?php
session_start();
$host ="localhost";
$user="root";
$password="";
$database="tes";
$tahun=$_GET['tahun'];
$tgl= date('d-M-Y');
mysql_connect($host,$user,$password) or die("Koneksi server gagal");
mysql_select_db($database);
//Queri untuk Menampilkan data
$query ="SELECT i.id_raker, r.nama_raker_kaur, i.realisasi, i.id_bulan
FROM isiraker i
JOIN kaur r
ON (i.id_raker = r.id_raker_kaur)
WHERE tahun ='$tahun'
AND no ='$_SESSION[no]'";
$db_query = mysql_query($query) or die("Query gagal");
//Variabel untuk iterasi
$i = 0;
//Mengambil nilai dari query database
while($data=mysql_fetch_row($db_query))
{
$cell[$i][0] = $data[0];
$cell[$i][1] = $data[1];
$cell[$i][2] = $data[2];
$cell[$i][3] = $data[3];
$i++;
}
require_once ("fpdf16/fpdf.php");
class PDF extends FPDF
{
//Fungsi Untuk Membuat Header
function Header()
{
$this->Image('logo.jpg',1,0.5,19.2);
//Pilih font Arial bold 15
$this->SetFont('Arial','B',14);
//Geser ke kanan
$this->Cell(80);
//Judul dalam bingkai
$this->Cell(30,10,'Title',1,0,'C');
//Ganti baris
$this->Ln(1.5);
}
//Fungsi Untuk Membuat Footer
}
$pdf = new PDF('P','cm','A4');
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont("Arial","B",8);
$pdf->Cell(19.2,1,'Laporan Realisasi Tahun '.$tahun,'LRTB',0,'C');
$pdf->Ln();
$pdf->Cell(0.75,1,'No','LRTB',0,'C');
$pdf->Cell(1.5,1,'ID RAKER','LRTB',0,'C');
$pdf->Cell(14,1,'NAMA RENCANA KERJA','LRTB',0,'C');
$pdf->Cell(1.75,1,'REALISASI','LRTB',0,'C');
$pdf->Cell(1.2,1,'BULAN','LRTB',0,'C');
$pdf->Ln();
$pdf->SetFont('Times','',7);
for($j=0;$j<$i;$j++)
{
//menampilkan data dari hasil query database
$pdf->Cell(0.75,1,$j+1,'LBTR',0,'C');
$pdf->Cell(1.5,1,$cell[$j][0],'LBTR',0,'C');
$pdf->Cell(14,1,$cell[$j][1],'LBTR',0,'C');
$pdf->Cell(1.75,1,$cell[$j][2],'LBTR',0,'C');
$pdf->Cell(1.2,1,$cell[$j][3],'LBTR',0,'C');
$pdf->Ln();
}
$pdf->Cell(19,1,'Bandung, '.$tgl);
function Footer()
{
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Page number
$this->Cell(0,10,'Halaman ke : '.$this->PageNo(),0,0,'C');
}
//menampilkan output berupa halaman PDF
$pdf->Output();
?>
<html>
<body>
<?php
session_start();
if (empty($_SESSION['username']) AND empty($_SESSION['passuser'])){
echo "<link href='style.css' rel='stylesheet' type='text/css'>
<center>Untuk mengakses modul, Anda harus login <br>";
echo "<a href=../../index.php><b>LOGIN</b></a></center>";
}
else{
$aksi="bagian/bag_tampil_raker/aksi_tampil.php";
$tahun=$_POST['tahun'];
echo "Tahun : ".$tahun;
switch($_GET[act]){
// Tampil Divisi
default:
echo "<h2>View Raker</h2>
<form method=POST action='?module=tampil_raker_kaur&act=input'>
<table>
<tr><td>
Tahun : <select name='tahun' class='required' title='Bulan harus dipilih'>
<option value=0 selected>- Pilih Tahun -</option>
<option value=2011>2011</option>
<option value=2012>2012</option>
<option value=2013>2013</option>
<option value=2014>2014</option>
<option value=2015>2015</option>
<option value=2016>2016</option>
</select>
</td></tr>";
?>
<script>
function buka(){
window.open("pesan.php","","width=500,height=400,toolbar=0");
}
</script>
<a href="javascript:buka()" class="view-all">Kirim Pesan</a>
<?php
echo"<tr><td colspan=2><input type='submit' name='submit' value=Tampilkan></td></tr></table> </form> ";
}
}
?>
<?php
$module=$_GET[module];
$act=$_GET[act];
if ($module=='tampil_raker_kaur' AND $act=='input'){
if(isset($_POST['submit'])){
$Tahun = $_POST['tahun'];
$sql ="SELECT i.id_raker, r.no, i.id_bulan, i.realisasi, r.nama_raker_kaur, r.id_raker_kaur
FROM isiraker i
JOIN kaur r
ON (i.id_raker = r.id_raker_kaur)
WHERE tahun ='$Tahun'
AND no ='$_SESSION[no]'";
$result = mysql_query($sql);
if(mysql_num_rows($result) > 0){
$proker = Array();
while ( $row = mysql_fetch_object($result) ){
$proker[$row->nama_raker_kaur][$row->id_bulan] = $row->realisasi;
}
?>
<a href="http://localhost/tugaskp2/bagian/bag_tampil_pdf/pdf.php?tahun=<?php echo $tahun ?>" target="_blank" >Download PDF</a>
<table>
<hr>
<p><font color="blue">
<?php echo"Presentase Realisasi Tahun $Tahun";?> </font></p>
<tr>
<th width='5%' rowspan=2><div align=center><strong>NO</strong></div></th>
<th width='35%' rowspan=2><div align=center><strong>NAMA RAKER</strong></div></th>
<th colspan='52%'><div align=center><strong>REALISASI (Bulan) dalam persen %</strong></div></th>
</tr>
<tr>
<th width=4 height=23><div align=center><strong>Jan</strong></div></th>
<th width=4 height=23><div align=center><strong>Feb</strong></div></th>
<th width=4 height=23><div align=center><strong>Mar</strong></div></th>
<th width=4 height=23><div align=center><strong>Apr</strong></div></th>
<th width=4 height=23><div align=center><strong>Mei</strong></div></th>
<th width=4 height=23><div align=center><strong>Jun</strong></div></th>
<th width=4 height=23><div align=center><strong>Jal</strong></div></th>
<th width=4 height=23><div align=center><strong>Aug</strong></div></th>
<th width=4 height=23><div align=center><strong>Sep</strong></div></th>
<th width=4 height=23><div align=center><strong>Okt</strong></div></th>
<th width=4 height=23><div align=center><strong>Nov</strong></div></th>
<th width=4 height=23><div align=center><strong>Des</strong></div></th>
<th width=4 height=23><div align=center><strong>Total</strong></div></th>
</tr>
<?php
$no=1;
foreach( $proker as $key => $ar_value ){
$total = 0;
echo '<tr><td>'.$no.'</td>';
$no++;
echo "<td>$key</td>";
for($i=1;$i<=12;$i++){
if(empty($ar_value[$i])){
echo "<td>0</td>";
}
else{ echo "<td><b>$ar_value[$i]<b></td>";
$total += $ar_value[$i];
}
}
echo '<td><font color=blue><b>'.$total.'</b></font></td>';
echo '</tr>';
}
?>
</table>
<?php
}else{
echo 'Data tidak ditemukan !!!';
}
}
}
?>
</body>
</html>