lawang code

lawang Code


Tanyakan kode disini

Membuat laporan menggunakan Yii Framework

ditanyakan oleh epiece 3 tahun yang lalu

Selamat sore semua, saya mau tanya bagaimana cara membuat reporting Yii framework menggunakan FPDF ?

Menampilkan 1-4 dari 4 hasil

epiece menjawab 3 tahun yang lalu :

tapi ane gan pake pdf grid gan, semua lebih ke Controller, gimana caranya gan? source ane di Controller gini gan :

public function actionBeasiswa(){
    if (!Yii::app()->user->isGuest)
    tbl_beasiswa.nim_mhs, dat_mahasiswa.nama_mhs, dat_mahasiswa.tmp_lhr_mhs, dat_mahasiswa.tgl_lhr_mhs, dat_mahasiswa.almt_mhs, 
    tab_program_studi.nama_pst, tab_program_studi.fakultas, case(dat_mahasiswa.kd_jenis) when 'B' then 'S-2' else case (dat_mahasiswa.kd_jenis) when 'C' then 'S-1' else 'D-3' end end as jenjang , 
    case left(dat_mahasiswa.kd_kls,1) when '0' then mid(dat_mahasiswa.kd_kls,2,1) else mid(dat_mahasiswa.kd_kls,1,2) end semt 
    from tbl_beasiswa 
    INNER JOIN dat_mahasiswa on tbl_beasiswa.nim_mhs=dat_mahasiswa.nim_mhs
    inner join tab_program_studi on  dat_mahasiswa.kd_pst=tab_program_studi.kd_pst;
    $this->renderPartial('beasiswa');
}


handita okviyanto menjawab 3 tahun yang lalu :

Ini query doang gan? maksudnya gmana gan? tinggal pake dataProvider sendiri pake CSqlDataProvider ini di viewnya

$this->widget('ext.pdf.EPDFGrid', array(
'id'        => 'informe-pdf',
'fileName'  => 'Informe en PDF',//Nombre del archivo generado sin la extension pdf (.pdf)
'dataProvider'  => $dataProvider, //puede ser $model->search()
'columns'   => array(
    'columnName1',
    'columnName2',
    'columnName3',
    array(
        'name'  => 'columnName4',
        'value' => '$data->relationName->value',
    ),
),
'config'    => array(
    'title'     => 'Libro Diario',
    'subTitle'  => 'Informe Al: '.$model->fecha,
    'colWidths' => array(40, 90, 40, 70),
),
));


Terus controllernya gini ..

$sql="SELECT * FROM Tabel a WHERE condition INNER JOIN ..........ON ";//query agan sendiri
$dataProvider=new CSqlDataProvider($sql,array("keyField"=>"fieldAgan"));




epiece menjawab 3 tahun yang lalu :

Gan ane gak pake views ane lbih ke Controller langsung direct ke Index, Full code untuk FPDF seperti ini Gan :

    class BeasiswaController extends Controller 
   {
   public funtion actionIndex()
   }
    $_nim = Yii::app()->user->name;
    $_smt = Yii::app()->user->smt;
    $dbCommand = Yii::app()->db->createCommand("set @sum := 0;");
    $dbCommand->execute();
    $sql = 
    // "set @sum := 0;"
     "select "

    . " dat_mahasiswa.nama_mhs, dat_mahasiswa.almt_mhs, dat_mahasiswa.tgl_lhr_mhs, dat_mahasiswa.tmp_lhr_mhs, tab_program_studi.nama_pst, tab_program_studi.fakultas, case(dat_mahasiswa.kd_jenis) when 'B' then 'S-2' else case (dat_mahasiswa.kd_jenis) when 'C' then 'S-1' else 'D-3' end end as jenjang,case left(dat_mahasiswa.kd_kls,1) when '0' then mid(dat_mahasiswa.kd_kls,2,1) else mid(dat_mahasiswa.kd_kls,1,2) end semt"
    . " from dat_mahasiswa, tab_program_studi" 
    . " where dat_mahasiswa.nim_mhs='$_nim' and tab_program_studi.kd_pst = dat_mahasiswa.kd_pst;";

    $dbCommand = Yii::app()->db->createCommand($sql);
    $data = $dbCommand->queryAll($dbCommand);

    require_once ("protected/extensions/fpdf17/fpdf.php");
    $pdf=new PDF('P','mm','A4');
    $pdf->AddPage();
    $pdf->SetFont('Arial','',12);
    $pdf->SetFont('Times','B','14');
    $pdf->Cell(0,7,'','0',1,'C');
    $pdf->Cell(0,1,'SURAT KETERANGAN BEASISWA','0',1,'C');
    $pdf->Cell(0,0,'_________________________________','0',1,'C');
    $pdf->SetFont('Times','','12');
    $pdf->Cell(0,12,'Nomor: ............................................................................','0',1,'C');

    $pdf->Ln();
    $pdf->SetFont('Times','','12');
    $pdf->Cell(0,10,'Universitas , dengan ini menerangkan bahwa:','0',1,'L');
    $pdf->Cell(0,8,'','0',1,'L');

    $nama = array(
    array("label"=>"Nama","length"=>40, "align"=>"L"),
    array("label"=>':',"length"=>5, "align"=>"L"),
    array("label"=>Yii::app()->user->nama_mhs,"length"=>43, "align"=>"L"),
    );
        $pdf->SetFont('Times','','12');
        $pdf->SetFillColor(255,255,255);
        $pdf->SetTextColor(0);
        $pdf->SetDrawColor(250, 235, 215);
        foreach ($nama as $kolom) {
            $pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
        }

    $pdf->Cell(0,6,'','0',1,'L');   

    $nim = array(
            array("label"=>"NIM","length"=>40, "align"=>"L"),
            array("label"=>':',"length"=>5, "align"=>"L"),
            array("label"=>Yii::app()->user->nim_mhs,"length"=>5, "align"=>"L"),
    );
        $pdf->SetFont('Times','','12');
        $pdf->SetFillColor(255,255,255);
        $pdf->SetTextColor(0);
        $pdf->SetDrawColor(250, 235, 215);
        foreach ($nim as $kolom) {
            $pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
        }

    $pdf->Cell(0,6,'','0',1,'L');

    $tempat = array(
            array("label"=>"Tempat/Tanggal Lahir","length"=>40, "align"=>"L"),
            array("label"=>':',"length"=>5, "align"=>"L"),
            array("label"=>'',"length"=>35, "align"=>"L"),
            array("label"=>'/',"length"=>2, "align"=>"L"),
            array("label"=>'',"length"=>5, "align"=>"L"),

    );
        $pdf->SetFont('Times','','12');
        $pdf->SetFillColor(255,255,255);
        $pdf->SetTextColor(0);
        $pdf->SetDrawColor(250, 235, 215);
        foreach ($tempat as $kolom) {
            $pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
        }

    $pdf->Cell(0,6,'','0',1,'L');

    $alamat = array(
            array("label"=>"Alamat","length"=>40, "align"=>"L"),
            array("label"=>':',"length"=>5, "align"=>"L"),
            array("label"=>'',"length"=>5, "align"=>"L"),
    );
        $pdf->SetFont('Times','','12');
        $pdf->SetFillColor(255,255,255);
        $pdf->SetTextColor(0);
        $pdf->SetDrawColor(250, 235, 215);
        foreach ($alamat as $kolom) {
            $pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
        }

    $pdf->Cell(0,14,'','0',1,'L');
    $pdf->Cell(0,2,'Adalah benar yang bersangkutan adalah Mahasiswa  pada:','0',1,'L');

    $pdf->Cell(0,10,'','0',1,'L');

    $pst = array(
            array("label"=>"Program Studi","length"=>40, "align"=>"L"),
            array("label"=>':',"length"=>5, "align"=>"L"),
            array("label"=>'',"length"=>5, "align"=>"L"),
    );
        $pdf->SetFont('Times','','12');
        $pdf->SetFillColor(255,255,255);
        $pdf->SetTextColor(0);
        $pdf->SetDrawColor(250, 235, 215);
        foreach ($pst as $kolom) {
            $pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
        }

    $pdf->Cell(0,6,'','0',1,'L');

    $fakultas = array(
            array("label"=>"Fakultas","length"=>40, "align"=>"L"),
            array("label"=>':',"length"=>5, "align"=>"L"),
            array("label"=>'',"length"=>5, "align"=>"L"),
    );
        $pdf->SetFont('Times','','12');
        $pdf->SetFillColor(255,255,255);
        $pdf->SetTextColor(0);
        $pdf->SetDrawColor(250, 235, 215);
        foreach ($fakultas as $kolom) {
            $pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
        }

    $pdf->Cell(0,6,'','0',1,'L');

    $Jenjang = array(
    array("label"=>"Jenjang Pendidikan","length"=>40, "align"=>"L"),
    array("label"=>':',"length"=>5, "align"=>"L"),
    array("label"=>'',"length"=>5, "align"=>"L"),
    );
        $pdf->SetFont('Times','','12');
        $pdf->SetFillColor(255,255,255);
        $pdf->SetTextColor(0);
        $pdf->SetDrawColor(250, 235, 215);
        foreach ($Jenjang as $kolom) {
            $pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
        }

    $pdf->Cell(0,6,'','0',1,'L');

    $Semester = array(
            array("label"=>"Semester","length"=>40, "align"=>"L"),
            array("label"=>':',"length"=>5, "align"=>"L"),
            array("label"=>'',"length"=>5, "align"=>"L"),
    );
        $pdf->SetFont('Times','','12');
        $pdf->SetFillColor(255,255,255);
        $pdf->SetTextColor(0);
        $pdf->SetDrawColor(250, 235, 215);
        foreach ($Semester as $kolom) {
            $pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
        }

    $pdf->Cell(0,6,'','0',1,'L');

    $Tahun = array(
            array("label"=>"Tahun Akademik","length"=>40, "align"=>"L"),
            array("label"=>':',"length"=>5, "align"=>"L"),
            array("label"=>'',"length"=>5, "align"=>"L"),
    );
        $pdf->SetFont('Times','','12');
        $pdf->SetFillColor(255,255,255);
        $pdf->SetTextColor(0);
        $pdf->SetDrawColor(250, 235, 215);
        foreach ($Tahun as $kolom) {
            $pdf->Cell($kolom['length'], 3, $kolom['label'],0, '0', $kolom['align'], true);
        }

    $pdf->Cell(0,10,'','0',1,'L');
    $pdf->Cell(0,8,'Dengan ini kami terangkan bahwa yang bersangkutan berkelakuan baik dan belum memperoleh beasiswa','0',1,'L');
    $pdf->Cell(0,2,'dari pihak manapun.','0',1,'L');

    $pdf->Cell(0,10,'','0',1,'L');
    $pdf->Cell(0,2,'Demikian surat keterangan ini kami buat, untuk dapat dipergunakan sebagaimana mestinya.','0',1,'L');

    $pdf->Cell(0,12,'','0',1,'L');
    $pdf->Cell(0,6,', ...........................        ','0',1,'R');
    $pdf->Cell(0,6,'a.n. Rektor                                   ','0',1,'R');
    $pdf->Cell(0,6,'Ketua Program Studi                   ','0',1,'R');
    $pdf->Cell(0,10,'','0',1,'R');
    $pdf->Cell(0,15,'..............................................       ','0',1,'R');


    $pdf->Output("Beasiswa.pdf","I");
    echo "PDF file is generated successfully!";
}

// Uncomment the following methods and override them if needed
/*
public function filters()
{
    // return the filter configuration for this controller, e.g.:
    return array(
        'inlineFilterName',
        array(
            'class'=>'path.to.FilterClass',
            'propertyName'=>'propertyValue',
        ),
    );
}
}


Anda harus login terlebih dahulu untuk memberikan komentar

Recent Tag

X 6
X 49
X 14
X 10
X 1
X 5
X 4
X 13
X 10

Bantuan

Help

Feedback

Help