<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Printout extends MY_Controller {

	function __construct() {
        parent::__construct();
		$this->load->library('dompdf_gen');
    }

    function index(){
		redirect(base_url());
	}
    function kwitansi($id){
		$data['kwitansi'] = $this->model_global->get_data(array('data' => 'row','table' => 'bayar', 'where' => array( 'id_bayar' => $id)));
		$this->load->view('kwitansi',$data);
		$paper_size  = 'A4';
		$orientation = 'landscape';
		$this->dompdf->set_paper($paper_size, $orientation);
		$html = $this->output->get_output();
		$this->dompdf->load_html($html);
		$this->dompdf->render();
		$this->dompdf->stream("kwitansi_".$data['kwitansi']['id_invoice']."_".$data['kwitansi']['tanggal'].".pdf");
	}

    function invoice($id){
		$data['invoice'] = $this->model_global->get_data(array('data' => 'row','table' => 'invoice', 'where' => array( 'id_invoice' => $id)));
		$data['tiket'] = $this->model_global->get_data(array('select' => '*', 'table' => 'additional','where' => array('status !=' => -1,'id_invoice' => $id), 'order_by' => 'id_additional desc'));
		$data['dbayar'] = $this->model_global->get_data(array('select' => '*', 'table' => 'bayar','where' => array('status' => 1,'id_invoice' => $id), 'order_by' => 'id_bayar desc'));
		$this->load->view('cetakinvoice',$data);
		$paper_size  = 'A4';
		$orientation = 'portrait';
		$this->dompdf->set_paper($paper_size, $orientation);
		$html = $this->output->get_output();
		$this->dompdf->load_html($html);
		$this->dompdf->render();
		$this->dompdf->stream("invoice_".$data['invoice']['id_invoice']."_".$data['invoice']['tanggal'].".pdf");
	}

}

