function brand_create($user_id = 0, $brand_name = NULL) { try { return $this->pdb->insert("bom_brand", array("brand_name" => $brand_name, "user_id" => $user_id, "created_on" => current_date_time(), "updated_on" => current_date_time())); } catch (PDOException $e) { return false; } }
function relation_create($user_id = 0, $user_id_from_contact = 0, $relation_type = NULL, $group_id = NULL) { try { return $this->pdb->insert("bom_user_relation", array("parent_id" => $user_id, "child_id" => $user_id_from_contact, "relation_type" => $relation_type, "group_id" => $group_id, "created_on" => current_date_time(), "updated_on" => current_date_time())); } catch (PDOException $e) { $e->getMessage(); return false; } }
function otp_verify($user_id = NULL, $passcode = NULL) { $current_date_time = current_date_time(); $otp_match_cond = "user_id='{$user_id}' AND otp='{$passcode}'"; $otp_match = $this->pdb->singleVal("bom_users", $otp_match_cond, "user_id"); if (!$otp_match) { return "Please enter correct One time password."; } $otp_expire_check_cond = "user_id='{$user_id}' AND otp_expire_time<='{$current_date_time}'"; $otp_expire_check = $this->pdb->singleval("bom_users", $otp_expire_check_cond, 'user_id'); if ($otp_expire_check) { return "One time password expired, please press resend otp and verify."; } else { $this->pdb->update("bom_users", array("is_otp_verified" => 1, "status" => 1), "user_id='{$user_id}'"); return 1; } }
public function sign_up_post() { $key_empty = ''; $user = []; $user_detail = []; $brandimage = ''; $companyimage = ''; if (empty($this->post('usertype'))) { $key_empty = 'usertype'; } if (empty($this->post('displayname'))) { $key_empty = 'displayname'; } if (empty($this->post('companyname'))) { $key_empty = 'companyname'; } if (empty($this->post('emailid'))) { if (empty($this->post('socialid'))) { $key_empty = 'socialid'; } else { if (empty($this->post('socialtype'))) { $key_empty = 'socialtype'; } } } else { if (!is_email_format($this->post('emailid'))) { $this->response(['status' => FALSE, 'message' => 'Email Id not valid', 'code' => REST_Controller::HTTP_BAD_REQUEST], REST_Controller::HTTP_OK); // NOT_FOUND (404) being the HTTP response code } else { if (!empty($this->user->is_email_exist($this->post('emailid')))) { $this->response(['status' => FALSE, 'message' => 'Email Id already exists', 'code' => REST_Controller::HTTP_BAD_REQUEST], REST_Controller::HTTP_OK); // NOT_FOUND (404) being the HTTP response code } } } if (empty($this->post('country'))) { $key_empty = 'country'; } if (empty($this->post('state'))) { $key_empty = 'state'; } if (empty($this->post('city'))) { $key_empty = 'city'; } if (empty($this->post('mobile'))) { $key_empty = 'mobile'; } if (empty($this->post('socialid'))) { if (empty($this->post('password'))) { $key_empty = 'password'; } } if (empty($_FILES['brandimage']['name'])) { //$key_empty = 'brandimage'; } if (empty($_FILES['companyimage']['name'])) { //$key_empty = 'companyimage'; } if (empty($this->post('devicetype'))) { $key_empty = 'devicetype'; } if (empty($this->post('deviceid'))) { //$key_empty = 'deviceid'; } if (!empty($key_empty)) { // Set the response and exit $this->response(['status' => FALSE, 'message' => $key_empty . ' not found', 'code' => REST_Controller::HTTP_BAD_REQUEST], REST_Controller::HTTP_OK); // NOT_FOUND (404) being the HTTP response code } $config = array('upload_path' => "./assets/uploads/", 'allowed_types' => "gif|jpg|png|jpeg", 'overwrite' => TRUE, 'max_size' => "2048000", 'max_height' => "768", 'max_width' => "1024"); // if(!$this->upload->do_upload('brandimage')) // { // $this->response([ // 'status' => FALSE, // 'message' => 'Could not create user at this time', // 'code' =>REST_Controller::HTTP_INTERNAL_SERVER_ERROR // ], REST_Controller::HTTP_OK); // INTERNAL_SERVER_ERROR (500) being the HTTP response code // // }else{ // echo 'errr'; // echo $this->upload->display_errors();die(); // $brandimage = $this->upload->data('orig_name'); // } // if(!$this->upload->do_upload('companyimage')) // { // $this->response([ // 'status' => FALSE, // 'message' => 'Could not create user at this time', // 'code' =>REST_Controller::HTTP_INTERNAL_SERVER_ERROR // ], REST_Controller::HTTP_OK); // INTERNAL_SERVER_ERROR (500) being the HTTP response code // // }else{ // echo $this->upload->display_errors();die(); // $companyimage = $this->upload->data('orig_name'); // } //$otp = otp_generate(); $otp = 12345; $user = array('user_type' => $this->post('usertype'), 'login_email' => $this->post('emailid'), 'password' => encrypt_text($this->post('password')), 'social_type' => $this->post('socialtype'), 'social_id' => $this->post('socialid'), 'social_id' => $this->post('socialid'), 'otp' => $otp, 'otp_expire_time' => otp_expire(), 'device_id' => $this->post('deviceid'), 'device_type' => $this->post('devicetype'), 'created_on' => current_date_time(), 'updated_on' => current_date_time()); $user_id = $this->user->sign_up_user($user); if (empty($user_id)) { $this->response(['status' => FALSE, 'message' => 'Could not create user at this time', 'code' => REST_Controller::HTTP_INTERNAL_SERVER_ERROR], REST_Controller::HTTP_OK); // INTERNAL_SERVER_ERROR (500) being the HTTP response code } $user_detail_table = $this->post('usertype') == 'm' ? 'bom_manufacturers' : ($this->post('usertype') == 'v' ? 'bom_vendors' : 'bom_customers'); $user_detail_prefix = $this->post('usertype') == 'm' ? 'manu' : ($this->post('usertype') == 'v' ? 'vndr' : 'cstmr'); $user_detail = array('user_id' => $user_id, $user_detail_prefix . '_brand_logo' => $brandimage, $user_detail_prefix . '_company_photo' => $companyimage, $user_detail_prefix . '_display_name' => $this->post('displayname'), $user_detail_prefix . '_company_name' => $this->post('companyname'), $user_detail_prefix . '_email_id' => $this->post('emailid'), $user_detail_prefix . '_country' => $this->post('country'), $user_detail_prefix . '_state' => $this->post('state'), $user_detail_prefix . '_city' => $this->post('city'), $user_detail_prefix . '_contact_number' => $this->post('mobile')); $user_detail_id = $this->user->sign_up_user_detail($user_detail_table, $user_detail); if (empty($user_detail_id)) { $this->response(['status' => FALSE, 'message' => 'Could not create user at this time', 'code' => REST_Controller::HTTP_INTERNAL_SERVER_ERROR], REST_Controller::HTTP_OK); // INTERNAL_SERVER_ERROR (500) being the HTTP response code } else { //send_otp(); $this->response(['brandimage' => UPLOAD_URL . $brandimage, 'companyimage' => UPLOAD_URL . $companyimage, 'status' => TRUE, 'userid' => $user_id, 'code' => REST_Controller::HTTP_CREATED], REST_Controller::HTTP_OK); // CREATED (201) being the HTTP response code } //add commit and rollback code }
private function update_time_login($table, $id) { return $this->db->update($table, array('last_login' => current_date_time()), 'id=' . $id); }
public function update_user($id) { $values = array('username' => $_POST['username'], 'password' => md5($_POST['password']), 'im_type' => $_POST['im_type'], 'im_id' => $_POST['im_id'], 'user_active' => $_POST['user_active'], 'im_active' => $_POST['im_active'], 'last_update' => current_date_time()); return $this->db->update($this->db_table, $values, 'id=' . $id); }
public function update($id) { $values = array('site_name' => $_POST['site_name'], 'site_author' => $_POST['site_author'], 'email_forwarder' => $_POST['email_forwarder'], 'site_slogan' => $_POST['site_slogan'], 'site_footer' => $_POST['site_footer'], 'site_meta_desc' => $_POST['site_meta_desc'], 'site_meta_key' => $_POST['site_meta_key'], 'site_status' => $_POST['site_status'], 'offline_message' => $_POST['offline_message'], 'date_updated' => current_date_time()); return $this->db->update($this->db_table, $values, 'id=' . $id); }