Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
46400a56ab
@ -100,6 +100,7 @@ $routes->group("/user", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->get("list", "UserController::list");
|
$routes->get("list", "UserController::list");
|
||||||
$routes->get("getuser/(:hash)", "UserController::getuser/$1");
|
$routes->get("getuser/(:hash)", "UserController::getuser/$1");
|
||||||
$routes->get("deactive/(:hash)", "UserController::deactive/$1");
|
$routes->get("deactive/(:hash)", "UserController::deactive/$1");
|
||||||
|
$routes->get("activateUser/(:any)", "UserController::activateUser/$1");
|
||||||
$routes->get("rolesandteams", "UserController::getRolesAndTeams");
|
$routes->get("rolesandteams", "UserController::getRolesAndTeams");
|
||||||
$routes->get("getUserActivityHistory", "UserController::getUserActivityHistory");
|
$routes->get("getUserActivityHistory", "UserController::getUserActivityHistory");
|
||||||
$routes->match(['get','post','put'], 'partner', 'UserController::partner');
|
$routes->match(['get','post','put'], 'partner', 'UserController::partner');
|
||||||
|
|||||||
@ -1004,8 +1004,8 @@ class ClientController extends AdminController
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
'short_name' => [
|
'short_name' => [
|
||||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]|min_length[2]|max_length[15]',
|
'rules' => 'required|regex_match[/^[a-zA-Z0-9_\- ]+$/]|min_length[2]|max_length[15]',
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'Client Short Name is required',
|
'required' => 'Client Short Name is required',
|
||||||
'regex_match' => 'Client Short Name can only contain letters, numbers, hyphens and underscores.',
|
'regex_match' => 'Client Short Name can only contain letters, numbers, hyphens and underscores.',
|
||||||
'min_length' => 'Client Short Name must be at least 2 characters.',
|
'min_length' => 'Client Short Name must be at least 2 characters.',
|
||||||
@ -1013,9 +1013,8 @@ class ClientController extends AdminController
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
'pan' => [
|
'pan' => [
|
||||||
'rules' => 'required|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]$/]',
|
'rules' => 'permit_empty|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]$/]',
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'PAN Number is required.',
|
|
||||||
'regex_match' => 'Invalid PAN format. Example: ABCDE1234F'
|
'regex_match' => 'Invalid PAN format. Example: ABCDE1234F'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@ -1120,7 +1119,7 @@ class ClientController extends AdminController
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
'short_name' => [
|
'short_name' => [
|
||||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]',
|
'rules' => 'required|regex_match[/^[a-zA-Z0-9_\- ]+$/]|min_length[2]|max_length[15]',
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'Client Short Name is required',
|
'required' => 'Client Short Name is required',
|
||||||
'regex_match' => 'Client Short Name can only contain letters, numbers, hyphens and underscores.',
|
'regex_match' => 'Client Short Name can only contain letters, numbers, hyphens and underscores.',
|
||||||
@ -1129,9 +1128,8 @@ class ClientController extends AdminController
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
'pan' => [
|
'pan' => [
|
||||||
'rules' => 'required|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]$/]',
|
'rules' => 'permit_empty|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]$/]',
|
||||||
'errors' => [
|
'errors' => [
|
||||||
'required' => 'PAN Number is required.',
|
|
||||||
'regex_match' => 'Invalid PAN format. Example: ABCDE1234F'
|
'regex_match' => 'Invalid PAN format. Example: ABCDE1234F'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@ -5803,6 +5801,99 @@ class ClientController extends AdminController
|
|||||||
|
|
||||||
// print_r($postData); die;
|
// print_r($postData); die;
|
||||||
$client_type = $postData['client_type'] ?? null;
|
$client_type = $postData['client_type'] ?? null;
|
||||||
|
$from_modal = $postData['from_modal'] ?? null;
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
'client_name' => [
|
||||||
|
'label' => 'Client Name',
|
||||||
|
'rules' => 'required|regex_match[/^[a-zA-Z0-9 ,\/_\-]+$/]',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Client Name is required.',
|
||||||
|
'regex_match' => 'Client Name only allows letters, numbers, spaces, and , / _ -'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'short_name' => [
|
||||||
|
'label' => 'Client Short Name',
|
||||||
|
'rules' => 'required|regex_match[/^[a-zA-Z0-9,\/_\-]+$/]|is_unique[clients.short_name]',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Short Name is required.',
|
||||||
|
'regex_match' => 'Short Name only allows letters, numbers, and , / _ -',
|
||||||
|
'is_unique' => 'This Short Name is already in use.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'pan' => [
|
||||||
|
'label' => 'PAN',
|
||||||
|
'rules' => 'permit_empty|regex_match[/^[A-Z]{5}[0-9]{4}[A-Z]{1}$/]',
|
||||||
|
'errors' => [
|
||||||
|
'regex_match' => 'Invalid PAN format (Example: ABCDE1234F).'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'entity_type_id' => [
|
||||||
|
'label' => 'Entity Type',
|
||||||
|
'rules' => 'required',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Please select an Entity Type.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'branch_name' => [
|
||||||
|
'label' => 'Branch Name',
|
||||||
|
'rules' => 'required|regex_match[/^[a-zA-Z0-9 ,\/_\-]+$/]',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Branch Name is required.',
|
||||||
|
'regex_match' => 'Branch Name only allows letters, numbers, spaces, and , / _ -'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'branch_code' => [
|
||||||
|
'label' => 'Branch Code',
|
||||||
|
'rules' => 'required|regex_match[/^[a-zA-Z0-9,\/_\-]+$/]',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Branch Code is required.',
|
||||||
|
'regex_match' => 'Branch Code only allows letters, numbers, and , / _ -'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'name' => [
|
||||||
|
'label' => 'Contact Person Name',
|
||||||
|
'rules' => 'required|regex_match[/^[a-zA-Z0-9 ,\/_\-]+$/]',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Name is required.',
|
||||||
|
'regex_match' => 'Name only allows letters, numbers, spaces, and , / _ -'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'mobile' => [
|
||||||
|
'label' => 'Mobile',
|
||||||
|
'rules' => 'required|numeric|exact_length[10]',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Mobile number is required.',
|
||||||
|
'numeric' => 'Mobile must contain only digits.',
|
||||||
|
'exact_length' => 'Mobile number must be exactly 10 digits.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'email' => [
|
||||||
|
'label' => 'Email',
|
||||||
|
'rules' => 'required|valid_email',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Email is required.',
|
||||||
|
'valid_email' => 'Please provide a valid email address.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'gst' => [
|
||||||
|
'label' => 'GST',
|
||||||
|
'rules' => 'required|regex_match[/^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$/]',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'GST Number is required.',
|
||||||
|
'regex_match' => 'Invalid GST format (Example: 12ABCDE1234F5Z6).'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isset($from_modal) && !$this->validate($rules)) {
|
||||||
|
return $this->response->setStatusCode(400)->setJSON([
|
||||||
|
'status' => false,
|
||||||
|
'message' => 'Input validation failed',
|
||||||
|
'code' => 400,
|
||||||
|
'errors' => $this->validator->getErrors()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$client_insert = null;
|
$client_insert = null;
|
||||||
if ($client_type == 2) {
|
if ($client_type == 2) {
|
||||||
@ -5928,7 +6019,8 @@ class ClientController extends AdminController
|
|||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
if (!$this->validate($rules)) {
|
|
||||||
|
if (!$this->validate($rules)) {
|
||||||
return $this->response->setStatusCode(400)->setJSON([
|
return $this->response->setStatusCode(400)->setJSON([
|
||||||
'status' => false,
|
'status' => false,
|
||||||
'message' => 'Input validation failed',
|
'message' => 'Input validation failed',
|
||||||
@ -5936,6 +6028,7 @@ class ClientController extends AdminController
|
|||||||
'errors' => $this->validator->getErrors()
|
'errors' => $this->validator->getErrors()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
$sanitized_post_data = sanitizeInputArrayAdvanced($data);
|
$sanitized_post_data = sanitizeInputArrayAdvanced($data);
|
||||||
$id = $sanitized_post_data['vehicle_primary_key'] ?? null;
|
$id = $sanitized_post_data['vehicle_primary_key'] ?? null;
|
||||||
|
|||||||
@ -370,7 +370,9 @@ class LeadsController extends BaseController
|
|||||||
$actual_lead_id = ! empty($actual_lead_id) ? $actual_lead_id : null;
|
$actual_lead_id = ! empty($actual_lead_id) ? $actual_lead_id : null;
|
||||||
$postData = $this->request->getPost();
|
$postData = $this->request->getPost();
|
||||||
$data = $this->prepareLeadData();
|
$data = $this->prepareLeadData();
|
||||||
$rules = [
|
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
|
||||||
'lead_type' => [
|
'lead_type' => [
|
||||||
'rules' => 'integer',
|
'rules' => 'integer',
|
||||||
@ -380,21 +382,6 @@ class LeadsController extends BaseController
|
|||||||
'rules' => 'required',
|
'rules' => 'required',
|
||||||
'errors' => ['required' => 'Issuer is required'],
|
'errors' => ['required' => 'Issuer is required'],
|
||||||
],
|
],
|
||||||
'entity_type_id' => [
|
|
||||||
'rules' => 'required',
|
|
||||||
'errors' => ['required' => 'Entity Type is required'],
|
|
||||||
],
|
|
||||||
'client_name' => [
|
|
||||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]',
|
|
||||||
'errors' => [
|
|
||||||
'required' => 'Client Name is required',
|
|
||||||
'regex_match' => 'Client Name only letters, numbers, space, hyphens and underscores are allowed',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'client_short_name' => [
|
|
||||||
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]',
|
|
||||||
'errors' => ['required' => 'Client Short Name is required', 'regex_match' => 'Client Short Name only letters, numbers, hyphens and underscores are allowed'],
|
|
||||||
],
|
|
||||||
'gst' => [
|
'gst' => [
|
||||||
'rules' => 'required|regex_match[/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/]',
|
'rules' => 'required|regex_match[/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/]',
|
||||||
'errors' => [
|
'errors' => [
|
||||||
@ -460,6 +447,30 @@ class LeadsController extends BaseController
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (isset($postData['lead_type']) && $postData['lead_type'] == 1) {
|
||||||
|
|
||||||
|
$rules['entity_type_id'] = [
|
||||||
|
'rules' => 'required',
|
||||||
|
'errors' => ['required' => 'Entity Type is required'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$rules['client_name'] = [
|
||||||
|
'rules' => 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Client Name is required',
|
||||||
|
'regex_match' => 'Client Name only letters, numbers, space, hyphens and underscores are allowed',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$rules['client_short_name'] = [
|
||||||
|
'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]',
|
||||||
|
'errors' => [
|
||||||
|
'required' => 'Client Short Name is required',
|
||||||
|
'regex_match' => 'Client Short Name only letters, numbers, hyphens and underscores are allowed'
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($postData as $key => $value) {
|
foreach ($postData as $key => $value) {
|
||||||
// Check if the key starts with 'docs_name_'
|
// Check if the key starts with 'docs_name_'
|
||||||
if (strpos($key, 'docs_name_') === 0) {
|
if (strpos($key, 'docs_name_') === 0) {
|
||||||
|
|||||||
@ -1290,7 +1290,13 @@ class TicketController extends BaseController
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
// --- ADDITIONAL / CONDITIONAL FIELDS ---
|
// --- ADDITIONAL / CONDITIONAL FIELDS ---
|
||||||
'claim_number' => ['label' => 'Claim Number','rules' => 'permit_empty|alpha_numeric_punct','errors' => ['alpha_numeric_punct' => 'Invalid Claim Number.']],
|
'claim_number' => [
|
||||||
|
'label' => 'Claim Number',
|
||||||
|
'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9\/_-]+$/]',
|
||||||
|
'errors' => [
|
||||||
|
'regex_match' => 'Claim Number only allows letters, numbers, slashes (/), hyphens (-), and underscores (_).'
|
||||||
|
]
|
||||||
|
],
|
||||||
'denial_date' => ['label' => 'Denial Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Denial Date must be dd/mm/yyyy.']],
|
'denial_date' => ['label' => 'Denial Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Denial Date must be dd/mm/yyyy.']],
|
||||||
'approved_amount' => ['label' => 'Approved Amount','rules' => 'permit_empty|numeric',
|
'approved_amount' => ['label' => 'Approved Amount','rules' => 'permit_empty|numeric',
|
||||||
'errors' => ['numeric' => 'Approved amount must be numeric']
|
'errors' => ['numeric' => 'Approved amount must be numeric']
|
||||||
@ -1649,7 +1655,13 @@ class TicketController extends BaseController
|
|||||||
],
|
],
|
||||||
|
|
||||||
// --- ADDITIONAL / CONDITIONAL FIELDS ---
|
// --- ADDITIONAL / CONDITIONAL FIELDS ---
|
||||||
'claim_number' => ['label' => 'Claim Number','rules' => 'permit_empty|alpha_numeric_punct','errors' => ['alpha_numeric_punct' => 'Invalid Claim Number.']],
|
'claim_number' => [
|
||||||
|
'label' => 'Claim Number',
|
||||||
|
'rules' => 'permit_empty|regex_match[/^[a-zA-Z0-9\/_-]+$/]',
|
||||||
|
'errors' => [
|
||||||
|
'regex_match' => 'Claim Number only allows letters, numbers, slashes (/), hyphens (-), and underscores (_).'
|
||||||
|
]
|
||||||
|
],
|
||||||
'denial_date' => ['label' => 'Denial Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Denial Date must be dd/mm/yyyy.']],
|
'denial_date' => ['label' => 'Denial Date','rules' => 'permit_empty|regex_match[/^\d{2}\/\d{2}\/\d{4}$/]','errors' => ['regex_match' => 'Denial Date must be dd/mm/yyyy.']],
|
||||||
'approved_amount' => ['label' => 'Approved Amount','rules' => 'permit_empty|numeric',
|
'approved_amount' => ['label' => 'Approved Amount','rules' => 'permit_empty|numeric',
|
||||||
'errors' => ['numeric' => 'Approved amount must be numeric']
|
'errors' => ['numeric' => 'Approved amount must be numeric']
|
||||||
|
|||||||
@ -474,7 +474,29 @@ class UserController extends AdminController
|
|||||||
$emailToDelete = $model->where('id', $id)->first();
|
$emailToDelete = $model->where('id', $id)->first();
|
||||||
$deactive = $model->where('id', $id)->set(['is_active' => 0])->update();
|
$deactive = $model->where('id', $id)->set(['is_active' => 0])->update();
|
||||||
|
|
||||||
$this->bookStack->deleteUser($emailToDelete);
|
// $this->bookStack->deleteUser($emailToDelete);
|
||||||
|
if($deactive)
|
||||||
|
{
|
||||||
|
// $db = \Config\Database::connect();
|
||||||
|
// $tableName = 'hdz_staff';
|
||||||
|
|
||||||
|
// $db->table($tableName)->insert($hdz_staff);
|
||||||
|
|
||||||
|
|
||||||
|
echo json_encode(array("status" => true));
|
||||||
|
}else{
|
||||||
|
echo json_encode(array("status" => false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activateUser($id = null)
|
||||||
|
{
|
||||||
|
$model = new UserModel();
|
||||||
|
|
||||||
|
$emailToDelete = $model->where('id', $id)->first();
|
||||||
|
$deactive = $model->where('id', $id)->set(['is_active' => 1])->update();
|
||||||
|
|
||||||
|
// $this->bookStack->deleteUser($emailToDelete);
|
||||||
if($deactive)
|
if($deactive)
|
||||||
{
|
{
|
||||||
// $db = \Config\Database::connect();
|
// $db = \Config\Database::connect();
|
||||||
|
|||||||
@ -388,8 +388,16 @@ table.dataTable tbody td {
|
|||||||
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
|
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
|
||||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||||
<div class="dropdown-menu dropdown-menu-right" style="cursor: pointer;">
|
<div class="dropdown-menu dropdown-menu-right" style="cursor: pointer;">
|
||||||
<a class="dropdown-item btnEdit" data-id="<?php echo $row->id; ?>"><i data-id="<?php echo $row->id; ?>" class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle btnEdit"></i>Edit</a>
|
<a data-toggle="modal" data-target="#con-close-modal" class="dropdown-item btnEdit" data-id="<?php echo $row->id; ?>"><i data-id="<?php echo $row->id; ?>" class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle btnEdit"></i>Edit</a>
|
||||||
<a class="dropdown-item btnDelete" data-id="<?php echo $row->id; ?>"><i data-id="<?php echo $row->id; ?>" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle btnDelete"></i>Delete</a>
|
<?php if($row->is_active == 1 && in_array(get_session_userid(), [1, 5])) { ?>
|
||||||
|
<a class="dropdown-item btnDelete" data-id="<?php echo $row->id; ?>"><i data-id="<?php echo $row->id; ?>" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle btnDelete"></i>Delete</a>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if($row->is_active == 0 && in_array(get_session_userid(), [1, 5])) { ?>
|
||||||
|
<a class="dropdown-item btnActivate" data-id="<?php echo $row->id; ?>">
|
||||||
|
<i class="mdi mdi-account-check mr-2 text-muted font-18 vertical-middle btnActivate" data-id="<?php echo $row->id; ?>"></i>
|
||||||
|
Activate
|
||||||
|
</a>
|
||||||
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@ -1208,7 +1216,29 @@ table.dataTable tbody td {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('body').on('click', '.btnActivate', function () {
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: "Are you sure?",
|
||||||
|
text: "You need to active this user",
|
||||||
|
icon: "info",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: "#3085d6",
|
||||||
|
confirmButtonText: "Yes",
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
|
||||||
|
var student_id = $(this).attr('data-id');
|
||||||
|
$.get('<?php echo base_url('user/activateUser/');?>'+student_id, function (data) {
|
||||||
|
console.log(data);
|
||||||
|
toastr.success('User actived successfully', 'Success');
|
||||||
|
window.location.reload()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$('body').on('click', '.btnPartnerEdit', function () {
|
$('body').on('click', '.btnPartnerEdit', function () {
|
||||||
let user = JSON.parse($(this).attr('data-obj')); // ✅ convert back to object
|
let user = JSON.parse($(this).attr('data-obj')); // ✅ convert back to object
|
||||||
|
|||||||
@ -67,8 +67,7 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="mobile">CD Account Number<span class="text-danger">*</span></label>
|
<label for="mobile">CD Account Number<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="cd_ac_no_for_cd_master" name="cd_ac_no" onkeypress="return onlyNumbers(event)" required data-parsley-type="digits">
|
<input type="text" class="form-control" id="cd_ac_no_for_cd_master" name="cd_ac_no" pattern="[a-zA-Z0-9\/_-]+" title="Only letters, numbers, /, -, and _ are allowed" required> <small style="margin-left: 10px;font-size: 10px;"><span class="text-danger" id="cd_ac_no_for_cd_master_errorr"></span></small>
|
||||||
<small style="margin-left: 10px;font-size: 10px;"><span class="text-danger" id="cd_ac_no_for_cd_master_errorr"></span></small>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
@ -366,4 +365,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
// Target the input by its ID
|
||||||
|
$('#cd_ac_no_for_cd_master').on('keypress', function(e) {
|
||||||
|
// Get the character code
|
||||||
|
var keyCode = e.which || e.keyCode;
|
||||||
|
var char = String.fromCharCode(keyCode);
|
||||||
|
|
||||||
|
// Regular Expression: allow a-z, A-Z, 0-9, /, -, _
|
||||||
|
// If the character doesn't match, prevent it from being typed
|
||||||
|
var regex = /^[a-zA-Z0-9\/_-]+$/;
|
||||||
|
|
||||||
|
if (!regex.test(char)) {
|
||||||
|
e.preventDefault();
|
||||||
|
// Optional: Show a quick error message in your span
|
||||||
|
$('#cd_ac_no_for_cd_master_errorr').text('Character not allowed').fadeOut(2000, function() {
|
||||||
|
$(this).text('').show();
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Also handle "Paste" to ensure invalid data isn't pasted in
|
||||||
|
$('#cd_ac_no_for_cd_master').on('input', function() {
|
||||||
|
var value = $(this).val();
|
||||||
|
var sanitized = value.replace(/[^a-zA-Z0-9\/_-]/g, '');
|
||||||
|
$(this).val(sanitized);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -124,8 +124,8 @@ input:checked + .slider:before {
|
|||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="pan">PAN<span class="text-danger">*</span></label>
|
<label for="pan">PAN<span class="text-danger"></span></label>
|
||||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN Number" data-parsley-error-message="Invalid PAN Number. Example: ABCDE1234F" value="<?= isset($client['pan']) ? $client['pan'] : '' ?>" name="pan" data-parsley-trigger="change" data-parsley-pattern="^[A-Z]{5}[0-9]{4}[A-Z]$" required>
|
<input type="text" class="form-control" id="pan" placeholder="Enter PAN Number" data-parsley-error-message="Invalid PAN Number. Example: ABCDE1234F" value="<?= isset($client['pan']) ? $client['pan'] : '' ?>" name="pan" data-parsley-trigger="change" data-parsley-pattern="^[A-Z]{5}[0-9]{4}[A-Z]$">
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="form-group col-md-4">
|
<!-- <div class="form-group col-md-4">
|
||||||
<label for="gst">GST<span class="text-danger">*</span></label>
|
<label for="gst">GST<span class="text-danger">*</span></label>
|
||||||
|
|||||||
@ -647,57 +647,58 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function toggleAccordion(header) {
|
|
||||||
if (event.target.classList.contains('fa-info-circle') ||
|
// function toggleAccordion(header) {
|
||||||
event.target.parentElement.classList.contains('fa-info-circle')) {
|
// if (event.target.classList.contains('fa-info-circle') ||
|
||||||
getHrActivityHistory();
|
// event.target.parentElement.classList.contains('fa-info-circle')) {
|
||||||
return; // Do nothing if click was on the info icon
|
// getHrActivityHistory();
|
||||||
}
|
// return; // Do nothing if click was on the info icon
|
||||||
const card = header.parentElement;
|
// }
|
||||||
const content = card.querySelector('.card-content');
|
// const card = header.parentElement;
|
||||||
const icon = header.querySelector('.accordion-icon i');
|
// const content = card.querySelector('.card-content');
|
||||||
|
// const icon = header.querySelector('.accordion-icon i');
|
||||||
|
|
||||||
// Close all other accordions
|
// // Close all other accordions
|
||||||
document.querySelectorAll('.user-card').forEach(otherCard => {
|
// document.querySelectorAll('.user-card').forEach(otherCard => {
|
||||||
if (otherCard !== card) {
|
// if (otherCard !== card) {
|
||||||
const otherContent = otherCard.querySelector('.card-content');
|
// const otherContent = otherCard.querySelector('.card-content');
|
||||||
const otherIcon = otherCard.querySelector('.accordion-icon i');
|
// const otherIcon = otherCard.querySelector('.accordion-icon i');
|
||||||
otherIcon.setAttribute('class', 'mdi mdi-chevron-down');
|
// otherIcon.setAttribute('class', 'mdi mdi-chevron-down');
|
||||||
|
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
// Toggle current accordion
|
// // Toggle current accordion
|
||||||
content.classList.toggle('active');
|
// content.classList.toggle('active');
|
||||||
if (content.classList.contains('active')) {
|
// if (content.classList.contains('active')) {
|
||||||
icon.classList.setAttribute('class', 'mdi mdi-chevron-up');
|
// icon.classList.setAttribute('class', 'mdi mdi-chevron-up');
|
||||||
} else {
|
// } else {
|
||||||
icon.classList.setAttribute('class', 'mdi mdi-chevron-down');
|
// icon.classList.setAttribute('class', 'mdi mdi-chevron-down');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
function toggleSection(checkbox, sectionId) {
|
// function toggleSection(checkbox, sectionId) {
|
||||||
const section = document.getElementById(sectionId);
|
// const section = document.getElementById(sectionId);
|
||||||
const checkboxes = section.querySelectorAll('input[type="checkbox"]');
|
// const checkboxes = section.querySelectorAll('input[type="checkbox"]');
|
||||||
|
|
||||||
if (checkbox.checked) {
|
// if (checkbox.checked) {
|
||||||
section.classList.remove('hidden');
|
// section.classList.remove('hidden');
|
||||||
checkboxes.forEach(cb => {
|
// checkboxes.forEach(cb => {
|
||||||
cb.disabled = false;
|
// cb.disabled = false;
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
section.classList.add('hidden');
|
// section.classList.add('hidden');
|
||||||
checkboxes.forEach(cb => {
|
// checkboxes.forEach(cb => {
|
||||||
cb.checked = false;
|
// cb.checked = false;
|
||||||
cb.disabled = true;
|
// cb.disabled = true;
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
function getCheckedValues(name) {
|
// function getCheckedValues(name) {
|
||||||
const checkboxes = document.querySelectorAll(`input[name="${name}"]:checked`);
|
// const checkboxes = document.querySelectorAll(`input[name="${name}"]:checked`);
|
||||||
return Array.from(checkboxes).map(cb => parseInt(cb.value));
|
// return Array.from(checkboxes).map(cb => parseInt(cb.value));
|
||||||
}
|
// }
|
||||||
|
|
||||||
function getHrActivityHistory() {
|
function getHrActivityHistory() {
|
||||||
console.log(event.target.dataset.id); //return;
|
console.log(event.target.dataset.id); //return;
|
||||||
@ -827,12 +828,6 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to get checked checkbox values (if not already defined)
|
|
||||||
function getCheckedValues(namePrefix) {
|
|
||||||
const checkboxes = document.querySelectorAll(`input[name^="${namePrefix}"]:checked`);
|
|
||||||
return Array.from(checkboxes).map(cb => cb.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).on('change', '.select-all', function() {
|
$(document).on('change', '.select-all', function() {
|
||||||
let $this = $(this);
|
let $this = $(this);
|
||||||
let type = $this.data('type');
|
let type = $this.data('type');
|
||||||
|
|||||||
@ -126,6 +126,27 @@
|
|||||||
|
|
||||||
<?php foreach ($hr_access_data as $key => $value) {
|
<?php foreach ($hr_access_data as $key => $value) {
|
||||||
$key = $key + 1;
|
$key = $key + 1;
|
||||||
|
|
||||||
|
// Calculate data counts per user for toggling rules
|
||||||
|
$prePolicyCount = 0;
|
||||||
|
if (!empty($pre_policy_data)) {
|
||||||
|
foreach ($pre_policy_data as $p) {
|
||||||
|
if (!empty($value['pre_hr_id']) && $value['pre_branch_id'] === $p['branch_id']) {
|
||||||
|
$prePolicyCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$postPolicyCount = 0;
|
||||||
|
if (!empty($post_policy_data)) {
|
||||||
|
foreach ($post_policy_data as $p) {
|
||||||
|
if (!empty($value['post_hr_id']) && $value['post_branch_id'] === $p['branch_id']) {
|
||||||
|
$postPolicyCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$cdCount = !empty($post_cd_data) ? count($post_cd_data) : 0;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- User 1 Card -->
|
<!-- User 1 Card -->
|
||||||
@ -158,7 +179,7 @@
|
|||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="section-title">
|
<div class="section-title">
|
||||||
<input type="checkbox" class="main-checkbox"
|
<input type="checkbox" class="main-checkbox"
|
||||||
onchange="toggleSection(this, '<?= 'user' . $key ?>-pre')" name="<?= 'user' . $key ?>_modules"
|
onchange="toggleSection(this, '<?= 'user' . $key ?>-pre', <?= $prePolicyCount ?>)" name="<?= 'user' . $key ?>_modules"
|
||||||
value="1" <?php if (in_array(1, $value['allowed_pre_modules'] ?? [])) {
|
value="1" <?php if (in_array(1, $value['allowed_pre_modules'] ?? [])) {
|
||||||
echo 'checked';
|
echo 'checked';
|
||||||
} ?>>
|
} ?>>
|
||||||
@ -219,7 +240,7 @@
|
|||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="section-title">
|
<div class="section-title">
|
||||||
<input type="checkbox" class="main-checkbox"
|
<input type="checkbox" class="main-checkbox"
|
||||||
onchange="toggleSection(this, '<?= 'user' . $key ?>-active')" name="<?= 'user' . $key ?>_modules"
|
onchange="toggleSection(this, '<?= 'user' . $key ?>-active', <?= $postPolicyCount ?>)" name="<?= 'user' . $key ?>_modules"
|
||||||
value="2" <?php if (in_array(2, $value['allowed_post_modules'])) {
|
value="2" <?php if (in_array(2, $value['allowed_post_modules'])) {
|
||||||
echo 'checked';
|
echo 'checked';
|
||||||
} ?>>
|
} ?>>
|
||||||
@ -294,7 +315,7 @@
|
|||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="section-title">
|
<div class="section-title">
|
||||||
<input type="checkbox" class="main-checkbox"
|
<input type="checkbox" class="main-checkbox"
|
||||||
onchange="toggleSection(this, '<?= 'user' . $key ?>-cd')" name="<?= 'user' . $key ?>_modules" value="3" <?php if (in_array(3, $value['allowed_post_modules'])) {
|
onchange="toggleSection(this, '<?= 'user' . $key ?>-cd', <?= $cdCount ?>)" name="<?= 'user' . $key ?>_modules" value="3" <?php if (in_array(3, $value['allowed_post_modules'])) {
|
||||||
echo 'checked';
|
echo 'checked';
|
||||||
} ?>>
|
} ?>>
|
||||||
<i class="mdi mdi-file mr-2"></i>CD statement
|
<i class="mdi mdi-file mr-2"></i>CD statement
|
||||||
@ -367,4 +388,74 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
function toggleAccordion(header) {
|
||||||
|
const card = header.parentElement;
|
||||||
|
const content = card.querySelector('.card-content');
|
||||||
|
const icon = header.querySelector('.accordion-icon i');
|
||||||
|
|
||||||
|
// Close all other accordions
|
||||||
|
document.querySelectorAll('.user-card').forEach(otherCard => {
|
||||||
|
if (otherCard !== card) {
|
||||||
|
const otherContent = otherCard.querySelector('.card-content');
|
||||||
|
const otherIcon = otherCard.querySelector('.accordion-icon i');
|
||||||
|
if (otherContent && otherIcon) {
|
||||||
|
otherContent.classList.remove('active');
|
||||||
|
otherIcon.setAttribute('class', 'mdi mdi-chevron-down');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Toggle current accordion
|
||||||
|
if (content && icon) {
|
||||||
|
content.classList.toggle('active');
|
||||||
|
if (content.classList.contains('active')) {
|
||||||
|
icon.setAttribute('class', 'mdi mdi-chevron-up');
|
||||||
|
} else {
|
||||||
|
icon.setAttribute('class', 'mdi mdi-chevron-down');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleSection(checkbox, sectionId, dataCount) {
|
||||||
|
const section = document.getElementById(sectionId);
|
||||||
|
const checkboxes = section.querySelectorAll('input[type="checkbox"]');
|
||||||
|
|
||||||
|
// If checkbox is being unchecked, always allow without any restriction
|
||||||
|
if (!checkbox.checked) {
|
||||||
|
section.classList.add('hidden');
|
||||||
|
checkboxes.forEach(cb => {
|
||||||
|
cb.checked = false;
|
||||||
|
cb.disabled = true;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// From here, checkbox is being checked
|
||||||
|
// If there is no data, show warning and revert the checkbox state
|
||||||
|
if (!dataCount || dataCount === 0) {
|
||||||
|
checkbox.checked = false;
|
||||||
|
if (typeof toastr !== 'undefined' && toastr.warning) {
|
||||||
|
toastr.warning('No data available for this section.', 'Warning');
|
||||||
|
} else {
|
||||||
|
alert('No data available for this section.');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data is available and checkbox is being checked - show section and enable inner checkboxes
|
||||||
|
section.classList.remove('hidden');
|
||||||
|
checkboxes.forEach(cb => {
|
||||||
|
cb.disabled = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCheckedValues(name) {
|
||||||
|
const checkboxes = document.querySelectorAll(`input[name="${name}"]:checked`);
|
||||||
|
return Array.from(checkboxes).map(cb => cb.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
@ -314,7 +314,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-4 renewalFields">
|
<div class="form-group col-md-4 renewalFields">
|
||||||
<label for="contact_person_summary">Contact Person</label>
|
<label for="contact_person_summary">Contact Person<span class="text-danger">*</span></label>
|
||||||
<select class="form-control" name="contact_person_summary" id="contact_person_summary">
|
<select class="form-control" name="contact_person_summary" id="contact_person_summary">
|
||||||
<option value="">Select a Contact</option>
|
<option value="">Select a Contact</option>
|
||||||
</select>
|
</select>
|
||||||
@ -1243,7 +1243,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="">Date of Commencement <span class="text-danger"></span></label>
|
<label for="">Date of Commencement <span class="text-danger">*</span></label>
|
||||||
<div class="input-icon">
|
<div class="input-icon">
|
||||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC" onchange="calculatePolicyMetrics(this)">
|
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC" onchange="calculatePolicyMetrics(this)">
|
||||||
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
|
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
|
||||||
@ -1252,7 +1252,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="">Date of Expiry <span class="text-danger"></span></label>
|
<label for="">Date of Expiry <span class="text-danger">*</span></label>
|
||||||
<div class="input-icon">
|
<div class="input-icon">
|
||||||
<input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE">
|
<input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE">
|
||||||
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
|
<i class="mdi mdi-calendar-blank-outline additional-icon"></i>
|
||||||
|
|||||||
@ -8,16 +8,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
||||||
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
|
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="from_modal" value="1">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label for="client_name">Client Name<span class="text-danger">*</span></label>
|
<label for="client_name_for_modal">Client Name<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="client_name" name="client_name" required>
|
<input type="text" class="form-control" id="client_name_for_modal" name="client_name" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label for="short_name">Client Short name<span class="text-danger">*</span></label>
|
<label for="client_short_name_for_modal">Client Short name<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="short_name" name="short_name" onkeyup="validateInputForClient(this, 'clients', 'short_name')" required>
|
<input type="text" class="form-control" id="client_short_name_for_modal" name="short_name" onkeyup="validateInputForClient(this, 'clients', 'short_name')" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
@ -31,7 +32,7 @@
|
|||||||
<!-- Client Type -->
|
<!-- Client Type -->
|
||||||
<div class="form-row clienttypediv" style="display: none;">
|
<div class="form-row clienttypediv" style="display: none;">
|
||||||
|
|
||||||
<div class="form-group col-md-6">
|
<!-- <div class="form-group col-md-6">
|
||||||
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="dob" placeholder="DD/MM/YYYY" name="dob" >
|
<input type="text" class="form-control" id="dob" placeholder="DD/MM/YYYY" name="dob" >
|
||||||
</div>
|
</div>
|
||||||
@ -40,16 +41,16 @@
|
|||||||
<label for="cost_center">Mobile<span class="text-danger"></span></label>
|
<label for="cost_center">Mobile<span class="text-danger"></span></label>
|
||||||
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
|
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
|
||||||
onkeypress="return onlyNumbers(event)" onchange="validateInputForClient(this, 'clients', 'phone')">
|
onkeypress="return onlyNumbers(event)" onchange="validateInputForClient(this, 'clients', 'phone')">
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
<!-- <div class="form-group col-md-12">
|
||||||
<label for="email2">Email<span class="text-danger">*</span></label>
|
<label for="email2">Email<span class="text-danger">*</span></label>
|
||||||
<input type="email" class="form-control" id="email2" placeholder="Enter Email" name="email2">
|
<input type="email" class="form-control" id="email2" placeholder="Enter Email" name="email2">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label for="aadhar">Aadhar</label>
|
<label for="aadhar">Aadhar</label>
|
||||||
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInputForClient(this, 'clients', 'aadhar')">
|
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInputForClient(this, 'clients', 'aadhar')">
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -57,8 +58,8 @@
|
|||||||
<div class="form-row branchdiv">
|
<div class="form-row branchdiv">
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label for="short_name">Entity Type<span class="text-danger"></span></label>
|
<label for="short_name">Entity Type<span class="text-danger">*</span></label>
|
||||||
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id" required>
|
||||||
<option value="" selected>Select Entity</option>
|
<option value="" selected>Select Entity</option>
|
||||||
<?php
|
<?php
|
||||||
if (isset($entity) && count($entity)) {
|
if (isset($entity) && count($entity)) {
|
||||||
@ -87,7 +88,7 @@
|
|||||||
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)" required>
|
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)" oninput="this.value = this.value.replace(/[^0-9]/g, '');" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label for="email">Email<span class="text-danger">*</span></label>
|
<label for="email">Email<span class="text-danger">*</span></label>
|
||||||
@ -285,11 +286,87 @@
|
|||||||
error: function (xhr, status, error) {
|
error: function (xhr, status, error) {
|
||||||
console.error(xhr.responseText);
|
console.error(xhr.responseText);
|
||||||
console.error(status, error);
|
console.error(status, error);
|
||||||
isClientFormSubmitting = false;
|
setTimeout(function() {
|
||||||
$('.loader').fadeOut();
|
$('.loader').fadeOut();
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
// $('#client_add_modal_submit_btn').prop('disabled', false);
|
||||||
|
if (xhr.status === 400) {
|
||||||
|
let response = JSON.parse(xhr.responseText);
|
||||||
|
let errorMessages = "";
|
||||||
|
let seenMessages = []; // Array to store unique messages
|
||||||
|
if (response.errors) {
|
||||||
|
$.each(response.errors, function (field, message) {
|
||||||
|
if (!seenMessages.includes(message)) {
|
||||||
|
errorMessages += `• ${message}<br>`;
|
||||||
|
seenMessages.push(message); // Mark this message as "seen"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toastr.error(errorMessages, 'Validation Error', { "allowHtml": true });
|
||||||
|
} else {
|
||||||
|
toastr.warning(response.message || 'Validation failed', 'Warning');
|
||||||
|
}
|
||||||
|
} else if (xhr.status === 403) {
|
||||||
|
let response = JSON.parse(xhr.responseText);
|
||||||
|
toastr.error(response.message, 'Security Policy');
|
||||||
|
} else if (xhr.status === 404) {
|
||||||
|
toastr.warning('Resource not found', 'Warning');
|
||||||
|
} else if (xhr.status === 500) {
|
||||||
|
toastr.error('Something went wrong . Please try again later.', 'Server Error');
|
||||||
|
} else {
|
||||||
|
toastr.error('An unexpected error occurred. Please try again later.', 'Error');
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#client_name_for_modal').on('input', function() {
|
||||||
|
clearTimeout(shortNameTimer);
|
||||||
|
shortNameTimer = setTimeout(generateShortNameModal, 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
function generateShortNameModal() {
|
||||||
|
let clientInput = $("#client_name_for_modal");
|
||||||
|
let shortInput = $("#client_short_name_for_modal");
|
||||||
|
let newClientName = clientInput.val().trim();
|
||||||
|
|
||||||
|
console.log(`LN : NEW - ${newClientName}`);
|
||||||
|
if (newClientName.length == 0) {
|
||||||
|
shortInput.val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let shortName = newClientName.substring(0, 10).replace(/\s+/g, '').toUpperCase();
|
||||||
|
console.log(`LN : NEW - ${shortName}`);
|
||||||
|
makeUniqueShortNameModal(shortName);
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeUniqueShortNameModal(baseName) {
|
||||||
|
let input = $("#client_short_name_for_modal")[0];
|
||||||
|
|
||||||
|
checkDuplicateTableFieldValue("clients", "short_name", baseName, function(isDuplicate) {
|
||||||
|
if (isDuplicate) {
|
||||||
|
let counter = 1;
|
||||||
|
function tryNext() {
|
||||||
|
let padded = String(counter).padStart(3, '0'); // 001, 002, 003
|
||||||
|
let newName = baseName + padded;
|
||||||
|
|
||||||
|
checkDuplicateTableFieldValue("clients", "short_name", newName, function(exists) {
|
||||||
|
if (exists) {
|
||||||
|
counter++;
|
||||||
|
tryNext();
|
||||||
|
} else {
|
||||||
|
$("#client_short_name_for_modal").val(newName);
|
||||||
|
validateInput(input, "clients", "short_name");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
tryNext();
|
||||||
|
} else {
|
||||||
|
$("#client_short_name_for_modal").val(baseName);
|
||||||
|
validateInput(input, "clients", "short_name");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user