Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
bd9d15d4c1
@ -2689,7 +2689,7 @@ class ClientController extends AdminController
|
|||||||
'errors' => ['required' => 'Please select a Client Branch.']
|
'errors' => ['required' => 'Please select a Client Branch.']
|
||||||
],
|
],
|
||||||
'policy_type_id' => [
|
'policy_type_id' => [
|
||||||
'rules' => 'required|is_natural_no_zero',
|
'rules' => ['required', 'is_natural_no_zero'],
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'Policy Type is required.',
|
'required' => 'Policy Type is required.',
|
||||||
'is_natural_no_zero' => 'Please select a valid Policy Type.'
|
'is_natural_no_zero' => 'Please select a valid Policy Type.'
|
||||||
@ -2707,11 +2707,16 @@ class ClientController extends AdminController
|
|||||||
'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\s_\-\/\\\]+$/]'],
|
'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\s_\-\/\\\]+$/]'],
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'Policy No is required.',
|
'required' => 'Policy No is required.',
|
||||||
'regex_match' => 'Policy No Only letters, numbers, spaces, underscores, hyphens, forward slashes, and backslashes are allowed.'
|
'regex_match' => 'Invalid characters in Policy No.'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'gst' => [
|
'gst' => [
|
||||||
'rules' => 'required|numeric|greater_than_equal_to[0]|less_than_equal_to[100]',
|
'rules' => [
|
||||||
|
'required',
|
||||||
|
'numeric',
|
||||||
|
'greater_than_equal_to[0]',
|
||||||
|
'less_than_equal_to[100]'
|
||||||
|
],
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'GST percentage is required.',
|
'required' => 'GST percentage is required.',
|
||||||
'numeric' => 'GST must be a valid number.',
|
'numeric' => 'GST must be a valid number.',
|
||||||
@ -2735,16 +2740,31 @@ class ClientController extends AdminController
|
|||||||
'rules' => 'permit_empty'
|
'rules' => 'permit_empty'
|
||||||
],
|
],
|
||||||
'disclaimer' => [
|
'disclaimer' => [
|
||||||
'rules' => 'permit_empty|string|min_length[5]',
|
'rules' => ['permit_empty', 'string', 'min_length[5]'],
|
||||||
'errors' => ['min_length' => 'Disclaimer should be at least 5 characters long if provided.']
|
'errors' => ['min_length' => 'Disclaimer should be at least 5 characters long if provided.']
|
||||||
],
|
],
|
||||||
|
|
||||||
// --- CHECKBOXES (Permit Empty) ---
|
|
||||||
'enrolment_visibility' => ['rules' => 'permit_empty'],
|
'enrolment_visibility' => ['rules' => 'permit_empty'],
|
||||||
'is_lgbtq' => ['rules' => 'permit_empty']
|
'is_lgbtq' => ['rules' => 'permit_empty']
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!$this->validate($rules)) {
|
// 2. Run the initial validation
|
||||||
|
$isValid = $this->validate($rules);
|
||||||
|
|
||||||
|
// 3. Perform manual date comparison
|
||||||
|
$start = $this->request->getPost('policy_start_date');
|
||||||
|
$end = $this->request->getPost('policy_end_date');
|
||||||
|
|
||||||
|
$startDate = change_date_format($start ?? null, 'd-m-Y', 'Y-m-d') ?? null;
|
||||||
|
$endDate = change_date_format($end ?? null, 'd-m-Y', 'Y-m-d') ?? null;
|
||||||
|
|
||||||
|
if ($startDate && $endDate && ($endDate < $startDate)) {
|
||||||
|
// Manually push the error into the validator
|
||||||
|
$this->validator->setError('policy_end_date', 'Policy start and end date are mismatched (End date cannot be before Start date).');
|
||||||
|
$isValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Check final status
|
||||||
|
if (!$isValid) {
|
||||||
return $this->response->setStatusCode(400)->setJSON([
|
return $this->response->setStatusCode(400)->setJSON([
|
||||||
'status' => false,
|
'status' => false,
|
||||||
'message' => 'Input validation failed',
|
'message' => 'Input validation failed',
|
||||||
@ -2851,13 +2871,12 @@ class ClientController extends AdminController
|
|||||||
public function editClientPolicy()
|
public function editClientPolicy()
|
||||||
{
|
{
|
||||||
$rules = [
|
$rules = [
|
||||||
// --- BASIC SELECTS (Required) ---
|
|
||||||
'client_branch_id' => [
|
'client_branch_id' => [
|
||||||
'rules' => 'required',
|
'rules' => 'required',
|
||||||
'errors' => ['required' => 'Please select a Client Branch.']
|
'errors' => ['required' => 'Please select a Client Branch.']
|
||||||
],
|
],
|
||||||
'policy_type_id' => [
|
'policy_type_id' => [
|
||||||
'rules' => 'required|is_natural_no_zero',
|
'rules' => ['required', 'is_natural_no_zero'],
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'Policy Type is required.',
|
'required' => 'Policy Type is required.',
|
||||||
'is_natural_no_zero' => 'Please select a valid Policy Type.'
|
'is_natural_no_zero' => 'Please select a valid Policy Type.'
|
||||||
@ -2871,17 +2890,20 @@ class ClientController extends AdminController
|
|||||||
'rules' => 'required',
|
'rules' => 'required',
|
||||||
'errors' => ['required' => 'Please select a TPA.']
|
'errors' => ['required' => 'Please select a TPA.']
|
||||||
],
|
],
|
||||||
|
|
||||||
// --- TEXT FIELDS (Required & Specific Format) ---
|
|
||||||
'policy_no' => [
|
'policy_no' => [
|
||||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9\s_\-\/\\\]+$/]',
|
'rules' => ['required', 'regex_match[/^[a-zA-Z0-9\s_\-\/\\\]+$/]'],
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'This field is required.',
|
'required' => 'Policy No is required.',
|
||||||
'regex_match' => 'Only letters, numbers, spaces, _, -, /, and \ are allowed.'
|
'regex_match' => 'Invalid characters in Policy No.'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'gst' => [
|
'gst' => [
|
||||||
'rules' => 'required|numeric|greater_than_equal_to[0]|less_than_equal_to[100]',
|
'rules' => [
|
||||||
|
'required',
|
||||||
|
'numeric',
|
||||||
|
'greater_than_equal_to[0]',
|
||||||
|
'less_than_equal_to[100]'
|
||||||
|
],
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'GST percentage is required.',
|
'required' => 'GST percentage is required.',
|
||||||
'numeric' => 'GST must be a valid number.',
|
'numeric' => 'GST must be a valid number.',
|
||||||
@ -2889,47 +2911,47 @@ class ClientController extends AdminController
|
|||||||
'less_than_equal_to' => 'GST percentage cannot exceed 100%.'
|
'less_than_equal_to' => 'GST percentage cannot exceed 100%.'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
// --- DATE FIELDS (Required) ---
|
|
||||||
'policy_start_date' => [
|
'policy_start_date' => [
|
||||||
'rules' => 'required|valid_date',
|
'rules' => 'required',
|
||||||
'errors' => [
|
'errors' => ['required' => 'Start date is required.']
|
||||||
'required' => 'Start date is required.',
|
|
||||||
'valid_date' => 'Enter a valid date format (YYYY-MM-DD).'
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'policy_end_date' => [
|
'policy_end_date' => [
|
||||||
'rules' => 'required|valid_date',
|
'rules' => 'required',
|
||||||
'errors' => [
|
'errors' => ['required' => 'End date is required.']
|
||||||
'required' => 'End date is required.',
|
|
||||||
'valid_date' => 'Enter a valid date format (YYYY-MM-DD).'
|
|
||||||
]
|
|
||||||
],
|
|
||||||
|
|
||||||
// --- PERMIT EMPTY FIELDS (Optional) ---
|
|
||||||
'base_policy' => [
|
|
||||||
'rules' => 'permit_empty'
|
|
||||||
],
|
],
|
||||||
'wellness_plan_id' => [
|
'wellness_plan_id' => [
|
||||||
'rules' => 'permit_empty|alpha_numeric',
|
'rules' => 'permit_empty|alpha_numeric',
|
||||||
'errors' => [
|
'errors' => ['alpha_numeric' => 'Wellness Plan ID can only contain letters and numbers.']
|
||||||
'alpha_numeric' => 'Wellness Plan ID can only contain letters and numbers (no spaces or special characters).'
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'wellness_vendor_id' => [
|
'wellness_vendor_id' => [
|
||||||
'rules' => 'permit_empty'
|
'rules' => 'permit_empty'
|
||||||
],
|
],
|
||||||
'disclaimer' => [
|
'disclaimer' => [
|
||||||
'rules' => 'permit_empty|string|min_length[5]',
|
'rules' => ['permit_empty', 'string', 'min_length[5]'],
|
||||||
'errors' => ['min_length' => 'Disclaimer should be at least 5 characters long if provided.']
|
'errors' => ['min_length' => 'Disclaimer should be at least 5 characters long if provided.']
|
||||||
],
|
],
|
||||||
|
|
||||||
// --- CHECKBOXES (Permit Empty) ---
|
|
||||||
'enrolment_visibility' => ['rules' => 'permit_empty'],
|
'enrolment_visibility' => ['rules' => 'permit_empty'],
|
||||||
'is_lgbtq' => ['rules' => 'permit_empty']
|
'is_lgbtq' => ['rules' => 'permit_empty']
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!$this->validate($rules)) {
|
// 2. Run the initial validation
|
||||||
|
$isValid = $this->validate($rules);
|
||||||
|
|
||||||
|
// 3. Perform manual date comparison
|
||||||
|
$start = $this->request->getPost('policy_start_date');
|
||||||
|
$end = $this->request->getPost('policy_end_date');
|
||||||
|
|
||||||
|
$startDate = change_date_format($start ?? null, 'd-m-Y', 'Y-m-d') ?? null;
|
||||||
|
$endDate = change_date_format($end ?? null, 'd-m-Y', 'Y-m-d') ?? null;
|
||||||
|
|
||||||
|
if ($startDate && $endDate && ($endDate < $startDate)) {
|
||||||
|
// Manually push the error into the validator
|
||||||
|
$this->validator->setError('policy_end_date', 'Policy start and end date are mismatched (End date cannot be before Start date).');
|
||||||
|
$isValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Check final status
|
||||||
|
if (!$isValid) {
|
||||||
return $this->response->setStatusCode(400)->setJSON([
|
return $this->response->setStatusCode(400)->setJSON([
|
||||||
'status' => false,
|
'status' => false,
|
||||||
'message' => 'Input validation failed',
|
'message' => 'Input validation failed',
|
||||||
|
|||||||
@ -3180,12 +3180,11 @@ class TicketController extends BaseController
|
|||||||
],
|
],
|
||||||
'url.*' => [
|
'url.*' => [
|
||||||
'label' => 'URL',
|
'label' => 'URL',
|
||||||
'rules' => 'if_exist|required|regex_match[/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/]',
|
'rules' => 'required',
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'URL is required.',
|
'required' => 'URL is required',
|
||||||
'regex_match' => 'The URL format is invalid. Example: www.google.com or https://google.com'
|
]
|
||||||
]
|
]
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!$this->validate($rules)) {
|
if (!$this->validate($rules)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user