168 lines
4.4 KiB
PHP
168 lines
4.4 KiB
PHP
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
/**
|
|
* AMS
|
|
*
|
|
* @package HMVC
|
|
* @author Venba
|
|
* @copyright 2022 Venba
|
|
* @license https://venbainfotech.com/licenses/MIT MIT License
|
|
* @link <URI> (description)
|
|
* @version GIT: $Id$
|
|
* @since Version 0.0.1
|
|
* @filesource
|
|
*
|
|
*/
|
|
|
|
class User extends Admin_Controller
|
|
{
|
|
/**
|
|
* [__construct description]
|
|
*
|
|
* @method __construct
|
|
*/
|
|
public function __construct()
|
|
{
|
|
// To inherit directly the attributes of the parent class.
|
|
parent::__construct();
|
|
$this->load->model('MY_Model');
|
|
$this->load->model('user_model');
|
|
// $this->load->helper(array('form', 'url'));
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
|
|
$this->layout->set('users', "abc");
|
|
$this->layout->buffer('main_content', 'User/index');
|
|
$this->layout->render('default_layout');
|
|
|
|
|
|
}
|
|
|
|
public function userList()
|
|
{
|
|
if (is_superadmin()) {
|
|
$user_list = $this->user_model->get_admin();
|
|
}
|
|
else if(is_admin()) {
|
|
$user_list = $this->user_model->get_user(user()->business_id , "user");
|
|
}
|
|
$this->layout->set('tableData', $user_list);
|
|
$this->layout->buffer('main_content', 'User/user_list');
|
|
$this->layout->render('default_layout');
|
|
|
|
}
|
|
|
|
public function addUser()
|
|
{
|
|
$business = $this->user_model->business();
|
|
$this->layout->set('data', user());
|
|
$this->layout->set('business_dropdown', $business);
|
|
$this->layout->buffer('main_content', 'User/add_user');
|
|
$this->layout->render('default_layout');
|
|
|
|
}
|
|
|
|
public function createUser()
|
|
{
|
|
$data=$this->input->post();
|
|
// $data['business_id'] = user()->business_id;
|
|
// $data['created_by'] = user()->id;
|
|
// $data['role'] = "user";
|
|
unset($data['confirm_password']);
|
|
$data['password'] = hash_password($this->input->post('password'));
|
|
$table="users";
|
|
$create_user = $this->MY_Model->insert($data,$table);
|
|
redirect('user/userList');
|
|
|
|
}
|
|
|
|
|
|
public function editUser($id)
|
|
{
|
|
$usertData = $this->user_model->get_user_by_md5_id($id,user()->business_id);
|
|
$this->layout->set('editData', $usertData);
|
|
$this->layout->buffer('main_content', 'User/edit_user');
|
|
$this->layout->render('default_layout');
|
|
|
|
}
|
|
|
|
|
|
public function editUsers()
|
|
{
|
|
|
|
$table="users";
|
|
$action = $this->input->post();
|
|
|
|
$id = $this->input->post('id');
|
|
$userData = $this->MY_Model->edit_option($action, $id, $table);
|
|
redirect('user/userList');
|
|
|
|
}
|
|
|
|
public function deleteUser($id)
|
|
{
|
|
$Data = $this->user_model->delete_user_by_md5_id($id,user()->business_id);
|
|
redirect('user/userList');
|
|
}
|
|
|
|
public function activateUser($id)
|
|
{
|
|
$Data = $this->user_model->activate_inactive_users($id,user()->business_id);
|
|
redirect('user/userList');
|
|
}
|
|
|
|
public function profile()
|
|
{
|
|
$user_list = $this->MY_Model->get_by_id( user()->id , 'users');
|
|
$this->layout->set('userData', $user_list);
|
|
$this->layout->buffer('main_content', 'User/profile');
|
|
$this->layout->render('default_layout');
|
|
}
|
|
|
|
public function editprofile($id)
|
|
{
|
|
$usertData = $this->user_model->get_user_by_md5_id($id,user()->business_id);
|
|
$this->layout->set('editData', $usertData);
|
|
$this->layout->buffer('main_content', 'User/edit_profile');
|
|
$this->layout->render('default_layout');
|
|
}
|
|
|
|
public function editprofiles()
|
|
{
|
|
$table="users";
|
|
$action = $this->input->post();
|
|
|
|
$id = $this->input->post('id');
|
|
//file upload confic
|
|
$user_image['upload_path'] = APPPATH. '../assets/uploads/profile_picture';
|
|
$user_image['allowed_types'] = 'jpg|png';
|
|
$user_image['max_size'] = 80000;
|
|
//upload
|
|
$this->load->library('upload', $user_image);
|
|
$this->upload->initialize($user_image);
|
|
if ( ! $this->upload->do_upload('profile_image'))
|
|
{
|
|
$error = array('error' => $this->upload->display_errors());
|
|
|
|
unset($action['profile_image']);
|
|
} else{
|
|
$upload_user_image = $this->upload->data();
|
|
$action['profile_image'] = $upload_user_image['file_name'];
|
|
|
|
}
|
|
|
|
$userData = $this->MY_Model->edit_option($action, $id, $table);
|
|
redirect('user/profile');
|
|
}
|
|
|
|
|
|
public function changepassword()
|
|
{
|
|
echo "hai";
|
|
// $this->load->view('change_password');
|
|
}
|
|
|
|
}
|