Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* This is the model class for table "user". */
- //vnnovate file
- if (!defined('BASEPATH'))
- exit('No direct script access allowed');
- class webservice_model extends CI_Model
- {
- function __construct()
- {
- parent::__construct();
- $data = array();
- }
- /* This function check individual user validate or not
- * @params : N/A
- * @return : return array of success or failure message */
- // public function validateUser() {
- // if ($this->input->get_post('email', TRUE) && $this->input->get_post('password', TRUE)) {
- // if (!filter_var($this->input->get_post('email', TRUE), FILTER_VALIDATE_EMAIL) === false) {
- // $email = $this->input->get_post('email', TRUE);
- // $token = $this->input->get_post('token', TRUE);
- // // $user_type = $this->input->get_post('user_type', TRUE);
- // $password = base64_encode($this->input->get_post('password', TRUE));
- // $row = $this->db->from('user')->where('email', $email)->where('password', $password)->get()->row();
- // if (count($row) > 0) {
- // $data = $this->getClientRecord($row, 'login');
- // $data['status'] = "success";
- // $data['message'] = "Login Successfull";
- // //}
- // } else {
- // $data['status'] = "failure";
- // $data['message'] = "Login Failed. The email or password you entered is incorrect";
- // }
- // } else {
- // $data['status'] = "failure";
- // $data['message'] = "Please enter valid email address";
- // }
- // } else {
- // $data['status'] = "failure";
- // $data['message'] = "Please enter email and password";
- // }
- // return $data;
- // }
- public function validateUser()
- {
- if ($this->input->get_post('email', TRUE) &&filter_var($this->input->get_post('email', TRUE), FILTER_VALIDATE_EMAIL) === true) {
- $login_type = $this->input->get_post('login_type');
- $fb_id = $this->input->get_post('fb_id');
- $email = $this->input->get_post('email', TRUE);
- $token = $this->input->get_post('token', TRUE);
- $first_name = $this->input->get_post('first_name', TRUE);
- $last_name = $this->input->get_post('last_name', TRUE);
- $password = base64_encode($this->input->get_post('password', TRUE));
- if (isset($_POST['password'])) {
- $row = $this->db->from('user')->where('email', $email)->where('password', $password)->get()->row();
- if (count($row) > 0) {
- $data = $this->getClientRecord($row, $row->login_type, 'login');
- $id = $row->id;
- $this->db->where('id', $id);
- $flag = $this->db->update('user', array('token' => $token));
- if ($flag) {
- $data['status'] = "success";
- $data['message'] = "Login Successfull";
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "Login Failed. The email or password you entered is incorrect";
- }
- } else {
- $image = $this->input->get_post('image', TRUE);
- $path = FCPATH . "assets/profilepic/";
- //$imageStr = str_replace('data:image/png;base64,', '', $file);
- $imageStr = str_replace(' ', '+', $image);
- $dataStr = base64_decode($imageStr);
- $fileName = uniqid() . '.png';
- $file = $path . $fileName;
- $success = file_put_contents($file, $dataStr);
- $rowArr = $this->db->get_where('user', array('email' => $this->input->get_post('email', TRUE)))->result();
- if (count($rowArr) > 0) {
- $data['status'] = "failure";
- $data['message'] = $this->input->get_post('email', TRUE) . " email address already exists!";
- } else {
- $row = $this->db->from('user')->where('fb_id', $fb_id)->get()->row();
- if (count($row) > 0) {
- $data = $this->getClientRecord($row, $row->login_type, 'login');
- $id = $row->id;
- $this->db->where('id', $id);
- $flag = $this->db->update('user', array('token' => $token));
- if ($flag) {
- $data['status'] = "success";
- $data['message'] = "Login Successfull";
- } else {
- $data['status'] = "failure";
- $data['message'] = "Login Failed. The email or password you entered is incorrect";
- }
- } else {
- $fbArr = array(
- 'email' => $email,
- 'fb_id' => $fb_id,
- 'first_name' => $first_name,
- 'last_name' => $last_name,
- 'image' => $fileName,
- 'login_type' => 'fb'
- );
- $fbDataSave = $this->db->insert('user', $fbArr);
- $row = $this->db->from('user')->where('fb_id', $fb_id)->get()->row();
- if (count($row) > 0) {
- $data = $this->getClientRecord($row, $row->login_type, 'login');
- $id = $row->id;
- $this->db->where('id', $id);
- $flag = $this->db->update('user', array('token' => $token));
- if ($flag) {
- $data['status'] = "success";
- $data['message'] = "Login Successfull";
- } else {
- $data['status'] = "failure";
- $data['message'] = "Login Failed. The email or password you entered is incorrect";
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not found";
- }
- }
- }
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "Please enter email and password";
- }
- return ($this->normaliseArray($data));
- }
- /**
- * @param $row
- * @param $login
- * @param $login_type
- * @return mixed
- */
- public function getClientRecord($row, $login, $login_type)
- {
- $data['status'] = "success";
- if (!empty($login) && $login == 'signup') {
- $data['message'] = "user successfully registered";
- } else {
- $data['message'] = "user successfully logged";
- }
- $data['userId'] = $row->id;
- $data['login_type'] = $row->login_type;
- $data['fb_id'] = $row->fb_id;
- $data['first_name'] = $row->first_name;
- $data['last_name'] = $row->last_name;
- $data['email'] = $row->email;
- $data['password'] = base64_decode($row->password);
- $data['phone'] = $row->phone;
- $data['state'] = $row->state;
- $data['neighborhood'] = $row->neighborhood;
- $data['school'] = $row->school;
- $profile_pic = $row->image;
- $pics = "http://" . $_SERVER['SERVER_NAME'] . "/girlfriend_app/assets/profilepic/" . $profile_pic;
- $data['image'] = $pics;
- //$data['trainer_email'] = $row->trainer_email;
- return $data;
- }
- // public function UserProfile() {
- // if ($this->input->get_post('email', TRUE)) {
- // $rowArr = $this->db->get_where('user', array('email' => $this->input->get_post('email', TRUE)))->result();
- // if (count($rowArr) > 0) {
- // $data['status'] = "failure";
- // $data['message'] = $this->input->get_post('email', TRUE) . " email address already exists!";
- // } else {
- // $first_name = "";
- // $last_name = "";
- // $email = "";
- // $password = "";
- // $phone = "";
- // $state = "";
- // $city = "";
- // $neighborhood = "";
- // $school = "";
- // $image = "";
- // if ($this->input->get_post('first_name', TRUE)) {
- // $first_name = $this->input->get_post('first_name', TRUE);
- // }
- // if ($this->input->get_post('last_name', TRUE)) {
- // $last_name = $this->input->get_post('last_name', TRUE);
- // }
- // if ($this->input->get_post('email', TRUE)) {
- // $email = $this->input->get_post('email', TRUE);
- // }
- // if ($this->input->get_post('phone', TRUE)) {
- // $phone = $this->input->get_post('phone', TRUE);
- // }
- // if ($this->input->get_post('state', TRUE)) {
- // $state = $this->input->get_post('state', TRUE);
- // }
- // if ($this->input->get_post('city', TRUE)) {
- // $city = $this->input->get_post('city', TRUE);
- // }
- // if ($this->input->get_post('neighborhood', TRUE)) {
- // $neighborhood = $this->input->get_post('neighborhood', TRUE);
- // }
- // if ($this->input->get_post('school', TRUE)) {
- // $school = $this->input->get_post('school', TRUE);
- // }
- // if ($this->input->get_post('image', TRUE)) {
- // $image = $this->input->get_post('image', TRUE);
- // $path = FCPATH . "assets/profilepic/";
- // //$imageStr = str_replace('data:image/png;base64,', '', $file);
- // $imageStr = str_replace(' ', '+', $image);
- // $dataStr = base64_decode($imageStr);
- // $fileName = uniqid() . '.png';
- // $file = $path . $fileName;
- // $success = file_put_contents($file, $dataStr);
- // }
- // $password = base64_encode($this->input->get_post('password', TRUE));
- // $insArr = array(
- // 'first_name' => $first_name,
- // 'last_name' => $last_name,
- // 'email' => $email,
- // 'password' => $password,
- // 'phone' => $phone,
- // 'state' => $state,
- // 'city' => $city,
- // 'school' =>$school,
- // 'image' => $fileName,
- // 'neighborhood' => $neighborhood
- // );
- // $flag = $this->db->insert('user', $insArr);
- // if ($flag) {
- // //$rows = $this->db->from('user')->where('id', $this->db->insert_id())->get()->row();
- // //$data = $this->getTrainerRecord($rows, 'signup');
- // $data['status'] = "success";
- // $data['message'] = "register successfully.";
- // $data['result'] = $insArr;
- // } else {
- // $data['status'] = "failure";
- // $data['message'] = "Trainer does not register";
- // }
- // }
- // } else {
- // $data['status'] = "failure";
- // $data['message'] = "Please enter email address";
- // }
- // return $data;
- // }
- public function UserProfile()
- {
- if ($this->input->get_post('user_id', TRUE)) {
- $user_id = $this->input->get_post('user_id', TRUE);
- if ($this->input->get_post('first_name', TRUE)) {
- $first_name = $this->input->get_post('first_name', TRUE);
- }
- if ($this->input->get_post('last_name', TRUE)) {
- $last_name = $this->input->get_post('last_name', TRUE);
- }
- if ($this->input->get_post('state', TRUE)) {
- $state = $this->input->get_post('state', TRUE);
- }
- if ($this->input->get_post('city', TRUE)) {
- $city = $this->input->get_post('city', TRUE);
- }
- if ($this->input->get_post('neighborhood', TRUE)) {
- $neighborhood = $this->input->get_post('neighborhood', TRUE);
- }
- if ($this->input->get_post('school', TRUE)) {
- $school = $this->input->get_post('school', TRUE);
- }
- if ($this->input->get_post('image', TRUE)) {
- $image = $this->input->get_post('image', TRUE);
- $path = FCPATH . "assets/profilepic/";
- //$imageStr = str_replace('data:image/png;base64,', '', $file);
- $imageStr = str_replace(' ', '+', $image);
- $dataStr = base64_decode($imageStr);
- $fileName = uniqid() . '.png';
- $file = $path . $fileName;
- $success = file_put_contents($file, $dataStr);
- }
- $password = base64_encode($this->input->get_post('password', TRUE));
- $insArr = array(
- 'id' => $user_id,
- 'first_name' => $first_name,
- 'last_name' => $last_name,
- 'state' => $state,
- 'city' => $city,
- 'school' => $school,
- 'image' => $fileName,
- 'neighborhood' => $neighborhood
- );
- $this->db->where('id', $user_id);
- if ($this->db->update('user', $insArr)) {
- $data['status'] = "success";
- $data['message'] = "user details update successfully .";
- $data['result'] = $insArr;
- } else {
- $data['status'] = "failure";
- $data['message'] = "Trainer does not register";
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "Please enter user id";
- }
- return $data;
- }
- // public function UserRegister()
- // {
- // $email = $this->input->get_post('email', TRUE);
- // if ($email == "") {
- // $data['status'] = "failure";
- // $data['message'] = "enter email adrress";
- // }
- // $password = $this->input->get_post('password', TRUE);
- // if ($password == "") {
- // $data['status'] = "failure";
- // $data['message'] = "enter password";
- // }
- // return $data;
- // }
- public function UserRegister()
- {
- if ($this->input->get_post('email', TRUE)) {
- $rowArr = $this->db->get_where('user', array('email' => $this->input->get_post('email', TRUE)))->result();
- if (count($rowArr) > 0) {
- $data['status'] = "failure";
- $data['message'] = $this->input->get_post('email', TRUE) . " email address already exists!";
- } else {
- $email = "";
- $password = "";
- $email = $this->input->get_post('email', TRUE);
- $rowArr = $this->db->get_where('friend_invites', array('to_email' => $this->input->get_post('email', TRUE)))->result();
- if ($this->input->get_post('email', TRUE)) {
- $email = $this->input->get_post('email', TRUE);
- }
- if ($this->input->get_post('password', TRUE)) {
- $password = $this->input->get_post('password', TRUE);
- }
- $password = base64_encode($this->input->get_post('password', TRUE));
- $insArr = array(
- 'email' => $email,
- 'password' => $password,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $str_arr = $this->db->insert('user', $insArr);
- $insert_id = $this->db->insert_id();
- $user_id = (string)$insert_id;
- $insArr['user_id'] = $user_id;
- foreach ($rowArr as $key => $value) {
- $from_user_id = $value->from_id;
- $from_email = $value->from_email;
- $to_email = $value->to_email;
- $friend_data_insert = array(
- 'user_id' => $from_user_id,
- 'friend_id' => $insert_id,
- 'email' => $email,
- 'status' => '1',
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->insert('friends', $friend_data_insert);
- $friend_data = array(
- 'user_id' => $insert_id,
- 'friend_id' => $from_user_id,
- 'email' => $from_email,
- 'status' => '1',
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->insert('friends', $friend_data);
- $payment_data = array(
- 'user_id' => $insert_id,
- 'friend_id' => $from_user_id,
- 'payment_status' => '0',
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->insert('payment', $payment_data);
- }
- $rowArr = $this->db->get_where('friend_invites', array('to_email' => $this->input->get_post('email', TRUE)))->row();
- if (count($rowArr) > 0) {
- $id = $rowArr->id;
- $email = $rowArr->email;
- $this->db->where('id', $id);
- $this->db->delete('friend_invites');
- }
- if ($str_arr) {
- $data['status'] = "success";
- $data['message'] = "user register successfully";
- $data['result'] = $insArr;
- } else {
- $data['status'] = "failure";
- $data['message'] = "user not register";
- }
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "Please enter email address";
- }
- return $data;
- }
- // public function registerUserProfilechange() {
- // if ($this->input->get_post('user_id', TRUE)) {
- // $user_id = $this->input->get_post('user_id', TRUE);
- // $image = "";
- // if ($_FILES['image']['name']) {
- // $image = $_FILES['image']['name'];
- // $this->config = array(
- // 'upload_path' => './assets/profilepic/',
- // 'allowed_types' => 'jpg|jpeg|png|gif',
- // 'file_name' => $_FILES['image']['name']
- // );
- // $this->load->library('upload', $this->config);
- // if ($this->upload->do_upload('image')) {
- // $value = array('image' => $image);
- // $this->db->where('id', $user_id);
- // if ($this->db->update('user', $value)) {
- // $data['status'] = "success";
- // $data['message'] = "User Profile Upload successfully";
- // } else {
- // $data['status'] = "failure";
- // $data['message'] = "User does not register";
- // }
- // } else {
- // $data['error'] = array('error' => $this->upload->display_errors());
- // }
- // }
- // } else {
- // $data['status'] = "failure";
- // $data['message'] = "Please enter user id";
- // }
- // return $data;
- // }
- public function registerUserProfilechange()
- {
- if ($this->input->get_post('user_id', TRUE)) {
- $user_id = $this->input->get_post('user_id', TRUE);
- if ($this->input->get_post('first_name', TRUE)) {
- $first_name = $this->input->get_post('first_name', TRUE);
- }
- if ($this->input->get_post('last_name', TRUE)) {
- $last_name = $this->input->get_post('last_name', TRUE);
- }
- if ($this->input->get_post('state', TRUE)) {
- $state = $this->input->get_post('state', TRUE);
- }
- if ($this->input->get_post('city', TRUE)) {
- $city = $this->input->get_post('city', TRUE);
- }
- if ($this->input->get_post('neighborhood', TRUE)) {
- $neighborhood = $this->input->get_post('neighborhood', TRUE);
- }
- if ($this->input->get_post('school', TRUE)) {
- $school = $this->input->get_post('school', TRUE);
- }
- if ($this->input->get_post('image', TRUE)) {
- $image = $this->input->get_post('image', TRUE);
- $path = FCPATH . "assets/profilepic/";
- //$imageStr = str_replace('data:image/png;base64,', '', $file);
- $imageStr = str_replace(' ', '+', $image);
- $dataStr = base64_decode($imageStr);
- $fileName = uniqid() . '.png';
- $file = $path . $fileName;
- $success = file_put_contents($file, $dataStr);
- }
- $password = base64_encode($this->input->get_post('password', TRUE));
- // $image = $_FILES['image']['name'];
- // $this->config = array(
- // 'upload_path' => './assets/profilepic/',
- // 'allowed_types' => 'jpg|jpeg|png|gif',
- // 'file_name' => $_FILES['image']['name']
- // );
- // $pics = $this->load->library('upload', $this->config);
- // if($this->upload->do_upload('image'))
- // {
- // $value = $image;
- // }
- // else {
- // $data['error'] = array('error' => $this->upload->display_errors());
- // }
- $insArr = array(
- 'first_name' => $first_name,
- 'last_name' => $last_name,
- 'state' => $state,
- 'city' => $city,
- 'school' => $school,
- 'image' => $fileName,
- 'neighborhood' => $neighborhood
- );
- $this->db->where('id', $user_id);
- if ($this->db->update('user', $insArr)) {
- $data['status'] = "success";
- $data['message'] = "user details update successfully .";
- $data['result'] = $insArr;
- } else {
- $data['status'] = "failure";
- $data['message'] = "Trainer does not register";
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "Please enter user id";
- }
- return $data;
- }
- public function add_event()
- {
- $current_date = date('M d Y');
- $time = date('h:i A');
- // echo $time;die;
- // echo $time;die;
- // $c1 = date('M d Y h:i:s a',strtotime($current_date));
- //echo $c1;die;
- //get the previes date into current date.
- //$d = date('M d Y', strtotime('-1 day', strtotime($current_date)));
- $user_id = $this->input->get_post('user_id', TRUE);
- $event_title = $this->input->get_post('event_title', TRUE);
- $event_location = $this->input->get_post('event_location', TRUE);
- $event_date = $this->input->get_post('event_date', TRUE);
- $event_time = $this->input->get_post('event_time', TRUE);
- $a1 = $event_date . " " . $event_time;
- $c1 = date('Y-m-d h:i A', strtotime($a1));
- $this->db->where('event.event_date_time <', $c1);
- $this->db->delete('event');
- if ($user_id == "") {
- $data['status'] = "failure";
- $data['message'] = "enter user id";
- }
- if ($event_title == "") {
- $data['status'] = "failure";
- $data['message'] = "enter event title";
- }
- if ($event_location == "") {
- $data['status'] = "failure";
- $data['message'] = "enter event location";
- }
- if ($event_date == "") {
- $data['status'] = "failure";
- $data['message'] = "enter event date";
- }
- if ($event_time == "") {
- $data['status'] = "failure";
- $data['message'] = "enter event time";
- } else {
- $insert_array = array(
- 'user_id' => $user_id,
- 'event_title' => $event_title,
- 'event_location' => $event_location,
- 'event_date' => $event_date,
- 'event_time' => $event_time,
- 'event_date_time' => $c1,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $event = $this->db->insert('event', $insert_array);
- if ($event) {
- $data['status'] = "success";
- $data['message'] = "event create successfully";
- $data['result'] = $insert_array;
- } else {
- $data['status'] = "failure";
- $data['message'] = "try again";
- }
- }
- return $data;
- }
- public function event_update()
- {
- $id = $this->input->get_post('id', TRUE);
- $event_title = $this->input->get_post('event_title', TRUE);
- $event_location = $this->input->get_post('event_location', TRUE);
- $event_date = $this->input->get_post('event_date', TRUE);
- $event_time = $this->input->get_post('event_time', TRUE);
- if ($user_id == "") {
- $data['status'] = "failure";
- $data['message'] = "enter user id";
- }
- if ($event_title == "") {
- $data['status'] = "failure";
- $data['message'] = "enter event title";
- }
- if ($event_location == "") {
- $data['status'] = "failure";
- $data['message'] = "enter event location";
- }
- if ($event_date == "") {
- $data['status'] = "failure";
- $data['message'] = "enter event date";
- }
- if ($event_time == "") {
- $data['status'] = "failure";
- $data['message'] = "enter event time";
- } else {
- $insert_array = array(
- // 'user_id' => $user_id,
- 'event_title' => $event_title,
- 'event_location' => $event_location,
- 'event_date' => $event_date,
- 'event_time' => $event_time,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->where('id', $id);
- $event = $this->db->update('event', $insert_array);
- if ($event) {
- $data['status'] = "success";
- $data['message'] = "event update successfully";
- $data['result'] = $insert_array;
- } else {
- $data['status'] = "failure";
- $data['message'] = "event not updated";
- }
- }
- return $data;
- }
- public function event_notification()
- {
- $user_id = $this->input->get_post('user_id', TRUE);
- $current_date = date('M d Y');
- $checkId = $this->db->get_where('event', array('user_id' => $user_id))->result();
- if (count($checkId) > 0) {
- $this->db->select('event.event_title,event.event_date,user.token,user.id,event.event_title');
- $this->db->from('event');
- $this->db->join('user', 'event.user_id = user.id', 'left');
- $this->db->where('event.user_id', $user_id);
- $this->db->where('event.event_date', $current_date);
- $query = $this->db->get();
- $result = $query->result();
- foreach ($result as $value) {
- $event_date = $value->event_date;
- $token = $value->token;
- $message = $value->event_title;
- //$current_data = date('M-d-Y');
- $id = $value->id;
- if ($event_date == $current_date) {
- $this->iosPushNotificationtoUser($token, $message, $id);
- $eventArr = array(
- 'user_id' => $user_id,
- 'notification' => $message,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $eventSave = $this->db->insert('log', $eventArr);
- if ($eventSave) {
- $data['status'] = "success";
- $data['message'] = "notification save";
- $data['result'] = $eventArr;
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not dave";
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "notification fail";
- }
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "user id not found";
- }
- return $data;
- }
- public function notification_list()
- {
- $user_id = $this->input->get_post('user_id', TRUE);
- $this->db->select('log.user_id,user.first_name,user.last_name,user.image,log.notification,log.created_date');
- $this->db->from('log');
- $this->db->join('user', 'log.user_id = user.id');
- $this->db->where('log.user_id', $user_id);
- $query = $this->db->get();
- $result = $query->result_array();
- if (count($result) > 0) {
- $i = 0;
- foreach ($result as $value) {
- $pics = $value['image'];
- if ($pics == "") {
- $pics = 'download.png';
- $result[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
- $img = $result[$i]['image'];
- $i++;
- $result->image = $img;
- } else {
- $result[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
- $pics = $result[$i]['image'];
- $i++;
- $result->image = $pics;
- }
- $data['status'] = "success";
- $data['message'] = "get notification list";
- $data['result'] = $result;
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not found";
- }
- return $data;
- }
- public function event_list()
- {
- $current_date = date('M d Y');
- $user_id = $this->input->get_post('user_id', TRUE);
- $this->db->select('event.id,event.user_id,event.event_title,event.event_title,event.event_location,event.event_date,event.event_time,event.event_date_time,event.event_timer');
- $this->db->from('event');
- $this->db->where('event.user_id', $user_id);
- $this->db->order_by('event.event_date', 'ASC');
- $query = $this->db->get();
- $result = $query->result_array();
- if (count($result) > 0) {
- $i = 0;
- foreach ($result as $key => $row) {
- $datetime1 = new DateTime();
- $event_timer = $row['event_timer'];
- $event_date = $row['event_date'];
- $get_date = $row['event_date'];
- $time = date("H:i", strtotime($row['event_time']));
- $event_date1 = date('Y-m-d', strtotime($get_date));
- $month = strtotime($get_date);
- $get_month = date("M", $month);
- $get_day = date("d", $month);
- $new_date_time = $event_date1 . " " . $time;
- $datetime2 = new DateTime($new_date_time);
- $interval = $datetime1->diff($datetime2);
- echo $interval->format('%Y-%m-%d %H:%i:%s');
- $result[$i]['month'] = $get_month;
- $result[$i]['day'] = $get_day;
- $result[$i]['event_date'] = $event_date;
- $result[$i]['date_time'] = $event_date1 . " " . $time;
- $result[$i]['new_date_time'] = $datetime2;
- $i++;
- }
- $event_date_time = date('Y-m-d h:i A');
- $this->db->where('event.event_date_time <', $event_date_time);
- $this->db->delete('event');
- // }
- $data['status'] = "success";
- $data['message'] = "event list";
- $data['result'] = $result;
- } else {
- $data['status'] = "failure";
- $data['message'] = "try again";
- }
- return $data;
- }
- // public function change_password(){
- // //$new_password = $this->input->get_post('new_password', TRUE);
- // $confirm_password = $this->input->get_post('new_password', TRUE);
- // $id = $this->input->get_post('user_id', TRUE);
- // if($new_password){
- // $data['status'] = "failure";
- // $data['mesage'] = "enter password";
- // }if($confirm_password){
- // $data['status'] = "failure";
- // $data['mesage'] = "enter password";
- // }else{
- // $confirm_password = base64_encode($this->input->get_post('password', TRUE));
- // $updatArr = array(
- // 'password' => $confirm_password,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $abc = $this->db->where('id',$id);
- // $Arr_update = $this->db->update('user',$updatArr);
- // $data['status'] = "success";
- // $data['message']= "change password";
- // $data['result'] = $updatArr;
- // }
- // return $data;
- // }
- public function change_password()
- {
- $password = $this->input->get_post('password', TRUE);
- $old_password = base64_encode($this->input->get_post('old_password', TRUE));
- $user_id = $this->input->get_post('user_id', TRUE);
- if ($new_password) {
- $data['status'] = "failure";
- $data['mesage'] = "enter password";
- }
- if ($confirm_password) {
- $data['status'] = "failure";
- $data['mesage'] = "enter password";
- } else {
- $pass_get = $this->db->get_where('user', array('id' => $user_id))->result();
- if (count($pass_get) > 0) {
- foreach ($pass_get as $password) {
- $get_old_password = $password->password;
- if ($old_password == $get_old_password) {
- $password = base64_encode($this->input->get_post('password', TRUE));
- $updatArr = array(
- 'password' => $password,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $abc = $this->db->where('id', $user_id);
- $Arr_update = $this->db->update('user', $updatArr);
- $data['status'] = "success";
- $data['message'] = "password change successfully";
- $data['result'] = $updatArr;
- } else {
- $data['status'] = "failure";
- $data['message'] = "old password is wrong";
- }
- }
- }
- // $password = base64_encode($this->input->get_post('password', TRUE));
- // $updatArr = array(
- // 'password' => $password,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $abc = $this->db->where('id',$user_id);
- // $Arr_update = $this->db->update('user',$updatArr);
- // $data['status'] = "success";
- // $data['message']= "password change successfully";
- // $data['result'] = $updatArr;
- }
- return $data;
- }
- public function add_friends()
- {
- if (count($_POST) > 0) {
- if (!empty($_POST['email'])) {
- // $checkEmailId = $this->db->get_where('user',array('email' => $this->input->get_post('email',TRUE)))->result();
- // if(count($checkEmailId) > 0){
- // $data['status'] = "failure";
- // $data['message'] = "email address is not register";
- // }
- //else{
- $msg = $this->sendFriendRequestEmail($_POST);
- if ($msg['resp'] == 'success') {
- $data['status'] = "success";
- $data['message'] = $msg['msg'];
- } else {
- $data['status'] = "failure";
- $data['message'] = $msg['msg'];
- }
- //}
- } else {
- $data['status'] = "failure";
- $data['message'] = "Please enter valid email address";
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "Please enter email address";
- }
- return $data;
- }
- public function friend_list()
- {
- $user_id = $this->input->get_post('user_id', TRUE);
- $this->db->select('friends.user_id,friends.friend_id,friends.email,friends.status,user.first_name,user.last_name,user.image');
- $this->db->from('friends');
- $this->db->join('user', 'friends.email = user.email');
- $this->db->where('status', 1);
- $this->db->where('friends.user_id', $user_id);
- // $this->db->where('friends.user_id = user.id');
- $query = $this->db->get();
- $result = $query->result_array();
- // $checkId = $this->db->get_where('user',array('id' => $user_id))->row();
- // $user_email = $checkId->email;
- if (count($result) > 0) {
- $i = 0;
- foreach ($result as $image) {
- //print_r($image);exit;
- $friend_user_id = $image['id'];
- $friend_email = $image['email'];
- $pics = $image['image'];
- if ($pics == "") {
- $pics = 'download.png';
- $result[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
- $img = $result[$i]['image'];
- $i++;
- $result->image = $img;
- } else {
- $pics = $image['image'];
- $result[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
- $img = $result[$i]['image'];
- $i++;
- $result->image = $img;
- //}
- }
- if ($email > 0) {
- $update_array = array(
- 'status' => 1,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->where('id', $get_id);
- $update_Arr = $this->db->update('friends', $update_array);
- }
- }
- // $checkData = $this->db->get_where('friends',array('user_id' => $friend_user_id,'friend_id' => $friends_id))->result();
- // if(count($checkData) > 0){
- // }else{
- // $dataSave = array(
- // 'user_id' => $friend_user_id,
- // 'email' => $user_email,
- // 'friend_id' => $friends_id,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $insertArr = $this->db->insert('friends',$dataSave);
- // }
- $data['status'] = "success";
- $data['message'] = "friends list";
- $data['result'] = $result;
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not found";
- }
- return $data;
- }
- public function friends_list_details()
- {
- $this->db->select('user.id,user.email');
- $this->db->from('user');
- $this->db->order_by('id', 'desc');
- $this->db->limit(1);
- $query = $this->db->get();
- $result = $query->row();
- $last_id = $result->id;
- $id = $this->input->get_post('id', TRUE);
- $this->db->select('user.id,user.first_name,user.image');
- $this->db->from('user');
- $this->db->join('friends', 'user.email = friends.email');
- //$this->db->join('fill_question_answer','user.id = fill_question_answer.user_id');
- $this->db->where('user.id', $id);
- $query = $this->db->get();
- $row = $query->row();
- if (count($row) > 0) {
- $pics1 = $row->image;
- if ($pics1 == "") {
- $row->image = base_url() . "assets/profilepic/download.png";
- } else {
- $profile = $row->image;
- $path2 = base_url() . "assets/profilepic/" . $profile;
- $row->image = $path2;
- }
- $data['status'] = "success";
- $data['message'] = "friends details";
- $data['result'] = $row;
- }
- $this->db->select('user.id,fill_question_answer.QuestionName,fill_question_answer.answer,fill_question_answer.Other');
- $this->db->from('fill_question_answer');
- $this->db->join('user', 'fill_question_answer.user_id = user.id');
- $this->db->where('user.id', $id);
- $query = $this->db->get();
- $result = $query->result();
- if (count($row) > 0) {
- // $pics = $row->image;
- // $path = base_url()."assert/profilepic/".$pics;
- // $row->image = $path;
- $data['status'] = "success";
- $data['message'] = "friend details";
- // $data['result'] = $row;
- $data['question_answer'] = $result;
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not found";
- }
- return $data;
- }
- public function all_question_qnswer()
- {
- $this->db->select('question_answer.question_id,question_answer.answer_id,question_answer.answer');
- $this->db->from('question_answer');
- $query = $this->db->get();
- $result = $query->result();
- $data['status'] = "success";
- $data['message'] = "all question answer";
- $data['result'] = $result;
- return $data;
- }
- /*public function fill_question_answer()
- {
- $user_id = $this->input->get_post('user_id',TRUE);
- $questions = $this->input->get_post('questions',TRUE);
- $questionArr = json_decode($questions,TRUE);
- foreach ($questionArr as $key1 => $value1) {
- $QuestionId = $value1['QuestionId'];
- $AnswerId = $value1['AnswerId'];
- $Other = $value1['Other'];
- $Gifted = $value1['Gifted'];
- $FriendId = $value1['FriendId'];
- $QuestionName = $value1['QuestionName'];
- $answer = $value1['answer'];
- $queAnsArr = array(
- 'user_id' => $user_id,
- 'QuestionId' => $QuestionId,
- 'AnswerId' => $AnswerId,
- 'Other' => $Other,
- 'FriendId' => $FriendId,
- 'Gifted' => $Gifted,
- 'QuestionName'=> $QuestionName,
- 'answer' => $answer,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $questionAnsSave = $this->db->insert('fill_question_answer',$queAnsArr);
- }
- $data['status'] = "success";
- $data['message'] = "save all question answer";
- $data['result'] = $queAnsArr;
- return $data;
- } */
- // public function fill_question_answer()
- // {
- // $user_id = $this->input->get_post('user_id',TRUE);
- // $questions = $this->input->get_post('questions',TRUE);
- // $payment = $this->input->get_post('payment',TRUE);
- // $questionArr = json_decode($questions,TRUE);
- // $this->db->where('user_id',$user_id);
- // $delArr = $this->db->delete('fill_question_answer');
- // // foreach ($questionArr as $key => $arr) {
- // foreach ($questionArr as $key1 => $value1) {
- // $QuestionId = $value1['QuestionId'];
- // $AnswerId = $value1['AnswerId'];
- // $Other = $value1['Other'];
- // $Gifted = $value1['Gifted'];
- // $FriendId = $value1['FriendId'];
- // $QuestionName = $value1['QuestionName'];
- // $answer = $value1['answer'];
- // // $payment = $value1['payment'];
- // $queAnsArr = array(
- // 'user_id' => $user_id,
- // 'QuestionId' => $QuestionId,
- // 'AnswerId' => $AnswerId,
- // 'Other' => $Other,
- // 'FriendId' => $FriendId,
- // 'Gifted' => $Gifted,
- // 'QuestionName'=> $QuestionName,
- // 'answer' => $answer,
- // 'payment' => $payment,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $questionAnsSave = $this->db->insert('fill_question_answer',$queAnsArr);
- // //}
- // }
- // $insPay = array(
- // 'user_id' => $user_id,
- // 'payment_status' => $payment,
- // 'friend_id' => $user_id,
- // 'payment_date' => date('Y-m-d H:i:s'),
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // //$this->db->where('id',$user_id);
- // // $this->db->update('user',array('payment_status'=> $payment));
- // $this->db->insert('payment',$insPay);
- // // $this->db->where('id',$user_id);
- // // $this->db->update('user','payment_status' => $payment);
- // $unique_number = rand(1,100);
- // $otheransArr = array(
- // 'question_id' => $QuestionId,
- // 'answer_id' => $unique_number,
- // 'other_ans_id' => $unique_number,
- // 'answer' => $Other,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $this->db->insert('question_answer',$otheransArr);
- // $data['status'] = "success";
- // $data['message'] = "save all question answer";
- // $data['result'] = $queAnsArr;
- // return $data;
- // }
- // public function fill_question_answer()
- // {
- // $user_id = $this->input->get_post('user_id',TRUE);
- // $questions = $this->input->get_post('questions',TRUE);
- // $payment = $this->input->get_post('payment',TRUE);
- // $questionArr = json_decode($questions,TRUE);
- // $this->db->where('user_id',$user_id);
- // $delArr = $this->db->delete('fill_question_answer');
- // foreach ($questionArr as $key => $arr) {
- // foreach ($arr as $key1 => $value1) {
- // $QuestionId = $value1['QuestionId'];
- // $AnswerId = $value1['AnswerId'];
- // $Other = $value1['Other'];
- // $Gifted = $value1['Gifted'];
- // $FriendId = $value1['FriendId'];
- // $QuestionName = $value1['QuestionName'];
- // $answer = $value1['answer'];
- // // $payment = $value1['payment'];
- // $queAnsArr = array(
- // 'user_id' => $user_id,
- // 'QuestionId' => $QuestionId,
- // 'AnswerId' => $AnswerId,
- // 'Other' => $Other,
- // 'FriendId' => $FriendId,
- // 'Gifted' => $Gifted,
- // 'QuestionName'=> $QuestionName,
- // 'answer' => $answer,
- // 'payment' => $payment,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $questionAnsSave = $this->db->insert('fill_question_answer',$queAnsArr);
- // }
- // }
- // $insPay = array(
- // 'user_id' => $user_id,
- // 'payment_status' => $payment,
- // 'friend_id' => $user_id,
- // 'payment_date' => date('Y-m-d H:i:s'),
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // //$this->db->where('id',$user_id);
- // // $this->db->update('user',array('payment_status'=> $payment));
- // $this->db->insert('payment',$insPay);
- // // }
- // // $this->db->where('id',$user_id);
- // // $this->db->update('user','payment_status' => $payment);
- // $data['status'] = "success";
- // $data['message'] = "save all question answer";
- // $data['result'] = $queAnsArr;
- // return $data;
- // }
- public function fill_question_answer()
- {
- $user_id = $this->input->get_post('user_id', TRUE);
- $questions = $this->input->get_post('questions', TRUE);
- $payment = $this->input->get_post('payment', TRUE);
- $questionArr = json_decode($questions, TRUE);
- $this->db->where('user_id', $user_id);
- $delArr = $this->db->delete('fill_question_answer');
- // foreach ($questionArr as $key => $arr) {
- foreach ($questionArr as $key1 => $value1) {
- $QuestionId = $value1['QuestionId'];
- $AnswerId = $value1['AnswerId'];
- $Other = $value1['Other'];
- $Gifted = $value1['Gifted'];
- $FriendId = $value1['FriendId'];
- $QuestionName = $value1['QuestionName'];
- $answer = $value1['answer'];
- // $payment = $value1['payment'];
- $queAnsArr = array(
- 'user_id' => $user_id,
- 'QuestionId' => $QuestionId,
- 'AnswerId' => $AnswerId,
- 'Other' => $Other,
- 'FriendId' => $FriendId,
- 'Gifted' => $Gifted,
- 'QuestionName' => $QuestionName,
- 'answer' => $answer,
- 'payment' => $payment,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $questionAnsSave = $this->db->insert('fill_question_answer', $queAnsArr);
- //}
- $insPay = array(
- 'user_id' => $user_id,
- 'payment_status' => $payment,
- 'friend_id' => $user_id,
- 'payment_date' => date('Y-m-d H:i:s'),
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->insert('payment', $insPay);
- //if(!empty($Other)){
- if ($answer == "other") {
- $unique_number = rand(1, 100);
- $otheransArr = array(
- 'question_id' => $QuestionId,
- 'answer_id' => $unique_number,
- 'other_ans_id' => $unique_number,
- 'answer' => $Other,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->insert('question_answer', $otheransArr);
- }
- }
- $data['status'] = "success";
- $data['message'] = "save all question answer";
- $data['result'] = $queAnsArr;
- return $data;
- }
- public function update_all_quetion_answer()
- {
- $id = $this->input->get_post('id', TRUE);
- $questions = $this->input->get_post('questions', TRUE);
- $user_id = $this->input->get_post('user_id', TRUE);
- $payment = $this->input->get_post('payment', TRUE);
- $questionArr = json_decode($questions, TRUE);
- foreach ($questionArr as $key1 => $value1) {
- foreach ($value1 as $key1 => $arr) {
- $id = $arr['id'];
- $QuestionId = $arr['QuestionId'];
- $AnswerId = $arr['AnswerId'];
- $Other = $arr['Other'];
- $Gifted = $arr['Gifted'];
- $FriendId = $arr['FriendId'];
- $QuestionName = $arr['QuestionName'];
- $answer = $arr['answer'];
- $queAnsArr = array(
- 'user_id' => $user_id,
- 'QuestionId' => $QuestionId,
- 'AnswerId' => $AnswerId,
- 'Other' => $Other,
- 'FriendId' => $FriendId,
- 'Gifted' => $Gifted,
- 'QuestionName' => $QuestionName,
- 'answer' => $answer,
- 'payment' => $payment,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->where('id', $id);
- $questionAnsSave = $this->db->update('fill_question_answer', $queAnsArr);
- }
- }
- $data['status'] = "success";
- $data['message'] = "update all question answer";
- $data['result'] = $queAnsArr;
- return $data;
- }
- public function iosPushNotificationtoUser($token, $message, $id)
- {
- $dataArr = array("token" => $token, "message" => $message, "id" => $id);
- $url = "https://recoverrefuel.com/webservices/ios_push_notification_girlfriendgift";
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_URL => $url,
- CURLOPT_USERAGENT => 'Push',
- CURLOPT_POST => 1,
- CURLOPT_POSTFIELDS => $dataArr
- ));
- $resp = curl_exec($curl);
- //print_r($resp);exit;
- }
- // public function fill_question_answer()
- // {
- // $user_id = $this->input->get_post('user_id',TRUE);
- // $questions = $this->input->get_post('questions',TRUE);
- // // $questionArr = json_encode($questions);
- // $questionArr = json_decode($questions,TRUE);
- // foreach ($questionArr as $key => $row) {
- // $QuestionId = $row['QuestionId'];
- // $AnswerId = $row['AnswerId'];
- // $Other = $row['Other'];
- // $Gifted = $row['Gifted'];
- // $FriendId = $row['FriendId'];
- // $QuestionName = $row['QuestionName'];
- // $queAnsArr = array(
- // 'user_id' => $user_id,
- // 'QuestionId' => $QuestionId,
- // 'AnswerId' => $AnswerId,
- // 'Other' => $Other,
- // 'FriendId' => $FriendId,
- // 'Gifted' => $Gifted,
- // 'QuestionName'=> $QuestionName,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $questionAnsSave = $this->db->insert('fill_question_answer',$queAnsArr);
- // }
- // $data['status'] = "success";
- // $data['message'] = "save all question answer";
- // $data['result'] = $queAnsArr;
- // return $data;
- // }
- // public function fill_question_answer()
- // {
- // $user_id = $this->input->get_post('user_id',TRUE);
- // $questions = $this->input->get_post('questions',TRUE);
- // // $questionArr = json_encode($questions);
- // echo '<pre>';
- // print_r($questions);
- // exit;
- // $questionArr = json_decode($questions,TRUE);
- // foreach ($questionArr as $value) {
- // //foreach ($row as $key => $value) {
- // // $id = $row['question_id'];
- // // $question = $row['question'];
- // // $answer = $row['answer'];
- // // $other = $row['other'];
- // // $gifted = $row['gifted'];
- // // $friend_id = $row['friend_id'];
- // $QuestionId = $value['QuestionId'];
- // $AnswerId = $value['AnswerId'];
- // $Other = $value['Other'];
- // $Gifted = $value['Gifted'];
- // $FriendId = $value['FriendId'];
- // $QuestionName = $value['QuestionName'];
- // // $queAnsArr = array(
- // // 'user_id' => $user_id,
- // // 'question_id' => $id,
- // // 'question' => $question,
- // // 'answer' => $answer,
- // // 'other' => $other,
- // // 'friend_id' => $friend_id,
- // // 'gifted' => $gifted,
- // // 'created_date' => date('Y-m-d H:i:s')
- // // );
- // $queAnsArr = array(
- // 'user_id' => $user_id,
- // 'QuestionId' => $QuestionId,
- // 'AnswerId' => $AnswerId,
- // 'Other' => $Other,
- // 'FriendId' => $FriendId,
- // 'Gifted' => $Gifted,
- // 'QuestionName'=> $QuestionName,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $questionAnsSave = $this->db->insert('fill_question_answer',$queAnsArr);
- // // }
- // }
- // $data['status'] = "success";
- // $data['message'] = "save all question answer";
- // $data['result'] = $queAnsArr;
- // return $data;
- // }
- // 05/07/2017
- // public function fill_question_answer_show(){
- // $user_id = $this->input->get_post('user_id',TRUE);
- // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
- // $this->db->from('fill_question_answer');
- // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- // $this->db->join('user','fill_question_answer.user_id = user.id');
- // $this->db->where('fill_question_answer.user_id',$user_id);
- // $query = $this->db->get();
- // $result = $query->result_array();
- // if(count($result) > 0){
- // $i = 0;
- // foreach ($result as $image) {
- // $friend_id = $image['FriendId'];
- // $name = $image['first_name'];
- // $pics = $image['image'];
- // $QuestionId = $image['QuestionId'];
- // if($friend_id == 0){
- // $result[$i]['first_name'] = "";
- // $result[$i]['image'] = "";
- // $i++;
- // }else{
- // $result->first_name = $name;
- // $result[$i]['image'] = base_url()."assets/profilepic/". $pics;
- // $pics = $result[$i]['image'];
- // $i++;
- // $result->image = $pics;
- // }
- // $data['status'] = "success";
- // $data['message'] = "get question answer";
- // if($QuestionId == 1){
- // $answer = $image['Other'];
- // $result[0]['answer'] = $answer;
- // }
- // else{
- // $answer = $image['Other'];
- // }
- // $data['result'] = $result;
- // }
- // }else{
- // $data['status'] = "failure";
- // $data['message'] = "data not found";
- // }
- // return $data;
- // }
- // public function fill_question_answer_show(){
- // $user_id = $this->input->get_post('user_id',TRUE);
- // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
- // $this->db->from('fill_question_answer');
- // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- // $this->db->join('user','fill_question_answer.user_id = user.id');
- // $this->db->where('fill_question_answer.user_id',$user_id);
- // $query = $this->db->get();
- // $result = $query->result_array();
- // if(count($result) > 0){
- // $i = 0;
- // foreach ($result as $image) {
- // $friend_id = $image['FriendId'];
- // $name = $image['first_name'];
- // $pics = $image['image'];
- // $QuestionId = $image['QuestionId'];
- // if($friend_id == 0){
- // $result[$i]['first_name'] = "";
- // $result[$i]['image'] = "";
- // $i++;
- // }else{
- // $check_friends_id = $this->db->get_where('user',array('id' =>$friend_id))->result_array();
- // if(count($check_friends_id) > 0){
- // foreach ($check_friends_id as $key =>$value) {
- // $friends_first_name = $value['first_name'];
- // $friends_last_name = $value['last_name'];
- // $friends_image = $value['image'];
- // $result[$i]['first_name'] = $friends_first_name." ".$friends_last_name;
- // $friends = $result[$i]['first_name'];
- // //print_r($friends);exit;
- // $result[$i]['first_name'] = $friends;
- // $result[$i]['image'] = base_url()."assets/profilepic/". $friends_image;
- // $pics = $result[$i]['image'];
- // $i++;
- // $result->image = $pics;
- // }
- // }else{
- // $result->first_name = $name;
- // $result[$i]['image'] = base_url()."assets/profilepic/". $pics;
- // $pics = $result[$i]['image'];
- // $i++;
- // $result->image = $pics;
- // }
- // }
- // $data['status'] = "success";
- // $data['message'] = "get question answer";
- // if($QuestionId == 1){
- // $answer = $image['Other'];
- // $result[0]['answer'] = $answer;
- // }
- // else{
- // $answer = $image['Other'];
- // }
- // $data['result'] = $result;
- // }
- // }else{
- // $data['status'] = "failure";
- // $data['message'] = "data not found";
- // }
- // return $data;
- // }
- // public function fill_question_answer_show(){
- // $user_id = $this->input->get_post('user_id',TRUE);
- // $this->db->select('fill_question_answer.id as fill_id,fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,fill_question_answer.payment');
- // $this->db->from('fill_question_answer');
- // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- // $this->db->join('user','fill_question_answer.user_id = user.id');
- // // $this->db->join('payment','fill_question_answer.payment = payment.payment_status');
- // $this->db->where('fill_question_answer.user_id',$user_id);
- // //$this->db->where('payment.payment_status','0');
- // $query = $this->db->get();
- // $result = $query->result_array();
- // //print_r($result);exit;
- // $paymentCheck = $this->db->get_where('payment',array('user_id' => $user_id))->result();
- // foreach ($paymentCheck as $payment) {
- // $get_payment = $payment->payment_status;
- // }
- // if(count($result) > 0){
- // $i = 0;
- // foreach ($result as $image) {
- // $friend_id = $image['FriendId'];
- // $name = $image['first_name'];
- // $pics = $image['image'];
- // $other = $image['Other'];
- // $payment = $image['payment'];
- // $QuestionId = $image['QuestionId'];
- // //$friend_id1 = $image['friend_id'];
- // if($friend_id == 0){
- // $result[$i]['first_name'] = "";
- // $result[$i]['image'] = "";
- // $i++;
- // }else{
- // if($pics == ""){
- // $result->image = $pics;
- // }else{
- // $result->first_name = $name;
- // $result[$i]['image'] = base_url()."assets/profilepic/". $pics;
- // $pics = $result[$i]['image'];
- // $i++;
- // $result->image = $pics;
- // }
- // }
- // }
- // $data['status'] = "success";
- // $data['message'] = "get question answer";
- // if($QuestionId == 1){
- // $answer = $image['Other'];
- // $result[0]['answer'] = $answer;
- // }else{
- // $answer = $image['Other'];
- // }
- // if($payment == 0){
- // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
- // $this->db->from('fill_question_answer');
- // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- // $this->db->join('user','fill_question_answer.user_id = user.id');
- // // $this->db->join('payment','user_id')
- // $this->db->where('fill_question_answer.user_id',$user_id);
- // //$this->db->where('fill_question_answer.QuestionId',$q_id);
- // $this->db->order_by('fill_question_answer.QuestionId','ASC');
- // $this->db->limit(10, 0);
- // $query_str = $this->db->get();
- // $result_array = $query_str->result_array();
- // //print_r($result1); exit;
- // $data['status'] = "success";
- // $data['message'] = "get question answer show";
- // $data['payment'] = $payment;
- // $data['result'] = $result_array;
- // // }
- // }else{
- // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,fill_question_answer.payment');
- // $this->db->from('fill_question_answer');
- // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- // $this->db->join('user','fill_question_answer.user_id = user.id');
- // // $this->db->join('payment','user.id = payment.user_id');
- // $this->db->where('fill_question_answer.user_id',$user_id);
- // $this->db->where('fill_question_answer.payment','1');
- // $str_qry = $this->db->get();
- // $ret = $str_qry->result_array();
- // // print_r($ret);exit;
- // $data['status'] = "success";
- // $data['message'] = "getting all question answer";
- // $data['payment'] = $payment;
- // $data['result'] = $ret;
- // //}
- // }
- // //$data['result'] = $result;
- // //}
- // }else{
- // $data['status'] = "failure";
- // $data['message'] = "data not found";
- // }
- // return $data;
- // }
- public function fill_question_answer_show()
- {
- $user_id = $this->input->get_post('user_id', TRUE);
- $this->db->select('fill_question_answer.id as fill_id,fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,fill_question_answer.payment');
- $this->db->from('fill_question_answer');
- $this->db->join('question_answer', 'fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- $this->db->join('user', 'fill_question_answer.user_id = user.id');
- // $this->db->join('payment','fill_question_answer.payment = payment.payment_status');
- $this->db->where('fill_question_answer.user_id', $user_id);
- //$this->db->where('payment.payment_status','0');
- $query = $this->db->get();
- $result = $query->result_array();
- //print_r($result);exit;
- $paymentCheck = $this->db->get_where('payment', array('user_id' => $user_id))->result();
- foreach ($paymentCheck as $payment) {
- $get_payment = $payment->payment_status;
- }
- if (count($result) > 0) {
- $i = 0;
- foreach ($result as $image) {
- $friend_id = $image['FriendId'];
- $name = $image['first_name'];
- $pics = $image['image'];
- $other = $image['Other'];
- $payment = $image['payment'];
- $QuestionId = $image['QuestionId'];
- //$friend_id1 = $image['friend_id'];
- // $checkFriendId = $this->db->get_where('user',array('id' => $friend_id))->row();
- // if(count($checkFriendId) > 0 ){
- // $friend_id = $checkFriendId->id;
- // $first_name = $checkFriendId->first_name;
- // $last_name = $checkFriendId->last_name;
- // $full_name = $first_name . "" .$last_name;
- // if($friend_id == 0){
- // $result[$i]['first_name'] = "";
- // $result[$i]['image'] = "";
- // $i++;
- // }else{
- // if($pics == ""){
- // $result->image = $pics;
- // }else{
- // $result->first_name = $full_name;
- // $result[$i]['image'] = base_url()."assets/profilepic/". $pics;
- // $pics = $result[$i]['image'];
- // $i++;
- // $result->image = $pics;
- // }
- // }
- // }else{
- // $result[$i]['first_name'] = "";
- // $result[$i]['image'] = "";
- // $i++;
- // }
- }
- $data['status'] = "success";
- $data['message'] = "get question answer";
- //$data['result'] = $result;
- // if($QuestionId == 1){
- // $answer = $image['Other'];
- // $result[0]['answer'] = $answer;
- // }else{
- // $answer = $image['Other'];
- // }
- if ($payment == 0) {
- $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,fill_question_answer.created_date');
- $this->db->from('fill_question_answer1');
- $this->db->join('question_answer', 'fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- $this->db->join('user', 'fill_question_answer.user_id = user.id');
- // $this->db->join('payment','user_id')
- $this->db->where('fill_question_answer.user_id', $user_id);
- //$this->db->where('fill_question_answer.QuestionId',$q_id);
- $this->db->order_by('fill_question_answer.QuestionId', 'ASC');
- $this->db->limit(10, 0);
- $query_str = $this->db->get();
- // print_r($this->db->last_query());exit;
- $result_array = $query_str->result_array();
- $i = 0;
- foreach ($result_array as $birthDate) {
- $friend_id = $birthDate['FriendId'];
- $questionId = $birthDate['QuestionId'];
- $date = $birthDate['created_date'];
- $created_date = $birthDate['created_date'];
- //$creat_date = date($created_date);
- $creat_date = date('d-M-Y', strtotime($created_date));
- $checkFriendId = $this->db->get_where('user', array('id' => $friend_id))->row();
- if (count($checkFriendId) > 0) {
- $friend_id = $checkFriendId->id;
- $first_name = $checkFriendId->first_name;
- $last_name = $checkFriendId->last_name;
- $fri_full_name = $first_name . " " . $last_name;
- if ($friend_id == 0) {
- $result_array[$i]['date'] = $creat_date;
- $result_array[$i]['first_name'] = "";
- $result_array[$i]['image'] = "";
- $i++;
- } else {
- if ($pics == "") {
- $result_array->image = $pics;
- } else {
- $result_array[$i]['date'] = $creat_date;
- $result_array[$i]['first_name'] = $fri_full_name;
- $result_array[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
- $pics = $result_array[$i]['image'];
- $i++;
- $result_array->image = $pics;
- $result_array->first_name = $name;
- }
- }
- } else {
- $result_array[$i]['first_name'] = "";
- $result_array[$i]['image'] = "";
- $i++;
- }
- if ($questionId == 1) {
- $birthDate = $birthDate['Other'];
- $result_array[0]['answer'] = $birthDate;
- } else {
- $answer = $birthDate['Other'];
- }
- }
- $data['status'] = "success";
- $data['message'] = "get question answer show";
- $data['payment'] = $payment;
- $data['result'] = $result_array;
- // }
- } else {
- $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,fill_question_answer.payment,fill_question_answer.created_date');
- $this->db->from('fill_question_answer');
- $this->db->join('question_answer', 'fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- $this->db->join('user', 'fill_question_answer.user_id = user.id');
- // $this->db->join('payment','user.id = payment.user_id');
- $this->db->where('fill_question_answer.user_id', $user_id);
- $this->db->where('fill_question_answer.payment', '1');
- $this->db->order_by('fill_question_answer.QuestionId', 'ASC');
- $str_qry = $this->db->get();
- $result_array = $str_qry->result_array();
- //print_r($result_array);
- $i = 0;
- $final_array = [];
- foreach ($result_array as $birthDate) {
- $questionId = $birthDate['QuestionId'];
- $date = $birthDate['created_date'];
- $created_date = $birthDate['created_date'];
- //$creat_date = date($created_date);
- $creat_date = date('d-M-Y', strtotime($created_date));
- $friend_id = $birthDate['FriendId'];
- $checkFriendId = $this->db->get_where('user', array('id' => $friend_id))->row();
- //print_r($checkFriendId);
- ///---
- $arr['QuestionName'] = isset($birthDate['QuestionName']) ? $birthDate['QuestionName'] : '';
- $arr['AnswerId'] = isset($birthDate['AnswerId']) ? $birthDate['AnswerId'] : '';
- $arr['QuestionId'] = isset($birthDate['QuestionId']) ? $birthDate['QuestionId'] : '';
- $arr['FriendId'] = isset($checkFriendId->id) ? $checkFriendId->id : '0';
- $arr['Gifted'] = isset($birthDate['Gifted']) ? $birthDate['Gifted'] : '';
- $arr['Other'] = isset($birthDate['Other']) ? $birthDate['Other'] : '';
- $arr['answer'] = isset($birthDate['answer']) ? $birthDate['answer'] : '';
- $arr['first_name'] = $checkFriendId->first_name . " " . $checkFriendId->last_name;
- if ($arr['FriendId'] != 0) {
- $arr['image'] = isset($checkFriendId->image) && $checkFriendId->image != "" ? base_url() . "assets/profilepic/" . $checkFriendId->image : base_url() . "assets/profilepic/download.png";
- } else {
- $arr['image'] = "";
- }
- $arr['payment'] = isset($birthDate['payment']) ? $birthDate['payment'] : '';
- $arr['created_date'] = isset($birthDate['created_date']) ? $birthDate['created_date'] : '';
- if ($questionId == 1) {
- $arr['answer'] = $birthDate['Other'];
- } else {
- $arr['answer'] = $birthDate['answer'];
- }
- //$birthDate['frend'] = $arr;
- $mer = array_merge($birthDate, $arr);
- $final_array[] = $arr;
- ///--
- /**
- * if(count($checkFriendId) > 0 ){
- * // print_r($checkFriendId);
- * $friend_id = $checkFriendId->id;
- * $first_name = $checkFriendId->first_name;
- * $last_name = $checkFriendId->last_name;
- * $fri_full_name = $first_name . " " .$last_name;
- * $pics = $checkFriendId->image;
- * if($friend_id == 0){
- * $result_array[$i]['date'] = $creat_date;
- * $result_array[$i]['first_name'] = "";
- * $result_array[$i]['image'] = "";
- * $i++;
- * }else{
- * if($pics == ""){
- * $result_array->image = $pics;
- * }else{
- *
- * $result_array[$i]['date'] = $creat_date;
- * $result_array[$i]['first_name'] = $fri_full_name;
- * // print_r($result_array[$i]['first_name']);exit;
- * $result_array[$i]['image'] = base_url()."assets/profilepic/". $pics;
- * $pics = $result_array[$i]['image'];
- * $i++;
- * $result_array->image = $pics;
- * $result_array->first_name = $name;
- * }
- * }
- * }else{
- * $result_array[$i]['first_name'] = "";
- * $result_array[$i]['image'] = "";
- * $i++;
- * }
- *
- * if($questionId == 1){
- * $birthDate = $birthDate['Other'];
- * $result_array[0]['answer'] = $birthDate;
- * }else{
- * $answer = $birthDate['Other'];
- * }
- */
- }
- //echo $friend_id = $birthDate['FriendId'];
- // print_r($result_array);exit;
- $data['status'] = "success";
- $data['message'] = "getting all question answer";
- $data['payment'] = $payment;
- $data['result'] = $final_array;//$result_array;
- //}
- }
- //$data['result'] = $result;
- //}
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not found";
- }
- return $data;
- }
- // public function friends_question_answer_show(){
- // $user_id = $this->input->get_post('user_id',TRUE);
- // $friend_id = $this->input->get_post('friend_id',TRUE);
- // $this->db->select('fill_question_answer.id,fill_question_answer.user_id,fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer');
- // $this->db->from('fill_question_answer');
- // $this->db->join('question_answer','fill_question_answer.QuestionId = question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- // $this->db->join('payment','fill_question_answer.user_id = payment.friend_id');
- // //$this->db->join('user','fill_question_answer.user_id = user.id');
- // // $this->db->join('payment','fill_question_answer.payment = payment.payment_status');
- // $this->db->where('payment.user_id',$user_id);
- // $this->db->where('payment.friend_id',$friend_id);
- // //$this->db->where('payment.payment_status','1');
- // $query = $this->db->get();
- // $result = $query->result_array();
- // $checkPaymentArr = $this->db->get_where('payment',array('user_id' => $user_id,'friend_id' => $friend_id))->row();
- // $payment_status = $checkPaymentArr->payment_status;
- // if(count($result) > 0){
- // foreach ($result as $image) {
- // $friend_id = $image['FriendId'];
- // $name = $image['first_name'];
- // $pics = $image['image'];
- // $other = $image['Other'];
- // //$payment = $image['payment_status'];
- // $QuestionId = $image['QuestionId'];
- // if($payment_status == 0){
- // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
- // $this->db->from('fill_question_answer');
- // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- // $this->db->join('user','fill_question_answer.user_id = user.id');
- // $this->db->where('fill_question_answer.user_id',$user_id);
- // $this->db->where("QuestionId >= 1 and QuestionId <= 10");
- // // $this->db->order_by('fill_question_answer.QuestionId','ASC');
- // $query_str = $this->db->get();
- // // print_r($this->db->last_query())->result();
- // $result_array = $query_str->result_array();
- // //print_r($result_array);exit;
- // $data['status'] = "success";
- // $data['message'] = "get question answer show";
- // $data['payment'] = $payment_status;
- // $data['result'] = $result_array;
- // // }
- // }else{
- // $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image,payment.payment_status');
- // $this->db->from('fill_question_answer');
- // $this->db->join('question_answer','fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- // $this->db->join('user','fill_question_answer.user_id = user.id');
- // $this->db->join('payment','user.id = payment.user_id');
- // $this->db->where('fill_question_answer.user_id',$user_id);
- // $this->db->where('payment.payment_status','1');
- // $str_qry = $this->db->get();
- // $ret = $str_qry->result_array();
- // // print_r($ret);exit;
- // $data['status'] = "success";
- // $data['message'] = "getting all question answer";
- // $data['payment'] = $get_payment;
- // $data['result'] = $ret;
- // //}
- // }
- // }
- // // $data['status'] = "success";
- // // $data['message'] = "friends question answer details";
- // // $data['result'] = $result;
- // }else{
- // $data['status'] = "failure";
- // $data['message'] = "data not found";
- // }
- // return $data;
- // }
- public function friends_payment_status()
- {
- $user_id = $this->input->get_post('user_id', TRUE);
- $friend_id = $this->input->get_post('friend_id', TRUE);
- $payment = $this->input->get_post('payment', TRUE);
- $checkId = $this->db->get_where('payment', array('user_id' => $user_id, 'friend_id' => $friend_id, 'payment_status' => '0'))->result();
- if ($checkId) {
- $upudateArr = array(
- 'payment_status' => 1
- );
- $this->db->where('user_id', $user_id)->where('friend_id', $friend_id);
- $updateSave = $this->db->update('payment', $upudateArr);
- $data['status'] = "success";
- $data['message'] = "update successfully";
- $data['result'] = $upudateArr;
- } else {
- $paymentArr = array(
- 'user_id' => $user_id,
- 'friend_id' => $friend_id,
- 'payment_status' => $payment,
- 'create_date' => date('Y-m-d H:i:s')
- );
- $insertArr = $this->db->insert('payment', $paymentArr);
- if (count($insertArr)) {
- $data['status'] = "success";
- $data['message'] = "payment successfully";
- $data['result'] = $paymentArr;
- //$data['payment']
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not found";
- }
- }
- return $data;
- }
- public function friends_question_answer_show()
- {
- $user_id = $this->input->get_post('user_id', TRUE);
- $friend_id = $this->input->get_post('friend_id', TRUE);
- $this->db->select('fill_question_answer.id,fill_question_answer.user_id,fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,fill_question_answer.payment');
- $this->db->from('fill_question_answer');
- $this->db->join('question_answer', 'fill_question_answer.QuestionId = question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- // $this->db->join('payment','fill_question_answer.user_id = payment.friend_id');
- $this->db->join('user', 'fill_question_answer.user_id = user.id');
- // $this->db->join('payment','fill_question_answer.payment = payment.payment_status');
- $this->db->where('user.id', $friend_id);
- // $this->db->where('payment.user_id',$user_id);
- //$this->db->where('payment.friend_id',$friend_id);
- //$this->db->where('payment.payment_status','1');
- $query = $this->db->get();
- $result = $query->result_array();
- // print_r($result);exit;
- $checkPaymentArr = $this->db->get_where('payment', array('user_id' => $user_id, 'friend_id' => $friend_id))->row();
- $payment_status = $checkPaymentArr->payment_status;
- if ($payment_status == "") {
- $payment_status = "0";
- } else {
- $payment_status = $checkPaymentArr->payment_status;
- }
- $get_friend_id = $checkPaymentArr->friend_id;
- $get_user_id = $checkPaymentArr->user_id;
- $user_payment = $this->db->get_where('fill_question_answer', array('user_id' => $friend_id))->result();
- //print_r($user_payment);exit;
- foreach ($user_payment as $user_pay) {
- $total_payment = $user_pay->payment;
- }
- if (count($result) > 0) {
- foreach ($result as $image) {
- $friend_id = $image['FriendId'];
- $name = $image['first_name'];
- $pics = $image['image'];
- $other = $image['Other'];
- //$payment = $image['payment_status'];
- $QuestionId = $image['QuestionId'];
- if ($payment_status == 0) {
- $friend_id = $this->input->get_post('friend_id', TRUE);
- $this->db->select('fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
- $this->db->from('fill_question_answer');
- $this->db->join('question_answer', 'fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- $this->db->join('user', 'fill_question_answer.user_id = user.id');
- //$this->db->where('fill_question_answer.user_id',$get_friend_id);
- $this->db->where('fill_question_answer.user_id', $friend_id);
- $this->db->where("QuestionId >= 1 and QuestionId <= 10");
- $this->db->order_by('fill_question_answer.QuestionId', 'ASC');
- $query_str = $this->db->get();
- // print_r($this->db->last_query())->result();
- $result_array = $query_str->result_array();
- //print_r($result_array);exit;
- foreach ($result_array as $birthDate) {
- $questionId = $birthDate['QuestionId'];
- if ($questionId == 1) {
- $birthDate = $birthDate['Other'];
- $result_array[0]['answer'] = $birthDate;
- } else {
- $answer = $birthDate['Other'];
- }
- if ($questionId == 2) {
- $rose = $birthDate['Other'];
- if ($rose == "") {
- $rose1 = $birthDate['answer'];
- $result_array[1]['answer'] = $rose1;
- } else {
- $result_array[1]['answer'] = $rose;
- }
- } else if ($questionId == 3) {
- $fragrances = $birthDate['Other'];
- if ($fragrances == "") {
- $fragrances1 = $birthDate['answer'];
- $result_array[2]['answer'] = $fragrances1;
- } else {
- $result_array[2]['answer'] = $fragrances;
- }
- } else if ($questionId == 4) {
- $body = $birthDate['Other'];
- if ($body == "") {
- $body1 = $birthDate['answer'];
- $result_array[3]['answer'] = $body1;
- } else {
- $result_array[3]['answer'] = $body;
- }
- } else if ($questionId == 5) {
- $body = $birthDate['Other'];
- if ($body == "") {
- $body1 = $birthDate['answer'];
- $result_array[4]['answer'] = $body1;
- } else {
- $result_array[4]['answer'] = $body;
- }
- } else if ($questionId == 6) {
- $restorent = $birthDate['Other'];
- if ($restorent == "") {
- $restorent1 = $birthDate['answer'];
- $result_array[5]['answer'] = $restorent1;
- } else {
- $result_array[5]['answer'] = $restorent;
- }
- } else if ($questionId == 7) {
- $cocktail = $birthDate['Other'];
- if ($cocktail == "") {
- $cocktail1 = $birthDate['answer'];
- $result_array[6]['answer'] = $cocktail1;
- } else {
- $result_array[6]['answer'] = $cocktail;
- }
- } else if ($questionId == 8) {
- $answer = $birthDate['Other'];
- if ($answer == "") {
- $answer1 = $birthDate['answer'];
- $result_array[7]['answer'] = $answer1;
- } else {
- $result_array[7]['answer'] = $answer;
- }
- } else if ($questionId == 9) {
- $answer = $birthDate['Other'];
- if ($answer == "") {
- $answer1 = $birthDate['answer'];
- $result_array[8]['answer'] = $answer1;
- } else {
- $result_array[8]['answer'] = $answer;
- }
- } else if ($questionId == 10) {
- $answer = $birthDate['Other'];
- if ($answer == "") {
- $answer1 = $birthDate['answer'];
- $result_array[9]['answer'] = $answer1;
- } else {
- $result_array[9]['answer'] = $answer;
- }
- } else {
- }
- }
- $data['status'] = "success";
- $data['message'] = "get question answer show";
- $data['payment'] = $payment_status;
- $data['total_payment'] = $total_payment;
- $data['result'] = $result_array;
- // }
- } else {
- //echo "hi";exit;
- $this->db->select('fill_question_answer.user_id,fill_question_answer.QuestionName,fill_question_answer.AnswerId,fill_question_answer.QuestionId,fill_question_answer.FriendId,fill_question_answer.Gifted,fill_question_answer.Other,question_answer.answer,user.first_name,user.image');
- $this->db->from('fill_question_answer');
- $this->db->join('question_answer', 'fill_question_answer.QuestionId =question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- $this->db->join('user', 'fill_question_answer.user_id = user.id');
- //$this->db->join('payment','user.id = payment.user_id');
- $this->db->where('fill_question_answer.user_id', $get_friend_id);
- // $this->db->where('payment.friend_id',$get_friend_id);
- //$this->db->where('payment.payment_status','1');
- $str_qry = $this->db->get();
- $ret = $str_qry->result_array();
- // print_r($ret);exit;
- $data['status'] = "success";
- $data['message'] = "getting all question answer";
- $data['payment'] = $payment_status;
- $data['total_payment'] = $total_payment;
- $data['result'] = $ret;
- //}
- }
- }
- // $data['status'] = "success";
- // $data['message'] = "friends question answer details";
- // $data['result'] = $result;
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not found";
- }
- return $data;
- }
- public function all_question_answer()
- {
- $this->db->select('question_answer.question_id,question_list.question,question_answer.answer_id,question_answer.answer');
- $this->db->from('question_answer');
- $this->db->join('question_list', 'question_answer.question_id = question_list.id');
- // $this->db->join('fill_question_answer','question_list.id = fill_question_answer.question_id');
- $query = $this->db->get();
- $result = $query->result();
- // $questionArr = $this->db->get_where('question_answer',array('answer' => ""))->result();
- // foreach ($questionArr as $value) {
- // $get_id = $value->id;
- // $this->db->where('id',$get_id);
- // $this->db->delete('question_answer');
- // }
- if (count($result) > 0) {
- $data['status'] = "success";
- $data['message'] = "all question answer list";
- $data['result'] = $result;
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not found";
- }
- return $data;
- }
- public function rating_review()
- {
- $user_id = $this->input->get_post('user_id', TRUE);
- $rate = $this->input->get_post('rate', TRUE);
- $review = $this->input->get_post('review', TRUE);
- if ($rate == "") {
- $data['status'] = "failure";
- $data['message'] = "enter rate";
- }
- if ($review == "") {
- $data['status'] = "failure";
- $data['message'] = "enter review";
- } else {
- $insertArr = array(
- 'user_id' => $user_id,
- 'rate' => $rate,
- 'review' => $review,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $saveArr = $this->db->insert('rating', $insertArr);
- if ($saveArr) {
- $data['status'] = "success";
- $data['message'] = "rating save";
- $data['result'] = $insertArr;
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not save";
- }
- }
- return $data;
- }
- public function givenQueAns()
- {
- $user_id = $this->input->get_post('user_id', TRUE);
- $this->db->select('fill_question_answer.id,fill_question_answer.user_id,fill_question_answer.FriendId,fill_question_answer.QuestionId,fill_question_answer.QuestionName,fill_question_answer.Other,fill_question_answer.Gifted,user.first_name,user.image,fill_question_answer.answer');
- $this->db->from('fill_question_answer');
- $this->db->join('user', 'fill_question_answer.user_id = user.id');
- $this->db->join('question_answer', 'fill_question_answer.QuestionId = question_answer.question_id AND fill_question_answer.AnswerId = question_answer.answer_id');
- $this->db->where('fill_question_answer.user_id', $user_id);
- $query = $this->db->get();
- $result = $query->result_array();
- if (count($result) > 0) {
- $i = 0;
- $data['status'] = "success";
- $data['message'] = "user question answer list";
- // while($res = mysql_fetch_array($result)){
- foreach ($result as $image) {
- $friend_id = $image['FriendId'];
- $QuestionId = $image['QuestionId'];
- $AnswerId = $image['AnswerId'];
- $QuestionName = $image['QuestionName'];
- $Other = $image['Other'];
- $Gifted = $image['Gifted'];
- $answer = $image['answer'];
- $name = $image['first_name'];
- $pics = $image['image'];
- // $data['user_id'] = $user_id;
- // $data['friend_id'] = $friend_id;
- // $data['question_id'] = $QuestionId;
- // $data['question_name'] = $QuestionName;
- // if($AnswerId == 0){
- // $data['answer'] = $Other;
- // }else{
- // $data['answer'] = $answer;
- // }
- // $data['other'] = $Other;
- // $data['gifted'] = $Gifted;
- // $data['first_name'] = $name;
- // $data['image'] = $pics;
- if ($friend_id == 0) {
- $result[$i]['first_name'] = "";
- // $result->first_name = "";
- //$result->image = "";
- $result[$i]['image'] = "";
- $i++;
- } else {
- // $result[$i]['first_name'] = $name;
- $result->first_name = $name;
- $result[$i]['image'] = base_url() . "assets/profilepic/" . $pics;
- $pics = $result[$i]['image'];
- $i++;
- $result->image = $pics;
- }
- if ($QuestionId == 1) {
- $answer = $image['Other'];
- $result[0]['answer'] = $answer;
- } else {
- $data['answer'] = $Other;
- }
- $data['result'] = $result;
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "data not found";
- }
- return $data;
- }
- public function set_upload_options_certi()
- {
- //upload an image options
- $config = array();
- $config['upload_path'] = './assets/certificates/';
- $config['allowed_types'] = 'pdf|doc|docx|txt';
- $config['max_size'] = '0';
- $config['overwrite'] = FALSE;
- return $config;
- }
- public function forgotPassword()
- {
- //if ($this->input->get_post('email', TRUE)) {
- // if (!filter_var($this->input->get_post('email', TRUE), FILTER_VALIDATE_EMAIL) === false) {
- $msg = $this->sendForgotPasswordEmail($this->input->get_post('email', TRUE));
- if ($msg['resp'] == 'success') {
- $data['status'] = "success";
- $data['message'] = $msg['msg'];
- } else {
- $data['status'] = "failure";
- $data['message'] = $msg['msg'];
- }
- // }
- // else {
- // $data['status'] = "failure";
- // $data['message'] = "Please enter valid email address";
- // }
- // } else {
- // // $data['status'] = "failure";
- // // $data['message'] = "Please enter email address";
- // // }
- return $data;
- }
- function sendForgotPasswordEmail($postdata)
- {
- // $email = $this->input->get_post('email',TRUE);
- $row = $this->db->from('user')->where('email', $postdata)->get()->row();
- //echo $this->db->last_query();
- if (count($row) > 0) {
- $temp_pass = md5(uniqid());
- $this->session->set_userdata('temp_pass', $temp_pass);
- $tstamp = $_SERVER["REQUEST_TIME"];
- $message = "Hello " . $row->first_name . " " . $row->last_name . ",";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "Hope you are doing great..!!";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "You recently requested to reset your password for your Girlfriends' app account. click the button below to reset it.";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "admin/resetPassword/" . $this->session->userdata('temp_pass') . "/" . $tstamp . "'>Reset Your Password</a>";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "If you did not request a password reset, you can safely ignore this email. Only a person with access to your email can reset your account password.";
- $message .= "<br/>";
- $message .= "This password reset is only valid for the next 24 hours.";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "Thank you,";
- $message .= "<br/>";
- $message .= "Girlfriends' GiftBox Team";
- $this->load->library('email');
- $this->email->set_newline("\r\n");
- $this->email->set_mailtype("html");
- $this->email->from('noreply@giftbox.com', 'GiftBox');
- $this->email->to($row->email);
- $this->email->subject('Forgot Password Link');
- $this->email->message($message);
- if ($this->email->send()) {
- $this->db->where('id', $row->id);
- //$updatep = $this->db->update('user', array('temp_pass' => $this->session->userdata('temp_pass_ses'), "tstamp" => $tstamp));
- $updatep = $this->db->update('user', array('temp_pass' => $this->session->userdata('temp_pass'), "tstamp" => $tstamp));
- if ($updatep) {
- $msg = "Please check your email.";
- return array('msg' => $msg, 'resp' => 'success');
- }
- } else {
- $msg = "Email does not send.";
- return array('msg' => $msg, 'resp' => 'error');
- }
- } else {
- $msg = "Email does not found";
- return array('msg' => $msg, 'resp' => 'error');
- }
- }
- // function sendFriendRequestEmail($email = '') {
- // $user_id = $this->input->get_post('user_id', TRUE);
- // $email = $this->input->get_post('email', TRUE);
- // // $rowArr = $this->db->get_where('friends', array('email' => $this->input->get_post('email', TRUE)))->result();
- // // if (count($rowArr) > 0) {
- // // $data['status'] = "failure";
- // // $data['message'] = $this->input->get_post('email', TRUE) . " email address already exists!";
- // // $msg = $this->input->get_post('email', TRUE) . " email address already exists!";
- // // return array('msg' => $msg, 'resp' => 'success');
- // // }else{
- // $message .= "Hi !";
- // $message .="<br/>";
- // $message .="<br/>";
- // $message .= "I just downloaded a fabulous app called My Girlfriends Favorite Gifts in iOS. I created a profile of my favorite gift ideas for myself, and I want you to do the same! This way when I want to get you a gift, I'll know your favs and you'll know mine! It's fun & easy...check it out";
- // $message .="<br/>";
- // $message .="<br/>";
- // // $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "admin/reqestAccept"."'>Request Accept</a>";
- // $message .="<br/>";
- // $message .="Thank you,";
- // $message .="<br/>";
- // $message .="Regards Gf GiftBox Team";
- // $this->load->library('email');
- // $this->email->set_newline("\r\n");
- // $this->email->set_mailtype("html");
- // $this->email->from('krunal@cannydoer.com', 'GiftBox');
- // // $this->email->to($row->email);
- // $this->email->to($email);
- // $this->email->subject('Friend Request Accept');
- // $this->email->message($message);
- // if ($this->email->send()) {
- // // $this->db->where('id', $row->id);
- // // $updatep = $this->db->update('user', array('temp_pass' => $this->session->userdata('temp_pass_ses'), "tstamp" => $tstamp));
- // //return array('msg' => $msg, 'resp' => 'mail send');
- // //$login_user_id = $this->input->get_post('email', TRUE);
- // // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
- // // if(count($checkUserAndFriendsId) > 0){
- // // $data['status'] = "failure";
- // // $data['message'] = "request already send";
- // // }else{
- // $checkUserId = $this->db->get_where('user',array('id' => $user_id))->row();
- // $login_user_email = $checkUserId->email;
- // $email = $this->input->get_post('email', TRUE);
- // $insert_Array = array(
- // 'email' => $email,
- // 'user_id' => $user_id,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $insert_data = $this->db->insert('friends',$insert_Array);
- // $insert_id = $this->db->insert_id();
- // $getLastRecord = $this->db->get_where('friends',array('id' => $insert_id))->row();
- // $get_email = $getLastRecord->email;
- // $get_user_id = $getLastRecord->user_id;
- // $checkemail = $this->db->get_where('user',array('email' => $get_email))->row();
- // $get_id = $checkemail->id;
- // $get_user_email = $checkemail->email;
- // $updateArr = array(
- // 'friend_id' => $get_id,
- // );
- // $this->db->where('id',$insert_id);
- // $this->db->update('friends',$updateArr);
- // // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
- // //print_r($checkUserAndFriendsId);exit;
- // $friendsArr = array(
- // 'user_id' => $get_id,
- // 'friend_id' => $get_user_id,
- // 'email' => $login_user_email,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $this->db->insert('friends',$friendsArr);
- // $paymentData = array(
- // 'user_id' => $get_user_id,
- // 'friend_id' =>$get_id,
- // 'payment_status' => 0,
- // 'create_date' => date('Y-m-d H:i:s')
- // );
- // $insertPaymentData = $this->db->insert('payment',$paymentData);
- // // }
- // // if ($updatep) {
- // $msg = "Please check your email.";
- // return array('msg' => $msg, 'resp' => 'success');
- // // }
- // } else {
- // $msg = "Email does not send.";
- // return array('msg' => $msg, 'resp' => 'error');
- // }
- // // }
- // //}
- // // else {
- // // $msg = "Email does not found";
- // // return array('msg' => $msg, 'resp' => 'error');
- // // }
- // }
- function sendFriendRequestEmail2($postdata)
- {
- $user_id = $postdata['user_id'];
- $email = $postdata['email'];
- $rowArr = $this->db->get_where('user', array('email' => $email))->result();
- if (count($rowArr) > 0) {
- // $data['status'] = "failure";
- // $data['message'] = $this->input->get_post('email', TRUE) . " email address already exists!";
- // $msg = $this->input->get_post('email', TRUE) . " email address already exists!";
- // return array('msg' => $msg, 'resp' => 'success');
- $checkEmail = $this->db->get_where('friends', array('email' => $email))->row();
- if (count($checkEmail) > 0) {
- $getuserEmail = $this->db->get_where('user', array('email' => $email))->row();
- $getUserId = $getuserEmail->id;
- $friendsRequestCheck = $this->db->get_where('friends', array('user_id' => $user_id, 'friend_id' => $getUserId))->result();
- if (count($friendsRequestCheck) > 0) {
- //$msg = "This email address already register as friend";
- $msg = "friends is already added";
- return array('msg' => $msg, 'resp' => 'failure');
- } else {
- $checkUserId = $this->db->get_where('user', array('id' => $user_id))->row();
- $login_user_email = $checkUserId->email;
- $first_name = $checkUserId->first_name;
- $last_name = $checkUserId->last_name;
- $email = $this->input->get_post('email', TRUE);
- $insertUserData = array(
- 'email' => $email,
- );
- //$this->db->insert('user',$insertUserData);
- $insert_Array = array(
- 'email' => $email,
- 'user_id' => $user_id,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $insert_data = $this->db->insert('friends', $insert_Array);
- $insert_id = $this->db->insert_id();
- $getLastRecord = $this->db->get_where('friends', array('id' => $insert_id))->row();
- $get_email = $getLastRecord->email;
- $get_user_id = $getLastRecord->user_id;
- $checkemail = $this->db->get_where('user', array('email' => $get_email))->row();
- $get_id = $checkemail->id;
- $get_user_email = $checkemail->email;
- $get_name = $checkemail->first_name;
- $updateArr = array(
- 'friend_id' => $get_id,
- );
- $this->db->where('id', $insert_id);
- $this->db->update('friends', $updateArr);
- // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
- //print_r($checkUserAndFriendsId);exit;
- $friendsArr = array(
- 'user_id' => $get_id,
- 'friend_id' => $get_user_id,
- 'email' => $login_user_email,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->insert('friends', $friendsArr);
- $paymentData = array(
- 'user_id' => $get_user_id,
- 'friend_id' => $get_id,
- 'payment_status' => 0,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $insertPaymentData = $this->db->insert('payment', $paymentData);
- // $message = "Hi !";
- $message = "Hello " . $get_name;
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= $first_name . " " . $last_name . " " . " " . "friends request send";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "I just downloaded a fabulous app called My Girlfriends Favorite Gifts in iOS. I created a profile of my favorite gift ideas for myself, and I want you to do the same! This way when I want to get you a gift, I'll know your favs and you'll know mine! It's fun & easy...check it out.";
- $message .= "<br/>";
- $message .= "<br/>";
- //$message .= "<a href="www.facebook"</a>";
- $message .= "To get started simply download the <a href='https://itunes.apple.com'>Girl Friend Application</a>";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "webservice/reqestAccept/$get_user_id/$get_id" . "'>Request Accept</a>";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "Thank you,";
- $message .= "<br/>";
- $message .= "Regards Gf GiftBox Team";
- $this->load->library('email');
- $this->email->set_newline("\r\n");
- $this->email->set_mailtype("html");
- $this->email->from('krunal@cannydoer.com', 'GiftBox');
- // $this->email->to($row->email);
- $this->email->to($email);
- $this->email->subject('Friend Request Accept');
- $this->email->message($message);
- if ($this->email->send()) {
- // $checkUserId = $this->db->get_where('user',array('id' => $user_id))->row();
- // $login_user_email = $checkUserId->email;
- // $email = $this->input->get_post('email', TRUE);
- // $insertUserData = array(
- // 'email' => $email,
- // );
- // //$this->db->insert('user',$insertUserData);
- // $insert_Array = array(
- // 'email' => $email,
- // 'user_id' => $user_id,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $insert_data = $this->db->insert('friends',$insert_Array);
- // $insert_id = $this->db->insert_id();
- // $getLastRecord = $this->db->get_where('friends',array('id' => $insert_id))->row();
- // $get_email = $getLastRecord->email;
- // $get_user_id = $getLastRecord->user_id;
- // $checkemail = $this->db->get_where('user',array('email' => $get_email))->row();
- // $get_id = $checkemail->id;
- // $get_user_email = $checkemail->email;
- // $updateArr = array(
- // 'friend_id' => $get_id,
- // );
- // $this->db->where('id',$insert_id);
- // $this->db->update('friends',$updateArr);
- // // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
- // //print_r($checkUserAndFriendsId);exit;
- // $friendsArr = array(
- // 'user_id' => $get_id,
- // 'friend_id' => $get_user_id,
- // 'email' => $login_user_email,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $this->db->insert('friends',$friendsArr);
- // $paymentData = array(
- // 'user_id' => $get_user_id,
- // 'friend_id' =>$get_id,
- // 'payment_status' => 0,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $insertPaymentData = $this->db->insert('payment',$paymentData);
- // }
- // if ($updatep) {
- $msg = "Please check your email.";
- return array('msg' => $msg, 'resp' => 'success');
- // }
- } else {
- $msg = "Email does not send.";
- return array('msg' => $msg, 'resp' => 'error');
- }
- }
- } else {
- $checkUserId = $this->db->get_where('user', array('id' => $user_id))->row();
- $login_user_email = $checkUserId->email;
- $first_name = $checkUserId->first_name;
- $last_name = $checkUserId->last_name;
- $email = $this->input->get_post('email', TRUE);
- $insertUserData = array(
- 'email' => $email,
- );
- //$this->db->insert('user',$insertUserData);
- $insert_Array = array(
- 'email' => $email,
- 'user_id' => $user_id,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $insert_data = $this->db->insert('friends', $insert_Array);
- $insert_id = $this->db->insert_id();
- $getLastRecord = $this->db->get_where('friends', array('id' => $insert_id))->row();
- $get_email = $getLastRecord->email;
- $get_user_id = $getLastRecord->user_id;
- $checkemail = $this->db->get_where('user', array('email' => $get_email))->row();
- $get_id = $checkemail->id;
- $get_user_email = $checkemail->email;
- $get_name = $checkemail->first_name;
- $updateArr = array(
- 'friend_id' => $get_id,
- );
- $this->db->where('id', $insert_id);
- $this->db->update('friends', $updateArr);
- // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
- //print_r($checkUserAndFriendsId);exit;
- $friendsArr = array(
- 'user_id' => $get_id,
- 'friend_id' => $get_user_id,
- 'email' => $login_user_email,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->insert('friends', $friendsArr);
- $paymentData = array(
- 'user_id' => $get_user_id,
- 'friend_id' => $get_id,
- 'payment_status' => 0,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $insertPaymentData = $this->db->insert('payment', $paymentData);
- // $message = "Hi !";
- $message = "Hello " . $get_name;
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= $first_name . " " . $last_name . " " . " " . "friends request send";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "I just downloaded a fabulous app called My Girlfriends Favorite Gifts in iOS. I created a profile of my favorite gift ideas for myself, and I want you to do the same! This way when I want to get you a gift, I'll know your favs and you'll know mine! It's fun & easy...check it out.";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "To get started simply download the <a href='https://itunes.apple.com'>Girl Friend Application</a>";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "webservice/reqestAccept/$get_user_id/$get_id" . "'>Request Accept</a>";
- // $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "admin/reqestAccept"."'>Request Accept</a>";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "Thank you,";
- $message .= "<br/>";
- $message .= "Regards Gf GiftBox Team";
- $this->load->library('email');
- $this->email->set_newline("\r\n");
- $this->email->set_mailtype("html");
- $this->email->from('krunal@cannydoer.com', 'GiftBox');
- // $this->email->to($row->email);
- $this->email->to($email);
- $this->email->subject('Friend Request Accept');
- $this->email->message($message);
- if ($this->email->send()) {
- // $this->db->where('id', $row->id);
- // $updatep = $this->db->update('user', array('temp_pass' => $this->session->userdata('temp_pass_ses'), "tstamp" => $tstamp));
- //return array('msg' => $msg, 'resp' => 'mail send');
- //$login_user_id = $this->input->get_post('email', TRUE);
- // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
- // if(count($checkUserAndFriendsId) > 0){
- // $data['status'] = "failure";
- // $data['message'] = "request already send";
- // }else{
- // $checkUserId = $this->db->get_where('user',array('id' => $user_id))->row();
- // $login_user_email = $checkUserId->email;
- // $email = $this->input->get_post('email', TRUE);
- // $insertUserData = array(
- // 'email' => $email,
- // );
- // //$this->db->insert('user',$insertUserData);
- // $insert_Array = array(
- // 'email' => $email,
- // 'user_id' => $user_id,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $insert_data = $this->db->insert('friends',$insert_Array);
- // $insert_id = $this->db->insert_id();
- // $getLastRecord = $this->db->get_where('friends',array('id' => $insert_id))->row();
- // $get_email = $getLastRecord->email;
- // $get_user_id = $getLastRecord->user_id;
- // $checkemail = $this->db->get_where('user',array('email' => $get_email))->row();
- // $get_id = $checkemail->id;
- // $get_user_email = $checkemail->email;
- // $updateArr = array(
- // 'friend_id' => $get_id,
- // );
- // $this->db->where('id',$insert_id);
- // $this->db->update('friends',$updateArr);
- // // $checkUserAndFriendsId = $this->db->get_where('friends',array('friend_id' => $get_user_id,'user_id' => $get_id))->result();
- // //print_r($checkUserAndFriendsId);exit;
- // $friendsArr = array(
- // 'user_id' => $get_id,
- // 'friend_id' => $get_user_id,
- // 'email' => $login_user_email,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $this->db->insert('friends',$friendsArr);
- // $paymentData = array(
- // 'user_id' => $get_user_id,
- // 'friend_id' =>$get_id,
- // 'payment_status' => 0,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $insertPaymentData = $this->db->insert('payment',$paymentData);
- // }
- // if ($updatep) {
- $msg = "Please check your email.";
- return array('msg' => $msg, 'resp' => 'success');
- // }
- } else {
- $msg = "Email does not send.";
- return array('msg' => $msg, 'resp' => 'error');
- }
- }
- } else {
- //$msg = $this->input->get_post('email', TRUE) . " email address already exists!";
- $msg = "Mail not found";
- return array('msg' => $msg, 'resp' => 'failure');
- }
- }
- function sendFriendRequestEmail($postdata)
- {
- $user_id = $postdata['user_id'];
- $email = $postdata['email'];
- $rowArr = $this->db->get_where('user', array('email' => $email))->row();
- $id = $rowArr->id;
- $resultArr = $this->db->get_where('friends', array('user_id' => $user_id, 'friend_id' => $id, 'user_id' => $id, 'friend_id' => $user_id))->row();
- if (count($resultArr) > 0) {
- $msg = "freinds is already added";
- return array('msg' => $msg, 'resp' => 'success');
- } else {
- $user_id = $this->input->get_post('user_id', TRUE);
- $email = $this->input->get_post('email', TRUE);
- $checkEmailArr = $this->db->get_where('user', array('email' => $email))->row();
- if (count($checkEmailArr) > 0) {
- //echo "if";
- $rowuserArr = $this->db->get_where('user', array('email' => $email))->row();
- $name = $rowuserArr->first_name;
- $first_name = ucfirst($name);
- $friend_id = $rowuserArr->id;
- $friend_email = $rowuserArr->email;
- $resultuserArr = $this->db->get_where('user', array('id' => $user_id))->row();
- $user_id = $resultuserArr->id;
- $user_email = $resultuserArr->email;
- $sender_name = $resultuserArr->first_name;
- $username = ucfirst($sender_name);
- $message = "Hello " . $first_name . ",";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= $username . " " . $resultuserArr->last_name . " " . "has sent a friend request";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "I just downloaded a fabulous app called My Girlfriends' Favorite Gifts in iOS. I created a profile of my favorite gift ideas for myself, and I want you to do the same! This way when I want to get you a gift, I'll know your favs and you'll know mine! It's fun & easy...check it out.";
- $message .= "<br/>";
- $message .= "<br/>";
- //$message .= "<a href="www.facebook"</a>";
- $message .= "To get started simply download <a href='https://itunes.apple.com/us/app/my-girl-friends-favourite-gift/id1270615255?ls=1&mt=8'>My Girlfriends' Favorite Gifts application</a>";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "index.php/webservice/reqestAccept/$user_id/$friend_id" . "'>Request Accept</a>";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "Thank you,";
- $message .= "<br/>";
- $message .= "Regards Gf Gift Team";
- // $config = Array(
- // 'protocol' => 'smtp',
- // 'smtp_host' => 'ssl://smtp.googlemail.com',
- // 'smtp_port' => '587',
- // 'smtp_user' => 'akshay@vnnovate.com',
- // 'smtp_pass' => 'akshay@123',
- // 'mailtype' => 'html',
- // 'charset' => 'iso-8859-1',
- // 'wordwrap' => true
- // );
- $this->load->library('email');
- $this->email->initialize();
- $this->email->set_newline("\r\n");
- $this->email->set_mailtype("html");
- $this->email->from('noreply@giftbox.com', 'GiftBox');
- // $this->email->to($row->email);
- $this->email->to($email);
- $this->email->subject('Friend Request Accept');
- $this->email->message($message);
- // $this->email->send();
- // echo $this->email->print_debugger();exit;
- if ($this->email->send()) {
- // echo $this->email->print_debugger();exit;
- // $to = $email;
- // $subject = 'Friend Request Accept';
- // $headers = 'From: webmaster@example.com' . "\r\n" .
- // 'Reply-To: webmaster@example.com' . "\r\n" .
- // 'X-Mailer: PHP/' . phpversion();
- // $mail = mail($to, $subject, $message, $headers);
- // if($mail){
- //insert the user data in freind table
- $UserData = array(
- 'user_id' => $user_id,
- 'friend_id' => $friend_id,
- 'email' => $friend_email,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->insert('friends', $UserData);
- //end
- //insert freinds data in friend table
- $FriendData = array(
- 'user_id' => $friend_id,
- 'friend_id' => $user_id,
- 'email' => $user_email,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->insert('friends', $FriendData);
- //end
- //payment data insert in payment table
- $paymentData = array(
- 'user_id' => $user_id,
- 'friend_id' => $friend_id,
- 'payment_status' => 0,
- 'created_date' => date('Y-m-d H:i:s')
- );
- $this->db->insert('payment', $paymentData);
- //end
- $msg = "send a mail freind's email id.";
- return array('msg' => $msg, 'resp' => 'success');
- } else {
- $msg = "Email does not send.";
- return array('msg' => $msg, 'resp' => 'error');
- }
- } else {
- $user_id = $this->input->get_post('user_id', TRUE);
- $email = $this->input->get_post('email', TRUE);
- $resultuserArr = $this->db->get_where('user', array('id' => $user_id))->row();
- $from_email = $resultuserArr->email;
- $insertEmailId = array(
- 'from_email' => $from_email,
- 'from_id' => $user_id,
- 'to_email' => $email
- );
- $insertEmail = $this->db->insert('friend_invites', $insertEmailId);
- $insert_id = $this->db->insert_id();
- // $rowuserArr = $this->db->get_where('friend_invites', array('email' => $email))->row();
- // $friend_id = $rowuserArr->id;
- $resultuserArr = $this->db->get_where('user', array('id' => $user_id))->row();
- $userEmail = $resultuserArr->email;
- $user_id = $resultuserArr->id;
- $first_name = $resultuserArr->first_name;
- $name = ucfirst($first_name);
- $message = "Hello Friend,";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= $name . " " . $resultuserArr->last_name . " " . "has sent a friend request";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "I just downloaded a fabulous app called My Girlfriends' Favorite Gifts in iOS. I created a profile of my favorite gift ideas for myself, and I want you to do the same! This way when I want to get you a gift, I'll know your favs and you'll know mine! It's fun & easy...check it out.";
- $message .= "<br/>";
- $message .= "<br/>";
- //$message .= "<a href="www.facebook"</a>";
- $message .= "To get started simply download <a href='https://itunes.apple.com/us/app/my-girl-friends-favourite-gift/id1270615255?ls=1&mt=8'>My Girlfriends' Favorite Gifts application</a>";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "<a style='background-color: #ed6b75;border-color: #ea5460;color: #fff;border-radius:5px;cursor:pointer;padding:6px 12px;text-align:center;font-size:15px;text-decoration:none;font-weight:bold;' href='" . base_url() . "index.php/webservice/reqestAccept/$user_id/$insert_id" . "'>Accept Request</a>";
- $message .= "<br/>";
- $message .= "<br/>";
- $message .= "Thank you";
- $message .= "<br/>";
- $message .= "Regards Gf Gift Team";
- // $config = Array(
- // 'protocol' => 'smtp',
- // 'smtp_host' => 'ssl://smtp.googlemail.com',
- // 'smtp_port' => '465',
- // 'smtp_user' => 'akshay@vnnovate.com',
- // 'smtp_pass' => 'akshay@123',
- // 'mailtype' => 'html',
- // 'charset' => 'iso-8859-1',
- // 'wordwrap' => true
- // );
- $this->load->library('email');
- $this->email->initialize();
- $this->email->set_newline("\r\n");
- $this->email->set_mailtype("html");
- $this->email->from('noreply@giftbox.com', 'GiftBox');
- // $this->email->to($row->email);
- $this->email->to($email);
- $this->email->subject('Friend Request Accept');
- $this->email->message($message);
- // $this->email->send();
- // echo $this->email->print_debugger();exit;
- if ($this->email->send()) {
- // echo $this->email->print_debugger();exit;
- // $to = $email;
- // $subject = 'Friend Request Accept';
- // $headers = 'From: webmaster@example.com' . "\r\n" .
- // 'Reply-To: webmaster@example.com' . "\r\n" .
- // 'X-Mailer: PHP/' . phpversion();
- // $mail = mail($to, $subject, $message, $headers);
- // if ($mail) {
- //fetch last inserted record in user table
- $getLastRecord = $this->db->get_where('friend_invites', array('id' => $insert_id))->row();
- $frined_email = $getLastRecord->email;
- $frined_id = $getLastRecord->id;
- //end
- //insert the user data in freind table
- // $UserData = array(
- // 'user_id' => $user_id,
- // 'friend_id' => $frined_id,
- // 'email' => $frined_email,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $this->db->insert('friends',$UserData);
- //end
- //insert freinds data in friend table
- // $FriendData = array(
- // 'user_id' => $frined_id,
- // 'friend_id' => $user_id,
- // 'email' => $userEmail,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $this->db->insert('friends',$FriendData);
- //end
- //payment data insert in payment table
- // $paymentData = array(
- // 'user_id' => $user_id,
- // 'friend_id' => $frined_id,
- // 'payment_status' => 0,
- // 'created_date' => date('Y-m-d H:i:s')
- // );
- // $this->db->insert('payment',$paymentData);
- //end
- $msg = "send a mail freind's email id.";
- return array('msg' => $msg, 'resp' => 'success');
- } else {
- $msg = "Mail Does Not Send.";
- return array('msg' => $msg, 'resp' => 'failure');
- }
- }
- }
- }
- public function reqestAccept($user_id, $friend_id)
- {
- $user_id = $this->uri->segment(3);
- $friend_id = $this->uri->segment(4);
- $frid = $this->uri->segment(5);
- //check frined id in user table
- $chechUserId = $this->db->get_where('user', array('id' => $friend_id))->row();
- $first_name = $chechUserId->first_name;
- if ($first_name == "") {
- redirect('admin/registration');
- } //end
- else {
- $checkUserFriendId = $this->db->get_where('friends', array('user_id' => $user_id, 'friend_id' => $friend_id))->row();
- //get user_id in friend table
- $get_send_user_id = $checkUserFriendId->id;
- $upate_user_array = array(
- 'status' => 1
- );
- $this->db->where('id', $get_send_user_id);
- $this->db->update('friends', $upate_user_array);
- $checkFriendsId = $this->db->get_where('friends', array('user_id' => $friend_id, 'friend_id' => $user_id))->row();
- //end
- //get friend_id in friend table
- $get_user_friend_id = $checkFriendsId->id;
- $update_friends_array = array(
- 'status' => 1
- );
- $this->db->where('id', $get_user_friend_id);
- $this->db->update('friends', $update_friends_array);
- //end
- redirect('webservice/itunesPage');
- }
- }
- public function itunesPage()
- {
- $myurl = "https://itunes.apple.com/us/app/my-girl-friends-favourite-gift/id1270615255?ls=1&mt=8";
- redirect($myurl);
- }
- public function editTrainerProfile()
- {
- if ($this->input->get_post('trainer_id', TRUE)) {
- $trainer_id = "";
- $first_name = "";
- $last_name = "";
- $business_name = "";
- $gender = "";
- $dob = "";
- $email = "";
- $credit_card = "";
- $credit_card_exp = "";
- $credit_card_csv = "";
- $password = "";
- if ($this->input->get_post('trainer_id', TRUE)) {
- $trainer_id = $this->input->get_post('trainer_id', TRUE);
- }
- if ($this->input->get_post('first_name', TRUE)) {
- $first_name = $this->input->get_post('first_name', TRUE);
- }
- if ($this->input->get_post('last_name', TRUE)) {
- $last_name = $this->input->get_post('last_name', TRUE);
- }
- if ($this->input->get_post('business_name', TRUE)) {
- $business_name = $this->input->get_post('business_name', TRUE);
- }
- if ($this->input->get_post('gender', TRUE)) {
- $gender = $this->input->get_post('gender', TRUE);
- }
- if ($this->input->get_post('dob', TRUE)) {
- $dob = $this->input->get_post('dob', TRUE);
- }
- if ($this->input->get_post('email', TRUE)) {
- $email = $this->input->get_post('email', TRUE);
- }
- if ($this->input->get_post('credit_card', TRUE)) {
- $credit_card = $this->input->get_post('credit_card', TRUE);
- }
- if ($this->input->get_post('credit_card_exp', TRUE)) {
- $credit_card_exp = $this->input->get_post('credit_card_exp', TRUE);
- }
- if ($this->input->get_post('credit_card_csv', TRUE)) {
- $credit_card_csv = $this->input->get_post('credit_card_csv', TRUE);
- }
- $password = base64_encode($this->input->get_post('password', TRUE));
- $updArr = array(
- 'first_name' => $first_name,
- 'last_name' => $last_name,
- 'business_name' => $business_name,
- 'gender' => $gender,
- 'dob' => $dob,
- 'email' => $email,
- 'password' => $password,
- 'credit_card' => $credit_card,
- 'credit_card_exp' => $credit_card_exp,
- 'credit_card_csv' => $credit_card_csv
- );
- $this->db->where('id', $trainer_id);
- if ($this->db->update('trainer', $updArr)) {
- $data['status'] = "success";
- $data['message'] = "Trainer Profile updated successfully.";
- } else {
- $data['status'] = "failure";
- $data['message'] = "Trainer Profile not updated.";
- }
- } else {
- $data['status'] = "failure";
- $data['message'] = "Please enter trainer id";
- }
- return $data;
- }
- public function normaliseArray($arr, $recurse = True)
- {
- if (!is_array($arr))
- return $arr;
- if (count(array_filter(array_keys($arr), 'is_numeric')) == count($arr))
- $arr = array_values($arr);
- if ($recurse) {
- foreach ($arr as $k => $a) {
- $arr[$k] = $this->normaliseArray($a, $recurse);
- }
- }
- return $arr;
- }
- }
Add Comment
Please, Sign In to add comment