<?php
class Failed_call extends Controller
{

	function Failed_call()
	{

		parent::Controller();
	}


	function index()
	{
	    if($this->clogin->is_logged_in())
		{
			redirect("admin/cpanel", "Location");
		}
		else
		{
			redirect("login/index", "Location");
		}
	}


		

/**
 ***********************************************************************
 * @Start Failed Call  Section *****************************************
 ***********************************************************************
*/

/**
 * @Show Failed Call List
*/

	function failedCallList($errorMessage=0)
	{
		if($this->clogin->is_logged_in())
		{
			$userID = $this->session->userdata('userID');
			$reportCURD = $this->session->userdata('reportCURD');
			if($reportCURD == NO_ACCESS)
			redirect("admin/cpanel/accessDenied", "Location");

			$data['call_start'] = date('Y-m-d');
			$data['call_end'] = date('Y-m-d');
			$data['login']		= 'NULL';
			$data['called_number'] = 'NULL';
			$data['startoffset'] = "0";
			$data['limit'] = LIMIT_PERPAGE;
            $this->load->model('failedcallModel');
			$data['total'] = $this->failedcallModel->getTotalnumFailedCall($call_start=date('Y-m-d'),$call_end=date('Y-m-d'),$login='NULL',$called_number='NULL');
			$data['failedcallList'] = $this->failedcallModel->failedCallList($startoffset = 0,$limit = LIMIT_PERPAGE,$call_start=date('Y-m-d'),$call_end=date('Y-m-d'),$login='NULL',$called_number='NULL');			
			$data['titleMessage'] = 'Failed Call List';
			$data['titleErrorMessage'] = "";
			$this->load->view('failedcall/failed_call_list',$data);
		}
		else
		{
			redirect("login/index", "Location");
		}
	}
	




/**
 * @Show Failed Call List Pagination
*/

	function failedCallListPagination($startoffset,$limit,$call_start,$call_end,$login,$called_number,$myRandom=0)
	{
		if($this->clogin->is_logged_in())
		{
			$userID = $this->session->userdata('userID');
			$reportCURD = $this->session->userdata('reportCURD');
			$data['call_start'] = $call_start;
			$data['call_end'] = $call_end;
            $data['login'] = $login;
			$data['called_number'] = $called_number;
			$data['startoffset'] = $startoffset;
			$data['limit'] = $limit;
            $this->load->model('failedcallModel');
			$data['total'] = $this->failedcallModel->getTotalnumFailedCall($call_start,$call_end,$login,$called_number);
			$data['failedcallList'] = $this->failedcallModel->failedCallList($startoffset,$limit,$call_start,$call_end,$login,$called_number);			
			$data['titleMessage'] = 'Failed Call List';
			$data['titleErrorMessage'] = "";
			$this->load->view('failedcall/failed_call_list_pagi',$data);
		}
		else
		{
			redirect("login/index", "Location");
		}
	}
}