CHANGE_CLIENT_INCEPTION_CRS_AND_LIVE_ISSUE_AND_OTHERS : RV

This commit is contained in:
VENKATESHWARAN 2025-08-02 13:03:11 +05:30
parent 8655218ef5
commit 393270f2a6
12 changed files with 1451 additions and 172 deletions

View File

@ -87,6 +87,8 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
$routes->get('deposit/(:num)', 'ClientController::deposit/$1');
$routes->get('remove/(:num)', 'ClientController::removeClient/$1');
$routes->get("list/(:any)", "ClientController::editClientOnboarding/$1");
$routes->post('wipe', 'ClientController::wipeDemoClient');
// application/config/routes.php
// Add a route for the view_Deposit method

View File

@ -809,7 +809,12 @@ class ClientController extends AdminController
$data['is_download_btn'] = 1;
}
if(empty($data['parent_client_id'])){
$data['parent_client_id'] = null;
}
$insert = $this->clientModel->insert($data);
if ($insert) {
$client_data = $this->clientModel->where(['id' => $insert, 'is_active' => 1])->first();
return $this->respond(['status' => true, 'code' => 200, 'data' => $client_data], 200);
@ -838,6 +843,9 @@ class ClientController extends AdminController
$data['is_download_btn'] = 1;
}
if(empty($data['parent_client_id'])){
$data['parent_client_id'] = null;
}
// print_r($data);die;
$update = $this->clientModel->update($id, $data);
@ -3557,21 +3565,54 @@ class ClientController extends AdminController
public function get_cd_ac($client_id, $insurer_id, $insurer_branch_id)
{
// Get client data
$client_data = $this->clientModel
->where('is_active', 1)
->where('id', $client_id)
->first();
$cd_data = $this->CDMasterModel
$cd_data = [];
// If client has a parent, fetch parent client CD data
if (!empty($client_data['parent_client_id'])) {
$parent_cd_data = $this->CDMasterModel
->where('client_id', $client_data['parent_client_id'])
->where('insurer_id', $insurer_id)
->where('insurer_branch_id', $insurer_branch_id)
->where('is_active', 1)
->findAll();
$cd_data = array_merge($cd_data, $parent_cd_data);
}
// Fetch current client CD data
$client_cd_data = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id)
->where('insurer_branch_id', $insurer_branch_id)
->where('is_active', 1)
->findAll();
if ($cd_data) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200);
$cd_data = array_merge($cd_data, $client_cd_data);
if (!empty($cd_data)) {
return $this->respond([
'status' => true,
'code' => 200,
'data' => $cd_data
], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'insurer_id' => $insurer_id, 'client_id' => $client_id], 200);
return $this->respond([
'status' => false,
'code' => 404,
'client_id' => $client_id,
'insurer_id' => $insurer_id,
'insurer_branch_id' => $insurer_branch_id
], 200);
}
}
public function otherPolicyTermsFormSubmit()
{
@ -4100,22 +4141,60 @@ class ClientController extends AdminController
}
public function getCDAccNoByClientAndInsurer($client, $insurer, $insurer_branch_id)
public function getCDAccNoByClientAndInsurer($client_id, $insurer_id, $insurer_branch_id)
{
$cdmData = $this->CDMasterModel
->where('client_id', $client)
->where('insurer_id', $insurer)
->where('insurer_branch_id', $insurer_branch_id)
->where('is_active', 1)
->findAll();
// Get client data
$client_data = $this->clientModel
->where('is_active', 1)
->where('id', $client_id)
->first();
if ($cdmData) {
return $this->respond(['status' => true, 'data' => $cdmData], 200);
$cd_data = [];
// If client has a parent, fetch parent client CD data
if (!empty($client_data['parent_client_id'])) {
$parent_cd_data = $this->CDMasterModel
->where('client_id', $client_data['parent_client_id'])
->where('insurer_id', $insurer_id)
->where('insurer_branch_id', $insurer_branch_id)
->where('is_active', 1)
->findAll();
$cd_data = array_merge($cd_data, $parent_cd_data);
}
// Fetch current client CD data
$client_cd_data = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id)
->where('insurer_branch_id', $insurer_branch_id)
->where('is_active', 1)
->findAll();
$cd_data = array_merge($cd_data, $client_cd_data);
if (!empty($cd_data)) {
return $this->respond([ 'status' => true,'code' => 200, 'data' => $cd_data], 200);
} else {
return $this->respond(['status' => false], 200);
return $this->respond(['status' => false,'code' => 404,'client_id' => $client_id,'insurer_id' => $insurer_id,'insurer_branch_id' => $insurer_branch_id ], 200);
}
}
// public function getCDAccNoByClientAndInsurer($client, $insurer, $insurer_branch_id)
// {
// $cdmData = $this->CDMasterModel
// ->where('client_id', $client)
// ->where('insurer_id', $insurer)
// ->where('insurer_branch_id', $insurer_branch_id)
// ->where('is_active', 1)
// ->findAll();
// if ($cdmData) {
// return $this->respond(['status' => true, 'data' => $cdmData], 200);
// } else {
// return $this->respond(['status' => false], 200);
// }
// }
public function createClientWithMinimalData()
{
@ -6147,7 +6226,7 @@ class ClientController extends AdminController
}
}
// ---------------------------------------------------------------------------------------------------
// ---------------- HR ACCESS CONTROL -----------------------------------------------------------------------------------
public function viewHrAccessData()
{
@ -6493,8 +6572,585 @@ class ClientController extends AdminController
}
}
// ------------------- DEMO CLIENT FUNCTION --------------------------------------------------------------------------------
// public function wipeDemoClient()
// {
// // $this->myLogger->logme('error', "Wipe Demo Client function called");
// $this->myLogger->logme('error', "Wipe Demo Client function called"); // Red text
// $this->myLogger->logme('error', "Wipe Demo client Payload : " . json_encode($this->request->getPost() ?? []));
// $client_id = $this->request->getPost('client_id');
// if (empty($client_id)) {
// return $this->respond(['status' => false, 'message' => 'Client id required'], 404);
// }
// // 1. Client Model
// $client_data = $this->clientModel->where('id', $client_id)->where('is_active', 1)->first();
// $this->myLogger->logme('error', "Client data : " . json_encode($client_data ?? []));
// if (!empty($client_data)) {
// $is_deleted = $this->clientModel->where('id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Client data removed successfully.");
// } else {
// $this->myLogger->logme('error', "Client record does not exist.");
// }
// } else {
// return $this->respond(['status' => false, 'message' => 'Client not found'], 404);
// }
// // 2. Client RM Model
// $client_rm_data = $this->clientRMModel->where('client_id', $client_id)->first();
// $this->myLogger->logme('error', "Client Relationship Manager data : " . json_encode($client_rm_data ?? []));
// if (!empty($client_rm_data)) {
// $is_deleted = $this->clientRMModel->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Client Relationship Manager data removed successfully.");
// } else {
// $this->myLogger->logme('error', "Client Relationship Manager record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "Client Relationship Manager data not found.");
// }
// // 3. Client KYC Docs Model
// $client_kyc_data = $this->clientKYCDocsModel->where('client_id', $client_id)->findAll();
// $this->myLogger->logme('error', "Client KYC Docs data : " . json_encode($client_kyc_data ?? []));
// if (!empty($client_kyc_data)) {
// $is_deleted = $this->clientKYCDocsModel->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Client KYC Docs data removed successfully.");
// } else {
// $this->myLogger->logme('error', "Client KYC Docs record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "Client KYC Docs data not found.");
// }
// // 4. Client Branch Model
// $client_branch_data = $this->clientBranchModel->where('client_id', $client_id)->findAll();
// $this->myLogger->logme('error', "Client Branch data : " . json_encode($client_branch_data ?? []));
// $branch_ids = array_column($client_branch_data, 'id') ?? [];
// $this->myLogger->logme('error', "Client Branch id count : " . count($branch_ids ?? []));
// if (!empty($client_branch_data)) {
// $is_deleted = $this->clientBranchModel->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Client Branch data removed successfully.");
// if(!empty($branch_ids)){
// $level_contact_data = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->findAll();
// $this->myLogger->logme('error', "Level Contact data : " . json_encode($level_contact_data ?? []));
// $is_deleted = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Level Contact data removed successfully.");
// } else {
// $this->myLogger->logme('error', "Level Contact record does not exist. To delete");
// }
// }else{
// $this->myLogger->logme('error', "Level Contact data not found.");
// }
// } else {
// $this->myLogger->logme('error', "Client Branch record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "Client Branch data not found.");
// }
// // 5. Client Policy Model
// $client_policy_data = $this->clientPolicyModel->where('client_id', $client_id)->findAll();
// $this->myLogger->logme('error', "Client Policy data : " . json_encode($client_policy_data ?? []));
// $policy_ids = array_column($client_policy_data, 'id') ?? [];
// $this->myLogger->logme('error', "Client Policy id count : " . count($policy_ids ?? []));
// if (!empty($client_policy_data)) {
// $is_deleted = $this->clientPolicyModel->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Client Policy data removed successfully.");
// if(!empty($policy_ids)){
// $employee_policy_data = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->findAll();
// $this->myLogger->logme('error', "Employee Policy data count : " . count($employee_policy_data ?? []));
// $is_deleted = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Employee policy data removed successfully.");
// } else {
// $this->myLogger->logme('error', "Employee policy record does not exist. To delete");
// }
// }else{
// $this->myLogger->logme('error', "Employee policy data not found.");
// }
// } else {
// $this->myLogger->logme('error', "Client Policy record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "Client Policy data not found.");
// }
// // 6. Employee Model
// $employee_data = $this->employeeModel->where('client_id', $client_id)->findAll();
// $this->myLogger->logme('error', "Employee data count : " . count($employee_data ?? []));
// if (!empty($employee_data)) {
// $is_deleted = $this->employeeModel->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Employee data removed successfully.");
// } else {
// $this->myLogger->logme('error', "Employee record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "Employee data not found.");
// }
// // 7. Client Deposit Model
// $client_deposit_data = $this->clientDepositModel->where('client_id', $client_id)->findAll();
// $this->myLogger->logme('error', "Client Deposit data : " . json_encode($client_deposit_data ?? []));
// if (!empty($client_deposit_data)) {
// $is_deleted = $this->clientDepositModel->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Client Deposit data removed successfully.");
// } else {
// $this->myLogger->logme('error', "Client Deposit record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "Client Deposit data not found.");
// }
// // 8. Policy Premium 1 Model
// $policy_premium1_data = $this->policyPremium1Model->where('client_id', $client_id)->findAll();
// $this->myLogger->logme('error', "Policy Premium 1 data count : " . count($policy_premium1_data ?? []));
// if (!empty($policy_premium1_data)) {
// $is_deleted = $this->policyPremium1Model->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Policy Premium 1 data removed successfully.");
// } else {
// $this->myLogger->logme('error', "Policy Premium 1 record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "Policy Premium 1 data not found.");
// }
// // 9. Policy Premium 2 Model
// $policy_premium2_data = $this->policyPremium2Model->where('client_id', $client_id)->findAll();
// $this->myLogger->logme('error', "Policy Premium 2 data count: " . count($policy_premium2_data ?? []));
// if (!empty($policy_premium2_data)) {
// $is_deleted = $this->policyPremium2Model->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Policy Premium 2 data removed successfully.");
// } else {
// $this->myLogger->logme('error', "Policy Premium 2 record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "Policy Premium 2 data not found.");
// }
// // 10. Notification Model
// $notification_data = $this->notificationModel->where('client_id', $client_id)->findAll();
// $this->myLogger->logme('error', "Notification data : " . json_encode($notification_data ?? []));
// if (!empty($notification_data)) {
// $is_deleted = $this->notificationModel->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Notification data removed successfully.");
// } else {
// $this->myLogger->logme('error', "Notification record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "Notification data not found.");
// }
// // 11. CD Master Model
// $cd_master_data = $this->CDMasterModel->where('client_id', $client_id)->findAll();
// $this->myLogger->logme('error', "CD Master data : " . json_encode($cd_master_data ?? []));
// if (!empty($cd_master_data)) {
// $is_deleted = $this->CDMasterModel->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "CD Master data removed successfully.");
// } else {
// $this->myLogger->logme('error', "CD Master record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "CD Master data not found.");
// }
// // 12. Policy Transaction Model
// $policy_transaction_data = $this->policyTransactionModel->where('client_id', $client_id)->findAll();
// $this->myLogger->logme('error', "Policy Transaction data : " . json_encode($policy_transaction_data ?? []));
// $pt_ids = array_column($policy_transaction_data, 'id') ?? [];
// $this->myLogger->logme('error', "Policy Transaction id count : " . count($pt_ids ?? []));
// if (!empty($policy_transaction_data)) {
// $is_deleted = $this->policyTransactionModel->where('client_id', $client_id)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "Policy Transaction data removed successfully.");
// if(!empty($pt_ids)){
// $pt_co_share_data = $this->PTCOShareDetailsModel->whereIn('pt_id', $pt_ids)->findAll();
// $this->myLogger->logme('error', "PT CO Share data : " . json_encode($pt_co_share_data ?? []));
// $is_deleted = $this->PTCOShareDetailsModel->whereIn('pt_id', $pt_ids)->delete();
// if ($is_deleted) {
// $this->myLogger->logme('error', "PT CO Share data removed successfully.");
// } else {
// $this->myLogger->logme('error', "PT CO Share record does not exist. To delete");
// }
// }else{
// $this->myLogger->logme('error', "PT CO Share data not found.");
// }
// } else {
// $this->myLogger->logme('error', "Policy Transaction record does not exist. To delete");
// }
// } else {
// $this->myLogger->logme('error', "Policy Transaction data not found.");
// }
// $this->myLogger->logme('error', "Wipe Demo Client function closed");
// return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200);
// }
public function wipeDemoClient()
{
$this->myLogger->logme('error', "========================================");
$this->myLogger->logme('error', "WIPE DEMO CLIENT FUNCTION STARTED");
$this->myLogger->logme('error', "========================================");
$this->myLogger->logme('error', "Request Payload: " . json_encode($this->request->getPost() ?? []));
$client_id = $this->request->getPost('client_id');
if (empty($client_id)) {
$this->myLogger->logme('error', "ERROR: Client ID is required");
return $this->respond(['status' => false, 'message' => 'Client id required'], 404);
}
$this->myLogger->logme('error', "Client ID to wipe: " . $client_id);
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 1. CLIENT MODEL DELETION
// ========================================
$this->myLogger->logme('error', "1. PROCESSING CLIENT MODEL");
$client_data = $this->clientModel->where('id', $client_id)->where('is_active', 1)->first();
$this->myLogger->logme('error', " Found Client Data: " . json_encode($client_data ?? []));
if (!empty($client_data)) {
$is_deleted = $this->clientModel->where('id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete client record");
}
} else {
$this->myLogger->logme('error', " ✗ Client not found or inactive");
return $this->respond(['status' => false, 'message' => 'Client not found'], 404);
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 2. CLIENT RM MODEL DELETION
// ========================================
$this->myLogger->logme('error', "2. PROCESSING CLIENT RM MODEL");
$client_rm_data = $this->clientRMModel->where('client_id', $client_id)->first();
$this->myLogger->logme('error', " Found Client RM Data: " . json_encode($client_rm_data ?? []));
if (!empty($client_rm_data)) {
$is_deleted = $this->clientRMModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client RM data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Client RM record");
}
} else {
$this->myLogger->logme('error', " No Client RM data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 3. CLIENT KYC DOCS MODEL DELETION
// ========================================
$this->myLogger->logme('error', "3. PROCESSING CLIENT KYC DOCS MODEL");
$client_kyc_data = $this->clientKYCDocsModel->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Client KYC Records: " . count($client_kyc_data ?? []));
$this->myLogger->logme('error', " Client KYC Data: " . json_encode($client_kyc_data ?? []));
if (!empty($client_kyc_data)) {
$is_deleted = $this->clientKYCDocsModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client KYC Docs data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Client KYC Docs records");
}
} else {
$this->myLogger->logme('error', " No Client KYC Docs data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 4. CLIENT BRANCH MODEL DELETION
// ========================================
$this->myLogger->logme('error', "4. PROCESSING CLIENT BRANCH MODEL");
$client_branch_data = $this->clientBranchModel->where('client_id', $client_id)->findAll();
$branch_ids = array_column($client_branch_data, 'id') ?? [];
$this->myLogger->logme('error', " Found Client Branch Records: " . count($client_branch_data ?? []));
$this->myLogger->logme('error', " Branch IDs: " . json_encode($branch_ids));
$this->myLogger->logme('error', " Client Branch Data: " . json_encode($client_branch_data ?? []));
if (!empty($client_branch_data)) {
$is_deleted = $this->clientBranchModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client Branch data removed successfully");
// Delete related Level Contact data
if (!empty($branch_ids)) {
$this->myLogger->logme('error', " 4a. PROCESSING RELATED LEVEL CONTACT DATA");
$level_contact_data = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->findAll();
$this->myLogger->logme('error', " Found Level Contact Records: " . count($level_contact_data ?? []));
$this->myLogger->logme('error', " Level Contact Data: " . json_encode($level_contact_data ?? []));
$is_deleted = $this->levelContactModel->where('contact_type', 'client')->whereIn('ref_id', $branch_ids)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Level Contact data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Level Contact records");
}
} else {
$this->myLogger->logme('error', " No Branch IDs available for Level Contact deletion");
}
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Client Branch records");
}
} else {
$this->myLogger->logme('error', " No Client Branch data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 5. CLIENT POLICY MODEL DELETION
// ========================================
$this->myLogger->logme('error', "5. PROCESSING CLIENT POLICY MODEL");
$client_policy_data = $this->clientPolicyModel->where('client_id', $client_id)->findAll();
$policy_ids = array_column($client_policy_data, 'id') ?? [];
$this->myLogger->logme('error', " Found Client Policy Records: " . count($client_policy_data ?? []));
$this->myLogger->logme('error', " Policy IDs: " . json_encode($policy_ids));
$this->myLogger->logme('error', " Client Policy Data: " . json_encode($client_policy_data ?? []));
if (!empty($client_policy_data)) {
$is_deleted = $this->clientPolicyModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client Policy data removed successfully");
// Delete related Employee Policy data
if (!empty($policy_ids)) {
$this->myLogger->logme('error', " 5a. PROCESSING RELATED EMPLOYEE POLICY DATA");
$employee_policy_data = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->findAll();
$this->myLogger->logme('error', " Found Employee Policy Records: " . count($employee_policy_data ?? []));
$is_deleted = $this->employeePolicyModel->whereIn('client_policy_id', $policy_ids)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Employee Policy data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Employee Policy records");
}
} else {
$this->myLogger->logme('error', " No Policy IDs available for Employee Policy deletion");
}
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Client Policy records");
}
} else {
$this->myLogger->logme('error', " No Client Policy data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 6. EMPLOYEE MODEL DELETION
// ========================================
$this->myLogger->logme('error', "6. PROCESSING EMPLOYEE MODEL");
$employee_data = $this->employeeModel->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Employee Records: " . count($employee_data ?? []));
if (!empty($employee_data)) {
$is_deleted = $this->employeeModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Employee data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Employee records");
}
} else {
$this->myLogger->logme('error', " No Employee data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 7. CLIENT DEPOSIT MODEL DELETION
// ========================================
$this->myLogger->logme('error', "7. PROCESSING CLIENT DEPOSIT MODEL");
$client_deposit_data = $this->clientDepositModel->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Client Deposit Records: " . count($client_deposit_data ?? []));
$this->myLogger->logme('error', " Client Deposit Data: " . json_encode($client_deposit_data ?? []));
if (!empty($client_deposit_data)) {
$is_deleted = $this->clientDepositModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Client Deposit data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Client Deposit records");
}
} else {
$this->myLogger->logme('error', " No Client Deposit data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 8. POLICY PREMIUM 1 MODEL DELETION
// ========================================
$this->myLogger->logme('error', "8. PROCESSING POLICY PREMIUM 1 MODEL");
$policy_premium1_data = $this->policyPremium1Model->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Policy Premium 1 Records: " . count($policy_premium1_data ?? []));
if (!empty($policy_premium1_data)) {
$is_deleted = $this->policyPremium1Model->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Policy Premium 1 data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Policy Premium 1 records");
}
} else {
$this->myLogger->logme('error', " No Policy Premium 1 data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 9. POLICY PREMIUM 2 MODEL DELETION
// ========================================
$this->myLogger->logme('error', "9. PROCESSING POLICY PREMIUM 2 MODEL");
$policy_premium2_data = $this->policyPremium2Model->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Policy Premium 2 Records: " . count($policy_premium2_data ?? []));
if (!empty($policy_premium2_data)) {
$is_deleted = $this->policyPremium2Model->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Policy Premium 2 data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Policy Premium 2 records");
}
} else {
$this->myLogger->logme('error', " No Policy Premium 2 data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 10. NOTIFICATION MODEL DELETION
// ========================================
$this->myLogger->logme('error', "10. PROCESSING NOTIFICATION MODEL");
$notification_data = $this->notificationModel->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found Notification Records: " . count($notification_data ?? []));
$this->myLogger->logme('error', " Notification Data: " . json_encode($notification_data ?? []));
if (!empty($notification_data)) {
$is_deleted = $this->notificationModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Notification data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Notification records");
}
} else {
$this->myLogger->logme('error', " No Notification data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 11. CD MASTER MODEL DELETION
// ========================================
$this->myLogger->logme('error', "11. PROCESSING CD MASTER MODEL");
$cd_master_data = $this->CDMasterModel->where('client_id', $client_id)->findAll();
$this->myLogger->logme('error', " Found CD Master Records: " . count($cd_master_data ?? []));
$this->myLogger->logme('error', " CD Master Data: " . json_encode($cd_master_data ?? []));
if (!empty($cd_master_data)) {
$is_deleted = $this->CDMasterModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ CD Master data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete CD Master records");
}
} else {
$this->myLogger->logme('error', " No CD Master data found");
}
$this->myLogger->logme('error', "----------------------------------------");
// ========================================
// 12. POLICY TRANSACTION MODEL DELETION
// ========================================
$this->myLogger->logme('error', "12. PROCESSING POLICY TRANSACTION MODEL");
$policy_transaction_data = $this->policyTransactionModel->where('client_id', $client_id)->findAll();
$pt_ids = array_column($policy_transaction_data, 'id') ?? [];
$this->myLogger->logme('error', " Found Policy Transaction Records: " . count($policy_transaction_data ?? []));
$this->myLogger->logme('error', " Policy Transaction IDs: " . json_encode($pt_ids));
$this->myLogger->logme('error', " Policy Transaction Data: " . json_encode($policy_transaction_data ?? []));
if (!empty($policy_transaction_data)) {
$is_deleted = $this->policyTransactionModel->where('client_id', $client_id)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ Policy Transaction data removed successfully");
// Delete related PT CO Share data
if (!empty($pt_ids)) {
$this->myLogger->logme('error', " 12a. PROCESSING RELATED PT CO SHARE DATA");
$pt_co_share_data = $this->PTCOShareDetailsModel->whereIn('pt_id', $pt_ids)->findAll();
$this->myLogger->logme('error', " Found PT CO Share Records: " . count($pt_co_share_data ?? []));
$this->myLogger->logme('error', " PT CO Share Data: " . json_encode($pt_co_share_data ?? []));
$is_deleted = $this->PTCOShareDetailsModel->whereIn('pt_id', $pt_ids)->delete();
if ($is_deleted) {
$this->myLogger->logme('error', " ✓ PT CO Share data removed successfully");
} else {
$this->myLogger->logme('error', " ✗ Failed to delete PT CO Share records");
}
} else {
$this->myLogger->logme('error', " No Policy Transaction IDs available for PT CO Share deletion");
}
} else {
$this->myLogger->logme('error', " ✗ Failed to delete Policy Transaction records");
}
} else {
$this->myLogger->logme('error', " No Policy Transaction data found");
}
$this->myLogger->logme('error', "========================================");
$this->myLogger->logme('error', "WIPE DEMO CLIENT FUNCTION COMPLETED");
$this->myLogger->logme('error', "Client ID: " . $client_id . " - Successfully processed");
$this->myLogger->logme('error', "========================================");
return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200);
}
}

View File

@ -302,8 +302,9 @@ class EmployeeController extends AdminController
//for TPA/insurer upload
$data['events'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
//for inception upload
$data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement','enrollment' => 'Enrolment'];
$data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
// $data['actions'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement','enrollment' => 'Enrolment'];
$data['import_or_export'] = ['import' => 'Import', 'export' => 'Export'];
$data['insurer_or_tpa'] = ['insurer' => 'Insurer', 'tpa' => 'TPA'];

View File

@ -1319,6 +1319,7 @@ class EmployeeServiceController extends AdminController
//get file name
$file_id = $params['file_id'];
$file = $this->fileModel->find($file_id);
// dd($file);
$file_name_with_path = WRITEPATH."/uploads/excel/".$file['file_name'];
@ -1330,6 +1331,7 @@ class EmployeeServiceController extends AdminController
$excel_data = $sheet->rangeToArray('A1:' . $allowedHighestColumn['col_cell_name'] . $highestRowAndColumn['row']);
// $excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
// dd($excel_data);
unset($excel_data[0]);
// kint::dump($excel_data);
$endorsement_data = [];
@ -1379,10 +1381,14 @@ class EmployeeServiceController extends AdminController
->where('employee_polices.client_policy_id',$file['policy_id'])
->where('employees.emp_status !=','truncated')
->where('employees.is_active', 1)
->where('employee_polices.status !=','truncated')
->where('employee_polices.is_active', 1)
->first();
// $employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->first();
// dd($employee);
// kint::dump($employee);
if(is_array($employee) && count($employee))
{
// dd($employee);
@ -1406,7 +1412,13 @@ class EmployeeServiceController extends AdminController
if(!in_array($employee['id'],$endorsement_data))//make entry in endorsement firsttime only with checking that PK of emp exisintg in variable $endorsement_data
{
$employee_policy = $this->employeePolicyModel->where('employee_id',$employee['id'])->where('client_policy_id',$file['policy_id'])->first();
$employee_policy = $this->employeePolicyModel
->where('employee_id',$employee['id'])
->where('client_policy_id',$file['policy_id'])
->where('status !=','truncated')
->where('is_active', 1)
->first();
$data = ['emp_id' => $employee['id'],'name' => $employee['name'],'emp_status' => $employee['emp_status'],'emp_policy_id' => $employee_policy['id'],'emp_code' => $employee['emp_code'],'change_event' => $employee['change_event'],'date_of_exit' => $employee_policy['date_of_exit'],'reason_for_exit' => $employee_policy['reason_for_exit'],'status' => $employee_policy['status'],'claim_status' => $employee_policy['claim_status']];
$endorsement($data,$file,$row);
$endorsement_data[] = $employee['id'];
@ -1447,7 +1459,7 @@ class EmployeeServiceController extends AdminController
//set success msg to pull notifications
$this->setPullNotification($this->getFileMetaDataByFileId($file_id,'success'));
return $endorsement_data;
return $endorsement_data;
}

View File

@ -664,12 +664,18 @@ if(!function_exists('generate_insurer_based_excel')){
$rowData = [];
foreach ($excel_header_array as $header) {
$fieldName = $header['db_column_name'];
$defaultValue = isset($header['default_value']) ? $header['default_value'] : null;
if ($fieldName === 'index') {
$value = $serialNumber;
} else {
$value = $row->$fieldName ?? '';
if(empty($fieldName) && !empty($defaultValue)){
$value = $defaultValue;
}else{
$value = $row->$fieldName ?? '';
}
}
$rowData[] = $value;

View File

@ -40,6 +40,7 @@ class ClientModel extends Model
"reply_to",
"mail_domain",
"addon_subheading",
"parent_client_id",
];

View File

@ -1085,10 +1085,10 @@ class EmployeePolicyModel extends Model
}
$status_condition = "{$insurer_or_tpa}" === 'tpa'
? "employee_polices.status = 'inactive' AND employees.emp_status = 'active'"
? "employee_polices.status = 'active' AND employees.emp_status = 'active'"
: "employee_polices.status = 'active' AND employees.emp_status = 'active'";
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
$query = $this->db->query("
SELECT DISTINCT

View File

@ -1,4 +1,4 @@
<style>
<!-- <style>
body {
.multiselect-native-select {
position: relative;
@ -34,7 +34,197 @@ body {
table.dataTable tbody td {
padding: 4px 4px !important;
}
</style> -->
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
.multiselect-native-select {
position: relative;
}
.multiselect-native-select select {
border: 0 !important;
clip: rect(0 0 0 0) !important;
height: 1px !important;
margin: -1px -1px -1px -3px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important;
left: 50%;
top: 30px;
}
.multiselect-container {
width: 100% !important;
}
.multiselect-selected-text {
float: left !important;
}
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
/* Tooltip Styles */
.tooltip-trigger {
color: #007bff;
cursor: pointer;
font-size: 16px;
display: inline-block;
}
.tooltip-trigger:hover {
color: #0056b3;
}
.tooltip-container {
position: fixed;
top: 0;
left: 0;
pointer-events: none;
z-index: 9999;
}
.tooltip {
visibility: hidden;
opacity: 0;
position: absolute;
background-color: white;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
padding: 15px;
transition: opacity 0.3s, visibility 0.3s;
max-width: 600px;
min-width: 500px;
max-height: 600px; /* Limits height */
overflow-y: auto; /* Enables scrolling */
pointer-events: auto;
}
/* Optional: Custom scrollbar styling */
.tooltip::-webkit-scrollbar {
width: 8px;
}
.tooltip::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 4px;
}
.tooltip::-webkit-scrollbar-thumb {
background: #c1c1c1;
border-radius: 4px;
}
.tooltip::-webkit-scrollbar-thumb:hover {
background: #a8a8a8;
}
/* .tooltip {
visibility: hidden;
opacity: 0;
position: absolute;
background-color: white;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
padding: 15px;
transition: opacity 0.3s, visibility 0.3s;
max-width: 600px;
min-width: 500px;
pointer-events: auto;
} */
.tooltip::after {
content: "";
position: absolute;
border-width: 5px;
border-style: solid;
}
.tooltip.show {
visibility: visible;
opacity: 1;
}
.tooltip-table {
width: 100%;
border-collapse: collapse;
font-size: 12px;
margin: 0;
}
.tooltip-table th {
background-color: #f8f9fa;
font-weight: bold;
padding: 8px;
border: 1px solid #dee2e6;
text-align: left;
font-size: 11px;
}
.tooltip-table td {
padding: 6px 8px;
border: 1px solid #dee2e6;
vertical-align: top;
font-size: 11px;
line-height: 1.3;
}
.tooltip-table tbody tr:nth-child(even) {
background-color: #f8f9fa;
}
.tooltip-table tbody tr:hover {
background-color: #e3f2fd;
}
.team-cell {
font-weight: bold;
background-color: #e7f3ff !important;
}
/* Form styling for demo */
.form-group {
margin-bottom: 1rem;
}
.form-control {
display: block;
width: 100%;
padding: 0.375rem 0.75rem;
font-size: 1rem;
line-height: 1.5;
color: #495057;
background-color: #fff;
border: 1px solid #ced4da;
border-radius: 0.25rem;
}
label {
display: inline-block;
margin-bottom: 0.5rem;
font-weight: 600;
}
.text-danger {
color: #dc3545;
}
</style>
<!-- End ADD and EDIT Page HTML -->
<div class="row" id="List-page">
<div class="col-12">
@ -96,7 +286,7 @@ table.dataTable tbody td {
<!-- modal content -->
<div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -142,7 +332,9 @@ table.dataTable tbody td {
<div class="form-row">
<div class="form-group col-md-12">
<label for="emp_code">User Role<span class="text-danger">*</span></label>
<label for="emp_code">User Role<span class="text-danger">*</span>
<span class="tooltip-trigger fa fa-info-circle" id="roleAccessMatrixTrigger"></span>
</label>
<select class="form-control" id="role" name="role" required>
<option value="">Select Role</option>
<?php foreach($roleData as $value) { ?>
@ -153,7 +345,9 @@ table.dataTable tbody td {
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="profile">User Team<span class="text-danger">*</span></label>
<label for="profile">User Team<span class="text-danger">*</span>
<span class="tooltip-trigger fa fa-info-circle" id="accessMatrixTrigger"></span>
</label>
<select hidden class="form-control" id="team" name="team[]" multiple required>
<?php foreach($teamData as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['name'] ?></option>
@ -175,145 +369,449 @@ table.dataTable tbody td {
</div>
</div><!-- /.modal -->
<!-- Tooltip container separate from trigger -->
<div class="tooltip-container" id="tooltipContainer">
<div class="tooltip" id="accessMatrixTooltip">
<table class="tooltip-table">
<thead>
<tr>
<th>Team</th>
<th>Module</th>
<th>Access Rights</th>
</tr>
</thead>
<tbody>
<tr>
<td class="team-cell">Management</td>
<td>BDS - All access</td>
<td>All access</td>
</tr>
<tr>
<td class="team-cell" rowspan="5">Finance</td>
<td>BDS - Policy Transaction</td>
<td>Policy | Endorsement | Statement Upload</td>
</tr>
<tr>
<td>BDS - Report</td>
<td>TAT wise | ACM Status wise | ACM TAT wise</td>
</tr>
<tr>
<td>BDS - Pending Actions</td>
<td>Finance Team</td>
</tr>
<tr>
<td>BDS - Masters</td>
<td>Vehicle | CD</td>
</tr>
<tr>
<td>BDS - Documents</td>
<td></td>
</tr>
<tr>
<td class="team-cell" rowspan="5">Business</td>
<td>BDS - Policy Transaction</td>
<td>Policy | Endorsement</td>
</tr>
<tr>
<td>BDS - Report</td>
<td>TAT wise | ACM Status wise | ACM TAT wise</td>
</tr>
<tr>
<td>BDS - Pending Actions</td>
<td>Business Team</td>
</tr>
<tr>
<td>BDS - Masters</td>
<td>Vehicle | CD</td>
</tr>
<tr>
<td>BDS - Documents</td>
<td></td>
</tr>
<tr>
<td class="team-cell" rowspan="2">POS</td>
<td>BDS - Policy Transaction</td>
<td>Policy | Endorsement</td>
</tr>
<tr>
<td>BDS - Report</td>
<td>BDS, TAT wise | ACM Status wise | ACM TAT wise</td>
</tr>
<tr>
<td class="team-cell">Enrollment</td>
<td>Inception File Upload</td>
<td>All access</td>
</tr>
<tr>
<td class="team-cell">Claims</td>
<td>Claims</td>
<td>All access</td>
</tr>
<tr>
<td class="team-cell">Sales</td>
<td>LEAD</td>
<td>Lead creation | RFQ creation</td>
</tr>
<tr>
<td class="team-cell">Business Support</td>
<td>LEAD</td>
<td>All access</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="tooltip-container" id="roleTooltipContainer">
<div class="tooltip" id="roleAccessMatrixTooltip">
<table class="tooltip-table">
<thead>
<tr>
<th>Team</th>
<th>Module</th>
<th>Access Rights</th>
</tr>
</thead>
<tbody>
<tr>
<td class="team-cell">Head</td>
<td>All modules</td>
<td>All access</td>
</tr>
<tr>
<td class="team-cell">Admin</td>
<td>All modules</td>
<td>All access</td>
</tr>
<tr>
<td class="team-cell">Manager</td>
<td>Access to all modules except the "Masters" module</td>
<td>All access</td>
</tr>
<tr>
<td class="team-cell">Account Manager</td>
<td>Access to all modules except the "Masters" module</td>
<td>All access without "Delete option"</td>
</tr>
<tr>
<td class="team-cell">Staff</td>
<td>Based on the "Teams"</td>
<td>Based on the "Teams"</td>
</tr>
</tbody>
</table>
</div>
</div>
<script>
$(document).ready(function () {
$(document).ready(function () {
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + // Keep your original alignment for the search and buttons
"<'row'<'col-sm-12'tr>>" + // Table rows
"<'row'<'col-sm-6'i><'col-sm-6'p>>",
buttons: [
{
extend: 'csv',
text: 'CSV',
title: 'UserList',
exportOptions: {
columns: ':not(:last-child)'
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + // Keep your original alignment for the search and buttons
"<'row'<'col-sm-12'tr>>" + // Table rows
"<'row'<'col-sm-6'i><'col-sm-6'p>>",
buttons: [
{
extend: 'csv',
text: 'CSV',
title: 'UserList',
exportOptions: {
columns: ':not(:last-child)'
}
}
}
],
],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
});
$('#team').multiselect({
nonSelectedText: 'Select Team',
enableFiltering: false,
enableCaseInsensitiveFiltering: false,
includeSelectAllOption : false,
buttonWidth:'100%'
});
$('#btnAdd').click(function(){
$('#first_name').val('');
$('#last_name').val('');
$('#email').val('');
$('#mobile').val('');
$('#emp_code').val('');
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
})
$('.close').click(function(){
$('#UserId').val('');
$('#first_name').val('');
$('#email').val('');
$('#mobile').val('');
$('#emp_code').val('');
$('#role').val('')
})
$('body').on('click', '.btnEdit', function () {
var user_id = $(this).attr('data-id');
$.ajax({
url: '<?php echo base_url('user/getuser/');?>'+user_id,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res)
$('#updateModal').modal('show');
$('#role').val('')
$('#UserForm').attr('action', '<?php echo base_url('user/edit');?>');
$('#UserId').val(res.data.id);
$('#first_name').val(res.data.first_name);
$('#last_name').val(res.data.last_name);
$('#email').val(res.data.email);
$('#mobile').val(res.data.mobile);
$('#emp_code').val(res.data.emp_code);
$('#role option[value="' + res.data.role + '"]').prop('selected', true);
$('#btnSubmit').html('Update');
$.each(res.userTeamData, function(index, item) {
$('#team option[value="' + item.team_id + '"]').prop('selected', true);
$('#team').multiselect('refresh');
});
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
error: function (xhr, status, error) {
console.error("Error Details:");
console.error("Status Code:", xhr.status);
console.error("Status Text:", xhr.statusText);
console.error("Response Text:", xhr.responseText);
console.error("Ready State:", xhr.readyState);
console.error("Response Headers:", xhr.getAllResponseHeaders());
console.error("Error Thrown:", error);
console.error("Status:", status);
}
});
$('#team').multiselect({
nonSelectedText: 'Select Team',
enableFiltering: false,
enableCaseInsensitiveFiltering: false,
includeSelectAllOption : false,
buttonWidth:'100%'
});
});
$('body').on('click', '.btnDelete', function () {
Swal.fire({
title: "Are you sure?",
text: "You need to remove this user",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
var student_id = $(this).attr('data-id');
$.get('<?php echo base_url('user/deactive/');?>'+student_id, function (data) {
console.log(data);
toastr.success('User removed successfully', 'success');
window.location.reload()
})
}
$('#btnAdd').click(function(){
$('#first_name').val('');
$('#last_name').val('');
$('#email').val('');
$('#mobile').val('');
$('#emp_code').val('');
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
})
$('.close').click(function(){
$('#UserId').val('');
$('#first_name').val('');
$('#email').val('');
$('#mobile').val('');
$('#emp_code').val('');
$('#role').val('')
})
$('body').on('click', '.btnEdit', function () {
var user_id = $(this).attr('data-id');
$.ajax({
url: '<?php echo base_url('user/getuser/');?>'+user_id,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res)
$('#updateModal').modal('show');
$('#role').val('')
$('#UserForm').attr('action', '<?php echo base_url('user/edit');?>');
$('#UserId').val(res.data.id);
$('#first_name').val(res.data.first_name);
$('#last_name').val(res.data.last_name);
$('#email').val(res.data.email);
$('#mobile').val(res.data.mobile);
$('#emp_code').val(res.data.emp_code);
$('#role option[value="' + res.data.role + '"]').prop('selected', true);
$('#btnSubmit').html('Update');
$.each(res.userTeamData, function(index, item) {
$('#team option[value="' + item.team_id + '"]').prop('selected', true);
$('#team').multiselect('refresh');
});
},
error: function (xhr, status, error) {
console.error("Error Details:");
console.error("Status Code:", xhr.status);
console.error("Status Text:", xhr.statusText);
console.error("Response Text:", xhr.responseText);
console.error("Ready State:", xhr.readyState);
console.error("Response Headers:", xhr.getAllResponseHeaders());
console.error("Error Thrown:", error);
console.error("Status:", status);
}
});
});
});
$('body').on('click', '.btnDelete', function () {
Swal.fire({
title: "Are you sure?",
text: "You need to remove this user",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
});
var student_id = $(this).attr('data-id');
$.get('<?php echo base_url('user/deactive/');?>'+student_id, function (data) {
console.log(data);
toastr.success('User removed successfully', 'success');
window.location.reload()
})
}
});
});
function onlyNumbers(event){
var charcode;
charcode = event.which || event.keyCode;
if(charcode>= 48 && charcode <= 57)return true;
return false;
}
});
var form = document.getElementById("UserForm");
function onlyNumbers(event){
var charcode;
charcode = event.which || event.keyCode;
if(charcode>= 48 && charcode <= 57)return true;
return false;
}
// Add submit event listener to the form
form.addEventListener("submit", function(event) {
// Disable the submit button to avoid multiple submissions
// document.getElementById("btnSubmit").disabled = true;
});
var form = document.getElementById("UserForm");
// Add submit event listener to the form
form.addEventListener("submit", function(event) {
// Disable the submit button to avoid multiple submissions
// document.getElementById("btnSubmit").disabled = true;
});
</script>
<script>
function initializeTooltip() {
const trigger = document.getElementById('accessMatrixTrigger');
console.log(trigger);
const tooltip = document.getElementById('accessMatrixTooltip');
console.log(tooltip);
const tooltipContainer = document.getElementById('tooltipContainer');
console.log(tooltipContainer);
if (!trigger || !tooltip || !tooltipContainer) {
console.error('Tooltip elements not found');
return;
}
function positionTooltip(event) {
const triggerRect = trigger.getBoundingClientRect();
const tooltipRect = tooltip.getBoundingClientRect();
const viewportWidth = window.innerWidth;
const viewportHeight = window.innerHeight;
let left = triggerRect.right + 10; // 10px to the right of trigger
let top = triggerRect.top;
// Check if tooltip goes off-screen to the right
if (left + tooltipRect.width > viewportWidth) {
left = triggerRect.left - tooltipRect.width - 10; // Show to the left instead
}
// Check if tooltip goes off-screen at the bottom
if (top + tooltipRect.height > viewportHeight) {
top = viewportHeight - tooltipRect.height - 10;
}
// Ensure tooltip doesn't go above viewport
if (top < 10) {
top = 10;
}
tooltipContainer.style.left = left + 'px';
tooltipContainer.style.top = top + 'px';
// Position arrow
const arrow = tooltip.querySelector('::after');
if (left < triggerRect.left) {
// Tooltip is to the left, arrow should point right
tooltip.style.setProperty('--arrow-position', 'right');
} else {
// Tooltip is to the right, arrow should point left
tooltip.style.setProperty('--arrow-position', 'left');
}
}
// Show tooltip on hover
trigger.addEventListener('mouseenter', function(event) {
positionTooltip(event);
tooltip.classList.add('show');
});
// Hide tooltip when mouse leaves trigger
trigger.addEventListener('mouseleave', function() {
tooltip.classList.remove('show');
});
// Keep tooltip visible when hovering over the tooltip itself
tooltip.addEventListener('mouseenter', function() {
tooltip.classList.add('show');
});
tooltip.addEventListener('mouseleave', function() {
tooltip.classList.remove('show');
});
// Reposition on window resize
window.addEventListener('resize', function() {
if (tooltip.classList.contains('show')) {
positionTooltip();
}
});
}
function initializeRoleTooltip() {
const trigger = document.getElementById('roleAccessMatrixTrigger');
console.log(trigger);
const tooltip = document.getElementById('roleAccessMatrixTooltip');
console.log(tooltip);
const tooltipContainer = document.getElementById('roleTooltipContainer');
console.log(tooltipContainer);
if (!trigger || !tooltip || !tooltipContainer) {
console.error('Tooltip elements not found');
return;
}
function positionTooltip(event) {
const triggerRect = trigger.getBoundingClientRect();
const tooltipRect = tooltip.getBoundingClientRect();
const viewportWidth = window.innerWidth;
const viewportHeight = window.innerHeight;
let left = triggerRect.right + 10; // 10px to the right of trigger
let top = triggerRect.top;
// Check if tooltip goes off-screen to the right
if (left + tooltipRect.width > viewportWidth) {
left = triggerRect.left - tooltipRect.width - 10; // Show to the left instead
}
// Check if tooltip goes off-screen at the bottom
if (top + tooltipRect.height > viewportHeight) {
top = viewportHeight - tooltipRect.height - 10;
}
// Ensure tooltip doesn't go above viewport
if (top < 10) {
top = 10;
}
tooltipContainer.style.left = left + 'px';
tooltipContainer.style.top = top + 'px';
// Position arrow
const arrow = tooltip.querySelector('::after');
if (left < triggerRect.left) {
// Tooltip is to the left, arrow should point right
tooltip.style.setProperty('--arrow-position', 'right');
} else {
// Tooltip is to the right, arrow should point left
tooltip.style.setProperty('--arrow-position', 'left');
}
}
// Show tooltip on hover
trigger.addEventListener('mouseenter', function(event) {
positionTooltip(event);
tooltip.classList.add('show');
});
// Hide tooltip when mouse leaves trigger
trigger.addEventListener('mouseleave', function() {
tooltip.classList.remove('show');
});
// Keep tooltip visible when hovering over the tooltip itself
tooltip.addEventListener('mouseenter', function() {
tooltip.classList.add('show');
});
tooltip.addEventListener('mouseleave', function() {
tooltip.classList.remove('show');
});
// Reposition on window resize
window.addEventListener('resize', function() {
if (tooltip.classList.contains('show')) {
positionTooltip();
}
});
}
// Initialize when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeTooltip);
document.addEventListener('DOMContentLoaded', initializeRoleTooltip);
} else {
initializeTooltip();
initializeRoleTooltip();
}
</script>

View File

@ -111,6 +111,17 @@ input:checked + .slider:before {
<label for="gst">GST<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" value="<?= isset($client['gst']) ? $client['gst'] : '' ?>" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
</div> -->
<div class="form-group col-md-4">
<label for="parent_client_id">Parent Group<span class="text-danger">*</span></label>
<select class="form-control" id="parent_client_id" name="parent_client_id">
<option value="" >Select Parent</option>
<?php foreach($clients as $value) { ?>
<option value="<?= $value['id'] ?>" <?= isset($client['parent_client_id']) && $client['parent_client_id'] == $value['id'] ? "selected" : '' ?>><?= $value['client_name'] ?></option>
<?php } ?>
</select>
</div>
</div>
<hr>
</div>
@ -171,9 +182,10 @@ input:checked + .slider:before {
var form_action = '';
$(document).ready(function() {
$('#client_logo').change(function() {
validateFile(this);
});
$('#client_logo').change(function() {
validateFile(this);
});
$('#parent_client_id').select2();
});
$(document).ready(function () {

View File

@ -93,7 +93,7 @@ table.dataTable thead th {
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="<?= base_url("client/list/"); ?><?= $row->id;?>"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" href="<?= base_url("client/deposit/{$row->id}"); ?>"><i class="mdi mdi-cash mr-2 text-muted font-18 vertical-middle"></i>CD Transactions</a>
<?php if(get_role_id() != 3 && get_role_id() != 4) { ?>
<?php if(in_array(get_role_id(), [1, 5])) { ?>
<a class="dropdown-item" data-id="<?= $row->id;?>" onclick="removeClient(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>
</div>
@ -316,39 +316,105 @@ $(document).ready(function()
});
})
//DO NOT REMOVE THIS FUNCTION >>> THI FUNCTION FOR CLIENT SOFT DELETE
// function removeClient(element)
// {
// Swal.fire({
// title: "Are you sure?",
// text: "You need to remove this client.",
// icon: "info",
// showCancelButton: true,
// confirmButtonColor: "#3085d6",
// confirmButtonText: "Yes",
// }).then((result) => {
// if (result.isConfirmed) {
// $('.loader').fadeIn();
// $('.loader-mask').fadeIn();
// var id = element.getAttribute('data-id');
// var form_action = '<?= base_url("client/remove/") ?>' + id;
// $.ajax({
// url: form_action,
// type: "GET",
// dataType: 'json',
// processData: false,
// contentType: false,
// success: function(res) {
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// if(res){
// if (res.status == true) {
// toastr.success('Client removed successfully.', 'success');
// location.reload();
// } else {
// Swal.fire({
// title: "warning!",
// text: res.message,
// icon: "warning"
// });
// // toastr.warning(res.message, 'warning');
// }
// }
// },
// error: function (xhr, status, error) {
// console.error(xhr.responseText);
// console.error(status, error);
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// console.log('Something Wrong!', 'warning');
// }
// });
// }
// });
// }
function removeClient(element)
{
{
console.log("Remove client function called")
console.log('element', element);
Swal.fire({
title: "Are you sure?",
text: "You need to remove this client.",
icon: "info",
html: `Is this a Demo Client?, Please reconfirm by clicking Yes to delete. <br> <span style = "color : red; font-size : 14px;">Note : This data will be deleted permanently and cannot be recovered.</span>`,
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
console.log('Print the result : ', result)
if (result.isConfirmed) {
console.log('Click Yes : ', result.isConfirmed);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("client/remove/") ?>' + id;
console.log('client_id', id);
var form_action = '<?= base_url("/client/wipe") ?>';
console.log('URL : ', form_action);
$.ajax({
url: form_action,
type: "GET",
type: "POST",
data: {client_id : id},
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log('Client remove function response : ', res);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res){
if (res.status == true) {
toastr.success('Client removed successfully.', 'success');
toastr.success(res.message, 'success');
location.reload();
} else {
Swal.fire({
@ -358,7 +424,6 @@ function removeClient(element)
});
// toastr.warning(res.message, 'warning');
}
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
@ -371,7 +436,6 @@ function removeClient(element)
}
});
}
$(document).on('click', '.client_info', function() {

View File

@ -471,13 +471,14 @@
const newRow = document.createElement('div');
newRow.className = 'form-row dynamic-form-row';
newRow.innerHTML = `
<div class="form-group col-md-5">
<div class="form-group col-md-4">
<label for="excel_column_name">Header Name<span class="text-danger">*</span></label>
<input id="excel_column_name" value="${data !== null && data !== undefined && data !== '' ? data.column_name : ''}" class="form-control" type="text" name="excel_column_name[]" placeholder="Excel Header Column Name">
</div>
<div class="form-group col-md-5">
<div class="form-group col-md-3">
<label for="db_column_name">DataBase Column Name<span class="text-danger"></span></label>
<select class="form-control db-column-name-select" name="db_column_name[]" onchange="checkForDuplicates(this)">
<select class="form-control db-column-name-select dbColumn" name="db_column_name[]" onchange="checkForDuplicates(this)" ${data !== null && data !== undefined && data !== '' && data.default_value != "" && data.default_value != null ? 'disabled' : ''}>
<option value="" selected >Select</option>
<?php if (!empty($db_column_name)){ ?>
<?php foreach ($db_column_name as $key => $value) { ?>
@ -486,17 +487,25 @@
<?php } ?>
</select>
</div>
<div class="form-group col-md-3">
<label for="default_value">Default Value<span class="text-danger"></span></label>
<input id="default_value" value="${data != null && data != undefined && data != '' && data.default_value != "" && data.default_value != null ? data.default_value : ''}" class="form-control" type="text" name="default_value[]" placeholder="Excel Default value">
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(this)">+</a>
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
</div>
`;
container.appendChild(newRow);
if (data !== null && data.db_column_name !== undefined) {
if (data != null && data.db_column_name != undefined) {
const selectElement = newRow.querySelector('.db-column-name-select');
selectElement.value = data.db_column_name;
$('.dbColumn').select2();
}
$('.dbColumn').select2();
}
// function removeHTMLInput(element)
@ -523,6 +532,7 @@
try {
var columnNames = $('input[name="excel_column_name[]"]');
var defaultValues = $('input[name="default_value[]"]');
var dbColumnNames = $('select[name="db_column_name[]"]');
// Check if both arrays are of the same length
@ -534,6 +544,7 @@
columnNames.each(function(index) {
var columnName = $(this).val();
var dbColumnName = dbColumnNames.eq(index).val() ?? null;
var defaultValue = defaultValues.eq(index).val() ?? null;
// if (!columnName) {
// throw new Error(`Column name at index ${index} is empty.`);
@ -545,7 +556,8 @@
var columnObj = {
'column_index': index,
'column_name': columnName,
'db_column_name': dbColumnName
'db_column_name': dbColumnName,
'default_value': defaultValue
};
formArray.push(columnObj);
});
@ -695,4 +707,17 @@
});
}
$(document).on('input', 'input[name="default_value[]"]', function () {
let $defaultInput = $(this);
let $row = $defaultInput.closest('.form-row, .row'); // Adjust based on your actual container
let $dbSelect = $row.find('select[name="db_column_name[]"]');
if ($defaultInput.val().trim() !== '') {
$dbSelect.val('').trigger('change').prop('disabled', true);
} else {
$dbSelect.prop('disabled', false);
}
});
</script>

View File

@ -209,9 +209,11 @@ table.dataTable tbody td {
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>RFQ
</a>
<?php if(!in_array($row['status'], ['queued', 'rfq_created', 'rfq_sent'])) { ?>
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 2; ?>" class="dropdown-item btnEdit3" data-id="<?= $row['id']; ?>">
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>QCR
</a>
<?php if(in_array(get_role_id(), [1, 5, 2, 3]) || in_array(BUSINESS_SUPPORT_TEAM_ID, user_team()) ) { ?>
<a href="<?= base_url('/rfq/list/').$row['id'] . '/' . 2; ?>" class="dropdown-item btnEdit3" data-id="<?= $row['id']; ?>">
<i class="mdi mdi-note-text mr-2 text-muted font-18 vertical-middle"></i>QCR
</a>
<?php } ?>
<?php } ?>
</div>
</div>