113 lines
6.7 KiB
PHP
113 lines
6.7 KiB
PHP
<?php if (isset($lead_edit_data)) {
|
|
if (! isset($lastFiveYears) || ! is_array($lastFiveYears)) {
|
|
$year = (int) date('Y');
|
|
$month = (int) date('m');
|
|
$currentFYStart = ($month >= 4) ? $year : $year - 1;
|
|
$lastFiveYears = [];
|
|
|
|
for ($i = 0; $i < 6; $i++) {
|
|
$startYear = $currentFYStart - $i;
|
|
$lastFiveYears[] = "{$startYear}-" . ($startYear + 1);
|
|
}
|
|
}
|
|
|
|
$claims = ! empty($lead_edit_data['fin_years_claims_array'])
|
|
? $lead_edit_data['fin_years_claims_array']
|
|
: [['year' => '', 'claim_amount' => '', 'status' => '', 'policy_type' => '', 'date_of_loss' => '', 'cause_of_loss' => '']];
|
|
$leadType = (int) ($lead_edit_data['lead_type'] ?? 0);
|
|
$showClaimsSection = in_array($leadType, [1, 2, 3], true);
|
|
$claimHistoryLabel = $leadType === 1 ? 'Mortality Experience' : 'Claims Experience';
|
|
?>
|
|
<?php if ($showClaimsSection) { ?>
|
|
<div class="custom-control custom-switch">
|
|
<input type="checkbox" onchange="claimHistoryToggle()" class="custom-control-input" id="claim_history" name="claim_history" <?= $lead_edit_data['claim_history'] == 1 ? 'checked' : '' ?> />
|
|
<label class="custom-control-label" for="claim_history"><?= $claimHistoryLabel ?></label>
|
|
</div><br>
|
|
<?php
|
|
|
|
if ($lead_edit_data['claim_history'] == 1) {
|
|
foreach ($claims as $key => $value) {
|
|
$isNilClaimRow = ! empty($value['nil_claims']);
|
|
?>
|
|
|
|
<div class="row claim-row<?= $isNilClaimRow ? ' claim-row-nil' : '' ?>">
|
|
<div class="form-group col-md-2 claim-year-group">
|
|
<label for="first_year_<?= $key ?>">Year<span class="text-danger claim-required-star">*</span></label>
|
|
<select class="form-control first_year_ claim-input" id="first_year_<?= $key ?>" name="first_year[]">
|
|
<option value="">Select Year</option>
|
|
<?php foreach ($lastFiveYears as $year) {
|
|
$selected = ($year == $value['year']) ? 'selected' : '';
|
|
echo "<option value='$year' $selected>$year</option>";
|
|
} ?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-2">
|
|
<label>Nil Claims</label>
|
|
<input type="hidden" class="nil-claims-value" name="nil_claims[]" value="<?= $isNilClaimRow ? '1' : '0' ?>">
|
|
<div class="custom-control custom-checkbox" style="padding-top: 8px;">
|
|
<input type="checkbox" class="custom-control-input nil-claims-checkbox" id="nil_claims_<?= $key ?>" onchange="nilClaimsToggle(this)"<?= $isNilClaimRow ? ' checked' : '' ?>>
|
|
<label class="custom-control-label" for="nil_claims_<?= $key ?>">Nil Claims</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group col-md-2 claim-field-group">
|
|
<label for="first_policy_type_<?= $key ?>">Policy Type<span class="text-danger claim-required-star"<?= $isNilClaimRow ? ' style="display:none;"' : '' ?>>*</span></label>
|
|
<input type="text" class="form-control claim-input" id="first_policy_type_<?= $key ?>" name="first_policy_type_[]"
|
|
value="<?= htmlspecialchars($value['policy_type'] ?? '') ?>"<?= $isNilClaimRow ? ' disabled' : '' ?>>
|
|
</div>
|
|
<div class="form-group col-md-2 claim-field-group">
|
|
<label for="first_date_of_loss_<?= $key ?>">Date of Loss<span class="text-danger claim-required-star"<?= $isNilClaimRow ? ' style="display:none;"' : '' ?>>*</span></label>
|
|
<input type="text" class="form-control loss_date claim-input" id="first_date_of_loss_<?= $key ?>" name="first_date_of_loss_[]"
|
|
value="<?= htmlspecialchars($value['date_of_loss'] ?? '') ?>"<?= $isNilClaimRow ? ' disabled' : '' ?>>
|
|
</div>
|
|
<div class="form-group col-md-2 claim-field-group">
|
|
<label for="first_cause_of_loss_<?= $key ?>">Cause Of Loss <span class="text-danger claim-required-star"<?= $isNilClaimRow ? ' style="display:none;"' : '' ?>>*</span></label>
|
|
<input type="text" class="form-control claim-input" id="first_cause_of_loss_<?= $key ?>" name="first_cause_of_loss[]"
|
|
value="<?= htmlspecialchars($value['cause_of_loss'] ?? '') ?>"<?= $isNilClaimRow ? ' disabled' : '' ?>>
|
|
</div>
|
|
<div class="form-group col-md-2 claim-field-group">
|
|
<label for="first_claim_amount_<?= $key ?>">Claim Amount<span class="text-danger claim-required-star"<?= $isNilClaimRow ? ' style="display:none;"' : '' ?>>*</span></label>
|
|
<input type="text" class="form-control claim-input" id="first_claim_amount_<?= $key ?>" name="first_claim_amount[]"
|
|
value="<?= htmlspecialchars($value['claim_amount'] ?? '') ?>"<?= $isNilClaimRow ? ' disabled' : '' ?>>
|
|
</div>
|
|
<div class="form-group col-md-2 claim-field-group">
|
|
<label for="first_settled_amount_<?= $key ?>">Settled Amount<span class="text-danger claim-required-star"<?= $isNilClaimRow ? ' style="display:none;"' : '' ?>>*</span></label>
|
|
<input type="text" class="form-control claim-input" id="first_settled_amount_<?= $key ?>" name="first_settled_amount[]"
|
|
value="<?= htmlspecialchars($value['settled_amount'] ?? '') ?>"<?= $isNilClaimRow ? ' disabled' : '' ?>>
|
|
</div>
|
|
<div class="form-group col-md-2 claim-field-group">
|
|
<label for="first_claim_status_<?= $key ?>">Claim Status<span class="text-danger claim-required-star"<?= $isNilClaimRow ? ' style="display:none;"' : '' ?>>*</span></label>
|
|
<input type="text" class="form-control claim-input" id="first_claim_status_<?= $key ?>" name="first_claim_status[]"
|
|
value="<?= htmlspecialchars($value['status'] ?? '') ?>"<?= $isNilClaimRow ? ' disabled' : '' ?>>
|
|
</div>
|
|
<div class="form-group col-md-2">
|
|
<div class="" style="position: relative; top: 28px; float: right; text-align: end;">
|
|
<a class="btn btn-danger waves-effect waves-light" onclick="removeClaim(this)">x</a>
|
|
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="appendThreeYearsClaims()">+</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
<script>
|
|
$(".loss_date").each(function () {
|
|
flatpickr(this, {
|
|
dateFormat: "d-m-Y",
|
|
});
|
|
});
|
|
|
|
if (typeof initNilClaimsRows === 'function') {
|
|
initNilClaimsRows();
|
|
}
|
|
|
|
if (typeof updateNonEbClaimRowVisibility === 'function') {
|
|
updateNonEbClaimRowVisibility();
|
|
}
|
|
</script>
|
|
<?php } ?>
|
|
<?php } ?>
|