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

class AccountReceivables extends CI_Controller {
	public function __construct(){
		parent::__construct();
		$this->load->library('layouts');
		$this->load->model('menu');
	}
	
	public function index()
	{
		$this->lang->load("ar",$this->session->userdata('language'));
		$this->layouts->add_includes('js/charts/excanvas.min.js')
			->add_includes('js/charts/jquery.flot.js')
//			->add_includes('js/charts/jquery.flot.stack.js')
//			->add_includes('js/charts/jquery.flot.pie.js')
//			->add_includes('js/charts/jquery.flot.resize.js')
//			->add_includes('js/jvectormap/jquery-jvectormap-1.2.2.min.js')
			;
		$this->layouts->view('ar/home', array('latest' => 'sidebar/latest'));
		}
	public function openInvoice_AR(){
		$this->lang->load("salesorder",$this->session->userdata('language'));
		$this->load->model('Ar_chart');
		$this->load->model('Compfinancialyear');
		$query = $this->Ar_chart->openInvoices_all();
		if($query){
   			print json_encode(array(
				"status"=>"success", 
				"message"=>$query,
				));
		}else{
   			print json_encode(array(
				"status"=>"failed", 
				"message"=>'',
				));
		}
	}
	public function payment_AR(){
		$this->lang->load("salesorder",$this->session->userdata('language'));
		$this->load->model('Ar_chart');
		$this->load->model('Compfinancialyear');
			$add_year = date("Y");
			$query1 = $this->Compfinancialyear->financialYear_yearperiod($add_year,1);
			if($query1){
				$startDate = $query1[0]->startDate;
//				$endDate = $query1[0]->endDate;
			}else{
				
			}
		$data['selyear'] = $add_year;
		$data['selper'] = $add_period;
		$query = $this->Ar_chart->receivables_all_date($startDate, $endDate);
		if($query){
   			print json_encode(array(
				"status"=>"success", 
				"message"=>$query,
				));
		}else{
   			print json_encode(array(
				"status"=>"failed", 
				"message"=>'',
				));
		}
	}
}

?>
