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

class CountSheet extends CI_Controller {
	
	public function __construct(){
		parent::__construct();
		$this->load->library('layouts');
		$this->load->helper('form');
		$this->load->helper('menu');
		$this->layouts->set_title('iAccount');		
		
		$this->load->model('master/masterCode_model');
		$this->load->model('Menu');
		$this->load->model('inventory_report/Count_sheet');
		$this->lang->load("countsheet",$this->session->userdata('language'));	
	}
	
	public function listing(){
		
		/*header("HTTP/1.1 301 Moved Permanently"); 
		header("Location: ".base_url()."listing/");*/
	}
	
	//Print Count sheet for item count
	public function printCountSheet($locID = ''){
		//Retrive items based on the location
		$data['datatbls'] = $this->Count_sheet->get_loc_items(element('compID', $this->session->userdata('logged_in')),$locID);
		
		if($locID != ''){
			$this->load->model('Location');
			$data['locInfo'] = $this->Location->location_id($locID);
		}
		$id = $this->uri->segment(3);
		$data['id'] = $id;
		$this->load->model('company/company_info_model');
		$data['company'] = $this->company_info_model->companyById(element('compID', $this->session->userdata('logged_in')));
		//$data['header']	= $this->load->view('layouts/rptheader', $data);
	
		$this->load->view('inventory/countsheetprint', $data);
			
	}
	
	//List all item or list item depanding on location
	public function index($locID = ''){
		//Retrive items based on the location
		$data['datatbls'] = $this->Count_sheet->get_loc_items(element('compID', $this->session->userdata('logged_in')),$locID);
			
		if($locID != ''){
			$this->load->model('Location');
			$data['locInfo'] = $this->Location->location_id($locID);
		}		
		//Page top company information start
		//$this->load->model('company/formSetup_Model');
			
		//$this->lang->load("invoices",$this->session->userdata('language'));

		$this->load->library('layouts');
		
		//$this->load->model('Usermaster');
		//$data['records'] = $this->Usermaster->usermaster_all();
		
		$this->load->model('company/company_info_model');
		$data['company'] = $this->company_info_model->companyById(element('compID', $this->session->userdata('logged_in')));
		if($locID != '')	$data['id'] = $locID;
		else				$data['id'] = '';
		
		//$this->load->model('purchase/purchase_model');
		//$data['rptData'] = $this->purchase_model->rptGetPaymentAdvice(72);
		//Page top company information end
		
		//Gether location list
		$this->load->model('Location');
		$data['location'] = $this->Location->location_byCompanyAll(element('compID', $this->session->userdata('logged_in')));
			
		$this->layouts->add_includes('js/datatables/jquery.dataTables.min.js')
					->add_includes('js/validationengine/jquery.validationEngine.js');
		$this->layouts->view('inventory/countsheet', array('latest' => 'sidebar/latest'), $data);
	}	
}