Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
vadivelJ96 2025-10-15 17:31:07 +05:30
commit 21e7359c12
26 changed files with 4266 additions and 2721 deletions

View File

@ -396,6 +396,9 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->post('savePlacementDataAndValidateMemberDataFile', 'LeadsController::savePlacementDataAndValidateMemberDataFile'); $routes->post('savePlacementDataAndValidateMemberDataFile', 'LeadsController::savePlacementDataAndValidateMemberDataFile');
$routes->get('checkMemberDataFileValidationStatus', 'LeadsController::checkMemberDataFileValidationStatus'); $routes->get('checkMemberDataFileValidationStatus', 'LeadsController::checkMemberDataFileValidationStatus');
$routes->match(['get', 'post', 'delete'], 'nhanceBranchMaster', 'MasterController::nhanceBranchMaster'); $routes->match(['get', 'post', 'delete'], 'nhanceBranchMaster', 'MasterController::nhanceBranchMaster');
$routes->match(['get', 'post', 'delete'], 'vehicleTypeMaster', 'MasterController::vehicleTypeMaster');
$routes->match(['get', 'post', 'delete'], 'rtoMaster', 'MasterController::rtoMaster');
}); });

View File

@ -518,8 +518,8 @@ class ClientController extends AdminController
public function updateEmpAndPolicyStatus() public function updateEmpAndPolicyStatus()
{ {
$return = $this->clientPolicyModel->updateStatus(); $return = $this->clientPolicyModel->updateStatus();
return $return;
$this->myLogger->logme('error', 'Client Policy Status Update Count: {data}', ['data' => $return['client']]); $this->myLogger->logme('error', 'Client Policy Status Update Count: {data}', ['data' => $return['client']]);
$this->myLogger->logme('error', 'Employee Policy Status Update Count: {data}', ['data' => $return['emp']]); $this->myLogger->logme('error', 'Employee Policy Status Update Count: {data}', ['data' => $return['emp']]);
} }
@ -1613,7 +1613,7 @@ class ClientController extends AdminController
if ($update) { if ($update) {
$policy_transaction_update = $this->deactivatePolicyTransactionsPolicy($id); // $policy_transaction_update = $this->deactivatePolicyTransactionsPolicy($id);
return $this->respond(['status' => true, 'code' => 200], 200); return $this->respond(['status' => true, 'code' => 200], 200);
} else { } else {
@ -4816,6 +4816,7 @@ class ClientController extends AdminController
'vehicle_no' => $data['vehicle_no'], 'vehicle_no' => $data['vehicle_no'],
'type' => $data['type'], 'type' => $data['type'],
'rc' => $data['rc'], 'rc' => $data['rc'],
'rto_id' => $data['rto_id'],
'branch_id' => $branch_insert, 'branch_id' => $branch_insert,
'owner' => $client_insert, 'owner' => $client_insert,
]; ];
@ -4861,6 +4862,7 @@ class ClientController extends AdminController
'vehicle_no' => $data['vehicle_no'], 'vehicle_no' => $data['vehicle_no'],
'type' => $data['type'], 'type' => $data['type'],
'rc' => $data['rc'], 'rc' => $data['rc'],
'rto_id' => $data['rto_id'],
'branch_id' => $data['branch_id'] ?? null, 'branch_id' => $data['branch_id'] ?? null,
'owner' => $data['owner'], 'owner' => $data['owner'],
]; ];
@ -5064,10 +5066,12 @@ class ClientController extends AdminController
->where('policy_no', $policy_no) ->where('policy_no', $policy_no)
->countAllResults(); ->countAllResults();
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('policy_status', 1)->where('policy_no', trim($policy_no))->first();
if ($data > 0) { if ($data > 0) {
return $this->respond(['status' => true, 'message' => 'This policy number is already linked to another client', 'data' => $data, 'code' => 409, 'received_data' => $received_data], 200); return $this->respond(['status' => true, 'message' => 'This policy number is already linked to another client', 'data' => $data, 'code' => 409, 'received_data' => $received_data, 'client_policy_id' => $client_policy_data['id'] ?? null], 200);
} else { } else {
return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200); return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data, 'client_policy_id' => $client_policy_data['id'] ?? null], 200);
} }
} }

View File

@ -225,20 +225,23 @@ class DashboardController extends AdminController
$pendingActionsController = new PendingActionsController; $pendingActionsController = new PendingActionsController;
$pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard(); $pendingActionsData = $pendingActionsController->getPendingActionsForDashBoard();
$businessTeamData = $this->policyTransactionModel->getBusinessReportList();
$financeTeamData = $this->policyTransactionModel->getFinanceReportList();
$businessTeamStatusData = $this->data_construct_for_bds($businessTeamData);
$financeTeamStatusData = $this->data_construct_for_bds($financeTeamData);
//BDS dashboard data
// $businessTeamData = $this->policyTransactionModel->getBusinessReportList();
// $financeTeamData = $this->policyTransactionModel->getFinanceReportList();
// $businessTeamStatusData = $this->data_construct_for_bds($businessTeamData);
// $financeTeamStatusData = $this->data_construct_for_bds($financeTeamData);
$businessTeamData = [];
$financeTeamData = [];
$businessTeamStatusData = [];
$financeTeamStatusData = [];
$data['client_branch_emp_list'] = $results; $data['client_branch_emp_list'] = $results;
$session = \Config\Services::session(); $session = \Config\Services::session();
$session->set('enrollment_data', json_encode($data)); $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;
// dd($businessTeamData);
$data['financeTeamCount'] = count($financeTeamData) ?? 0; $data['financeTeamCount'] = count($financeTeamData) ?? 0;
$data['businessTeamStatusData'] = $businessTeamStatusData; $data['businessTeamStatusData'] = $businessTeamStatusData;
$data['financeTeamStatusData'] = $financeTeamStatusData; $data['financeTeamStatusData'] = $financeTeamStatusData;

View File

@ -35,7 +35,7 @@ use App\Controllers\JobWorker;
use App\Controllers\Jobs\SubJob; use App\Controllers\Jobs\SubJob;
use App\Controllers\EmployeeServiceController; use App\Controllers\EmployeeServiceController;
use App\Controllers\EmpDataServiceController; use App\Controllers\EmpDataServiceController;
use App\Models\ThzMasterModel;
use CodeIgniter\API\ResponseTrait; use CodeIgniter\API\ResponseTrait;
use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Spreadsheet;
@ -1471,6 +1471,7 @@ class EmployeeController extends AdminController
$template_data_path = WRITEPATH . 'e_card_template/'; $template_data_path = WRITEPATH . 'e_card_template/';
// $tpa_short_name = strtolower(str_replace(' ', '_', $get_emp_code_and_client_policy_id['short_name'])) . '.html'; // $tpa_short_name = strtolower(str_replace(' ', '_', $get_emp_code_and_client_policy_id['short_name'])) . '.html';
$tpa_short_name = 'common.html'; $tpa_short_name = 'common.html';
// $tpa_short_name = 'new_ecard.html';
$final_path = $template_data_path . $tpa_short_name; $final_path = $template_data_path . $tpa_short_name;
$this->myLogger->logme('error', 'Checking if template file exists at: ' . $final_path); $this->myLogger->logme('error', 'Checking if template file exists at: ' . $final_path);
@ -1523,10 +1524,12 @@ class EmployeeController extends AdminController
'{QR_IOS}' => base_url() . 'public/e_card_imgs/ios.png', '{QR_IOS}' => base_url() . 'public/e_card_imgs/ios.png',
'{QR_ANDROID_2}' => base_url() . 'public/e_card_imgs/play_store.png', '{QR_ANDROID_2}' => base_url() . 'public/e_card_imgs/play_store.png',
'{QR_IOS_2}' => base_url() . 'public/e_card_imgs/appstore.png', '{QR_IOS_2}' => base_url() . 'public/e_card_imgs/appstore.png',
'{NHANCE_N_LOGO}' => base_url() . 'public/assets/images/Nhance_Favi.png',
]; ];
$placeholders['{LEVELS}'] = $this->generateAcmAndMForEcard($client_id); $placeholders['{LEVELS}'] = $this->generateAcmAndMForEcard($client_id);
$placeholders['{NETWORK_HOSPITAL}'] = $this->generateNetworkHospitalsForEcard($value['network_hospitals']);
foreach ($placeholders as $placeholder => $replaceValue) { foreach ($placeholders as $placeholder => $replaceValue) {
$htmlContent = str_replace($placeholder, $replaceValue, $htmlContent); $htmlContent = str_replace($placeholder, $replaceValue, $htmlContent);
} }
@ -1534,13 +1537,23 @@ class EmployeeController extends AdminController
$html .= $htmlContent; $html .= $htmlContent;
} }
// return $html;
// DomPdf // DomPdf
$options = new Options(); $options = new Options();
$options->set('isRemoteEnabled', true); $options->set('isRemoteEnabled', true);
$options->set('isHtml5ParserEnabled', true); $options->set('isHtml5ParserEnabled', true);
$dompdf = new Dompdf($options); $dompdf = new Dompdf($options);
$dompdf->loadHtml('<style>@page { margin: 0; }</style>' . $html); // remove the margin // $dompdf->loadHtml('<style>@page { margin: 0; }</style>' . $html); // remove the margin
$dompdf->loadHtml('
<style>
@page { margin: 0; }
@import url("https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap");
body { font-family: "Lato", sans-serif !important; }
</style>
' . $html
);
$dompdf->setPaper('A4', 'portrait'); $dompdf->setPaper('A4', 'portrait');
$dompdf->render(); $dompdf->render();
@ -2939,20 +2952,43 @@ class EmployeeController extends AdminController
// Generate the HTML content // Generate the HTML content
$html = ''; $html = '';
$level_index = 1;
foreach ($levels as $level => $contacts) { foreach ($levels as $level => $contacts) {
$displayLevel = $level == 3 ? 1 : 2; // Switch levels for display $displayLevel = $level == 3 ? 1 : 2; // Switch levels for display
$html .= '<br>Level ' . $displayLevel . '<br>'; if($level_index == 1){
$html .= 'Level ' . $displayLevel . '<br>';
}else{
$html .= '<br> Level ' . $displayLevel . '<br>';
}
foreach ($contacts as $index => $contact) { foreach ($contacts as $index => $contact) {
$html .= ($index + 1) . '. ' . $contact['first_name'] . ' / ' . $contact['mobile'] . ' / ' . $contact['email'] . '<br>'; $html .= ($index + 1) . '. ' . $contact['first_name'] . ' / ' . $contact['mobile'] . ' / ' . $contact['email'] . '<br>';
} }
$level_index++;
} }
$html .= '<br><br><br>'; $html .= '<br>';
return $html; return $html;
} }
public function generateNetworkHospitalsForEcard($network_hospitals)
{
$html = "";
if (!empty($network_hospitals)) {
$html = '<div style="margin-top: 6px;">
<span style="font-weight: 500;">Network Hospital:</span>
<a href="' . $network_hospitals . '" target="_blank" style="color: #0066cc; text-decoration: none; display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;">' . $network_hospitals . '</a>
</div>';
}
// For debugging
// print_r($html); die;
return $html;
}
public function getBatchFileData() public function getBatchFileData()
{ {
$file_id = $this->request->getGet('file_id'); $file_id = $this->request->getGet('file_id');
@ -3065,7 +3101,8 @@ class EmployeeController extends AdminController
} else { } else {
$text = "create"; $text = "create";
$data['created_by'] = get_session_userid(); $data['created_by'] = get_session_userid();
$this->thzMasterModel->insert($data); $thzMasterModel = new ThzMasterModel();
$thzMasterModel->insert($data);
$insertID = $this->partnerEndorsementRequestModel->insertID(); $insertID = $this->partnerEndorsementRequestModel->insertID();
$result = true; $result = true;
} }

View File

@ -36,6 +36,8 @@ use App\Models\InsurerExcelExportTemplateModel;
use App\Models\NhanceBranchModel; use App\Models\NhanceBranchModel;
use App\Models\SettingsModel; use App\Models\SettingsModel;
use App\Models\VehicleModel; use App\Models\VehicleModel;
use App\Models\VehicleTypeModel;
use App\Models\RTOModel;
use CodeIgniter\CLI\CLI; use CodeIgniter\CLI\CLI;
@ -2022,15 +2024,19 @@ class MasterController extends AdminController
dd($result); dd($result);
} }
//----------------------------------------------------------------------------------------------------------
public function nhanceBranchMaster() public function nhanceBranchMaster()
{ {
$nhanceBranchModel = new NhanceBranchModel(); $nhanceBranchModel = new NhanceBranchModel();
$method = $this->request->getMethod();
$data['tab_name'] = 'Nhance Branch';
$data['page_name'] = 'Nhance Branchs';
if ($this->request->is('post')) { if ($method === 'post') {
$id = $this->request->getPost('pk') ?? null; $id = $this->request->getPost('pk') ?? null;
$data = $this->request->getPost(); $data = $this->request->getPost();
print_r($data); die;
if (empty($id)) { if (empty($id)) {
$update_status = $nhanceBranchModel->insert($data); $update_status = $nhanceBranchModel->insert($data);
@ -2054,7 +2060,7 @@ class MasterController extends AdminController
], 200); ], 200);
} }
} elseif ($this->request->is('get')) { } elseif ($method === 'get') {
$id = $this->request->getGet('pk') ?? null; $id = $this->request->getGet('pk') ?? null;
@ -2070,7 +2076,7 @@ class MasterController extends AdminController
$data = $nhanceBranchModel->where('is_active', 1)->findAll(); $data = $nhanceBranchModel->where('is_active', 1)->findAll();
return $this->loadLayout('nhance_branch_list', ['data' => $data]); return $this->loadLayout('nhance_branch_list', ['data' => $data]);
} elseif ($this->request->is('delete')) { } elseif ($method === 'delete') {
$input = $this->request->getRawInput(); $input = $this->request->getRawInput();
$id = $input['pk'] ?? null; $id = $input['pk'] ?? null;
@ -2106,7 +2112,167 @@ class MasterController extends AdminController
public function vehicleTypeMaster() public function vehicleTypeMaster()
{ {
$vehicleTypeModel = new VehicleTypeModel();
$method = $this->request->getMethod();
$data['tab_name'] = 'Vehicle Type';
$data['page_name'] = 'Vehicle Types';
if ($method === 'post') {
$id = $this->request->getPost('pk') ?? null;
$data = $this->request->getPost();
if (empty($id)) {
$update_status = $vehicleTypeModel->insert($data);
} else {
$update_status = $vehicleTypeModel->where('id', $id)->set($data)->update();
}
if ($update_status) {
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'Vehicle Type Master updated successfully',
'data' => $data
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Failed to update',
'data' => $data
], 200);
}
} elseif ($method === 'get') {
$id = $this->request->getGet('pk') ?? null;
if (!empty($id)) {
$data = $vehicleTypeModel->where('is_active', 1)->where('id', $id)->findAll();
if (!empty($data)) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
} else {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found'], 200);
}
}
$data = $vehicleTypeModel->where('is_active', 1)->findAll();
return $this->loadLayout('vehicle_type_master_list', ['data' => $data]);
} elseif ($method === 'delete') {
$input = $this->request->getRawInput();
$id = $input['pk'] ?? null;
if (empty($id)) {
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'No ID provided for deletion'
], 200);
}
$update_status = $vehicleTypeModel->where('id', $id)->set(['is_active' => 0])->update();
if ($update_status) {
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'Data removed successfully',
'pk' => $id
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Failed to remove data',
'pk' => $id
], 200);
}
}
}
public function rtoMaster()
{
$rtoModel = new RTOModel();
$method = $this->request->getMethod();
$data['tab_name'] = 'RTO';
$data['page_name'] = 'RTO';
if ($method === 'post') {
$id = $this->request->getPost('pk') ?? null;
$data = $this->request->getPost();
if (empty($id)) {
$update_status = $rtoModel->insert($data);
} else {
$update_status = $rtoModel->where('id', $id)->set($data)->update();
}
if ($update_status) {
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'RTO Master updated successfully',
'data' => $data
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Failed to update',
'data' => $data
], 200);
}
} elseif ($method === 'get') {
$id = $this->request->getGet('pk') ?? null;
if (!empty($id)) {
$data = $rtoModel->where('is_active', 1)->where('id', $id)->findAll();
if (!empty($data)) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
} else {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found'], 200);
}
}
$data = $rtoModel->where('is_active', 1)->findAll();
return $this->loadLayout('rto_master_list', ['data' => $data]);
} elseif ($method === 'delete') {
$input = $this->request->getRawInput();
$id = $input['pk'] ?? null;
if (empty($id)) {
return $this->respond([
'status' => false,
'code' => 404,
'message' => 'No ID provided for deletion'
], 200);
}
$update_status = $rtoModel->where('id', $id)->set(['is_active' => 0])->update();
if ($update_status) {
return $this->respond([
'status' => true,
'code' => 200,
'message' => 'Data removed successfully',
'pk' => $id
], 200);
} else {
return $this->respond([
'status' => false,
'code' => 400,
'message' => 'Failed to remove data',
'pk' => $id
], 200);
}
}
} }
} }

View File

@ -151,6 +151,8 @@ class PolicyTransactionController extends BaseController
// 'bicycle' => 'Bicycle' // 'bicycle' => 'Bicycle'
// ]; // ];
$data['vehicle_type'] = db_connect()->table('vehicle_type')->where('is_active', 1)->get()->getResultArray(); $data['vehicle_type'] = db_connect()->table('vehicle_type')->where('is_active', 1)->get()->getResultArray();
$data['rto_details'] = db_connect()->table('rto_master')->where('is_active', 1)->get()->getResultArray();
$data['vehicle_des'] = [ $data['vehicle_des'] = [
'commercial' => 'Commercial', 'commercial' => 'Commercial',
'private' => 'Private', 'private' => 'Private',
@ -261,6 +263,7 @@ class PolicyTransactionController extends BaseController
$data = $this->preparePolicyData(); $data = $this->preparePolicyData();
$data['cd_ac_pk'] = $this->request->getPost('cd_ac_no'); $data['cd_ac_pk'] = $this->request->getPost('cd_ac_no');
$data['issuer'] = 2; $data['issuer'] = 2;
$data['status'] = 'completed';
$this->myLogger->logme('error', 'Policy Trancaction modified form data ( insert data ) : '. json_encode($data)); $this->myLogger->logme('error', 'Policy Trancaction modified form data ( insert data ) : '. json_encode($data));
@ -276,7 +279,6 @@ class PolicyTransactionController extends BaseController
$data = $this->request->getPost(); $data = $this->request->getPost();
// print_r($data); die; // print_r($data); die;
// var_dump($data); die;
if (empty($data['policy_issue_date'])) { if (empty($data['policy_issue_date'])) {
$data['policy_issue_date'] = null; $data['policy_issue_date'] = null;
@ -304,7 +306,6 @@ class PolicyTransactionController extends BaseController
$data['last_action_date'] = change_date_format($data['last_action_date']); $data['last_action_date'] = change_date_format($data['last_action_date']);
} }
// Separate Insurer and TPA Branch IDs and IDs // Separate Insurer and TPA Branch IDs and IDs
if (isset($data['insurer_id']) && !empty($data['insurer_id'])) { if (isset($data['insurer_id']) && !empty($data['insurer_id'])) {
list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']); list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']);
@ -373,6 +374,7 @@ class PolicyTransactionController extends BaseController
$pt_co_share_details = $this->insertOrUpdateCoShareDetails($data, $insert); $pt_co_share_details = $this->insertOrUpdateCoShareDetails($data, $insert);
$client_policy_id = null;
if ($data['ct_type'] == 2) { if ($data['ct_type'] == 2) {
$client_policy_insert_data = $this->prepareClientPolicyInsertData($data); $client_policy_insert_data = $this->prepareClientPolicyInsertData($data);
$client_policy_id = $this->clientPolicyModel->insert($client_policy_insert_data); $client_policy_id = $this->clientPolicyModel->insert($client_policy_insert_data);
@ -381,7 +383,7 @@ class PolicyTransactionController extends BaseController
} }
if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) { if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) {
$this->processCompletedStatus($data, $client_policy_id, $data['insurer_id']); $this->processCompletedStatus($data, $client_policy_id, $data['insurer_id'], $insert);
} }
} }
@ -391,7 +393,6 @@ class PolicyTransactionController extends BaseController
$clientController = new ClientController(); $clientController = new ClientController();
$data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']); $data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']);
$data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']); $data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']);
$data['entity_type_id'] = $client_data['entity_type_id']; $data['entity_type_id'] = $client_data['entity_type_id'];
return $this->respondSuccess($insert, "Policy transaction created successfully", $data); return $this->respondSuccess($insert, "Policy transaction created successfully", $data);
@ -432,20 +433,20 @@ class PolicyTransactionController extends BaseController
} }
} }
if($old_pt_data['status'] != "completed"){ // if($old_pt_data['status'] != "completed"){
if ($data['status'] == 'completed' && $data['ct_type'] == 2) { // if ($data['status'] == 'completed' && $data['ct_type'] == 2) {
if ($data['client_type'] == 1 && $data['is_cd_reduce_from_bds'] == 1) { // if ($data['client_type'] == 1 && $data['is_cd_reduce_from_bds'] == 1) {
$this->processCompletedStatus($data, $data['client_policy_id'], $data['insurer_id']); // $this->processCompletedStatus($data, $data['client_policy_id'], $data['insurer_id'], $id);
} // }
} // }
} // }
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll(); $data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll();
} }
if(isset($data['cd_amt_changed']) && !empty($data['cd_amt_changed'])){ if(isset($data['cd_amt_changed']) && !empty($data['cd_amt_changed'])){
$policy_data = $this->policyTransactionModel->where('is_active', 1)->where('id', $id)->first(); $policy_data = $this->policyTransactionModel->where('is_active', 1)->where('id', $id)->first();
$this->cdCorrection($policy_data, $data['cd_amt_changed']); $this->cdCorrection($policy_data, $data['cd_amt_changed'], $id);
} }
$client_data = $this->clientModel->where('id', $data['client_id'])->first(); $client_data = $this->clientModel->where('id', $data['client_id'])->first();
@ -467,10 +468,6 @@ class PolicyTransactionController extends BaseController
{ {
// Prepare data for insertion and updating // Prepare data for insertion and updating
$coShareDetails = []; $coShareDetails = [];
// print_r($data); die;
// die;
if (isset($data['co_share_id']) && !empty($data['co_share_id'])) { if (isset($data['co_share_id']) && !empty($data['co_share_id'])) {
$this->removePtCoShareRecords($data['co_share_id'], $pt_id); $this->removePtCoShareRecords($data['co_share_id'], $pt_id);
} }
@ -564,7 +561,6 @@ class PolicyTransactionController extends BaseController
} }
// print_r($this->PTCOShareDetailsModel->getLastQuery()); die; // print_r($this->PTCOShareDetailsModel->getLastQuery()); die;
// print_r($coShareDetails); // print_r($coShareDetails);
// die; // die;
@ -610,7 +606,7 @@ class PolicyTransactionController extends BaseController
$this->policyTransactionStatusModel->insert($statusData); $this->policyTransactionStatusModel->insert($statusData);
} }
private function processCompletedStatus($data, $client_policy_id, $insurer_id) private function processCompletedStatus($data, $client_policy_id, $insurer_id, $policyTranId)
{ {
$totalAmount = (int)$data['total'][0] ?? 0; $totalAmount = (int)$data['total'][0] ?? 0;
$description = 'The following amount of Rs. ' . $totalAmount . '/- has been debited for the ' . $data['emp_count'] . ' employees at Inception (BDS).'; $description = 'The following amount of Rs. ' . $totalAmount . '/- has been debited for the ' . $data['emp_count'] . ' employees at Inception (BDS).';
@ -628,13 +624,19 @@ class PolicyTransactionController extends BaseController
'updated_by' => get_session_userid(), 'updated_by' => get_session_userid(),
'event_name' => 'inception', 'event_name' => 'inception',
'is_active' => 1, 'is_active' => 1,
'cd_ac_pk' => $data['cd_ac_pk'] 'cd_ac_pk' => $data['cd_ac_pk'],
'pt_id' => $policyTranId ?? null,
]; ];
DepositHelper::saveDeposit($cdTransactionData, get_session_userid()); $result = DepositHelper::saveDeposit($cdTransactionData, get_session_userid());
if(isset($result) && $result['success'] == true){
$update_data['ct_tran_id'] = $result['insert_id'];
$this->policyTransactionModel->where('id', $policyTranId)->set($update_data)->update();
}
} }
private function cdCorrection($data, $amt) private function cdCorrection($data, $amt, $policyTranId)
{ {
$totalAmount = (int)($amt ?? 0); $totalAmount = (int)($amt ?? 0);
$description = 'The following amount of Rs. ' . $totalAmount . '/- has been debited towards the difference arising from the change in the BDS base premium.'; $description = 'The following amount of Rs. ' . $totalAmount . '/- has been debited towards the difference arising from the change in the BDS base premium.';
@ -652,7 +654,8 @@ class PolicyTransactionController extends BaseController
'updated_by' => get_session_userid(), 'updated_by' => get_session_userid(),
'event_name' => 'inception', 'event_name' => 'inception',
'is_active' => 1, 'is_active' => 1,
'cd_ac_pk' => $data['cd_ac_pk'] 'cd_ac_pk' => $data['cd_ac_pk'],
'pt_id' => $policyTranId ?? null,
]; ];
DepositHelper::saveDeposit($cdTransactionData, get_session_userid()); DepositHelper::saveDeposit($cdTransactionData, get_session_userid());
@ -1026,20 +1029,28 @@ class PolicyTransactionController extends BaseController
} }
} }
public function removePolicyTransaction($id) public function removePolicyTransaction($id, $type = 0)
{ {
if ($id) { if ($id) {
$data['is_active'] = 0; $data['is_active'] = 0;
$policy_transaction_data = $this->policyTransactionModel->where('id', $id)->first(); $policy_transaction_data = $this->policyTransactionModel->where('id', $id)->first();
if($policy_transaction_data['policy_type_id'] > 7){ if($policy_transaction_data['policy_type_id'] > 7 && $type == 0){
$this->policyTransactionModel->where('id', $id)->set($data)->update(); $this->policyTransactionModel->where('id', $id)->set($data)->update();
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update(); $this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
$this->clientPolicyModel->where('id', $policy_transaction_data['client_policy_id'])->set($data)->update(); $this->clientPolicyModel->where('id', $policy_transaction_data['client_policy_id'])->set($data)->update();
$this->policyTransactionModel->where('client_policy_id', $policy_transaction_data['client_policy_id'])->set($data)->update(); $this->policyTransactionModel->where('client_policy_id', $policy_transaction_data['client_policy_id'])->set($data)->update();
$cd_transaction_model = new ClientDepositModel();
$this->$cd_transaction_model->where('policy_transaction_id', $id)->set($data)->update();
}else{ }else{
$this->policyTransactionModel->where('id', $id)->set($data)->update(); $this->policyTransactionModel->where('id', $id)->set($data)->update();
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update(); $this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
$cd_transaction_model = new ClientDepositModel();
$this->$cd_transaction_model->where('policy_transaction_id', $id)->set($data)->update();
} }
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Policy Transaction removed successfully'], 200); return $this->respond(['status' => true, 'code' => 200, 'message' => 'Policy Transaction removed successfully'], 200);
} else { } else {
@ -1167,6 +1178,7 @@ class PolicyTransactionController extends BaseController
{ {
$id = $this->request->getPost('id'); $id = $this->request->getPost('id');
$data = $this->preparePolicyTransactionData(); $data = $this->preparePolicyTransactionData();
$data['status'] = 'completed';
// print_r($data); die; // print_r($data); die;
if (!$id) { if (!$id) {
@ -1334,9 +1346,9 @@ class PolicyTransactionController extends BaseController
if ($update) { if ($update) {
$this->insertTransactionStatus($id, $data, 1); $this->insertTransactionStatus($id, $data, 1);
if($old_endorse_data['status'] != "completed"){ // if($old_endorse_data['status'] != "completed"){
$this->handleCompletedStatus($data, $id); // $this->handleCompletedStatus($data, $id);
} // }
$this->insertOrUpdateCoShareDetails($data, $id); $this->insertOrUpdateCoShareDetails($data, $id);
@ -1347,30 +1359,40 @@ class PolicyTransactionController extends BaseController
} }
private function handleCompletedStatus($data, $policy_tran_id) private function handleCompletedStatus($data, $policy_tran_id)
{ {
if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) { if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) {
$tolamt = (int) $data['total'][0] ?? 0; $tolamt = (int) $data['total'][0] ?? 0;
$description = 'The following amount of Rs. ' . round($tolamt, 2) . '/- has been' . if(!empty($tolamt)){
($data['action_type'] == 'deletion' ? ' Credit ' : ' Debit ') . 'from the policy transaction (BDS)'; $description = 'The following amount of Rs. ' . round($tolamt, 2) . '/- has been' .
$cd_tranction_data = [ ($data['action_type'] == 'deletion' ? ' Credit ' : ' Debit ') . 'from the policy transaction (BDS)';
'amount' => $tolamt,
'sub_type_id' => $data['action_type'] == 'deletion' ? 3 : 4, $cd_tranction_data = [
'client_id' => $data['client_id'], 'amount' => abs($tolamt),
'client_policy_id' => $data['client_policy_id'], 'sub_type_id' => $data['action_type'] == 'deletion' ? 3 : 4,
'endorsement_no' => null, 'client_id' => $data['client_id'],
'cd_ac_no' => $data['cd_ac_no'] ?? null, 'client_policy_id' => $data['client_policy_id'],
'insurer_id' => $data['insurer_id'], 'endorsement_no' => null,
'description' => $description, 'cd_ac_no' => $data['cd_ac_no'] ?? null,
'transaction_type' => $data['action_type'] == 'deletion' ? 'Credit' : 'Debit', 'insurer_id' => $data['insurer_id'],
'updated_by' => get_session_userid(), 'description' => $description,
'event_name' => $data['action_type'], 'transaction_type' => $data['action_type'] == 'deletion' ? 'Credit' : 'Debit',
'is_active' => 1, 'updated_by' => get_session_userid(),
'cd_ac_pk' => $data['cd_ac_pk'] ?? null, 'event_name' => $data['action_type'],
]; 'is_active' => 1,
'cd_ac_pk' => $data['cd_ac_pk'] ?? null,
'pt_id' => $policy_tran_id ?? null,
];
$result = DepositHelper::saveDeposit($cd_tranction_data, get_session_userid());
if(isset($result['success']) && $result['success']){
$update_data['ct_tran_id'] = $result['insert_id'];
$this->policyTransactionModel->where('id', $policy_tran_id)->set($update_data)->update();
}
}
DepositHelper::saveDeposit($cd_tranction_data, get_session_userid());
} }
} }
@ -1398,13 +1420,13 @@ class PolicyTransactionController extends BaseController
->orderBy('id', 'asc') ->orderBy('id', 'asc')
->first(); ->first();
$pt_id = null; $pt_id = null;
if(!empty($data)){ if(!empty($data)){
$inception_data = $this->policyTransactionModel->where('policy_no', $data['policy_no'])->where('client_id', $data['client_id'])->first(); $inception_data = $this->policyTransactionModel->where('policy_no', $data['policy_no'])->where('client_id', $data['client_id'])->first();
$pt_id = $inception_data['id']; $pt_id = $inception_data['id'];
} }
if (!empty($data['policy_start_date'])) { if (!empty($data['policy_start_date'])) {
$data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y'); $data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y');
} }
@ -1565,6 +1587,16 @@ class PolicyTransactionController extends BaseController
// print_r($data['endorse_eff_date']); die; // print_r($data['endorse_eff_date']); die;
$pt_bp_amt = $this->PTCOShareDetailsModel
->select('bp_amt, amount')
->where('pt_id', $id)
->where('co_share_type', 1)
->where('is_active', 1)
->first();
// dd(db_connect()->getLastQuery() ,$pt_bp_amt);
$data['base_cd_amount'] = $pt_bp_amt['amount'] ?? null;
if ($data) { if ($data) {
return $this->respond(['status' => true, 'data' => $data, 'pt_id' => $pt_id], 200); return $this->respond(['status' => true, 'data' => $data, 'pt_id' => $pt_id], 200);
} else { } else {
@ -2111,7 +2143,7 @@ class PolicyTransactionController extends BaseController
//insurer statement list page //insurer statement list page
public function statementList() public function statementList()
{ {
// dd($this->validateInsurerStatement(['file_id' => 49])); // for check validateInsurerStatementfunction with hard coded file id always un command // dd($this->updateInsurerStatement(['file_id' => 133])); // for check validateInsurerStatementfunction with hard coded file id always un command
$data['insurers'] = $this->insurerModel->where('is_active',1)->findAll(); $data['insurers'] = $this->insurerModel->where('is_active',1)->findAll();
$today = date('Y-m-d'); $today = date('Y-m-d');
$fromday = $from_date = date('Y-m-d', strtotime('-180 days', strtotime($today))); $fromday = $from_date = date('Y-m-d', strtotime('-180 days', strtotime($today)));
@ -2356,13 +2388,13 @@ class PolicyTransactionController extends BaseController
// $excel_row = ExcelSanitizeHelper::sanitizeArrayData($excel_row); // $excel_row = ExcelSanitizeHelper::sanitizeArrayData($excel_row);
$is_source_found = 0; $is_source_found = 0;
// Kint::dump($excel_key,$excel_row[1],$excel_row[2]); // Kint::dump($excel_key,$excel_row[1],$excel_row[2]);
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel // $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
$policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel // $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel
$policy_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[1]); //policy_end_date from excel $policy_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[1]); //policy_end_date from excel
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel // $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
$endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]); //policy_end_date from excel $endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]); //policy_end_date from excel
@ -2468,11 +2500,11 @@ class PolicyTransactionController extends BaseController
if (!$is_row_empty) { if (!$is_row_empty) {
$is_source_found = 0; $is_source_found = 0;
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel // $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
$policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel // $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel
$policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]); // $policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]); //
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel // $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
foreach ($source_data as $source_key => $source_row) { foreach ($source_data as $source_key => $source_row) {
@ -2485,9 +2517,10 @@ class PolicyTransactionController extends BaseController
//calculate percentage first //calculate percentage first
$total_amt = 0; $total_amt = 0;
$actual_bp_per = trim($excel_row[9]); // $actual_bp_per = trim($excel_row[9]); //commented becoz this filed removed tfrom excel file
$actual_bp_brokerage = trim($excel_row[12]); $actual_bp_per = 0; //set default value 0 for maintaining existing code flow
$actual_bp_amt = trim($excel_row[6]); $actual_bp_brokerage = trim($excel_row[5]);
$actual_bp_amt = trim($excel_row[3]);
if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) { if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) {
$total_amt += $actual_bp_brokerage; $total_amt += $actual_bp_brokerage;
@ -2500,9 +2533,10 @@ class PolicyTransactionController extends BaseController
$total_amt += $actual_bp_brokerage; $total_amt += $actual_bp_brokerage;
} }
$actual_tp_per = trim($excel_row[10]); // $actual_tp_per = trim($excel_row[10]);//commented becoz this filed removed tfrom excel file
$actual_tp_brokerage = trim($excel_row[13]); $actual_tp_per = 0;//set default value 0 for maintaining existing code flow
$actual_tp_amt = trim($excel_row[7]); $actual_tp_brokerage = trim($excel_row[6]);
$actual_tp_amt = trim($excel_row[4]);
if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") { if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") {
$total_amt += $actual_tp_brokerage; $total_amt += $actual_tp_brokerage;
@ -2515,9 +2549,13 @@ class PolicyTransactionController extends BaseController
$total_amt += $actual_tp_brokerage; $total_amt += $actual_tp_brokerage;
} }
$actual_tep_per = trim($excel_row[11]); // $actual_tep_per = trim($excel_row[11]);
$actual_tep_brokerage = trim($excel_row[14]); // $actual_tep_brokerage = trim($excel_row[14]);
$actual_tep_amt = trim($excel_row[8]); // $actual_tep_amt = trim($excel_row[8]);
$actual_tep_per = 0;
$actual_tep_brokerage = 0;
$actual_tep_amt = 0;
if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") { if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") {
$total_amt += $actual_tep_brokerage; $total_amt += $actual_tep_brokerage;
@ -2533,7 +2571,7 @@ class PolicyTransactionController extends BaseController
//find variance //find variance
$variance_amt = $source_row['exp_amt'] - $total_amt; $variance_amt = $source_row['exp_amt'] - $total_amt;
$data_to_update[] = ['co_share_id' => $source_row['id'], 'actual_bp_amt' => $actual_bp_amt, 'actual_tp_amt' => $actual_tp_amt, 'actual_tep_amt' => $actual_tep_amt, 'actual_bp_per' => $actual_bp_per, 'actual_tp_per' => $actual_tp_per, 'actual_tep_per' => $actual_tep_per, 'variance' => $variance_amt, 'actual_tep_brokerage_amt' => $actual_tep_brokerage, 'actual_tp_brokerage_amt' => $actual_tp_brokerage, 'actual_bp_brokerage_amt' => $actual_bp_brokerage, 'reward' => trim($excel_row[15]), 'statement_id' => $file_id]; $data_to_update[] = ['co_share_id' => $source_row['id'], 'actual_bp_amt' => $actual_bp_amt, 'actual_tp_amt' => $actual_tp_amt, 'actual_tep_amt' => $actual_tep_amt, 'actual_bp_per' => $actual_bp_per, 'actual_tp_per' => $actual_tp_per, 'actual_tep_per' => $actual_tep_per, 'variance' => $variance_amt, 'actual_tep_brokerage_amt' => $actual_tep_brokerage, 'actual_tp_brokerage_amt' => $actual_tp_brokerage, 'actual_bp_brokerage_amt' => $actual_bp_brokerage, 'reward' => trim($excel_row[7]), 'statement_id' => $file_id];
unset($source_data[$source_key]); unset($source_data[$source_key]);
continue 2; continue 2;

View File

@ -66,7 +66,8 @@ class DepositHelper
'updated_by' => $data['updated_by'], 'updated_by' => $data['updated_by'],
'balance' => $newBalance, // Include the new balance in the data array 'balance' => $newBalance, // Include the new balance in the data array
'cd_ac_pk'=> isset($data['cd_ac_pk'])?$data['cd_ac_pk']:null, 'cd_ac_pk'=> isset($data['cd_ac_pk'])?$data['cd_ac_pk']:null,
'record_date' => $data['record_date'] ?? null 'record_date' => $data['record_date'] ?? null,
'policy_transaction_id' => $data['pt_id'] ?? null
]; ];
// Insert data and get the insert ID // Insert data and get the insert ID

View File

@ -28,7 +28,8 @@ class ClientDepositModel extends Model
"event_name", "event_name",
"unit", "unit",
"cd_ac_pk", "cd_ac_pk",
"record_date" "record_date",
"policy_transaction_id",
]; ];

View File

@ -1471,7 +1471,7 @@ class EmployeePolicyModel extends Model
ep.tpa_id, ep.tpa_id,
ep.uhid, ep.uhid,
ep.policy_end_date, cp.policy_end_date,
ep.basic_cover_si, ep.basic_cover_si,
clients.client_name, clients.client_name,
@ -1537,7 +1537,7 @@ class EmployeePolicyModel extends Model
ep.tpa_id, ep.tpa_id,
ep.uhid, ep.uhid,
ep.policy_end_date, cp.policy_end_date,
ep.basic_cover_si, ep.basic_cover_si,
clients.client_name, clients.client_name,

View File

@ -305,7 +305,7 @@ class PolicyTransactionModel extends Model
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) { if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
$fromDate = date('Y-m-d', strtotime('-30 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
@ -881,7 +881,7 @@ class PolicyTransactionModel extends Model
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) { if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
$fromDate = date('Y-m-d', strtotime('-60 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
if (empty($where)) { if (empty($where)) {
@ -1060,7 +1060,7 @@ class PolicyTransactionModel extends Model
// Default to Last 30 Days if No Filters Are Applied // Default to Last 30 Days if No Filters Are Applied
if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer) && empty($where)) { if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer) && empty($where)) {
$fromDate = date('Y-m-d', strtotime('-60 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
@ -1108,7 +1108,7 @@ class PolicyTransactionModel extends Model
->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left') ->join('client_branch', 'policy_transaction.client_branch_id = client_branch.id', 'left')
->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left') ->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left') ->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left') ->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
->where('policy_transaction.is_active', 1) ->where('policy_transaction.is_active', 1)
->where('policy_transaction.action_type !=', 'inception'); ->where('policy_transaction.action_type !=', 'inception');
@ -1163,7 +1163,7 @@ class PolicyTransactionModel extends Model
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) { if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
$fromDate = date('Y-m-d', strtotime('-60 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
@ -1313,7 +1313,7 @@ class PolicyTransactionModel extends Model
->where('policy_transaction.' . $date_type . '<=', $endDate); ->where('policy_transaction.' . $date_type . '<=', $endDate);
} else { } else {
$fromDate = date('Y-m-d', strtotime('-30 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
@ -1416,7 +1416,7 @@ class PolicyTransactionModel extends Model
->where('policy_transaction.' . $date_type . '<=', $endDate); ->where('policy_transaction.' . $date_type . '<=', $endDate);
} else { } else {
$fromDate = date('Y-m-d', strtotime('-30 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
@ -1457,7 +1457,7 @@ class PolicyTransactionModel extends Model
public function getFinanceReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0) public function getFinanceReportList($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
{ {
$dateThreshold = date('Y-m-d H:i:s', strtotime("- 3 days")); $dateThreshold = date('Y-m-d H:i:s', strtotime("-90 days"));
$builder = $this->db->table('policy_transaction') $builder = $this->db->table('policy_transaction')
->select(" ->select("
@ -1519,7 +1519,7 @@ class PolicyTransactionModel extends Model
->where('policy_transaction.' . $date_type . '<=', $endDate); ->where('policy_transaction.' . $date_type . '<=', $endDate);
} else { } else {
$fromDate = date('Y-m-d', strtotime('-30 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
@ -1624,7 +1624,7 @@ class PolicyTransactionModel extends Model
$builder->where('policy_transaction.' . $date_type . '>=', $startDate) $builder->where('policy_transaction.' . $date_type . '>=', $startDate)
->where('policy_transaction.' . $date_type . '<=', $endDate); ->where('policy_transaction.' . $date_type . '<=', $endDate);
} else { } else {
$fromDate = date('Y-m-d', strtotime('-30 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
$builder->where('policy_transaction.created_at >=', $fromDate) $builder->where('policy_transaction.created_at >=', $fromDate)
@ -1712,7 +1712,7 @@ class PolicyTransactionModel extends Model
//function for fetch renewal report data //function for fetch renewal report data
public function getRenewalReportData($start_date = null, $end_date = null, $client_type = null, $client = null, $issuer = null) public function getRenewalReportData($start_date = null, $end_date = null, $client_type = null, $client = null, $issuer = null)
{ {
$fromDate = date('Y-m-d', strtotime('-60 days')); $fromDate = date('Y-m-d', strtotime('-90 days'));
$toDate = date('Y-m-d 23:59:59'); $toDate = date('Y-m-d 23:59:59');
if (!empty($start_date) && !empty($end_date)) { if (!empty($start_date) && !empty($end_date)) {

57
app/Models/RTOModel.php Normal file
View File

@ -0,0 +1,57 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class RTOModel extends Model
{
protected $table = 'rto_master';
protected $primaryKey = 'id';
protected $allowedFields = [
'id',
'rto_state',
'rto_code',
'rto_name',
'created_at',
'created_by',
'updated_at',
'updated_by',
'is_active',
];
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = ["checkAndADDCreatedByValue"];
protected $afterInsert = [];
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
protected function checkAndADDCreatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['created_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['created_by'] = get_session_userid();
}
return $data;
}
protected function checkAndUpdateUpdatedByValue(array $data)
{
// Check if 'updated_by' value is null or empty
if (empty($data['data']['updated_by'])) {
// Set 'updated_by' value to the current session user ID
$data['data']['updated_by'] = get_session_userid();
}
return $data;
}}

View File

@ -25,6 +25,7 @@ class VehicleModel extends Model
'is_active', 'is_active',
'created_by', 'created_by',
'updated_by', 'updated_by',
'rto_id',
]; ];

View File

@ -208,7 +208,7 @@
<?php if(in_array(get_role_id(), [1,2,3,5]) || (get_role_id() == 4 && in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?> <?php if(in_array(get_role_id(), [1,2,3,5]) || (get_role_id() == 4 && in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
<li class="nav-item d-flex justify-content-center align-items-center"> <!-- <li class="nav-item d-flex justify-content-center align-items-center">
<a href="#bds-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-1 dash-anchor nav-dash" id="bds_tab"> <a href="#bds-dash-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-1 dash-anchor nav-dash" id="bds_tab">
<img src="<?= base_url() . "public"; ?>/assets/images/inactive_bds.png" alt="Logo" height="14" class="inactive_bds"> <img src="<?= base_url() . "public"; ?>/assets/images/inactive_bds.png" alt="Logo" height="14" class="inactive_bds">
<img src="<?= base_url() . "public"; ?>/assets/images/active_bds.png" alt="Logo" height="14" <img src="<?= base_url() . "public"; ?>/assets/images/active_bds.png" alt="Logo" height="14"
@ -217,7 +217,7 @@
<span class="d-none d-sm-inline-block dash-tab dash-tab-font">BDS</span> <span class="d-none d-sm-inline-block dash-tab dash-tab-font">BDS</span>
</a> </a>
</li> </li>
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; -->
<?php } ?> <?php } ?>
<?php if ((get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?> <?php if ((get_role_id() == STAFF_ROLE_ID && in_array(CLAIMS_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?>
@ -262,7 +262,7 @@
<?php endif; ?> <?php endif; ?>
<?php if(in_array(get_role_id(), [1,2,3,5]) || (get_role_id() == 4 && in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?> <?php if(in_array(get_role_id(), [1,2,3,5]) || (get_role_id() == 4 && in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()))) { ?>
<?php include('bds_dash.php'); ?> <!-- <?php //include('bds_dash.php'); ?> -->
<?php } ?> <?php } ?>
<?php if ((get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?> <?php if ((get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_team())) || in_array(get_role_id(),[1,5])) :?>
<?php include("leads_dash.php") ?> <?php include("leads_dash.php") ?>

View File

@ -1792,6 +1792,15 @@
<li> <li>
<a href="<?= base_url('/user/list') ?>"> Users </a> <a href="<?= base_url('/user/list') ?>"> Users </a>
</li> </li>
<li>
<a href="<?= base_url('/util/nhanceBranchMaster') ?>"> Nhance Branch </a>
</li>
<li>
<a href="<?= base_url('/util/vehicleTypeMaster') ?>"> Vehicle Type </a>
</li>
<li>
<a href="<?= base_url('/util/rtoMaster') ?>"> RTO </a>
</li>
<?php } ?> <?php } ?>

View File

@ -452,6 +452,58 @@ if (isset($selected_lead_type)) {
$('#salse_person_id').trigger('change'); $('#salse_person_id').trigger('change');
} }
// $('#client_name').on('input', generateShortName);
let shortNameTimer;
$('#client_name').on('input', function() {
clearTimeout(shortNameTimer);
shortNameTimer = setTimeout(generateShortName, 200);
});
function generateShortName() {
let clientInput = $("#client_name");
let shortInput = $("#client_short_name");
let newClientName = clientInput.val().trim();
console.log(`LN : NEW - ${newClientName}`);
if (newClientName.length == 0) {
shortInput.val('');
return;
}
let shortName = newClientName.substring(0, 10).replace(/\s+/g, '').toUpperCase();
makeUniqueShortName(shortName);
}
function makeUniqueShortName(baseName) {
let input = $("#client_short_name")[0];
checkDuplicateTableFieldValue("clients", "short_name", baseName, function(isDuplicate) {
if (isDuplicate) {
let counter = 1;
function tryNext() {
let padded = String(counter).padStart(3, '0'); // 001, 002, 003
let newName = baseName + padded;
checkDuplicateTableFieldValue("clients", "short_name", newName, function(exists) {
if (exists) {
counter++;
tryNext();
} else {
$("#client_short_name").val(newName);
validateInput(input, "clients", "short_name");
}
});
}
tryNext();
} else {
$("#client_short_name").val(baseName);
validateInput(input, "clients", "short_name");
}
});
}
function validateInput(input, table, field){ function validateInput(input, table, field){
let client_type = $('#client_type').val(); let client_type = $('#client_type').val();

View File

@ -14,25 +14,43 @@
<tr> <tr>
<th class="font-weight-medium">S.No.</th> <th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">Branch Name</th> <th class="font-weight-medium">Branch Name</th>
<!-- <th class="font-weight-medium">Status</th> -->
<th class="font-weight-medium">Action</th> <th class="font-weight-medium">Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php if(isset($data)) { ?>
<?php foreach($data as $index => $row) { ?> <?php foreach($data as $index => $row) { ?>
<tr> <tr>
<td class="text-dark"><?= esc($index + 1); ?></td> <td class="text-dark">&nbsp;&nbsp;<?= esc($index + 1); ?></td>
<td><?= $row['branch_name']; ?></td> <td><?= $row['branch_name']; ?></td>
<!-- <td>
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
</span>
</td> -->
<td> <td>
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;"> <div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a> <a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right" style="cursor: pointer;"> <div class="dropdown-menu dropdown-menu-right" style="cursor: pointer;">
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', <?= $row['id']; ?>)"><i data-id="<?= $row['id']; ?>" class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a> <a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', <?= $row['id']; ?>)"><i data-id="<?= $row['id']; ?>" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
<?php if ($row['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
<?php endif; ?>
</div> </div>
</div> </div>
</td> </td>
</tr> </tr>
<?php } ?> <?php } ?>
<?php } else { ?>
<tr>
<td colspan="3" class="text-center">No data available</td>
</tr>
<?php } ?>
</tbody> </tbody>
</table> </table>
@ -43,14 +61,15 @@
<!-- modal content --> <!-- modal content -->
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static"> <div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered modal-lg"> <div class="modal-dialog modal-dialog-centered">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title">Add Branch</h4> <h4 class="modal-title" id="modalLabel">Add Branch</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div> </div>
<div class="modal-body p-4"> <div class="modal-body p-4">
<form class="parsley-examples" id="nhanceBranchForm" enctype="multipart/form-data"> <!-- <form class="parsley-examples" id="nhanceBranchForm" enctype="multipart/form-data"> -->
<form id="nhanceBranchForm" enctype="multipart/form-data">
<input type="hidden" name="pk" id="nhance_branch_id"/> <input type="hidden" name="pk" id="nhance_branch_id"/>
<div class="form-group"> <div class="form-group">
<div class="form-row"> <div class="form-row">
@ -61,7 +80,7 @@
</div> </div>
</div> </div>
<div class="form-group text-right m-b-0"> <div class="form-group text-right m-b-0">
<button class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button> <button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
</div> </div>
</form> </form>
</div> </div>
@ -69,7 +88,6 @@
</div> </div>
</div> </div>
<script> <script>
var table; var table;
$(document).ready(function () { $(document).ready(function () {
@ -127,42 +145,100 @@
myModal.show(); myModal.show();
} }
function handleSaveEditAndDelete(type = 'submit', pk = null){ // old Version
// function handleSaveEditAndDelete(type = 'submit', pk = null){
console.log("type", type) // let url = '<?= base_url('util/nhanceBranchMaster') ?>';
// let method = "POST";
// let requestData = {};
// $('#modalLabel').text('Add Branch');
// requestData.pk = pk;
// if(type == 'submit'){
// $("#nhanceBranchForm").find("input, select, textarea").each(function () {
// let name = $(this).attr("name");
// let value = $.trim($(this).val());
// if (name) requestData[name] = value;
// });
// }
// if(type == 'remove'){
// method = "DELETE";
// }else if (type == 'edit'){
// method = "GET"
// }
// console.log("type", type)
// console.log("url", url)
// console.log("method", method)
// console.log("requestData", requestData)
// $('.loader').fadeIn();
// $('.loader-mask').fadeIn();
// // Send AJAX request
// sendAjaxRequestForGlobal(url, method, requestData, function(response) {
// console.log('Data fetched successfully:', response);
// if (response.status) {
// if(type == 'edit'){
// $('#modalLabel').text('Edit Branch');
// appendEditData(response.data);
// }else{
// toastr.success(response.message, 'SUCCESS');
// }
// } else {
// toastr.warning(response.message, 'WARNING');
// }
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// }, function(xhr, status, error) {
// console.error('Error fetching data:', error);
// console.error(xhr.responseText);
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// });
// }
function handleSaveEditAndDelete(type = 'submit', el = null) {
let url = '<?= base_url('util/nhanceBranchMaster') ?>'; let url = '<?= base_url('util/nhanceBranchMaster') ?>';
console.log("url", url) let method = "POST";
let requestData = {}; let requestData = {};
let pk = null;
// If element is passed (from edit/remove button), get its data-id
if (el) { pk = $(el).data('id'); }
requestData.pk = pk;
if(type == 'submit'){ if(type == 'submit'){
$("#vehicle_form_row_div").find("input, select, textarea").each(function () { $("#nhanceBranchForm").find("input, select, textarea").each(function () {
let name = $(this).attr("name"); let name = $(this).attr("name");
let value = $.trim($(this).val()); let value = $.trim($(this).val());
if (name) requestData[name] = value;
if (name) {
requestData[name] = value;
console.log("✅ Added field:", name, "=", value);
}
}); });
}else{
requestData = {
pk: pk,
};
} }
console.log("requestData", requestData)
let method = "POST";
if(type == 'remove'){ if(type == 'remove'){
method = "DELETE"; method = "DELETE";
}else if (type == 'edit'){ } else if (type == 'edit'){
method = "GET" method = "GET";
$('#modalLabel').text('Edit Branch');
$('#nhanceBranchForm')[0].reset();
} }
console.log("method", method)
console.log("type", type)
console.log("url", url)
console.log("method", method)
console.log("requestData", requestData)
$('.loader').fadeIn(); $('.loader').fadeIn();
$('.loader-mask').fadeIn(); $('.loader-mask').fadeIn();
@ -175,11 +251,18 @@
if (response.status) { if (response.status) {
if(type == 'edit'){ if(type == 'edit'){
appendEditData(response.data); appendEditData(response.data);
}else{ } else if(type == 'remove'){
toastr.success(response.message, 'SUCCESS'); toastr.success(response.message, 'Success');
if(el) $(el).closest('tr').remove();
} else if(type == 'submit'){
toastr.success(response.message, 'Success');
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.hide();
$('#nhanceBranchForm')[0].reset();
window.location.reload();
} }
} else { } else {
toastr.warning(response.message, 'WARNING'); toastr.warning(response.message, 'Warning');
} }
$('.loader').fadeOut(); $('.loader').fadeOut();
@ -188,19 +271,19 @@
}, function(xhr, status, error) { }, function(xhr, status, error) {
console.error('Error fetching data:', error); console.error('Error fetching data:', error);
console.error(xhr.responseText); console.error(xhr.responseText);
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
}); });
} }
function resetValues(){ function resetValues(){
$('#branch_name').val(''); $('#modalLabel').text('Add Branch');
$('#nhanceBranchForm')[0].reset();
} }
function appendEditData(data){ function appendEditData(data){
$('#branch_name').val(data.branch_name); $('#nhance_branch_id').val(data[0]['id']);
$('#branch_name').val(data[0]['branch_name']);
openModal() openModal()
} }
</script> </script>

File diff suppressed because it is too large Load Diff

View File

@ -327,7 +327,7 @@ table.dataTable thead th {
<?php foreach ($endorsement_data_list as $index => $row) { ?> <?php foreach ($endorsement_data_list as $index => $row) { ?>
<tr> <tr>
<td class="text-center"><?php echo $index + 1; ?></td> <td class="text-center"><?php echo $index + 1; ?></td>
<td><?php echo $issuer[$row['issuer']] ?: 'N/A'; ?></td><!-- Issuer --> <td><?php echo $issuer[$row['issuer']] ?? 'N/A'; ?></td><!-- Issuer -->
<td><?php echo $row['client_short_name'] ?: 'N/A'; ?></td><!-- Client --> <td><?php echo $row['client_short_name'] ?: 'N/A'; ?></td><!-- Client -->
<td><?php echo $row['client_branch_name'] ?: 'N/A'; ?></td><!-- Branch --> <td><?php echo $row['client_branch_name'] ?: 'N/A'; ?></td><!-- Branch -->
<td><?php echo $row['insurer_short_name'] ?: 'N/A'; ?></td><!-- Insurer --> <td><?php echo $row['insurer_short_name'] ?: 'N/A'; ?></td><!-- Insurer -->
@ -346,6 +346,9 @@ table.dataTable thead th {
<a class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>" onclick="getPolicyTransactionDataForEndorsementEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')"> <a class="dropdown-item btnEdit" data-id="<?= $row['id']; ?>" onclick="getPolicyTransactionDataForEndorsementEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a> </a>
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>', <?= $row['policy_type_id'] ?>)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
</div> </div>
</div> </div>
</td> </td>
@ -717,6 +720,7 @@ table.dataTable thead th {
'data-iep': item.iep, 'data-iep': item.iep,
'data-itp': item.itp, 'data-itp': item.itp,
'data-bap': item.bap, 'data-bap': item.bap,
'data-allocg': item.allocg,
'data-tpa': item.tpa_branch_id + '-' + item.tpa_id, 'data-tpa': item.tpa_branch_id + '-' + item.tpa_id,
'data-ptid': item.policy_type_id, 'data-ptid': item.policy_type_id,
}); });
@ -978,4 +982,41 @@ table.dataTable thead th {
$('#date_div').hide() $('#date_div').hide()
} }
} }
function removePolicyTransaction(input, pt_id, policy_type_id) {
let string = "Do you want to delete this transaction?";
if(policy_type_id > 7){
string = "Do you want to delete this transaction? Deleting this will also remove the linked CRM policy entry.";
}
confirmActionSweertAlert(string, "Yes, Proceed!", "No, Cancel").then((confirmed) => {
if (confirmed) {
let type = '1';
let url = '<?= base_url('policy_tranction/inception/removePolicyTransaction/') ?>' + pt_id + '/' + type;
// Include `pt_id` in the AJAX request if necessary
let requestData = {
pt_id: pt_id ,
type: 1 ,
};
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
window.location.reload();
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
});
}
});
}
</script> </script>

View File

@ -413,210 +413,208 @@
<!-- Pre sales Row --> <!-- Pre sales Row -->
<div class="row" id="pre_sales_row"> <div class="row" id="pre_sales_row">
<div class="col-md-12"> <div class="col-md-12">
<div id="accordion_1" class="mb-0">
<div id="accordion_1" class="mb-0"> <label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center"> <span class="font-color-black">Pre Sales</span>
<span class="font-color-black">Pre Sales</span> <a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo" aria-expanded="true">
aria-expanded="true"> <i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i> </a>
</a> </label>
</label> <div class="card mb-1">
<div class="card mb-1"> <div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_1">
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_1"> <div class="card-body">
<div class="card-body"> <div class="row" id="policyholdernamediv" style="display: none;">
<div class="row" id="policyholdernamediv" style="display: none;"> <div class="form-group col-md-3">
<div class="form-group col-md-3"> <label for="bp_igst">Policyholder Name</label>
<label for="bp_igst">Policyholder Name</label> <input id="policy_holder_name" value="" type="text" class="form-control" name="policy_holder_name">
<input id="policy_holder_name" value="" type="text" class="form-control" name="policy_holder_name"> </div>
</div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label class="switch" style="position: relative;top: 30px;left: 4px;"> <label class="switch" style="position: relative;top: 30px;left: 4px;">
<input id="same_as_proposer" type="checkbox" name="same_as_proposer" checked> <input id="same_as_proposer" type="checkbox" name="same_as_proposer" checked>
<span class="slider round" style="height: 27px;"></span> <span class="slider round" style="height: 27px;"></span>
</label> </label>
<label for="same_as_proposer" <label for="same_as_proposer"
style="position: relative;top: 31px;left: 17px;">Insured (Same as Proposer)</label> style="position: relative;top: 31px;left: 17px;">Insured (Same as Proposer)</label>
</div>
</div>
<div class="row" id="family_details" style="display: none;">
<div class="col-md-12">
<div class="form-section">
<h4>Family details</h4>
<div id="dynamic-form-container-for-insured"></div>
</div> </div>
</div> </div>
<div class="row" id="family_details" style="display: none;"> </div>
<div class="col-md-12"> <hr>
<div class="form-section"> <div class="row">
<h4>Family details</h4>
<div id="dynamic-form-container-for-insured"></div>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="addon_policy"> Business Type <span id="base_danger" <label for="addon_policy"> Business Type <span id="base_danger"
class="text-danger">*</span></label> class="text-danger">*</span></label>
<select class="form-control" id="issue_type" name="issue_type" required> <select class="form-control" id="issue_type" name="issue_type" required>
<option value="" selected>Select Issue Type</option> <option value="" selected>Select Issue Type</option>
<?php <?php
if (isset($issuing_type) && count($issuing_type)) { if (isset($issuing_type) && count($issuing_type)) {
foreach ($issuing_type as $key => $value) { foreach ($issuing_type as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>"; echo "<option value=" . $key . ">" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="bp_gst_amt">Revenue Type</label>
<select id="revenue_type" class="form-control" name="revenue_type">
<option value="">Select</option>
<option value="NA">NA</option>
<option value="EA">EA</option>
<option value="EANR">EANR</option>
</select>
</div>
<div class="form-group col-md-3" id="renewal" style="display: none;">
<label for="addon_policy"> Renewal Source Policy <span id="base_danger"class="text-danger"></span></label>
<select class="form-control" id="source_client_policy_id"name="source_client_policy_id" onchange="setRenewalPolicyData(this)">
<option value="" selected>Select Renewal Source Policy</option>
</select>
</div>
<div class="form-group col-md-3 sded_dates" style="display: none;">
<label for="addon_policy">Policy Start Date<span id="base_danger"
class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_policy_start_date"
name="renewal_policy_start_date" placeholder="DD/MM/YYYY" >
</div>
<div class="form-group col-md-3 sded_dates" style="display: none;">
<label for="addon_policy">Policy End Date<span id="base_danger"
class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_policy_end_date"
name="renewal_policy_end_date" placeholder="DD/MM/YYYY" >
</div>
<div class="form-group col-md-3 roll_div" style="display: none;">
<label for="rollover_date">Date of Expiring Policy for Rollover</label>
<input id="rollover_date" value="" type="text" class="form-control" name="rollover_date" placeholder="DD/MM/YYYY">
</div>
<div class="form-group col-md-3">
<label for="ref">Reference</label>
<input id="ref" value="" type="text" class="form-control" name="ref">
</div>
<!-- <div class="form-group col-md-3">
<label for="addon_policy"> Status <span id="base_danger"class="text-danger">*</span></label>
<select class="form-control" id="policy_status" name="status" required>
<option value="" selected>Select Status</option>
<?php
if (isset($policy_status) && count($policy_status)) {
foreach ($policy_status as $key => $value) {
if($key == 'pending'){
echo "<option value=" . $key . " selected>" . $value . "</option>";
}else{
echo "<option value=" . $key . ">" . $value . "</option>";
}
} }
} }
?> ?>
</select> </select>
</div> </div> -->
<div class="form-group col-md-3"> <!-- <div class="form-group col-md-3">
<label for="bp_gst_amt">Revenue Type</label> <label for="ppteam">PP Team</label>
<select id="revenue_type" class="form-control" name="revenue_type"> <select class="form-control" id="ppteam" name="ppteam">
<option value="">Select</option> <option value="">Select PP Team</option>
<option value="NA">NA</option> <?php if (isset($ppTeamsData)) { ?>
<option value="EA">EA</option> <?php foreach ($ppTeamsData as $value) { ?>
<option value="EANR">EANR</option> <option value="<?= $value['id'];?>">
</select> <?= $value['first_name'];?>
</div>
<div class="form-group col-md-3" id="renewal" style="display: none;">
<label for="addon_policy"> Renewal Source Policy <span id="base_danger"class="text-danger"></span></label>
<select class="form-control" id="source_client_policy_id"name="source_client_policy_id" onchange="setRenewalPolicyData(this)">
<option value="" selected>Select Renewal Source Policy</option>
</select>
</div>
<div class="form-group col-md-3 sded_dates" style="display: none;">
<label for="addon_policy">Policy Start Date<span id="base_danger"
class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_policy_start_date"
name="renewal_policy_start_date" placeholder="DD/MM/YYYY" >
</div>
<div class="form-group col-md-3 sded_dates" style="display: none;">
<label for="addon_policy">Policy End Date<span id="base_danger"
class="text-danger">*</span></label>
<input type="text" class="form-control" id="renewal_policy_end_date"
name="renewal_policy_end_date" placeholder="DD/MM/YYYY" >
</div>
<div class="form-group col-md-3 roll_div" style="display: none;">
<label for="rollover_date">Date of Expiring Policy for Rollover</label>
<input id="rollover_date" value="" type="text" class="form-control" name="rollover_date" placeholder="DD/MM/YYYY">
</div>
<div class="form-group col-md-3">
<label for="ref">Reference</label>
<input id="ref" value="" type="text" class="form-control" name="ref">
</div>
<div class="form-group col-md-3">
<label for="addon_policy"> Status <span id="base_danger"class="text-danger">*</span></label>
<select class="form-control" id="policy_status" name="status" required>
<option value="" selected>Select Status</option>
<?php
if (isset($policy_status) && count($policy_status)) {
foreach ($policy_status as $key => $value) {
if($key == 'pending'){
echo "<option value=" . $key . " selected>" . $value . "</option>";
}else{
echo "<option value=" . $key . ">" . $value . "</option>";
}
}
}
?>
</select>
</div>
<!-- <div class="form-group col-md-3">
<label for="ppteam">PP Team</label>
<select class="form-control" id="ppteam" name="ppteam">
<option value="">Select PP Team</option>
<?php if (isset($ppTeamsData)) { ?>
<?php foreach ($ppTeamsData as $value) { ?>
<option value="<?= $value['id'];?>">
<?= $value['first_name'];?>
</option>
<?php } ?>
<?php } ?>
</select>
</div> -->
<!-- <div class="form-group col-md-3">
<label for="remark">Remarks</label>
<textarea id="remark" class="form-control" name="remarks" rows="1"></textarea>
</div> -->
<!-- <div class="form-group col-md-6">
<label for="listed_insurers">Shortlisted Insurers</label>
<select class="form-control" id="listed_insurers" name="listed_insurers" multiple>
<option value=""></option>
<?php foreach ($insurer_branch as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>">
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
</option> </option>
<?php } ?> <?php } ?>
</select> <?php } ?>
</div> --> </select>
</div> -->
</div> <!-- <div class="form-group col-md-3">
<!-- <hr> --> <label for="remark">Remarks</label>
<div class="row"> <textarea id="remark" class="form-control" name="remarks" rows="1"></textarea>
<!-- <div class="form-group col-md-3"> </div> -->
<label for="addon_policy"> Status <span id="base_danger"class="text-danger">*</span></label>
<select class="form-control" id="policy_status" name="status" required> <!-- <div class="form-group col-md-6">
<option value="" selected>Select Status</option> <label for="listed_insurers">Shortlisted Insurers</label>
<?php <select class="form-control" id="listed_insurers" name="listed_insurers" multiple>
if (isset($policy_status) && count($policy_status)) { <option value=""></option>
foreach ($policy_status as $key => $value) { <?php foreach ($insurer_branch as $value) { ?>
if($key == 'pending'){ <option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>" data-id="<?= $value['insurer_id'] ?>">
echo "<option value=" . $key . " selected>" . $value . "</option>"; <?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
}else{ </option>
echo "<option value=" . $key . ">" . $value . "</option>"; <?php } ?>
} </select>
</div> -->
</div>
<!-- <hr> -->
<div class="row">
<!-- <div class="form-group col-md-3">
<label for="addon_policy"> Status <span id="base_danger"class="text-danger">*</span></label>
<select class="form-control" id="policy_status" name="status" required>
<option value="" selected>Select Status</option>
<?php
if (isset($policy_status) && count($policy_status)) {
foreach ($policy_status as $key => $value) {
if($key == 'pending'){
echo "<option value=" . $key . " selected>" . $value . "</option>";
}else{
echo "<option value=" . $key . ">" . $value . "</option>";
} }
} }
?> }
</select> ?>
</div> --> </select>
</div> -->
<!-- <div class="form-group col-md-3"> <!-- <div class="form-group col-md-3">
<label for="bp_cgst">Latest Action Date</label> <label for="bp_cgst">Latest Action Date</label>
<input id="last_action_date" type="text" class="form-control" name="last_action_date" placeholder="DD/MM/YYYY"> <input id="last_action_date" type="text" class="form-control" name="last_action_date" placeholder="DD/MM/YYYY">
</div> --> </div> -->
<!-- <div class="form-group col-md-3"> <!-- <div class="form-group col-md-3">
<label for="fund_received">Fund Recd / Sent to Insurer</label> <label for="fund_received">Fund Recd / Sent to Insurer</label>
<input id="fund_received" value="" type="text" class="form-control" name="fund_received"> <input id="fund_received" value="" type="text" class="form-control" name="fund_received">
</div> --> </div> -->
<!-- <div class="form-group col-md-3"> <!-- <div class="form-group col-md-3">
<label class="switch" style="position: relative;top: 32px;left: 20px;"> <label class="switch" style="position: relative;top: 32px;left: 20px;">
<input id="policy_with_corr" type="checkbox" name="policy_with_corr"> <input id="policy_with_corr" type="checkbox" name="policy_with_corr">
<span class="slider round" style="height: 27px;"></span> <span class="slider round" style="height: 27px;"></span>
</label> </label>
<label for="policy_with_corr" style="position: relative;top: 33px;left: 25px;"> Policy with Correction</label> <label for="policy_with_corr" style="position: relative;top: 33px;left: 25px;"> Policy with Correction</label>
</div> --> </div> -->
<!-- <div class="form-group col-md-3"> <!-- <div class="form-group col-md-3">
<label class="switch" style="position: relative;top: 32px;left: 20px;"> <label class="switch" style="position: relative;top: 32px;left: 20px;">
<input id="is_cd_reduce_from_bds" type="checkbox" name="is_cd_reduce_from_bds"> <input id="is_cd_reduce_from_bds" type="checkbox" name="is_cd_reduce_from_bds">
<span class="slider round" style="height: 27px;"></span> <span class="slider round" style="height: 27px;"></span>
</label> </label>
<label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;"> Make Entry in CD &nbsp;&nbsp; <i class="mdi mdi-information-outline info-icon" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i> <label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;"> Make Entry in CD &nbsp;&nbsp; <i class="mdi mdi-information-outline info-icon" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i>
</label> </label>
</div> --> </div> -->
<!-- <div class="form-group col-md-3 current_date" style="display: none;"> <!-- <div class="form-group col-md-3 current_date" style="display: none;">
<label for="bp_igst">Process Start Date</label> <label for="bp_igst">Process Start Date</label>
<input id="process_start_date" type="text" class="form-control" name="process_start_date" placeholder="DD/MM/YYYY"> <input id="process_start_date" type="text" class="form-control" name="process_start_date" placeholder="DD/MM/YYYY">
</div> --> </div> -->
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
</div> </div>
@ -957,7 +955,7 @@
</div> <!-- sales_row div closed here --> </div> <!-- sales_row div closed here -->
<div class="form-group text-right mt-1 m-b-0" id="submitButton"> <div class="form-group text-right mt-2 m-b-0" id="submitButton">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" <button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnSubmit">Submit</button> id="btnSubmit">Submit</button>
</div> </div>
@ -1132,6 +1130,17 @@
<script> <script>
$(document).ready(function(){
$('#sales_row').show();
$('#policy_no').prop('required', true);
$('#policy_issue_date').prop('required', true);
$('#policy_start_date').prop('required', true);
$('#policy_end_date').prop('required', true);
$('.follow_insurer').prop('required', true);
})
$("#infoIcon").click(function() { $("#infoIcon").click(function() {
var policyTransactionPK = $('#policy_tranction_primarykey').val(); var policyTransactionPK = $('#policy_tranction_primarykey').val();
getDataForInfo(policyTransactionPK, function(data) { getDataForInfo(policyTransactionPK, function(data) {
@ -5118,11 +5127,11 @@
function checkCDAmountForBasePremium(input) { function checkCDAmountForBasePremium(input) {
console.log('#################################### Check CD Amount For Base Premium ####################################'); console.log('#################################### Check CD Amount For Base Premium ####################################');
console.log(input)
let policy_type_id = $('#policy_type_id').val(); let policy_type_id = $('#policy_type_id').val();
console.log("policy_type_id ", policy_type_id); console.log("policy_type_id ", policy_type_id);
console.log(input)
let client_type = $('#client_type').val(); let client_type = $('#client_type').val();
console.log('client type', client_type); console.log('client type', client_type);
@ -5640,6 +5649,20 @@
</div> </div>
</div> </div>
<div class="form-group col-md-3">
<label for="rto_id">RTO</label>
<select class="form-control readonly-color readonly-select" id="rto_id" name="rto_id" style="appearance:none;-webkit-appearance:none;-moz-appearance:none;cursor:not-allowed;">
<option value=""></option>
<?php
if (isset($rto_details) && count($rto_details)) {
foreach ($rto_details as $key => $value) {
echo '<option value="' . $value['id'] . '" data-state="' . $value['rto_state'] . '" data-code="' . $value['rto_code'] . '">' . $value['rto_name'] . '</option>';
}
}
?>
</select>
</div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="rc">Chassis No</label> <label for="rc">Chassis No</label>
<input type="text" class="form-control" id="rc" name="rc" <input type="text" class="form-control" id="rc" name="rc"
@ -5739,6 +5762,13 @@
appendOwner(client_list); appendOwner(client_list);
$('#owner').select2(); $('#owner').select2();
$('#owner_branch').select2(); $('#owner_branch').select2();
$('#client_name').on('input', generateShortName);
/** $("#client_name").on("input change keyup", function() {
clearTimeout(shortNameTimer); // cancel previous call
shortNameTimer = setTimeout(() => {
generateShortName(); // only runs after 200ms pause
}, 200); // adjust debounce delay as needed
}); **/
// $("#vehicle_form_row_div").on("input change", "input, select, textarea", function () { // $("#vehicle_form_row_div").on("input change", "input, select, textarea", function () {
// if ($("#client_type").val() === "") { // if ($("#client_type").val() === "") {
@ -6001,6 +6031,9 @@
// resultDiv.classList.add('show'); // resultDiv.classList.add('show');
$('#vehicle_no_validation').val('1'); $('#vehicle_no_validation').val('1');
} }
// call here
autoFetchRtoName(input);
} }
// Custom Parsley validator for vehicle format // Custom Parsley validator for vehicle format
@ -6147,6 +6180,14 @@
</div>`; </div>`;
$('#client_row_div').append(html); $('#client_row_div').append(html);
$('#client_name').on('input', generateShortName);
/** $("#client_name").on("input change keyup", function() {
clearTimeout(shortNameTimer); // cancel previous call
shortNameTimer = setTimeout(() => {
generateShortName(); // only runs after 200ms pause
}, 200); // adjust debounce delay as needed
}); **/
if(client_type == 1){ if(client_type == 1){
$('.group_client').show(); $('.group_client').show();
@ -6176,6 +6217,52 @@
$("#client_type").focus(); // focus back to client_type $("#client_type").focus(); // focus back to client_type
} }
}); });
}
function generateShortName() {
let clientInput = $("#client_name");
let shortInput = $("#short_name");
let newClientName = clientInput.val().trim();
console.log(`LN : NEW - ${newClientName}`);
if (newClientName.length == 0){ shortInput.val(''); return; }
if (newClientName.length > 0) {
let shortName = newClientName.substring(0, 10).replace(/\s+/g, '').toUpperCase();
makeUniqueShortName(shortName);
}
}
function makeUniqueShortName(baseName) {
let input = $("#short_name")[0]; // input element
checkDuplicateTableFieldValue("clients", "short_name", baseName, function(isDuplicate) {
if (isDuplicate) {
// Append sequence until unique
let counter = 1;
function tryNext() {
let padded = String(counter).padStart(3, '0'); // 001, 002, 003
let newName = baseName + padded;
checkDuplicateTableFieldValue("clients", "short_name", newName, function(exists) {
if (exists) {
counter++;
tryNext(); // keep checking
} else {
$("#short_name").val(newName);
validateInputForClient(input, "clients", "short_name");
}
});
}
tryNext();
} else {
$("#short_name").val(baseName);
validateInputForClient(input, "clients", "short_name");
}
});
} }
function validateInputForClient(input, table, field) { function validateInputForClient(input, table, field) {
@ -6277,5 +6364,32 @@
console.log("✅ total[] changed:", val); console.log("✅ total[] changed:", val);
}); });
function autoFetchRtoName(val) {
console.log(`i am here ${val}`);
val = val.toUpperCase().trim();
let stateCode = val.slice(0, 2); // 1st 2 here i am split the state code
let numberCode = val.slice(2, 4); // 2nd 2 here i am split the number code
console.log(`Ln ST: ${stateCode} | NC: ${numberCode}`);
let matched = false;
$('#rto_id option').each(function() {
let optionState = $(this).attr('data-state');
let optionCode = $(this).attr('data-code');
console.log(`Ln optionState : ${optionState} | optionCode : ${optionCode}`);
if (stateCode === optionState && numberCode === optionCode) {
$('#rto_id').val($(this).val()).trigger('change'); // ✅ select it
matched = true;
return false; // break the loop
}
});
if (!matched) {
$('#rto_id').val('').trigger('change'); // reset select
}
}
</script> </script>

View File

@ -570,6 +570,7 @@ $(document).ready(function() {
className: 'btn app-btn-primary mr-2', className: 'btn app-btn-primary mr-2',
action: function (e, dt, node, config) { action: function (e, dt, node, config) {
hide_list_show_add(); hide_list_show_add();
addInsurerColumn() ;
} }
}, },
{ {

View File

@ -0,0 +1,254 @@
<style>
.dataTables_filter {
position: absolute;
}
</style>
<!-- End ADD and EDIT Page HTML -->
<div class="row" id="List-page">
<div class="col-12">
<div class="card">
<div class="card-body maincard">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">RTO Office at</th>
<th class="font-weight-medium">RTO Code</th>
<th class="font-weight-medium">RTO State</th>
<!-- <th class="font-weight-medium">Status</th> -->
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php if(isset($data)) { ?>
<?php foreach($data as $index => $row) { ?>
<tr>
<td class="text-dark">&nbsp;&nbsp;<?= esc($index + 1); ?></td>
<td><?= $row['rto_name']; ?></td>
<td><?= $row['rto_code']; ?></td>
<td><?= $row['rto_state']; ?></td>
<!-- <td>
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
</span>
</td> -->
<td>
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right" style="cursor: pointer;">
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
<?php if ($row['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td colspan="3" class="text-center">No data available</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- modal content -->
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modalLabel">Add RTO Details</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<!-- <form class="parsley-examples" id="RTOForm" enctype="multipart/form-data"> -->
<form id="RTOForm" enctype="multipart/form-data">
<input type="hidden" name="pk" id="rto_id"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="rto_name">RTO Office Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="rto_name" name="rto_name" placeholder="Enter RTO Office Name" required>
</div>
<div class="form-group col-md-12">
<label for="rto_code">RTO Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="rto_code" name="rto_code"
placeholder="Enter RTO Code" required
maxlength="2"
inputmode="numeric"
pattern="[0-9]{2}"
oninput="this.value = this.value.replace(/[^0-9]/g, '').slice(0,2);">
</div>
<div class="form-group col-md-12">
<label for="rto_state">RTO State<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="rto_state" name="rto_state"
placeholder="Enter RTO State" required
maxlength="2"
pattern="[A-Z]{2}"
oninput="this.value = this.value.replace(/[^A-Za-z]/g, '').toUpperCase().slice(0,2);">
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
var table;
$(document).ready(function () {
var ticketsTable = $('#user-table');
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-7'f><'col-sm-5 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: [
{
text: 'Add',
className: 'btn app-btn-primary mr-2',
action: function(e, dt, node, config) {
openModal()
}
},
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
title: 'RTO',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"></i>
</div>`,
searchPlaceholder: "Search"
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
});
$('.close').click(function(){
resetValues()
})
function openModal(){
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show();
}
function handleSaveEditAndDelete(type = 'submit', el = null) {
let url = '<?= base_url('util/rtoMaster') ?>';
let method = "POST";
let requestData = {};
let pk = null;
// If element is passed (from edit/remove button), get its data-id
if (el) { pk = $(el).data('id'); }
requestData.pk = pk;
if(type == 'submit'){
$("#RTOForm").find("input, select, textarea").each(function () {
let name = $(this).attr("name");
let value = $.trim($(this).val());
if (name) requestData[name] = value;
});
}
if(type == 'remove'){
method = "DELETE";
} else if (type == 'edit'){
method = "GET";
$('#modalLabel').text('Edit RTO details');
$('#vehicleTypeForm')[0].reset();
}
console.log("type", type)
console.log("url", url)
console.log("method", method)
console.log("requestData", requestData)
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, method, requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status) {
if(type == 'edit'){
appendEditData(response.data);
} else if(type == 'remove'){
toastr.success(response.message, 'Success');
if(el) $(el).closest('tr').remove();
} else if(type == 'submit'){
toastr.success(response.message, 'Success');
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.hide();
resetValues();
window.location.reload();
}
} else {
toastr.warning(response.message, 'Warning');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
function resetValues(){
$('#modalLabel').text('Add RTO Details');
$('#RTOForm')[0].reset();
}
function appendEditData(data){
$('#rto_id').val(data[0]['id']);
$('#rto_name').val(data[0]['rto_name']);
$('#rto_code').val(data[0]['rto_code']);
$('#rto_state').val(data[0]['rto_state']);
openModal()
}
</script>

View File

@ -0,0 +1,230 @@
<style>
.dataTables_filter {
position: absolute;
}
</style>
<!-- End ADD and EDIT Page HTML -->
<div class="row" id="List-page">
<div class="col-12">
<div class="card">
<div class="card-body maincard">
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">Vehicle Type</th>
<!-- <th class="font-weight-medium">Status</th> -->
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php if(isset($data)) { ?>
<?php foreach($data as $index => $row) { ?>
<tr>
<td class="text-dark">&nbsp;&nbsp;<?= esc($index + 1); ?></td>
<td><?= $row['vehicle_type']; ?></td>
<!-- <td>
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
</span>
</td> -->
<td>
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right" style="cursor: pointer;">
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
<?php if ($row['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
<?php endif; ?>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td colspan="3" class="text-center">No data available</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- modal content -->
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modalLabel">Add Vehicle Type</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<!-- <form class="parsley-examples" id="vehicleTypeForm" enctype="multipart/form-data"> -->
<form id="vehicleTypeForm" enctype="multipart/form-data">
<input type="hidden" name="pk" id="vehicle_type_id"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="vehicle_type">Vehicle Type<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="vehicle_type" name="vehicle_type" placeholder="Enter Vehicle Type" required>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
var table;
$(document).ready(function () {
var ticketsTable = $('#user-table');
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-7'f><'col-sm-5 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: [
{
text: 'Add',
className: 'btn app-btn-primary mr-2',
action: function(e, dt, node, config) {
openModal()
}
},
{
extend: 'collection',
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
className: 'btn app-btn-secondary ',
buttons: [
{
extend: 'csv',
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
title: 'Policy-Tranction-Inception-List',
className: 'app-btn-primary ',
exportOptions: {
columns: ':not(:last-child)'
},
}
]
}
],
language: {
search: `
<div class="datatable-search-wrapper">
_INPUT_
<i class="mdi mdi-magnify datatable-search-icon"></i>
</div>`,
searchPlaceholder: "Search"
},
paging: true, // Enable pagination
pageLength: 10, // Set default number of rows per page (optional)
// ordering: false,
});
});
$('.close').click(function(){
resetValues()
})
function openModal(){
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.show();
}
function handleSaveEditAndDelete(type = 'submit', el = null) {
let url = '<?= base_url('util/vehicleTypeMaster') ?>';
let method = "POST";
let requestData = {};
let pk = null;
// If element is passed (from edit/remove button), get its data-id
if (el) { pk = $(el).data('id'); }
requestData.pk = pk;
if(type == 'submit'){
$("#vehicleTypeForm").find("input, select, textarea").each(function () {
let name = $(this).attr("name");
let value = $.trim($(this).val());
if (name) requestData[name] = value;
});
}
if(type == 'remove'){
method = "DELETE";
} else if (type == 'edit'){
method = "GET";
$('#modalLabel').text('Edit Vehicle Type');
$('#vehicleTypeForm')[0].reset();
}
console.log("type", type)
console.log("url", url)
console.log("method", method)
console.log("requestData", requestData)
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Send AJAX request
sendAjaxRequestForGlobal(url, method, requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status) {
if(type == 'edit'){
appendEditData(response.data);
} else if(type == 'remove'){
toastr.success(response.message, 'Success');
if(el) $(el).closest('tr').remove();
} else if(type == 'submit'){
toastr.success(response.message, 'Success');
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
myModal.hide();
resetValues();
window.location.reload();
}
} else {
toastr.warning(response.message, 'Warning');
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
function resetValues(){
$('#modalLabel').text('Add Vehicle Type');
$('#vehicleTypeForm')[0].reset();
}
function appendEditData(data){
$('#vehicle_type_id').val(data[0]['id']);
$('#vehicle_type').val(data[0]['vehicle_type']);
openModal()
}
</script>

View File

@ -1360,7 +1360,7 @@ $(document).ready(function () {
if (lead_status != "won") { if (lead_status != "won") {
console.log("Lead status is not 'won', setting interval for submitData"); console.log("Lead status is not 'won', setting interval for submitData");
// startInterval(); startInterval();
} else { } else {
console.log("Lead status is 'won', submitData will not be called"); console.log("Lead status is 'won', submitData will not be called");
} }
@ -1557,8 +1557,8 @@ function saveFamilyMembersDetails() {
function resetFamiliyDialogModalValues() { function resetFamiliyDialogModalValues() {
$('#familiy_dialog_row_index').val(''); // $('#familiy_dialog_row_index').val('');
$('#familiy_dialog_column_index').val(''); // $('#familiy_dialog_column_index').val('');
// Reset Self // Reset Self
$('#family_self').prop('checked', true); $('#family_self').prop('checked', true);
@ -3751,6 +3751,8 @@ function setCellInnerHTMLByCellIndex(tableId, rowIndex, colIndex, htmlContent) {
// Set the innerHTML of the cell // Set the innerHTML of the cell
cell.innerHTML = htmlContent; cell.innerHTML = htmlContent;
console.log(`Updated cell at row ${rowIndex}, column ${colIndex} with content: ${htmlContent}`); console.log(`Updated cell at row ${rowIndex}, column ${colIndex} with content: ${htmlContent}`);
$('#familiy_dialog_row_index').val('');
$('#familiy_dialog_column_index').val('');
} else { } else {
console.error(`Column index ${colIndex} does not exist in row ${rowIndex}`); console.error(`Column index ${colIndex} does not exist in row ${rowIndex}`);
} }

Binary file not shown.

View File

@ -0,0 +1,271 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Health Insurance E-Card</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
/* font-family: 'Lato', sans-serif; */
background-color: #fff;
padding: 5px;
}
.card-container {
display: table;
width: 100%;
max-width: 750px;
margin: 0 auto;
table-layout: fixed;
border-spacing: 5px 0;
}
.card {
display: table-cell;
background: white;
width: 50%;
padding: 10px;
border: 1px solid #ddd;
vertical-align: top;
}
.card-header {
display: table;
width: 100%;
margin-bottom: 10px;
table-layout: fixed;
}
.logo-left {
display: table-cell;
width: 35px;
vertical-align: middle;
}
.logo-left img {
width: 32px;
height: 32px;
}
.logo-right {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.logo-right img {
width: 65px;
height: auto;
}
.card-body {
position: relative;
padding-left: 65px;
min-height: 80px;
}
.n-logo {
position: absolute;
left: 5px;
top: 30px;
width: 55px;
}
.n-logo img {
width: 55px;
height: auto;
}
.details {
width: 100%;
margin-left: 16px;
}
.details-table {
width: 100%;
border-collapse: collapse;
font-size: 10px;
line-height: 1.4;
}
.details-table td {
padding: 1px 1px;
vertical-align: top;
}
.detail-label {
width: 65px;
font-weight: 600;
color: #333;
white-space: nowrap;
}
.detail-separator {
width: 8px;
text-align: center;
color: #666;
}
.detail-value {
color: #333;
word-break: break-word;
white-space: normal;
font-weight: 300;
}
.support-section {
font-size: 7.5px;
}
.support-title {
color: #ff6b35;
font-weight: 600;
margin-bottom: 6px;
font-size: 10px;
}
.support-details {
font-size: 8px;
font-weight: 500;
line-height: 1.4;
color: #333;
margin-top: 0px;
}
.level-title {
font-weight: 500;
margin-top: 4px;
margin-bottom: 2px;
}
.cashless-title {
color: #ff6b35;
font-weight: 600;
margin-top: 0px;
margin-bottom: 3px;
font-size: 10px;
}
.footer-note {
text-align: center;
margin-top: 8px;
font-size: 8px;
color: #666;
}
</style>
</head>
<body>
<div class="card-container">
<!-- Front Card -->
<div class="card">
<div class="card-header">
<div class="logo-left">
<img src="{INSURER_LOGO}" alt="Insurer logo">
</div>
<div class="logo-right">
<img src="{TPA_LOGO}" alt="TPA logo">
</div>
</div>
<div class="card-body">
<div class="n-logo">
<img src="{NHANCE_N_LOGO}" alt="N Logo">
</div>
<div class="details">
<table class="details-table">
<tbody>
<tr>
<td class="detail-label">Policy Holder</td>
<td class="detail-separator">:</td>
<td class="detail-value">AMERICAN MEGATRENDS INTERNATIONAL INDIA PVT LTD</td>
</tr>
<tr>
<td class="detail-label">Insurer</td>
<td class="detail-separator">:</td>
<td class="detail-value">The New India Assurance</td>
</tr>
<tr>
<td class="detail-label">TPA</td>
<td class="detail-separator">:</td>
<td class="detail-value">Mediassit</td>
</tr>
<tr>
<td class="detail-label">Primary Insured</td>
<td class="detail-separator">:</td>
<td class="detail-value">Suganya A</td>
</tr>
<tr>
<td class="detail-label">Beneficiary Name</td>
<td class="detail-separator">:</td>
<td class="detail-value">Suganya A</td>
</tr>
<tr>
<td class="detail-label">Member ID</td>
<td class="detail-separator">:</td>
<td class="detail-value">4060881280</td>
</tr>
<tr>
<td class="detail-label">Employee Code</td>
<td class="detail-separator">:</td>
<td class="detail-value">9332</td>
</tr>
<tr>
<td class="detail-label">Relation</td>
<td class="detail-separator">:</td>
<td class="detail-value">Self</td>
</tr>
<tr>
<td class="detail-label">Policy Period</td>
<td class="detail-separator">:</td>
<td class="detail-value">1-Apr-2025 to 31-Mar-2026</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Back Card -->
<div class="card">
<div class="card-header">
<div class="logo-left">
<img src="{INSURER_LOGO}" alt="Insurer logo">
</div>
<div class="logo-right">
<img src="{TPA_LOGO}" alt="TPA logo">
</div>
</div>
<div class="card-body">
<div class="n-logo">
<img src="{NHANCE_N_LOGO}" alt="N Logo">
</div>
<div class="details">
<div class="support-section">
<div class="support-title">For support :</div>
<div class="support-details">
{LEVELS}
<div class="cashless-title">For cashless claims:</div>
<div>Share a valid ID with this E-card at the Hospital Insurance Desk.</div>
{NETWORK_HOSPITAL}
</div>
</div>
</div>
</div>
<div class="footer-note">
This E-Card is non-transferable and valid only at network (cashless) hospitals
</div>
</div>
</div>
</body>
</html>