Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include "../../conn.php";
- define('FPDF_FONTPATH', 'fpdf/font/');
- include "fpdf/fpdf.php";
- $semes = mysql_query("SELECT kode, ket_smstr FROM semester where aktif='aktif'");
- $sm = mysql_fetch_array($semes);
- $status = $sm['ket_smstr'];
- //mencaritahu gasal atau genap
- $s = explode(" ", $status);
- $g = $s[0]; //kalo di echo hasilnya genap/gasal
- $bulangasal = array("juli","agustus","september","oktober","nopember","desember");
- $bulangenap = array("januari","februari","maret","april","mei","juni");
- class PDF extends FPDF
- {
- function Header()
- {
- $this->Image('../../../images/logo.JPG',7,0.8,2);
- $this->SetFont('Times','B','10');
- $this->Cell(26.5,0.5,'LAPORAN KEUANGAN',0,0,'C');
- $this->Ln();
- $this->SetFont('Times','B','11');
- $this->Cell(26.5,0.5,'SMK PALEBON SEMARANG',0,0,'C');
- $this->Ln();
- $this->Cell(26.5,0.5,'Jalan Palebon Raya No. 30 Pedurungan Semarang (50199)',0,0,'C');
- $this->SetFont('Times','B','10');
- $this->Ln();
- $this->Cell(26.5,0.5,'Semester '.$status,0,0,'C');
- $this->Line(3,3.3,26.5,3.3);
- $this->Line(3,3.4,26.5,3.4);
- $this->Ln();
- }
- public function Footer()
- {
- $this->SetY(-2,5);
- $this->SetFont('Times','','6');
- $this->Cell(5,0.5,'di cetak oleh '.$_SESSION['login_name'].' jam:'.date ("H:i:s"),0,false,'C',0,'',0,false,'T','M');
- }
- }
- $pdf = new PDF('L','cm','a4');
- $pdf->Open();
- $pdf->AliasNbPages();
- $pdf->AddPage();
- $pdf->SetMargins('3','3','3');
- $pdf->Ln();
- $pdf->Ln();
- //mencaritahu dari identitas siswa
- $s = mysql_fetch_array(mysql_query("SELECT * FROM student where nis='".$_POST['nis']."'"));
- //mendapatkan kelas
- $k = mysql_fetch_array(mysql_query("SELECT kelas, jurusan FROM kelas WHERE id_kelas='".$s['id_kelas']."'"));
- $pdf->Cell(1.5,0.5,'Nama ',0,0,'L');
- $pdf->Cell(0.5,0.5,':',0,0,'C');
- $pdf->Cell(5,0.5,$s['nama'],0,1,'L');
- $pdf->Cell(1.5,0.5,'NIS',0,0,'L');
- $pdf->Cell(0.5,0.5,':',0,0,'C');
- $pdf->Cell(5,0.5,$s['nis'],0,1,'L');
- $pdf->Cell(1.5,0.5,'Kelas',0,0,'L');
- $pdf->Cell(0.5,0.5,':',0,0,'C');
- $pdf->Cell(5,0.5,$k['kelas']." ".$k['jurusan'],0,1,'L');
- $pdf->Ln();
- if($g == 'Gasal'){
- for($n=0; $n<=5; $n++){
- $pdf->Cell(3,0.5,ucfirst($bulangasal[$n]),1,0,'C');
- }
- $pdf->Cell(3,0.5,'',0,1,'C');
- }elseif ($g == 'Genap'){
- for($n=0; $n<=5; $n++){
- $pdf->Cell(3,0.5,ucfirst($bulangenap[$n]),1,0,'C');
- }
- $pdf->Cell(3,0.5,'',0,1,'C');
- }
- //isi label
- $masuk=mysql_query("SELECT * FROM keu_".$sm['kode']." where nis='".$_POST['nis']."'");
- if(mysql_num_rows($masuk) < '1'){
- $pdf->Cell(26,0.5,'Belum ada data pembayaran SPP',0,0,'C');
- }else{
- while($m=mysql_fetch_array($masuk)){
- //th tabel
- if($g == 'Gasal'){
- for($n=0; $n<=5; $n++){
- if($m[$bulangasal[$n]] == '1'){ $value = 'Lunas'; }else { $value = 'Belum Bayar';}
- $pdf->Cell(3,0.5,$value,1,0,'C');
- }
- $pdf->Cell(3,0.5,'',0,1,'C');
- }else{
- for($n=0; $n<=5; $n++){
- if($m[$bulangenap[$n]] == '1'){ $value = 'Lunas'; }else { $value = 'Belum Bayar';}
- $pdf->Cell(3,0.5,$value,1,0,'C');
- }
- $pdf->Cell(3,0.5,'',0,1,'C');
- }
- }
- }
- $pdf->Output("Laporan keuangan ".$_POST['nis'].".pdf","D");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment