FIX_CLAIMS,FEAT_DATE_VALIDATION,FEAT_CLIENT_POLICY
This commit is contained in:
parent
1aaf6a8ef7
commit
07bb7503e0
@ -531,6 +531,8 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->post('note/(:any)','TicketController::crudNote/$1');
|
$routes->post('note/(:any)','TicketController::crudNote/$1');
|
||||||
$routes->post('reply','TicketController::saveReply');
|
$routes->post('reply','TicketController::saveReply');
|
||||||
$routes->match( ['get', 'post'], 'ticket_reports','TicketController::ticketReports');
|
$routes->match( ['get', 'post'], 'ticket_reports','TicketController::ticketReports');
|
||||||
|
$routes->post('getPolicyStartDate','TicketController::getPolicyStartDate');
|
||||||
|
$routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID");
|
||||||
// $routes->post('ticket_messages','TicketController::getTicketMessage');
|
// $routes->post('ticket_messages','TicketController::getTicketMessage');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,9 @@ use App\Models\TicketMailTemplateModel;
|
|||||||
use App\Models\TicketMessageModel;
|
use App\Models\TicketMessageModel;
|
||||||
use App\Models\TicketNoteModel;
|
use App\Models\TicketNoteModel;
|
||||||
use App\Models\UserModel;
|
use App\Models\UserModel;
|
||||||
|
use App\Models\ClientPolicyModel;
|
||||||
|
use App\Models\EmployeePolicyModel;
|
||||||
|
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Kint\Kint;
|
use Kint\Kint;
|
||||||
@ -45,6 +48,8 @@ class TicketController extends BaseController
|
|||||||
protected $triggerType;
|
protected $triggerType;
|
||||||
protected $userModel;
|
protected $userModel;
|
||||||
protected $employeeModel;
|
protected $employeeModel;
|
||||||
|
protected $clientPolicyModel;
|
||||||
|
protected $employeePolicyModel;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@ -80,10 +85,10 @@ class TicketController extends BaseController
|
|||||||
];
|
];
|
||||||
$this->claimType = [
|
$this->claimType = [
|
||||||
1 => [
|
1 => [
|
||||||
1 => "Main",
|
1 => "Main Hospitalization",
|
||||||
|
3 => "Pre / Post",
|
||||||
2 => "OPD",
|
2 => "OPD",
|
||||||
3 => "Pre ReOpen",
|
4 => "ReOpen",
|
||||||
4 => "Post ReOpen",
|
|
||||||
],
|
],
|
||||||
2 => [
|
2 => [
|
||||||
1 => "TTD",
|
1 => "TTD",
|
||||||
@ -157,6 +162,8 @@ class TicketController extends BaseController
|
|||||||
$this->ticketMessageModel = new TicketMessageModel();
|
$this->ticketMessageModel = new TicketMessageModel();
|
||||||
$this->userModel = new UserModel();
|
$this->userModel = new UserModel();
|
||||||
$this->employeeModel = new EmployeeModel();
|
$this->employeeModel = new EmployeeModel();
|
||||||
|
$this->clientPolicyModel = new ClientPolicyModel();
|
||||||
|
$this->employeePolicyModel = new EmployeePolicyModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ticketList()
|
public function ticketList()
|
||||||
@ -439,7 +446,6 @@ class TicketController extends BaseController
|
|||||||
$template_data['subject'] = $this->replacePlaceholders($template_data['subject'], $ticket_data);
|
$template_data['subject'] = $this->replacePlaceholders($template_data['subject'], $ticket_data);
|
||||||
}
|
}
|
||||||
$data = $this->ticket_form_data($ticket_data['ticket_type_id'], $ticket_data['claim_status_id']);
|
$data = $this->ticket_form_data($ticket_data['ticket_type_id'], $ticket_data['claim_status_id']);
|
||||||
$data['ticket_data'] = $ticket_data;
|
|
||||||
$data['reply_data'] = $template_data;
|
$data['reply_data'] = $template_data;
|
||||||
$data['placeHolders'] = $this->placeHolders;
|
$data['placeHolders'] = $this->placeHolders;
|
||||||
$data['message_data'] = $this->getTicketMessage($ticket_id);
|
$data['message_data'] = $this->getTicketMessage($ticket_id);
|
||||||
@ -447,6 +453,12 @@ class TicketController extends BaseController
|
|||||||
$data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']);
|
$data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']);
|
||||||
$data['ticket_history'] = $this->ticketHistory($ticket_id);
|
$data['ticket_history'] = $this->ticketHistory($ticket_id);
|
||||||
$data['ticket_check_list'] = db_connect()->table('ticket_check_list')->where('is_active', 1)->where('ticket_type_id', $ticket_data['ticket_type_id'])->get()->getResultArray();
|
$data['ticket_check_list'] = db_connect()->table('ticket_check_list')->where('is_active', 1)->where('ticket_type_id', $ticket_data['ticket_type_id'])->get()->getResultArray();
|
||||||
|
if (!empty($ticket_data['client_policy_id'])){
|
||||||
|
$ticket_data['client_policy_id_text'] = $this->clientPolicyModel->select('concat(policy_type.policy_type,"-",client_policy.policy_no) as client_policy_name')->join('policy_type','policy_type.id = client_policy.policy_type_id and policy_type.is_active = 1')->where('client_policy.id',$ticket_data['client_policy_id'])->first()['client_policy_name'];
|
||||||
|
}
|
||||||
|
// dd($ticket_data);
|
||||||
|
$data['ticket_data'] = $ticket_data;
|
||||||
|
|
||||||
// dd($data);
|
// dd($data);
|
||||||
|
|
||||||
return $this->loadLayout('ticket_edit_onbording', $data);
|
return $this->loadLayout('ticket_edit_onbording', $data);
|
||||||
@ -841,8 +853,16 @@ class TicketController extends BaseController
|
|||||||
$replaceData = $ticket_data[$value] ?? '';
|
$replaceData = $ticket_data[$value] ?? '';
|
||||||
} else if ($value == "policy_type") {
|
} else if ($value == "policy_type") {
|
||||||
$replaceData = str_replace("Claim-", "", $this->ticketType[$ticket_data['ticket_type_id']] ?? "");
|
$replaceData = str_replace("Claim-", "", $this->ticketType[$ticket_data['ticket_type_id']] ?? "");
|
||||||
} else {
|
} else if ($value == 'emp_name'){
|
||||||
$replaceData = isset($ticket_data[$value]) ? strtoupper($ticket_data[$value]) : '';
|
if(empty($ticket_data['emp_id'])){
|
||||||
|
$replaceData = $ticket_data['emp_name']??"";
|
||||||
|
}
|
||||||
|
}else if ($value == 'insured_name'){
|
||||||
|
if(empty($ticket_data['insured_emp_id'])){
|
||||||
|
$replaceData = $ticket_data['insured_name']?? "";
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
$replaceData = isset($ticket_data[$value]) ? $ticket_data[$value] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = str_replace($key, $replaceData, $content);
|
$content = str_replace($key, $replaceData, $content);
|
||||||
@ -1434,4 +1454,72 @@ class TicketController extends BaseController
|
|||||||
return $lastMatchedStatus;
|
return $lastMatchedStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPolicyStartDate()
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = $this->request->getPost();
|
||||||
|
$client_policy_id = $data['policy_id'];
|
||||||
|
$policy_start_date = $this->clientPolicyModel->select('policy_start_date')->where('id', $client_policy_id)->first()['policy_start_date'];
|
||||||
|
// dd($data);
|
||||||
|
if (isset($data['employeeId']) && $data['employeeId'] != "" && $data['employeeId'] != null) {
|
||||||
|
// dd($data);
|
||||||
|
$emp_id = $data['employeeId'];
|
||||||
|
$empData = $this->employeeModel->select('dob,doj')->where('id',$emp_id)->findAll();
|
||||||
|
|
||||||
|
if (!empty($empData) && $empData != "" && $empData != null ) {
|
||||||
|
foreach ($empData as &$emp) { // Loop through the data
|
||||||
|
$emp['dob'] = date('d/m/Y', strtotime($emp['dob']));
|
||||||
|
$emp['doj'] = date('d/m/Y', strtotime($emp['doj']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($empData){
|
||||||
|
return $this->respond(['status' => true, 'minDate' => $policy_start_date,'empData'=> $empData], 200);
|
||||||
|
}else{
|
||||||
|
return $this->respond(['status' => false, 'message' => "Policy Not Found"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// dd($policy_start_date);
|
||||||
|
if ($policy_start_date) {
|
||||||
|
return $this->respond(['status' => true, 'minDate' => $policy_start_date], 200);
|
||||||
|
} else {
|
||||||
|
return $this->respond(['status' => false, 'message' => "Policy Not Found"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPoliciesbyEmpID() {
|
||||||
|
$received_data = $this->request->getPost();
|
||||||
|
$emp_id = $received_data['emp_id'];
|
||||||
|
|
||||||
|
// Get all client policy IDs for the given employee
|
||||||
|
$policies = $this->employeePolicyModel
|
||||||
|
->select('client_policy_id')
|
||||||
|
->where('employee_id', $emp_id)
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
if (empty($policies)) {
|
||||||
|
return []; // Return empty if no policies found
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract client policy IDs into an array
|
||||||
|
$policy_ids = array_column($policies, 'client_policy_id');
|
||||||
|
|
||||||
|
// Fetch all policy names and IDs in one query
|
||||||
|
$policyNameandID = $this->clientPolicyModel
|
||||||
|
->select('CONCAT(policy_type.policy_type, "-", client_policy.policy_no) as client_policy_name, client_policy.id as client_policy_value,client_policy.policy_type_id')
|
||||||
|
->join('policy_type', 'policy_type.id = client_policy.policy_type_id AND policy_type.is_active = 1')
|
||||||
|
->whereIn('client_policy.id', $policy_ids)
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
// dd($policyNameandID);
|
||||||
|
if ($policyNameandID){
|
||||||
|
|
||||||
|
return $this->respond(['status'=>true,'policy_data'=> $policyNameandID]);
|
||||||
|
}else{
|
||||||
|
return $this->respond(['status'=>false,'message'=> "Policy Not Found"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,6 +72,8 @@ class TicketMasterModel extends Model
|
|||||||
'non_id_reason',
|
'non_id_reason',
|
||||||
'head_rejection_reason',
|
'head_rejection_reason',
|
||||||
'pay_initiate_date',
|
'pay_initiate_date',
|
||||||
|
'emp_personal_mail',
|
||||||
|
'client_policy_id'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,15 @@
|
|||||||
|
<style>
|
||||||
|
.select2-selection__choice {
|
||||||
|
background-color: #0a8794 !important;
|
||||||
|
color: white !important;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-selection__choice__remove {
|
||||||
|
color: white !important;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -8,14 +20,27 @@
|
|||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<!-- <label for="ticket_auto_query_note">Add Notes</label> -->
|
<!-- <label for="ticket_auto_query_note">Add Notes</label> -->
|
||||||
<div class="form-row" id="rac_rate_dropdown">
|
<div class="form-row" id="rac_rate_dropdown">
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-9">
|
||||||
<select id="ticket_mail_auto_query_customButton" class="form-control">
|
<label>Documents</label> <br />
|
||||||
<option value="">Documents</option>
|
<select class="form-control" name="documents[]" id="ticket_mail_auto_query_customButton" multiple>
|
||||||
<?php foreach ($ticket_check_list as $value): ?>
|
<?php foreach ($ticket_check_list as $value): ?>
|
||||||
<option value="<?= $value['document']; ?>"><?= $value['document']; ?></option>
|
<option value="<?= $value['document']; ?>"
|
||||||
|
<?php //
|
||||||
|
// if (!isset($getData) || (isset($getData['documents']) && in_array($value['document'], $getData['documents']))) {
|
||||||
|
// echo 'selected';
|
||||||
|
// }
|
||||||
|
?>>
|
||||||
|
<?= $value['document']; ?>
|
||||||
|
</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div style="padding-top:30px;padding-left:20px;" class="col-md-3">
|
||||||
|
<button type="button" class="btn btn-primary" id="insertSelectedDocumnets">Insert Documents</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<textarea class="form-control" id="ticket_auto_query_note" name="note" rows="3"
|
<textarea class="form-control" id="ticket_auto_query_note" name="note" rows="3"
|
||||||
placeholder="Enter Text"></textarea>
|
placeholder="Enter Text"></textarea>
|
||||||
@ -33,141 +58,136 @@
|
|||||||
<!-- end -->
|
<!-- end -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
const auto_query_editor = Jodit.make("#ticket_auto_query_note", editorConfig);
|
// $('#ticket_mail_auto_query_customButton').select2();
|
||||||
// var mail_content = `<?= isset($ticket_note['note'])?$ticket_note['note']:'' ?> `;
|
$('#ticket_mail_auto_query_customButton').select2({
|
||||||
// console.log('query_content', mail_content);
|
placeholder: "Select Documents",
|
||||||
// $('.jodit-wysiwyg').html(mail_content);
|
allowClear: true,
|
||||||
|
closeOnSelect: false, // This is the key option to keep the dropdown open
|
||||||
|
tags: true
|
||||||
|
});
|
||||||
|
|
||||||
let lastActiveField = null;
|
$("textarea.select2-search__field").attr('rows', '1');
|
||||||
auto_query_editor.events.on("focus", function() {
|
$("textarea.select2-search__field").css('resize', 'none');
|
||||||
lastActiveField = auto_query_editor;
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#ticket_auto_query_note").on("focus", function() {
|
const auto_query_editor = Jodit.make("#ticket_auto_query_note", editorConfig);
|
||||||
lastActiveField = this;
|
let lastActiveField = null;
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('change', function(event) {
|
auto_query_editor.events.on("focus", function() {
|
||||||
|
lastActiveField = auto_query_editor;
|
||||||
|
});
|
||||||
|
|
||||||
var target = event.target;
|
$("#insertSelectedDocumnets").on("click", function() {
|
||||||
|
// Get all selected documents
|
||||||
|
const selectedDocuments = $("#ticket_mail_auto_query_customButton").val();
|
||||||
|
|
||||||
if (target.matches('#ticket_mail_auto_query_customButton')) {
|
if (!selectedDocuments || selectedDocuments.length === 0) {
|
||||||
|
toastr.warning('Please select documents first', 'Warning');
|
||||||
let placeholderValue = $(target).val();
|
return;
|
||||||
if (!placeholderValue) return;
|
|
||||||
|
|
||||||
if (lastActiveField) {
|
|
||||||
if (lastActiveField.id === "ticket_auto_query_note") {
|
|
||||||
insertAtCursor(lastActiveField, placeholderValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(target).val('');
|
if (lastActiveField === auto_query_editor) {
|
||||||
}
|
// Insert each document on a new line
|
||||||
});
|
selectedDocuments.forEach(document => {
|
||||||
|
auto_query_editor.selection.insertHTML(document + '<br>');
|
||||||
|
});
|
||||||
|
|
||||||
function insertAtCursor(input, textToInsert) {
|
// Clear the selection
|
||||||
if (document.selection) {
|
$("#ticket_mail_auto_query_customButton").val(null).trigger('change');
|
||||||
input.focus();
|
} else {
|
||||||
var sel = document.selection.createRange();
|
toastr.warning('Please focus on the text area first', 'Warning');
|
||||||
sel.text = textToInsert;
|
|
||||||
} else if (input.selectionStart || input.selectionStart === 0) {
|
|
||||||
let startPos = input.selectionStart;
|
|
||||||
let endPos = input.selectionEnd;
|
|
||||||
input.value = input.value.substring(0, startPos) + textToInsert + input.value.substring(endPos, input.value.length);
|
|
||||||
input.selectionStart = input.selectionEnd = startPos + textToInsert.length;
|
|
||||||
} else {
|
|
||||||
input.value += textToInsert;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
url = '<?= base_url('ticket/note/1') ?>';
|
|
||||||
data = {
|
|
||||||
id: $('#ticket_master_id').val(),
|
|
||||||
is_auto_query: 1
|
|
||||||
};
|
|
||||||
$.ajax({
|
|
||||||
url: url,
|
|
||||||
data: data,
|
|
||||||
type: 'POST',
|
|
||||||
success: function(res) {
|
|
||||||
console.log('auto query res', res)
|
|
||||||
if (res.status == true) {
|
|
||||||
$('.jodit-wysiwyg').html(res.data.note);
|
|
||||||
$('#query_note_id').val(res.data.id);
|
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
error: function(xhr, status, error) {
|
|
||||||
console.error(xhr.responseText);
|
|
||||||
console.error(status, error);
|
|
||||||
setTimeout(function() {
|
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
|
||||||
toastr.warning('Something Went Wrong!', 'warning');
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#ticket_auto_query").submit(function(event) {
|
// $("#ticket_mail_auto_query_customButton").change(function (){
|
||||||
|
// event.stopPropagation();
|
||||||
|
// })
|
||||||
|
|
||||||
event.preventDefault();
|
$(document).ready(function() {
|
||||||
$('.loader').fadeIn();
|
|
||||||
$('.loader-mask').fadeIn();
|
|
||||||
|
|
||||||
var url = '<?= base_url("/ticket/note/2"); ?>';
|
url = '<?= base_url('ticket/note/1') ?>';
|
||||||
var formData = $(this).serializeArray();
|
data = {
|
||||||
var ticket_id = $('#ticket_master_id').val();
|
id: $('#ticket_master_id').val(),
|
||||||
if (ticket_id != null && ticket_id != '') {
|
is_auto_query: 1
|
||||||
formData.push({
|
};
|
||||||
name: 'ticket_id',
|
$.ajax({
|
||||||
value: ticket_id
|
url: url,
|
||||||
});
|
data: data,
|
||||||
}
|
type: 'POST',
|
||||||
var primary_key = $('#query_note_id').val();
|
success: function(res) {
|
||||||
if (primary_key != null && primary_key != '') {
|
console.log('auto query res', res)
|
||||||
formData.push({
|
if (res.status == true) {
|
||||||
name: 'id',
|
$('.jodit-wysiwyg').html(res.data.note);
|
||||||
value: primary_key
|
$('#query_note_id').val(res.data.id);
|
||||||
});
|
}
|
||||||
}
|
},
|
||||||
formData.push({
|
error: function(xhr, status, error) {
|
||||||
name: 'is_auto_query',
|
console.error(xhr.responseText);
|
||||||
value: 1
|
console.error(status, error);
|
||||||
})
|
setTimeout(function() {
|
||||||
console.log(formData);
|
$('.loader').fadeOut();
|
||||||
sendAjaxRequestForGlobal(url, 'POST', formData, function(response) {
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
if (response.status == true) {
|
toastr.warning('Something Went Wrong!', 'warning');
|
||||||
$('.loader').fadeOut();
|
}, 1000);
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
|
||||||
toastr.success('Note Added Successfully', 'Success');
|
|
||||||
// console.log("Respone id is ")
|
|
||||||
// console.log(response.id);
|
|
||||||
$('#query_note_id').val(response.id);
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
|
||||||
let message = response.message;
|
|
||||||
toastr.error(message, 'ERROR');
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
$("#ticket_auto_query").submit(function(event) {
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
|
var url = '<?= base_url("/ticket/note/2"); ?>';
|
||||||
|
var formData = $(this).serializeArray();
|
||||||
|
var ticket_id = $('#ticket_master_id').val();
|
||||||
|
if (ticket_id != null && ticket_id != '') {
|
||||||
|
formData.push({
|
||||||
|
name: 'ticket_id',
|
||||||
|
value: ticket_id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var primary_key = $('#query_note_id').val();
|
||||||
|
if (primary_key != null && primary_key != '') {
|
||||||
|
formData.push({
|
||||||
|
name: 'id',
|
||||||
|
value: primary_key
|
||||||
|
});
|
||||||
|
}
|
||||||
|
formData.push({
|
||||||
|
name: 'is_auto_query',
|
||||||
|
value: 1
|
||||||
|
})
|
||||||
|
console.log(formData);
|
||||||
|
sendAjaxRequestForGlobal(url, 'POST', formData, function(response) {
|
||||||
|
if (response.status == true) {
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
toastr.success('Note Added Successfully', 'Success');
|
||||||
|
// console.log("Respone id is ")
|
||||||
|
// console.log(response.id);
|
||||||
|
$('#query_note_id').val(response.id);
|
||||||
|
|
||||||
|
|
||||||
}, function(xhr, status, error) {
|
} else {
|
||||||
console.error('Error fetching data:', error);
|
$('.loader').fadeOut();
|
||||||
console.error(xhr.responseText);
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
toastr.error('An error occurred while fetching the report page.', 'ERROR');
|
let message = response.message;
|
||||||
|
toastr.error(message, 'ERROR');
|
||||||
|
}
|
||||||
|
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
}, function(xhr, status, error) {
|
||||||
|
console.error('Error fetching data:', error);
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
toastr.error('An error occurred while fetching the report page.', 'ERROR');
|
||||||
|
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -1,3 +1,17 @@
|
|||||||
|
<style>
|
||||||
|
.readonly-color {
|
||||||
|
background-color: #e0e0e0;
|
||||||
|
/* Darker background */
|
||||||
|
color: #666;
|
||||||
|
/* Darker text color */
|
||||||
|
}
|
||||||
|
|
||||||
|
.readonly-select {
|
||||||
|
pointer-events: none;
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="<?= !isset($ticket_data) ? "card" : "" ?>" style="margin-right: 23px;">
|
<div class="<?= !isset($ticket_data) ? "card" : "" ?>" style="margin-right: 23px;">
|
||||||
@ -73,9 +87,8 @@
|
|||||||
<label for="policy_no">Policy No <span class="text-danger"></span></label>
|
<label for="policy_no">Policy No <span class="text-danger"></span></label>
|
||||||
<input type="text" class="form-control" id="policy_no"
|
<input type="text" class="form-control" id="policy_no"
|
||||||
value="<?= isset($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>"
|
value="<?= isset($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>"
|
||||||
name="policy_no" placeholder="Policy Number" >
|
name="policy_no" placeholder="Policy Number">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="tpa_id">TPA ID <span class="text-danger"></span></label>
|
<label for="tpa_id">TPA ID <span class="text-danger"></span></label>
|
||||||
<input type="text" class="form-control" id="tpa_no" placeholder="Enter TPA ID"
|
<input type="text" class="form-control" id="tpa_no" placeholder="Enter TPA ID"
|
||||||
@ -97,6 +110,13 @@
|
|||||||
name="emp_mail" required>
|
name="emp_mail" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-3">
|
||||||
|
<label for="emp_personal_mail">Employee Personal Mail ID</label>
|
||||||
|
<input type="text" class="form-control" id="emp_personal_mail" placeholder="Enter EMP Personal Mail"
|
||||||
|
value="<?= isset($ticket_data['emp_personal_mail']) ? $ticket_data['emp_personal_mail'] : '' ?>"
|
||||||
|
name="emp_personal_mail">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="client_name">Corporate Name <span class="text-danger">*</span></label>
|
<label for="client_name">Corporate Name <span class="text-danger">*</span></label>
|
||||||
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
|
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
|
||||||
@ -108,6 +128,20 @@
|
|||||||
<input type=hidden id="insurer_id" name="insurer_id" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
|
<input type=hidden id="insurer_id" name="insurer_id" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
|
||||||
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly required>
|
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly required>
|
||||||
</div>
|
</div>
|
||||||
|
<input type="hidden" id="empIDHidden" onchange="getClientPolicy()">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Policy <span class="text-danger">*</span></label>
|
||||||
|
<select id="emp_client_policy" name="client_policy_id"
|
||||||
|
class="form-control custom-select" required onchange="setMinDateDOA(this.value)">
|
||||||
|
<?php if (!empty($ticket_data['client_policy_id'])) { ?>
|
||||||
|
<option value="<?= $ticket_data['client_policy_id'] ?>"><?= $ticket_data['client_policy_id_text'] ?></option>
|
||||||
|
<?php } else { ?>
|
||||||
|
<option value="">Policy</option>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="tpa_id">TPA <span class="text-danger"></span></label>
|
<label for="tpa_id">TPA <span class="text-danger"></span></label>
|
||||||
@ -120,12 +154,12 @@
|
|||||||
<select class="form-control" id="acm_id" name="acm_id" required>
|
<select class="form-control" id="acm_id" name="acm_id" required>
|
||||||
<!-- <option value="0">Select Account Manager</option> -->
|
<!-- <option value="0">Select Account Manager</option> -->
|
||||||
<?php
|
<?php
|
||||||
if (isset($acms) && count($acms)) {
|
if (isset($acms) && count($acms)) {
|
||||||
foreach ($acms as $key => $value) {
|
foreach ($acms as $key => $value) {
|
||||||
$selected = (isset($ticket_data) && $ticket_data['acm_id'] == $value['id']) ? 'selected' : '';
|
$selected = (isset($ticket_data) && $ticket_data['acm_id'] == $value['id']) ? 'selected' : '';
|
||||||
echo "<option value=" . $value['id'] . " $selected >" . $value['first_name'] . "</option>";
|
echo "<option value=" . $value['id'] . " $selected >" . $value['first_name'] . "</option>";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -145,12 +179,12 @@
|
|||||||
<select class="form-control" id="claim_status_id" name="claim_status_id" required>
|
<select class="form-control" id="claim_status_id" name="claim_status_id" required>
|
||||||
<!-- <option value="0">Select status</option> -->
|
<!-- <option value="0">Select status</option> -->
|
||||||
<?php
|
<?php
|
||||||
if (isset($claim_status) && count($claim_status)) {
|
if (isset($claim_status) && count($claim_status)) {
|
||||||
foreach ($claim_status as $key => $value) {
|
foreach ($claim_status as $key => $value) {
|
||||||
$selected = (isset($ticket_data) && $ticket_data['claim_status_id'] == $value['id']) ? 'selected' : '';
|
$selected = (isset($ticket_data) && $ticket_data['claim_status_id'] == $value['id']) ? 'selected' : '';
|
||||||
echo "<option value=" . $value['id'] . " $selected>" . $value['claim_status'] . "</option>";
|
echo "<option value=" . $value['id'] . " $selected>" . $value['claim_status'] . "</option>";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -160,12 +194,12 @@
|
|||||||
<select class="form-control" id="priority" name="priority" required>
|
<select class="form-control" id="priority" name="priority" required>
|
||||||
<!-- <option value="0">Select Priority</option> -->
|
<!-- <option value="0">Select Priority</option> -->
|
||||||
<?php
|
<?php
|
||||||
if (isset($priorityType) && count($priorityType)) {
|
if (isset($priorityType) && count($priorityType)) {
|
||||||
foreach ($priorityType as $key => $value) {
|
foreach ($priorityType as $key => $value) {
|
||||||
$selected = (isset($ticket_data) && $ticket_data['priority'] == $key) ? 'selected' : '';
|
$selected = (isset($ticket_data) && $ticket_data['priority'] == $key) ? 'selected' : '';
|
||||||
echo "<option value=" . $key . " $selected>" . $value . "</option>";
|
echo "<option value=" . $key . " $selected>" . $value . "</option>";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -347,12 +381,12 @@
|
|||||||
<select class="form-control" id="non_id_reason" name="non_id_reason">
|
<select class="form-control" id="non_id_reason" name="non_id_reason">
|
||||||
<option value="">Select Reason</option>
|
<option value="">Select Reason</option>
|
||||||
<?php
|
<?php
|
||||||
if (isset($nonIDReason) && count($nonIDReason)) {
|
if (isset($nonIDReason) && count($nonIDReason)) {
|
||||||
foreach ($nonIDReason as $key => $value) {
|
foreach ($nonIDReason as $key => $value) {
|
||||||
$selected = (isset($ticket_data) && $ticket_data['non_id_reason'] == $key) ? 'selected' : '';
|
$selected = (isset($ticket_data) && $ticket_data['non_id_reason'] == $key) ? 'selected' : '';
|
||||||
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
|
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -389,12 +423,23 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
let GlobelExtraFields = [];
|
let GlobelExtraFields = [];
|
||||||
|
var doa;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$("#emp_client_policy").select2();
|
||||||
|
|
||||||
|
var policy_id = $("#emp_client_policy").val();
|
||||||
|
if (policy_id != null && policy_id != "") {
|
||||||
|
$("#emp_client_policy").addClass('readonly-select').select2('destroy');
|
||||||
|
}
|
||||||
|
// getClientPolicy();
|
||||||
var doa = flatpickr("#doa", {
|
var doa = flatpickr("#doa", {
|
||||||
dateFormat: "d/m/Y",
|
dateFormat: "d/m/Y",
|
||||||
allowInput: false
|
allowInput: false,
|
||||||
|
onChange: function(selectedDates) {
|
||||||
|
let selectedDOA = selectedDates[0]; // Get selected DOA date
|
||||||
|
dod.set("minDate", selectedDOA); // Set DOD minDate to DOA
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var dod = flatpickr("#dod", {
|
var dod = flatpickr("#dod", {
|
||||||
@ -576,11 +621,11 @@
|
|||||||
|
|
||||||
var selectedClaimStatus = $('#claim_status_id').val();
|
var selectedClaimStatus = $('#claim_status_id').val();
|
||||||
var $thirdClass = $(`.${thirdClass}`);
|
var $thirdClass = $(`.${thirdClass}`);
|
||||||
var hasValue = $thirdClass.find('input, textarea, select').filter(function () {
|
var hasValue = $thirdClass.find('input, textarea, select').filter(function() {
|
||||||
return $(this).val().trim() !== ''; // Check if at least one field is not empty
|
return $(this).val().trim() !== ''; // Check if at least one field is not empty
|
||||||
}).length > 0;
|
}).length > 0;
|
||||||
|
|
||||||
$thirdClass.each(function () {
|
$thirdClass.each(function() {
|
||||||
var id = $(this).find('[id]').first().attr('id');
|
var id = $(this).find('[id]').first().attr('id');
|
||||||
var $label = $(this).find('label');
|
var $label = $(this).find('label');
|
||||||
var $thisDiv = $(this);
|
var $thisDiv = $(this);
|
||||||
@ -595,12 +640,12 @@
|
|||||||
if ($label.length && !$label.find('.text-danger').length) {
|
if ($label.length && !$label.find('.text-danger').length) {
|
||||||
$label.append(' <span class="text-danger">*</span>');
|
$label.append(' <span class="text-danger">*</span>');
|
||||||
}
|
}
|
||||||
console.log("input from if ",$inputs);
|
console.log("input from if ", $inputs);
|
||||||
// $inputs.attr('required', true);
|
// $inputs.attr('required', true);
|
||||||
$('.' + thirdClass).find('input, textarea,select').attr('required', true);
|
$('.' + thirdClass).find('input, textarea,select').attr('required', true);
|
||||||
} else {
|
} else {
|
||||||
$label.find('.text-danger').remove();
|
$label.find('.text-danger').remove();
|
||||||
console.log("input ",$inputs);
|
console.log("input ", $inputs);
|
||||||
// $inputs.prop('required', false);
|
// $inputs.prop('required', false);
|
||||||
$('.' + thirdClass).find('input, textarea,select').attr('required', false);
|
$('.' + thirdClass).find('input, textarea,select').attr('required', false);
|
||||||
}
|
}
|
||||||
@ -647,109 +692,325 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// function addRequiredFieldSymbol(field_name) {
|
// function addRequiredFieldSymbol(field_name) {
|
||||||
// // Find the field with the given name
|
// // Find the field with the given name
|
||||||
// var $field = $(`[name="${field_name}"]`);
|
// var $field = $(`[name="${field_name}"]`);
|
||||||
|
|
||||||
// if ($field.length) {
|
// if ($field.length) {
|
||||||
// // Find the parent div of this field
|
// // Find the parent div of this field
|
||||||
// var $parentDiv = $field.closest('div');
|
// var $parentDiv = $field.closest('div');
|
||||||
|
|
||||||
// if ($parentDiv.length) {
|
// if ($parentDiv.length) {
|
||||||
// // Get the classes as an array
|
// // Get the classes as an array
|
||||||
// var classes = $parentDiv.attr('class') ? $parentDiv.attr('class').split(/\s+/) : [];
|
// var classes = $parentDiv.attr('class') ? $parentDiv.attr('class').split(/\s+/) : [];
|
||||||
|
|
||||||
// if (classes.length > 0) {
|
// if (classes.length > 0) {
|
||||||
// // Get the last class in the array
|
// // Get the last class in the array
|
||||||
// var lastClass = classes[classes.length - 1];
|
// var lastClass = classes[classes.length - 1];
|
||||||
|
|
||||||
// // Find all divs with this last class
|
// // Find all divs with this last class
|
||||||
// var $allDivsWithClass = $(`.${lastClass}`);
|
// var $allDivsWithClass = $(`.${lastClass}`);
|
||||||
|
|
||||||
// // Add asterisk to all labels within these divs
|
// // Add asterisk to all labels within these divs
|
||||||
// $allDivsWithClass.each(function() {
|
// $allDivsWithClass.each(function() {
|
||||||
// var $label = $(this).find('label');
|
// var $label = $(this).find('label');
|
||||||
// if ($label.length && !$label.find('.text-danger').length) {
|
// if ($label.length && !$label.find('.text-danger').length) {
|
||||||
// $label.append(' <span class="text-danger">*</span>');
|
// $label.append(' <span class="text-danger">*</span>');
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// console.log(`Added required symbol to ${$allDivsWithClass.length} labels with class "${lastClass}"`);
|
// console.log(`Added required symbol to ${$allDivsWithClass.length} labels with class "${lastClass}"`);
|
||||||
// } else {
|
// } else {
|
||||||
// console.warn(`Parent div for field "${field_name}" has no classes`);
|
// console.warn(`Parent div for field "${field_name}" has no classes`);
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
// console.warn(`No parent div found for field name="${field_name}"`);
|
// console.warn(`No parent div found for field name="${field_name}"`);
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
// console.warn(`No field found with name="${field_name}"`);
|
// console.warn(`No field found with name="${field_name}"`);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
function addRequiredFieldSymbolByClass(className) {
|
function addRequiredFieldSymbolByClass(className) {
|
||||||
var $divsWithClass = $(`.${className}`);
|
var $divsWithClass = $(`.${className}`);
|
||||||
|
|
||||||
if ($divsWithClass.length) {
|
if ($divsWithClass.length) {
|
||||||
let extrafieldsArray = $('#extra_fields_array_for_validate').val();
|
let extrafieldsArray = $('#extra_fields_array_for_validate').val();
|
||||||
try {
|
try {
|
||||||
extrafieldsArray = JSON.parse(extrafieldsArray); // Convert string to object
|
extrafieldsArray = JSON.parse(extrafieldsArray); // Convert string to object
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Invalid JSON format in extra_fields_array_for_validate:", error);
|
console.error("Invalid JSON format in extra_fields_array_for_validate:", error);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectedClaimStatus = $('#claim_status_id').val();
|
||||||
|
console.log("Selected claim status ID:", selectedClaimStatus);
|
||||||
|
console.log("Extra Field Array:", extrafieldsArray[selectedClaimStatus]);
|
||||||
|
|
||||||
|
// ✅ Check if at least one field inside the class has a value
|
||||||
|
// var hasValue = $divsWithClass.find('input, textarea, select').filter(function () {
|
||||||
|
// return $(this).val().trim() !== ''; // Check if at least one field is not empty
|
||||||
|
// }).length > 0;
|
||||||
|
|
||||||
|
// $divsWithClass.each(function () {
|
||||||
|
// var id = $(this).find('[id]').first().attr('id');
|
||||||
|
// var $label = $(this).find('label');
|
||||||
|
// var $thisDiv = $(this);
|
||||||
|
// var $inputs = $thisDiv.find('input, textarea, select');
|
||||||
|
|
||||||
|
|
||||||
|
// // ✅ Condition 1: Check if this ID is in extraFieldsArray (required by status)
|
||||||
|
// var shouldAddRequired = extrafieldsArray[selectedClaimStatus] && extrafieldsArray[selectedClaimStatus].includes(id);
|
||||||
|
|
||||||
|
// // ✅ Condition 2: If any field in the class has a value, make all required
|
||||||
|
// if (shouldAddRequired || hasValue) {
|
||||||
|
// if ($label.length && !$label.find('.text-danger').length) {
|
||||||
|
// $label.append(' <span class="text-danger">*</span>');
|
||||||
|
// }
|
||||||
|
// console.log("input from if ",$inputs);
|
||||||
|
// $inputs.attr('required', true);
|
||||||
|
// } else {
|
||||||
|
// $label.find('.text-danger').remove();
|
||||||
|
// console.log("input ",$inputs);
|
||||||
|
// $inputs.prop('required', false);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
console.log(`Processed ${$divsWithClass.length} labels with class "${className}"`);
|
||||||
|
} else {
|
||||||
|
console.warn(`No divs found with class="${className}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
var selectedClaimStatus = $('#claim_status_id').val();
|
|
||||||
console.log("Selected claim status ID:", selectedClaimStatus);
|
|
||||||
console.log("Extra Field Array:", extrafieldsArray[selectedClaimStatus]);
|
|
||||||
|
|
||||||
// ✅ Check if at least one field inside the class has a value
|
|
||||||
// var hasValue = $divsWithClass.find('input, textarea, select').filter(function () {
|
|
||||||
// return $(this).val().trim() !== ''; // Check if at least one field is not empty
|
|
||||||
// }).length > 0;
|
|
||||||
|
|
||||||
// $divsWithClass.each(function () {
|
|
||||||
// var id = $(this).find('[id]').first().attr('id');
|
|
||||||
// var $label = $(this).find('label');
|
|
||||||
// var $thisDiv = $(this);
|
|
||||||
// var $inputs = $thisDiv.find('input, textarea, select');
|
|
||||||
|
|
||||||
|
|
||||||
// // ✅ Condition 1: Check if this ID is in extraFieldsArray (required by status)
|
|
||||||
// var shouldAddRequired = extrafieldsArray[selectedClaimStatus] && extrafieldsArray[selectedClaimStatus].includes(id);
|
|
||||||
|
|
||||||
// // ✅ Condition 2: If any field in the class has a value, make all required
|
|
||||||
// if (shouldAddRequired || hasValue) {
|
|
||||||
// if ($label.length && !$label.find('.text-danger').length) {
|
|
||||||
// $label.append(' <span class="text-danger">*</span>');
|
|
||||||
// }
|
|
||||||
// console.log("input from if ",$inputs);
|
|
||||||
// $inputs.attr('required', true);
|
|
||||||
// } else {
|
|
||||||
// $label.find('.text-danger').remove();
|
|
||||||
// console.log("input ",$inputs);
|
|
||||||
// $inputs.prop('required', false);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
console.log(`Processed ${$divsWithClass.length} labels with class "${className}"`);
|
|
||||||
} else {
|
|
||||||
console.warn(`No divs found with class="${className}"`);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$('#mode_of_intimation').change(function(){
|
$('#mode_of_intimation').change(function() {
|
||||||
console.log("function called");
|
console.log("function called");
|
||||||
var mode_of_intimation = $('#mode_of_intimation').val();
|
var mode_of_intimation = $('#mode_of_intimation').val();
|
||||||
console.log('mode of ',mode_of_intimation);
|
console.log('mode of ', mode_of_intimation);
|
||||||
|
|
||||||
if (mode_of_intimation == 2){
|
if (mode_of_intimation == 2) {
|
||||||
$('#pod_no').attr('required', 'required');
|
$('#pod_no').attr('required', 'required');
|
||||||
$('#pod_no_label_1_span').text("*");
|
$('#pod_no_label_1_span').text("*");
|
||||||
}else{
|
} else {
|
||||||
$('#pod_no').removeAttr('required', false);
|
$('#pod_no').removeAttr('required', false);
|
||||||
$('#pod_no_label_1_span').text("");
|
$('#pod_no_label_1_span').text("");
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#empIDHidden").change(function() {
|
||||||
|
console.log("change is detected in hidden branch id");
|
||||||
|
getClientPolicy();
|
||||||
|
})
|
||||||
|
|
||||||
|
function getClientPolicy() {
|
||||||
|
console.log("get policy function called");
|
||||||
|
hiddenData = $("#empIDHidden").val();
|
||||||
|
hiddenData = JSON.parse(hiddenData);
|
||||||
|
console.log('employee id ', hiddenData['emp_id']);
|
||||||
|
data = {
|
||||||
|
emp_id: hiddenData['emp_id']
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: '<?= base_url("/ticket/getPoliciesbyEmpID") ?>',
|
||||||
|
type: "POST",
|
||||||
|
data: data,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(res) {
|
||||||
|
|
||||||
|
console.log('getClientAndBranchAndPolicy', res);
|
||||||
|
if (res.status == true) {
|
||||||
|
console.log("data is received2");
|
||||||
|
policyList = res.policy_data;
|
||||||
|
// appendClients(res.client_data);
|
||||||
|
// appendClientsFoerMobileSearch(res.client_data);
|
||||||
|
appendPolicyDropdown(policyList);
|
||||||
|
console.log("after function");
|
||||||
|
} else {
|
||||||
|
console.log('No data found');
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
console.error(status, error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//append the clients policy data to the modal
|
||||||
|
// function appendPolicyDropdown(data) {
|
||||||
|
// console.log("second function is called : ", data);
|
||||||
|
// let ticket_type = $('#ticket_type_id').val();
|
||||||
|
// hiddenData = $("#empIDHidden").val();
|
||||||
|
// hiddenData = JSON.parse(hiddenData);
|
||||||
|
// let branch_id = hiddenData['branch_id'];
|
||||||
|
// let policy_id = hiddenData['policy_id'];
|
||||||
|
// let searchType = hiddenData['searchType'];
|
||||||
|
// data = data[branch_id];
|
||||||
|
// console.log("branch filtered data ", data);
|
||||||
|
// $('#emp_client_policy').empty();
|
||||||
|
|
||||||
|
// $('#emp_client_policy').append($('<option>', {
|
||||||
|
// value: '',
|
||||||
|
// text: 'Select Client Policy'
|
||||||
|
// }));
|
||||||
|
|
||||||
|
// $.each(data, function(index, item) {
|
||||||
|
// // console.log('inside the loop for this time count : ',item);
|
||||||
|
// console.log("debugging policy type id : ", item.id);
|
||||||
|
// if (ticket_type == 1) {
|
||||||
|
// console.log("inside if condition 1");
|
||||||
|
|
||||||
|
// if (item.policy_type_id == 2 || item.policy_type_id == 3 || item.policy_type_id == 4 || item
|
||||||
|
// .policy_type_id == 5) {
|
||||||
|
// console.log("inside if condition 2");
|
||||||
|
|
||||||
|
// if (policy_id == item.id) {
|
||||||
|
// console.log("inside if condition 3");
|
||||||
|
|
||||||
|
// var option = $('<option>', {
|
||||||
|
// value: item.id,
|
||||||
|
// text: item.policy_type + '-' + item.policy_no,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $('#emp_client_policy').append(option).select2();
|
||||||
|
// if (searchType != null && searchType != "") {
|
||||||
|
// $('#emp_client_policy').val(item.id).addClass('readonly-select').select2('destroy');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else if (ticket_type == 2) {
|
||||||
|
|
||||||
|
// if (item.policy_type_id == 1) {
|
||||||
|
// var option = $('<option>', {
|
||||||
|
// value: item.id,
|
||||||
|
// text: item.policy_type + '-' + item.policy_no,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $('#emp_client_policy').append(option).select2();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// } else if (ticket_type == 3) {
|
||||||
|
|
||||||
|
// if (item.policy_type_id == 6) {
|
||||||
|
// var option = $('<option>', {
|
||||||
|
// value: item.id,
|
||||||
|
// text: item.policy_type + '-' + item.policy_no,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $('#emp_client_policy').append(option).select2();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// } else if (ticket_type == 4) {
|
||||||
|
|
||||||
|
// if (item.policy_type == 7) {
|
||||||
|
// var option = $('<option>', {
|
||||||
|
// value: item.id,
|
||||||
|
// text: item.policy_type + '-' + item.policy_no,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $('#emp_client_policy').append(option).select2();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// });
|
||||||
|
// console.log("loop is completed");
|
||||||
|
// setMinDateDOA(policy_id);
|
||||||
|
// }
|
||||||
|
|
||||||
|
function appendPolicyDropdown(data) {
|
||||||
|
hiddenData = $("#empIDHidden").val();
|
||||||
|
hiddenData = JSON.parse(hiddenData);
|
||||||
|
|
||||||
|
console.log("second function is called : ", data);
|
||||||
|
let ticket_type = $('#ticket_type_id').val();
|
||||||
|
$('#emp_client_policy').empty();
|
||||||
|
$('#emp_client_policy').append($('<option>', {
|
||||||
|
value: '',
|
||||||
|
text: 'Select Client Policy'
|
||||||
|
}));
|
||||||
|
|
||||||
|
var policyAppendCount = 0;
|
||||||
|
$.each(data, function(index, item) {
|
||||||
|
// console.log(item);
|
||||||
|
|
||||||
|
if (ticket_type == 1 && item.policy_type_id != 1) {
|
||||||
|
$('#emp_client_policy').append($('<option>', {
|
||||||
|
value: item.client_policy_value,
|
||||||
|
text: item.client_policy_name
|
||||||
|
}));
|
||||||
|
policyAppendCount++;
|
||||||
|
if (hiddenData['searchType'] != null && hiddenData['searchType'] != "" && hiddenData['policy_id'] != null && hiddenData['policy_id'] != "") {
|
||||||
|
// $('#emp_client_policy').select2();
|
||||||
|
$("#emp_client_policy").select2();
|
||||||
|
$('#emp_client_policy').val(hiddenData['policy_id']).addClass('readonly-select').select2('destroy').trigger("change");
|
||||||
|
} else {
|
||||||
|
// $('#emp_client_policy').append($('<option>', {
|
||||||
|
// value: item.client_policy_value,
|
||||||
|
// text: item.client_policy_name
|
||||||
|
// }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
console.log('policy append count ',policyAppendCount);
|
||||||
|
if (policyAppendCount == 0){
|
||||||
|
toastr.warning("No Policies found for the Employee","Warning");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// $('#emp_client_policy').select2();
|
||||||
|
$("#emp_client_policy").on('change', function() {
|
||||||
|
console.log("change function called ");
|
||||||
|
policy_id = $("#emp_client_policy").val();
|
||||||
|
setMinDateDOA(policy_id);
|
||||||
|
})
|
||||||
|
|
||||||
|
function setMinDateDOA(policy_id) {
|
||||||
|
console.log("Function set min date called ");
|
||||||
|
console.log("Existing DOA instance: ", doa);
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (response.status) {
|
||||||
|
let minDate = new Date(response.minDate);
|
||||||
|
// If doa is not initialized, create the instance
|
||||||
|
if (!doa) {
|
||||||
|
console.log("doa not found, initializing");
|
||||||
|
doa = flatpickr("#doa", {
|
||||||
|
dateFormat: "d/m/Y",
|
||||||
|
allowInput: false,
|
||||||
|
onChange: function(selectedDates) {
|
||||||
|
let selectedDOA = selectedDates[0]; // Get selected DOA date
|
||||||
|
dod.set("minDate", selectedDOA); // Set DOD minDate to DOA
|
||||||
|
},
|
||||||
|
minDate: minDate
|
||||||
|
});
|
||||||
|
var dod = flatpickr("#dod", {
|
||||||
|
dateFormat: "d/m/Y",
|
||||||
|
allowInput: false
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// If already initialized, just set the minDate
|
||||||
|
doa.set("minDate", minDate);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error(response.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
console.error(status, error);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
@ -68,6 +68,13 @@
|
|||||||
name="emp_mail" required>
|
name="emp_mail" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-3">
|
||||||
|
<label for="emp_personal_mail">Employee Personal Mail ID</label>
|
||||||
|
<input type="text" class="form-control" id="emp_personal_mail" placeholder="Enter EMP Personal Mail"
|
||||||
|
value="<?= isset($ticket_data['emp_personal_mail']) ? $ticket_data['emp_personal_mail'] : '' ?>"
|
||||||
|
name="emp_personal_mail">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="policy_no">Policy No <span class="text-danger"></span></label>
|
<label for="policy_no">Policy No <span class="text-danger"></span></label>
|
||||||
<input type="text" class="form-control" id="policy_no"
|
<input type="text" class="form-control" id="policy_no"
|
||||||
@ -86,6 +93,23 @@
|
|||||||
<input type=hidden id="insurer_id" name="insurer_id" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
|
<input type=hidden id="insurer_id" name="insurer_id" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
|
||||||
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly required>
|
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly required>
|
||||||
</div>
|
</div>
|
||||||
|
<input type="hidden" id="empIDHidden" onchange="getClientPolicy()">
|
||||||
|
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Policy <span class="text-danger">*</span></label>
|
||||||
|
<select id="emp_client_policy" name="client_policy_id"
|
||||||
|
class="form-control custom-select" required onchange="setDateValidation(this.value,true)"
|
||||||
|
<?= isset($ticket_data['client_policy_id'])?" class = 'readonly-select'":'' ?>
|
||||||
|
>
|
||||||
|
<?php if (!empty($ticket_data['client_policy_id'])) { ?>
|
||||||
|
<option value="<?= $ticket_data['client_policy_id'] ?>"><?= $ticket_data['client_policy_id_text'] ?></option>
|
||||||
|
<?php } else { ?>
|
||||||
|
<option value="">Select Policy</option>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<label for="acm_id">Account Manager <span class="text-danger">*</span></label>
|
<label for="acm_id">Account Manager <span class="text-danger">*</span></label>
|
||||||
@ -293,14 +317,22 @@
|
|||||||
<script>
|
<script>
|
||||||
let GlobelExtraFields = [];
|
let GlobelExtraFields = [];
|
||||||
|
|
||||||
|
var date_of_join;
|
||||||
|
var dob;
|
||||||
|
var date_of_accident;
|
||||||
|
var date_of_death;
|
||||||
|
var date_of_intimat;
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
var date_of_join = flatpickr("#date_of_join", {
|
$("#emp_client_policy").select2();
|
||||||
|
date_of_join = flatpickr("#date_of_join", {
|
||||||
dateFormat: "d/m/Y",
|
dateFormat: "d/m/Y",
|
||||||
allowInput: false
|
allowInput: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var dob = flatpickr("#dob", {
|
dob = flatpickr("#dob", {
|
||||||
dateFormat: "d/m/Y",
|
dateFormat: "d/m/Y",
|
||||||
allowInput: false
|
allowInput: false
|
||||||
});
|
});
|
||||||
@ -310,17 +342,22 @@
|
|||||||
allowInput: false
|
allowInput: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var date_of_accident = flatpickr("#date_of_accident", {
|
date_of_accident = flatpickr("#date_of_accident", {
|
||||||
|
dateFormat: "d/m/Y",
|
||||||
|
allowInput: false,
|
||||||
|
onChange: function(selectedDates) {
|
||||||
|
let selectedDOA = selectedDates[0]; // Get selected DOA date
|
||||||
|
date_of_death.set("minDate", selectedDOA); // Set DOD minDate to DOA
|
||||||
|
date_of_intimat.set("minDate",selectedDOA);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
date_of_death = flatpickr("#date_of_death", {
|
||||||
dateFormat: "d/m/Y",
|
dateFormat: "d/m/Y",
|
||||||
allowInput: false
|
allowInput: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var date_of_death = flatpickr("#date_of_death", {
|
date_of_intimat = flatpickr("#date_of_intimat", {
|
||||||
dateFormat: "d/m/Y",
|
|
||||||
allowInput: false
|
|
||||||
});
|
|
||||||
|
|
||||||
var date_of_intimat = flatpickr("#date_of_intimat", {
|
|
||||||
dateFormat: "d/m/Y",
|
dateFormat: "d/m/Y",
|
||||||
allowInput: false
|
allowInput: false
|
||||||
});
|
});
|
||||||
@ -425,7 +462,7 @@
|
|||||||
var hasValue = $thirdClass.find('input, textarea, select').filter(function() {
|
var hasValue = $thirdClass.find('input, textarea, select').filter(function() {
|
||||||
return $(this).val().trim() !== ''; // Check if at least one field is not empty
|
return $(this).val().trim() !== ''; // Check if at least one field is not empty
|
||||||
}).length > 0;
|
}).length > 0;
|
||||||
console.log ("has value ",hasValue);
|
console.log("has value ", hasValue);
|
||||||
$thirdClass.each(function() {
|
$thirdClass.each(function() {
|
||||||
var id = $(this).find('[id]').first().attr('id');
|
var id = $(this).find('[id]').first().attr('id');
|
||||||
var $label = $(this).find('label');
|
var $label = $(this).find('label');
|
||||||
@ -435,7 +472,7 @@
|
|||||||
|
|
||||||
// ✅ Condition 1: Check if this ID is in extraFieldsArray (required by status)
|
// ✅ Condition 1: Check if this ID is in extraFieldsArray (required by status)
|
||||||
var shouldAddRequired = extrafieldsArray[selectedClaimStatus] && extrafieldsArray[selectedClaimStatus].includes(id);
|
var shouldAddRequired = extrafieldsArray[selectedClaimStatus] && extrafieldsArray[selectedClaimStatus].includes(id);
|
||||||
console.log ("shouldAddRequired ",shouldAddRequired);
|
console.log("shouldAddRequired ", shouldAddRequired);
|
||||||
|
|
||||||
// ✅ Condition 2: If any field in the class has a value, make all required
|
// ✅ Condition 2: If any field in the class has a value, make all required
|
||||||
if (shouldAddRequired || hasValue) {
|
if (shouldAddRequired || hasValue) {
|
||||||
@ -546,4 +583,194 @@
|
|||||||
// console.warn(`No divs found with class="${className}"`);
|
// console.warn(`No divs found with class="${className}"`);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
$("#empIDHidden").change(function() {
|
||||||
|
console.log("change is detected in hidden branch id");
|
||||||
|
getClientPolicy();
|
||||||
|
})
|
||||||
|
|
||||||
|
var employeeId = "";
|
||||||
|
|
||||||
|
function getClientPolicy() {
|
||||||
|
console.log("get policy function called");
|
||||||
|
hiddenData = $("#empIDHidden").val();
|
||||||
|
hiddenData = JSON.parse(hiddenData);
|
||||||
|
console.log('employee id ', hiddenData['emp_id']);
|
||||||
|
employeeId = hiddenData['emp_id'];
|
||||||
|
data = {
|
||||||
|
emp_id: hiddenData['emp_id']
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: '<?= base_url("/ticket/getPoliciesbyEmpID") ?>',
|
||||||
|
type: "POST",
|
||||||
|
data: data,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(res) {
|
||||||
|
|
||||||
|
console.log('getClientAndBranchAndPolicy', res);
|
||||||
|
if (res.status == true) {
|
||||||
|
console.log("data is received2");
|
||||||
|
policyList = res.policy_data;
|
||||||
|
// appendClients(res.client_data);
|
||||||
|
// appendClientsFoerMobileSearch(res.client_data);
|
||||||
|
appendPolicyDropdown(policyList);
|
||||||
|
console.log("after function");
|
||||||
|
} else {
|
||||||
|
console.log('No data found');
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
console.error(status, error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function appendPolicyDropdown(data) {
|
||||||
|
|
||||||
|
// var ticket_type = $('#ticket_type').val();
|
||||||
|
hiddenData = $("#empIDHidden").val();
|
||||||
|
hiddenData = JSON.parse(hiddenData);
|
||||||
|
|
||||||
|
console.log("second function is called : ", data);
|
||||||
|
let ticket_type = $('#ticket_type_id').val();
|
||||||
|
$('#emp_client_policy').empty();
|
||||||
|
$('#emp_client_policy').append($('<option>', {
|
||||||
|
value: '',
|
||||||
|
text: 'Select Client Policy'
|
||||||
|
}));
|
||||||
|
|
||||||
|
var policyAppendCount = 0;
|
||||||
|
$.each(data, function(index, item) {
|
||||||
|
// console.log(item);
|
||||||
|
|
||||||
|
if (ticket_type != 1 && item.policy_type_id != 2) {
|
||||||
|
$('#emp_client_policy').append($('<option>', {
|
||||||
|
value: item.client_policy_value,
|
||||||
|
text: item.client_policy_name
|
||||||
|
}));
|
||||||
|
policyAppendCount++;
|
||||||
|
if (hiddenData['searchType'] != null && hiddenData['searchType'] != "" && hiddenData['policy_id'] != null && hiddenData['policy_id'] != "") {
|
||||||
|
// $('#emp_client_policy').select2();
|
||||||
|
$("#emp_client_policy").select2();
|
||||||
|
$('#emp_client_policy').val(hiddenData['policy_id']).addClass('readonly-select').select2('destroy').trigger("change");
|
||||||
|
} else {
|
||||||
|
// $('#emp_client_policy').append($('<option>', {
|
||||||
|
// value: item.client_policy_value,
|
||||||
|
// text: item.client_policy_name
|
||||||
|
// }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (policyAppendCount == 0) {
|
||||||
|
toastr.warning("No Policies found for the Employee", "Warning");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// $('#emp_client_policy').select2();
|
||||||
|
$("#emp_client_policy").on('change', function() {
|
||||||
|
console.log("change function called ");
|
||||||
|
policy_id = $("#emp_client_policy").val();
|
||||||
|
// setMinDateDOA(policy_id);
|
||||||
|
setDateValidation(policy_id, true);
|
||||||
|
})
|
||||||
|
|
||||||
|
function setDateValidation(policy_id, memberset = null) {
|
||||||
|
$.ajax({
|
||||||
|
url: '<?= base_url("ticket/getPolicyStartDate") ?>',
|
||||||
|
method: "POST",
|
||||||
|
data: {
|
||||||
|
policy_id: policy_id,
|
||||||
|
employeeId: employeeId ?? null
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
console.log(response);
|
||||||
|
if (response.status) {
|
||||||
|
if (memberset) {
|
||||||
|
var dobValue = response.empData[0].dob;
|
||||||
|
var doj = response.empData[0].doj;
|
||||||
|
console.log('data received fro controller ', dob, doj);
|
||||||
|
if (dobValue) {
|
||||||
|
$("#dob").val(dobValue);
|
||||||
|
$("#dob").addClass('readonly-select');
|
||||||
|
}
|
||||||
|
if (doj) {
|
||||||
|
$("#date_of_join").val(doj);
|
||||||
|
$("#date_of_join").addClass('readonly-select');
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if ($("#dob").hasClass('readonly-select')){
|
||||||
|
$("#dob").removeClass('readonly-select')
|
||||||
|
$("#dob").val("");
|
||||||
|
}
|
||||||
|
if ($("#date_of_join").hasClass('readonly-select')){
|
||||||
|
$("#date_of_join").removeClass('readonly-select')
|
||||||
|
$("#date_of_join").val("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.minDate) {
|
||||||
|
// var formatMinDate = response.minDate;
|
||||||
|
var formatMinDate = new Date(response.minDate);
|
||||||
|
date_of_accident.set("minDate", formatMinDate)
|
||||||
|
date_of_death.set("minDate", formatMinDate)
|
||||||
|
date_of_intimat.set("minDate", formatMinDate)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.error(response.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// function setMinDateDOA(policy_id) {
|
||||||
|
// console.log("Function set min date called ");
|
||||||
|
// console.log("Existing DOA instance: ", doa);
|
||||||
|
|
||||||
|
// $.ajax({
|
||||||
|
// url: '<?= base_url("ticket/getPolicyStartDate") ?>',
|
||||||
|
// method: "POST",
|
||||||
|
// data: {
|
||||||
|
// policy_id: policy_id
|
||||||
|
// },
|
||||||
|
// success: function(response) {
|
||||||
|
// console.log("mindate response ", response);
|
||||||
|
|
||||||
|
// if (response.status) {
|
||||||
|
// let minDate = new Date(response.minDate);
|
||||||
|
// // If doa is not initialized, create the instance
|
||||||
|
// if (!doa) {
|
||||||
|
// console.log("doa not found, initializing");
|
||||||
|
// doa = flatpickr("#doa", {
|
||||||
|
// dateFormat: "d/m/Y",
|
||||||
|
// allowInput: false,
|
||||||
|
// onChange: function(selectedDates) {
|
||||||
|
// let selectedDOA = selectedDates[0]; // Get selected DOA date
|
||||||
|
// dod.set("minDate", selectedDOA); // Set DOD minDate to DOA
|
||||||
|
// },
|
||||||
|
// minDate: minDate
|
||||||
|
// });
|
||||||
|
// var dod = flatpickr("#dod", {
|
||||||
|
// dateFormat: "d/m/Y",
|
||||||
|
// allowInput: false
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// // If already initialized, just set the minDate
|
||||||
|
// doa.set("minDate", minDate);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// console.error(response.message);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// error: function(xhr, status, error) {
|
||||||
|
// console.error(xhr.responseText);
|
||||||
|
// console.error(status, error);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
</script>
|
</script>
|
||||||
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,8 @@
|
|||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
th,td {
|
th,
|
||||||
|
td {
|
||||||
font-size: smaller !important;
|
font-size: smaller !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,13 +29,13 @@
|
|||||||
|
|
||||||
th:nth-child(1),
|
th:nth-child(1),
|
||||||
td:nth-child(1) {
|
td:nth-child(1) {
|
||||||
width: 150px;
|
width: 110px;
|
||||||
/* Adjust first column width */
|
/* Adjust first column width */
|
||||||
}
|
}
|
||||||
|
|
||||||
th:nth-child(2),
|
th:nth-child(2),
|
||||||
td:nth-child(2) {
|
td:nth-child(2) {
|
||||||
width: 550px;
|
width: 720px;
|
||||||
/* Adjust first column width */
|
/* Adjust first column width */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,7 +922,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"public_liability": [{
|
"public_liability": [{
|
||||||
table_type: "append",
|
table_type: "new",
|
||||||
table_name: "Public Liability Coverage",
|
table_name: "Public Liability Coverage",
|
||||||
table_id: "public_liability_addOnCoverage",
|
table_id: "public_liability_addOnCoverage",
|
||||||
table_editable: true,
|
table_editable: true,
|
||||||
@ -1897,9 +1898,101 @@
|
|||||||
element.appendChild(icon);
|
element.appendChild(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#saveRFQ').click( () => saveRFQ());
|
$('#saveRFQ').click(() => saveRFQ());
|
||||||
|
// $("#saveRFQ").click(function (){
|
||||||
|
// console.log("Hello the save req button is clicked");
|
||||||
|
// })
|
||||||
|
|
||||||
function saveRFQ(){
|
function saveRFQ() {
|
||||||
console.log("save rfq clicked");
|
const rfqData = {
|
||||||
|
table_data: {
|
||||||
|
headers: [],
|
||||||
|
data: []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get all tables
|
||||||
|
const tables = document.querySelectorAll('table');
|
||||||
|
if (tables.length === 0) return;
|
||||||
|
|
||||||
|
// Extract headers from the first table
|
||||||
|
const headerRow1 = tables[0].querySelector('thead tr:first-child');
|
||||||
|
const headerRow2 = tables[0].querySelector('thead tr:last-child');
|
||||||
|
const headers = [];
|
||||||
|
|
||||||
|
headerRow1.querySelectorAll('th').forEach((th, index) => {
|
||||||
|
const parentHeader = th.textContent.trim();
|
||||||
|
const subHeaders = [];
|
||||||
|
const subHeaderTh = headerRow2.children[index];
|
||||||
|
if (subHeaderTh) {
|
||||||
|
subHeaders.push(subHeaderTh.textContent.trim());
|
||||||
|
}
|
||||||
|
headers.push({
|
||||||
|
parentHeader,
|
||||||
|
subHeaders
|
||||||
|
});
|
||||||
|
});
|
||||||
|
rfqData.table_data.headers = headers;
|
||||||
|
|
||||||
|
// Process all tables
|
||||||
|
tables.forEach(table => {
|
||||||
|
const rows = table.querySelectorAll('tbody tr');
|
||||||
|
rows.forEach(row => {
|
||||||
|
const cells = row.querySelectorAll('td');
|
||||||
|
const rowData = {
|
||||||
|
SNO: '',
|
||||||
|
items: '',
|
||||||
|
data: []
|
||||||
|
};
|
||||||
|
|
||||||
|
// Extract SNO (first cell)
|
||||||
|
if (cells[0]) {
|
||||||
|
rowData.SNO = cells[0].textContent.replace(/\D/g, '') || '1';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract items (row ID)
|
||||||
|
rowData.items = row.id || '';
|
||||||
|
|
||||||
|
// Process each cell
|
||||||
|
cells.forEach((cell, cellIndex) => {
|
||||||
|
const header = headers[cellIndex];
|
||||||
|
if (!header) return;
|
||||||
|
|
||||||
|
const parentHeader = header.parentHeader;
|
||||||
|
const subHeader = header.subHeaders[0] || '-';
|
||||||
|
|
||||||
|
// Get displayed value
|
||||||
|
const value = cell.textContent.trim();
|
||||||
|
|
||||||
|
// Get input value (hidden field or checkbox state)
|
||||||
|
let inputValue = value;
|
||||||
|
const hiddenInput = cell.querySelector('input[type="hidden"]');
|
||||||
|
if (hiddenInput) {
|
||||||
|
inputValue = hiddenInput.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle Action column checkboxes
|
||||||
|
if (parentHeader === 'Action') {
|
||||||
|
const qcrChecked = cell.querySelector('.qcr-checkbox')?.checked ?? false;
|
||||||
|
const clientChecked = cell.querySelector('.client-checkbox')?.checked ?? false;
|
||||||
|
inputValue = {
|
||||||
|
qcr: qcrChecked ? 1 : 0,
|
||||||
|
stc: clientChecked ? 1 : 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
rowData.data.push({
|
||||||
|
parentth: parentHeader,
|
||||||
|
subth: subHeader,
|
||||||
|
value,
|
||||||
|
input_value: inputValue
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
rfqData.table_data.data.push(rowData);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(JSON.stringify(rfqData, null, 2));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user