<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use Twilio\Rest\Client;
class Home extends CI_Controller {
 	 
	function __construct(){ 
		parent::__construct();
		$this->data['success_msg']=$this->session->flashdata('success');
		$this->data['error_msg']=$this->session->flashdata('error');
		$this->data['configuration_details'] = $this->Cms_mdl->get_configuration_details();
		$this->data['top_title'] = $this->data['configuration_details']->title;   		 
 	}
	
	function send_text_message($phone,$mess){
		$this->load->file('twilio-php/Services/Twilio.php');
		$account_sid = 'ACaaa81d909f72d57424fe27bae97d448a';
		$auth_token = 'f6d39e3bece39941e818c960de5faeda';
		$client = new Services_Twilio($account_sid, $auth_token);

		$messsage = $client->account->messages->create(array(
			'From' => "+14243292010",
			'To'   => $phone,
			'Body' => $mess
		));
	
		//print $message->account_sid;
	}
	
	public function send_sms(){
		// Required if your environment does not handle autoloading
		require '/home/uniotkrz/public_html/vendor/autoload.php';
		
		// Use the REST API Client to make requests to the Twilio REST API
		
		
		// Your Account SID and Auth Token from twilio.com/console
		$sid = 'AC4897d9dcea3bcb3b186d77e9b10e9536';
		$token = '0a580169ff8758905860373371a71ffd';
		$client = new Client($sid, $token);
		
		// Use the client to do fun stuff like send text messages!
		$client->messages->create(
    // the number you'd like to send the message to
    '+918982546428',
    [
        // A Twilio phone number you purchased at twilio.com/console
        'from' => '+917223055521',
        // the body of the text message you'd like to send
        'body' => 'Hey! Ankit here!'
    ]
);	
	}
	
	public function page_not_found(){
		$this->load->view('Frontend/home/page_not_found',$this->data);  			
	}
	
	public function index(){ 		 
		$this->data['title']='';
		$this->data['active_class']=''; 
		//$this->data['slider_details']=$this->Sliderhome_mdl->slider_details();
		//$this->data['welcome_content']=$this->Cms_mdl->cms_details('Home','Welcome Content');
		//$this->load->view('Frontend/includes/front/header',$this->data);
		//$this->load->view('Frontend/home/home',$this->data);
		//$this->load->view('Frontend/includes/front/footer',$this->data);  			
	}
	
	public function common_page(){	
		$page_name = $this->uri->segment($last);
		$module_name='main_content';			
		$this->data['title']=ucwords(str_replace('_',' ',$page_name));
		$this->data['active_class']=$page_name;
		$this->data['page_content']=$this->Cms_mdl->cms_details($page_name,$module_name);
		$this->load->view('Frontend/includes/header',$this->data);
		$this->load->view('Frontend/pages/single',$this->data);
		$this->load->view('Frontend/includes/footer',$this->data); 
	}
	
	public function faq(){
		$this->data['title']='FAQ'; 
		$this->data['active_class']='faq';
		$this->data['faq_details']=$this->faq_mdl->faq_details();
		$this->load->view('Frontend/includes/header',$this->data);
		$this->load->view('Frontend/pages/faq',$this->data);
		$this->load->view('Frontend/includes/footer',$this->data); 	
	}
	
	public function newsletter_subscribe(){
		if(isset($_GET['email_id'])&& $_GET['email_id']!=''){
			echo $this->Cms_mdl->newsletter_subscribe($_GET['email_id']);
		}
	}
	
	 
} 