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

class FlexiReportCtrl extends CI_Controller
{

	public function index()
	{
		chk_login();
		$user_id=$_SESSION['user_id'];

		$this->load->model('Flexi_report_m');

		if (isset($_GET['from']) && isset($_GET['to'])) {

			$from = date("Y-m-d H:i:s", strtotime($this->input->get('from')));
			$to = date("Y-m-d H:i:s", strtotime($this->input->get('to')));

			$data['transactions']=$this->Flexi_report_m->transasction_report('*','load_transaction','created_at',$from,$to,"user_id='$user_id'");
		}
		else{

			$data['transactions']=$this->Flexi_report_m->transasction_report('*','load_transaction','','','',"user_id='$user_id'");

		}

		$this->load->view('templates/1_head.php');

		$this->load->view('templates/2_nav.php');

		$this->load->view('templates/3_sidebar_menu_left.php');

		$this->load->view('flexiload/report/transaction_load', $data); //4_dynamic

		$this->load->view('templates/5_footer.php');

		$this->load->view('templates/6_script_end.php');
	}

	public function sending_blance()
	{
		$user_id=$_SESSION['user_id'];
		$this->load->model('Flexi_report_m');

		$data['sendings']=$this->Flexi_report_m->sending_blance('','',"lt.sender_id='$user_id'");

		$this->load->view('templates/1_head.php');

		$this->load->view('templates/2_nav.php');

		$this->load->view('templates/3_sidebar_menu_left.php');

		$this->load->view('flexiload/report/sending_blance', $data); //4_dynamic

		$this->load->view('templates/5_footer.php');

		$this->load->view('templates/6_script_end.php');
	}

	public function receiving_blance()
	{
		$user_id=$_SESSION['user_id'];
		$this->load->model('Flexi_report_m');
		$data['receivings']=$this->Flexi_report_m->receiving_blance('','',"lt.receiver_id='$user_id'");

		$this->load->view('templates/1_head.php');

		$this->load->view('templates/2_nav.php');

		$this->load->view('templates/3_sidebar_menu_left.php');

		$this->load->view('flexiload/report/receiving_blance', $data); //4_dynamic

		$this->load->view('templates/5_footer.php');

		$this->load->view('templates/6_script_end.php');

	}
	public function package_order_history()
	{
		chk_login();
		$user_id=$_SESSION['user_id'];
		$this->load->model('Flexi_report_m');
		$data['orders']=$this->Flexi_report_m->package_order_history("user_id='$user_id'");

		$this->load->view('templates/1_head.php');

		$this->load->view('templates/2_nav.php');

		$this->load->view('templates/3_sidebar_menu_left.php');

		$this->load->view('flexiload/report/package_order', $data); //4_dynamic

		$this->load->view('templates/5_footer.php');

		$this->load->view('templates/6_script_end.php');

	}
	
	public function flexiIncomeHistory(){
		chk_login();

        $this->load->model('Flexi_report_m');

        $user_id = $this->session->user_id;

		$data['today'] = $this->Flexi_report_m->flexi_income($user_id,0);
	
        $data['last_seven_day'] = $this->Flexi_report_m->flexi_income($user_id,7);

        $data['last_thirtdy_day'] = $this->Flexi_report_m->flexi_income($user_id,30);

		$data['total'] = $this->Flexi_report_m->flexi_income($user_id,99999);
		
		$this->load->view('templates/1_head.php');

		$this->load->view('templates/2_nav.php');

		$this->load->view('templates/3_sidebar_menu_left.php');

		$this->load->view('flexiload/report/income_history', $data); //4_dynamic

		$this->load->view('templates/5_footer.php');

		$this->load->view('templates/6_script_end.php');
	}
	
}
