suseendhiran

This commit is contained in:
suseendhiran17 2022-12-29 10:35:32 +05:30
parent 435ac78060
commit 8a1409984b
7 changed files with 481 additions and 2 deletions

View File

@ -43,8 +43,8 @@
</li>
<li><a><i class="fa fa-user"></i> Users <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="<?php echo base_url();?>Asset">Users List</a></li>
<li><a href="#">Add Users</a></li>
<li><a href="<?php echo base_url();?>user/userList">Users List</a></li>
<li><a href="<?php echo base_url();?>user/addUser">Add Users</a></li>
</ul>
</li>

View File

View File

@ -0,0 +1,109 @@
<?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()
{
$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');
}
}

View File

@ -0,0 +1,38 @@
<?php
class User_model extends MY_Model {
public function get_user($business_id)
{
$this->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;
}
}

View File

@ -0,0 +1,140 @@
<!-- Body page content -->
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<div class="">
<div class="page-title">
<div class="title_left">
<h3>Add User</h3>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<!-- <div class="x_title"> -->
<!-- <ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
</li>
</ul> -->
<!-- <h6>General Information</h6> -->
<!-- <div class="clearfix"></div> -->
<!-- </div> -->
<div class="x_content">
<br />
<form id="" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?php echo base_url();?>User/createUser" enctype="multipart/form-data">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
<!-- --------------------------- -->
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Name </label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="name" name="name" value="" required="required" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="last-name"> Email </label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="email" name="email" value="" required="required" class="form-control ">
</div>
</div>
<!-- --------------------------- -->
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Mobile </label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="mobile" name="mobile" value="" required="required" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="last-name">Permit </label>
<div class="col-md-5 col-sm-5 ">
<select id="action_permit" name="action_permit" required="required" class="form-control" >
<option value="all">All</option>
<option value="view">View</option>
</select>
</div>
</div>
<!-- --------------------------- -->
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Username </label>
<div class="col-md-3 col-sm-3 ">
<input type="text" id="user_name" name="user_name" value="" required="required" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="last-name"> Password </label>
<div class="col-md-3 col-sm-3 ">
<input type="text" id="password" name="password" value="" required="required" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="last-name"> Confirm Password </label>
<div class="col-md-3 col-sm-3 ">
<input type="text" id="confirm_password" name="confirm_password" value="" required="required" class="form-control ">
<span id='message'></span>
</div>
</div>
<!-- --------------------------- -->
<!-- <div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="last-name"> Confirm Password </label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="confirm_password" name="confirm_password" value="" required="required" class="form-control ">
<span id='message'></span>
</div>
</div> -->
<!-- --------------------------- -->
<script>
$('#password, #confirm_password').on('keyup', function () {
if ($('#password').val() == $('#confirm_password').val() && $('#confirm_password').val().length > 0 ) {
$('#message').html('Matching').css('color', 'green');
} else
$('#message').html('Not Matching').css('color', 'red');
});
</script>
<div class="ln_solid"></div>
<div class="item form-group">
<div class="col-md-6 col-sm-6 offset-md-9">
<button class="btn btn-secondary" onclick="history.back()">Cancel</button>
<button class="btn btn-primary" type="reset">Reset</button>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- /Body page content -->

View File

@ -0,0 +1,104 @@
<!-- Body page content -->
<div class="">
<div class="page-title">
<div class="title_left">
<h3>Edit User</h3>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<!-- <div class="x_title"> -->
<!-- <ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
</li>
</ul> -->
<!-- <h6>General Information</h6> -->
<!-- <div class="clearfix"></div> -->
<!-- </div> -->
<div class="x_content">
<br />
<form id="" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?php echo base_url();?>User/editUsers" enctype="multipart/form-data">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
<input type="hidden" name="id" value="<?php echo $editData->id; ?>">
<!-- --------------------------- -->
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Name </label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="name" name="name" value="<?php echo $editData->name; ?>" required="required" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="last-name"> Email </label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="email" name="email" value="<?php echo $editData->email; ?>" required="required" class="form-control ">
</div>
</div>
<!-- --------------------------- -->
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Mobile </label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="mobile" name="mobile" value="<?php echo $editData->mobile; ?>" required="required" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="last-name">Permit </label>
<div class="col-md-5 col-sm-5 ">
<select id="action_permit" name="action_permit" required="required" class="form-control" >
<option value="<?php echo $editData->action_permit; ?>"><?php echo $editData->action_permit; ?></option>
<option value="all">all</option>
<option value="view">view</option>
</select>
</div>
</div>
<!-- --------------------------- -->
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Username </label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="user_name" name="user_name" value="<?php echo $editData->user_name; ?>" required="required" class="form-control ">
</div>
<label class="control-label col-md-1 col-sm-1 " for="last-name"> Password </label>
<div class="col-md-5 col-sm-5 ">
<input type="text" id="password" name="password" value="<?php echo $editData->password; ?>" required="required" class="form-control ">
</div>
</div>
<!-- --------------------------- -->
<div class="ln_solid"></div>
<div class="item form-group">
<div class="col-md-6 col-sm-6 offset-md-10">
<button class="btn btn-primary" onclick="history.back()">Cancel</button>
<button type="submit" class="btn btn-success">Update</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,88 @@
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title">
<h2>User Details </h2>
<ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>user/addUser" class="btn btn-sm btn-primary">Add User</a>
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="row">
<div class="col-sm-12">
<table id="datatable" class="table table-striped table-bordered" width="100%">
<thead>
<tr class="headings">
<th class="column-title">Name </th>
<th class="column-title">Email </th>
<th class="column-title">Mobile </th>
<!-- <th class="column-title">Serial </th>
<th class="column-title">Model </th>
<th class="column-title">Category </th>
<th class="column-title">Status </th> -->
<!-- <th class="column-title">Notes </th>
<th class="column-title">Warranty </th>
<th class="column-title">Order No </th>
<th class="column-title">Purchase Date </th>
<th class="column-title">Supplier </th>
<th class="column-title">Cost </th>
<th class="column-title">Location </th> -->
<th class="column-title" >Action </th>
</tr>
</thead>
<tbody>
<?php foreach ($tableData as $key => $value) { ?>
<tr class="even pointer">
<td class=" "> <?php echo $value->name; ?> </td>
<td class=" "><?php echo $value->email; ?> </td>
<td class=" "><?php echo $value->mobile; ?></td>
<!-- <td class=" "><?php echo $value->serial; ?></td>
<td class=" "><?php echo $value->model; ?></td>
<td class=" "><?php echo $value->category_name; ?></td>
<td class=" "><?php echo $value->status; ?></td> -->
<!--<td class=" "><?php echo $value->notes; ?> </td>
<td class=" "><?php echo $value->warranty; ?> </td>
<td class=" "><?php echo $value->order_no; ?></td>
<td class=" "><?php echo $value->purchase_date; ?></td>
<td class=" "><?php echo $value->supplier_name; ?></td>
<td class=" "><?php echo $value->cost; ?></td>
<td class=" "><?php echo $value->location_name; ?></td> -->
<td style=" text-align: center; font-size: 16px;">
<a href="<?php echo base_url()?>user/editUser/<?php echo md5($value->id);?>" ><i class="fa fa-pencil"></i></a>
&nbsp;
<a href="<?php echo base_url()?>user/deleteAsset/<?php echo md5($value->id);?>" ><i class="fa fa-trash"></i></a>
&nbsp;
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<br/>
<div style="display:none" id="sub-value">
</div>