emprit

cetak pdf

Apr 1st, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.59 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include "../../conn.php";
  4. define('FPDF_FONTPATH', 'fpdf/font/');
  5. include "fpdf/fpdf.php";
  6.  
  7. $semes = mysql_query("SELECT kode, ket_smstr FROM semester where aktif='aktif'");
  8. $sm = mysql_fetch_array($semes);
  9. $status = $sm['ket_smstr'];
  10.  
  11. //mencaritahu gasal atau genap
  12. $s      = explode(" ", $status);
  13. $g      = $s[0]; //kalo di echo hasilnya genap/gasal
  14.  
  15. $bulangasal = array("juli","agustus","september","oktober","nopember","desember");
  16. $bulangenap = array("januari","februari","maret","april","mei","juni");
  17.  
  18. class PDF extends FPDF
  19. {
  20.     function Header()
  21.     {
  22.        
  23.         $this->Image('../../../images/logo.JPG',7,0.8,2);
  24.         $this->SetFont('Times','B','10');
  25.         $this->Cell(26.5,0.5,'LAPORAN KEUANGAN',0,0,'C');
  26.         $this->Ln();
  27.         $this->SetFont('Times','B','11');
  28.         $this->Cell(26.5,0.5,'SMK PALEBON SEMARANG',0,0,'C');
  29.         $this->Ln();
  30.         $this->Cell(26.5,0.5,'Jalan Palebon Raya No. 30 Pedurungan Semarang (50199)',0,0,'C');
  31.         $this->SetFont('Times','B','10');
  32.         $this->Ln();
  33.         $this->Cell(26.5,0.5,'Semester '.$status,0,0,'C');
  34.         $this->Line(3,3.3,26.5,3.3);
  35.         $this->Line(3,3.4,26.5,3.4);
  36.         $this->Ln();
  37.     }
  38.  
  39.     public function Footer()
  40.     {  
  41.         $this->SetY(-2,5);
  42.         $this->SetFont('Times','','6');
  43.         $this->Cell(5,0.5,'di cetak oleh '.$_SESSION['login_name'].'  jam:'.date ("H:i:s"),0,false,'C',0,'',0,false,'T','M');
  44.     }
  45. }
  46.  
  47. $pdf = new PDF('L','cm','a4');
  48. $pdf->Open();
  49. $pdf->AliasNbPages();
  50. $pdf->AddPage();
  51. $pdf->SetMargins('3','3','3');
  52. $pdf->Ln();
  53. $pdf->Ln();
  54.  
  55. //mencaritahu dari identitas siswa
  56. $s = mysql_fetch_array(mysql_query("SELECT * FROM student where nis='".$_POST['nis']."'"));
  57. //mendapatkan kelas
  58. $k = mysql_fetch_array(mysql_query("SELECT kelas, jurusan FROM kelas WHERE id_kelas='".$s['id_kelas']."'"));
  59.  
  60.  
  61.     $pdf->Cell(1.5,0.5,'Nama ',0,0,'L');
  62.     $pdf->Cell(0.5,0.5,':',0,0,'C');
  63.     $pdf->Cell(5,0.5,$s['nama'],0,1,'L');
  64.     $pdf->Cell(1.5,0.5,'NIS',0,0,'L');
  65.     $pdf->Cell(0.5,0.5,':',0,0,'C');
  66.     $pdf->Cell(5,0.5,$s['nis'],0,1,'L');
  67.     $pdf->Cell(1.5,0.5,'Kelas',0,0,'L');
  68.     $pdf->Cell(0.5,0.5,':',0,0,'C');
  69.     $pdf->Cell(5,0.5,$k['kelas']." ".$k['jurusan'],0,1,'L');
  70.    
  71. $pdf->Ln();
  72.  
  73.     if($g == 'Gasal'){
  74.  
  75.         for($n=0; $n<=5; $n++){
  76.             $pdf->Cell(3,0.5,ucfirst($bulangasal[$n]),1,0,'C');
  77.         }
  78.         $pdf->Cell(3,0.5,'',0,1,'C');
  79.  
  80.     }elseif ($g == 'Genap'){
  81.  
  82.         for($n=0; $n<=5; $n++){
  83.             $pdf->Cell(3,0.5,ucfirst($bulangenap[$n]),1,0,'C');
  84.         }
  85.         $pdf->Cell(3,0.5,'',0,1,'C');
  86.  
  87.     }
  88.  
  89.     //isi label
  90.     $masuk=mysql_query("SELECT * FROM keu_".$sm['kode']." where nis='".$_POST['nis']."'");
  91.     if(mysql_num_rows($masuk) < '1'){
  92.         $pdf->Cell(26,0.5,'Belum ada data pembayaran SPP',0,0,'C');
  93.     }else{
  94.         while($m=mysql_fetch_array($masuk)){
  95.             //th tabel
  96.             if($g == 'Gasal'){
  97.                 for($n=0; $n<=5; $n++){
  98.                     if($m[$bulangasal[$n]] == '1'){ $value = 'Lunas'; }else { $value = 'Belum Bayar';}
  99.                     $pdf->Cell(3,0.5,$value,1,0,'C');
  100.                 }
  101.                 $pdf->Cell(3,0.5,'',0,1,'C');
  102.             }else{
  103.                 for($n=0; $n<=5; $n++){
  104.                     if($m[$bulangenap[$n]] == '1'){ $value = 'Lunas'; }else { $value = 'Belum Bayar';}
  105.                     $pdf->Cell(3,0.5,$value,1,0,'C');
  106.                 }
  107.                 $pdf->Cell(3,0.5,'',0,1,'C');
  108.             }
  109.         }
  110.     }
  111.    
  112.  
  113. $pdf->Output("Laporan keuangan ".$_POST['nis'].".pdf","D");
  114. ?>
Advertisement
Add Comment
Please, Sign In to add comment