From 8a1409984b93a7aea1df0ae4c9bd24f0f4831ab4 Mon Sep 17 00:00:00 2001 From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com> Date: Thu, 29 Dec 2022 10:35:32 +0530 Subject: [PATCH] suseendhiran --- .../Layout/views/includes/default_menu.php | 4 +- application/modules/User/.gitkeep | 0 application/modules/User/controllers/User.php | 109 ++++++++++++++ .../modules/User/models/User_model.php | 38 +++++ application/modules/User/views/add_user.php | 140 ++++++++++++++++++ application/modules/User/views/edit_user.php | 104 +++++++++++++ application/modules/User/views/user_list.php | 88 +++++++++++ 7 files changed, 481 insertions(+), 2 deletions(-) create mode 100644 application/modules/User/.gitkeep create mode 100644 application/modules/User/controllers/User.php create mode 100644 application/modules/User/models/User_model.php create mode 100644 application/modules/User/views/add_user.php create mode 100644 application/modules/User/views/edit_user.php create mode 100644 application/modules/User/views/user_list.php diff --git a/application/modules/Layout/views/includes/default_menu.php b/application/modules/Layout/views/includes/default_menu.php index d1c275d..9a68072 100644 --- a/application/modules/Layout/views/includes/default_menu.php +++ b/application/modules/Layout/views/includes/default_menu.php @@ -43,8 +43,8 @@
  • Users
  • diff --git a/application/modules/User/.gitkeep b/application/modules/User/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/application/modules/User/controllers/User.php b/application/modules/User/controllers/User.php new file mode 100644 index 0000000..679b224 --- /dev/null +++ b/application/modules/User/controllers/User.php @@ -0,0 +1,109 @@ + (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() + { + $user_list = $this->user_model->get_user(user()->business_id); + $this->layout->set('tableData', $user_list); + $this->layout->buffer('main_content', 'User/user_list'); + $this->layout->render('default_layout'); + + } + + public function addUser($id='empty') + { + if($id != 'empty') + { + $assetData = $this->Asset_model->get_asset_by_md5_id($id,user()->business_id); + $this->layout->set('assetData', $assetData); + } + + $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_assets = $this->MY_Model->insert($data,$table); + redirect('user/userList'); + + } + + + public function editUser($id) + { + $table="asset"; + $assetData = $this->user_model->get_asset_by_md5_id($id,user()->business_id); + $this->layout->set('editData', $assetData); + $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'); + $assetData = $this->MY_Model->edit_option($action, $id, $table); + redirect('user/userList'); + + } + + public function deleteAsset($id) + { + $Data = $this->user_model->delete_asset_by_md5_id($id,user()->business_id); + redirect('user/userList'); + } + +} diff --git a/application/modules/User/models/User_model.php b/application/modules/User/models/User_model.php new file mode 100644 index 0000000..462cb10 --- /dev/null +++ b/application/modules/User/models/User_model.php @@ -0,0 +1,38 @@ +db->select('*'); + $this->db->from('users'); + $this->db->where('business_id', $business_id); + $this->db->where('role', 'user'); + $this->db->where('is_active', 1); + $query = $this->db->get(); + $query = $query->result(); + return $query; + } + + public function get_asset_by_md5_id($id,$business_id) + { + $this->db->select('*'); + $this->db->from('users'); + $this->db->where('business_id', $business_id); + $this->db->where('md5(id)', $id); + $query = $this->db->get(); + $query = $query->row(); + return $query; + } + + public function delete_asset_by_md5_id($id,$business_id) + { + $this->db->where('md5(id)', $id); + $this->db->where('business_id', $business_id); + $this->db->where('role', 'user'); + $this->db->set('is_active',0); + $this->db->update('users'); + return; + } + + +} \ No newline at end of file diff --git a/application/modules/User/views/add_user.php b/application/modules/User/views/add_user.php new file mode 100644 index 0000000..21fc2b2 --- /dev/null +++ b/application/modules/User/views/add_user.php @@ -0,0 +1,140 @@ + + + + + + + +
    +
    + +
    +

    Add User

    +
    + + +
    +
    +
    +
    +
    + + + + + + +
    +
    +
    + + + + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + + +
    + +
    + + + + + + + + + + + + + + + +
    +
    +
    + + + +
    +
    + +
    +
    +
    +
    + + + + + + + + +
    +
    + diff --git a/application/modules/User/views/edit_user.php b/application/modules/User/views/edit_user.php new file mode 100644 index 0000000..dd1efe1 --- /dev/null +++ b/application/modules/User/views/edit_user.php @@ -0,0 +1,104 @@ + + + + + +
    +
    + +
    +

    Edit User

    +
    + + +
    +
    +
    +
    +
    + + + + + + +
    +
    +
    + + + + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + +
    + + + +
    +
    +
    + + +
    +
    + +
    +
    +
    +
    + + + + + + + + +
    +
    diff --git a/application/modules/User/views/user_list.php b/application/modules/User/views/user_list.php new file mode 100644 index 0000000..18c04ea --- /dev/null +++ b/application/modules/User/views/user_list.php @@ -0,0 +1,88 @@ + +
    +
    +
    +

    User Details

    + + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + $value) { ?> + + + + + + + + + + + + + +
    Name Email Mobile Action
    name; ?> email; ?> mobile; ?> + +   + +   +
    + + + +
    +
    +
    +
    +
    + +
    + + + \ No newline at end of file