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

class Contact extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see https://codeigniter.com/user_guide/general/urls.html
	 */
	function __construct() 
	{
        error_reporting(0);
        parent::__construct();

       
    }
	public function index()
	{
		$data['content'] = 'contact';
		$this->load->view('layout_home', $data);
		
	}
	public function mail()
	{
		$input_data = $this->input->post();
        $input_data = $this->security->xss_clean($input_data);

        $content='<html>
		<head>
		</head>
		<body>
		<p>Contact Details </p>
		<table>
		<tr>
		<td>Name :</td><td>' . $input_data['fname'].' ' . $input_data['lname'].' </td>
		</tr>
		<tr>
		<td>Email :</td><td>' . $input_data['contact_email'] . '</td>
		</tr>
		<tr>
		<td>Mobile :</td><td>' . $input_data['contact_number'] . '</td>
		</tr>
		<tr>
		<td>Message  :</td><td>' . $input_data['message'] . '</td>
		</tr>
		</table>
		</body>
		</html>';

		$content;
    	$config = Array(        
            'protocol' => 'sendmail',
            'smtp_host' => 'your domain SMTP host',
            'smtp_port' => 25,
            'smtp_user' => 'SMTP Username',
            'smtp_pass' => 'SMTP Password',
            'smtp_timeout' => '4',
            'mailtype'  => 'html', 
            'charset'   => 'iso-8859-1'
        );
		$this->load->library('email', $config);
		$this->email->set_newline("\r\n");

		$this->email->from('info@gaineronline.com');
		$subject='Contact Details';
		$this->email->to('robiatur.rayee@zeewebvalley.com');
		$this->email->subject($subject); // replace it with relevant subject 
		$this->email->message($content);   
		$responds=$this->email->send();


		$name=$input_data['fname'].' ' . $input_data['lname'];

		$insert_data['name'] = $name;
		$insert_data['email'] = $input_data['contact_email'];
		$insert_data['mobile'] = $input_data['contact_number'];
		$insert_data['comment'] = $input_data['message'];
		$insert_data['date'] = date('Y-m-d');
		$this->db->insert('contact',$insert_data);
	}
	public function enquery()
	{
		$input_data = $this->input->post();
        $input_data = $this->security->xss_clean($input_data);

        $content='<html>
		<head>
		</head>
		<body>
		<p>Enquery Details </p>
		<table>
		<tr>
		<td>Name :</td><td>' . $input_data['name'].' </td>
		</tr>
		<tr>
		<td>Email :</td><td>' . $input_data['email'] . '</td>
		</tr>
		<tr>
		<td>Mobile :</td><td>' . $input_data['mobile'] . '</td>
		</tr>
		<tr>
		<td>Service  :</td><td>' . $input_data['service'] . '</td>
		</tr>
		</table>
		</body>
		</html>';

		$content;
    	$config = Array(        
            'protocol' => 'sendmail',
            'smtp_host' => 'your domain SMTP host',
            'smtp_port' => 25,
            'smtp_user' => 'SMTP Username',
            'smtp_pass' => 'SMTP Password',
            'smtp_timeout' => '4',
            'mailtype'  => 'html', 
            'charset'   => 'iso-8859-1'
        );
		$this->load->library('email', $config);
		$this->email->set_newline("\r\n");

		$this->email->from('info@gaineronline.com');
		$subject='Enquery Details';
		$this->email->to('robiatur.rayee@zeewebvalley.com');
		$this->email->subject($subject); // replace it with relevant subject 
		$this->email->message($content);   
		$responds=$this->email->send();
		$insert_data['name'] = $input_data['name'];
		$insert_data['email'] = $input_data['email'];
		$insert_data['mobile'] = $input_data['mobile'];
		$insert_data['service'] = $input_data['service'];
		$insert_data['date'] = date('Y-m-d');
		$this->db->insert('enquery',$insert_data);
	}
	public function newsletter()
	{
		$input_data = $this->input->post();
        $input_data = $this->security->xss_clean($input_data);

        $content='<html>
		<head>
		</head>
		<body>
		<p>Newsletter Subscriber Details </p>
		<table>
		<tr>
		<td>Email :</td><td>' . $input_data['email'] . '</td>
		</tr>
		</table>
		</body>
		</html>';

		$content;
    	$config = Array(        
            'protocol' => 'sendmail',
            'smtp_host' => 'your domain SMTP host',
            'smtp_port' => 25,
            'smtp_user' => 'SMTP Username',
            'smtp_pass' => 'SMTP Password',
            'smtp_timeout' => '4',
            'mailtype'  => 'html', 
            'charset'   => 'iso-8859-1'
        );
		$this->load->library('email', $config);
		$this->email->set_newline("\r\n");

		$this->email->from('info@gaineronline.com');
		$subject='Newsletter Subscriber Details';
		$this->email->to('robiatur.rayee@zeewebvalley.com');
		$this->email->subject($subject); // replace it with relevant subject 
		$this->email->message($content);   
		$responds=$this->email->send();


		$insert_data['email'] = $input_data['email'];
		$insert_data['status'] = '1';
		$insert_data['date'] = date('Y-m-d');
		$this->db->insert('newsletter',$insert_data);
	}
}
