500 lines
26 KiB
PHP
500 lines
26 KiB
PHP
<style>
|
|
.readonly-select {
|
|
pointer-events: none;
|
|
background-color: #e0e0e0;
|
|
color: #666;
|
|
}
|
|
</style>
|
|
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="<?= !isset($ticket_data) ? "card" : "" ?>" style="margin-right: 23px;">
|
|
<div class="card-body">
|
|
<?php if(!isset($ticket_data)){ ?>
|
|
<!-- Header Section -->
|
|
<div class="row mb-3">
|
|
<div class="col-6 d-flex align-items-center">
|
|
<h4 class="mb-0">Claim <?= $ticket_form ?></h4>
|
|
</div>
|
|
<div class="col-6 text-right">
|
|
<a href="<?= base_url('ticket/list'); ?>" aria-label="Back to ticket list">
|
|
<i class="fas fa-arrow-left" style="font-size: 17px;"></i>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
<form role="form" class="parsley-examples" method="post" id="ticket_form_data" onsubmit="submitClaimForm(event, this)"
|
|
enctype="multipart/form-data">
|
|
|
|
<input type="hidden" id="ticket_master_id" name="ticket_master_id" value="<?= isset($ticket_data['id']) ? $ticket_data['id'] : '' ?>">
|
|
<input type="hidden" id="is_head_approved" name="is_head_approved" value="<?= isset($ticket_data['is_head_approved']) ? $ticket_data['is_head_approved'] : '' ?>">
|
|
<input type="hidden" id="extra_fields_array_for_validate" name="extra_fields_array_for_validate" value='<?= isset($extra_fields_array_for_validate) && !empty($extra_fields_array_for_validate) ? json_encode($extra_fields_array_for_validate) : "[]" ?>'>
|
|
|
|
<div class="form-group">
|
|
|
|
<h5>Employee Details</h5>
|
|
<hr>
|
|
|
|
<!-- first_data_points -->
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="emp_code">Employee ID <i class="fa fa-search text-danger"
|
|
aria-hidden="true" onclick="openFetchEmpDataodal(this)"></i> <span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="emp_code" placeholder="Enter Employee ID"
|
|
value="<?= isset($ticket_data['emp_code']) ? $ticket_data['emp_code'] : '' ?>"
|
|
name="emp_code">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="emp_name">Employee Name<span class="text-danger"></span></label>
|
|
<input type=hidden id="emp_id" name="emp_id" value="<?= isset($ticket_data['emp_id']) ? $ticket_data['emp_id'] : '' ?>">
|
|
<input type="text" class="form-control" id="emp_name" placeholder="Enter Employee Name"
|
|
value="<?= isset($ticket_data['emp_name']) ? $ticket_data['emp_name'] : '' ?>"
|
|
name="emp_name">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="emp_mobile">Employee Mobile No<span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="emp_mobile" placeholder="Enter EMP Mobile"
|
|
value="<?= isset($ticket_data['emp_mobile']) ? $ticket_data['emp_mobile'] : '' ?>"
|
|
name="emp_mobile">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="emp_mail">Employee Mail ID<span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="emp_mail" placeholder="Enter EMP Mail"
|
|
value="<?= isset($ticket_data['emp_mail']) ? $ticket_data['emp_mail'] : '' ?>"
|
|
name="emp_mail">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="policy_no">Policy No<span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="policy_no"
|
|
value="<?= isset($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>"
|
|
name="policy_no">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<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="text" class="form-control" id="client_name" placeholder="Client" value="<?= isset($ticket_data['client_name']) ? $ticket_data['client_name'] : '' ?>" readonly>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="insurer_id">Insurer<span class="text-danger"></span></label>
|
|
<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>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="acm_id">Account Manager<span class="text-danger"></span></label>
|
|
<select class="form-control" id="acm_id" name="acm_id">
|
|
<!-- <option value="0">Select Account Manager</option> -->
|
|
<?php
|
|
if (isset($acms) && count($acms)) {
|
|
foreach ($acms as $key => $value) {
|
|
$selected = (isset($ticket_data) && $ticket_data['acm_id'] == $value['id']) ? 'selected' : '';
|
|
echo "<option value=" . $value['id'] . " $selected>" . $value['first_name'] . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
</div>
|
|
<!-- end first_data_points -->
|
|
|
|
<h5>Claim Details</h5>
|
|
<hr>
|
|
|
|
<!-- second_data_points -->
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="ticket_type_id"> Policy Type <span class="text-danger"></span></label>
|
|
<select class="form-control readonly-select" id="ticket_type_id" name="ticket_type_id" readonly>
|
|
<?php
|
|
if (isset($ticket_type) && count($ticket_type)) {
|
|
foreach ($ticket_type as $key => $value) {
|
|
if($key != 1){
|
|
$selected = (isset($ticket_data) && $ticket_data['ticket_type_id'] == $key) ? 'selected' : ((isset($selected_ticket_type) && $selected_ticket_type == $key) ? 'selected' : '');
|
|
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="claim_status">Status<span class="text-danger"></span></label>
|
|
<select class="form-control" id="claim_status_id" name="claim_status_id">
|
|
<!-- <option value="0">Select status</option> -->
|
|
<?php
|
|
if (isset($claim_status) && count($claim_status)) {
|
|
foreach ($claim_status as $key => $value) {
|
|
$selected = (isset($ticket_data) && $ticket_data['claim_status_id'] == $value['id']) ? 'selected' : '';
|
|
echo "<option value=" . $value['id'] . " $selected>" . $value['claim_status'] . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="claim_type"> Claim Type <span class="text-danger"></span></label>
|
|
<select class="form-control" id="claim_type" name="claim_type">
|
|
<!-- <option value="0">Select claim Type</option> -->
|
|
<?php
|
|
if (isset($claim_type) && count($claim_type)) {
|
|
foreach ($claim_type as $key => $value) {
|
|
$selected = (isset($ticket_data) && $ticket_data['claim_type'] == $key) ? 'selected' : '';
|
|
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="date_of_join">Date of joining<span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="date_of_join"
|
|
placeholder="Enter Joining Date"
|
|
value="<?= isset($ticket_data['date_of_join']) ? $ticket_data['date_of_join'] : '' ?>"
|
|
name="date_of_join">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="date_of_incep">Date of Inception<span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="date_of_incep"
|
|
placeholder="Enter Inception Date"
|
|
value="<?= isset($ticket_data['date_of_incep']) ? $ticket_data['date_of_incep'] : '' ?>"
|
|
name="date_of_incep">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="dob">Date of Birth<span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="dob" placeholder="Enter Birth Date"
|
|
value="<?= isset($ticket_data['dob']) ? $ticket_data['dob'] : '' ?>" name="dob">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="date_of_accident">Date of Accident<span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="date_of_accident"
|
|
placeholder="Enter Accident Date"
|
|
value="<?= isset($ticket_data['date_of_accident']) ? $ticket_data['date_of_accident'] : '' ?>"
|
|
name="date_of_accident">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="date_of_death">Date of Death<span class="text-danger"></span></label>
|
|
<input type="date_of_death" class="form-control" id="date_of_death"
|
|
placeholder="Enter Death Date"
|
|
value="<?= isset($ticket_data['date_of_death']) ? $ticket_data['date_of_death'] : '' ?>"
|
|
name="date_of_death">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="date_of_intimat">Date of Intimation<span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="date_of_intimat"
|
|
placeholder="Enter Intimation Date"
|
|
value="<?= isset($ticket_data['date_of_intimat']) ? $ticket_data['date_of_intimat'] : '' ?>"
|
|
name="date_of_intimat">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label for="si_amt">Sum insured<span class="text-danger"></span></label>
|
|
<input type="text" class="form-control" id="si_amt" placeholder="Enter SI"
|
|
value="<?= isset($ticket_data['si_amt']) ? $ticket_data['si_amt'] : '' ?>"
|
|
name="si_amt">
|
|
</div>
|
|
</div>
|
|
<!-- end second_data_points -->
|
|
|
|
<h5>Additional Details</h5>
|
|
<hr>
|
|
|
|
<!-- third_data_points -->
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-3 approved" style="display: none;">
|
|
<label for="approved_amount">Approved Amount</label>
|
|
<input type="text" class="form-control" id="approved_amount" placeholder="Enter Approved Amount"
|
|
value="<?= isset($ticket_data['approved_amount']) ? $ticket_data['approved_amount'] : '' ?>" name="approved_amount">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3 approved" style="display: none;">
|
|
<label for="approved_date">Approved Date</label>
|
|
<input type="text" class="form-control datepicker" id="approved_date" placeholder="Select Approved Date"
|
|
value="<?= isset($ticket_data['approved_date']) ? $ticket_data['approved_date'] : '' ?>" name="approved_date">
|
|
</div>
|
|
|
|
<div class="form-group col-md-6 approved" style="display: none;">
|
|
<label for="approved_letter">Approved Letter</label>
|
|
<input type="text" class="form-control" id="approved_letter" placeholder="Enter Approved Letter"
|
|
value="<?= isset($ticket_data['approved_letter']) ? $ticket_data['approved_letter'] : '' ?>" name="approved_letter">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3 settled" style="display: none;">
|
|
<label for="utr_details">UTR Details</label>
|
|
<input type="text" class="form-control" id="utr_details" placeholder="Enter UTR Details"
|
|
value="<?= isset($ticket_data['utr_details']) ? $ticket_data['utr_details'] : '' ?>" name="utr_details">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3 settled" style="display: none;">
|
|
<label for="settled_date">Settled Date</label>
|
|
<input type="text" class="form-control datepicker" id="settled_date" placeholder="Select Settled Date"
|
|
value="<?= isset($ticket_data['settled_date']) ? $ticket_data['settled_date'] : '' ?>" name="settled_date">
|
|
</div>
|
|
|
|
<div class="form-group col-md-6 settled" style="display: none;">
|
|
<label for="settle_letter">Settle Letter</label>
|
|
<input type="text" class="form-control" id="settle_letter" placeholder="Enter Settle Letter"
|
|
value="<?= isset($ticket_data['settle_letter']) ? $ticket_data['settle_letter'] : '' ?>" name="settle_letter">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3 canceled" style="display: none;">
|
|
<label for="cancel_remark">Cancel Remark</label>
|
|
<textarea class="form-control" id="cancel_remark" rows="1" placeholder="Enter Cancel Remark" name="cancel_remark"><?= isset($ticket_data['cancel_remark']) ? $ticket_data['cancel_remark'] : '' ?></textarea>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3 returned" style="display: none;">
|
|
<label for="return_remark">Return Remark</label>
|
|
<textarea class="form-control" id="return_remark" rows="1" placeholder="Enter Return Remark" name="return_remark"><?= isset($ticket_data['return_remark']) ? $ticket_data['return_remark'] : '' ?></textarea>
|
|
</div>
|
|
|
|
<div class="form-group col-md-6 returned" style="display: none;">
|
|
<label for="awb_no_courier_name">AWB No with Courier Name</label>
|
|
<input type="text" class="form-control" id="awb_no_courier_name" placeholder="eg : 0001/ST Courier"
|
|
value="<?= isset($ticket_data['awb_no_courier_name']) ? $ticket_data['awb_no_courier_name'] : '' ?>" name="awb_no_courier_name">
|
|
</div>
|
|
|
|
|
|
</div>
|
|
<!-- end third_data_points -->
|
|
|
|
</div>
|
|
<div class="form-group col-md-12 text-right m-b-0" style="margin-top: 29px;">
|
|
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
|
id="btnSubmit">Submit</button>
|
|
<?php if(get_role_id() == 5 && isset($ticket_data) && in_array($ticket_data['claim_status_id'],[23,33,43])) { ?>
|
|
<a class="btn btn-secondary waves-effect waves-light mr-1" onclick="showConfirmationModal(event)">Rejected Approve</a>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
let GlobelExtraFields = [];
|
|
|
|
$(document).ready(function() {
|
|
|
|
var date_of_join = flatpickr("#date_of_join", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
var dob = flatpickr("#dob", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
var date_of_incep = flatpickr("#date_of_incep", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
var date_of_accident = flatpickr("#date_of_accident", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
var date_of_death = flatpickr("#date_of_death", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
var date_of_intimat = flatpickr("#date_of_intimat", {
|
|
dateFormat: "d/m/Y",
|
|
allowInput: false
|
|
});
|
|
|
|
flatpickr("#approved_date", { dateFormat: "d/m/Y", allowInput: false });
|
|
flatpickr("#settled_date", { dateFormat: "d/m/Y", allowInput: false });
|
|
|
|
// updateClaimStatusDisplay("<?= isset($ticket_data['claim_status_id']) ? $ticket_data['claim_status_id'] : 0 ?>")
|
|
var extraFields = <?= json_encode(isset($extra_fields) ? $extra_fields : []); ?>;
|
|
GlobelExtraFields = extraFields;
|
|
console.log("extraFields", extraFields);
|
|
claimStatusFieldChanges(extraFields);
|
|
|
|
|
|
})
|
|
|
|
function updateClaimStatusDisplay(value) {
|
|
|
|
console.log('value', value);
|
|
|
|
// Hide all sections first
|
|
$('.settled, .approved, .canceled, .returned').hide();
|
|
|
|
// Show relevant section based on value
|
|
if (value == 20 || value == 30 || value == 40) { // APPROVED
|
|
$('.approved').show();
|
|
} else if (value == 24 || value == 34 || value == 44) { // SETTLED
|
|
$('.settled').show();
|
|
}else if (value == 47 || value == 53 || value == 58) { // CANCELLED
|
|
$('.canceled').show();
|
|
}else if (value == 48 || value == 54 || value == 59) { // RETURNED
|
|
$('.returned').show();
|
|
}
|
|
}
|
|
|
|
$('#claim_status_id').on('change', function() {
|
|
updateClaimStatusDisplay($(this).val());
|
|
});
|
|
|
|
function claimStatusFieldChanges(fields) {
|
|
console.log('fields', fields);
|
|
fields.forEach(function(fieldId) {
|
|
var $field = $("#" + fieldId);
|
|
|
|
if ($field.length) {
|
|
// $field.prop('required', true);
|
|
|
|
var $parentDiv = $field.closest("div");
|
|
$parentDiv.show();
|
|
|
|
var $label = $parentDiv.find("label[for='" + fieldId + "']");
|
|
if ($label.length && !$label.find(".text-danger").length) {
|
|
$label.append(' <span class="text-danger">*</span>');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function claimStatusFieldRemoveREquired(fields, remove_or_add, thirdClass) {
|
|
|
|
console.log('--------------------------- claimStatusFieldRemoveREquired ---------------------------');
|
|
console.log('fields', fields);
|
|
console.log('remove_or_add', remove_or_add);
|
|
|
|
fields.forEach(function(fieldId) {
|
|
var $field = $("#" + fieldId);
|
|
|
|
if ($field.length) {
|
|
$field.prop('required', remove_or_add);
|
|
var $parentDiv = $field.closest("div");
|
|
console.log('parentDiv', $parentDiv);
|
|
var $label = $parentDiv.find("label[for='" + fieldId + "']");
|
|
// if(remove_or_add == false){
|
|
// $parentDiv.find("label[for='" + fieldId + "'] .text-danger").remove();
|
|
// console.log('one', remove_or_add);
|
|
// }else{
|
|
// if ($label.length && !$label.find(".text-danger").length) {
|
|
// $label.append(' <span class="text-danger">*</span>');
|
|
// }
|
|
// }
|
|
|
|
}
|
|
});
|
|
|
|
$('.'+thirdClass).find('input, textarea').attr('required', true);
|
|
|
|
}
|
|
|
|
$(document).on("input", function (event) {
|
|
|
|
let fields = GlobelExtraFields;
|
|
console.log('fields', fields);
|
|
let targetId = event.target.id;
|
|
console.log('targetId', targetId);
|
|
console.log('fields.includes(targetId)', fields.includes(targetId));
|
|
|
|
if (fields.includes(targetId)) {
|
|
|
|
let $field = $("#" + targetId);
|
|
console.log('$field id', $field);
|
|
let $parentDiv = $field.closest("div");
|
|
console.log('$parentDiv', $parentDiv);
|
|
// addRequiredFieldSymbol(targetId);
|
|
if ($parentDiv.length) {
|
|
let thirdClass = $parentDiv.attr("class").split(" ")[2] || "";
|
|
addRequiredFieldSymbolByClass(thirdClass);
|
|
console.log('thirdClass', thirdClass);
|
|
|
|
if (thirdClass) {
|
|
claimStatusFieldRemoveREquired(fields, false, thirdClass);
|
|
let $label = $(thirdClass).find("label");
|
|
if ($label.length && !$label.find(".text-danger").length) {
|
|
$label.append(' <span class="text-danger">*</span>');
|
|
}
|
|
} else {
|
|
claimStatusFieldRemoveREquired($field, false, '');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
// function addRequiredFieldSymbol(field_name) {
|
|
// // Find the field with the given name
|
|
// var $field = $(`[name="${field_name}"]`);
|
|
|
|
// if ($field.length) {
|
|
// // Find the parent div of this field
|
|
// var $parentDiv = $field.closest('div');
|
|
|
|
// if ($parentDiv.length) {
|
|
// // Get the classes as an array
|
|
// var classes = $parentDiv.attr('class') ? $parentDiv.attr('class').split(/\s+/) : [];
|
|
|
|
// if (classes.length > 0) {
|
|
// // Get the last class in the array
|
|
// var lastClass = classes[classes.length - 1];
|
|
|
|
// // Find all divs with this last class
|
|
// var $allDivsWithClass = $(`.${lastClass}`);
|
|
|
|
// // Add asterisk to all labels within these divs
|
|
// $allDivsWithClass.each(function() {
|
|
// var $label = $(this).find('label');
|
|
// if ($label.length && !$label.find('.text-danger').length) {
|
|
// $label.append(' <span class="text-danger">*</span>');
|
|
// }
|
|
// });
|
|
|
|
// console.log(`Added required symbol to ${$allDivsWithClass.length} labels with class "${lastClass}"`);
|
|
// } else {
|
|
// console.warn(`Parent div for field "${field_name}" has no classes`);
|
|
// }
|
|
// } else {
|
|
// console.warn(`No parent div found for field name="${field_name}"`);
|
|
// }
|
|
// } else {
|
|
// console.warn(`No field found with name="${field_name}"`);
|
|
// }
|
|
// }
|
|
function addRequiredFieldSymbolByClass(className) {
|
|
// Find all divs with the specified class
|
|
var $divsWithClass = $(`.${className}`);
|
|
|
|
if ($divsWithClass.length) {
|
|
// Add asterisk to all labels within these divs
|
|
$divsWithClass.each(function() {
|
|
var $label = $(this).find('label');
|
|
if ($label.length && !$label.find('.text-danger').length) {
|
|
$label.append(' <span class="text-danger">*</span>');
|
|
}
|
|
});
|
|
|
|
console.log(`Added required symbol to ${$divsWithClass.length} labels with class "${className}"`);
|
|
} else {
|
|
console.warn(`No divs found with class="${className}"`);
|
|
}
|
|
}
|
|
|
|
</script>
|