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

class Home extends CI_Controller { 
	 public function __construct()
       {
            parent::__construct();
			$this->load->model('product','pa');
       }
	public function index()
	{
		$data['rproducts']=$this->pa->rproducts();
		$data['page']='home';
		$this->load->view('container',$data);
	}
	public function aboutUs()
	{
		$data['page']='about_us';
		$this->load->view('container',$data);
	}
	public function contactUs($p_id=NULL)
	{
        if($p_id!=NULL)
		{
			$data=$this->pa->getproductname($p_id);
		}
		
		$data['page']='contact_us';
		$this->load->view('container',$data);
	}
	public function products()
	{
		$data['categories'] = $this->pa->get_categories();
		$data['page']='productlist';
		$this->load->view('container',$data);
	}
	public function productslist($cat_id)
	{
		$data['cproducts'] = $this->pa->get_cproducts($cat_id);
		$data['cat_name']=$this->pa->get_cname($cat_id);
		//echo '<pre>'; print_r($data);die;
		$data['page']='categoryproductlist';
		$this->load->view('container',$data);
	}
        public function sendmail()
        {
			session_start();
			if($_SESSION['captcha']==$_POST['captcha'])
			{
				$message="<html><head></head><body>Hello,<br/><br/>
				Name : ".$_POST['firstname']." ".$_POST['lastname']."<br/>
				Contact No : ".$_POST['mobile']."<br/>
				Email : ".$_POST['email']."<br/>
				Website : ".$_POST['website']."<br/>
				Company name : ".$_POST['company']."<br/>
				City : ".$_POST['city']."<br/>
				Date : ".date('d/m/Y')."<br/><br/> 
				Message : <br/>".$_POST['message']."<br/><br/>
				You can mail the info to this address — ".$_POST['email']."<br/>
				Thank you in advance, and look forward to receive the requested materials from you.<br/><br/>
				Sincerely,<br/>
				".$_POST['firstname']." ".$_POST['lastname']."<br/>
				".$_POST['company']."
				</body></html>";
				
				$mailstatus = sendsmtpmail('noreply@energyhydraulic.in','info@energyhydraulic.in','Product Inquiry: Request To Send Information',$message);
				if($mailstatus=="false")
				{
					$data=$_POST;
					$data['error']="mail fail";
				}
				else
				{
					$data['error']="mail sent";
				}
				$data['page']='contact_us';
				$this->load->view('container',$data);
				
			}
			else 
			{
				$data=$_POST;
				$data['error']="captcha";
				
				$data['page']='contact_us';
				$this->load->view('container',$data);
				
			}
            
       }
}

?>