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() {      ...

Preview PDF di Modal Bootstrap dengan Ajax

//preview pdf in line function preview_surat_keputusan(no) { $('#form')[0].reset(); $('.form-group').removeClass('has-error'); $('.help-block').empty(); $.ajax({ url : "<?php echo site_url('surat_keputusan/ajax_preview/')?>/" + no, type: "GET", dataType: "JSON",     success: function(data)     {     //paramater yang akan ditampilkan di modal         $('[name="no"]').val(data.no);         $('[name="ns"]').val(data.ns);         $('[name="thts"]').val(data.thts);         $('[name="pdf"]').val("http://localhost/dosdm/document/sm/pdf/"+data.thts+"-SK-"+data.ns+".pdf");         var link_base =  "http://localhost/dosdm/document/sm/pdf/"+data.thts+"-SK-"+data.ns+".pdf" ;             $('#pdf_view').attr('src', link_base);      ...

Hack File .xlsb

For first you must create a backup copy of your Workbook!!! Then you have to rename the XLSB file with ZIP extension. Test.XLSB => Test.ZIP             Opening your ZIP file using a compression software (e.g. WinRar) I can see the content of the file, structured in folders Inside the folder xl you can find a binary file named vbaProject.bin. Extract it on your desktop and edit it using a text editor. In my case I used Notepad++. Using the Find function of your editor, you must search the text DPB And replace the DPB string with DPx Then save the vbaProject.bin and replace this file inside the .ZIP File, renaming then .ZIP file in XLSB. Reopening the XLSB file using Excel, you will get an error message: you have to answer Yes to this error message. Then  Save , Close and Reopen your XLSB file. Now, if you go to VBA Editor (ALT + F11), you ca...