Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
14e7dda615
@ -17,7 +17,9 @@ class Acl
|
||||
'#^/getVerifiedPosUserData#' => ['public' => true],
|
||||
'#^/swagger#' => ['roles' => [ADMIN_ROLE_ID]],
|
||||
'#^/getEmployeeActiveOrInactivePolicy#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],
|
||||
'#^/sendextraparam#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],
|
||||
'#^/test/testingquerys#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],
|
||||
'#^/test/viewrfq#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],
|
||||
'#^/fedeploy#' => ['roles' => [ADMIN_ROLE_ID]],
|
||||
'#^/visitOffBoardCheck#' => ['roles' => [ADMIN_ROLE_ID]],
|
||||
'#^/logs#' => ['roles' => [ADMIN_ROLE_ID]],
|
||||
|
||||
@ -694,6 +694,7 @@ $routes->group("employeeRest", ["filter" => ['GlobalPostFileUploadGuard', 'ratel
|
||||
$routes->get("getPolicyAndEndorsementFiles", "EmployeeRestController::getPolicyAndEndorsementFiles");
|
||||
$routes->get("downloadPolicyFiles", "EmployeeRestController::downloadPolicyFiles");
|
||||
$routes->post("bulkEcardDownloadAsZip", "EmployeeRestController::bulkEcardDownloadAsZip");
|
||||
$routes->get("downloadSampleExcel/(:any)", "EmployeeController::downloadSampleExcelFile/$1");
|
||||
});
|
||||
|
||||
$routes->get("hrFileDownload", "EmployeeRestController::hrFileDownload");
|
||||
|
||||
@ -1036,12 +1036,13 @@ class ClientController extends AdminController
|
||||
// ]
|
||||
// ],
|
||||
'client_logo' => [
|
||||
'label' => 'Client Logo',
|
||||
'rules' => 'permit_empty|is_image[client_logo]|max_size[client_logo,200]|ext_in[client_logo,jpg,jpeg,png]|max_dims[client_logo,100,100]',
|
||||
'errors' => [
|
||||
'is_image' => 'The uploaded file must be an image',
|
||||
'max_size' => 'File size should not exceed 200 KB',
|
||||
'ext_in' => 'Allowed file types: jpg, jpeg, png',
|
||||
'max_dims' => 'Image dimensions must be 100 x 100 pixels',
|
||||
'is_image' => 'Please upload a valid image file.',
|
||||
'max_size' => 'The logo is too heavy (Max 200KB).',
|
||||
'ext_in' => 'Only JPG, JPEG, and PNG files are allowed.',
|
||||
'max_dims' => 'The logo must be no larger than 100x100 pixels.',
|
||||
]
|
||||
],
|
||||
];
|
||||
@ -6990,6 +6991,7 @@ class ClientController extends AdminController
|
||||
// $res = $policyTransactionController->validateInsurerStatement(['file_id' => '281']);
|
||||
// $res = $policyTransactionController->updateInsurerStatement(['file_id' => '62']);
|
||||
// $res = $policyTransactionController->bdsDumpExcelFileFormatValidation(['file_id' => '73']);
|
||||
// $res = $policyTransactionController->insertBulkBdsData(['file_id' => '78']);
|
||||
// dd($res);
|
||||
|
||||
// ----------EMP DATA SERVICE CONTROLLER--------------------------------------------------------------------------------
|
||||
|
||||
@ -1673,10 +1673,16 @@ class EmployeeRestController extends AdminController
|
||||
{
|
||||
try {
|
||||
|
||||
$client = $this->clientModel->where('md5(id)', $this->request->getGet('client_id'))->first();
|
||||
$client_id = $this->request->getGet('client_id');
|
||||
if (is_string($client_id) && preg_match('/^[a-f0-9]{32}$/i', $client_id)) {
|
||||
$client = $this->clientModel->where('MD5(id)', $client_id)->first();
|
||||
}else{
|
||||
$client = $this->clientModel->where('id', $client_id)->first();
|
||||
}
|
||||
|
||||
if (!empty($client)) {
|
||||
$client['client_logo'] = base_url() . 'public/uploads/logo/' . $client['client_logo'];
|
||||
$clientPolicy = $this->clientPolicyModel->where('md5(client_id)', $this->request->getGet('client_id'))
|
||||
$clientPolicy = $this->clientPolicyModel->where('client_id', $client['id'])
|
||||
->where('client_branch_id', $this->request->getGet('client_branch_id'))->findAll();
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => ['client' => $client, 'client_policy' => $clientPolicy]], 200);
|
||||
} else {
|
||||
|
||||
@ -447,7 +447,14 @@ class LeadsController extends BaseController
|
||||
'status' => [
|
||||
'rules' => 'required',
|
||||
'errors' => ['required' => 'Status is required']
|
||||
]
|
||||
],
|
||||
'next_reminder_date' => [
|
||||
'label' => 'Next Reminder Date',
|
||||
'rules' => 'permit_empty|valid_date[d/m/Y]',
|
||||
'errors' => [
|
||||
'valid_date' => 'The {field} must be in the format DD/MM/YYYY.'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($postData as $key => $value) {
|
||||
@ -465,7 +472,7 @@ class LeadsController extends BaseController
|
||||
|
||||
// print_r($rules); die;
|
||||
|
||||
if (isset($data['lead_form_type']) && (int)$data['lead_form_type'] === 2) {
|
||||
if ((int)$this->request->getPost('lead_form_type') === 2) {
|
||||
$rules['client_type'] = [
|
||||
'rules' => 'required',
|
||||
'errors' => ['required' => 'Client Type is required']
|
||||
@ -482,6 +489,51 @@ class LeadsController extends BaseController
|
||||
'rules' => 'required',
|
||||
'errors' => ['required' => 'Date of Expiry is required']
|
||||
];
|
||||
|
||||
if ((int)$this->request->getPost('claim_history') === 1) {
|
||||
$rules['first_year.*'] = [
|
||||
'rules' => 'required|regex_match[/^\d{4}-\d{4}$/]',
|
||||
'errors' => ['required' => 'Claim Year is required for all entries.','regex_match' => 'Year must be in format YYYY-YYYY.']
|
||||
];
|
||||
$rules['first_policy_type_.*'] = [
|
||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]',
|
||||
'errors' => ['required' => 'Policy Type is required in Claim History.',
|
||||
'regex_match' => 'Policy Type only letters, numbers, space, hyphens and underscores are allowed'
|
||||
]
|
||||
];
|
||||
$rules['first_date_of_loss_.*'] = [
|
||||
'rules' => 'required|regex_match[/^[0-9]{2}-[0-9]{2}-[0-9]{4}$/]',
|
||||
'errors' => ['required' => 'Date of Loss is required.',
|
||||
'regex_match' => 'Date of Loss must be inValid format.']
|
||||
];
|
||||
$rules['first_cause_of_loss.*'] = [
|
||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_-]+$/]',
|
||||
'errors' => [
|
||||
'required' => 'Cause of Loss is required.',
|
||||
'regex_match' => 'Cause of Loss only letters, numbers, space, hyphens and underscores are allowed'
|
||||
]
|
||||
];
|
||||
$rules['first_claim_amount.*'] = [
|
||||
'rules' => 'required|numeric',
|
||||
'errors' => [
|
||||
'required' => 'Claim Amount is required.',
|
||||
'numeric' => 'Claim Amount must be a number.'
|
||||
]
|
||||
];
|
||||
$rules['first_settled_amount.*'] = [
|
||||
'rules' => 'required|numeric',
|
||||
'errors' => ['required' => 'Settled Amount is required.',
|
||||
'numeric' => 'Settled Amount must be a number.']
|
||||
];
|
||||
$rules['first_claim_status.*'] = [
|
||||
'rules' => 'required|alpha_space',
|
||||
'errors' => [
|
||||
'required' => 'Claim Status is required.',
|
||||
'alpha_space' => 'Claim Status should only contain letters and spaces.'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 1. MANUALLY VALIDATE FILES BEFORE PROCESSING
|
||||
@ -516,7 +568,41 @@ class LeadsController extends BaseController
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!$this->validate($rules)) {
|
||||
|
||||
$isValid = $this->validate($rules);
|
||||
|
||||
$start_dates = $this->request->getPost('policy_start_date');
|
||||
$end_dates = $this->request->getPost('policy_end_date');
|
||||
|
||||
if ($start_dates && $end_dates) {
|
||||
|
||||
$starts = is_array($start_dates) ? $start_dates : [$start_dates];
|
||||
$ends = is_array($end_dates) ? $end_dates : [$end_dates];
|
||||
|
||||
foreach ($starts as $index => $s_date) {
|
||||
$e_date = $ends[$index] ?? null;
|
||||
|
||||
if ($s_date && $e_date) {
|
||||
|
||||
$f_start = change_date_format($s_date, 'd/m/Y', 'Y-m-d');
|
||||
$f_end = change_date_format($e_date, 'd/m/Y', 'Y-m-d');
|
||||
|
||||
if ($f_start && $f_end && ($f_end < $f_start)) {
|
||||
$isValid = false;
|
||||
|
||||
// Determine the error key name
|
||||
// If it's an array, we use index (e.g., policy_end_date.0)
|
||||
$errorKey = is_array($start_dates) ? "policy_end_date.$index" : "policy_end_date";
|
||||
|
||||
$this->validator->setError($errorKey, 'Date of Expiry cannot be before Date of Commencement.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$isValid) {
|
||||
|
||||
return $this->response->setStatusCode(400)->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Input validation failed',
|
||||
@ -715,9 +801,13 @@ class LeadsController extends BaseController
|
||||
$data['source_policy_end_date'] = null;
|
||||
}
|
||||
|
||||
//convert the date
|
||||
if (!empty($data['next_reminder_date'])) {
|
||||
$data['next_reminder_date'] = change_date_format($data['next_reminder_date']);
|
||||
// convert the date
|
||||
// Clean the input and handle empty strings
|
||||
$reminderDate = trim($data['next_reminder_date'] ?? '');
|
||||
|
||||
if ($reminderDate !== '' && $reminderDate != null && $reminderDate != 0) {
|
||||
$convertedDate = change_date_format($reminderDate);
|
||||
$data['next_reminder_date'] = $convertedDate ?: null;
|
||||
} else {
|
||||
$data['next_reminder_date'] = null;
|
||||
}
|
||||
|
||||
@ -1052,7 +1052,47 @@ class PolicyTransactionController extends BaseController
|
||||
'exp_amt.*' => ['label' => 'Expected Amount', 'rules' => 'permit_empty|decimal', 'errors' => ['decimal' => 'The Expected Amount field must contain a valid number.']]
|
||||
];
|
||||
|
||||
if (!$this->validate($rules)) {
|
||||
|
||||
$isValid = $this->validate($rules);
|
||||
|
||||
// $Date_of_commencement = $this->request->getPost('policy_start_date');
|
||||
// $Date_of_expiry = $this->request->getPost('policy_end_date');
|
||||
|
||||
// if ($Date_of_commencement && $Date_of_expiry && ($Date_of_expiry < $Date_of_commencement)) {
|
||||
// $this->validator->setError('policy_end_date', '$Date of Commencement and Date of Expiry are mismatched (Date of Expiry cannot be before $Date of Commencement).');
|
||||
// $isValid = false;
|
||||
// }
|
||||
|
||||
$start_dates = $this->request->getPost('policy_start_date');
|
||||
$end_dates = $this->request->getPost('policy_end_date');
|
||||
|
||||
if ($start_dates && $end_dates) {
|
||||
// Standardize: If it's a single string (Type 2), wrap it in an array
|
||||
$starts = is_array($start_dates) ? $start_dates : [$start_dates];
|
||||
$ends = is_array($end_dates) ? $end_dates : [$end_dates];
|
||||
|
||||
foreach ($starts as $index => $s_date) {
|
||||
$e_date = $ends[$index] ?? null;
|
||||
|
||||
if ($s_date && $e_date) {
|
||||
|
||||
$f_start = change_date_format($s_date, 'Y-m-d', 'Y-m-d'); // be carefully here we made so many times mistakes on here
|
||||
$f_end = change_date_format($e_date, 'Y-m-d', 'Y-m-d');// be carefully here we made so many times mistakes on here
|
||||
|
||||
if ($f_start && $f_end && ($f_end < $f_start)) {
|
||||
$isValid = false;
|
||||
|
||||
// Determine the error key name
|
||||
// If it's an array, we use index (e.g., policy_end_date.0)
|
||||
$errorKey = is_array($start_dates) ? "policy_end_date.$index" : "policy_end_date";
|
||||
|
||||
$this->validator->setError($errorKey, 'D.O.E(Date of Expiry) cannot be before D.O.C(Date of Commencement).');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isValid) {
|
||||
return $this->response->setStatusCode(400)->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Input validation failed',
|
||||
@ -5671,6 +5711,7 @@ class PolicyTransactionController extends BaseController
|
||||
// 'agent_code' => $current_agent_data['agent_code'] ?? null,
|
||||
'pos_id' => $current_agent_data['id'] ?? null,
|
||||
'file_id' => $params['file_id'],
|
||||
'created_by' => $file['created_by'] ?? null,
|
||||
'endorsement_no' => null,
|
||||
'client_branch_id' => null,
|
||||
'client_policy_id' => null,
|
||||
@ -5745,7 +5786,8 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
'pt_policy_issue_date' => change_date_format($policy_issue_date, 'd/M/Y', 'Y-m-d'),
|
||||
|
||||
'file_id' => $params['file_id']
|
||||
'file_id' => $params['file_id'],
|
||||
'created_by' => $file['created_by'] ?? null,
|
||||
];
|
||||
|
||||
if(!empty($vehicle_id) && !empty($client_id)){
|
||||
@ -5987,10 +6029,12 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
if (empty($vehicle_id) && empty($client_id)) {
|
||||
|
||||
foreach ($client_data as $c) {
|
||||
if (strcasecmp(trim($c['email']), $client_email) === 0) {
|
||||
$second_stage_client_id = $c['id'];
|
||||
break;
|
||||
if(strtolower(trim($vehicle_number)) != 'new'){
|
||||
foreach ($client_data as $c) {
|
||||
if (strcasecmp(trim($c['email']), $client_email) === 0) {
|
||||
$second_stage_client_id = $c['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6047,4 +6091,15 @@ class PolicyTransactionController extends BaseController
|
||||
];
|
||||
}
|
||||
|
||||
public function truncateBdsBulkUploadData()
|
||||
{
|
||||
$file_id = $this->request->getGet('file_id') ?? null;
|
||||
if (empty($file_id)) {
|
||||
return array('status' => false, 'message' => 'file_id is required');
|
||||
}
|
||||
|
||||
$this->policyTransactionModel->select()->findAll();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class GlobalPostFileUploadGuard implements FilterInterface
|
||||
'application/vnd.oasis.opendocument.text' => ['odt'],
|
||||
'text/rtf' => ['rtf'],
|
||||
'application/rtf' => ['rtf'],
|
||||
'application/vnd.ms-excel' => ['xls'],
|
||||
'application/vnd.ms-excel' => ['xls', 'xlsx'],
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => ['xlsx'],
|
||||
'application/vnd.oasis.opendocument.spreadsheet' => ['ods'],
|
||||
'text/csv' => ['csv'],
|
||||
|
||||
@ -221,6 +221,7 @@ input:checked + .slider:before {
|
||||
$(document).ready(function() {
|
||||
$('#client_logo').change(function() {
|
||||
validateFile(this);
|
||||
return;
|
||||
});
|
||||
$('#parent_client_id').select2();
|
||||
});
|
||||
|
||||
@ -1027,7 +1027,7 @@
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_year_${increment}">Year<span class="text-danger">*</span></label>
|
||||
<select class="form-control first_year_" id="first_year_${increment}" name="first_year[]">
|
||||
<select class="form-control claim-input first_year_" id="first_year_${increment}" name="first_year[]">
|
||||
<option value="">Select Year</option>
|
||||
<?php foreach ($lastFiveYears as $year) {
|
||||
echo "<option value='$year'>$year</option>";
|
||||
@ -1036,27 +1036,27 @@
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_policy_type_${increment}">Policy Type<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_policy_type_${increment}" name="first_policy_type_[]">
|
||||
<input type="text" class="form-control claim-input" id="first_policy_type_${increment}" name="first_policy_type_[]">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_date_of_loss_${increment}">Date of Loss<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control loss_date" id="first_date_of_loss_${increment}" name="first_date_of_loss_[]">
|
||||
<input type="text" class="form-control loss_date claim-input" id="first_date_of_loss_${increment}" name="first_date_of_loss_[]">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_cause_of_death_${increment}">Cause Of Loss <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]">
|
||||
<input type="text" class="form-control claim-input" id="first_cause_of_loss_${increment}" name="first_cause_of_loss[]">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_claim_amount_${increment}">Claim Amount<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_claim_amount_${increment}" name="first_claim_amount[]">
|
||||
<input type="text" class="form-control claim-input" id="first_claim_amount_${increment}" name="first_claim_amount[]">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_claim_amount_${increment}">Settled Amount<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_settled_amount_${increment}" name="first_settled_amount[]">
|
||||
<input type="text" class="form-control claim-input" id="first_settled_amount_${increment}" name="first_settled_amount[]">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="first_claim_status_${increment}">Claim Status<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="first_claim_status_${increment}" name="first_claim_status[]">
|
||||
<input type="text" class="form-control claim-input" id="first_claim_status_${increment}" name="first_claim_status[]">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<div class="" style="position: relative; top: 28px; float: right; text-align: end;">
|
||||
@ -1072,6 +1072,16 @@
|
||||
|
||||
referenceDiv.insertAdjacentHTML('beforeend', claimsFields);
|
||||
|
||||
let isChecked = $("#claim_history").length > 0 ? $("#claim_history").prop("checked") : true;
|
||||
let lastRow = $(".claim-row").last();
|
||||
if (isChecked) {
|
||||
lastRow.show();
|
||||
lastRow.find(".claim-input").attr("required", true);
|
||||
} else {
|
||||
lastRow.hide();
|
||||
lastRow.find(".claim-input").removeAttr("required");
|
||||
}
|
||||
|
||||
// Increment claim index
|
||||
increment = increment + 1;
|
||||
|
||||
@ -1143,9 +1153,15 @@
|
||||
// No rows yet, so create them
|
||||
appendThreeYearsClaims();
|
||||
}
|
||||
$(".claim-input").attr("required", true);
|
||||
} else {
|
||||
|
||||
$(".claim-row").hide();
|
||||
$(".claim-input").removeAttr("required"); // Required Attributes Remove
|
||||
$(".claim-input").val(""); // Value Reset
|
||||
$(".claim-input").each(function() {
|
||||
$(this).parsley().reset(); // Validation Reset
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user