Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
6133432ff7
@ -554,6 +554,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->match( ['get', 'post'], 'ticket_reports','TicketController::ticketReports');
|
||||
$routes->post('getPolicyStartDate','TicketController::getPolicyStartDate');
|
||||
$routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID");
|
||||
$routes->post("getMoreInfo","TicketController::getMoreInfo");
|
||||
// $routes->post('ticket_messages','TicketController::getTicketMessage');
|
||||
});
|
||||
|
||||
|
||||
@ -54,6 +54,8 @@ class TicketController extends BaseController
|
||||
public function __construct()
|
||||
{
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
set_session_context('Ticket Master Controller');
|
||||
|
||||
|
||||
$this->ticketMasterModel = new TicketMasterModel();
|
||||
|
||||
@ -1761,4 +1763,84 @@ class TicketController extends BaseController
|
||||
$this->loadLayout("ticket_feedback_list",$data);
|
||||
}
|
||||
|
||||
public function getMoreInfo() {
|
||||
$ticket_id = $this->request->getPost('ticket_id');
|
||||
$this->myLogger->logme("error", "Ticket ID : " . $ticket_id);
|
||||
|
||||
$fields = $this->extraFields;
|
||||
$data_to_send = [];
|
||||
|
||||
// Get ticket data
|
||||
$ticket_data = $this->ticketMasterModel->where("id", $ticket_id)->where("is_active", 1)->first();
|
||||
|
||||
// Query previous status
|
||||
$ticket_previous_status = $this->ticketMasterModel
|
||||
->select("th.old_value, tcs.claim_status")
|
||||
->join("ticket_history th", "th.ticket_id = ticket_master.id AND th.field_name = 'claim_status_id' AND th.is_active = 1")
|
||||
->join("ticket_claim_status tcs", "tcs.id = th.old_value AND tcs.is_active = 1")
|
||||
->where("ticket_master.is_active", 1)
|
||||
->where("ticket_master.id", $ticket_id)
|
||||
->groupBy("th.old_value, tcs.claim_status")
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
// Loop through previous status and gather the required data
|
||||
foreach ($ticket_previous_status as $status) {
|
||||
$this->myLogger->logme("error", "Status : " . json_encode($status));
|
||||
|
||||
if (isset($fields[$status['old_value']])) {
|
||||
$field = $fields[$status['old_value']];
|
||||
|
||||
// Ensure claim_status is a scalar value (string or int)
|
||||
$claim_status = (string)$status['claim_status']; // Cast to string to avoid issues
|
||||
|
||||
// Initialize claim_status if it doesn't exist in the array
|
||||
if (!isset($data_to_send[$claim_status])) {
|
||||
$data_to_send[$claim_status] = [];
|
||||
}
|
||||
|
||||
// Handle case where $field is an array
|
||||
if (is_array($field)) {
|
||||
foreach ($field as $f) {
|
||||
// Check if the field exists in the ticket data
|
||||
$data_to_send[$claim_status][$f] = isset($ticket_data[$f]) ? $ticket_data[$f] : null;
|
||||
|
||||
// Check if the field contains a date and format it
|
||||
if ($this->isDate($data_to_send[$claim_status][$f])) {
|
||||
$data_to_send[$claim_status][$f] = date('d-m-Y', strtotime($data_to_send[$claim_status][$f]));
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Data for field {$f}: " . json_encode($data_to_send[$claim_status][$f]));
|
||||
}
|
||||
} else {
|
||||
// If field is not an array, handle it as a single field
|
||||
$data_to_send[$claim_status][$field] = isset($ticket_data[$field]) ? $ticket_data[$field] : null;
|
||||
|
||||
// Check if the field contains a date and format it
|
||||
if ($this->isDate($data_to_send[$claim_status][$field])) {
|
||||
$data_to_send[$claim_status][$field] = date('d-m-Y', strtotime($data_to_send[$claim_status][$field]));
|
||||
}
|
||||
|
||||
$this->myLogger->logme("error", "Data for field {$field}: " . json_encode($data_to_send[$claim_status][$field]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', "Total data: " . json_encode($data_to_send));
|
||||
|
||||
// Send response based on data availability
|
||||
if (!empty($data_to_send)) {
|
||||
return $this->respond(['status' => true, 'data' => $data_to_send], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false], 200);
|
||||
}
|
||||
}
|
||||
|
||||
private function isDate($value) {
|
||||
// Check if the value is a valid date string (basic validation)
|
||||
return strtotime($value) !== false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -11,6 +11,18 @@
|
||||
background-color: #f0f0f0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.info-icon {
|
||||
color: #007bff;
|
||||
font-size: 15px;
|
||||
transition: 0.3s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.info-icon:hover {
|
||||
color: #0056b3;
|
||||
font-size: 24px;
|
||||
}
|
||||
</style>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@ -168,7 +180,7 @@
|
||||
<!-- end first_data_points -->
|
||||
|
||||
<br><br>
|
||||
<h5>Claim Details</h5>
|
||||
<h5>Claim Details <span><i id="infoIcon" class="fas fa-info-circle info-icon" title="Click for more details"></i></span></h5>
|
||||
<hr>
|
||||
|
||||
<!-- second_data_points -->
|
||||
@ -415,6 +427,24 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Info Modal -->
|
||||
<div class="modal fade" id="moreInfoModal" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="fullWidthModalLabel">More Information</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="dynamicDivFillInfo"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
// $(document).ready(function() {
|
||||
// var calim_status = $('#claim_status_id').val();
|
||||
@ -964,7 +994,7 @@
|
||||
value: '',
|
||||
text: 'Select Client Policy'
|
||||
}));
|
||||
console.log("got data from backend ",data);
|
||||
console.log("got data from backend ", data);
|
||||
let policyCount = 1;
|
||||
var policyAppendCount = 0;
|
||||
$.each(data, function(index, item) {
|
||||
@ -972,19 +1002,19 @@
|
||||
|
||||
if (ticket_type == 1 && item.policy_type_id != 1) {
|
||||
$('#emp_client_policy').append($('<option>', {
|
||||
value: item.client_policy_value,
|
||||
text: item.client_policy_name
|
||||
}));
|
||||
$("#policy_no").val("");
|
||||
if (policyCount == 1){
|
||||
console.log("policy count from if",item.policy_no);
|
||||
value: item.client_policy_value,
|
||||
text: item.client_policy_name
|
||||
}));
|
||||
$("#policy_no").val("");
|
||||
if (policyCount == 1) {
|
||||
console.log("policy count from if", item.policy_no);
|
||||
$("#policy_no").val(item.policy_no);
|
||||
}else{
|
||||
console.log("policy count from greter if ","");
|
||||
} else {
|
||||
console.log("policy count from greter if ", "");
|
||||
$("#policy_no").val("");
|
||||
}
|
||||
policyCount++;
|
||||
policyAppendCount++;
|
||||
policyAppendCount++;
|
||||
if (hiddenData['searchType'] != null && hiddenData['searchType'] != "" && hiddenData['policy_id'] != null && hiddenData['policy_id'] != "") {
|
||||
// $('#emp_client_policy').select2();
|
||||
$("#emp_client_policy").select2();
|
||||
@ -998,9 +1028,9 @@
|
||||
}
|
||||
|
||||
})
|
||||
console.log('policy append count ',policyAppendCount);
|
||||
if (policyAppendCount == 0){
|
||||
toastr.warning("No Policies found for the Employee","Warning");
|
||||
console.log('policy append count ', policyAppendCount);
|
||||
if (policyAppendCount == 0) {
|
||||
toastr.warning("No Policies found for the Employee", "Warning");
|
||||
}
|
||||
}
|
||||
// $('#emp_client_policy').select2();
|
||||
@ -1019,14 +1049,14 @@
|
||||
$("#policy_no").val(policy_no);
|
||||
console.log("Function set min date called ");
|
||||
console.log("Existing DOA instance: ", doa);
|
||||
console.log('sent data ',policy_id);
|
||||
console.log('sent data ', policy_id);
|
||||
$.ajax({
|
||||
url: '<?= base_url("ticket/getPolicyStartDate") ?>',
|
||||
method: "POST",
|
||||
data: {
|
||||
policy_id: policy_id
|
||||
},
|
||||
|
||||
|
||||
success: function(response) {
|
||||
console.log("mindate response ", response);
|
||||
|
||||
@ -1062,4 +1092,107 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
$("#infoIcon").click(function() {
|
||||
var ticket_id = $('#ticket_master_id').val();
|
||||
getDataForInfo(ticket_id, function(data) {
|
||||
console.log("data: ", data);
|
||||
if (data && Object.keys(data).length) {
|
||||
// openModal();
|
||||
var myModal = new bootstrap.Modal(document.getElementById('moreInfoModal'));
|
||||
myModal.show();
|
||||
|
||||
appendHtmlToModal(data);
|
||||
} else {
|
||||
// toastr.warning("Data not Found");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function getDataForInfo(ticketId, callback) {
|
||||
$.ajax({
|
||||
url: "<?= base_url('ticket/getMoreInfo') ?>",
|
||||
type: "POST",
|
||||
data: {
|
||||
ticket_id: ticketId
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.status) {
|
||||
console.log("Info Response: ", response);
|
||||
callback(response.data); // pass data to the callback
|
||||
} else {
|
||||
toastr.warning("No Data Found");
|
||||
callback(null);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function appendHtmlToModal(data) {
|
||||
var container = document.getElementById('dynamicDivFillInfo');
|
||||
|
||||
// Clear any previous content inside the container
|
||||
container.innerHTML = '';
|
||||
|
||||
// Iterate over each status in the data
|
||||
for (let status in data) {
|
||||
if (data.hasOwnProperty(status)) {
|
||||
// Create the status subheading
|
||||
var statusHeading = document.createElement('h5');
|
||||
statusHeading.textContent = status;
|
||||
container.appendChild(statusHeading);
|
||||
|
||||
// Create a row container to group the fields in a row
|
||||
var rowContainer = document.createElement('div');
|
||||
rowContainer.classList.add('row'); // Add Bootstrap row class to group fields
|
||||
|
||||
// Iterate over each field within the current status
|
||||
for (let field in data[status]) {
|
||||
if (data[status].hasOwnProperty(field)) {
|
||||
// Create a container for each field with col-md-4 class
|
||||
var fieldContainer = document.createElement('div');
|
||||
fieldContainer.classList.add('form-group', 'col-md-4'); // Apply col-md-4 to each field
|
||||
|
||||
// Create a label for the field
|
||||
var fieldLabel = document.createElement('label');
|
||||
fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
|
||||
fieldContainer.appendChild(fieldLabel);
|
||||
|
||||
// Create either an input field or a textarea based on the field name
|
||||
var fieldInput;
|
||||
if (field === 'approved_letter' || field == "settle_letter") {
|
||||
// Create a textarea for 'approved_letter'
|
||||
fieldInput = document.createElement('textarea');
|
||||
fieldInput.classList.add('form-control');
|
||||
fieldInput.textContent = data[status][field]; // Set the value to the field content
|
||||
} else {
|
||||
// Create an input field for other fields
|
||||
fieldInput = document.createElement('input');
|
||||
fieldInput.type = 'text';
|
||||
fieldInput.classList.add('form-control');
|
||||
fieldInput.value = data[status][field];
|
||||
}
|
||||
|
||||
fieldInput.setAttribute('readonly', 'readonly'); // Set field as readonly
|
||||
|
||||
// Append the input (or textarea) to the container
|
||||
fieldContainer.appendChild(fieldInput);
|
||||
|
||||
// Append the field container to the row container
|
||||
rowContainer.appendChild(fieldContainer);
|
||||
}
|
||||
}
|
||||
|
||||
// Append the row container to the main container
|
||||
container.appendChild(rowContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -4,6 +4,18 @@
|
||||
background-color: #e0e0e0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.info-icon {
|
||||
color: #007bff;
|
||||
font-size: 15px;
|
||||
transition: 0.3s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.info-icon:hover {
|
||||
color: #0056b3;
|
||||
font-size: 24px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row">
|
||||
@ -130,7 +142,7 @@
|
||||
<!-- end first_data_points -->
|
||||
|
||||
<br><br>
|
||||
<h5>Claim Details</h5>
|
||||
<h5>Claim Details <span><i id="infoIcon" class="fas fa-info-circle info-icon" title="Click for more details"></i></span></h5>
|
||||
<hr>
|
||||
|
||||
<!-- second_data_points -->
|
||||
@ -320,6 +332,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Info Modal -->
|
||||
<div class="modal fade" id="moreInfoModal" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="fullWidthModalLabel">More Information</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="dynamicDivFillInfo"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let GlobelExtraFields = [];
|
||||
|
||||
@ -815,4 +844,107 @@
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
</script>
|
||||
<script>
|
||||
$("#infoIcon").click(function() {
|
||||
var ticket_id = $('#ticket_master_id').val();
|
||||
getDataForInfo(ticket_id, function(data) {
|
||||
console.log("data: ", data);
|
||||
if (data && Object.keys(data).length) {
|
||||
// openModal();
|
||||
var myModal = new bootstrap.Modal(document.getElementById('moreInfoModal'));
|
||||
myModal.show();
|
||||
|
||||
appendHtmlToModal(data);
|
||||
} else {
|
||||
// toastr.warning("No Data Found");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function getDataForInfo(ticketId, callback) {
|
||||
$.ajax({
|
||||
url: "<?= base_url('ticket/getMoreInfo') ?>",
|
||||
type: "POST",
|
||||
data: {
|
||||
ticket_id: ticketId
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.status) {
|
||||
console.log("Info Response: ", response);
|
||||
callback(response.data); // pass data to the callback
|
||||
} else {
|
||||
toastr.warning("No Data Found");
|
||||
callback(null);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function appendHtmlToModal(data) {
|
||||
var container = document.getElementById('dynamicDivFillInfo');
|
||||
|
||||
// Clear any previous content inside the container
|
||||
container.innerHTML = '';
|
||||
|
||||
// Iterate over each status in the data
|
||||
for (let status in data) {
|
||||
if (data.hasOwnProperty(status)) {
|
||||
// Create the status subheading
|
||||
var statusHeading = document.createElement('h5');
|
||||
statusHeading.textContent = status;
|
||||
container.appendChild(statusHeading);
|
||||
|
||||
// Create a row container to group the fields in a row
|
||||
var rowContainer = document.createElement('div');
|
||||
rowContainer.classList.add('row'); // Add Bootstrap row class to group fields
|
||||
|
||||
// Iterate over each field within the current status
|
||||
for (let field in data[status]) {
|
||||
if (data[status].hasOwnProperty(field)) {
|
||||
// Create a container for each field with col-md-4 class
|
||||
var fieldContainer = document.createElement('div');
|
||||
fieldContainer.classList.add('form-group', 'col-md-4'); // Apply col-md-4 to each field
|
||||
|
||||
// Create a label for the field
|
||||
var fieldLabel = document.createElement('label');
|
||||
fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
|
||||
fieldContainer.appendChild(fieldLabel);
|
||||
|
||||
// Create either an input field or a textarea based on the field name
|
||||
var fieldInput;
|
||||
if (field === 'approved_letter' || field == "settle_letter") {
|
||||
// Create a textarea for 'approved_letter'
|
||||
fieldInput = document.createElement('textarea');
|
||||
fieldInput.classList.add('form-control');
|
||||
fieldInput.textContent = data[status][field]; // Set the value to the field content
|
||||
} else {
|
||||
// Create an input field for other fields
|
||||
fieldInput = document.createElement('input');
|
||||
fieldInput.type = 'text';
|
||||
fieldInput.classList.add('form-control');
|
||||
fieldInput.value = data[status][field];
|
||||
}
|
||||
|
||||
fieldInput.setAttribute('readonly', 'readonly'); // Set field as readonly
|
||||
|
||||
// Append the input (or textarea) to the container
|
||||
fieldContainer.appendChild(fieldInput);
|
||||
|
||||
// Append the field container to the row container
|
||||
rowContainer.appendChild(fieldContainer);
|
||||
}
|
||||
}
|
||||
|
||||
// Append the row container to the main container
|
||||
container.appendChild(rowContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user