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

class Infos extends CI_Controller {

	public function __construct(){
        parent::__construct();
		$this->load->model('token_model');
    }


    public function index()
    {
		$headers = apache_request_headers();

		## METHOD INCONNU
		$method = $_SERVER['REQUEST_METHOD'];
		$this->token_model->valideMethod($method,'GET');

		## AUTHENTIFICATION 
		$login = $headers['Authorization'];
		$explode = explode(' ',$login);
		$login = trim($explode[1]);	
		$this->token_model->valideToken($login);
		
		$query = "select agents.company as business_name,neighborhood,phone_number,agent_id as business_id from agents  where agent_id='".$this->token_model->agent_id."'";
		
		$account = $this->db->query($query)->row_array();
		
		/** */
		

		if(empty($account))
		{
			header('HTTP/1.0 401 Unauthorized');
			$return['error'] =apiError(400,"This account is not configured.");
			local_json($return);
		}
		$result['data']=$account;
		
		$reponse['solde']= $account['Balance'];
		$reponse['commission'] = floor($account['commission']*10000)/10000;
		
		local_json($result);
		
    }
	
	public function add()
    {

	}
}