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

class Home extends CI_Controller {	 
	public function __construct() {
        parent::__construct();
		$this->load->model('webadmin/Home_model','home');
		         
    }
	
	public function index(){ 
		//var_dump($this->session->userdata('expert')['Logged_In']);die;
		if($this->session->userdata('mapmyadmin')['Logged_In']==false){
			$this->load->view('webadmin/login_view');
		}else{  			 
			$this->load->view('webadmin/includes/mapmycareer_header');
			$this->load->view('webadmin/home_view');
			$this->load->view('webadmin/includes/mapmycareer_footer');
		}
	}
	
	
	
	public function signIn(){		
		$adminEmail=trim($this->input->post('email'));
		$adminPassword=trim($this->input->post('password'));
		if($adminEmail=="" && $adminPassword==""){
			echo json_encode(array("success"=>false,"field_name"=>'both', "text"=>'<span style="color:red">Both fields are Required!</span>'));
		}else if($adminEmail=="" ){
			echo json_encode(array("success"=>false,"field_name"=>'a_email', "text"=>'<span style="color:red">Please Enter valid Email!</span>'));
		}else if($adminPassword=="" ){
			echo json_encode(array("success"=>false,"field_name"=>'a_password', "text"=>'<span style="color:red">Please Enter valid Password!</span>'));
		}else{
			
			$exit=$this->home->is_email_exists($adminEmail);
			if($exit){
				$this->home->get_login_details($adminEmail,$adminPassword);
			}else{
				echo json_encode(array("success"=>false,"field_name"=>'a_email', "text"=>'<span style="color:red">Please Enter valid Email!</span>'));
			}			
		}	
	}
	
	function logout(){
		$this->session->unset_userdata('mapmyadmin');
		redirect(ADMIN_URL);
	}
	
	public function SendEmail() {		
        /*$from="no-reply@FreshDailies.com";
		 $to="deepakverma05445@gmail.com";
		$subject="sdsd sds";
		$msg="dhdsjddf dfdf ddsdsdd";
        $this->email->from($from, 'FRESH Dailies');
        $this->email->to($to);
        
        $this->email->subject($subject);
        $this->email->message($msg);
        $this->email->send();
        var_dump($this->email->print_debugger());die;*/
    }
	
	
	function read_docx(){
		$this->load->helper('text_helper');
		 $filename =HTTP_UPLOAD_PATH .'css.docx';
		 var_dump(ascii_to_entities($filename));die;
		 		  
	
		 //echo $striped_content;
	}
}