<?php

	class m_masters extends  CI_Model {

		function __construct(){
		parent::__construct();		
		$this->db->query("SET time_zone='+7:00'");

		}
		public function getusers($querystring)
		{
			// $data=$this->db->query($querystring);
			$data=$this->db->query($querystring);
			$this->db->close();
			return $data;
			// return $this->db->get('users');
		}
		
		public function updating($string)
		{
			$this->db->query($string);
			$this->db->close();
		}

		public function querying($string){
			try {
		        
		        $result = $this->db->query($string);
		        if(!$result)
		        {
		        	throw new Exception('error in query');
      				return false;
		        }
		        return $result;
		    } catch (Exception $e) {
		        return;

		    }
		    $this->db->close();
		}
		public function inserting($string)
		{
			$this->db->query($string);
			$this->db->close();
		}
		public function getOperatorGroups()
		{
			$data=$this->db->query("select *  from operatorgroups order by createddate desc");
			$this->db->close();
			return $data;
		}
		public function getOperators()
		{
			$data=$this->db->query("select *  from operators order by createddate desc");
			$this->db->close();
			return $data;
		}
		public function reportcalloperator($datefrom,$dateto)
		{
        	$data=$this->db->query("call calloperator('".$datefrom."','".$dateto."')");  
        	$this->db->close();
        	return $data;                
    	}

    	public function distributedata()
    	{
    		$data = $this->db->query("call distribute()");
    		$this->db->close();
        	return $data;  
    	}

    	public function closedistributedata()
    	{
    		$data = $this->db->query("call closedistribute()");
    		$this->db->close();
        	return $data;  
    	}

        public function reportregis($datefrom,$dateto)
        {
            $data=$this->db->query("call reportregis('".$datefrom."','".$dateto."')");  
            $this->db->close();
            return $data;                
        }

        public function reportfeed($datefrom,$dateto)
        {
            $data=$this->db->query("call reportfeed('".$datefrom."','".$dateto."')");  
            $this->db->close();
            return $data;                
        }

        public function reportblast($datefrom,$dateto)
        {
            $data=$this->db->query("call reportblast('".$datefrom."','".$dateto."')");  
            $this->db->close();
            return $data;                
        }
        
        public function reportblock($datefrom,$dateto)
        {
            $data=$this->db->query("call reportblock('".$datefrom."','".$dateto."')");  
            $this->db->close();
            return $data;                
        }


    	public function reportcalloperator_og($datefrom,$dateto,$og)
		{
        	$data=$this->db->query("call calloperator_og('".$datefrom."','".$dateto."','".$og."')");  
        	$this->db->close();
        	return $data;                
    	}

    	public function reportsisadata_og($grup)
    	{
    		$data=$this->db->query("call sisadata_og('".$grup."')");  
        	return $data;   
    	}
    	public function reportsisadata_ogr($grup)
    	{
    		$data=$this->db->query("call sisadata_ogr('".$grup."')");  
        	return $data;   
    	}


    	public function reportsisadata_td($td)
    	{
    		$data=$this->db->query("call sisadata_td('".$td."')");
    		$this->db->close();   
        	return $data;

    	}

    	public function reportsisadata_tdm($td)
    	{
    		$data=$this->db->query("call sisadata_tdm('".$td."')");  
    		$this->db->close(); 
        	return $data;  

    	}

    	public function reportrawreport($datefrom,$dateto)
		{
        	$data=$this->db->query("call rawreport('".$datefrom."','".$dateto."')");  
        	$this->db->close(); 
        	return $data; 
        	               
    	}

    	public function reportrequestedplayers($datefrom,$dateto,$OG)
		{
        	$data=$this->db->query("call requestedplayers('".$datefrom."','".$dateto."','" .$OG."')");  
        	$this->db->close();  
        	return $data;  
        	             
    	}
    	public function reportrequestedplayersall($datefrom,$dateto)
		{
        	$data=$this->db->query("call requestedplayersall('".$datefrom."','".$dateto."')");  
        	$this->db->close();
        	return $data;    
        	            
    	}

	}
?>