Ejemplo n.º 1
0
 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');
         }
     }
 }
Ejemplo n.º 2
0
 public function check_edit_user_permissions($user_id)
 {
     $this->data['action_type'] = 'edit';
     if ($this->session->userdata('logged_in_user')->sb_hotel_user_type == 'u') {
         $this->data['title'] = LABEL_1;
         $this->data['userinfo'] = $this->User_model->get_user_info($user_id);
         $this->data['hotelusertypes'] = getAvailableHotelUserTypes();
         $this->data['user_type'] = $this->session->userdata('logged_in_user')->sb_hotel_user_type;
         $this->data['hotel_id'] = $this->data['userinfo']->sb_hotel_id;
         /*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]);
         }
     }
     if ($this->session->userdata('logged_in_user')->sb_hotel_user_type == 'a') {
         $this->data['title'] = LABEL_1;
         $this->data['user_type'] = $this->session->userdata('logged_in_user')->sb_hotel_user_type;
         $this->data['userinfo'] = $this->User_model->get_user_info($user_id);
         $this->data['hotelusertypes'] = getAvailableHotelUserTypes();
         $this->data['hotel_id'] = $this->session->userdata('logged_in_user')->sb_hotel_id;
         $this->data['designation_list'] = $this->User_model->get_all_designations();
         $hotel_user_id = $this->session->userdata('logged_in_user')->sb_hotel_user_id;
         $this->data['user_id'] = $hotel_user_id;
         $this->data['parent_services'] = $this->Services_model->get_hotel_unique_parent_services($this->data['userinfo']->sb_hotel_id);
         if (($key = array_search('u', $this->data['hotelusertypes'])) !== false) {
             unset($this->data['hotelusertypes'][$key]);
         }
         if (($key = array_search('a', $this->data['hotelusertypes'])) !== false) {
             unset($this->data['hotelusertypes'][$key]);
         }
     }
     if ($this->session->userdata('logged_in_user')->sb_hotel_user_type == 'm') {
         $this->data['title'] = LABEL_1;
         $this->data['userinfo'] = $this->User_model->get_user_info($user_id);
         $this->data['hotelusertypes'] = getAvailableHotelUserTypes();
         $this->data['sb_hotel_name'] = $this->Hotel_model->get_hotel_name($this->data['userinfo']->sb_hotel_id);
         $this->data['designation_list'] = $this->User_model->get_all_designations();
         $this->data['user_type'] = $this->session->userdata('logged_in_user')->sb_hotel_user_type;
         $hotel_user_id = $this->session->userdata('logged_in_user')->sb_hotel_user_id;
         $this->data['user_id'] = $hotel_user_id;
         $this->data['hotel_id'] = $this->session->userdata('logged_in_user')->sb_hotel_id;
         $this->data['parent_services'] = $this->Services_model->get_hotel_user_parent_service($hotel_user_id);
         if (($key = array_search('m', $this->data['hotelusertypes'])) !== false) {
             unset($this->data['hotelusertypes'][$key]);
         }
         if (($key = array_search('u', $this->data['hotelusertypes'])) !== false) {
             unset($this->data['hotelusertypes'][$key]);
         }
         if (($key = array_search('a', $this->data['hotelusertypes'])) !== false) {
             unset($this->data['hotelusertypes'][$key]);
         }
     }
     $hotel_user_id = $this->session->userdata('logged_in_user')->sb_hotel_user_id;
     $this->data['user_id'] = $hotel_user_id;
     if ($this->data['hotel_id'] == 0) {
         $this->data['hotel_name'] = "None";
     } else {
         $result = $this->Hotel_model->get_hotel_name($this->data['hotel_id']);
         $this->data['hotel_name'] = $result[0]['sb_hotel_name'];
     }
 }