299 lines
7.9 KiB
PHP
299 lines
7.9 KiB
PHP
<?php
|
|
//session_start();
|
|
$riwayat_kegiatan_id=$_GET['riwayat_kegiatan_id'];
|
|
/**
|
|
* @author Achmad Solichin
|
|
* @website http://achmatim.net
|
|
* @email achmatim@gmail.com
|
|
*/
|
|
|
|
|
|
|
|
require_once("fpdf17/fpdf.php");
|
|
|
|
class FPDF_AutoWrapTable extends FPDF {
|
|
private $data = array();
|
|
private $options = array(
|
|
'filename' => '',
|
|
'destinationfile' => '',
|
|
'paper_size'=>'F4',
|
|
'orientation'=>'P'
|
|
);
|
|
|
|
function __construct($data = array(), $options = array()) {
|
|
parent::__construct();
|
|
$this->data = $data;
|
|
$this->options = $options;
|
|
}
|
|
|
|
public function rptDetailData () {
|
|
//
|
|
$border = 0;
|
|
$this->AddPage();
|
|
$this->SetAutoPageBreak(true,30);
|
|
$this->AliasNbPages();
|
|
$left = 25;
|
|
|
|
//header
|
|
/* $this->SetFont("", "B", 15);
|
|
$this->MultiCell(0, 12, 'PT. ACHMATIM DOT NET');
|
|
$this->Cell(0, 1, " ", "B");
|
|
$this->Ln(10); */
|
|
|
|
include('../koneksi.php');
|
|
date_default_timezone_set('Asia/Jakarta');
|
|
$riwayat_kegiatan_id=$_GET['riwayat_kegiatan_id'];
|
|
|
|
$kpl=pg_query("SELECT p.nama,p.nipb,k.pangkat
|
|
FROM data_kepala k
|
|
INNER JOIN data_pegawai p ON (p.id=k.data_pegawai_id) WHERE k.aktif='t'");
|
|
while($rkpl=pg_fetch_array($kpl)) {
|
|
$nm_kepala=$rkpl[0];
|
|
$pangkat=$rkpl[2];
|
|
$nip=$rkpl[1];
|
|
}
|
|
|
|
$thn_skrg=date('Y');
|
|
$jam=$_POST['jam_main'];
|
|
$data = pg_query("SELECT no_undangan,tgl_acara,waktu_mulai,waktu_selesai,
|
|
(SELECT nama FROM data_ruangan WHERE id=tempat),
|
|
tujuan,
|
|
(SELECT nama FROM data_pegawai WHERE id=pimpinan),
|
|
(SELECT nama FROM satuan_kerja WHERE id=penanggungjawab),
|
|
(SELECT nama FROM data_pegawai WHERE id=notulis),
|
|
(SELECT nama FROM jabatan_pegawai WHERE id=(SELECT jabatan_pegawai_id FROM data_pegawai WHERE id=pimpinan)),
|
|
(SELECT nipb FROM data_pegawai WHERE id=notulis),
|
|
(SELECT nama FROM satuan_kerja WHERE id=perencana_rapat),
|
|
kesimpulan
|
|
FROM riwayat_kegiatan WHERE id='$riwayat_kegiatan_id'");
|
|
while($row=pg_fetch_array($data)) {
|
|
$no_undangan=$row['no_undangan'];
|
|
$tgl_kegiatan=$row['tgl_acara'];
|
|
$waktu_mulai=$row['waktu_mulai'];
|
|
$waktu_selesai=$row['waktu_selesai'];
|
|
$nm_ruangan=$row[4];
|
|
$tujuan_rapat=$row['tujuan'];
|
|
$nm_pimpinan=$row[6];
|
|
$satker=$row[7];
|
|
$nm_notulen=$row[8];
|
|
//$jabatan=$row[9];
|
|
$jabatan=$row[12];
|
|
$nip=$row[10];
|
|
$perencana_rapat=$row[11];
|
|
}
|
|
|
|
$array_hari = array(1=>"Senin","Selasa","Rabu","Kamis","Jumat", "Sabtu","Minggu");
|
|
$hari = $array_hari[date("N",strtotime($tgl_kegiatan))];
|
|
|
|
$bulan = array(
|
|
'01' => 'JANUARI',
|
|
'02' => 'FEBRUARI',
|
|
'03' => 'MARET',
|
|
'04' => 'APRIL',
|
|
'05' => 'MEI',
|
|
'06' => 'JUNI',
|
|
'07' => 'JULI',
|
|
'08' => 'AGUSTUS',
|
|
'09' => 'SEPTEMBER',
|
|
'10' => 'OKTOBER',
|
|
'11' => 'NOVEMBER',
|
|
'12' => 'DESEMBER',
|
|
);
|
|
$bulan[date('m')];
|
|
|
|
$this->SetFont("", "B", 12);
|
|
$this->SetX($left); $this->Cell(0, 10, strtoupper('notulen rapat '.$perencana_rapat), 0, 1,'C');
|
|
$this->SetX($left); $this->Cell(0, 20, 'RSUD DR. SAIFUL ANWAR', 0, 1,'C');
|
|
$this->Ln(20);
|
|
$this->SetFont('Arial','',12);
|
|
$this->SetX($left); $this->Cell(0, 10, 'Hari / Tanggal : '.strtoupper($hari).', '.date('d',strtotime($tgl_kegiatan)).' '.(strtoupper($bulan[date('m',strtotime($tgl_kegiatan))])).' '.date('Y',strtotime($tgl_kegiatan)), 0, 1,'L');
|
|
$this->SetX($left); $this->Cell(0, 20, 'Waktu : '.date('H:i',strtotime($waktu_mulai)).' - '.date('H:i',strtotime($waktu_selesai)), 0, 1,'L');
|
|
$this->SetX($left); $this->Cell(0, 10, 'Pimpinan Rapat : '.$nm_pimpinan, 0, 1,'L');
|
|
$this->SetX($left); $this->Cell(0, 20, 'Jabatan : '.$jabatan, 0, 1,'L');
|
|
$this->SetX($left); $this->Cell(0, 10, 'Notulis : '.$nm_notulen, 0, 1,'L');
|
|
$this->Ln(15);
|
|
$this->SetX($left); $this->Cell(0, 10, 'Hal-hal yang perlu ditindaklanjuti :', 0, 1,'L');
|
|
$this->Ln(15);
|
|
$h = 23;
|
|
$left = 40;
|
|
$top = 80;
|
|
#tableheader
|
|
$this->SetFillColor(255);
|
|
$left = $this->GetX();
|
|
$this->SetFont("", "B", 11);
|
|
$this->Cell(45,$h,'No',1,0,'C',true);
|
|
$this->SetX($left += 45); $this->Cell(250, $h, 'Pembahasan', 1, 0, 'C',true);
|
|
$this->SetX($left += 250); $this->Cell(250, $h, 'Tindak Lanjut', 1, 1, 'C',true);
|
|
//$this->Ln(20);
|
|
|
|
$this->SetFont('Arial','',11);
|
|
$this->SetWidths(array(45,250,250));
|
|
$this->SetAligns(array('C','L','L'));
|
|
|
|
$no = 1; $this->SetFillColor(255);
|
|
foreach ($this->data as $baris) {
|
|
$this->Row(
|
|
array($no++,
|
|
$baris['pembahasan'],
|
|
$baris['tindak_lanjut']
|
|
));
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public function printPDF () {
|
|
|
|
if ($this->options['paper_size'] == "F4") {
|
|
$a = 8.3 * 72; //1 inch = 72 pt
|
|
$b = 13.0 * 72;
|
|
$this->FPDF($this->options['orientation'], "pt", array($a,$b));
|
|
} else {
|
|
$this->FPDF($this->options['orientation'], "pt", $this->options['paper_size']);
|
|
}
|
|
|
|
$this->SetAutoPageBreak(false);
|
|
$this->AliasNbPages();
|
|
$this->SetFont("helvetica", "B", 10);
|
|
//$this->AddPage();
|
|
|
|
$this->rptDetailData();
|
|
|
|
$this->Output($this->options['filename'],$this->options['destinationfile']);
|
|
}
|
|
|
|
private $widths;
|
|
private $aligns;
|
|
|
|
function SetWidths($w)
|
|
{
|
|
//Set the array of column widths
|
|
$this->widths=$w;
|
|
}
|
|
|
|
function SetAligns($a)
|
|
{
|
|
//Set the array of column alignments
|
|
$this->aligns=$a;
|
|
}
|
|
|
|
function Row($data)
|
|
{
|
|
//Calculate the height of the row
|
|
$nb=0;
|
|
for($i=0;$i<count($data);$i++)
|
|
$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
|
|
$h=14*$nb;
|
|
//Issue a page break first if needed
|
|
$this->CheckPageBreak($h);
|
|
//Draw the cells of the row
|
|
for($i=0;$i<count($data);$i++)
|
|
{
|
|
$w=$this->widths[$i];
|
|
$a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
|
|
//Save the current position
|
|
$x=$this->GetX();
|
|
$y=$this->GetY();
|
|
//Draw the border
|
|
$this->Rect($x,$y,$w,$h);
|
|
//Print the text
|
|
$this->MultiCell($w,14,$data[$i],0,$a);
|
|
//Put the position to the right of the cell
|
|
$this->SetXY($x+$w,$y);
|
|
}
|
|
//Go to the next line
|
|
$this->Ln($h);
|
|
}
|
|
|
|
function CheckPageBreak($h)
|
|
{
|
|
//If the height h would cause an overflow, add a new page immediately
|
|
if($this->GetY()+$h>$this->PageBreakTrigger)
|
|
$this->AddPage($this->CurOrientation);
|
|
}
|
|
|
|
function NbLines($w,$txt)
|
|
{
|
|
//Computes the number of lines a MultiCell of width w will take
|
|
$cw=&$this->CurrentFont['cw'];
|
|
if($w==0)
|
|
$w=$this->w-$this->rMargin-$this->x;
|
|
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
|
|
$s=str_replace("\r",'',$txt);
|
|
$nb=strlen($s);
|
|
if($nb>0 and $s[$nb-1]=="\n")
|
|
$nb--;
|
|
$sep=-1;
|
|
$i=0;
|
|
$j=0;
|
|
$l=0;
|
|
$nl=1;
|
|
while($i<$nb)
|
|
{
|
|
$c=$s[$i];
|
|
if($c=="\n")
|
|
{
|
|
$i++;
|
|
$sep=-1;
|
|
$j=$i;
|
|
$l=0;
|
|
$nl++;
|
|
continue;
|
|
}
|
|
if($c==' ')
|
|
$sep=$i;
|
|
$l+=$cw[$c];
|
|
if($l>$wmax)
|
|
{
|
|
if($sep==-1)
|
|
{
|
|
if($i==$j)
|
|
$i++;
|
|
}
|
|
else
|
|
$i=$sep+1;
|
|
$sep=-1;
|
|
$j=$i;
|
|
$l=0;
|
|
$nl++;
|
|
}
|
|
else
|
|
$i++;
|
|
}
|
|
return $nl;
|
|
}
|
|
} //end of class
|
|
|
|
/* contoh penggunaan dengan data diambil dari database mysql
|
|
*
|
|
* 1. buatlah database di mysql
|
|
* 2. buatlah tabel 'pegawai' dengan field: nip, nama, alamat, email dan website
|
|
* 3. isikan beberapa contoh data ke tabel pegawai tersebut.
|
|
*
|
|
* */
|
|
|
|
#koneksi ke database (disederhanakan)
|
|
include('../koneksi.php');
|
|
$riwayat_kegiatan_id=$_GET['riwayat_kegiatan_id'];
|
|
|
|
#ambil data dari DB dan masukkan ke array
|
|
$data = array();
|
|
$query = "SELECT pembahasan,tindak_lanjut FROM riwayat_notulen WHERE riwayat_kegiatan_id='$riwayat_kegiatan_id' ORDER BY id ASC";
|
|
$sql = pg_query ($query);
|
|
while ($row = pg_fetch_assoc($sql)) {
|
|
array_push($data, $row);
|
|
}
|
|
|
|
//pilihan
|
|
$options = array(
|
|
'filename' => '', //nama file penyimpanan, kosongkan jika output ke browser
|
|
'destinationfile' => '', //I=inline browser (default), F=local file, D=download
|
|
'paper_size'=>'F4', //paper size: F4, A3, A4, A5, Letter, Legal
|
|
'orientation'=>'P' //orientation: P=portrait, L=landscape
|
|
);
|
|
//unset($_SESSION['riwayat_kegiatan_id']);
|
|
$tabel = new FPDF_AutoWrapTable($data, $options);
|
|
$tabel->printPDF();
|
|
|
|
?>
|