Skip to main content

Cetak Rekap dengan MPDF

Controller:

class Sks_rekap extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('sks/sks_rekap_model');
}

public function index()
{
    $this->load->model('sks/sks_rekap_model');
    $data['departments'] =  $this->sks_rekap_model->get_departments();
    $data['center']='sks/sks_rekap_view';
        /* note - you don't need to have the extension when it's a php file */
    $this->load->view('dashboard/v_dashboard',$data);

}

public function cetak()
{
    $this->load->model('sks/sks_rekap_model');
    $data['departments'] =  $this->sks_rekap_model->get_departments();
        /* note - you don't need to have the extension when it's a php file */
    $this->load->view('sks/sks_rekap_cetak_mpdf',$data);

}



}

//

model

<?php
//Fuile ada di model/keluar2016/keluar2016_model.php
defined('BASEPATH') OR exit('No direct script access allowed');
class Sks_rekap_model extends CI_Model {

public function __construct()
{
parent::__construct();
$this->load->database();
$this->db = $this->load->database('simpeg', TRUE);
}


public function get_departments()
{
    $sql = $this->db->query("SELECT
            thsms,
            kd_dosen,
            nama,

            fakultas_ekonomi,
            fakultas_hukum,
            fakultas_teknik_sipil_dan_perencanaan,
            fakultas_teknologi_industri,

            fakultas_mipa,
            fakultas_iai,
            fakultas_psikologi_dan_ilmu_sosial_budaya,
            fakultas_kedokteran,
            fakultas_d3k,
            fakultas_d3fe,
            fakultas_PM,

            fakultas_ekonomi + fakultas_hukum + fakultas_teknik_sipil_dan_perencanaan + fakultas_teknologi_industri + fakultas_mipa + fakultas_iai + fakultas_psikologi_dan_ilmu_sosial_budaya + fakultas_kedokteran + fakultas_d3k
            AS total_durasi

        FROM (
            SELECT
                thsms,
                kd_dosen,
                nama,

                SUM(IF(fakultas = 'FE', sks,0)) AS fakultas_ekonomi,
                SUM(IF(fakultas = 'FH', sks,0)) AS fakultas_hukum,
                SUM(IF(fakultas = 'FTI', sks,0)) AS fakultas_teknologi_industri,
                SUM(IF(fakultas = 'FTSP', sks,0)) AS fakultas_teknik_sipil_dan_perencanaan,
                SUM(IF(fakultas = 'MIPA', sks,0)) AS fakultas_mipa,
                SUM(IF(fakultas = 'FK', sks,0)) AS fakultas_kedokteran,
                SUM(IF(fakultas = 'FPSB', sks,0)) AS fakultas_psikologi_dan_ilmu_sosial_budaya,
                SUM(IF(fakultas = 'FIAI', sks, 0)) AS fakultas_iai,
                SUM(IF(fakultas = 'D3K', sks, 0)) AS fakultas_d3k,
                SUM(IF(fakultas = 'D3FE', sks, 0)) AS fakultas_d3fe,
                SUM(IF(fakultas = 'PM', sks, 0)) AS fakultas_PM

                FROM
                sks_mengajar_pasca
            WHERE nama NOT LIKE '%DOSEN%' AND nama NOT LIKE '%ASS.%'
            GROUP BY nama
        ) AS temp_table");
    return $sql->result();

}

}

//

mpdf
//
<?php

$path  = $_SERVER['DOCUMENT_ROOT'];
    $path1 = "/raport/assets/mpdf60/mpdf.php";
    include ($path.$path1);
ob_start();

?>

<style>
h1 {
    font-family: Bookman Old Style;
    font-size: 24px;
    font-style: normal;
    font-variant: normal;
    font-weight: 500;
    line-height: 26.4px;
}
h3 {
    font-family: Bookman Old Style;
    font-size: 14px;
    font-style: normal;
    font-variant: normal;
    font-weight: 500;
    line-height: 15.4px;
}
p {
    font-family: Bookman Old Style;
    font-size: 14px;
    font-style: normal;
    font-variant: normal;
    font-weight: 400;
    line-height: 20px;
}
blockquote {
    font-family: Bookman Old Style;
    font-size: 21px;
    font-style: normal;
    font-variant: normal;
    font-weight: 400;
    line-height: 30px;
}
pre {
    font-family: Bookman Old Style;
    font-size: 13px;
    font-style: normal;
    font-variant: normal;
    font-weight: 400;
    line-height: 18.5667px;
}

td {
    padding: 3px 5px 3px 5px;
    border-right: 1px solid #666666;
    border-bottom: 1px solid #666666;
}

.head td {
    font-weight: bold;
    font-size: 12px;
    valign: center;
    background: #D3D3D3 ;
}

table .main tbody tr td {
    font-size: 12px;
}

table, table .main {
    width: 100%;
    border-top: 1px solid #666;
    border-left: 1px solid #666;
    border-collapse: collapse;
    background: #fff;
   
}


table.polosz, table.polosz, tr.polosz, td.polosz {
    border-top: 0px ;
    border-left: 0px ;
    border-right: 0px ;
    border-bottom: 0px ;
}



h1 {
    font-size:30px;
}

displayed {
    display: block;
    margin-left: auto;
    margin-right: auto }
polosz {
border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px;
}
</style>

<!--- ISIAN --->

<table>
<?php
foreach($departments as $store)
    {
            echo  '<tr>';
            echo  '<td>'. $store->thsms . ' - '.$store->kd_dosen.'</td>';
            echo  '<td>'. $store->nama . '</td>';
            echo  '<td>'. $store->fakultas_psikologi_dan_ilmu_sosial_budaya . '</td>';
            echo  '<td>'. $store->fakultas_psikologi_dan_ilmu_sosial_budaya . '</td>';           
            echo  '<td>'. $store->fakultas_psikologi_dan_ilmu_sosial_budaya . '</td>';                   
            echo  '</tr>';       
    }
?>

</table>

<!--- ISIAN --->

<?php

$content = ob_get_clean();

$header = '<table cellpadding=0 cellspacing=0 style="border:none;">
           <tr><td style="border:none;" align="left"></td></tr></table>';

$footer = '<table cellpadding=0 cellspacing=0 style="border:none;">
           <tr><td style="margin-right:-5px;border:none;" align="left">
           Dicetak: '.date("Y-m-d H:i").'</td>
           <td style="margin-right:-5px;border:none;" align="right">
           Halaman: {PAGENO} / {nb}</td></tr></table>';   
try {

/* $mpdf=new mPDF('utf-8', array(190,236) ,'Arial', 8, 8, 19, 5, 5, 4);  */
   
    $mpdf=new mPDF('utf-8', "A4", 9 ,'Bookman', 8, 8, 20, 5, 5, 4);
/*     $mpdf->simpleTables = true;
    $mpdf->packTableData = true;
    $keep_table_proportions = TRUE;
    $mpdf->shrink_tables_to_fit=1; */

    $mpdf->SetTitle("Raport Kurikulum 2013");
    $mpdf->AddPage();
    $mpdf->setHTMLHeader($header);
    $mpdf->setHTMLFooter($footer);
    $stylesheet = file_get_contents('css/style_1.css');
    $mpdf->WriteHTML($stylesheet,1);
    $mpdf->WriteHTML($content);
    $mpdf->Output("Coba","I");
} catch(Exception $e) {
    echo $e;
    exit;
}
?>
//view/sks/

Comments

Popular posts from this blog

FPDF dengan CodeIgniter

Cetak Surat Keputusan Controller: <?php //File in controller named surat_keputusan.php defined('BASEPATH') OR exit('No direct script access allowed'); class Cetak_surat_keputusan extends CI_Controller { public function __construct()     {         parent::__construct();         $this->load->helper('url');         $this->load->database();                $this->db->select();         $this->db->from('surat.config_sk');                $query = $this->db->get();                 return $query->result();             } public function index() {      ...

Layar Biru versi PHP Bagian 1 (file prefil_dbf.php)

file config.php <?php $db_uname = 'root'; $db_passwd = ''; $db_name = 'layar_biru'; //database yang dipilih $db_host = 'localhost'; $xbase_dir = 'D:\ACADEMIC\htdocs\layar_biru\files'; $die_on_mysql_error = false; // when investigating errors, set this to true $from_encoding=""; //Encoding of database, e.g. CP866 or empty, if convert is not required     file prefil.dbf   <?php include "config.php";            // please copy the config.sample.php and edit the correct fields include "classes/XBase/Table.php"; include "classes/XBase/Column.php"; include "classes/XBase/Record.php"; include "classes/DBFhandler.php"; use XBase\Table;  // Initializing vars ini_set( 'memory_limit', '2048M' ); set_time_limit( 0 ); $time_start = time(); $files = scandir($xbase_dir) or die ("Error! Could not open directory '$xbase_dir'."); $conn = new mysqli($db_host,...

Converter dbf ke MYSQL

Banyak tool yang dipakai dan direkomendasikan orang untuk mengkonversi database , khususnya DBF ke MySQL. Ada yang menggunakan / menyarankan Navicat, CDBF for Linux , dbf2mysql, MySQL Migration Toolkit , dll. Bahkan ada pula yang mau bersusah-payah melakukannya dengan cara tradisionil dan ribet, yaitu dengan menggunakan MS Access: ekspor file ini, ganti syntax-nya menjadi sql, bla..bla..bla… dsb. Setelah menyimak semuanya, endingnya ternyata gak bikin happy. Meski begitu saya hargai effort mereka. Karena dari upaya mereka itulah kita menjadi tahu bahwa tool yang ini dan itu tidak cocok  dipakai. Tool yang saya pakai adalah Full Convert Enterprise (FCE). Komen saya terhadap tool ini cuma satu, keren! Kenapa? Karena bukan hanya source DBF saja yang bisa di-convert, tapi juga source lainnya (Interbase/Firebird, Oracle , Paradox, SQL Server, dll). Download: Full Convert Enterprise Full Version di sini (size 4.7 MB) Password: bayusibond Berikut adalah langkah-langkah m...