Skip to main content

bikin downloadan laporan pdf

3 replies [Last post]
lg mulai belajar dari awal framework ci nih...mohon bimbingannya...^_^
tommyshare's picture
User offline. Last seen 9 weeks 21 hours ago. Offline
Joined: 07/16/2009

agan mastah2 ci...ane need help nih tuk bikin download laporan pdf...langsung aje ke tkp koding nye yeee...

Controller guest.php

class Guest extends Controller {

function Guest() {
parent::Controller();

if ($this->auth->cek('member'))
redirect('member/memberonly');

$this->load->model('newmodel');
}

function news($mode = 'view', $item = NULL) {
switch ($mode) {
case 'view':
$this->news_view($item);
break;

case 'detail':
$this->news_detail($item);
break;
}
}

private function news_view($page) {
$this->load->library('pagination');

$config['base_url'] = site_url('guest/news/view');
$config['total_rows'] = $this->newmodel->countAll();
$config['per_page'] = '10';
$config['cur_page'] = $page;
$this->pagination->initialize($config);

$data['news'] = $this->newmodel->getThumbs(
$config['per_page'],
$config['cur_page']
);

$this->load->view('guest/news', $data);
}

private function news_detail($id) {
$data['new'] = $this->newmodel->getDetail($id);

$this->load->view('guest/news_detail', $data);
}

Model newmodel.php

class NewModel extends Model {
private $table = 'tbl_news';

function NewModel() {
parent::Model();
}

function countAll() {
$this->db->where('deleted', 0);
return $this->db->count_all($this->table);
}

function getThumbs($num, $offset) {
$this->db->select('id, judul, gambar, tgl_news');
$this->db->where('deleted', 0);
$query = $this->db->get($this->table, $num, $offset);

return $query->result();
}

function getDetail($id) {
$this->db->where('id', $id);
$this->db->where('deleted', 0);
$query = $this->db->get($this->table);

return $query->row();
}

View news_detail.php

 if ( ! defined('BASEPATH')) exit('No direct script access allowed');

Berita Selengkapnya

Judul
:
<?=$new->judul?>

Tanggal News
:
<?=$new->tgl_news?>

Kategori
:
<?=$new->kategori?>

Deskripsi
:
<?=$new->ket?>

Gambar
:
gambar?>" width="400" height="300" alt="Gambar <?=$new->judul?>" />

Curhatannya...

1. Ane mo buat link download berita dalam bentuk laporan pdf gan dr koding diatas tp letak link downloadnye ntu dibawah label tampilan gambar dr news_detail.php.

2. Ane pernah baca di http://masdeka.web.id/bikin-laporan-...n-codeigniter/ truz ane bingung nih tuk ikutin tutorial ntu masukin ke koding diatas.

3. Agan2 mastah2 ci bisa ga tolong editin koding diatas pake link tutorial intruksi No. 2.

Thx yaaa agan2 tuk wktnye sorry klo ane agak cerewet n merepotkan agan semuanya maklumlah msh newbie nih...

Next destination : Bandung (again) XD
zawaruddin's picture
User offline. Last seen 2 days 21 hours ago. Offline
Joined: 02/28/2011
Coba Pake Library php cezpdf.php ama class.pdf.php

taruh library tsb d folder libraries
untuk controller dpt gunakan fungsi seperti ini

function header($stat==0){
		//$stat1 = array();
		if(strcmp($stat,"PO")==0){
			return array('ORDER DATE','ORDER NO','ASSY NO','QTY','O/S','ETA','LAST UPDATE','CND','ADD','LEAD TIME','CUSTOMER');
		}else{ // jika $stat = "Assy"
			return array('Assy No','Product','CCT','Status','Customer');
		}
	}
function exportPdfMenu($bentuk=='landscape') {		
		$data['Header'] = $this->header();
		//load data
		$loop = 0;
		$array = array();
 
       foreach($this->po_model->getPO_All() as $row){				
			$content[$loop] = array($row->date_order,$row->no_po,
								$row->assy_no,$row->quantity,$row->outs,
								$row->eta,$row->update_order,$row->cnd,$row->add_order,$row->lead_time, $this->customers_model->getNameCustomer($row->id_cust));
 
			array_push($array, $content[$loop]);
			$loop++;				
		}		
 
 
		$this->load->library('cezpdf');
		$this->load->helper('pdf');
 
		if(strcmp($bentuk,'portrait')==0){
			$this->cezpdf = new Cezpdf('A4',$bentuk);//& new Cezpdf('A4','portrait');
			//membuat header dan footer pada file pdf yang dibuat
			header_footer_pdf($bentuk);
			$this->cezpdf->ezTable($array, $data['Header'], "PO", array('width'=>500));
		}else{
			$this->cezpdf = new Cezpdf('A4');//& new Cezpdf('A4','portrait');
			//membuat header dan footer pada file pdf yang dibuat
			header_footer_pdf($bentuk);
			$this->cezpdf->ezTable($array, $data['Header'], "PO", array('width'=>750));
		}
		//$this->cezpdf->ezTable($db_data, $col_names, "Menu", array('width'=>700));
		$this->cezpdf->ezStream();
	}

------------------------------------------------------------
Go..Go..Go.. CodeIgniter

Visit My Blog @ zawaruddin.blogspot.com

does not have a status.
codec's picture
User offline. Last seen 12 weeks 17 hours ago. Offline
Joined: 10/11/2010
coba pake plugin

coba pake plugin dompdf.
gampang makenya :D

lg mulai belajar dari awal framework ci nih...mohon bimbingannya...^_^
tommyshare's picture
User offline. Last seen 9 weeks 21 hours ago. Offline
Joined: 07/16/2009
tolongin donk...

mas codec tolong di cobain donk pake plugin dompdf dr koding yg saya ksh di atas ntu soalnye ane msh bingung cara pake dompdf truz mskin pluginnye gmn...thx yaaa tuk masukannya...maaf saya msh newbie pake ci nih...^_^

Premium Drupal Themes by Adaptivethemes