1191 lines
59 KiB
PHP
1191 lines
59 KiB
PHP
<style>
|
|
.readonly-select {
|
|
pointer-events: none;
|
|
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;
|
|
}
|
|
|
|
.label-font-size{
|
|
font-size:0.875rem;
|
|
}
|
|
|
|
</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="mdi mdi-arrow-left" style="font-size: 17px;"></i>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
<form role="form" class="parsley-examples" method="post" id="ticket_form_data"
|
|
onsubmit="return validateBeforeSubmit(event, this)"
|
|
enctype="multipart/form-data">
|
|
|
|
<div class="form-group">
|
|
<h5>General Details</h5>
|
|
<hr>
|
|
<!-- Hide_data_points -->
|
|
<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) : "[]" ?>'>
|
|
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
|
|
<input type="hidden" id="emp_id" name="emp_id" value="<?= isset($ticket_data['emp_id']) ? $ticket_data['emp_id'] : '' ?>">
|
|
<input type="hidden" id="emp_name" name="emp_name" value="<?= isset($ticket_data['emp_name']) ? $ticket_data['emp_name'] : '' ?>">
|
|
<!-- first_data_points -->
|
|
<div class="form-row">
|
|
|
|
<!-- <div class="form-group col-md-3">
|
|
<label class="label-font-size" for="emp_code">Employee ID <span class="text-danger">*</span> <i class="mdi mdi-magnify 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" required>
|
|
</div> -->
|
|
|
|
<!-- <div class="form-group col-md-3">
|
|
<label class="label-font-size" 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" required>
|
|
</div> -->
|
|
|
|
<div class="form-group col-md-3">
|
|
<label class="label-font-size" for="client_name">Client Name <span class="text-danger">*</span></label>
|
|
<select class="form-control" id="client_name" name="client_name" required onchange="fetchOtherDetails(this,1)" data-parsley-trigger="change" data-parsley-required-message="Please select a option">
|
|
<option value="0">Select Client</option>
|
|
<?php
|
|
if (isset($client_for_motor) && count($client_for_motor)) {
|
|
foreach ($client_for_motor as $value) {
|
|
$selected = (isset($ticket_data) && $ticket_data['client_name'] == $value['client_name']) ? 'selected' : '';
|
|
echo '<option data-cid="'.$value['id'].'" data-cname="'.$value['client_name'].'" value="'.$value['client_name'].'" '.$selected.'>'.$value['client_name'] .' - '.$value['phone'] .'</option>';
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label class="label-font-size" for="vehicle_id">Vehicle <span class="text-danger">*</span></label>
|
|
<select class="form-control" id="vehicle_id" name="vehicle_id" required data-parsley-trigger="change" data-parsley-required-message="Please select a option">
|
|
<option value="0">Select Vehicle</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label class="label-font-size" for="emp_client_policy">Policy <span class="text-danger">*</span></label>
|
|
<select class="form-control" id="emp_client_policy" name="client_policy_id" required onchange="fetchOtherDetails(this,2)" data-parsley-trigger="change" data-parsley-required-message="Please select a option">
|
|
<option value="0"
|
|
data-policynumber="" data-managerid=""
|
|
data-insuredname="" data-agentid=""
|
|
data-insurerid="" data-insurername="" >Select Policy</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label class="label-font-size" for="insurer_name">Insurer </label>
|
|
<input type=text class="form-control" id="insurer_name" placeholder="Enter Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly>
|
|
<input type="hidden" id="insurer_id" name="insurer_id" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
|
|
<input type="hidden" id="agent_id" name="agent_id" value="<?= isset($ticket_data['agent_id']) ? $ticket_data['agent_id'] : '' ?>">
|
|
<input type="hidden" id="manager_id" name="manager_id" value="<?= isset($ticket_data['manager_id']) ? $ticket_data['manager_id'] : '' ?>">
|
|
<input type="hidden" id="policy_no" name="policy_no" value="<?= isset($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label class="label-font-size" for="emp_mobile"> Mobile No </label>
|
|
<input type="text" class="form-control" id="emp_mobile" placeholder="Enter Mobile No"
|
|
value="<?= isset($ticket_data['emp_mobile']) ? $ticket_data['emp_mobile'] : '' ?>"
|
|
name="emp_mobile" readonly>
|
|
</div>
|
|
|
|
<div class="form-group col-md-3">
|
|
<label class="label-font-size" for="emp_mail"> Mail ID </label>
|
|
<input type="text" class="form-control" id="emp_mail" placeholder="Enter Mail ID"
|
|
value="<?= isset($ticket_data['emp_mail']) ? $ticket_data['emp_mail'] : '' ?>"
|
|
name="emp_mail" readonly>
|
|
</div>
|
|
|
|
<!-- <div class="form-group col-md-3">
|
|
<label class="label-font-size" 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">
|
|
<label class="label-font-size" for="acm_id">Account Manager <span class="text-danger">*</span></label>
|
|
<select class="form-control" id="acm_id" name="acm_id" required>
|
|
<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 -->
|
|
|
|
<br><br>
|
|
<h5>Claim Details <span><i id="infoIcon" class="mdi mdi-information-outline info-icon" title="Click for more details"></i></span></h5>
|
|
<hr>
|
|
|
|
<!-- second_data_points -->
|
|
<div class="form-row">
|
|
<div class="form-group col-md-3">
|
|
<label class="label-font-size" 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 == 8) {
|
|
$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 class="label-font-size" for="claim_status_id">Status <span class="text-danger">*</span></label>
|
|
<select class="form-control" id="claim_status_id" name="claim_status_id" required data-parsley-trigger="change" data-parsley-required-message="Please select a status">
|
|
<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 class="label-font-size" for="claim_type"> Claim Type <span class="text-danger">*</span></label>
|
|
<select class="form-control" id="claim_type" name="claim_type" required>
|
|
!-- <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 class="label-font-size" 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 class="label-font-size" 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 class="label-font-size" 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" required>
|
|
</div> -->
|
|
|
|
<!-- <div class="form-group col-md-3">
|
|
<label class="label-font-size" 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 class="label-font-size" 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 class="label-font-size" 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" required>
|
|
</div> -->
|
|
|
|
<!-- <div class="form-group col-md-3">
|
|
<label class="label-font-size" 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" required>
|
|
</div> -->
|
|
</div>
|
|
<!-- end second_data_points -->
|
|
|
|
<!-- <br><br>
|
|
<h5>Additional Details</h5>
|
|
<hr> -->
|
|
|
|
<!-- third_data_points -->
|
|
<!-- <div class="form-row approved" style="display: none;">
|
|
|
|
<div class="form-group col-md-3 approved" style="display: none;">
|
|
<label class="label-font-size" 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 class="label-font-size" 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 class="label-font-size" 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-6 approved" style="display: none;">
|
|
<label class="label-font-size" for="approved_description">Approved Description</label>
|
|
<input type="text" class="form-control" id="approved_description" placeholder="Enter Approved Description"
|
|
value="<?= isset($ticket_data['approved_description']) ? $ticket_data['approved_description'] : '' ?>" name="approved_description">
|
|
</div>
|
|
|
|
<div class="form-group col-md-3 settled" style="display: none;">
|
|
<label class="label-font-size" 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 class="label-font-size" 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 class="label-font-size" 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 class="label-font-size" 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 class="label-font-size" 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 class="label-font-size" 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>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</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 = [];
|
|
|
|
// var date_of_join;
|
|
// var dob;
|
|
// var date_of_accident;
|
|
// var date_of_death;
|
|
// var date_of_intimat;
|
|
|
|
|
|
// $(document).ready(function() {
|
|
|
|
// $("#emp_client_policy").select2();
|
|
// date_of_join = flatpickr("#date_of_join", {
|
|
// dateFormat: "d/m/Y",
|
|
// maxDate: "today",
|
|
// allowInput: false
|
|
// });
|
|
|
|
// dob = flatpickr("#dob", {
|
|
// dateFormat: "d/m/Y",
|
|
// maxDate: "today",
|
|
// allowInput: false
|
|
// });
|
|
|
|
// var date_of_incep = flatpickr("#date_of_incep", {
|
|
// dateFormat: "d/m/Y",
|
|
// maxDate: "today",
|
|
// allowInput: false
|
|
// });
|
|
|
|
// date_of_accident = flatpickr("#date_of_accident", {
|
|
// dateFormat: "d/m/Y",
|
|
// maxDate: "today",
|
|
// 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",
|
|
// maxDate: "today",
|
|
// allowInput: false
|
|
// });
|
|
|
|
// date_of_intimat = flatpickr("#date_of_intimat", {
|
|
// dateFormat: "d/m/Y",
|
|
// maxDate: "today",
|
|
// allowInput: false
|
|
// });
|
|
|
|
// flatpickr("#approved_date", {
|
|
// dateFormat: "d/m/Y",
|
|
// maxDate: "today",
|
|
// allowInput: false
|
|
// });
|
|
// flatpickr("#settled_date", {
|
|
// dateFormat: "d/m/Y",
|
|
// maxDate: "today",
|
|
// 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();
|
|
// }
|
|
|
|
// $field = $('#approved_description')
|
|
// $field.prop('required', false);
|
|
// var $parentDiv = $field.closest("div");
|
|
// $parentDiv.find("label[for='approved_description'] .text-danger").remove();
|
|
|
|
// }
|
|
|
|
// $('#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);
|
|
// let extrafieldsArray = $('#extra_fields_array_for_validate').val();
|
|
// try {
|
|
// extrafieldsArray = JSON.parse(extrafieldsArray); // Convert string to object
|
|
// } catch (error) {
|
|
// console.error("Invalid JSON format in extra_fields_array_for_validate:", error);
|
|
// return;
|
|
// }
|
|
|
|
// var selectedClaimStatus = $('#claim_status_id').val();
|
|
// var $thirdClass = $(`.${thirdClass}`);
|
|
// var hasValue = $thirdClass.find('input, textarea, select').filter(function() {
|
|
// return $(this).val().trim() !== ''; // Check if at least one field is not empty
|
|
// }).length > 0;
|
|
// console.log("has value ", hasValue);
|
|
// $thirdClass.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);
|
|
// console.log("shouldAddRequired ", shouldAddRequired);
|
|
|
|
// // ✅ 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);
|
|
// $('.' + thirdClass).find('input, textarea,select').attr('required', true);
|
|
// console.log(`class ${thirdClass} added required label and added required field`);
|
|
// } else {
|
|
// $label.find('.text-danger').remove();
|
|
// console.log("input ", $inputs);
|
|
// // $inputs.prop('required', false);
|
|
// $('.' + thirdClass).find('input, textarea,select').attr('required', false);
|
|
// console.log(`class ${thirdClass} removed required label and removed required field`);
|
|
// }
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
// $(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, '');
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// $field = $('#approved_description')
|
|
// $field.prop('required', false);
|
|
// var $parentDiv = $field.closest("div");
|
|
// $parentDiv.find("label[for='approved_description'] .text-danger").remove();
|
|
|
|
// });
|
|
// // 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}"`);
|
|
// // }
|
|
// // }
|
|
|
|
// $("#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;
|
|
// console.log("got data from backend ",data);
|
|
// let policyCount = 1;
|
|
// $.each(data, function(index, item) {
|
|
// // console.log("item len",item.length);
|
|
|
|
// if (ticket_type != 1 && item.policy_type_id != 2) {
|
|
// $('#emp_client_policy').append($('<option>', {
|
|
// value: item.client_policy_value,
|
|
// text: item.client_policy_name,
|
|
// 'data-insurerid' : item.insurer_id ?? "",
|
|
// 'data-tpaid' : item.tpa_id ?? "",
|
|
// 'data-insurername' : item.insurer_name ?? "",
|
|
// 'data-tpaname' : item.tpa_name ?? "",
|
|
// }));
|
|
// console.log("policy count from loop","");
|
|
// $("#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 ","");
|
|
// $("#policy_no").val("");
|
|
// }
|
|
// policyCount++;
|
|
// 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 setPolicyNo(){
|
|
// var policy_name = $("#emp_client_policy option:selected").text();
|
|
// var policy_no = policy_name.split("-")[1];
|
|
// $("#policy_no").val(policy_no);
|
|
// console.log("after text split",policy_no);
|
|
// }
|
|
|
|
// function setDateValidation(policy_id, memberset = null) {
|
|
// setPolicyNo();
|
|
// $.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 dateOfInception = response.empData[0].date_of_inception;
|
|
// var dobValue = response.empData[0].dob;
|
|
// var doj = response.empData[0].doj;
|
|
// var basicCoverSI = response.empData[0].basic_cover_si
|
|
// console.log('data received fro controller ', dob, doj);
|
|
// if (dobValue) {
|
|
// $("#dob").val(dobValue);
|
|
// $("#dob").addClass('readonly-select');
|
|
// }
|
|
// if (dateOfInception){
|
|
// $("#date_of_incep").val(dateOfInception);
|
|
// $("#date_of_incep").addClass('readonly-select');
|
|
// }
|
|
// if (doj) {
|
|
// $("#date_of_join").val(doj);
|
|
// $("#date_of_join").addClass('readonly-select');
|
|
// }
|
|
|
|
// $("#si_amt").val(basicCoverSI);
|
|
// $("#si_amt").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 setInsurerAndTPAData(input) {
|
|
// let selectedOption = $(input).find('option:selected');
|
|
|
|
// let insurer_id = selectedOption.data('insurerid');
|
|
// let insurer_name = selectedOption.data('insurername');
|
|
// let tap_name = selectedOption.data('tpaname');
|
|
// let tap_id = selectedOption.data('tpaid');
|
|
|
|
// console.log('Insurer ID:', insurer_id);
|
|
// console.log('Insurer Name:', insurer_name);
|
|
// console.log('TPA Name:', tap_name);
|
|
// console.log('TPA ID:', tap_id);
|
|
|
|
// $('#insurer_id').val(insurer_id);
|
|
// $('#tpa_id').val(tap_id);
|
|
// $('#insurer_name').val(insurer_name);
|
|
// $('#tpa_name').val(tap_name);
|
|
// }
|
|
|
|
// // 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>
|
|
$("#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) {
|
|
// console.log('status', status)
|
|
// console.log('data[status]', data[status])
|
|
// console.log('data[status].length', data[status].length)
|
|
|
|
// let length = Object.keys(data[status]).length;
|
|
// console.log('length', length);
|
|
|
|
|
|
// if (data.hasOwnProperty(status) && length > 0) {
|
|
// // 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
|
|
// fieldLabel.textContent = field.display_name;
|
|
// 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].display_value; // 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].display_value;
|
|
// }
|
|
|
|
// 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>
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
// window.onload = function() {
|
|
// document.getElementById("ticket_form_data").reset();
|
|
// };
|
|
|
|
$("#emp_client_policy").select2();
|
|
$("#vehicle_id").select2();
|
|
$("#client_name").select2();
|
|
|
|
<?php if (isset($ticket_data) && !empty($ticket_data)) : ?>
|
|
let clientId = $("#client_id").val();
|
|
let vehicleId = "<?= $ticket_data['vehicle_id'] ?? '' ?>";
|
|
let policyId = "<?= $ticket_data['client_policy_id'] ?? '' ?>";
|
|
|
|
if (clientId && clientId !== "0") {
|
|
// Select Client
|
|
$("#client_name option").each(function () {
|
|
if ($(this).data("cid") == clientId) {
|
|
$(this).prop("selected", true);
|
|
}
|
|
});
|
|
|
|
// Fetch vehicles & policies with preselect
|
|
fetchVehiclePolicy(clientId, vehicleId, policyId, "edit");
|
|
|
|
// Readonly fields
|
|
setReadonlyField("emp_mail", "<?= $ticket_data['emp_mail'] ?? '' ?>", 'Mail ID');
|
|
setReadonlyField("emp_mobile", "<?= $ticket_data['emp_mobile'] ?? '' ?>", 'Mobile No');
|
|
setReadonlyField("insurer_name", "<?= $ticket_data['insurer_name'] ?? '' ?>", 'Insurer');
|
|
}
|
|
<?php endif; ?>
|
|
});
|
|
|
|
|
|
function fetchOtherDetails(input,flag){
|
|
let selectedOption = $(input).find('option:selected');
|
|
if(flag == "1"){ // Client change
|
|
let id = selectedOption.data('cid');
|
|
let name = selectedOption.data('cname');
|
|
|
|
$('#client_id').val(id);
|
|
$('#emp_id').val(id);
|
|
$('#emp_name').val(name);
|
|
|
|
fetchVehiclePolicy(id); // reset mode
|
|
} else if(flag == "2"){ // Policy change
|
|
let policyId = selectedOption.val();
|
|
let insuredName = selectedOption.data('insuredname');
|
|
let policyNumber = selectedOption.data('policynumber');
|
|
let agentId = selectedOption.data('agentid');
|
|
let managerId = selectedOption.data('managerid');
|
|
let insurerId = selectedOption.data('insurerid');
|
|
let insurerName = selectedOption.data('insurername');
|
|
|
|
$('#policy_no').val(policyNumber);
|
|
$('#agent_id').val(agentId);
|
|
$('#manager_id').val(managerId);
|
|
$('#insurer_id').val(insurerId);
|
|
$('#insurer_name').val(insurerName);
|
|
setReadonlyField("insurer_name", insurerName, 'Insurer');
|
|
}
|
|
}
|
|
|
|
function fetchVehiclePolicy(id, vehicleId = null, policyId = null, mode = "add") {
|
|
$.ajax({
|
|
url: '<?php echo base_url('ticket/fetchVehiclePolicy/');?>' + id,
|
|
method: "GET",
|
|
success: function (res) {
|
|
// Vehicle dropdown
|
|
let $vehicleSelect = $('#vehicle_id');
|
|
$vehicleSelect.empty().append('<option value="0">Select Vehicle</option>');
|
|
$.each(res.data.vehicle_list, function(index, item) {
|
|
let selected = (vehicleId && vehicleId == item.id) ? "selected" : "";
|
|
$vehicleSelect.append('<option value="'+ item.id +'" '+selected+'>'+ item.vehicle_no +'</option>');
|
|
});
|
|
$vehicleSelect.select2();
|
|
|
|
// Policy dropdown
|
|
let $policySelect = $('#emp_client_policy');
|
|
$policySelect.empty().append('<option value="0">Select Policy</option>');
|
|
$.each(res.data.partner_policy_list, function(index, item) {
|
|
let selected = (policyId && policyId == item.id) ? "selected" : "";
|
|
$policySelect.append(
|
|
'<option value="'+ item.id +'" '+selected+
|
|
' data-policynumber="'+ item.policy_number +'" data-insuredname="'+ item.insuredname +'" data-agentid="'+ item.agent_id +'" data-managerid="'+ item.manager_id +'" data-insurerid="'+ item.insurer_id +'" data-insurername="'+ item.insurer_name +'" >'+ item.policy_number +'</option>'
|
|
);
|
|
});
|
|
$policySelect.select2();
|
|
|
|
// Readonly contact fields
|
|
if (mode === "add") {
|
|
setReadonlyField("emp_mail", res.data.email ?? "", 'Mail ID');
|
|
$("#emp_mail").val(res.data.email ?? "");
|
|
setReadonlyField("emp_mobile", res.data.phone ?? "", 'Mobile No');
|
|
$("#emp_mobile").val(res.data.phone ?? "");
|
|
}
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error("Error:", error, xhr.responseText);
|
|
}
|
|
});
|
|
}
|
|
|
|
function setReadonlyField(fieldId, value, labelText) {
|
|
let $field = $("#" + fieldId);
|
|
let $label = $('label[for="' + fieldId + '"]');
|
|
|
|
if (value && value.trim() !== "") {
|
|
// Not required, readonly
|
|
$field.val(value).prop("readonly", true).prop("required", false)
|
|
.removeAttr("data-parsley-trigger")
|
|
.removeAttr("data-parsley-required-message");
|
|
$label.html(labelText);
|
|
} else {
|
|
$field.val("").prop("readonly", false).prop("required", true)
|
|
.attr("data-parsley-trigger", "change")
|
|
.attr("data-parsley-required-message", "Please Enter " + labelText.toLowerCase());
|
|
$label.html(labelText + ' <span class="text-danger">*</span>');
|
|
}
|
|
}
|
|
|
|
function validateBeforeSubmit(e, form) {
|
|
e.preventDefault();
|
|
var $form = $(form);
|
|
|
|
// Remove old error messages (only for selects)
|
|
$form.find(".field-error").remove();
|
|
$form.find("select").removeClass("is-invalid");
|
|
|
|
let isValid = true;
|
|
|
|
|
|
// $form.find("input[required], select[required]").each(function ()
|
|
$form.find("select[required]").each(function () {
|
|
let $field = $(this);
|
|
let value = $field.val().trim();
|
|
|
|
if (value === "" || value === "0" || value === undefined) {
|
|
isValid = false;
|
|
$field.addClass("is-invalid");
|
|
|
|
let errorMessage = $field.attr("data-parsley-required-message") || "This field is required";
|
|
|
|
$field.closest(".form-group").append(
|
|
'<p class="field-error text-danger d-block mt-1">' +
|
|
errorMessage +
|
|
'</p>'
|
|
);
|
|
}
|
|
});
|
|
|
|
if (!isValid) {
|
|
let $firstError = $form.find(".is-invalid").first();
|
|
$("html, body").animate(
|
|
{ scrollTop: $firstError.offset().top - 100 },
|
|
500
|
|
);
|
|
$firstError.focus();
|
|
return false;
|
|
}
|
|
|
|
// ✅ Let Parsley validate inputs automatically
|
|
if (!$form.parsley().validate()) {
|
|
return false;
|
|
}
|
|
|
|
// All good
|
|
submitClaimForm(e, form);
|
|
return true;
|
|
}
|
|
|
|
|
|
</script>
|