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

class Cheque_Process extends CI_Controller {

    var $main_menu_name = "cheque_process";
	var $sub_menu_name = "cheque_process";

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

		
		$this->load->model('Cheque_Process_Model');
		$this->load->model('Bank_Model');
		
			$this->load->model('Sales_Model');
		$this->load->model('Supplier_Model');
		$this->load->model('Warehouse_Model');
		$this->load->model('Common_Model');
		$this->load->model('Tax_Rates_Model');
		$this->load->model('Customer_Model');
		$this->load->model('Sales_Return_Model');
		$this->load->model('Cus_Pricing_Model');
		$this->load->model('Country_Model');
		$this->load->model('Transfer_Model');
		$this->load->model('Purchases_Model');
		$this->load->model('User_Model');
		$this->load->model('Product_Damage_Model');//
		$this->load->model('Product_Models');//
		$this->load->model('category_models');
			$this->load->model('Department_Model');
	}
	
	public function index()
	{
		$data['main_menu_name'] = $this->main_menu_name;
		$data['sub_menu_name'] = $this->sub_menu_name;				
		$data['bank_list'] = $this->Bank_Model->get_all_bank();
		
		
		$this->load->view('cheque_print',$data);
		
	//	echo "test";
		
	}
	
	public function cheque_printing()
	{
		$payee_only=$this->input->get('payee_only');
		$amount=$this->input->get('amount');
		$payee=$this->input->get('payee');
		$chque_date=$this->input->get('chque_date');
		$chque_date=date('dmY', strtotime($chque_date));
		if($payee_only==1){		
		}
		else
		{			
		$payee_only=0;	
		}
		
		
		if($amount&&$payee&&$chque_date){		
		$number_as_string=number_format($amount, 2, '.', '');
		$number_with_mark=number_format($amount, 2, '.', ',');
		
		$data['chque_date']=$chque_date;
		$data['payee']=$payee;
		$data['amount']=$number_with_mark;
		$data['payee_only']=$payee_only;		
		$data['cheque_amount_in_words']=$this->Cheque_Process_Model->convertNumber($number_as_string);
		}
		else
		{
			$data='';
		}
		
		$this->load->view('models/print_cheque',$data);
	}

	
	

}