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

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

class pages extends BaseController {

    public function __construct()
    {
        parent::__construct();

      //  $this->load->database();
      //  $this->load->helper('url');
		$this->isLoggedIn(); 
        $this->load->library('grocery_CRUD');
 
    }

	/* This function used to show the main page of the screen */
    public function _controller_output($output = null)
    { 		 $this->load->view('includes/header'); 
        $this->load->view('Mainpage',(array)$output);
		$this->load->view('includes/footer');
    }
 

   

    public function index()
    {
		$this->_controller_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
    }
		
    public function SupplierDetails()
    {
		
		
		
        try{
            $crud = new grocery_CRUD();
			
            
            $crud->set_table('T_SupplierDetailsN');
            $crud->set_subject('Supplier Details');
            $crud->required_fields('SupplierName','Address','Contactnumber','AlternateContactNumber','EmailAddress','TIN','PAN');
            $crud->columns('SupplierID','SupplierName','Address','Contactnumber','AlternateContactNumber','EmailAddress','TIN','PAN','CreatedDate');
			$crud->field_type('CreatedDate','hidden', date("Y-m-d H:i:s"));
			$crud->field_type('SupplierID','hidden');
            $output = $crud->render();
			
			 	 
				$this->_controller_output($output);
			 
        }catch(Exception $e){
            show_error($e->getMessage().' --- '.$e->getTraceAsString());
        }
    }
	
 
	 function RawMaterial()
    {
        if($this->isAdmin() == TRUE)
        {
            $this->loadThis();
        }
        else
        {
            $this->load->model('Grocery_crud_model');
            //$data['SupplierName'] = $this->Grocery_crud_model->getSupplierName();
            //$data['users'] = $this->purchaseorder_model->getusers();
            
            $this->global['pageTitle'] = 'siddharth : Add New PO';

            $this->loadViews("Mainpage", $this->global, $data, NULL);
        }
    
        try{
            $crud = new grocery_CRUD();

            
            $crud->set_table('T_RawMaterialDetailsN');
            $crud->set_subject('RawMaterialDetails');
            $crud->required_fields('MaterialName','MaterialType','SupplierID');
            $crud->columns('MaterialCode','MaterialName','MaterialType','SupplierID','CreatedDate');
            $crud->field_type('CreatedDate','hidden', date("Y-m-d H:i:s"));
			$crud->field_type('MaterialCode','hidden');
            $output = $crud->render();

            $this->_controller_output($output);

        }catch(Exception $e){
            show_error($e->getMessage().' --- '.$e->getTraceAsString());
        }
    }
	
	 
	public function AssetDetails()
    {
		if($this->isAdmin() == TRUE)
        {
            $this->loadThis();
        }
        else
        {
            $this->load->model('Grocery_crud_model');
            //$data['SupplierName'] = $this->Grocery_crud_model->getSupplierName();
            //$data['users'] = $this->purchaseorder_model->getusers();
            
            $this->global['pageTitle'] = 'siddharth : Add New PO';

            $this->loadViews("Mainpage", $this->global,  NULL);
        }
        try{
            $crud = new grocery_CRUD();

            $now = new DateTime();
            echo $now->format('Y-m-d H:i:s');  
             echo $now->getTimestamp(); 
            $crud->set_table('T_AssetDetails');
            $crud->set_subject('AssetDetails');
            $crud->required_fields('Asset_Name','Description','Department','Location','AssetOwner','SupplierName','DateOfPurchase','DateOfCommission','SupportVendor','SupportFrom','SupportTo','CreatedDate');
            $crud->columns('Asset_Code','Asset_Name','Description','Department','Location','AssetOwner','SupplierName','DateOfPurchase','DateOfCommission','SupportVendor','SupportFrom','SupportTo','CreatedDate');
            $crud->field_type('CreatedDate','hidden', date("Y-m-d H:i:s"));
			$crud->field_type('Asset_Code','hidden');
            $output = $crud->render();

            $this->_controller_output($output);
			// $this->load->view('AssetDetails.php',(array)$output);

        }catch(Exception $e){
            show_error($e->getMessage().' --- '.$e->getTraceAsString());
        }
		
    }
public function CostDetails()
    {
        try{
            $crud = new grocery_CRUD();

           
            $crud->set_table('T_CostCentre');
            $crud->set_subject('CostDetails');
            $crud->required_fields('CostName','Description');
            $crud->columns('CostCentreID','CostName','Description','CreatedDate');
            $crud->field_type('CostCentreID','hidden');
			$crud->field_type('CreatedDate','hidden', date("Y-m-d H:i:s"));
			$output = $crud->render();
			

            $this->_controller_output($output);
			// $this->load->view('AssetDetails.php',(array)$output);

        }catch(Exception $e){
            show_error($e->getMessage().' --- '.$e->getTraceAsString());
        }
		
    }	
 	
 	


}