Postingan lainnya
Cara memakai TCPDF di CodeIgniter
gan, ane mau tanya caranya agar halaman web bisa jadi pdf dengan memasang library TCPDF itu gimana? ini sintaks codeigniter saya controller:
public function laporan_master_imp()
{
// load db and model
$this->load->database('sqlsrv_import_statistic', true);
$this->load->model('server/db1/import_statistic/laporan_master_imp');
$data['kueri'] = $this->laporan_master_imp->tampil_data();
$this->load->view('server/db1/import_statistic/laporan_master_imp', $data);
}
model:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Laporan_master_imp extends CI_Model
{
private $dbo;
function __construct()
{
parent::__construct();
$this->dbo = $this->load->database('sqlsrv_import_statistic', true);
}
public function tampil_data(){
$hs = $this->input->post('hs');
$importir = $this->input->post('importir');
$tglawal = $this->input->post('tglawal');
$tglakhir = $this->input->post('tglakhir');
$kueri = $this->db->query("
select Importir, Pemasok, NegaraPemasok, sum(Quantity) as Total_Quantity, sum(Berat) as Total_Berat, sum(HargaCIF) as Total_Amount
, cast(cast(sum(HargaCIF) as decimal(15,3))/cast(sum(Quantity) as decimal(15,3)) as decimal(15,3)) Average_UnitPrice_By_Qty
, cast(cast(sum(HargaCIF) as decimal(15,3))/cast(sum(Berat) as decimal(15,3)) as decimal(15,3)) Average_UnitPrice_By_Berat
, MataUang
from MASTER_IMP
where
HS like '$hs%' and Importir like '%$importir%'
and convert(datetime,TanggalPIB,103) >= '$tglawal'
and convert(datetime,TanggalPIB,103) <= '$tglakhir'
group by Pemasok, Importir, MataUang, NegaraPemasok
order by Importir, Pemasok
");
return array('hs' => $hs, 'tglawal' => $tglawal, 'tglakhir' => $tglakhir, 'result' => $kueri);
}
}
view:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Laporan MASTER_IMP</title>
<?php include 'application/views/komponen/header.php'; ?>
</head>
<body>
<div class="container-fluid text-center">
<div class="row content">
<div class="col text-right">
Tanggal terbit: <?php echo date('d M Y'); ?>
</div>
<div class="col-sm-12 text-left">
<div class="row">
<div class="col text-center">
<h3><u>REPORT</u></h3>
<h5>HS: <?php echo $kueri['hs']; ?></h5>
<h6>PERIOD (<?php
$timeawal = strtotime($kueri['tglawal']);
$newformatawal = date('d M Y',$timeawal);
$timeakhir = strtotime($kueri['tglakhir']);
$newformatakhir = date('d M Y',$timeakhir);
echo $newformatawal; ?> - <?php echo $newformatakhir; ?>)</h6>
</div>
</div>
<table class="table table-hover table-bordered">
<thead>
<tr style="background-color:darkgray">
<th>NO</th>
<th>SUPPLIER</th>
<th>COO SUPPLIER</th>
<th>IMPORTER</th>
<th>QUANTITY (KG)</th>
<th>AMOUNT</th>
<th>UNIT PRICE</th>
</tr>
</thead>
<?php
$no = 1;
$sum_Total_Berat=0;
$sum_Total_Amount=0;
foreach($kueri['result']->result() as $baris){
?>
<tr>
<td align="right"><?php echo number_format($no++,0,",","."); ?></td>
<td><?php echo $baris->Pemasok; ?></td>
<td><?php echo strtoupper($this->kode_negara->list_negara($baris->NegaraPemasok)); ?></td>
<td><?php echo $baris->Importir; ?></td>
<td align="right"><?php echo number_format($baris->Total_Berat,0,",","."); ?></td>
<td align="right"><?php echo number_format($baris->Total_Amount,2,",","."); ?></td>
<td align="right"><?php echo number_format($baris->Average_UnitPrice_By_Berat,2,",","."); ?></td>
<?php
$sum_Total_Berat += $baris->Total_Berat;
$sum_Total_Amount += $baris->Total_Amount;
}
?>
<tr style="background-color:skyblue">
<td colspan="4" align="center">TOTAL</td>
<td align="right"><?php echo number_format($sum_Total_Berat,0,",","."); ?></td>
<td align="right"><?php echo number_format($sum_Total_Amount,2,",","."); ?></td>
<td></td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>
mohon bantuannya
0
3 Jawaban:
pertama load librarynya dlu, $this->load->library(path/to/library/class); langsung aja load view. di dalem view nya pake contonya aja ada di folder examples di dalam tcpdf :v
0
Biasakan baca - baca dulu dokumentasi dari library yang mau di pakai dan juga liat example code nya yang ada ^^. Di sana udah di jelasin caranya mas gan hehe
0