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

class Seller extends CI_Controller {
	 

	function __construct() 
	{
        error_reporting(0);
        parent::__construct();
        $this->load->driver('session');
        $this->load->library('session');
        $this->load->model('CommonModel');
        $this->load->helper('Security');
        $this->load->library('form_validation');       
       
  }
	public function register()
	{
		$ip=$_SERVER['REMOTE_ADDR'];
		$current_date=date("Y-m-d");
        
        $data['metatitle']= 'Gaineronine Seller Registration';
        $data['metakey']= 'Gaineronine Seller Registration';
        $data['meta_description']= 'Gaineronine Seller Registration';
        $data['countries']=$this->db->get('countries')->result_array();
		//$data['object']= $this->CommonModel->ticker_data();
		$data['content'] = 'seller_register';
		$this->load->view('layout_home', $data);
	}	
  public function get_state()
  {
    
      $input_data = $this->input->post();
            $input_data = $this->security->xss_clean($input_data);

      $data_category=$this->db->where('country_id', $input_data['county'])->get('states')->result_array();
      ?>
      <div class="form-group">
                                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                        <label>State</label>
                                        <select  name="state" id="state" class="form-control" onchange="city_data()">
                                            
          <option value="0">Choose Any one</option>
            <?php foreach($data_category as $category){ ?>
            <option value="<?php echo  $category['id']; ?>"><?php echo  $category['state_name']; ?></option>
                                            
                                        
            <?php } ?>
            </select><br>
                                    </div>
                                </div>
      <?php
  }
  public function get_city()
  {
    
      $input_data = $this->input->post();
            $input_data = $this->security->xss_clean($input_data);

      $data_category=$this->db->where('state_id', $input_data['state'])->get('cities')->result_array();
      ?>
      <div class="form-group">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <label>City</label>
                    <select  name="city" id="city_id" class="form-control" >
                      <option value="0">Choose Any one</option>
                  <?php foreach($data_category as $category){ ?>
                  <option value="<?php echo  $category['id']; ?>"><?php echo  $category['city_name']; ?></option>
                  <?php } ?>
                    </select><br>
                </div>
          </div>
      <?php
    
  }
	public function MobileVerify()
	{
    $input_data = $this->input->post();
    $input_data = $this->security->xss_clean($input_data);
    $query = $this->db->query("select * from `customer` where  `email`='".$input_data['mobileno']."' and `veryfied`='1' "); 
    $row=$query->result_array();

    if($row){
      echo 'already_exists';
    } else{
      $string = '0123456789';
      $string_shuffled = str_shuffle($string);
      $otp = substr($string_shuffled, 1, 6);

      $customer_data['email'] = $input_data['mobileno'];
      $customer_data['otp'] = $otp;
      $customer_data['veryfied'] = '0'; 
      $this->db->insert('customer',$customer_data);
      $customer_id=$this->db->insert_id();
      $this->session->set_userdata('mobileno', $input_data['mobileno']);
      echo "success";

      //////////////////////////////////SMS///////////////////////////////////
      $content="This is your OTP ".$otp." to register for www.doctorvahaan.com, valid till 180 seconds - Team Doctorvahaan";

    $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@doctorvahaan.com','OTP from Doctorvahaan');
    $subject='Register OTP From Doctorvahaan';
    $this->email->to($input_data['mobileno']);
    $this->email->subject($subject); // replace it with relevant subject 
    $this->email->message($content);   
    $responds=$this->email->send();
    }
  } 
  public function validate_otp()
  {
    $input_data = $this->input->post();
    $input_data = $this->security->xss_clean($input_data);
    $query = $this->db->query("select * from `customer` where  `email`='".$this->session->userdata('mobileno')."' and `otp`='".$input_data['otp']."' "); 
    $row=$query->result_array();
    //echo $this->db->last_query();

    if($row){
      $this->session->set_userdata('customer_otp', $input_data['otp']);
      echo "success";
    } else{
      echo 'failed_otp';
    }
  }
  public function register_save()
  {

	$input_data = $this->input->post();
	$input_data = $this->security->xss_clean($input_data);
	
	$query = $this->db->query("select * from `sellers` where `s_email`='".$input_data['s_email']."'"); 
	$row=$query->result_array();

	if ($row) {
	 echo "emailexist";die;
	}
	else {
	
        
	
	$customer_data['s_name'] = $input_data['s_name'];
	$customer_data['s_mobile'] = $input_data['s_mobile'];
  $customer_data['s_email'] = $input_data['s_email'];
  $customer_data['password'] = $input_data['password'];
  $customer_data['county'] = $input_data['county'];
  $customer_data['state'] = $input_data['state'];
  $customer_data['city'] = $input_data['city'];
  $customer_data['pin'] = $input_data['pin'];
  $customer_data['address'] = $input_data['address'];
	// $customer_data['pass'] = base64_encode($input_data['r_password']);
	$customer_data['status'] = '0';	
  $customer_data['kyc'] = '0'; 
	$this->db->insert('sellers',$customer_data);
  $customer_id=$this->db->insert_id();
  $insert_data['seller_id'] = $customer_id;
  $this->db->insert('seller_kycs',$insert_data);
  $query = $this->db->query("select * from `sellers` where `id`='".$customer_id."' "); 
  $user_exsist=$query->result_array();

  
	
  $content="<!DOCTYPE html>
<html lang='en' xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:v='urn:schemas-microsoft-com:vml'>
<head>
<title>Account</title>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'/>
<meta content='width=device-width, initial-scale=1.0' name='viewport'/>
<!--[if !mso]><!-->
<link href='https://fonts.googleapis.com/css?family=Cabin' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'/>
<!--<![endif]-->
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
}
a[x-apple-data-detectors] {
color: inherit !important;
text-decoration: inherit !important;
}
#MessageViewBody a {
color: inherit;
text-decoration: none;
}
p {
line-height: inherit
}
.desktop_hide,
.desktop_hide table {
mso-hide: all;
display: none;
max-height: 0px;
overflow: hidden;
}
@media (max-width:670px) {
.desktop_hide table.icons-inner,
.social_block.desktop_hide .social-table {
display: inline-block !important;
}
.icons-inner {
text-align: center;
}
.icons-inner td {
margin: 0 auto;
}
.image_block img.big,
.row-content {
width: 100% !important;
}
.mobile_hide {
display: none;
}
.stack .column {
width: 100%;
display: block;
}
.mobile_hide {
min-height: 0;
max-height: 0;
max-width: 0;
overflow: hidden;
font-size: 0px;
}
.desktop_hide,
.desktop_hide table {
display: table !important;
max-height: none !important;
}
}
</style>
</head>
<body style='margin: 0; padding: 0; -webkit-text-size-adjust: none; text-size-adjust: none;'>
<table border='0' cellpadding='0' cellspacing='0' class='nl-container' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #000000;' width='100%'>
<tbody>
<tr>
<td>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row row-1' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f3e6f8;' width='100%'>
<tbody>
<tr>
<td>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row-content stack' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #000000; width: 550px;' width='550'>
<tbody>
<tr>
<td class='column column-1' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top; padding-top: 5px; padding-bottom: 5px; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;' width='100%'>
<table border='0' cellpadding='0' cellspacing='0' class='image_block block-1' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad' style='padding-bottom:15px;padding-top:15px;width:100%;padding-right:0px;padding-left:0px;'>
<div align='center' class='alignment' style='line-height:10px'><img alt='your logo' src='".base_url()."assets/images/logo.png' style='display: block; height: auto; border: 0; width: 195px; max-width: 100%;' title='your logo' width='195'/></div>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row row-2' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f3e6f8;' width='100%'>
<tbody>
<tr>
<td>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row-content stack' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; background-position: center top; background-repeat: no-repeat; color: #000000; width: 550px;' width='550'>
<tbody>
<tr>
<td class='column column-1' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top; padding-top: 45px; padding-bottom: 0px; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;' width='100%'>
<table border='0' cellpadding='20' cellspacing='0' class='divider_block block-1' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad'>
<div align='center' class='alignment'>
<table border='0' cellpadding='0' cellspacing='0' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='divider_inner' style='font-size: 1px; line-height: 1px; border-top: 0px solid #BBBBBB;'>
<div align='center' class='alignment' style='line-height:10px'><img alt='Alternate text' class='big' src='".base_url()."assets/images/register_success.jpg' style='display: block; height: auto; border: 0; width: 330px; max-width: 100%;' title='Alternate text' width='700'/></div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' class='heading_block block-3' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad' style='padding-top:35px;text-align:center;width:100%;'>
<h1 style='margin: 0; color: #000; direction: ltr; font-family: 'Cabin', Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 28px; font-weight: 400; letter-spacing: normal; line-height: 120%; text-align: center; margin-top: 0; margin-bottom: 0;'><strong>Registration Successfull</strong></h1>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' class='text_block block-4' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;' width='100%'>
<tr>
<td class='pad' style='padding-left:45px;padding-right:45px;padding-top:10px;'>
<div style='font-family: Arial, sans-serif'>
<div class='' style='font-size: 12px; font-family: 'Cabin', Arial, 'Helvetica Neue', Helvetica, sans-serif; mso-line-height-alt: 18px; color: #000; line-height: 1.5;'>
<p style='margin: 0; mso-line-height-alt: 19.5px; text-align: center;'><span style='font-size:13px;color:#000;'>Thank you for Registration </span></p>
</div>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='20' cellspacing='0' class='divider_block block-5' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad'>
<div align='center' class='alignment'>
<table border='0' cellpadding='0' cellspacing='0' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='80%'>
<tr>
<td class='divider_inner' style='font-size: 1px; line-height: 1px; border-top: 1px solid #E1B4FC;'><span></span></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' class='text_block block-4' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;' width='100%'>
<tr>
<td class='pad' style='padding-left:45px;padding-right:45px;padding-top:10px;'>
<div style='font-family: Arial, sans-serif'>
<div class='' style='font-size: 12px; font-family: 'Cabin', Arial, 'Helvetica Neue', Helvetica, sans-serif; mso-line-height-alt: 18px; color: #000; line-height: 1.5;'>
<p style='margin: 0; mso-line-height-alt: 19.5px; text-align: center;'><span style='font-size:13px;color:#000;'>Username: ".$user_exsist[0]['s_email']." </span></p>
<p style='margin: 0; mso-line-height-alt: 19.5px; text-align: center;'><span style='font-size:13px;color:#000;'>Password: ".$user_exsist[0]['password']." </span></p>
</div>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='20' cellspacing='0' class='divider_block block-5' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad'>
<div align='center' class='alignment'>
<table border='0' cellpadding='0' cellspacing='0' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='80%'>
<tr>
<td class='divider_inner' style='font-size: 1px; line-height: 1px; border-top: 1px solid #E1B4FC;'><span></span></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='10' cellspacing='0' class='button_block block-7' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad'>
<div align='center' class='alignment'>
<a href='https://gaineronline.com/seller-dashboard/' style='text-decoration:none;display:inline-block;color:#ffffff;background-color:#4d8d40;border-radius:30px;width:auto;border-top:1px solid transparent;font-weight:400;border-right:1px solid transparent;border-bottom:1px solid transparent;border-left:1px solid transparent;padding-top:10px;padding-bottom:10px;font-family:'Cabin', Arial, 'Helvetica Neue', Helvetica, sans-serif;text-align:center;mso-border-alt:none;word-break:keep-all;' target='_blank'><span style='padding-left:40px;padding-right:40px;font-size:14px;display:inline-block;letter-spacing:normal;'><span style='word-break: break-word;'><span data-mce-style='' style='line-height: 28px;'>LOGIN NOW</span></span></span></a>
</div>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row row-3' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f3e6f8;' width='100%'>
<tbody>
<tr>
<td>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row-content stack' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #000000; width: 650px;' width='650'>
<tbody>
<tr>
<td class='column column-1' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top; padding-top: 5px; padding-bottom: 10px; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;' width='100%'>
<table border='0' cellpadding='5' cellspacing='0' class='divider_block block-1' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad'>
<div align='center' class='alignment'>
<table border='0' cellpadding='0' cellspacing='0' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='divider_inner' style='font-size: 1px; line-height: 1px; border-top: 0px solid #BBBBBB;'><span></span></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' class='text_block block-2' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;' width='100%'>
<tr>
<td class='pad'>
<div style='font-family: sans-serif'>
<div class='' style='font-size: 12px; mso-line-height-alt: 14.399999999999999px; color: #8412c0; line-height: 1.2; font-family: Arial, Helvetica Neue, Helvetica, sans-serif;'>
<p style='margin: 0; text-align: center; mso-line-height-alt: 13.2px;'><span style='font-size:11px;'><span style='color:#8a3b8f;'>www.gaineronline.com/info@gaineronline.com</span><a href='https://www.gaineronline.com' style='color: #8412c0;'></a></span></p>
</div>
</div>
</td>
</tr>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>";

    $content;
    

      $config = Array(        
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.gmail.com',
            'smtp_port' => 465,
            'smtp_user' => 'gaineronline1@gmail.com',
            'smtp_pass' => 'njhzmthxbjrjdohn',
            'mailtype'  => 'html', 
            'charset'   => 'iso-8859-1'
        );
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");

    $this->email->from('gaineronline1@gmail.com','Login Details from Gainer');
    $subject='Seller Login Details from Gainer';
    $this->email->to($user_exsist[0]['s_email']);
    $this->email->subject($subject); // replace it with relevant subject 
    $this->email->message($content);   
    $responds=$this->email->send();
    //print_r($responds);
	echo "success";

	}


	}

     public function forgot_password()
  {

    $input_data = $this->input->post();
    $input_data = $this->security->xss_clean($input_data);
    $query = $this->db->query("select * from `sellers` where `s_email`='".$input_data['forgot_email']."'"); 
    $row=$query->result_array();

    if ($row) {
      $content="<!DOCTYPE html>
<html lang='en' xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:v='urn:schemas-microsoft-com:vml'>
<head>
<title>Forgot Password</title>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'/>
<meta content='width=device-width, initial-scale=1.0' name='viewport'/>
<!--[if !mso]><!-->
<link href='https://fonts.googleapis.com/css?family=Cabin' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'/>
<!--<![endif]-->
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
}
a[x-apple-data-detectors] {
color: inherit !important;
text-decoration: inherit !important;
}
#MessageViewBody a {
color: inherit;
text-decoration: none;
}
p {
line-height: inherit
}
.desktop_hide,
.desktop_hide table {
mso-hide: all;
display: none;
max-height: 0px;
overflow: hidden;
}
@media (max-width:670px) {
.desktop_hide table.icons-inner,
.social_block.desktop_hide .social-table {
display: inline-block !important;
}
.icons-inner {
text-align: center;
}
.icons-inner td {
margin: 0 auto;
}
.image_block img.big,
.row-content {
width: 100% !important;
}
.mobile_hide {
display: none;
}
.stack .column {
width: 100%;
display: block;
}
.mobile_hide {
min-height: 0;
max-height: 0;
max-width: 0;
overflow: hidden;
font-size: 0px;
}
.desktop_hide,
.desktop_hide table {
display: table !important;
max-height: none !important;
}
}
</style>
</head>
<body style='background-color: #000000; margin: 0; padding: 0; -webkit-text-size-adjust: none; text-size-adjust: none;'>
<table border='0' cellpadding='0' cellspacing='0' class='nl-container' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #000000;' width='100%'>
<tbody>
<tr>
<td>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row row-1' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f3e6f8;' width='100%'>
<tbody>
<tr>
<td>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row-content stack' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #000000; width: 650px;' width='650'>
<tbody>
<tr>
<td class='column column-1' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top; padding-top: 5px; padding-bottom: 5px; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;' width='100%'>
<table border='0' cellpadding='0' cellspacing='0' class='image_block block-1' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad' style='padding-bottom:15px;padding-top:15px;width:100%;padding-right:0px;padding-left:0px;'>
<div align='center' class='alignment' style='line-height:10px'><img alt='your logo' src='".base_url()."assets/images/logo.png' style='display: block; height: auto; border: 0; width: 195px; max-width: 100%;' title='your logo' width='195'/></div>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row row-2' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f3e6f8;' width='100%'>
<tbody>
<tr>
<td>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row-content stack' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; background-image: url(".base_url()."assets/images/ResetPassword_BG_2.png); background-position: center top; background-repeat: no-repeat; color: #000000; width: 650px;' width='650'>
<tbody>
<tr>
<td class='column column-1' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top; padding-top: 45px; padding-bottom: 0px; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;' width='100%'>
<table border='0' cellpadding='20' cellspacing='0' class='divider_block block-1' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad'>
<div align='center' class='alignment'>
<table border='0' cellpadding='0' cellspacing='0' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='divider_inner' style='font-size: 1px; line-height: 1px; border-top: 0px solid #BBBBBB;'><span></span></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='20' cellspacing='0' class='image_block block-2' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad'>
<div align='center' class='alignment' style='line-height:10px'><img alt='Forgot your password?' class='big' src='".base_url()."assets/images/lock5.png' style='display: block; height: auto; border: 0; width: 358px; max-width: 100%;' title='Forgot your password?' width='358'/></div>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' class='heading_block block-3' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad' style='padding-top:35px;text-align:center;width:100%;'>
<h1 style='margin: 0; color: #000; direction: ltr; font-family: 'Cabin', Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 28px; font-weight: 400; letter-spacing: normal; line-height: 120%; text-align: center; margin-top: 0; margin-bottom: 0;'><strong>Your Password Details</strong></h1>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' class='text_block block-4' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;' width='100%'>
<tr>
<td class='pad' style='padding-left:45px;padding-right:45px;padding-top:10px;'>
<div style='font-family: Arial, sans-serif'>
<div class='' style='font-size: 12px; font-family: 'Cabin', Arial, 'Helvetica Neue', Helvetica, sans-serif; mso-line-height-alt: 18px; color: #393d47; line-height: 1.5;'>
<p style='margin: 0; text-align: center; mso-line-height-alt: 27px;'><span style='font-size:18px;color:#000;'>Username - ".$row[0]['s_email']."</span></p>
<p style='margin: 0; text-align: center; mso-line-height-alt: 27px;'><span style='font-size:18px;color:#000;'>Password - ".base64_decode($row[0]['password'])."</span></p>
</div>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='20' cellspacing='0' class='divider_block block-5' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad'>
<div align='center' class='alignment'>
<table border='0' cellpadding='0' cellspacing='0' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='80%'>
<tr>
<td class='divider_inner' style='font-size: 1px; line-height: 1px; border-top: 1px solid #E1B4FC;'><span></span></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' class='text_block block-6' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;' width='100%'>
<tr>
<td class='pad' style='padding-bottom:10px;padding-left:45px;padding-right:45px;padding-top:10px;'>
<div style='font-family: Arial, sans-serif'>
<div class='' style='font-size: 12px; font-family: 'Cabin', Arial, 'Helvetica Neue', Helvetica, sans-serif; text-align: center; mso-line-height-alt: 18px; color: #393d47; line-height: 1.5;'>
<p style='margin: 0; mso-line-height-alt: 19.5px;'><span style='font-size:13px;color:#000;'>If you did make this request just click the button below:</span></p>
</div>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='10' cellspacing='0' class='button_block block-7' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad'>
<div align='center' class='alignment'>
<a href='https://www.doctorvahaan.com' style='text-decoration:none;display:inline-block;color:#ffffff;background-color:#4d8d40;border-radius:30px;width:auto;border-top:1px solid transparent;font-weight:400;border-right:1px solid transparent;border-bottom:1px solid transparent;border-left:1px solid transparent;padding-top:10px;padding-bottom:10px;font-family:'Cabin', Arial, 'Helvetica Neue', Helvetica, sans-serif;text-align:center;mso-border-alt:none;word-break:keep-all;' target='_blank'><span style='padding-left:40px;padding-right:40px;font-size:14px;display:inline-block;letter-spacing:normal;'><span style='word-break: break-word;'><span data-mce-style='' style='line-height: 28px;'>LOGIN NOW</span></span></span></a>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' class='text_block block-8' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;' width='100%'>
<tr>
<td class='pad' style='padding-bottom:15px;padding-left:10px;padding-right:10px;padding-top:10px;'>
<div style='font-family: Arial, sans-serif'>
<div class='' style='font-size: 12px; font-family: 'Cabin', Arial, 'Helvetica Neue', Helvetica, sans-serif; mso-line-height-alt: 14.399999999999999px; color: #393d47; line-height: 1.2;'>
<p style='margin: 0; font-size: 14px; text-align: center; mso-line-height-alt: 16.8px;'><span style='font-size:10px;color:#000;'><span style=''>If you didn't request to change your password, </span><span style=''>you don't have to do anything. So that's easy.</span></span></p>
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row row-3' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f3e6f8;' width='100%'>
<tbody>
<tr>
<td>
<table align='center' border='0' cellpadding='0' cellspacing='0' class='row-content stack' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #000000; width: 650px;' width='650'>
<tbody>
<tr>
<td class='column column-1' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top; padding-top: 5px; padding-bottom: 10px; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;' width='100%'>
<table border='0' cellpadding='5' cellspacing='0' class='divider_block block-1' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='pad'>
<div align='center' class='alignment'>
<table border='0' cellpadding='0' cellspacing='0' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt;' width='100%'>
<tr>
<td class='divider_inner' style='font-size: 1px; line-height: 1px; border-top: 0px solid #BBBBBB;'><span></span></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table border='0' cellpadding='0' cellspacing='0' class='text_block block-2' role='presentation' style='mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;' width='100%'>
<tr>
<td class='pad'>
<div style='font-family: sans-serif'>
<div class='' style='font-size: 12px; mso-line-height-alt: 14.399999999999999px; color: #8412c0; line-height: 1.2; font-family: Arial, Helvetica Neue, Helvetica, sans-serif;'>
<p style='margin: 0; text-align: center; mso-line-height-alt: 13.2px;'><span style='font-size:11px;'><span style='color:#8a3b8f;'>www.doctorvahaan.com/info@doctorvahaan.com </span><a href='http://www.doctorvahaan.com' style='color: #8412c0;'></a></span></p>
</div>
</div>
</td>
</tr>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>";

    $content;
      
      $config = Array(        
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.gmail.com',
            'smtp_port' => 465,
            'smtp_user' => 'gaineronline1@gmail.com',
            'smtp_pass' => 'njhzmthxbjrjdohn',
            'mailtype'  => 'html', 
            'charset'   => 'iso-8859-1'
        );
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");

    $this->email->from('gaineronline1@gmail.com','Forgot Password');
    $subject='Forgot Password Details from Gainer';
    $this->email->to($row[0]['email']);
    $this->email->subject($subject); // replace it with relevant subject 
    $this->email->message($content);   
    $responds=$this->email->send();
      echo 'success';
    }
    else {
      echo 'not_exist';
    }
    
  }
     public function profile($id='')
  {

    $data['profiledata']=$this->db->where('c_id',get_cookie('customer'))->get('customer')->result_array();
    //print_r($data['recordSet']);die;
    $data['metatitle']= 'Temple';
    $data['metakey']= 'Temple';
    $data['meta_description']= 'Temple';
    $data['content'] = 'profile';
    $this->load->view('layout_home', $data);
    if ($id!='') {
    $data['metatitle']= 'Temple';
        $data['metakey']= 'Temple';
        $data['meta_description']= 'Temple';
        $data['customer_details'] = $this->db->select('*')->where('md5(c_id)', $id)->get('customer')->result_array();
        $data['content'] = 'stock_discussion_forum/profile';
        $this->load->view('layout_home', $data);
    }
    
  }
  public function profileimage()
  {
    $input_data = $this->input->post();
    //echo $_FILES['profile_img']['name'];
    $ip=$_SERVER['REMOTE_ADDR']; 
    if (empty($_FILES['profile_img']['name']))
            {
              $edit_data['profile_img'] = $input_data['old_image'];
            }
            else
            {
              $_FILES['userfile']['name']     = $_FILES['profile_img']['name'];
            $_FILES['userfile']['type']     = $_FILES['profile_img']['type'];
            $_FILES['userfile']['tmp_name'] = $_FILES['profile_img']['tmp_name'];
            $_FILES['userfile']['error']    = $_FILES['profile_img']['error'];
            $_FILES['userfile']['size']     = $_FILES['profile_img']['size'];
        $config = array('upload_path' => "uploads/profile/",
                'allowed_types' => "gif|jpg|png|jpeg",
                'overwrite' => TRUE,
                'encrypt_name' => TRUE
                );
        $this->load->library('upload', $config);
        $this->upload->initialize($config);
        if($this->upload->do_upload())
        {
          $data = array('upload_data' => $this->upload->data());
          $file_name=$data['upload_data']['file_name'];
          $edit_data['profile'] = $file_name;
          $config["source_image"] = 'uploads/profile/'.$file_name;
          $config['new_image'] = 'uploads/profile/thumbnail/';
          $config['image_library']  = 'gd2';
          $config['create_thumb'] =  FALSE;
          $config['overwrite'] = TRUE;
          $config['maintain_ratio'] = FALSE;
          $config["width"] = 1366;
          $config["height"] = 650;
          

          $this->load->library('image_lib', $config);
          $this->image_lib->initialize($config);
          $this->image_lib->resize();
          $this->image_lib->clear();
          @unlink("uploads/profile/".$input_data['old_image']);
          @unlink("uploads/profile/thumbnail/".$input_data['old_image']);
        }
        
        
            } 
        
    $input_data = $this->security->xss_clean($input_data);
    $edit_data['user_ip'] = $ip;
    $this->db->where('c_id',get_cookie('customer'));
    $this->db->update('customer',$edit_data);
    echo 'success';
  }
  public function generalinformation()
  {
    $input_data = $this->input->post();
    //echo $_FILES['profile_img']['name'];
    $ip=$_SERVER['REMOTE_ADDR']; 
    $input_data = $this->security->xss_clean($input_data);
    $edit_data['name'] = $input_data['name'];
    // $edit_data['nickname'] = $input_data['nickname'];
    $edit_data['gender'] = $input_data['gender'];
    $edit_data['about_info'] = $input_data['about_info'];
    $this->db->where('c_id',get_cookie('customer'));
    $this->db->update('customer',$edit_data);
    echo 'success';
  }
  public function addressupdate()
  {
    $input_data = $this->input->post();
    //echo $_FILES['profile_img']['name'];
    $ip=$_SERVER['REMOTE_ADDR']; 
    $input_data = $this->security->xss_clean($input_data);
    $edit_data['name'] = $input_data['u_name'];
    $edit_data['email'] = $input_data['u_email'];
    $edit_data['city'] = $input_data['u_city'];
    $edit_data['state'] = $input_data['u_state'];
    $edit_data['pin'] = $input_data['u_pin'];
    $edit_data['address'] = $input_data['u_address']; 
    $this->db->where('c_id',$this->session->userdata('user_id'));
    $this->db->update('customer',$edit_data);
    echo 'success';
  }
  public function securityupd()
  {
    $input_data = $this->input->post();
    $user_exsist = $this->db->select('*')->where('pass',base64_encode($input_data['old_password']))->where('c_id', $this->session->userdata('user_id'))->get('customer')->result_array();
      

    if ($user_exsist) {
    $edit_customer['pass'] = base64_encode($input_data['u_cpassword']); 
    $this->db->where('c_id',$this->session->userdata('user_id'));
    $this->db->update('customer',$edit_customer);
    echo 'success';
    } else{
      echo "failed";
    }
    
  }
   public function fb_login()
   {
      $data = $this->input->post();
      $userInfo = json_decode($data['userinfo']);
      //print_r($userInfo);
      $current_date = date("d M Y ");

      $sql = "SELECT * FROM customer WHERE email='".$userInfo->email."'";
      $result = $this->db->query($sql);

      if($result->num_rows() > 0){
        $ftch = $result->result_array();
         $this->session->set_userdata('customer', $ftch[0]['c_id']);
         $this->session->set_userdata('login_session', true);
        $sql2 = "UPDATE `customer` SET `oauth_uid`='".$userInfo->id."',`oauth_provider`='Facebook' WHERE `email`='".$ftch[0]['email']."'";
        $this->db->query($sql2);

        $user_exsist = $this->db->select('*')->where('oauth_uid', $userInfo->id)->or_where('email', $userInfo->email)->where('pass', $password)->get('customer')->result_array();
        //echo $user_exsist[0]['c_id'];
        $this->session->set_userdata('customer', $user_exsist[0]['c_id']);
        $this->session->set_userdata('login_session', true);
        set_cookie('customer',$user_exsist[0]['c_id'],'3600000');
        set_cookie('chatuser',$user_exsist[0]['c_id'],'3600000');
      }else{
        $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
        $password = substr( str_shuffle( $chars ), 0, 8 );
        $insert_data['oauth_provider'] = 'Facebook';
        $insert_data['oauth_uid'] = $userInfo->id;
        $insert_data['pass'] = base64_encode($password);
        $insert_data['name'] = $userInfo->name;
        $insert_data['reg_date'] = $current_date;
        $insert_data['email'] = $userInfo->email;
        $insert_data['veryfied'] = '0';
        $insert_data['comment_status'] = '1';
        $this->db->insert('customer',$insert_data);
        $last_id=$this->db->insert_id();      
        set_cookie('customer',$last_id,'3600000');
        set_cookie('chatuser',$last_id,'3600000');
        $this->session->set_userdata('customer', $last_id);
        $this->session->set_userdata('login_session', true);
        
      }
    }
    public function google_login()
    {
      $data = $this->input->post();
      $current_date = date("d M Y ");
      $sql = "SELECT * FROM customer WHERE email='".$_POST["email"]."'";
      $result = $this->db->query($sql);

      if($result->num_rows() > 0){
        $ftch = $result->result_array();
         $this->session->set_userdata('customer', $ftch[0]['t_id']);
         $this->session->set_userdata('login_session', true);
        $sql2 = "UPDATE `customer` SET `oauth_uid`='".$_POST["id"]."',`oauth_provider`='Google' WHERE `t_id`='".$ftch[0]['t_id']."'";
        $this->db->query($sql2);
        //echo $this->db->last_query();
        set_cookie('customer',$ftch[0]['t_id'],'3600000');
        set_cookie('chatuser',$ftch[0]['t_id'],'3600000');
      }else{
        $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
        $password = substr( str_shuffle( $chars ), 0, 8 );
        $insert_data['oauth_provider'] = 'Google';
        $insert_data['oauth_uid'] = $_POST["id"];
        $insert_data['pass'] = $password;
        $insert_data['name'] = $_POST["name"];
        $insert_data['reg_date'] = $current_date;
        $insert_data['email'] = $_POST["email"];
        $insert_data['veryfied'] = '0';
        $insert_data['comment_status'] = '1';
        $this->db->insert('customer',$insert_data);
        $last_id=$this->db->insert_id();
             
        set_cookie('customer',$last_id,'3600000');
        set_cookie('chatuser',$last_id,'3600000');
        $this->session->set_userdata('customer', $last_id);
        $this->session->set_userdata('login_session', true);
        
      }
    }
    public function logout()
    {
      $this->session->unset_userdata('login_session');
      $this->session->unset_userdata('customer');
      $this->session->unset_userdata('user_id');
      $this->session->unset_userdata('name');
      $this->session->unset_userdata('email');
      $this->session->unset_userdata('mobile');
      redirect(base_url());
    }
}
