suseendhiran
This commit is contained in:
parent
d2b703e6e8
commit
3ae47e1bd1
@ -264,7 +264,9 @@ function getData($table,$id,$business_id)
|
||||
{
|
||||
$this->db->select();
|
||||
$this->db->from($table);
|
||||
if($business_id != NULL) {
|
||||
$this->db->where('business_id', $business_id);
|
||||
}
|
||||
$this->db->where('id', $id);
|
||||
$query = $this->db->get();
|
||||
$query = $query->row();
|
||||
|
||||
@ -47,7 +47,13 @@ public function set()
|
||||
public function fetch()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$data = $this->MY_Model->getData($this->table,$this->id,user()->business_id);
|
||||
if(is_superadmin()){
|
||||
$business_id = NULL;
|
||||
}
|
||||
else{
|
||||
$business_id = user()->business_id;
|
||||
}
|
||||
$data = $this->MY_Model->getData($this->table,$this->id, $business_id);
|
||||
if($args[0] == 'old_data'){ $this->old_data = $data; return $this->old_data; }
|
||||
else if($args[0] == 'new_data'){ $this->new_data = $data; return $this->new_data; }
|
||||
|
||||
|
||||
@ -3,10 +3,12 @@ class Audit_model extends MY_Model {
|
||||
|
||||
public function get_history($id,$table,$business_id)
|
||||
{
|
||||
$this->db->select('A.* , user.name as user_name ');
|
||||
$this->db->select('A.* , users.name as user_name ');
|
||||
$this->db->from('history A');
|
||||
$this->db->join('user', 'user.id = A.created_by', 'left');
|
||||
$this->db->where('A.business_id', $business_id);
|
||||
$this->db->join('users', 'users.id = A.created_by', 'left');
|
||||
if($business_id != NULL) {
|
||||
$this->db->where('A.business_id', $business_id);
|
||||
}
|
||||
$this->db->where('A.primary_id', $id);
|
||||
$this->db->where('A.table_name', $table);
|
||||
$query = $this->db->get();
|
||||
|
||||
@ -153,8 +153,8 @@ public function edit_business()
|
||||
//fetch old_data before new_data update
|
||||
$this->audit->fetch('old_data');
|
||||
//insert new data
|
||||
$assetData = $this->MY_Model->edit_option($action, $id, $table);
|
||||
if($assetData)
|
||||
$businessData = $this->MY_Model->edit_option($action, $id, $table);
|
||||
if($businessData)
|
||||
{
|
||||
//fetch new_data after post data update
|
||||
$this->audit->fetch('new_data');
|
||||
|
||||
@ -57,6 +57,8 @@
|
||||
|
||||
<a href="<?php echo base_url()?>business/delete_business/<?php echo md5($value->id);?>" ><i class="fa fa-trash"></i></a>
|
||||
|
||||
|
||||
<a> <i id="<?php echo $value->id;?>" class="fa fa-eye"></i></a>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
@ -77,4 +79,22 @@
|
||||
<div style="display:none" id="sub-value">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
|
||||
|
||||
<script>
|
||||
$(document).on('click','.fa-eye',function(){
|
||||
var id = $(this).attr("id")
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "<?php echo base_url()?>user/view_business_history/"+id,
|
||||
success: function(response) {
|
||||
response = JSON.parse(response);
|
||||
console.log(response);
|
||||
$('.bs-example-modal-lg').html(response);
|
||||
$('.bs-example-modal-lg').modal("show");
|
||||
},
|
||||
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -27,6 +27,7 @@ public function __construct()
|
||||
parent::__construct();
|
||||
$this->load->model('MY_Model');
|
||||
$this->load->model('user_model');
|
||||
$this->load->model('audit_model');
|
||||
// $this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
@ -124,7 +125,6 @@ public function editUsers()
|
||||
$this->audit->fetch('new_data');
|
||||
//audit history generation for update
|
||||
$test = $this->audit->create_history('update');
|
||||
print_r( $test);die();
|
||||
}
|
||||
redirect('user/userList');
|
||||
|
||||
@ -220,4 +220,24 @@ public function businessProfile($business_id)
|
||||
$this->layout->render('default_layout');
|
||||
}
|
||||
|
||||
|
||||
public function view_user_history($id)
|
||||
{
|
||||
$table = 'users';
|
||||
$user_history = $this->audit_model->get_history( $id , $table , user()->business_id);
|
||||
$data = array('title'=> "view" , 'user_history'=> $user_history );
|
||||
$htmlPage = $this->load->view('view_history.php',$data,true);
|
||||
echo json_encode($htmlPage);
|
||||
}
|
||||
|
||||
|
||||
public function view_business_history($id)
|
||||
{
|
||||
$table = 'business';
|
||||
$user_history = $this->audit_model->get_history( $id , $table , user()->business_id);
|
||||
$data = array('title'=> "view" , 'user_history'=> $user_history );
|
||||
$htmlPage = $this->load->view('view_history.php',$data,true);
|
||||
echo json_encode($htmlPage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -30,7 +30,9 @@ public function get_user_by_md5_id($id,$business_id)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('users');
|
||||
$this->db->where('business_id', $business_id);
|
||||
if ($business_id != NULL) {
|
||||
$this->db->where('business_id', $business_id);
|
||||
}
|
||||
$this->db->where('md5(id)', $id);
|
||||
$query = $this->db->get();
|
||||
$query = $query->row();
|
||||
|
||||
@ -38,10 +38,13 @@
|
||||
<a href="<?php echo base_url()?>user/deleteUser/<?php echo md5($value->id);?>" >
|
||||
<i class="#008000 fa fa-check-circle" style="font-size:20px;" title="deactivate"></i></a>
|
||||
|
||||
<a> <i id="<?php echo $value->id;?>" class="fa fa-eye"></i></a>
|
||||
<?php } ?>
|
||||
<?php if ($value->is_active == 0) { ?>
|
||||
<a href="<?php echo base_url()?>user/activateUser/<?php echo md5($value->id);?>" >
|
||||
<i class="green fa fa-check-circle" style="font-size:20px;" title="activate"></i></a>
|
||||
|
||||
<a> <i id="<?php echo $value->id;?>" class="fa fa-eye"></i></a>
|
||||
|
||||
<?php } ?>
|
||||
</td>
|
||||
@ -57,7 +60,27 @@
|
||||
|
||||
<br/>
|
||||
|
||||
<!-- Large modal -->
|
||||
<!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg" hidden>Large modal</button> -->
|
||||
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
|
||||
|
||||
<div style="display:none" id="sub-value">
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).on('click','.fa-eye',function(){
|
||||
var id = $(this).attr("id")
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "<?php echo base_url()?>user/view_user_history/"+id,
|
||||
success: function(response) {
|
||||
response = JSON.parse(response);
|
||||
console.log(response);
|
||||
$('.bs-example-modal-lg').html(response);
|
||||
$('.bs-example-modal-lg').modal("show");
|
||||
},
|
||||
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
34
application/modules/User/views/view_history.php
Normal file
34
application/modules/User/views/view_history.php
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
<!-- Large modal -->
|
||||
<!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg" hidden>Large modal</button> -->
|
||||
<!-- <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true"> -->
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myModalLabel"><?php echo $title; ?></h4>
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<?php foreach ($user_history as $key => $value) { ?>
|
||||
<div id="data" style="padding : 10px;">
|
||||
<lable class="col-form-label" id="first-line"><?php echo my_date_show_time($value->created_at). " " ?><i><?php echo $value->user_name; ?></i></lable></br>
|
||||
<lable class="column-title" style="color : black;" >
|
||||
<?php
|
||||
$column_name = str_replace("_"," ",$value->column_name);
|
||||
$column_name = ucwords($column_name);
|
||||
if($value->old_value == null)
|
||||
{ echo "'$column_name'"." Created with "."'$value->new_value'"; }
|
||||
else{ echo $column_name." Changed from "."'$value->old_value'"." to "."'$value->new_value'"; }
|
||||
?>
|
||||
</lable></br>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<!-- <button type="button" class="btn btn-primary">Save changes</button> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
@ -244,6 +244,9 @@ $("#file_profile").change(function(){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user