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

require APPPATH . '/libraries/BaseController.php';

class C_test extends BaseController {
  
    function __construct()
    {
        parent::__construct();
        
			$this->load->model('purchaseorder_model');
		    $this->load->library('session');
			$this->isLoggedIn();  
			//$this->load->library('grocery_CRUD');		   
    }
  
    public function create_pdf() {
    // Load all views as normal
	 
		 
			$PONO =   $_GET['PO'];
			 
			$data['PODetail'] = $this->purchaseorder_model->getPurchaseOrder($PONO);
			$data['POLineItem'] = $this->purchaseorder_model->getPOLineItem($PONO);
            //$this->global['pageTitle'] = 'Purchase Order Report';
			
			// Add header to pdf
			$this->load->view('includes/pdfheader');
			
			// Load the pdf page with multiviews
            $this->load->View("create_pdf", $data, NULL);
			
			// Add header to pdf
			$this->load->view('includes/pdffooter');
			
			// Get output html
			$php = $this->output->get_output();
			
			// Load library
			$this->load->library('dompdf_gen');
			
			// Convert to PDF
			$this->dompdf->load_html($php);
			$this->dompdf->render();
			$data['Attachment'] = FALSE;
			$this->dompdf->stream("PurchaseOrderreport.pdf",$data,$php);
		  
}
  
}
 