CHANGE_DOC_HISTORY : AADHAVAN
This commit is contained in:
parent
f7ab58cad4
commit
72b6281631
@ -63,6 +63,7 @@ use CodeIgniter\Router\RouteCollection;
|
||||
$routes->match(['get','post'],'/get_templates','MasterController::get_templates');
|
||||
$routes->match(['get','post'],'/create_docs','MasterController::create_docs');
|
||||
$routes->match(['get','post'],'/client_docs_preview','MasterController::client_docs_preview');
|
||||
$routes->get('client_docs_histroy/(:any)','MasterController::client_docs_histroy/$1');
|
||||
$routes->match(['get','post'],'/change_doc_status','MasterController::change_doc_status');
|
||||
$routes->match(['get','post'],'/test','MasterController::test');
|
||||
$routes->post('doc_generate_otp','MasterController::doc_generate_otp');
|
||||
|
||||
@ -272,7 +272,7 @@ class MasterController extends BaseController
|
||||
->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
|
||||
->findAll();
|
||||
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
|
||||
|
||||
// print_r($data['doc_list']);die;
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
echo view('share_docs',$data);
|
||||
@ -351,6 +351,64 @@ class MasterController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function client_docs_histroy($doc_id)
|
||||
{
|
||||
if($this->session->has('is_staff_logged_in')){
|
||||
$userData = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
}else if($this->session->has('is_client_logged_in')){
|
||||
$userData = $this->ClientBranchModel->where('id',$this->session->get('is_client_logged_in'))->get()->getRow();
|
||||
}
|
||||
|
||||
$data['docData'] = $this->ClientDocsModel->docPreview($doc_id);
|
||||
|
||||
// Fetch the document history
|
||||
$clientDocHistory = $this->DocsStatusModel->select('*')
|
||||
->where('client_docs_id', $doc_id)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
// Initialize an array to store the augmented results
|
||||
$augmentedHistory = [];
|
||||
|
||||
foreach ($clientDocHistory as $history) {
|
||||
if ($history->is_staff == 1) {
|
||||
// Fetch staff details
|
||||
$staffDetails = $this->StaffModel->select('name, email') // Adjust the columns as needed
|
||||
->where('staff_id', $history->created_by)
|
||||
->get()
|
||||
->getRow();
|
||||
$history->creator_details = $staffDetails;
|
||||
$history->creator_type = 'staff';
|
||||
} else {
|
||||
// Fetch client details
|
||||
$clientDetails = $this->ClientBranchModel->select('name, email') // Adjust the columns as needed
|
||||
->where('id', $history->created_by)
|
||||
->get()
|
||||
->getRow();
|
||||
$history->creator_details = $clientDetails;
|
||||
$history->creator_type = 'client';
|
||||
}
|
||||
|
||||
// Add the augmented history to the array
|
||||
$augmentedHistory[] = $history;
|
||||
}
|
||||
|
||||
// Assign the augmented history to the data array
|
||||
$data['client_doc_history'] = $augmentedHistory;
|
||||
|
||||
// Debug output
|
||||
// echo "<pre>";
|
||||
// print_r($data['client_doc_history']);
|
||||
// die;
|
||||
return json_encode($data);
|
||||
|
||||
// echo view('layout/header', ['Data'=>$userData]);
|
||||
// echo view('doc_history',$data);
|
||||
// echo view('layout/footer');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function change_doc_status()
|
||||
{
|
||||
try {
|
||||
@ -408,7 +466,7 @@ class MasterController extends BaseController
|
||||
try {
|
||||
$mobile_no = $this->request->getPost('mobile_no');
|
||||
|
||||
$client_data = $this->ClientModel->where('mobile_no', $mobile_no )->first();
|
||||
$client_data = $this->ClientBranchModel->where('mobile_no', $mobile_no )->first();
|
||||
|
||||
|
||||
if($client_data){
|
||||
|
||||
@ -57,7 +57,15 @@
|
||||
<?php endif; ?>
|
||||
|
||||
</td>
|
||||
<td><a href="<?php echo base_url().'client_docs_preview?doc_id='.$value['doc_id']; ?>"><i class='mdi mdi-eye-outline mr-1'></i>Preview</a></td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="<?php echo base_url().'client_docs_preview?doc_id='.$value['doc_id']; ?>" class="dropdown-item"><i class='mdi mdi-eye-outline mr-1' style="margin-right: 16px !important;"></i>Preview</a>
|
||||
<a id="doc_history_button" data-id="<?php echo $value['doc_id']; ?>" class="dropdown-item" data-toggle="modal" data-target="#bike_make_login-modal" data-title="Share"><i class="mdi mdi-history" style="margin-right: 16px !important;"></i>History</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
@ -79,8 +87,107 @@
|
||||
|
||||
|
||||
|
||||
<div id="bike_make_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 id="branch_action_type">Doc History</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form id="model_form_data" class="px-4">
|
||||
|
||||
<input type="text" id="business_id" value="" hidden>
|
||||
<input type="text" id="client_id" value="" hidden>
|
||||
<input type="text" id="branch_id" hidden>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<table class="table table-striped dt-responsive nowrap w-100">
|
||||
<thead>
|
||||
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right">
|
||||
<!-- <button class="btn btn-info waves-effect waves-light" type="submit" onclick="submitBranch(this)">Submit</button> -->
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- End Page content -->
|
||||
<!-- ============================================================== -->
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$(document).on('click', '#doc_history_button', function () {
|
||||
var url = '<?= base_url("client_docs_histroy/"); ?>' + $(this).data('id');
|
||||
function formatDate(dateString) {
|
||||
var options = { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hour12: true };
|
||||
var date = new Date(dateString);
|
||||
return date.toLocaleString('en-US', options).replace(',', '').toUpperCase();
|
||||
}
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
|
||||
// Clear the existing table body
|
||||
var tbody = $('#bike_make_login-modal .modal-body table tbody');
|
||||
tbody.empty();
|
||||
|
||||
// Iterate over the client_doc_history array and populate the table
|
||||
response.client_doc_history.forEach(function(item, index) {
|
||||
var creatorName = item.creator_details ? item.creator_details.name : 'N/A';
|
||||
var creatorType = item.creator_type ? ucfirst(item.creator_type) : 'N/A';
|
||||
|
||||
if(item.status == "Approved"){
|
||||
var reason_or_ip = ' - IP(';
|
||||
reason_or_ip_end = ')';
|
||||
}else if(item.status == "Rejected"){
|
||||
reason_or_ip = ' - Reason(';
|
||||
reason_or_ip_end = ')';
|
||||
}else{
|
||||
reason_or_ip = '';
|
||||
reason_or_ip_end = '';
|
||||
}
|
||||
var formattedDate = formatDate(item.created_at);
|
||||
var row = '<tr>' +
|
||||
'<td>Document ' + item.status + ' by ' + creatorName +' at, '+ formattedDate + reason_or_ip + item.note +reason_or_ip_end+'</td>' +
|
||||
|
||||
'</tr>';
|
||||
|
||||
tbody.append(row);
|
||||
});
|
||||
|
||||
// Show the modal
|
||||
$('#bike_make_login-modal').modal('show');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Helper function to capitalize the first letter
|
||||
function ucfirst(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
<tbody>
|
||||
|
||||
<?php foreach ($doc_list as $key => $value) { ?>
|
||||
|
||||
|
||||
<tr>
|
||||
<td> <?php echo $value['service_name']; ?></td>
|
||||
<td> <?php echo $value['document_name']; ?></td>
|
||||
@ -80,7 +80,7 @@
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item" href="<?php echo base_url().'client_docs_preview?doc_id='.$value['id']; ?>" > <i class='mdi mdi-eye-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Preview</a>
|
||||
<a class="dropdown-item" href="<?php echo base_url().'client_docs_preview?doc_id='.$value['doc_id']; ?>" > <i class='mdi mdi-eye-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Preview</a>
|
||||
|
||||
<?php if($value['is_active'] == 1 && $value['is_approved'] == 0){ ?>
|
||||
<a class="dropdown-item" data-id="<?php echo $value['id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Revert" onclick="statusChange(this)"><i class="mdi mdi-file-undo" style="margin-right: 16px !important;margin-left: 5px;"></i>Revert</a>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user