bb_sign/app/Views/client_home.php
2024-06-13 09:39:08 +05:30

194 lines
8.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- ============================================================== -->
<!-- Start Page Content here -->
<!-- ============================================================== -->
<style>
.dt-buttons.btn-group.flex-wrap{
display: none !important;
}
</style>
<div class="content-page">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Shared Docs</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100 display">
<thead>
<tr>
<th>Document</th>
<th>Shared at</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($doc_list as $key => $value) { ?>
<tr>
<td> <?php echo $value['service_name']; ?></td>
<td> <?php $date = new DateTime($value['created_at']); echo $date->format('d-M-Y h:i A'); ?></td>
<td>
<?php if ($value['is_approved'] == 1): ?>
<span style="color:green">Approved</span>
<?php elseif ($value['is_approved'] == 0): ?>
<span style="color:orange">Pending Approval</span>
<?php elseif ($value['is_approved'] == 2): ?>
<span style="color:red">Rejected</span>
<?php endif; ?>
</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="#client-doc-history-modal" data-title="Share"><i class="mdi mdi-history" style="margin-right: 16px !important;"></i>History</a>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div> <!-- container -->
</div> <!-- content -->
<div id="client-doc-history-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 = $('#client-doc-history-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
$('#client-doc-history-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>