Example #1
0
 public function verify_email()
 {
     //Setting up validation rules for form inputs
     $this->validation_rules = array(array('field' => 'username', 'label' => 'username', 'rules' => 'required|callback_validate_hoteluser', 'class' => 'text-danger'));
     $this->form_validation->set_error_delimiters('<div class="bg-danger">', '</div>');
     $this->form_validation->set_rules($this->validation_rules);
     $this->form_validation->set_message('validate_hoteluser', 'Hotel User with this username is not exist.');
     //$this->form_validation->set_message('valid_email','Please Enter Valid Email.');
     if ($this->form_validation->run() == FALSE) {
         $this->data['action'] = "/login/verify_user";
         $this->template->load('login_tpl', 'recovery_vw', $this->data);
     } else {
         //Get User Id From Email
         $user_info = $this->User_model->get_user_by_name($this->input->post('username'));
         $user_id = $user_info[0]['sb_hotel_user_id'];
         $hotelusername = $user_info[0]['sb_hotel_username'];
         $password = randomPassword();
         $hotel_user_data = array();
         $hotel_user_data['sb_hotel_userpasswd'] = createHashAndSalt($password);
         $result = $this->Hotel_model->edit_hotel_user($hotel_user_data, $user_id);
         $data = array();
         $data['password'] = $password;
         $data['hotelusername'] = $hotelusername;
         $message = $this->load->view('email/forgotpassword', $data, TRUE);
         sendMail('*****@*****.**', $user_info[0]['sb_hotel_useremail'], "Forgot Password", $message);
         $this->session->set_flashdata('SuccMsg', SUC_MSG_LEVEL_2);
         redirect('admin/login');
     }
 }
 public function change_password()
 {
     $old_password = $this->input->post('old_password');
     $new_password = $this->input->post('new_password');
     $arr = array();
     $arr['sb_hotel_user_id'] = $this->session->userdata('logged_in_user')->sb_hotel_user_id;
     //print_r($arr);
     $password = $this->changepassword_model->check_user($arr);
     //print_r($password);
     if (verifyPasswordHash($old_password, $password[0]['sb_hotel_userpasswd']) == TRUE) {
         $arr1['sb_hotel_userpasswd'] = createHashAndSalt($new_password);
         $user_info1 = $this->changepassword_model->update_user($arr1, $arr);
         $this->session->set_flashdata('change_success', PASSWORD_CHANGE_SUCCESS);
     } else {
         $this->session->set_flashdata('change_fail', PASSWORD_CHANGE_FAIL);
     }
     redirect('admin/changePassword');
 }
 function create_hotel_admin_user()
 {
     $data = $this->input->post();
     //Verify Hotel Data
     $this->validation_rules = array(array('field' => 'sb_hotel_username', 'label' => 'Hotel User', 'rules' => 'required|callback_validate_hoteluser', 'class' => 'text-danger'), array('field' => 'sb_hotel_useremail', 'label' => 'Hotel User Email', 'rules' => 'required|valid_email|callback_validate_hoteluseremail', 'class' => 'text-danger'), array('field' => 'sb_hotel_user_shift_from', 'label' => 'Hotel User Shift From', 'rules' => 'required', 'class' => 'text-danger'), array('field' => 'sb_hotel_user_shift_to', 'label' => 'Hotel User Shift To', 'rules' => 'required', 'class' => 'text-danger'));
     $this->form_validation->set_error_delimiters('<div class="text-danger">', '</div>');
     $this->form_validation->set_rules($this->validation_rules);
     $this->form_validation->set_message('validate_hoteluser', 'Hotel User with this name is already Exists.');
     $this->form_validation->set_message('validate_hoteluseremail', 'Hotel User with this email is already Exists.');
     $this->form_validation->set_message('valid_email', 'Please Enter Valid Email.');
     if ($this->form_validation->run() == FALSE) {
         $this->data['action'] = "admin/user/create_hotel_admin_user";
         $this->data['hotelusertypes'] = getAvailableHotelUserTypes();
         $this->data['hotellist'] = getAllHotels();
         if (($key = array_search('u', $this->data['hotelusertypes'])) !== false) {
             unset($this->data['hotelusertypes'][$key]);
         }
         if (($key = array_search('s', $this->data['hotelusertypes'])) !== false) {
             unset($this->data['hotelusertypes'][$key]);
         }
         if (($key = array_search('m', $this->data['hotelusertypes'])) !== false) {
             unset($this->data['hotelusertypes'][$key]);
         }
         $this->template->load('create_hotel_tpl', 'create_hotel_admin_user', $this->data);
     } else {
         $data["sb_hotel_user_pic"] = "";
         if (!empty($_FILES['sb_hotel_user_pic']['name'])) {
             $folderName = HOTEL_USER_PIC;
             $pic1 = upload_image($folderName, "sb_hotel_user_pic");
             if ($pic1 != 0) {
                 $data["sb_hotel_user_pic"] = $pic1;
             }
         }
         $data['sb_hotel_user_status'] = '0';
         if (isset($data['sb_hotel_user_status'])) {
             $data['sb_hotel_user_status'] = '1';
         }
         $hotelname = $this->Hotel_model->get_hotel_name($data['sb_hotel_id']);
         $password = $hotelname[0]['sb_hotel_name'];
         $password = str_replace(' ', '', $password);
         $data['sb_hotel_userpasswd'] = createHashAndSalt($password);
         $data['sb_hotel_user_shift_from'] = date("H:i:s", strtotime($data['sb_hotel_user_shift_from']));
         $data['sb_hotel_user_shift_to'] = date("H:i:s", strtotime($data['sb_hotel_user_shift_to']));
         $result = $this->Hotel_model->create_hotel_admin($data);
         $hotelusername = $data['sb_hotel_username'];
         $message = "Hi ,\n\t\t\t\t\t\t\tCongratulations Your administrator account is created on sebastian.\n\t\t\t\t\t\t\tAccount Details are\n\t\t\t\t\t\t\tUser Name =  {$hotelusername}\n\t\t\t\t\t\t\tPassword = {$password}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tThanks\n\t\t\t\t\t\t";
         sendMail('*****@*****.**', $data[sb_hotel_useremail], "Administrator Account Creation", $message);
         if ($result == '1') {
             $this->session->set_flashdata('category_success', HOTEL_ADMIN_CREATION_SUCCESS);
             redirect('admin/user/add_hotel_admin_user');
         } else {
             $this->session->set_flashdata('category_error', 'Error in Hotel Administrator Creation.');
             redirect('admin/user/add_hotel_admin_user');
         }
     }
 }
Example #4
0
 /**
  * This function will change password
  * return type- 
  * created on - 22th July 2015;
  * updated on - 
  * created by - Akshay Patil;
  */
 public function change_password()
 {
     $sb_hotel_user_id = $this->input->post('sb_hotel_user_id');
     $sb_hotel_userpasswd = $this->input->post('old_password');
     $newpassword = $this->input->post('new_password');
     if ($sb_hotel_user_id == '' || $sb_hotel_userpasswd == '' || $newpassword == '') {
         response_fail("Input may be empty");
     } else {
         $arr = array();
         $arr['sb_hotel_user_id'] = $sb_hotel_user_id;
         $password = $this->User_model->check_user($arr);
         if (count($password) <= 0) {
             response_fail("Email is wrong");
         } else {
             if (verifyPasswordHash($sb_hotel_userpasswd, $password[0]['sb_hotel_userpasswd']) == TRUE) {
                 $arr1['sb_hotel_userpasswd'] = createHashAndSalt($newpassword);
                 $user_info1 = $this->User_model->update_user($arr1, $arr);
                 response_ok();
             } else {
                 response_fail("Something is wrong");
             }
         }
     }
 }
Example #5
0
 function create_hotel_admin_user($hotel_id)
 {
     //Verify Hotel Data
     $data = $this->input->post();
     $this->validation_rules = array(array('field' => 'sb_hotel_username', 'label' => 'Hotel User', 'rules' => 'required|callback_validate_hoteluser', 'class' => 'text-danger'), array('field' => 'sb_hotel_useremail', 'label' => 'Hotel User Email', 'rules' => 'required|callback_validate_hoteluseremail', 'class' => 'text-danger'), array('field' => 'sb_hotel_user_shift_from', 'label' => 'Hotel User Shift From', 'rules' => 'required', 'class' => 'text-danger'), array('field' => 'sb_hotel_user_shift_to', 'label' => 'Hotel User Shift To', 'rules' => 'required', 'class' => 'text-danger'));
     $this->form_validation->set_error_delimiters('<div class="text-danger">', '</div>');
     $this->form_validation->set_rules($this->validation_rules);
     $this->form_validation->set_message('validate_hoteluser', 'Hotel User with this name is already Exists.');
     $this->form_validation->set_message('validate_hoteluseremail', 'Hotel User with this email is already Exists.');
     $this->form_validation->set_message('valid_email', 'Please Enter Valid Email.');
     if ($this->form_validation->run() == FALSE) {
         $this->data['hotel_id'] = $hotel_id;
         $result = $this->Hotel_model->get_hotel_name($hotel_id);
         if ($hotel_id == 0) {
             $this->data['hotel_name'] = "None";
         } else {
             $this->data['hotel_name'] = $result[0]['sb_hotel_name'];
         }
         $this->make_authentication_validation();
         $this->data['action'] = "admin/user/create_hotel_admin_user/" . $data['sb_hotel_id'];
         $this->template->load('page_tpl', 'create_hotel_admin_user', $this->data);
     } else {
         $this->data['hotel_id'] = $hotel_id;
         $result = $this->Hotel_model->get_hotel_name($hotel_id);
         if ($hotel_id == 0) {
             $this->data['hotel_name'] = "None";
         } else {
             $this->data['hotel_name'] = $result[0]['sb_hotel_name'];
         }
         $this->make_authentication_validation();
         $data["sb_hotel_user_pic"] = "";
         if (!empty($_FILES['sb_hotel_user_pic']['name'])) {
             $folderName = HOTEL_USER_PIC;
             $pic1 = upload_image($folderName, "sb_hotel_user_pic");
             if ($pic1 != 0) {
                 $data["sb_hotel_user_pic"] = $pic1;
             }
         }
         $data['sb_hotel_user_status'] = '0';
         if (isset($data['sb_hotel_user_status'])) {
             $data['sb_hotel_user_status'] = '1';
         }
         if (isset($data['sb_hotel_id'])) {
             $hotelname = $this->Hotel_model->get_hotel_name($data['sb_hotel_id']);
         } else {
             $hotelname = $this->Hotel_model->get_hotel_name($this->session->userdata('logged_in_user')->sb_hotel_id);
             $data['sb_hotel_id'] = $this->session->userdata('logged_in_user')->sb_hotel_id;
         }
         $password = randomPassword();
         //$password="******";
         $data['sb_hotel_userpasswd'] = createHashAndSalt($password);
         $data['sb_hotel_user_shift_from'] = date("H:i:s", strtotime($data['sb_hotel_user_shift_from']));
         $data['sb_hotel_user_shift_to'] = date("H:i:s", strtotime($data['sb_hotel_user_shift_to']));
         if (!isset($data['sb_staff_designation_id'])) {
             $data['sb_staff_designation_id'] = 0;
         }
         $hotel_user_data = array('sb_hotel_username' => $data['sb_hotel_username'], 'sb_hotel_useremail' => $data['sb_hotel_useremail'], 'sb_hotel_user_shift_from' => $data['sb_hotel_user_shift_from'], 'sb_hotel_user_shift_to' => $data['sb_hotel_user_shift_to'], 'sb_hotel_user_status' => '1', 'sb_hotel_user_type' => $data['sb_hotel_user_type'], 'sb_staff_designation_id' => $data['sb_staff_designation_id'], 'sb_hotel_user_pic' => $data['sb_hotel_user_pic'], 'sb_hotel_id' => $data['sb_hotel_id'], 'sb_hotel_userpasswd' => $data['sb_hotel_userpasswd']);
         $result = $this->Hotel_model->create_hotel_user($hotel_user_data);
         //We need to Add User Permissions & Services From HERE in db //
         if ($data['sb_hotel_user_type'] == 'u') {
             //Permissions For admins list
             $useradminpermissions = array('sb_hotel_user_id' => $result, 'sb_roleid' => '1', 'sb_user_role_status' => '1');
             $this->User_model->set_user_role($useradminpermissions);
             $user_module_array = array();
             $role_modules = $this->User_model->get_role_modules(1);
             $permarray = array();
             $i = 0;
             while ($i < count($role_modules)) {
                 array_push($permarray, $role_modules[$i]['sb_mod_id']);
                 $i++;
             }
             $count = 0;
             while ($count < count($permarray)) {
                 $singlearray = array('sb_hotel_user_id' => $result, 'sb_mod_id' => $permarray[$count], 'sb_user_mod_val' => '1');
                 array_push($user_module_array, $singlearray);
                 $count++;
             }
             $this->User_model->set_user_permissions($user_module_array);
         }
         if ($data['sb_hotel_user_type'] == 'a') {
             //Permissions For admins list
             $useradminpermissions = array('sb_hotel_user_id' => $result, 'sb_roleid' => '2', 'sb_user_role_status' => '1');
             $this->User_model->set_user_role($useradminpermissions);
             $user_module_array = array();
             $role_modules = $this->User_model->get_role_modules(2);
             $permarray = array();
             $i = 0;
             while ($i < count($role_modules)) {
                 array_push($permarray, $role_modules[$i]['sb_mod_id']);
                 $i++;
             }
             $count = 0;
             while ($count < count($permarray)) {
                 $singlearray = array('sb_hotel_user_id' => $result, 'sb_mod_id' => $permarray[$count], 'sb_user_mod_val' => '1');
                 array_push($user_module_array, $singlearray);
                 $count++;
             }
             $this->User_model->set_user_permissions($user_module_array);
         }
         if ($data['sb_hotel_user_type'] == 'm') {
             //Permissions For admins list
             $useradminpermissions = array('sb_hotel_user_id' => $result, 'sb_roleid' => '3', 'sb_user_role_status' => '1');
             $this->User_model->set_user_role($useradminpermissions);
             $user_module_array = array();
             $role_modules = $this->User_model->get_role_modules(3);
             $permarray = array();
             $i = 0;
             while ($i < count($role_modules)) {
                 array_push($permarray, $role_modules[$i]['sb_mod_id']);
                 $i++;
             }
             $count = 0;
             while ($count < count($permarray)) {
                 $singlearray = array('sb_hotel_user_id' => $result, 'sb_mod_id' => $permarray[$count], 'sb_user_mod_val' => '1');
                 array_push($user_module_array, $singlearray);
                 $count++;
             }
             $this->User_model->set_user_permissions($user_module_array);
             //Get all child Services of particular parent service and of particular hotel
             $child_services = $this->Services_model->get_hotel_child_services_by_parent_service($data['sb_hotel_id'], $data['sb_parent_service_id']);
             $i = 0;
             $insert_user_services = array();
             while ($i < count($child_services)) {
                 $singlearray = array('sb_hotel_service_map_id' => $child_services[$i]['sb_hotel_service_map_id'], 'sb_hotel_user_id' => $result, 'sb_parent_service_id' => $child_services[$i]['sb_parent_service_id'], 'sb_service_rel_status' => '1');
                 array_push($insert_user_services, $singlearray);
                 $i++;
             }
             $this->Services_model->set_services($insert_user_services, $result);
         }
         if ($data['sb_hotel_user_type'] == 's') {
             if (!isset($data['sb_child_service_id'])) {
                 $data['sb_child_service_id'] = '0';
             }
             //$child_services=$this->Services_model->get_hotel_child_service_map_id($data['sb_hotel_id'],$data['sb_parent_service_id'],$data['sb_child_service_id']);
             $child_services = $this->Services_model->get_hotel_child_services_by_parent_service($data['sb_hotel_id'], $data['sb_parent_service_id']);
             $i = 0;
             $insert_user_services = array();
             while ($i < count($child_services)) {
                 $singlearray = array('sb_hotel_service_map_id' => $child_services[$i]['sb_hotel_service_map_id'], 'sb_hotel_user_id' => $result, 'sb_parent_service_id' => $child_services[$i]['sb_parent_service_id'], 'sb_service_rel_status' => '1');
                 array_push($insert_user_services, $singlearray);
                 $i++;
             }
             $this->Services_model->set_services($insert_user_services, $result);
         }
         $hotelusername = $data['sb_hotel_username'];
         $data['password'] = $password;
         $data['hotelusername'] = $hotelusername;
         if ($data['sb_hotel_user_type'] == 's') {
             $message = $this->load->view('email/staffaccountcreation', $data, TRUE);
         } else {
             $message = $this->load->view('email/accountcreation', $data, TRUE);
         }
         sendMail('*****@*****.**', $data["sb_hotel_useremail"], "Administrator Account Creation", $message);
         //For Time being we are sending an email to developer.
         //sendMail('*****@*****.**',"*****@*****.**","Administrator Account Creation",$message);
         if ($result > '0') {
             $this->session->set_flashdata('category_success', HOTEL_ADMIN_CREATION_SUCCESS);
             redirect('admin/user/add_hotel_user/' . $hotel_id);
         } else {
             $this->session->set_flashdata('category_error', 'Error in Hotel Administrator Creation.');
             redirect('admin/user/add_hotel_user/' . $hotel_id);
         }
     }
 }