Commit 2a743d21 by Jansa Jose

send mail

parent 346c9102
......@@ -842,6 +842,17 @@ public function fb_login_post(){
$request = json_decode($postdata,true);
if($request){
$result = $this->Webservice_model->booking_details($request);
$this->db->select('users_id');
$ride_data = $this->db->get_where('ride',array('id'=>$request['ride_id']))->row();
$this->db->select('first_name,email');
$user_data = $this->db->get_where('users',array('id'=>$ride_data->users_id))->row();
$data['email'] = $user_data->email;
$data['name'] = $user_data->first_name;
$data['subject'] = 'New Ride Request';
$data['msg'] = 'Hi '.$data['name'] .', You Have a new Ride Request';
$this->send_mails($data);
if($result){
$response=array('status' => 'success','data'=>$result);
......@@ -877,7 +888,34 @@ public function fb_login_post(){
print json_encode($response);
}
public function send_mails($data){
$settings = $this->db->get_where('settings',array('id'=>'1'))->row();
$this->load->library('email');
$config = Array(
'protocol' => 'smtp',
'smtp_host' => $settings->smtp_host,
'smtp_port' => 587,
'smtp_user' => $settings->smtp_username, // change it to yours
'smtp_pass' => $settings->smtp_password, // change it to yours
'smtp_timeout'=>20,
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE
);
$this->email->initialize($config);// add this line
$subject = 'New Mail';
$this->email->from($settings->admin_email);
$this->email->to($data['email']);
$this->email->subject($data['subject']);
$this->email->message($data['msg']);
$this->email->send();
return "EmailSend";
}
......@@ -1369,7 +1407,7 @@ public function fb_login_post(){
'app_id' => "7c692b68-a71f-4c8d-b639-635e9dc4b7de",
'data' => array("type" => "ride alert",
"result" => $result,
"result" => (isset($result) && !empty($result))?$result:'',
"ride_id"=>$id,
"push_type"=>$type
),
......@@ -2416,6 +2454,10 @@ public function end_ride_update_post(){
$id='';
$res= $this->send_Message($content,$headings,$include_player_ids,$res,$type,$id);
$data['email'] = $res->email;
$data['subject'] = 'Booking Rejected';
$data['msg'] = 'Hi '.$res->first_name.', Your Request is Rejected.';
$this->send_mails($data);
$return = $res;
// print($return);
// $return = json_encode($return);
......@@ -2446,6 +2488,10 @@ public function end_ride_update_post(){
$id='';
$res= $this->send_Message($content,$headings,$include_player_ids,$res,$type,$id);
$data['email'] = $res->email;
$data['subject'] = 'Booking Approved';
$data['msg'] = 'Hi '.$res->first_name.', Your Request is Approved.';
$this->send_mails($data);
$return = $res;
// print($return);
// $return = json_encode($return);
......
......@@ -110,9 +110,7 @@ class Webservice_model extends CI_Model{
$num = $this->db->where(array('username'=>$data['username'],'status'=>'1'))->get('users')->num_rows();
$num1 = $this->db->where(array('email'=>$data['email'],'status'=>'1'))->get('users')->num_rows();
// echo $this->db->last_query();
$num2 = $this->db->where(array('phone_no'=>$data['phone_no'],'status'=>'1'))->get('users')->num_rows();
//echo $num."-".$num1."-".$num2;
if($num>0){
$result = array('status'=>'error','message'=>'username Already Exists');
}else if($num1>0){
......@@ -465,21 +463,6 @@ class Webservice_model extends CI_Model{
public function forgot_mails($data,$rand_pwd){
/*$rand_id = rand(1111,9999);
$rand_value = md5(time().$rand_id);
$this->db->where('id',$user_id)->update("users",array('req_id'=>$rand_value));
$this->db->where('email',$email);
$query = $this->db->get('users');
$rs = $query->row();
if ($rs) {
*/
// $username = $rs->first_name;
// $this->load->helper('string');
//$link = base_url()."Verify_email/verify/".$rand_value;
// if ($query) {
$settings = $this->db->get_where('settings',array('id'=>'1'))->row();
$this->load->library('email');
......@@ -503,12 +486,7 @@ public function forgot_mails($data,$rand_pwd){
$this->email->subject("Forgot Password - Tukkibi");
$this->email->message("Hi ".$data->name.", Your New Password is : ".$rand_pwd);
$this->email->send();
//echo $this->email->print_debugger();
return "EmailSend";
// }
/* }else {
return false;
} */
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment