<?php
class Payment_summery extends Controller
{
	function Payment_summery()
	{
		parent::Controller();
	}

	function reseller_payment_summery($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");

			 $startdate = date('Y-m-d',mktime(0,0,0,date('m'),date('d')-2,date('Y')));
			 $enddate = date('Y-m-d');
			 
			 $data['reseller4List'] = $this->generallib->getResellerList('NULL',4);
			 $data['reseller3List'] = $this->generallib->getResellerList('NULL',3);
			 $data['reseller2List'] = $this->generallib->getResellerList('NULL',2);
			 $data['reseller1List'] = $this->generallib->getResellerList('NULL',1);
			 //$data['rateList'] = $this->generallib->getTariffList($id_rate='NULL');
			 
			 $data['startdate']=  $startdate;
			 $data['enddate']=  $enddate;
             $data['reseller1id']=  '';
             $data['reseller2id']=  '';
             $data['reseller3id']=  '';
             $data['reseller4id']=  '';				 
			 $this->load->model('payment_summerymodel');
			 $data['paymentList'] = $this->payment_summerymodel->reseller_payment_summeryList($startdate,$enddate,$reseller1id='NULL',$reseller2id='NULL',$reseller3id='NULL',$reseller4id='NULL');

			 $data['titleMessage'] = "Reseller Payment Summary";
			 $data['titleErrorMessage'] = "";
			 $this->load->view('payment_summery/reseller_payment_summary',$data); 
		}
		else
		{
			redirect("login/index", "Location");
		}
	}
	
	
	function reseller_payment_summery_search($startdate='',$enddate='',$reseller1id='',$reseller2id='',$reseller3id='',$reseller4id='',$myrandom=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['reseller4List'] = $this->generallib->getResellerList('NULL',4);
             $data['reseller3List'] = $this->generallib->getResellerList('NULL',3);
             $data['reseller2List'] = $this->generallib->getResellerList('NULL',2);
             $data['reseller1List'] = $this->generallib->getResellerList('NULL',1);
             //$data['rateList'] = $this->generallib->getTariffList($id_rate='NULL');
             
             $data['startdate']=  $startdate;
             $data['enddate']=  $enddate;
             $data['reseller1id']=  $reseller1id;
             $data['reseller2id']=  $reseller2id;
             $data['reseller3id']=  $reseller3id;
             $data['reseller4id']=  $reseller4id;                 
             $this->load->model('payment_summerymodel');
             $data['paymentList'] = $this->payment_summerymodel->reseller_payment_summeryList($startdate,$enddate,$reseller1id,$reseller2id,$reseller3id,$reseller4id);

             $data['titleMessage'] = "Reseller Payment Summary";
             $data['titleErrorMessage'] = "";
             $this->load->view('payment_summery/reseller_payment_summary_search',$data);
        }
        else
        {
            redirect("login/index", "Location");
        }
    }
    
   
    
    function client_payment_summery($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");

             $startdate = date('Y-m-d',mktime(0,0,0,date('m'),date('d')-1,date('Y')));
             $enddate = date('Y-m-d');
             
             $data['startdate']=  $startdate;
             $data['enddate']=  $enddate;
             $data['wholesale_id']=  '';
             $data['gk_register_id']=  '';
             $data['ivr_id']=  '';
             
             $this->load->model('payment_summerymodel');
             $data['paymentList'] = $this->payment_summerymodel->client_payment_summeryList($startdate,$enddate,$wholesale_id='NULL',$gk_register_id='NULL',$ivr_id='NULL');

             $data['titleMessage'] = "Client Payment Summary";
             $data['titleErrorMessage'] = "";
             $this->load->view('payment_summery/client_payment_summary',$data); 
        }
        else
        {
            redirect("login/index", "Location");
        }
    }
    
    
    function client_payment_summery_search($startdate='',$enddate='',$wholesale_id='',$gk_register_id='',$ivr_id='',$myrandom=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['startdate']=  $startdate;
             $data['enddate']=  $enddate;
             $data['wholesale_id']=  $wholesale_id;
             $data['gk_register_id']=  $gk_register_id;
             $data['ivr_id']=  $ivr_id;
             
             $this->load->model('payment_summerymodel');
             $data['paymentList'] = $this->payment_summerymodel->client_payment_summeryList($startdate,$enddate,$wholesale_id,$gk_register_id,$ivr_id);

             $data['titleMessage'] = "Client Payment Summary";
             $data['titleErrorMessage'] = "";
             $this->load->view('payment_summery/client_payment_summary_search',$data);
        }
        else
        {
            redirect("login/index", "Location");
        }
    }
}