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

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

/**
 * Class : purchaseorder (PurchaseorderController)
 * User Class to control all user related operations.
 * @author : VenbaMail Mali
 * @version : 1.1
 * @since : 15 Feb 2016
 */
class purchaseorderform extends BaseController
{
    /**
     * This is default constructor of the class
     */
    public function __construct()
    {
        parent::__construct();
        $this->load->model('purchaseorder_model');
		
		$this->load->library('session');
	    $this->load->library('form_validation');
		
        $this->isLoggedIn();   
    }
    
    /**
     * This function used to load the first screen of the user
     */
    
	     function purchaseorder()
    {      
            
            
            $this->global['pageTitle'] = 'Siddharth : Purchase order form';
			 $data['MaterialList'] = $this->purchaseorder_model->getRawMaterialList(); 
			  $data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006');  
			 $data['RequestType'] = $this->purchaseorder_model->getConfigValue('C004');  
			 $data['Suplist'] = $this->purchaseorder_model->getSupplierName();  
            
            $this->loadViews("Purchaseorder", $this->global,$data, NULL);
         
    }
	       function alternatepo()
    {
        
            $this->global['pageTitle'] = 'Siddharth : Alternate PO';
            
            $this->loadViews("alterpurchaseorder", $this->global, NULL);
         
    }
	function alternatepoprint()
    {                 
            $this->global['pageTitle'] = 'Siddharth : Alternate PO print';
            
            $this->load->View("alterpurchaseorderprint", $this->global, NULL);  
			$php  = $this->output->get_output();		
		    
			// Load library
			$this->load->library('dompdf_gen');
			
				 			
			require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php');
			$dompdf = new DOMPDF();
			$dompdf->set_paper('A4', 'portrait');
			$dompdf->load_html($php);
			
			$dompdf->render();
			 
			// add the header
			$canvas = $dompdf->get_canvas();
			$font = Font_Metrics::get_font("helvetica", "bold");

					// the same call as in my previous example
			$canvas->page_text(72, 18, "Page: {PAGE_NUM} of {PAGE_COUNT}",
                   $font, 6, array(0,0,0));
				   
			$dompdf->stream($filename); 			
    }
	
    function pageNotFound()
    {
        $this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';
        
        $this->loadViews("404", $this->global, NULL, NULL);
    }
}

?>