Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- define('FPDF_FONTPATH', 'fpdf/font/');
- include "../../conn.php";
- 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");
- $index_bln_gasal = array("juli"=>"07","agustus"=>"08","september"=>"09","oktober"=>"10","nopember"=>"11","desember"=>"12");
- $bulangenap = array("januari","februari","maret","april","mei","juni");
- $index_bln_genap = array("januari"=>"01","februari"=>"02","maret"=>"03","april"=>"04","mei"=>"05","juni"=>"06");
- $bulan=$g == 'Gasal'? $bulangasal:$bulangenap;
- $index_bln=$g == 'Gasal'? $index_bln_gasal:$index_bln_genap;
- class PDF extends FPDF
- {
- function Header()
- {
- global $status;
- $this->Image('/home/wiyr1282/public_html/images/logo.jpg',7,1.5,2.5);
- $this->SetFont('Times','B','10');
- $this->Cell(27.5,0.5,'LAPORAN KEUANGAN',0,0,'C');
- $this->Ln();
- $this->SetFont('Times','B','11');
- $this->Cell(27.5,0.5,'SMK PALEBON SEMARANG',0,0,'C');
- $this->Ln();
- $this->Cell(27.5,0.5,'Jalan Palebon Raya No. 30 Pedurungan Semarang (50199)',0,0,'C');
- $this->SetFont('Times','B','10');
- $this->Ln();
- $this->Cell(27.5,0.5,'Semester '.$status,0,0,'C');
- $this->Line(3,4.3,27.5,4.3);
- $this->Line(3,4.4,27.5,4.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->SetMargins('2.7','2','2.7');
- foreach ($_POST['kelas'] as $kelas)
- {
- $no=1;
- //mendapatkan kelas
- $kk = mysql_query("SELECT kelas, jurusan, sub_kelas FROM kelas WHERE id_kelas='$kelas'")or die(mysql_error());
- $k = mysql_fetch_array($kk);
- //mendapatkan tarif perbulan
- $t = mysql_fetch_array(mysql_query("SELECT tarif FROM tarif WHERE id_kelas='".$kelas."'"));
- $pdf->AddPage();
- $pdf->Ln();
- $pdf->Ln();
- $pdf->SetFont('Times','B','11');
- $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']." ".$k['sub_kelas'],0,1,'L');
- $pdf->Cell(2.5,0.5,'Biaya Perbulan',0,0,'L');
- $pdf->Cell(0.5,0.5,':',0,0,'C');
- $pdf->Cell(5,0.5,$t['tarif'],0,1,'L');
- $pdf->Ln();
- //header
- $pdf->Cell(1,0.5,'No.',1,0,'C');
- $pdf->Cell(2,0.5,'NIS',1,0,'C');
- $pdf->Cell(3.5,0.5,'Nama',1,0,'C');
- for($n=0; $n<=5; $n++){
- $pdf->Cell(3,0.5,ucfirst($bulan[$n]),1,0,'C');
- }
- $pdf->Cell(3,0.5,'',0,1,'C');
- $pdf->SetFont('Times','','11');
- $ss = mysql_query("SELECT * FROM student WHERE id_kelas='$kelas' ORDER BY nis ASC");
- $sum=array();
- foreach($bulan as $val)
- $sum[$val]=0;
- while($s=mysql_fetch_array($ss))
- {
- //isi label
- $masuk=mysql_query("SELECT * FROM keu_".$sm['kode']." WHERE nis='".$s['nis']."'");
- if(mysql_num_rows($masuk) < '1')
- {
- //th tabel
- $pdf->Cell(1,0.5,$no,1,0,'C');
- $pdf->Cell(2,0.5,$s['nis'],1,0,'C');
- $pdf->Cell(3.5,0.5,$s['nama'],1,0,'C');
- $pdf->Cell(18,0.5,'Belum ada data pembayaran SPP',1,1,'C');
- }
- else
- {
- while($m=mysql_fetch_array($masuk))
- {
- //th tabel
- $pdf->Cell(1,0.5,$no,1,0,'C');
- $pdf->Cell(2,0.5,$s['nis'],1,0,'C');
- $pdf->Cell(3.5,0.5,$s['nama'],1,0,'C');
- $month_value = array();
- foreach($bulan as $val)
- $month_value[$val] = $m[$val];
- $output = array();
- foreach ($month_value as $key => $value)
- {
- if($value != null)
- {
- $bln = date("m",strtotime($value));
- if(isset($output[$bln]))
- $output[$bln][$index_bln[$key]] = $key;
- else
- $output[$bln] = array($index_bln[$key]=>$key);
- }
- else
- $month_value[$key] = "-";
- }
- //idxs mencari bulan yang membayar dalam satu semester
- foreach($output as $bln)
- if(is_array($bln))
- foreach($bln as $idx => $val)
- $idxs[] = $idx ;
- $total=array();
- foreach($index_bln as $bln => $idx)
- {
- $total[$bln] = 0;
- if(array_key_exists($idx,$output))
- {
- foreach($output[$idx] as $nmbulan)
- $total[$bln]+=$t['tarif'];
- $pdf->Cell(3,0.5,$total[$bln],1,0,'C');
- }
- else
- {
- // bandingkan ke bulan membayar.
- if(in_array($idx,$idxs))
- $pdf->Cell(3,0.5,$total[$bln],1,0,'C');
- else
- $pdf->Cell(3,0.5,"-",1,0,'C');
- }
- $sum[$bln]+=$total[$bln];
- }
- $pdf->Cell(3,0.5,'',0,1,'C');
- }
- }
- $no++;
- }
- //total
- $pdf->Cell(3,0.5,'TOTAL',0,0,'C');
- foreach($bulan as $val)
- {
- $pdf->Cell(3,0.5,$sum[$val],0,1,'C');
- }
- }
- $pdf->Output("Laporan keuangan.pdf","I");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement