GWM : Email login issue
This commit is contained in:
commit
cd260d4ffd
@ -156,6 +156,8 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->get("test-rack-rate", "EmployeeController::testRackRate");
|
$routes->get("test-rack-rate", "EmployeeController::testRackRate");
|
||||||
$routes->post("test-rack-rate", "EmployeeController::testRackRate");
|
$routes->post("test-rack-rate", "EmployeeController::testRackRate");
|
||||||
$routes->get('test_members_list', 'EmployeeController::test_members_list');
|
$routes->get('test_members_list', 'EmployeeController::test_members_list');
|
||||||
|
$routes->post('get_emp_history','EmployeeController::getEmpHistory');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$routes->group("/master", ["filter" => "authMVC"], function ($routes) {
|
$routes->group("/master", ["filter" => "authMVC"], function ($routes) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -98,19 +98,60 @@ class DashboardController extends AdminController
|
|||||||
public function dashboard()
|
public function dashboard()
|
||||||
{
|
{
|
||||||
|
|
||||||
$data = [];
|
$data['page_name'] = 'Dashboard';
|
||||||
|
|
||||||
|
$db = db_connect();
|
||||||
|
$sql = "SELECT
|
||||||
|
clients.id AS client_id,
|
||||||
|
clients.client_name,
|
||||||
|
clients.short_name,
|
||||||
|
client_branch.id AS client_branch_id,
|
||||||
|
client_branch.branch_name,
|
||||||
|
client_branch.branch_code,
|
||||||
|
|
||||||
|
COUNT(employees.id) AS total_employees,
|
||||||
|
SUM(CASE WHEN employees.emp_status = 'draft' THEN 1 ELSE 0 END) AS draft_count,
|
||||||
|
SUM(CASE WHEN employees.emp_status IN ('enrolled', 'active') THEN 1 ELSE 0 END) AS enrolled_count,
|
||||||
|
|
||||||
$results = $this->clientModel->select('clients.id as client_id, clients.client_name, clients.short_name,
|
SUM(CASE WHEN auth_history.user_id IS NOT NULL THEN 1 ELSE 0 END) AS logged_in_count,
|
||||||
client_branch.id as client_branch_id, client_branch.branch_name,
|
SUM(CASE WHEN auth_history.user_id IS NULL THEN 1 ELSE 0 END) AS not_logged_in_count,
|
||||||
client_branch.branch_code, employees.id as employee_id,
|
|
||||||
employees.name as employee_name, employees.relationship,
|
|
||||||
employees.emp_code, employees.emp_status, auth_history.user_type, client_policy.policy_type_id, client_policy.id as client_policy_id')
|
|
||||||
->join('client_branch', 'clients.id = client_branch.client_id', 'left')
|
|
||||||
->join('client_policy', 'client_branch.id = client_policy.client_branch_id', 'left')
|
|
||||||
->join('employees', 'client_branch.id = employees.client_branch_id', 'left')
|
|
||||||
->join('auth_history', 'employees.id = auth_history.user_id AND "employee" = auth_history.user_type', 'left')
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
|
CASE
|
||||||
|
WHEN EXISTS (
|
||||||
|
SELECT 1 FROM client_policy
|
||||||
|
WHERE client_policy.client_branch_id = client_branch.id
|
||||||
|
AND client_policy.is_active = 1
|
||||||
|
AND client_policy.open_for_enrollment = 1
|
||||||
|
) THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END AS open_or_close_enrollment
|
||||||
|
|
||||||
|
FROM clients
|
||||||
|
LEFT JOIN client_branch ON clients.id = client_branch.client_id
|
||||||
|
LEFT JOIN employees ON client_branch.id = employees.client_branch_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT user_id, user_type
|
||||||
|
FROM auth_history
|
||||||
|
WHERE user_type = 'employee'
|
||||||
|
GROUP BY user_id
|
||||||
|
) AS auth_history ON employees.id = auth_history.user_id
|
||||||
|
|
||||||
|
WHERE employees.relationship = 'Self'
|
||||||
|
AND employees.emp_status IN ('draft', 'enrolled', 'active')
|
||||||
|
AND employees.is_active = 1
|
||||||
|
AND clients.is_active = 1
|
||||||
|
AND client_branch.is_active = 1
|
||||||
|
|
||||||
|
GROUP BY clients.id, client_branch.id";
|
||||||
|
|
||||||
|
$query = $db->query($sql);
|
||||||
|
$results = $query->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
|
$data['client_branch_emp_list'] = $results;
|
||||||
|
$session = \Config\Services::session();
|
||||||
|
$session->set('enrollment_data', json_encode($data));
|
||||||
|
|
||||||
// $pendingActionsController = new PendingActionsController;
|
// $pendingActionsController = new PendingActionsController;
|
||||||
// $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
|
// $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
|
||||||
// $businessTeamData = $this->policyTransactionModel->getBusinessReportList();
|
// $businessTeamData = $this->policyTransactionModel->getBusinessReportList();
|
||||||
@ -118,95 +159,6 @@ class DashboardController extends AdminController
|
|||||||
// $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData);
|
// $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData);
|
||||||
// $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData);
|
// $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData);
|
||||||
|
|
||||||
$groupedData = [];
|
|
||||||
|
|
||||||
foreach ($results as $row) {
|
|
||||||
$clientId = $row['client_id'];
|
|
||||||
$clientName = $row['client_name'];
|
|
||||||
$shortName = $row['short_name'];
|
|
||||||
$branchId = $row['client_branch_id'];
|
|
||||||
$branchName = $row['branch_name'];
|
|
||||||
$branchCode = $row['branch_code'];
|
|
||||||
|
|
||||||
$clientPolicyId = $row['client_policy_id'];
|
|
||||||
$policyTypeId = $row['policy_type_id'];
|
|
||||||
$employeeId = '';
|
|
||||||
if ($employeeId != $row['employee_id']) {
|
|
||||||
$employeeId = $row['employee_id'];
|
|
||||||
} else {
|
|
||||||
$employeeId = null;
|
|
||||||
}
|
|
||||||
$employeeName = $row['employee_name'];
|
|
||||||
$employeeRelationship = $row['relationship'];
|
|
||||||
$employeeEmpCode = $row['emp_code'];
|
|
||||||
$employeeEmpStatus = $row['emp_status'];
|
|
||||||
$employeeUserType = $row['user_type'];
|
|
||||||
|
|
||||||
// Initialize the client entry if it doesn't exist
|
|
||||||
if (!isset($groupedData[$clientId])) {
|
|
||||||
$groupedData[$clientId] = [
|
|
||||||
'client_id' => $clientId,
|
|
||||||
'client_name' => $clientName,
|
|
||||||
'short_name' => $shortName,
|
|
||||||
'branches' => []
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the branch entry if it doesn't exist
|
|
||||||
if (!isset($groupedData[$clientId]['branches'][$branchId])) {
|
|
||||||
$groupedData[$clientId]['branches'][$branchId] = [
|
|
||||||
'client_branch_id' => $branchId,
|
|
||||||
'branch_name' => $branchName,
|
|
||||||
'branch_code' => $branchCode,
|
|
||||||
'emp_login' => 0,
|
|
||||||
'emp_enroll' => 0,
|
|
||||||
'client_policies' => [],
|
|
||||||
'employees' => []
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the client policy to the branch's policies list if it exists, not already added, and policyTypeId is not equal to 1
|
|
||||||
if ($clientPolicyId !== null && $policyTypeId != 1 && !in_array(['client_policy_id' => $clientPolicyId, 'policy_type_id' => $policyTypeId], $groupedData[$clientId]['branches'][$branchId]['client_policies'])) {
|
|
||||||
$groupedData[$clientId]['branches'][$branchId]['client_policies'][] = [
|
|
||||||
'client_policy_id' => $clientPolicyId,
|
|
||||||
'policy_type_id' => $policyTypeId
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append employee error to the branch's employees list if relationship is 'Self' and not already added
|
|
||||||
$employeeKey = $employeeId . '-' . $employeeName; // unique key to identify an employee
|
|
||||||
if ($employeeId !== null && $employeeRelationship == 'Self' && !isset($groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey])) {
|
|
||||||
$groupedData[$clientId]['branches'][$branchId]['employees'][$employeeKey] = [
|
|
||||||
'employee_id' => $employeeId,
|
|
||||||
'employee_name' => $employeeName,
|
|
||||||
'relationship' => $employeeRelationship,
|
|
||||||
'emp_code' => $employeeEmpCode,
|
|
||||||
'emp_status' => $employeeEmpStatus,
|
|
||||||
'user_type' => $employeeUserType
|
|
||||||
];
|
|
||||||
if (!empty($employeeUserType)) {
|
|
||||||
$groupedData[$clientId]['branches'][$branchId]['emp_login']++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increment emp_enroll if emp_status is not 'draft'
|
|
||||||
if ($employeeEmpStatus !== 'draft') {
|
|
||||||
$groupedData[$clientId]['branches'][$branchId]['emp_enroll']++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Re-index the arrays to match the expected structure
|
|
||||||
foreach ($groupedData as &$client) {
|
|
||||||
foreach ($client['branches'] as &$branch) {
|
|
||||||
$branch['employees'] = array_values($branch['employees']);
|
|
||||||
}
|
|
||||||
$client['branches'] = array_values($client['branches']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data['client_branch_emp_list'] = $groupedData;
|
|
||||||
$session = \Config\Services::session();
|
|
||||||
$session->set('enrollment_data', json_encode($data));
|
|
||||||
// echo "<pre>";
|
|
||||||
// $data['pendingActionsData'] = $pendingActionsData;
|
// $data['pendingActionsData'] = $pendingActionsData;
|
||||||
// $data['businessTeamCount'] = count($businessTeamData) ?? 0;
|
// $data['businessTeamCount'] = count($businessTeamData) ?? 0;
|
||||||
// $data['financeTeamCount'] = count($financeTeamData) ?? 0;
|
// $data['financeTeamCount'] = count($financeTeamData) ?? 0;
|
||||||
@ -214,9 +166,8 @@ class DashboardController extends AdminController
|
|||||||
// $data['financeTeamStatusData'] = $financeTeamStatusData;
|
// $data['financeTeamStatusData'] = $financeTeamStatusData;
|
||||||
// $data['policyStatus'] = $this->policyStatus;
|
// $data['policyStatus'] = $this->policyStatus;
|
||||||
// $data['colorShades'] = $this->colorShades;
|
// $data['colorShades'] = $this->colorShades;
|
||||||
// dd($data);die;
|
|
||||||
|
|
||||||
$data['page_name'] = 'Dashboard';
|
// dd($data);
|
||||||
|
|
||||||
echo view('layout/header', $data);
|
echo view('layout/header', $data);
|
||||||
echo view('DashBoard', $data);
|
echo view('DashBoard', $data);
|
||||||
|
|||||||
@ -25,6 +25,9 @@ use App\Models\InsurerExcelExportTemplateModel;
|
|||||||
use App\Models\InsurerModel;
|
use App\Models\InsurerModel;
|
||||||
use App\Models\ClientDepositModel;
|
use App\Models\ClientDepositModel;
|
||||||
use App\Models\PolicyPremium2Model;
|
use App\Models\PolicyPremium2Model;
|
||||||
|
use App\Models\AuditHistoryModel;
|
||||||
|
use App\Models\UserModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use App\Controllers\Jobs;
|
use App\Controllers\Jobs;
|
||||||
@ -64,6 +67,9 @@ class EmployeeController extends AdminController
|
|||||||
protected $insurerModel;
|
protected $insurerModel;
|
||||||
protected $cashDepositModel;
|
protected $cashDepositModel;
|
||||||
protected $PolicyPremium2Model;
|
protected $PolicyPremium2Model;
|
||||||
|
protected $auditHistory;
|
||||||
|
protected $userModel;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@ -84,6 +90,8 @@ class EmployeeController extends AdminController
|
|||||||
$this->insurerModel = new InsurerModel();
|
$this->insurerModel = new InsurerModel();
|
||||||
$this->cashDepositModel = new ClientDepositModel();
|
$this->cashDepositModel = new ClientDepositModel();
|
||||||
$this->PolicyPremium2Model = new PolicyPremium2Model();
|
$this->PolicyPremium2Model = new PolicyPremium2Model();
|
||||||
|
$this->auditHistory = new AuditHistoryModel();
|
||||||
|
$this->userModel = new userModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function list()
|
public function list()
|
||||||
@ -114,6 +122,10 @@ class EmployeeController extends AdminController
|
|||||||
// log_message('error',json_encode($data['employees']));
|
// log_message('error',json_encode($data['employees']));
|
||||||
// Set getData in $data array with the processed $filterData
|
// Set getData in $data array with the processed $filterData
|
||||||
$data['getData'] = $filterData;
|
$data['getData'] = $filterData;
|
||||||
|
|
||||||
|
$html = view('employee_data_list', $data);
|
||||||
|
return $this->respond(['status' => true, 'html' => $html], 200);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// dd($this->employeeModel->getLastQuery());
|
// dd($this->employeeModel->getLastQuery());
|
||||||
@ -2187,33 +2199,41 @@ class EmployeeController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//UPDATE EMPLOYEE
|
||||||
public function update_emp_data()
|
public function update_emp_data()
|
||||||
{
|
{
|
||||||
|
helper('utility_helper');
|
||||||
|
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
// print_rr($data);die();
|
// print_rr($data);die();
|
||||||
// $data['dob'] = date('Y-m-d', strtotime($data['dob']));
|
// $data['dob'] = date('Y-m-d', strtotime($data['dob']));
|
||||||
$data['dob'] = change_date_format($data['dob'], 'd/m/Y', 'Y-m-d');
|
if (isset($data['dob'])) {
|
||||||
|
$data['dob'] = change_date_format($data['dob'], null, 'Y-m-d');
|
||||||
|
}
|
||||||
// print_rr($data); die;
|
// print_rr($data); die;
|
||||||
|
|
||||||
// Fetch current employee data
|
// Fetch current employee data
|
||||||
$employee_data = $this->employeeModel->where('id', $data['employee_primary_id'])->first();
|
$employee_data = $this->employeeModel->where('id', $data['employee_primary_id'])->first();
|
||||||
|
|
||||||
if ($employee_data['relationship'] == 'Self') {
|
if ($employee_data['relationship'] == 'Self') {
|
||||||
|
|
||||||
if ($employee_data['gender'] != $data['gender']) {
|
if (isset($data['gender'])) {
|
||||||
|
|
||||||
$spouse_gender = ($data['gender'] == 'M') ? 'F' : 'M';
|
if ($employee_data['gender'] != $data['gender']) {
|
||||||
$this->employeeModel
|
|
||||||
->where('emp_code', $employee_data['emp_code'])
|
$spouse_gender = ($data['gender'] == 'M') ? 'F' : 'M';
|
||||||
->where('relationship', 'Spouse')
|
$this->employeeModel
|
||||||
->set(['gender' => $spouse_gender])
|
->where('emp_code', $employee_data['emp_code'])
|
||||||
->update();
|
->where('relationship', 'Spouse')
|
||||||
|
->set(['gender' => $spouse_gender])
|
||||||
|
->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the employee data
|
// Update the employee data
|
||||||
$result = $this->employeeModel->where('id', $data['employee_primary_id'])->set($data)->update();
|
$result = $this->employeeModel->where('id', $data['employee_primary_id'])->set($data)->update();
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $data, 'message' => 'Employee updated successfully'], 200);
|
return $this->respond(['status' => true, 'code' => 200, 'data' => $data, 'message' => 'Employee updated successfully'], 200);
|
||||||
} else {
|
} else {
|
||||||
@ -2650,4 +2670,55 @@ class EmployeeController extends AdminController
|
|||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getEmpHistory(){
|
||||||
|
|
||||||
|
$emp_id = $this->request->getPost('emp_id');
|
||||||
|
|
||||||
|
$data['emp_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_id)->where('table_name','employees')->orderBy('created_at', 'DESC')->findAll();
|
||||||
|
|
||||||
|
foreach ($data['emp_history'] as &$emp_history) {
|
||||||
|
$emp_history['field_name'] = $this->formatFieldName($emp_history['field_name']);
|
||||||
|
$user = $emp_history['created_by'];
|
||||||
|
|
||||||
|
if ($user != null && $user != '') {
|
||||||
|
$userData = $this->userModel->select('first_name, last_name')->where('id', $user)->where('is_active', 1)->first();
|
||||||
|
if ($userData) {
|
||||||
|
$emp_history['created_by'] = ucwords($userData['first_name'] . ' ' . $userData['last_name']);
|
||||||
|
} else {
|
||||||
|
$emp_history['created_by'] = '-';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$emp_history['created_by'] = '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$emp_history['created_at'] = date("d-m-Y H:i:s", strtotime($emp_history['created_at']));
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($emp_history);
|
||||||
|
|
||||||
|
$emp_pol_pk = $this->employeePolicyModel->select('id')->where('employee_id',$emp_id)->first()['id'];
|
||||||
|
$data['emp_pol_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_pol_pk)->where('table_name','employee_polices')->findAll();
|
||||||
|
|
||||||
|
return $this->respond(['status' => true, 'data' => $data],200);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formatFieldName($unformattedString){
|
||||||
|
|
||||||
|
if (str_contains($unformattedString, '_')) {
|
||||||
|
$data = str_replace('_', ' ', $unformattedString);
|
||||||
|
}else{
|
||||||
|
$data = $unformattedString;
|
||||||
|
}
|
||||||
|
|
||||||
|
$format = ucwords($data);
|
||||||
|
|
||||||
|
return $format;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1720,7 +1720,8 @@ class MasterController extends AdminController
|
|||||||
'excel' => WRITEPATH . 'uploads/excel/',
|
'excel' => WRITEPATH . 'uploads/excel/',
|
||||||
'statements' => WRITEPATH . 'uploads/statements/',
|
'statements' => WRITEPATH . 'uploads/statements/',
|
||||||
'import_excel' => WRITEPATH . 'uploads/import_excel/',
|
'import_excel' => WRITEPATH . 'uploads/import_excel/',
|
||||||
'logs' => WRITEPATH . 'uploads/logs/',
|
'logs' => WRITEPATH . 'logs',
|
||||||
|
'session' => WRITEPATH . 'session',
|
||||||
'client_kyc_documents' => WRITEPATH . 'uploads/client_kyc_documents/',
|
'client_kyc_documents' => WRITEPATH . 'uploads/client_kyc_documents/',
|
||||||
'tmp' => WRITEPATH . 'tmp/',
|
'tmp' => WRITEPATH . 'tmp/',
|
||||||
'e_card_imgs' => ROOTPATH . 'public/e_card_imgs',
|
'e_card_imgs' => ROOTPATH . 'public/e_card_imgs',
|
||||||
@ -1729,6 +1730,7 @@ class MasterController extends AdminController
|
|||||||
'logo' => ROOTPATH . 'public/uploads/logo/',
|
'logo' => ROOTPATH . 'public/uploads/logo/',
|
||||||
'template_bg' => ROOTPATH . 'public/uploads/template_bg/',
|
'template_bg' => ROOTPATH . 'public/uploads/template_bg/',
|
||||||
'attachments' => WRITEPATH . 'uploads/attachments/',
|
'attachments' => WRITEPATH . 'uploads/attachments/',
|
||||||
|
'cache' => WRITEPATH . 'cache',
|
||||||
'sample_import_excel' => ROOTPATH . 'public/sample_import_excel',
|
'sample_import_excel' => ROOTPATH . 'public/sample_import_excel',
|
||||||
'lead_files' => WRITEPATH . 'uploads/lead_files/',
|
'lead_files' => WRITEPATH . 'uploads/lead_files/',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -112,22 +112,29 @@ class RestAuthenticationController extends AdminController
|
|||||||
public function verifyEmployeeWithEmailId()
|
public function verifyEmployeeWithEmailId()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$data = $this->request->getJSON();
|
$data = $this->request->getJSON();
|
||||||
|
|
||||||
$email = $data->email;
|
$email = $data->email;
|
||||||
|
|
||||||
$employeeData = $this->employeeModel->select('employees.relationship,EP.employee_id')
|
$employeeData = $this->employeeModel->select('
|
||||||
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
|
employees.relationship,
|
||||||
->where('employees.is_active', 1)
|
EP.employee_id,
|
||||||
->where('employees.relationship', 'self')
|
employees.client_id,
|
||||||
->where('employees.emp_status !=', 'truncated')
|
employees.client_branch_id,
|
||||||
->where('employees.email_corporate', $email)
|
employees.email_corporate
|
||||||
->where('EP.is_active', 1)
|
|
||||||
->whereIn('EP.status', ['draft', 'enrolled'])
|
')
|
||||||
->first();
|
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
|
||||||
|
->where('employees.is_active', 1)
|
||||||
if (isset($employeeData['employee_id']))
|
->where('employees.relationship', 'Self')
|
||||||
{
|
->where('employees.emp_status !=', 'truncated')
|
||||||
|
->where('employees.email_corporate', $email)
|
||||||
|
->where('EP.is_active', 1)
|
||||||
|
->whereIn('EP.status', ['draft', 'enrolled'])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (isset($employeeData['employee_id'])) {
|
||||||
|
|
||||||
$otp = random_int(100000, 999999);
|
$otp = random_int(100000, 999999);
|
||||||
|
|
||||||
@ -140,43 +147,38 @@ class RestAuthenticationController extends AdminController
|
|||||||
$data->otp = $otp;
|
$data->otp = $otp;
|
||||||
$this->callThirdPartyAPI($data, 'updateEmpOTP');
|
$this->callThirdPartyAPI($data, 'updateEmpOTP');
|
||||||
|
|
||||||
|
|
||||||
$common = [
|
$common = [
|
||||||
'client_id' => $employeeData['client_id'],
|
'client_id' => $employeeData['client_id'],
|
||||||
'client_branch_id' => $employeeData['client_branch_id'],
|
'client_branch_id' => $employeeData['client_branch_id'],
|
||||||
'client_policy_id' => null,
|
'client_policy_id' => null,
|
||||||
'employee_policy_id' => null,
|
'employee_policy_id' => null,
|
||||||
'employee_id' => $employeeData['id'],
|
'employee_id' => $employeeData['employee_id'],
|
||||||
'mail_type' => 'otp_mail',
|
'mail_type' => 'otp_mail',
|
||||||
];
|
];
|
||||||
$subject = 'Nhance user verification - OTP';
|
$subject = 'Nhance user verification - OTP';
|
||||||
$mail_content = $otp.' is your verification code for Nhance.';
|
$mail_content = $otp . ' is your verification code for Nhance.';
|
||||||
$res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject ,'common'=>$common ,'message' => $mail_content]);
|
$res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject, 'common' => $common, 'message' => $mail_content]);
|
||||||
$this->myLogger->logme("info", $res);
|
$this->myLogger->logme("info", $res);
|
||||||
|
|
||||||
if(json_decode($res)->status == 'success')
|
if (json_decode($res)->status == 'success') {
|
||||||
{
|
$result = ['user_verification' => true, 'message' => "Verified Successfully"];
|
||||||
$result = ['user_verification' => true ,'message' => "Verified Successfully"];
|
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
} else {
|
||||||
|
$result = ['user_verification' => false, 'message' => "Mail sending failed , try again"];
|
||||||
}else{
|
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||||
$result = ['user_verification' => false , 'message' => "Mail sending failed , try again"];
|
|
||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
}else{
|
$result = ['user_verification' => false, 'message' => "Verification failed , try again"];
|
||||||
|
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||||
$result = ['user_verification' => false , 'message' => "Verification failed , try again"];
|
|
||||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Call the third-party API function
|
// Call the third-party API function
|
||||||
return $this->callThirdPartyAPI($this->request->getJSON(),'verifyEmployeeEmailId');
|
return $this->callThirdPartyAPI($this->request->getJSON(), 'verifyEmployeeEmailId');
|
||||||
}
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1123,20 +1123,27 @@ if (!function_exists('premium_calculation_manager'))
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$temp_slab_rates = $slab_details[ $slab_index ]['slab_rates'];
|
$temp_slab_rates = $slab_details[ $slab_index ]['slab_rates'];
|
||||||
|
|
||||||
//if curent action is dependent addition OR addition then pull insurer master to set whether add one day from employee date of coverage
|
|
||||||
if($emp_data['temp']['action'] == 'DA' || $emp_data['temp']['action'] == 'A')
|
|
||||||
{
|
|
||||||
$insurer = new InsurerModel();
|
|
||||||
$insurer = ($insurer->find($policy_terms['insurer_id']));
|
|
||||||
if($insurer['addition_add_day'] == true)
|
|
||||||
{
|
|
||||||
// $emp_data['policy_details']['date_coverage'] = (new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d');
|
|
||||||
|
|
||||||
$emp_data['policy_details']['date_coverage'] = isset($emp_data['policy_details']['date_coverage']) && $emp_data['policy_details']['date_coverage'] != '' && $emp_data['policy_details']['date_coverage'] != null ?
|
|
||||||
(new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d') : null ;
|
// ------------"THIS PART HAS NO INSURER IN THE PRE-ENROLL, SO COMMENT OUT THIS PART (04-03-2025)."-------------------------------------------------------------------------------------------------------------------
|
||||||
}
|
|
||||||
}
|
// //if curent action is dependent addition OR addition then pull insurer master to set whether add one day from employee date of coverage
|
||||||
|
// if($emp_data['temp']['action'] == 'DA' || $emp_data['temp']['action'] == 'A')
|
||||||
|
// {
|
||||||
|
// $insurer = new InsurerModel();
|
||||||
|
// $insurer = ($insurer->find($policy_terms['insurer_id']));
|
||||||
|
// if($insurer['addition_add_day'] == true)
|
||||||
|
// {
|
||||||
|
// // $emp_data['policy_details']['date_coverage'] = (new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d');
|
||||||
|
|
||||||
|
// $emp_data['policy_details']['date_coverage'] = isset($emp_data['policy_details']['date_coverage']) && $emp_data['policy_details']['date_coverage'] != '' && $emp_data['policy_details']['date_coverage'] != null ?
|
||||||
|
// (new DateTime($emp_data['policy_details']['date_coverage']))->modify('+1 day')->format('Y-m-d') : null ;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// dd($emp_data);
|
// dd($emp_data);
|
||||||
$is_match_found = false;
|
$is_match_found = false;
|
||||||
$gst = isset($policy_terms['gst']) && $policy_terms['gst'] != 0 ? $policy_terms['gst'] : 18;
|
$gst = isset($policy_terms['gst']) && $policy_terms['gst'] != 0 ? $policy_terms['gst'] : 18;
|
||||||
|
|||||||
@ -544,6 +544,10 @@ if (!function_exists('change_date_format')) {
|
|||||||
'Y/m/d', // 2024/12/01
|
'Y/m/d', // 2024/12/01
|
||||||
'Y.m.d', // 2024.12.01
|
'Y.m.d', // 2024.12.01
|
||||||
'Y,m,d', // 2024,12,01
|
'Y,m,d', // 2024,12,01
|
||||||
|
|
||||||
|
'd/m/Y', // 01/01/2025
|
||||||
|
'd-m-Y', // 01-01-2025
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -121,8 +121,8 @@ class ClientPolicyModel extends Model
|
|||||||
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
|
||||||
->select('policy_type.policy_type as policy_type_name')
|
->select('policy_type.policy_type as policy_type_name')
|
||||||
->select('client_branch.branch_name as branch_name')
|
->select('client_branch.branch_name as branch_name')
|
||||||
->join('insurers', 'insurers.id = client_policy.insurer_id')
|
->join('insurers', 'insurers.id = client_policy.insurer_id', 'left')
|
||||||
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
|
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id', 'left')
|
||||||
->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
|
->join('tpa', 'tpa.id = client_policy.tpa_id', 'left')
|
||||||
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')
|
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id', 'left')
|
||||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||||
|
|||||||
@ -149,7 +149,21 @@ class EmployeeModel extends Model
|
|||||||
{
|
{
|
||||||
|
|
||||||
return $this->db->table('employee_polices')
|
return $this->db->table('employee_polices')
|
||||||
->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment,client_policy.disclaimer,client_policy.policy_type_id , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
|
->select('
|
||||||
|
policy_type.long_name as Policy_Name ,
|
||||||
|
client_policy.policy_terms as Policy_Terms,
|
||||||
|
client_policy.client_id as ClientId,
|
||||||
|
client_policy.policy_id as PolicyId,
|
||||||
|
client_policy.id as ClientPolicyId,
|
||||||
|
CASE
|
||||||
|
WHEN client_policy.open_for_enrollment IS NULL THEN 0
|
||||||
|
ELSE client_policy.open_for_enrollment
|
||||||
|
END AS OpenForEnrollment,
|
||||||
|
client_policy.disclaimer,
|
||||||
|
client_policy.policy_type_id ,
|
||||||
|
employee_polices.tpa_id as tpa_id ,
|
||||||
|
employee_polices.rand_string as rand_string
|
||||||
|
', FALSE) // Select all columns from both tables
|
||||||
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
|
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
|
||||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||||
->where('client_policy.policy_status', 1)
|
->where('client_policy.policy_status', 1)
|
||||||
|
|||||||
@ -202,6 +202,7 @@ table.dataTable thead th {
|
|||||||
|
|
||||||
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
||||||
item.addEventListener('click', function(e) {
|
item.addEventListener('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
const onclickAttr = this.getAttribute('onclick');
|
const onclickAttr = this.getAttribute('onclick');
|
||||||
if (onclickAttr) {
|
if (onclickAttr) {
|
||||||
eval(onclickAttr);
|
eval(onclickAttr);
|
||||||
|
|||||||
@ -10,10 +10,10 @@
|
|||||||
<table class="table table-borderless table mb-0" id="table-client-policy">
|
<table class="table table-borderless table mb-0" id="table-client-policy">
|
||||||
<thead class="thead-light">
|
<thead class="thead-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Insurer</th>
|
<!-- <th>Insurer</th> -->
|
||||||
<th>Policy</th>
|
<th>Policy</th>
|
||||||
<th>Client Branch</th>
|
<th>Client Branch</th>
|
||||||
<th>TPA</th>
|
<!-- <th>TPA</th> -->
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th>Enrolment Status</th>
|
<th>Enrolment Status</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
@ -76,10 +76,10 @@
|
|||||||
<option value="" selected>Select Base Policy</option>
|
<option value="" selected>Select Base Policy</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<!-- <div class="form-group col-md-4">
|
||||||
<label for="policy_no">Policy No<span class="text-danger">*</span></label>
|
<label for="policy_no">Policy No<span class="text-danger">*</span></label>
|
||||||
<input value="" type="text" class="form-control" placeholder="Enter Policy Number " name="policy_no" id="policy_no" required>
|
<input value="" type="text" class="form-control" placeholder="Enter Policy Number " name="policy_no" id="policy_no" required>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -274,9 +274,11 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
$('#inception_type').change(function() {
|
$('#inception_type').change(function() {
|
||||||
|
|
||||||
var open_data = $('#open_date').parent();
|
var open_data = $('#open_date').parent();
|
||||||
var close_data = $('#close_date').parent();
|
var close_data = $('#close_date').parent();
|
||||||
var reminder_data = $('#reminder_date').parent();
|
var reminder_data = $('#reminder_date').parent();
|
||||||
|
|
||||||
if ($(this).prop('checked')) {
|
if ($(this).prop('checked')) {
|
||||||
$(open_data).show();
|
$(open_data).show();
|
||||||
$(close_data).show();
|
$(close_data).show();
|
||||||
@ -359,6 +361,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
|
|
||||||
if (policy_PrimaryKey !== '') {
|
if (policy_PrimaryKey !== '') {
|
||||||
|
|
||||||
var policyTable = '';
|
var policyTable = '';
|
||||||
var data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
|
var data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
|
||||||
console.log('client_policy_data', data)
|
console.log('client_policy_data', data)
|
||||||
@ -427,10 +430,10 @@ $(document).ready(function() {
|
|||||||
policyTable +=
|
policyTable +=
|
||||||
`
|
`
|
||||||
<tr>
|
<tr>
|
||||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
<! -- <td>${item.insurer_short} - ${item.insurer_branch_name}</td> -->
|
||||||
<td>${policy_name_data}</td>
|
<td>${policy_name_data}</td>
|
||||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||||
<td>${tpaValue}</td>
|
<! -- <td>${tpaValue}</td> -->
|
||||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||||
<td style="text-align: center;">${(enrollmentStatus)}</td>
|
<td style="text-align: center;">${(enrollmentStatus)}</td>
|
||||||
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
<td>${checkDateStatus(item.policy_end_date, 1)}</td>
|
||||||
@ -679,10 +682,10 @@ $("#policy_form").submit(function(event) {
|
|||||||
policyTable +=
|
policyTable +=
|
||||||
`
|
`
|
||||||
<tr>
|
<tr>
|
||||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
<!-- <td>${item.insurer_short} - ${item.insurer_branch_name}</td> -->
|
||||||
<td>${policy_name_data}</td>
|
<td>${policy_name_data}</td>
|
||||||
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
<td>${item.branch_name ? item.branch_name : ' - '}</td>
|
||||||
<td>${tpaValue}</td>
|
<!-- <td>${tpaValue}</td> -->
|
||||||
|
|
||||||
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
<td>${(item.policy_start_date)} / ${(item.policy_end_date)}</td>
|
||||||
<td style="text-align: center;">${(enrollmentStatus)}</td>
|
<td style="text-align: center;">${(enrollmentStatus)}</td>
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataTables_filter{
|
.dataTables_filter {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +38,43 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.readonly-select {
|
||||||
|
pointer-events: none;
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/* Timeline Design */
|
||||||
|
.timeline {
|
||||||
|
position: relative;
|
||||||
|
padding-left: 30px;
|
||||||
|
border-left: 3px solid #007bff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-item {
|
||||||
|
position: relative;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-dot {
|
||||||
|
position: absolute;
|
||||||
|
left: -10px;
|
||||||
|
top: 5px;
|
||||||
|
width: 15px;
|
||||||
|
height: 15px;
|
||||||
|
background: #007bff;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-content {
|
||||||
|
background: #f8f9fa;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<?php $pro_rata_total = 0; $gst_total = 0 ?>
|
<?php $pro_rata_total = 0; $gst_total = 0 ?>
|
||||||
@ -58,10 +95,10 @@
|
|||||||
|
|
||||||
<?php if (isset($getData)) {
|
<?php if (isset($getData)) {
|
||||||
if ($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
|
if ($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
|
||||||
<th class="font-weight-medium">Client/Branch</th>
|
<th class="font-weight-medium">Client/Branch</th>
|
||||||
<?php }
|
<?php }
|
||||||
if ($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
|
if ($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
|
||||||
<th class="font-weight-medium">Branch</th>
|
<th class="font-weight-medium">Branch</th>
|
||||||
<?php } } ?>
|
<?php } } ?>
|
||||||
|
|
||||||
<th class="font-weight-medium">Name</th>
|
<th class="font-weight-medium">Name</th>
|
||||||
@ -76,9 +113,11 @@
|
|||||||
<th class="font-weight-medium">Policy status</th>
|
<th class="font-weight-medium">Policy status</th>
|
||||||
<th class="font-weight-medium">(₹)Sum Insured</th>
|
<th class="font-weight-medium">(₹)Sum Insured</th>
|
||||||
<th class="font-weight-medium">(₹)Premium</th>
|
<th class="font-weight-medium">(₹)Premium</th>
|
||||||
<th class="font-weight-medium" id="rata_premium" data-toggle="tooltip" data-placement="top">(₹)Pro Rata <br> Premium</th>
|
<th class="font-weight-medium" id="rata_premium" data-toggle="tooltip" data-placement="top">
|
||||||
<th class="font-weight-medium" id="gst" data-toggle="tooltip" data-placement="top">(₹)GST</th>
|
(₹)Pro Rata <br> Premium</th>
|
||||||
<th class="font-weight-medium" > Action </th>
|
<th class="font-weight-medium" id="gst" data-toggle="tooltip" data-placement="top">(₹)GST
|
||||||
|
</th>
|
||||||
|
<th class="font-weight-medium"> Action </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@ -88,28 +127,30 @@
|
|||||||
$pro_rata_total = 0;
|
$pro_rata_total = 0;
|
||||||
$gst_total = 0;
|
$gst_total = 0;
|
||||||
foreach ($employees as $key => $employee) { ?>
|
foreach ($employees as $key => $employee) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b><?php echo ($key + 1); ?></b></td>
|
<td><b><?php echo ($key + 1); ?></b></td>
|
||||||
|
|
||||||
<?php if (isset($getData)) {
|
<?php if (isset($getData)) {
|
||||||
if ($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
|
if ($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
|
||||||
<td><?php echo $employee['client_short_name'] . ' - ' . $employee['client_branch_name']; ?></td>
|
<td><?php echo $employee['client_short_name'] . ' - ' . $employee['client_branch_name']; ?>
|
||||||
<?php }
|
</td>
|
||||||
|
<?php }
|
||||||
if ($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
|
if ($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
|
||||||
<td><?php echo $employee['client_branch_name']; ?></td>
|
<td><?php echo $employee['client_branch_name']; ?></td>
|
||||||
<?php } } ?>
|
<?php } } ?>
|
||||||
|
|
||||||
<td><?php echo $employee['name']; ?></td>
|
<td><?php echo $employee['name']; ?></td>
|
||||||
<td><?php echo $employee['emp_code']; ?></td>
|
<td><?php echo $employee['emp_code']; ?></td>
|
||||||
<td><?php echo $employee['relationship']; ?></td>
|
<td><?php echo $employee['relationship']; ?></td>
|
||||||
<td><?php echo $employee['gender']; ?></td>
|
<td><?php echo $employee['gender']; ?></td>
|
||||||
<td><?php echo date('d/m/Y', strtotime($employee['dob'])); ?></td>
|
<td><?php echo date('d/m/Y', strtotime($employee['dob'])); ?></td>
|
||||||
<td><?php echo isset($employee['policy_type']) ? $employee['policy_type'] : ''; ?> - <?php echo isset($employee['policy_no']) ? $employee['policy_no'] : ''; ?></td>
|
<td><?php echo isset($employee['policy_type']) ? $employee['policy_type'] : ''; ?> -
|
||||||
<td><?php echo $employee['insurer_short_name']; ?></td>
|
<?php echo isset($employee['policy_no']) ? $employee['policy_no'] : ''; ?></td>
|
||||||
<td><?php echo $employee['tpa_id']; ?></td>
|
<td><?php echo $employee['insurer_short_name']; ?></td>
|
||||||
<td><?php echo $employee['uhid']; ?></td>
|
<td><?php echo $employee['tpa_id']; ?></td>
|
||||||
<td>
|
<td><?php echo $employee['uhid']; ?></td>
|
||||||
<?php
|
<td>
|
||||||
|
<?php
|
||||||
switch ($employee['status']) {
|
switch ($employee['status']) {
|
||||||
case 'draft':
|
case 'draft':
|
||||||
echo '<span class="badge badge-secondary">' . $employee['status'] . '</span>';
|
echo '<span class="badge badge-secondary">' . $employee['status'] . '</span>';
|
||||||
@ -131,32 +172,54 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
<td><?php echo format_indian_number($employee['basic_cover_si']); ?></td>
|
<td><?php echo format_indian_number($employee['basic_cover_si']); ?></td>
|
||||||
<td><?php echo format_indian_number($employee['premium']); ?></td>
|
<td><?php echo format_indian_number($employee['premium']); ?></td>
|
||||||
<td><?php $pro_rata_total += $employee['rata_premimum']; echo format_indian_number($employee['rata_premimum']); ?></td>
|
<td><?php $pro_rata_total += $employee['rata_premimum']; echo format_indian_number($employee['rata_premimum']); ?>
|
||||||
<td><?php $gst_total += $employee['gst']; echo format_indian_number($employee['gst']); ?></td>
|
</td>
|
||||||
<td>
|
<td><?php $gst_total += $employee['gst']; echo format_indian_number($employee['gst']); ?>
|
||||||
<div class="btn-group dropdown">
|
</td>
|
||||||
<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>
|
<td>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="btn-group dropdown">
|
||||||
|
<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">
|
||||||
|
|
||||||
<?php if(in_array($employee['emp_status'], ['draft', 'enrolled', 'active']) && in_array($employee['status'], ['draft', 'enrolled', 'active'])) { ?>
|
<?php
|
||||||
<a class="dropdown-item" onclick="get_emp_master_data_for_update(this, '<?= $employee['employee_id'];?>')" ><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
if
|
||||||
<?php } ?>
|
(
|
||||||
|
(in_array($employee['emp_status'], ['draft', 'enrolled', 'active']) && in_array($employee['status'], ['draft', 'enrolled', 'active']))
|
||||||
|
) {
|
||||||
|
?>
|
||||||
|
<a class="dropdown-item"
|
||||||
|
onclick="get_emp_master_data_for_update(this, '<?= $employee['employee_id'];?>', '<?= $employee['status'];?>')"><i
|
||||||
|
class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||||
|
<a class="dropdown-item"
|
||||||
|
onclick="get_emp_history(this, '<?= $employee['employee_id'];?>')"> <i
|
||||||
|
class="mdi mdi-history mr-2 text-muted font-18 vertical-middle"></i>Employee
|
||||||
|
History</a>
|
||||||
|
|
||||||
<?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
<?php } ?>
|
||||||
<a href="<?= base_url('download-e-card/'). $employee['rand_string'] ?>" class="dropdown-item" target="_blank"><i class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View E-Card</a>
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['email_corporate'] != '' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
<?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
||||||
<a class="dropdown-item" onclick="send_mail_for_individual_employee_ecard('<?= $employee['id'];?>')" ><i class="mdi mdi-email-alert mr-2 text-muted font-18 vertical-middle"></i>Send E-Card Mail</a>
|
<a href="<?= base_url('download-e-card/'). $employee['rand_string'] ?>"
|
||||||
<?php } ?>
|
class="dropdown-item" target="_blank"><i
|
||||||
|
class="mdi mdi-eye mr-2 text-muted font-18 vertical-middle"></i>View
|
||||||
|
E-Card</a>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
</div>
|
<?php if($employee['relationship'] == 'Self' && in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['email_corporate'] != '' && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
|
||||||
</div>
|
<a class="dropdown-item"
|
||||||
</td>
|
onclick="send_mail_for_individual_employee_ecard('<?= $employee['id'];?>')"><i
|
||||||
</tr>
|
class="mdi mdi-email-alert mr-2 text-muted font-18 vertical-middle"></i>Send
|
||||||
|
E-Card Mail</a>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<?php } } ?>
|
<?php } } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
@ -165,10 +228,10 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
<?php if (isset($getData)) {
|
<?php if (isset($getData)) {
|
||||||
if ($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
|
if ($getData['client_id'] == '0' && $getData['policy_id'] == '0' && $getData['branch_id'] == '0' && ($getData['emp_code'] != "" || $getData['emp_name'] != "" || $getData['status'] != "")) { ?>
|
||||||
<th></th>
|
<th></th>
|
||||||
<?php }
|
<?php }
|
||||||
if ($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
|
if ($getData['client_id'] != '0' && $getData['branch_id'] == '0') { ?>
|
||||||
<th></th>
|
<th></th>
|
||||||
<?php } } ?>
|
<?php } } ?>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
@ -195,7 +258,8 @@
|
|||||||
|
|
||||||
<!-- modal content -->
|
<!-- modal content -->
|
||||||
|
|
||||||
<div id="emp_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
|
<div id="emp_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
|
||||||
|
style="display: none;">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
@ -204,22 +268,24 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-body p-4">
|
<div class="modal-body p-4">
|
||||||
<form role="form" class="parsley-examples" id="empForm" onsubmit="update_emp_master_data_submit_function(event, this)" enctype="multipart/form-data">
|
<form role="form" class="parsley-examples" id="empForm"
|
||||||
|
onsubmit="update_emp_master_data_submit_function(event, this)" enctype="multipart/form-data">
|
||||||
|
|
||||||
<input type="hidden" name="employee_primary_id" id="employee_primary_id"/>
|
<input type="hidden" name="employee_primary_id" id="employee_primary_id" />
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="emp_code">Employee Code<span class="text-danger">*</span></label>
|
<label for="emp_code">Employee Code<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="emp_code_for_edit" placeholder="Enter Code" readonly>
|
<input type="text" class="form-control" id="emp_code_for_edit" placeholder="Enter Code"
|
||||||
|
readonly>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-8">
|
<div class="form-group col-md-8">
|
||||||
<label for="name">Name<span class="text-danger">*</span></label>
|
<label for="name">Name<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" name="name" id="name" placeholder="Ente Name">
|
<input type="text" class="form-control" name="name" id="name" placeholder="Ente Name">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
@ -233,24 +299,30 @@
|
|||||||
|
|
||||||
<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="Enter DOB" name="dob" required>
|
<input type="text" class="form-control" id="dob" placeholder="Enter DOB" name="dob"
|
||||||
|
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>
|
||||||
<input type="text" class="form-control" id="email_corporate" placeholder="Enter Email" name="email_corporate" data-parsley-trigger="change" data-parsley-type="email" required>
|
<input type="text" class="form-control" id="email_corporate" placeholder="Enter Email"
|
||||||
|
name="email_corporate" data-parsley-trigger="change" data-parsley-type="email"
|
||||||
|
onchange="validateInput(this, 'employees', 'email_corporate')" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<label for="mobile">Mobile Number<span class="text-danger">*</span></label>
|
<label for="mobile">Mobile Number<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number" name="mobile" onkeypress = "return onlyNumbers(event)" maxlength="10" minlength="10" required>
|
<input type="text" class="form-control" id="mobile" placeholder="Enter Mobile Number"
|
||||||
|
name="mobile" onkeypress="return onlyNumbers(event)" maxlength="10" minlength="10"
|
||||||
|
onchange="validateInput(this, 'employees', 'mobile')" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group text-right m-b-0">
|
<div class="form-group text-right m-b-0">
|
||||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
|
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||||||
|
id="btnSubmit">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
@ -259,248 +331,398 @@
|
|||||||
</div>
|
</div>
|
||||||
</div><!-- /.modal -->
|
</div><!-- /.modal -->
|
||||||
|
|
||||||
|
<!-- Modal content for Emp History -->
|
||||||
|
<div class="modal fade" id="emp_history_modal" tabindex="-1" aria-labelledby="emp_history_modal_label"
|
||||||
|
aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" id="emp_history_modal_label">Employee History</h4>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
</div>
|
||||||
|
<div id="emp_history_content"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
$(document).ready(function(){
|
var dob = flatpickr("#dob", {
|
||||||
|
dateFormat: "d/m/Y",
|
||||||
var dob = flatpickr("#dob", {
|
allowInput: false, // Allows manual input
|
||||||
dateFormat: "d/M/Y",
|
yearSelector: true, // Ensures year can be selected manually
|
||||||
allowInput: false
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
var ticketsTable = $('#tickets-table');
|
|
||||||
|
|
||||||
if (ticketsTable.length) {
|
|
||||||
ticketsTable.DataTable({
|
|
||||||
scrollX: true,
|
|
||||||
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
|
|
||||||
"<'row'<'col-sm-12'tr>>" +
|
|
||||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
|
||||||
buttons: [{
|
|
||||||
extend: 'csv',
|
|
||||||
text: 'CSV',
|
|
||||||
title: 'Member-List',
|
|
||||||
},{
|
|
||||||
extend: 'excel',
|
|
||||||
text: 'Excel',
|
|
||||||
title: 'Member-List',
|
|
||||||
}],
|
|
||||||
language: {
|
|
||||||
search: "_INPUT_",
|
|
||||||
searchPlaceholder: "Search..."
|
|
||||||
},
|
|
||||||
paging: true, // Enable pagination
|
|
||||||
pageLength: 25 // Set default number of rows per page (optional)
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.error("Table not found.");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function get_emp_master_data_for_update(input, id){
|
})
|
||||||
|
|
||||||
get_emp_master_data_for_update_ajax(id)
|
$(document).ready(function() {
|
||||||
|
var ticketsTable = $('#tickets-table');
|
||||||
|
|
||||||
|
if (ticketsTable.length) {
|
||||||
|
ticketsTable.DataTable({
|
||||||
|
scrollX: true,
|
||||||
|
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
|
||||||
|
"<'row'<'col-sm-12'tr>>" +
|
||||||
|
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||||
|
buttons: [{
|
||||||
|
extend: 'csv',
|
||||||
|
text: 'CSV',
|
||||||
|
title: 'Member-List',
|
||||||
|
}, {
|
||||||
|
extend: 'excel',
|
||||||
|
text: 'Excel',
|
||||||
|
title: 'Member-List',
|
||||||
|
}],
|
||||||
|
language: {
|
||||||
|
search: "_INPUT_",
|
||||||
|
searchPlaceholder: "Search..."
|
||||||
|
},
|
||||||
|
paging: true, // Enable pagination
|
||||||
|
pageLength: 25 // Set default number of rows per page (optional)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error("Table not found.");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function get_emp_master_data_for_update_ajax(id){
|
function get_emp_master_data_for_update(input, id) {
|
||||||
|
|
||||||
$('.loader').fadeIn();
|
get_emp_master_data_for_update_ajax(id)
|
||||||
$('.loader-mask').fadeIn();
|
|
||||||
|
|
||||||
$.ajax({
|
}
|
||||||
url: '<?php echo base_url('util/get_emp_master_data_for_update/');?>'+id,
|
|
||||||
type: "GET",
|
|
||||||
dataType: 'json',
|
|
||||||
success: function (res) {
|
|
||||||
|
|
||||||
console.log('get_emp_master_data_for_update response', res)
|
function get_emp_master_data_for_update_ajax(id) {
|
||||||
|
|
||||||
$('.loader').fadeOut();
|
$('.loader').fadeIn();
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
let data = res.data
|
$.ajax({
|
||||||
|
url: '<?php echo base_url('util/get_emp_master_data_for_update/');?>' + id,
|
||||||
|
type: "GET",
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(res) {
|
||||||
|
|
||||||
if(res.status == true){
|
console.log('get_emp_master_data_for_update response', res)
|
||||||
|
|
||||||
if(data.relationship == 'Self'){
|
$('.loader').fadeOut();
|
||||||
$('#gender').prop('disabled', false)
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
}else{
|
|
||||||
$('#gender').prop('disabled', true)
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#employee_primary_id').val(data.id);
|
let data = res.data
|
||||||
$('#emp_code_for_edit').val(data.emp_code);
|
|
||||||
$('#name').val(data.name);
|
|
||||||
$('#gender').val(data.gender);
|
|
||||||
$('#dob').val(data.formatted_dob);
|
|
||||||
$('#email_corporate').val(data.email_corporate);
|
|
||||||
$('#mobile').val(data.mobile);
|
|
||||||
|
|
||||||
if(data.emp_status == "active"){
|
if (res.status == true) {
|
||||||
$('#name').prop('disabled', true);
|
|
||||||
$('#gender').prop('disabled', true);
|
|
||||||
$('#dob').prop('disabled', true);
|
|
||||||
}else{
|
|
||||||
$('#name').prop('disabled', false);
|
|
||||||
$('#gender').prop('disabled', false);
|
|
||||||
$('#dob').prop('disabled', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
var myModal = new bootstrap.Modal(document.getElementById('emp_modal'));
|
if (data.relationship == 'Self') {
|
||||||
myModal.show();
|
$('#gender').prop('disabled', false)
|
||||||
|
} else {
|
||||||
|
$('#gender').prop('disabled', true)
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
$('#employee_primary_id').val(data.id);
|
||||||
$('#employee_primary_id').val('');
|
$('#emp_code_for_edit').val(data.emp_code);
|
||||||
$('#emp_code_for_edit').val('');
|
$('#name').val(data.name);
|
||||||
$('#name').val('');
|
$('#gender').val(data.gender);
|
||||||
$('#gender').val('');
|
$('#dob').val(data.formatted_dob);
|
||||||
$('#dob').val('');
|
$('#email_corporate').val(data.email_corporate);
|
||||||
$('#email_corporate').val('');
|
$('#mobile').val(data.mobile);
|
||||||
$('#mobile').val('');
|
|
||||||
|
|
||||||
|
if (data.emp_status == "active") {
|
||||||
|
$('#name').prop('disabled', true);
|
||||||
|
$('#gender').prop('disabled', true);
|
||||||
|
$('#dob').prop('disabled', true);
|
||||||
|
} else {
|
||||||
$('#name').prop('disabled', false);
|
$('#name').prop('disabled', false);
|
||||||
$('#gender').prop('disabled', false);
|
$('#gender').prop('disabled', false);
|
||||||
$('#dob').prop('disabled', false);
|
$('#dob').prop('disabled', false);
|
||||||
|
|
||||||
toastr.warning(res.message, 'WARNING');
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
error: function (xhr, status, error) {
|
|
||||||
|
|
||||||
$('.loader').fadeOut();
|
var myModal = new bootstrap.Modal(document.getElementById('emp_modal'));
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
myModal.show();
|
||||||
|
|
||||||
console.error(xhr.responseText);
|
} else {
|
||||||
console.error(status, error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_emp_master_data_submit_function(event, form){
|
$('#employee_primary_id').val('');
|
||||||
|
$('#emp_code_for_edit').val('');
|
||||||
|
$('#name').val('');
|
||||||
|
$('#gender').val('');
|
||||||
|
$('#dob').val('');
|
||||||
|
$('#email_corporate').val('');
|
||||||
|
$('#mobile').val('');
|
||||||
|
|
||||||
event.preventDefault(); // Prevent the default form submission
|
$('#name').prop('disabled', false);
|
||||||
|
$('#gender').prop('disabled', false);
|
||||||
|
$('#dob').prop('disabled', false);
|
||||||
|
|
||||||
var isValid = $(form).parsley().validate();
|
toastr.warning(res.message, 'WARNING');
|
||||||
if (!isValid) {
|
}
|
||||||
console.log('Form is Empty', 'Warning');
|
},
|
||||||
return ;
|
error: function(xhr, status, error) {
|
||||||
|
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
console.error(status, error);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const formData = new FormData(form);
|
function update_emp_master_data_submit_function(event, form) {
|
||||||
|
|
||||||
const submitButton = form.querySelector('button[type="submit"]');
|
event.preventDefault(); // Prevent the default form submission
|
||||||
submitButton.disabled = true;
|
|
||||||
submitButton.innerText = 'Updating...';
|
|
||||||
|
|
||||||
$('.loader').fadeIn();
|
var isValid = $(form).parsley().validate();
|
||||||
$('.loader-mask').fadeIn();
|
if (!isValid) {
|
||||||
|
console.log('Form is Empty', 'Warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// AJAX request to update the individual employee
|
const formData = new FormData(form);
|
||||||
$.ajax({
|
|
||||||
url: '<?= base_url('/util/update_emp_data') ?>',
|
|
||||||
type: 'POST',
|
|
||||||
data: formData,
|
|
||||||
processData: false,
|
|
||||||
contentType: false,
|
|
||||||
success: function(response) {
|
|
||||||
|
|
||||||
console.log(response)
|
const submitButton = form.querySelector('button[type="submit"]');
|
||||||
$('.loader').fadeOut();
|
submitButton.disabled = true;
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
submitButton.innerText = 'Updating...';
|
||||||
|
|
||||||
if(response.status == true){
|
$('.loader').fadeIn();
|
||||||
toastr.success(response.message, 'SUCCESS');
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
$('.close').click();
|
|
||||||
|
|
||||||
$('#employee_primary_id').val('');
|
// AJAX request to update the individual employee
|
||||||
$('#emp_code_for_edit').val('');
|
$.ajax({
|
||||||
$('#name').val('');
|
url: '<?= base_url('/util/update_emp_data') ?>',
|
||||||
$('#gender').val('');
|
type: 'POST',
|
||||||
$('#dob').val('');
|
data: formData,
|
||||||
$('#email_corporate').val('');
|
processData: false,
|
||||||
$('#mobile').val('');
|
contentType: false,
|
||||||
|
success: function(response) {
|
||||||
|
|
||||||
window.location.reload();
|
console.log(response)
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
|
||||||
}else{
|
if (response.status == true) {
|
||||||
toastr.error(response.message, 'ERROR');
|
toastr.success(response.message, 'SUCCESS');
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function(xhr, status, error) {
|
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
|
||||||
// Handle error
|
|
||||||
console.error('Upload error occurred:');
|
|
||||||
console.error('Status: ', status); // Status of the request
|
|
||||||
console.error('Error: ', error); // Specific error message
|
|
||||||
console.error('XHR Object: ', xhr); // Full XHR object with response details
|
|
||||||
|
|
||||||
// Optionally log server response, if available
|
$('.close').click();
|
||||||
if (xhr.responseText) {
|
|
||||||
console.error('Response Text: ', xhr.responseText);
|
$('#employee_primary_id').val('');
|
||||||
|
$('#emp_code_for_edit').val('');
|
||||||
|
$('#name').val('');
|
||||||
|
$('#gender').val('');
|
||||||
|
$('#dob').val('');
|
||||||
|
$('#email_corporate').val('');
|
||||||
|
$('#mobile').val('');
|
||||||
|
|
||||||
|
// window.location.reload();
|
||||||
|
fetchEmpolyeeList();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
toastr.error(response.message, 'ERROR');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
// Handle error
|
||||||
|
console.error('Upload error occurred:');
|
||||||
|
console.error('Status: ', status); // Status of the request
|
||||||
|
console.error('Error: ', error); // Specific error message
|
||||||
|
console.error('XHR Object: ', xhr); // Full XHR object with response details
|
||||||
|
|
||||||
|
// Optionally log server response, if available
|
||||||
|
if (xhr.responseText) {
|
||||||
|
console.error('Response Text: ', xhr.responseText);
|
||||||
|
}
|
||||||
|
|
||||||
|
toastr.warning('Error uploading file', 'WARNING');
|
||||||
|
console.error('Upload error:', error);
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
// Re-enable the submit button and reset its text
|
||||||
|
submitButton.disabled = false;
|
||||||
|
submitButton.innerText = 'Submit';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_mail_for_individual_employee_ecard(id) {
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: "Do you want to send Ecard Mail?",
|
||||||
|
showDenyButton: true,
|
||||||
|
showCancelButton: false,
|
||||||
|
confirmButtonText: "Yes,Send",
|
||||||
|
denyButtonText: "Don't Send"
|
||||||
|
}).then((result) => {
|
||||||
|
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
|
||||||
|
url: '<?php echo base_url('util/send_mail_for_individual_employee_ecard/');?>' + id,
|
||||||
|
type: "GET",
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(res) {
|
||||||
|
|
||||||
|
console.log('send_mail_for_individual_employee_ecard response', res)
|
||||||
|
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
|
||||||
|
if (res.status == true) {
|
||||||
|
toastr.success(res.message, 'SUCCESS');
|
||||||
|
} else {
|
||||||
|
toastr.error(res.message, 'ERROR');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
console.error(status, error);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
toastr.warning('Error uploading file', 'WARNING');
|
function validateInput(input, table, field) {
|
||||||
console.error('Upload error:', error);
|
|
||||||
},
|
let value = $(input).val();
|
||||||
complete: function() {
|
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
let message = "Value is duplicate!";
|
||||||
// Re-enable the submit button and reset its text
|
if (label) {
|
||||||
submitButton.disabled = false;
|
message = label + " already exists!";
|
||||||
submitButton.innerText = 'Submit';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function send_mail_for_individual_employee_ecard(id){
|
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||||
|
if (isDuplicate) {
|
||||||
|
toastr.warning(message, 'WARNING');
|
||||||
|
$(input).val('')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Swal.fire({
|
}
|
||||||
title: "Do you want to send Ecard Mail?",
|
|
||||||
showDenyButton: true,
|
|
||||||
showCancelButton: false,
|
|
||||||
confirmButtonText: "Yes,Send",
|
|
||||||
denyButtonText: "Don't Send"
|
|
||||||
}).then((result) => {
|
|
||||||
|
|
||||||
if (result.isConfirmed) {
|
function onlyNumbers(event) {
|
||||||
|
var charcode;
|
||||||
|
charcode = event.which || event.keyCode;
|
||||||
|
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var modalInstance; // Store the modal instance globally
|
||||||
|
|
||||||
$('.loader').fadeIn();
|
function showModal() {
|
||||||
$('.loader-mask').fadeIn();
|
var myModalEl = document.getElementById('emp_history_modal');
|
||||||
|
modalInstance = new bootstrap.Modal(myModalEl, {
|
||||||
|
backdrop: true, // Ensures the backdrop is shown
|
||||||
|
keyboard: true // Allows closing with the Escape key
|
||||||
|
});
|
||||||
|
modalInstance.show();
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({
|
function closeModal() {
|
||||||
|
if (modalInstance) {
|
||||||
|
modalInstance.hide(); // Hide the modal and its backdrop
|
||||||
|
// Manually remove backdrop if it's still visible
|
||||||
|
setTimeout(function() {
|
||||||
|
document.querySelector('.modal-backdrop').classList.remove('show');
|
||||||
|
}, 150); // Wait for animation to finish
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
url: '<?php echo base_url('util/send_mail_for_individual_employee_ecard/');?>'+id,
|
|
||||||
type: "GET",
|
|
||||||
dataType: 'json',
|
|
||||||
success: function (res) {
|
|
||||||
|
|
||||||
console.log('send_mail_for_individual_employee_ecard response', res)
|
|
||||||
|
|
||||||
$('.loader').fadeOut();
|
function get_emp_history(input, emp_id) {
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
if(res.status == true){
|
let url = '<?= base_url("employee/get_emp_history")?>';
|
||||||
toastr.success(res.message, 'SUCCESS');
|
let requestData = {
|
||||||
}else{
|
emp_id: emp_id
|
||||||
toastr.error(res.message, 'ERROR');
|
};
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (xhr, status, error) {
|
|
||||||
|
|
||||||
$('.loader').fadeOut();
|
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
|
||||||
console.error(xhr.responseText);
|
if (response.status === true) {
|
||||||
console.error(status, error);
|
console.log('response data length', response.data.emp_history.length);
|
||||||
}
|
|
||||||
|
// **Clear old data**
|
||||||
|
$('#emp_history_content').html('');
|
||||||
|
|
||||||
|
// **Check if data exists**
|
||||||
|
if (response.data.emp_history.length > 0) {
|
||||||
|
let historyTable = `
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table w-100">
|
||||||
|
<thead class="bg-light">
|
||||||
|
<tr>
|
||||||
|
<th>Field</th>
|
||||||
|
<th>Change</th>
|
||||||
|
<th>User</th>
|
||||||
|
<th>Date/Time</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// **Loop through the data dynamically**
|
||||||
|
response.data.emp_history.forEach(row => {
|
||||||
|
historyTable += `
|
||||||
|
<tr>
|
||||||
|
<td>${row.field_name}</td>
|
||||||
|
<td>${row.old_value} => ${row.new_value}</td>
|
||||||
|
<td>${row.created_by}</td>
|
||||||
|
<td>${row.created_at}</td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
historyTable += `
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// **Append to modal**
|
||||||
|
$('#emp_history_content').append(historyTable);
|
||||||
|
} else {
|
||||||
|
$('#emp_history_content').html('<p class="text-center text-muted">No history available.</p>');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
// **Show the modal**
|
||||||
|
showModal();
|
||||||
</script>
|
} else {
|
||||||
|
let message = response.message;
|
||||||
|
toastr.error(message, 'ERROR');
|
||||||
|
}
|
||||||
|
}, function(xhr, status, error) {
|
||||||
|
console.error('Error fetching data:', error);
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
toastr.error('An error occurred while fetching the report page.', 'ERROR');
|
||||||
|
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// function closeModal(){
|
||||||
|
// var myModalEl = document.getElementById('emp_history_modal');
|
||||||
|
// var modalInstance = bootstrap.Modal.getInstance(myModalEl);
|
||||||
|
// if (modalInstance) {
|
||||||
|
// modalInstance.hide();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
</script>
|
||||||
@ -135,31 +135,105 @@ table.dataTable tbody td {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php include('employee_data_list.php');?>
|
<?php // include('employee_data_list.php');?>
|
||||||
|
|
||||||
|
<div id="employee_table_list"></div>
|
||||||
|
|
||||||
<!-- end row -->
|
<!-- end row -->
|
||||||
<div id="loader" class="loader" style="display:none;">SPINNER</div>
|
<div id="loader" class="loader" style="display:none;">SPINNER</div>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
// document.addEventListener("DOMContentLoaded", function () {
|
||||||
const table = document.getElementById("tickets-table");
|
// const table = document.getElementById("tickets-table");
|
||||||
|
|
||||||
// Create custom dropdown
|
// // Create custom dropdown
|
||||||
function createCustomDropdown(row) {
|
// function createCustomDropdown(row) {
|
||||||
// Get the original dropdown items
|
// // Get the original dropdown items
|
||||||
const originalDropdown = row.querySelector('.dropdown-menu');
|
// const originalDropdown = row.querySelector('.dropdown-menu');
|
||||||
if (!originalDropdown) return null;
|
// if (!originalDropdown) return null;
|
||||||
|
|
||||||
// Create new dropdown with proper background and spacing
|
// // Create new dropdown with proper background and spacing
|
||||||
const customDropdown = document.createElement('div');
|
// const customDropdown = document.createElement('div');
|
||||||
customDropdown.className = 'custom-dropdown-menu';
|
// customDropdown.className = 'custom-dropdown-menu';
|
||||||
|
|
||||||
// Copy inner content while maintaining icon alignment
|
// // Copy inner content while maintaining icon alignment
|
||||||
customDropdown.innerHTML = originalDropdown.innerHTML;
|
// customDropdown.innerHTML = originalDropdown.innerHTML;
|
||||||
|
|
||||||
return customDropdown;
|
// return customDropdown;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// let activeDropdown = null;
|
||||||
|
|
||||||
|
// // Add click event listener to rows
|
||||||
|
// table.querySelectorAll("tbody tr").forEach(row => {
|
||||||
|
// const customDropdown = createCustomDropdown(row);
|
||||||
|
// if (!customDropdown) return;
|
||||||
|
|
||||||
|
// document.body.appendChild(customDropdown);
|
||||||
|
|
||||||
|
// row.addEventListener("click", function(event) {
|
||||||
|
// // Ignore clicks on the action column
|
||||||
|
// if (event.target.closest('td:last-child')) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Hide any active dropdown
|
||||||
|
// if (activeDropdown) {
|
||||||
|
// activeDropdown.style.display = 'none';
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Get click position
|
||||||
|
// const rect = event.target.getBoundingClientRect();
|
||||||
|
|
||||||
|
// // Position the dropdown with some offset
|
||||||
|
// customDropdown.style.display = 'block';
|
||||||
|
// customDropdown.style.position = 'fixed';
|
||||||
|
// customDropdown.style.left = `${rect.left}px`;
|
||||||
|
// customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
|
||||||
|
|
||||||
|
// // Set as active dropdown
|
||||||
|
// activeDropdown = customDropdown;
|
||||||
|
|
||||||
|
// event.stopPropagation();
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Preserve click handlers and add auto-close
|
||||||
|
// customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
||||||
|
// item.addEventListener('click', function(e) {
|
||||||
|
// const onclickAttr = this.getAttribute('onclick');
|
||||||
|
// if (onclickAttr) {
|
||||||
|
// eval(onclickAttr);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const href = this.getAttribute('href');
|
||||||
|
// if (href && href !== '#') {
|
||||||
|
// window.location.href = href;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Close the dropdown after handling the click
|
||||||
|
// if (activeDropdown) {
|
||||||
|
// activeDropdown.style.display = 'none';
|
||||||
|
// activeDropdown = null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// e.stopPropagation();
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Close dropdown when clicking outside
|
||||||
|
// document.addEventListener("click", function() {
|
||||||
|
// if (activeDropdown) {
|
||||||
|
// activeDropdown.style.display = 'none';
|
||||||
|
// activeDropdown = null;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", init);
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
|
||||||
|
const table = document.getElementById("tickets-table");
|
||||||
let activeDropdown = null;
|
let activeDropdown = null;
|
||||||
|
|
||||||
// Add click event listener to rows
|
// Add click event listener to rows
|
||||||
@ -170,63 +244,91 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
document.body.appendChild(customDropdown);
|
document.body.appendChild(customDropdown);
|
||||||
|
|
||||||
row.addEventListener("click", function(event) {
|
row.addEventListener("click", function(event) {
|
||||||
// Ignore clicks on the action column
|
handleRowClick(event, customDropdown);
|
||||||
if (event.target.closest('td:last-child')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide any active dropdown
|
|
||||||
if (activeDropdown) {
|
|
||||||
activeDropdown.style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get click position
|
|
||||||
const rect = event.target.getBoundingClientRect();
|
|
||||||
|
|
||||||
// Position the dropdown with some offset
|
|
||||||
customDropdown.style.display = 'block';
|
|
||||||
customDropdown.style.position = 'fixed';
|
|
||||||
customDropdown.style.left = `${rect.left}px`;
|
|
||||||
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
|
|
||||||
|
|
||||||
// Set as active dropdown
|
|
||||||
activeDropdown = customDropdown;
|
|
||||||
|
|
||||||
event.stopPropagation();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Preserve click handlers and add auto-close
|
// Preserve click handlers and add auto-close
|
||||||
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
||||||
item.addEventListener('click', function(e) {
|
item.addEventListener('click', function(e) {
|
||||||
const onclickAttr = this.getAttribute('onclick');
|
handleItemClick(e, item);
|
||||||
if (onclickAttr) {
|
|
||||||
eval(onclickAttr);
|
|
||||||
}
|
|
||||||
|
|
||||||
const href = this.getAttribute('href');
|
|
||||||
if (href && href !== '#') {
|
|
||||||
window.location.href = href;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the dropdown after handling the click
|
|
||||||
if (activeDropdown) {
|
|
||||||
activeDropdown.style.display = 'none';
|
|
||||||
activeDropdown = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.stopPropagation();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Close dropdown when clicking outside
|
// Close dropdown when clicking outside
|
||||||
document.addEventListener("click", function() {
|
document.addEventListener("click", handleDocumentClick);
|
||||||
|
|
||||||
|
function createCustomDropdown(row) {
|
||||||
|
const originalDropdown = row.querySelector('.dropdown-menu');
|
||||||
|
if (!originalDropdown) return null;
|
||||||
|
|
||||||
|
const customDropdown = document.createElement('div');
|
||||||
|
customDropdown.className = 'custom-dropdown-menu';
|
||||||
|
|
||||||
|
// Clone original dropdown items while moving onclick handlers to data attributes
|
||||||
|
const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
|
||||||
|
customDropdown.innerHTML = originalDropdown.innerHTML;
|
||||||
|
|
||||||
|
// Transfer onclick handlers to data attributes
|
||||||
|
customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
|
||||||
|
const originalItem = originalItems[index];
|
||||||
|
const originalOnclick = originalItem.getAttribute('onclick');
|
||||||
|
if (originalOnclick) {
|
||||||
|
item.setAttribute('data-onclick', originalOnclick);
|
||||||
|
item.removeAttribute('onclick'); // Remove original handler
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return customDropdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRowClick(event, customDropdown) {
|
||||||
|
if (event.target.closest('td:last-child')) return;
|
||||||
|
|
||||||
|
if (activeDropdown) {
|
||||||
|
activeDropdown.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
const rect = event.target.getBoundingClientRect();
|
||||||
|
customDropdown.style.display = 'block';
|
||||||
|
customDropdown.style.position = 'fixed';
|
||||||
|
customDropdown.style.left = `${rect.left}px`;
|
||||||
|
customDropdown.style.top = `${rect.bottom + 5}px`;
|
||||||
|
|
||||||
|
activeDropdown = customDropdown;
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleItemClick(e, item) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Execute the stored onclick handler
|
||||||
|
const onclickAttr = item.getAttribute('data-onclick');
|
||||||
|
if (onclickAttr) {
|
||||||
|
eval(onclickAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
const href = item.getAttribute('href');
|
||||||
|
if (href && href !== '#') {
|
||||||
|
window.location.href = href;
|
||||||
|
}
|
||||||
|
|
||||||
if (activeDropdown) {
|
if (activeDropdown) {
|
||||||
activeDropdown.style.display = 'none';
|
activeDropdown.style.display = 'none';
|
||||||
activeDropdown = null;
|
activeDropdown = null;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDocumentClick() {
|
||||||
|
if (activeDropdown) {
|
||||||
|
activeDropdown.style.display = 'none';
|
||||||
|
activeDropdown = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
@ -468,8 +570,11 @@ function objectToQueryString(obj) {
|
|||||||
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchEmpolyeeList(event) {
|
function fetchEmpolyeeList(event = null) {
|
||||||
event.preventDefault(); // Prevent default action
|
|
||||||
|
if(event){
|
||||||
|
event.preventDefault(); // Prevent default action
|
||||||
|
}
|
||||||
|
|
||||||
var client_id = $('#clients').val();
|
var client_id = $('#clients').val();
|
||||||
var policy_id = $('#policies').val();
|
var policy_id = $('#policies').val();
|
||||||
@ -502,24 +607,35 @@ function fetchEmpolyeeList(event) {
|
|||||||
const queryString = objectToQueryString(queryParams);
|
const queryString = objectToQueryString(queryParams);
|
||||||
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
|
||||||
// console.log(apiURL);
|
// console.log(apiURL);
|
||||||
window.location.href = apiURL;
|
// window.location.href = apiURL;
|
||||||
|
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
|
|
||||||
// var apiURL2 = $('#get-emp-list').attr('href'); // Get href attribute value
|
// var apiURL2 = $('#get-emp-list').attr('href'); // Get href attribute value
|
||||||
// console.log(apiURL);
|
console.log(apiURL);
|
||||||
// $.ajax({
|
$.ajax({
|
||||||
// url: apiURL,
|
url: apiURL,
|
||||||
// method: 'GET',
|
method: 'GET',
|
||||||
// data: queryParams,
|
data: queryParams,
|
||||||
// success: function(response) {
|
success: function(response) {
|
||||||
// // Assuming response is a JSON array
|
if(response.status == true){
|
||||||
// // displayDataTables(response);
|
$('#employee_table_list').html(response.html);
|
||||||
// console.log(response);
|
$('.loader').fadeOut();
|
||||||
// },
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
// error: function(xhr, status, error) {
|
setTimeout(function(){
|
||||||
// console.error('Error:', error);
|
init()
|
||||||
// }
|
}, 1000)
|
||||||
// });
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error('Error:', error);
|
||||||
|
toastr.error('Failed to fetch Data','Error');
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -604,17 +604,17 @@
|
|||||||
<ul class="nav-second-level">
|
<ul class="nav-second-level">
|
||||||
<!-- <li>
|
<!-- <li>
|
||||||
<a href="<?= base_url('/master/insurer/list') ?>">Insurer</a>
|
<a href="<?= base_url('/master/insurer/list') ?>">Insurer</a>
|
||||||
</li>
|
</li> -->
|
||||||
<li>
|
<!-- <li>
|
||||||
<a href="<?= base_url('/master/tpa/list') ?>">TPA</a>
|
<a href="<?= base_url('/master/tpa/list') ?>">TPA</a>
|
||||||
</li>
|
</li> -->
|
||||||
<li>
|
<!-- <li>
|
||||||
<a href="<?= base_url('/master/kyc/list') ?>">KYC</a>
|
<a href="<?= base_url('/master/kyc/list') ?>">KYC</a>
|
||||||
</li>
|
</li> -->
|
||||||
<li>
|
<!-- <li>
|
||||||
<a href="<?= base_url('/master/policy/list') ?>">Policy</a>
|
<a href="<?= base_url('/master/policy/list') ?>">Policy</a>
|
||||||
</li>
|
</li> -->
|
||||||
<li>
|
<!-- <li>
|
||||||
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
|
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -644,7 +644,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</li> -->
|
</li> -->
|
||||||
|
|
||||||
<li>
|
<!-- <li>
|
||||||
<a id="app_content_management" href="#sidebarDashboardsmenu" data-toggle="collapse" class="waves-effect" style="color: grey;">
|
<a id="app_content_management" href="#sidebarDashboardsmenu" data-toggle="collapse" class="waves-effect" style="color: grey;">
|
||||||
<i class="fa fa-info-circle" aria-hidden="true"></i>
|
<i class="fa fa-info-circle" aria-hidden="true"></i>
|
||||||
<span class="badge badge-success badge-pill float-right">2</span>
|
<span class="badge badge-success badge-pill float-right">2</span>
|
||||||
@ -660,7 +660,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li> -->
|
||||||
|
|
||||||
<!-- leads -->
|
<!-- leads -->
|
||||||
<!-- <li>
|
<!-- <li>
|
||||||
@ -672,7 +672,7 @@
|
|||||||
|
|
||||||
<?php if((get_role_id() == 1 || get_role_id() == 5) && (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()))) { ?>
|
<?php if((get_role_id() == 1 || get_role_id() == 5) && (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()))) { ?>
|
||||||
|
|
||||||
<li>
|
<!-- <li>
|
||||||
<a href="#sidebarDashboards" data-toggle="collapse" class="waves-effect">
|
<a href="#sidebarDashboards" data-toggle="collapse" class="waves-effect">
|
||||||
<i class="mdi mdi-format-list-bulleted"></i>
|
<i class="mdi mdi-format-list-bulleted"></i>
|
||||||
<span class="badge badge-success badge-pill float-right">2</span>
|
<span class="badge badge-success badge-pill float-right">2</span>
|
||||||
@ -693,9 +693,9 @@
|
|||||||
<a href="<?= base_url('/policy_tranction/statement/list') ?>">Statement upload</a>
|
<a href="<?= base_url('/policy_tranction/statement/list') ?>">Statement upload</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<!-- <li>
|
<li>
|
||||||
<a href="<?= base_url('/policy_tranction/report/list') ?>">BDS</a>
|
<a href="<?= base_url('/policy_tranction/report/list') ?>">BDS</a>
|
||||||
</li> -->
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= base_url('/policy_tranction/report/report-varience-list') ?>">Variance</a>
|
<a href="<?= base_url('/policy_tranction/report/report-varience-list') ?>">Variance</a>
|
||||||
</li>
|
</li>
|
||||||
@ -726,7 +726,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li> -->
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -52,6 +52,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
var si_amt_parent_policy = new Set();
|
||||||
|
var si_amt_base_policy = new Set();
|
||||||
|
|
||||||
function loadModal(client_policy_id, base_policy_id) {
|
function loadModal(client_policy_id, base_policy_id) {
|
||||||
$('.loader').fadeIn();
|
$('.loader').fadeIn();
|
||||||
$('.loader-mask').fadeIn();
|
$('.loader-mask').fadeIn();
|
||||||
@ -65,7 +68,7 @@ function loadModal(client_policy_id, base_policy_id) {
|
|||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
};
|
};
|
||||||
|
|
||||||
var si_amt_base_policy = new Set();
|
|
||||||
|
|
||||||
function checkExistingMapping(client_policy_id, base_policy_id) {
|
function checkExistingMapping(client_policy_id, base_policy_id) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -78,27 +81,17 @@ function checkExistingMapping(client_policy_id, base_policy_id) {
|
|||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (response.status === true && response.code === 200 && response.data.length > 0) {
|
if (response.status === true && response.code === 200 && response.data.length > 0) {
|
||||||
// Clear existing rows except the first one
|
// Clear existing rows except the first one
|
||||||
$('.si-mapping-row:not(:first)').remove();
|
$('.si-mapping-row:not(:first)').empty();
|
||||||
|
|
||||||
// First, ensure base policy and parent policy data is loaded
|
// First, ensure base policy and parent policy data is loaded
|
||||||
fetchBasePolicy(client_policy_id, base_policy_id);
|
fetchBasePolicy(client_policy_id, base_policy_id).then(()=>{
|
||||||
fetchParentPolicy(client_policy_id, base_policy_id);
|
fetchParentPolicy(client_policy_id, base_policy_id).then(()=>{
|
||||||
|
// setTimeout(() => {
|
||||||
// Wait for dropdowns to be populated
|
|
||||||
setTimeout(() => {
|
|
||||||
response.data.forEach((mapping, index) => {
|
response.data.forEach((mapping, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
// Handle first row
|
// Handle first row
|
||||||
const firstRow = $('.si-mapping-row:first');
|
const firstRow = $('.si-mapping-row:first');
|
||||||
|
|
||||||
// Clear existing values
|
|
||||||
firstRow.find('select[name="choose_si_amount_from_base_policy"]')
|
|
||||||
.val('')
|
|
||||||
.trigger('change');
|
|
||||||
firstRow.find('select[name="choose_si_amount_for_policy[]"]')
|
|
||||||
.val([])
|
|
||||||
.trigger('change');
|
|
||||||
|
|
||||||
// Set base policy SI amount
|
// Set base policy SI amount
|
||||||
firstRow.find('select[name="choose_si_amount_from_base_policy"]')
|
firstRow.find('select[name="choose_si_amount_from_base_policy"]')
|
||||||
.val(mapping.base_policy_si_amount)
|
.val(mapping.base_policy_si_amount)
|
||||||
@ -113,22 +106,13 @@ function checkExistingMapping(client_policy_id, base_policy_id) {
|
|||||||
// Store pk value
|
// Store pk value
|
||||||
firstRow.find('input[name="primary_key"]').val(mapping.pk);
|
firstRow.find('input[name="primary_key"]').val(mapping.pk);
|
||||||
} else {
|
} else {
|
||||||
// Add new row for subsequent mappings
|
// For subsequent mappings, add a new row WITHOUT triggering the add button
|
||||||
addRow();
|
addSIMappingRow();
|
||||||
$('#addButton').trigger("click");
|
|
||||||
|
|
||||||
// Wait for the new row to be properly initialized
|
// Wait for the new row to be properly initialized
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
const newRow = $('.si-mapping-row:last');
|
const newRow = $('.si-mapping-row:last');
|
||||||
|
|
||||||
// Clear existing values
|
|
||||||
newRow.find('select[name="choose_si_amount_from_base_policy"]')
|
|
||||||
.val('')
|
|
||||||
.trigger('change');
|
|
||||||
newRow.find('select[name="choose_si_amount_for_policy[]"]')
|
|
||||||
.val([])
|
|
||||||
.trigger('change');
|
|
||||||
|
|
||||||
// Set base policy SI amount
|
// Set base policy SI amount
|
||||||
newRow.find('select[name="choose_si_amount_from_base_policy"]')
|
newRow.find('select[name="choose_si_amount_from_base_policy"]')
|
||||||
.val(mapping.base_policy_si_amount)
|
.val(mapping.base_policy_si_amount)
|
||||||
@ -142,11 +126,17 @@ function checkExistingMapping(client_policy_id, base_policy_id) {
|
|||||||
|
|
||||||
// Store pk value
|
// Store pk value
|
||||||
newRow.find('input[name="primary_key"]').val(mapping.pk);
|
newRow.find('input[name="primary_key"]').val(mapping.pk);
|
||||||
}, 500);
|
// }, 500);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 1000); // Wait for fetchBasePolicy and fetchParentPolicy to complete
|
// }, 1000);
|
||||||
}else{
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// Wait for dropdowns to be populated
|
||||||
|
// Wait for fetchBasePolicy and fetchParentPolicy to complete
|
||||||
|
} else {
|
||||||
fetchBasePolicy(client_policy_id, base_policy_id);
|
fetchBasePolicy(client_policy_id, base_policy_id);
|
||||||
fetchParentPolicy(client_policy_id, base_policy_id);
|
fetchParentPolicy(client_policy_id, base_policy_id);
|
||||||
}
|
}
|
||||||
@ -159,7 +149,7 @@ function checkExistingMapping(client_policy_id, base_policy_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fetchBasePolicy(client_policy_id, base_policy_id) {
|
function fetchBasePolicy(client_policy_id, base_policy_id) {
|
||||||
$.ajax({
|
return $.ajax({
|
||||||
url: '<?php echo base_url("util/getPolicySIRacketData")?>',
|
url: '<?php echo base_url("util/getPolicySIRacketData")?>',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
data: {
|
data: {
|
||||||
@ -180,17 +170,17 @@ function fetchBasePolicy(client_policy_id, base_policy_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert Set back to an array to use in the dropdown
|
// Convert Set back to an array to use in the dropdown
|
||||||
si_amt_base_policy = Array.from(si_amt_base_policy);
|
var si_amt_base_policy_array = Array.from(si_amt_base_policy);
|
||||||
console.log("Unique SI amounts:", si_amt_base_policy); // Check the result
|
console.log("Unique SI amounts:", si_amt_base_policy_array); // Check the result
|
||||||
|
|
||||||
// Clear existing options in the dropdown
|
// Clear existing options in the dropdown
|
||||||
// $('#choose_si_amount_from_base_policy').empty();
|
$('#choose_si_amount_from_base_policy').empty();
|
||||||
$('#choose_si_amount_from_base_policy').append('<option value="">Select SI Amount</option>');
|
$('#choose_si_amount_from_base_policy').append('<option value="">Select SI Amount</option>');
|
||||||
|
|
||||||
// Append the new options
|
// Append the new options
|
||||||
for (let i = 0; i < si_amt_base_policy.length; i++) {
|
for (let i = 0; i < si_amt_base_policy_array.length; i++) {
|
||||||
console.log("Appending option:", si_amt_base_policy[i]); // Log each SI value
|
console.log("Appending option:", si_amt_base_policy_array[i]); // Log each SI value
|
||||||
$('#choose_si_amount_from_base_policy').append(`<option value="${si_amt_base_policy[i]}">${si_amt_base_policy[i]}</option>`);
|
$('#choose_si_amount_from_base_policy').append(`<option value="${si_amt_base_policy_array[i]}">${si_amt_base_policy_array[i]}</option>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -203,9 +193,8 @@ function fetchBasePolicy(client_policy_id, base_policy_id) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var si_amt_parent_policy = new Set();
|
|
||||||
function fetchParentPolicy(client_policy_id, base_policy_id) {
|
function fetchParentPolicy(client_policy_id, base_policy_id) {
|
||||||
$.ajax({
|
return $.ajax({
|
||||||
url: '<?= base_url("util/fetchPolicySIDataForParentPolicy")?>',
|
url: '<?= base_url("util/fetchPolicySIDataForParentPolicy")?>',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
data: {
|
data: {
|
||||||
@ -224,17 +213,17 @@ function fetchParentPolicy(client_policy_id, base_policy_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert Set back to an array to use in the dropdown
|
// Convert Set back to an array to use in the dropdown
|
||||||
si_amt_parent_policy = Array.from(si_amt_parent_policy);
|
var si_amt_parent_policy_array = Array.from(si_amt_parent_policy);
|
||||||
console.log("Unique SI amounts:", si_amt_parent_policy); // Check the result
|
console.log("Unique SI amounts:", si_amt_parent_policy_array); // Check the result
|
||||||
|
|
||||||
// Clear existing options in the dropdown
|
// Clear existing options in the dropdown
|
||||||
// $('#choose_si_amount_for_policy').empty();
|
$('#choose_si_amount_for_policy').empty();
|
||||||
$('#choose_si_amount_for_policy').append('<option value="">Select SI Amount</option>');
|
$('#choose_si_amount_for_policy').append('<option value="">Select SI Amount</option>');
|
||||||
|
|
||||||
// Append the new options
|
// Append the new options
|
||||||
for (let i = 0; i < si_amt_parent_policy.length; i++) {
|
for (let i = 0; i < si_amt_parent_policy_array.length; i++) {
|
||||||
console.log("Appending option:", si_amt_parent_policy[i]); // Log each SI value
|
console.log("Appending option:", si_amt_parent_policy_array[i]); // Log each SI value
|
||||||
$('#choose_si_amount_for_policy').append(`<option value="${si_amt_parent_policy[i]}">${si_amt_parent_policy[i]}</option>`);
|
$('#choose_si_amount_for_policy').append(`<option value="${si_amt_parent_policy_array[i]}">${si_amt_parent_policy_array[i]}</option>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -256,98 +245,10 @@ $(document).ready(function() {
|
|||||||
$("textarea.select2-search__field").css('resize', 'none');
|
$("textarea.select2-search__field").css('resize', 'none');
|
||||||
|
|
||||||
// Function to get all selected base policy values
|
// Function to get all selected base policy values
|
||||||
function getSelectedBasePolicies() {
|
|
||||||
var selectedBasePolicies = [];
|
|
||||||
$('.si-mapping-row').each(function() {
|
|
||||||
var selectedBasePolicy = $(this).find('select[name="choose_si_amount_from_base_policy"]').val();
|
|
||||||
if (selectedBasePolicy) {
|
|
||||||
selectedBasePolicies.push(selectedBasePolicy);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return selectedBasePolicies;
|
|
||||||
}
|
|
||||||
|
|
||||||
function addRow() {
|
|
||||||
// Get selected base policies from all previous rows
|
|
||||||
var selectedBasePolicies = getSelectedBasePolicies();
|
|
||||||
|
|
||||||
// Check if si_amt_base_policy has been populated
|
|
||||||
if (si_amt_base_policy.length === 0) {
|
|
||||||
console.log("SI amounts not yet loaded.");
|
|
||||||
return; // Prevent adding the row if the data isn't ready
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new row with the same structure as the existing row
|
|
||||||
var newRow = $('<div class="form-row si-mapping-row">');
|
|
||||||
|
|
||||||
// Generate unique IDs for the new row's selects
|
|
||||||
var uniqueIdForBasePolicy = 'choose_base_policy_' + Date.now();
|
|
||||||
var uniqueIdForSIAmountForPolicy = 'choose_si_amount_for_policy_' + Date.now();
|
|
||||||
|
|
||||||
newRow.append(
|
|
||||||
'<input name = "primary_key" type="hidden" id="'+uniqueIdForBasePolicy+'" value="">'+
|
|
||||||
'<div class="form-group col-md-3">' +
|
|
||||||
'<label>Base Policy SI Amount<span class="text-danger">*</span></label>' +
|
|
||||||
'<select class="form-control" id="' + uniqueIdForBasePolicy + '" name="choose_si_amount_from_base_policy">' +
|
|
||||||
'<option value="">Choose SI Amount</option>' +
|
|
||||||
'</select>' +
|
|
||||||
'</div>'
|
|
||||||
);
|
|
||||||
|
|
||||||
newRow.append(
|
|
||||||
'<div class="form-group col-md-3">' +
|
|
||||||
'<label>Policy SI Amount</label><br />' +
|
|
||||||
'<select class="form-control" id="' + uniqueIdForSIAmountForPolicy + '" name="choose_si_amount_for_policy[]" multiple>' +
|
|
||||||
'</select>' +
|
|
||||||
'</div>'
|
|
||||||
);
|
|
||||||
|
|
||||||
newRow.append(
|
|
||||||
'<div class="form-group">' +
|
|
||||||
'<div class="btn-group" style="margin-top: 45px;">' +
|
|
||||||
'<button type="button" class="btn btn-danger remove-row" style="margin-right: 5px;">x</button>' +
|
|
||||||
'<button type="button" class="btn btn-success add-row">+</button>' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Append the new row to the container
|
|
||||||
$('#si-mapping-container').append(newRow);
|
|
||||||
|
|
||||||
// Loop through and append SI amounts to the new row's 'choose_si_amount_from_base_policy' dropdown
|
|
||||||
si_amt_base_policy.forEach(function(value) {
|
|
||||||
newRow.find('select[name="choose_si_amount_from_base_policy"]').append('<option value="'+value+'">'+value+'</option>');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Remove selected base policies from the new row's 'choose_si_amount_from_base_policy' options
|
|
||||||
newRow.find('select[name="choose_si_amount_from_base_policy"] option').each(function() {
|
|
||||||
var value = $(this).val();
|
|
||||||
if (selectedBasePolicies.includes(value)) {
|
|
||||||
$(this).remove();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Append the unique SI amounts to 'choose_si_amount_for_policy[]'
|
|
||||||
si_amt_parent_policy.forEach(function(value) {
|
|
||||||
newRow.find('select[name="choose_si_amount_for_policy[]"]').append('<option value="'+value+'">'+value+'</option>');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Re-initialize select2 for the new row's dropdowns
|
|
||||||
newRow.find('select[name="choose_si_amount_for_policy[]"]').select2({
|
|
||||||
placeholder: 'Select SI Amount'
|
|
||||||
});
|
|
||||||
|
|
||||||
newRow.find('select[name="choose_si_amount_from_base_policy"]').select2({
|
|
||||||
placeholder: 'Choose SI Amount'
|
|
||||||
});
|
|
||||||
|
|
||||||
$("textarea.select2-search__field").attr('rows', '1');
|
|
||||||
$("textarea.select2-search__field").css('resize', 'none');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use event delegation to bind the click event for .add-row
|
// Use event delegation to bind the click event for .add-row
|
||||||
$(document).on('click', '.add-row', function() {
|
$(document).on('click', '.add-row', function() {
|
||||||
addRow();
|
addSIMappingRow();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove an SI Mapping row
|
// Remove an SI Mapping row
|
||||||
@ -446,6 +347,9 @@ function submitForm() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function resetFormAndRemoveRows() {
|
function resetFormAndRemoveRows() {
|
||||||
|
|
||||||
|
si_amt_parent_policy.clear();
|
||||||
|
si_amt_base_policy.clear();
|
||||||
// Reset the form fields
|
// Reset the form fields
|
||||||
$('#si_mapping_form')[0].reset(); // Reset all form fields
|
$('#si_mapping_form')[0].reset(); // Reset all form fields
|
||||||
|
|
||||||
@ -462,5 +366,93 @@ function resetFormAndRemoveRows() {
|
|||||||
$('#choose_si_amount_for_policy').val('').trigger('change');
|
$('#choose_si_amount_for_policy').val('').trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSelectedBasePolicies() {
|
||||||
|
var selectedBasePolicies = [];
|
||||||
|
$('.si-mapping-row').each(function() {
|
||||||
|
var selectedBasePolicy = $(this).find('select[name="choose_si_amount_from_base_policy"]').val();
|
||||||
|
if (selectedBasePolicy) {
|
||||||
|
selectedBasePolicies.push(selectedBasePolicy);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return selectedBasePolicies;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addSIMappingRow() {
|
||||||
|
// Get selected base policies from all previous rows
|
||||||
|
var selectedBasePolicies = getSelectedBasePolicies();
|
||||||
|
|
||||||
|
// Check if si_amt_base_policy has been populated
|
||||||
|
if (si_amt_base_policy.length === 0) {
|
||||||
|
console.log("SI amounts not yet loaded.");
|
||||||
|
return; // Prevent adding the row if the data isn't ready
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new row with the same structure as the existing row
|
||||||
|
var newRow = $('<div class="form-row si-mapping-row">');
|
||||||
|
|
||||||
|
// Generate unique IDs for the new row's selects
|
||||||
|
var uniqueIdForBasePolicy = 'choose_base_policy_' + Date.now();
|
||||||
|
var uniqueIdForSIAmountForPolicy = 'choose_si_amount_for_policy_' + Date.now();
|
||||||
|
|
||||||
|
newRow.append(
|
||||||
|
'<input name="primary_key" type="hidden" value="">'+
|
||||||
|
'<div class="form-group col-md-3">' +
|
||||||
|
'<label>Base Policy SI Amount<span class="text-danger">*</span></label>' +
|
||||||
|
'<select class="form-control" id="' + uniqueIdForBasePolicy + '" name="choose_si_amount_from_base_policy">' +
|
||||||
|
'<option value="">Choose SI Amount</option>' +
|
||||||
|
'</select>' +
|
||||||
|
'</div>'
|
||||||
|
);
|
||||||
|
|
||||||
|
newRow.append(
|
||||||
|
'<div class="form-group col-md-3">' +
|
||||||
|
'<label>Policy SI Amount</label><br />' +
|
||||||
|
'<select class="form-control" id="' + uniqueIdForSIAmountForPolicy + '" name="choose_si_amount_for_policy[]" multiple>' +
|
||||||
|
'</select>' +
|
||||||
|
'</div>'
|
||||||
|
);
|
||||||
|
|
||||||
|
newRow.append(
|
||||||
|
'<div class="form-group">' +
|
||||||
|
'<div class="btn-group" style="margin-top: 45px;">' +
|
||||||
|
'<button type="button" class="btn btn-danger remove-row" style="margin-right: 5px;">x</button>' +
|
||||||
|
'<button type="button" class="btn btn-success add-row">+</button>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Append the new row to the container
|
||||||
|
$('#si-mapping-container').append(newRow);
|
||||||
|
|
||||||
|
// First, populate all options
|
||||||
|
si_amt_base_policy.forEach(function(value) {
|
||||||
|
newRow.find('select[name="choose_si_amount_from_base_policy"]').append('<option value="'+value+'">'+value+'</option>');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Then, remove already selected values from the dropdown
|
||||||
|
selectedBasePolicies.forEach(function(value) {
|
||||||
|
if (value) { // Check if the value is not empty
|
||||||
|
newRow.find('select[name="choose_si_amount_from_base_policy"] option[value="'+value+'"]').remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Append the unique SI amounts to 'choose_si_amount_for_policy[]'
|
||||||
|
si_amt_parent_policy.forEach(function(value) {
|
||||||
|
newRow.find('select[name="choose_si_amount_for_policy[]"]').append('<option value="'+value+'">'+value+'</option>');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialize select2 for the new dropdowns
|
||||||
|
newRow.find('select[name="choose_si_amount_for_policy[]"]').select2({
|
||||||
|
placeholder: 'Select SI Amount'
|
||||||
|
});
|
||||||
|
|
||||||
|
// newRow.find('select[name="choose_si_amount_from_base_policy"]').select2({
|
||||||
|
// placeholder: 'Choose SI Amount'
|
||||||
|
// });
|
||||||
|
|
||||||
|
$("textarea.select2-search__field").attr('rows', '1');
|
||||||
|
$("textarea.select2-search__field").css('resize', 'none');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -420,17 +420,21 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
|
|
||||||
// Create custom dropdown
|
// Create custom dropdown
|
||||||
function createCustomDropdown(row) {
|
function createCustomDropdown(row) {
|
||||||
// Get the original dropdown items
|
|
||||||
const originalDropdown = row.querySelector('.dropdown-menu');
|
const originalDropdown = row.querySelector('.dropdown-menu');
|
||||||
if (!originalDropdown) return null;
|
if (!originalDropdown) return null;
|
||||||
|
|
||||||
// Create new dropdown with proper background and spacing
|
|
||||||
const customDropdown = document.createElement('div');
|
const customDropdown = document.createElement('div');
|
||||||
customDropdown.className = 'custom-dropdown-menu';
|
customDropdown.className = 'custom-dropdown-menu';
|
||||||
|
|
||||||
// Copy inner content while maintaining icon alignment
|
|
||||||
customDropdown.innerHTML = originalDropdown.innerHTML;
|
customDropdown.innerHTML = originalDropdown.innerHTML;
|
||||||
|
|
||||||
|
// Remove inline onclick handlers and store them in data attributes
|
||||||
|
const originalItems = originalDropdown.querySelectorAll('.dropdown-item');
|
||||||
|
customDropdown.querySelectorAll('.dropdown-item').forEach((item, index) => {
|
||||||
|
const originalOnclick = originalItems[index].getAttribute('onclick');
|
||||||
|
item.removeAttribute('onclick'); // Remove the inline handler
|
||||||
|
item.setAttribute('data-onclick', originalOnclick); // Store in data attribute
|
||||||
|
});
|
||||||
|
|
||||||
return customDropdown;
|
return customDropdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,45 +448,34 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
document.body.appendChild(customDropdown);
|
document.body.appendChild(customDropdown);
|
||||||
|
|
||||||
row.addEventListener("click", function(event) {
|
row.addEventListener("click", function(event) {
|
||||||
// Ignore clicks on the first column (td:first-child)
|
// Ignore clicks on the first column
|
||||||
if (event.target.closest('td:first-child')) {
|
if (event.target.closest('td:first-child')) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide any active dropdown
|
if (activeDropdown) activeDropdown.style.display = 'none';
|
||||||
if (activeDropdown) {
|
|
||||||
activeDropdown.style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get click position
|
|
||||||
const rect = event.target.getBoundingClientRect();
|
const rect = event.target.getBoundingClientRect();
|
||||||
|
|
||||||
// Position the dropdown with some offset
|
|
||||||
customDropdown.style.display = 'block';
|
customDropdown.style.display = 'block';
|
||||||
customDropdown.style.position = 'fixed';
|
customDropdown.style.position = 'fixed';
|
||||||
customDropdown.style.left = `${rect.left}px`;
|
customDropdown.style.left = `${rect.left}px`;
|
||||||
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
|
customDropdown.style.top = `${rect.bottom + 5}px`;
|
||||||
|
|
||||||
// Set as active dropdown
|
|
||||||
activeDropdown = customDropdown;
|
activeDropdown = customDropdown;
|
||||||
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Preserve click handlers and add auto-close
|
// Handle custom dropdown clicks
|
||||||
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
||||||
item.addEventListener('click', function(e) {
|
item.addEventListener('click', function(e) {
|
||||||
const onclickAttr = this.getAttribute('onclick');
|
e.preventDefault();
|
||||||
if (onclickAttr) {
|
|
||||||
eval(onclickAttr);
|
|
||||||
}
|
|
||||||
|
|
||||||
const href = this.getAttribute('href');
|
// Execute the original onclick from data attribute
|
||||||
if (href && href !== '#') {
|
const onclickAttr = this.getAttribute('data-onclick');
|
||||||
window.location.href = href;
|
if (onclickAttr) eval(onclickAttr);
|
||||||
}
|
|
||||||
|
// Handle href navigation
|
||||||
|
const href = this.getAttribute('href');
|
||||||
|
if (href && href !== '#') window.location.href = href;
|
||||||
|
|
||||||
// Close the dropdown after handling the click
|
|
||||||
if (activeDropdown) {
|
if (activeDropdown) {
|
||||||
activeDropdown.style.display = 'none';
|
activeDropdown.style.display = 'none';
|
||||||
activeDropdown = null;
|
activeDropdown = null;
|
||||||
@ -493,7 +486,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Close dropdown when clicking outside
|
// Close dropdown on outside click
|
||||||
document.addEventListener("click", function() {
|
document.addEventListener("click", function() {
|
||||||
if (activeDropdown) {
|
if (activeDropdown) {
|
||||||
activeDropdown.style.display = 'none';
|
activeDropdown.style.display = 'none';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user