diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 58aa95b4..877ba46e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -396,6 +396,9 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->post('savePlacementDataAndValidateMemberDataFile', 'LeadsController::savePlacementDataAndValidateMemberDataFile'); $routes->get('checkMemberDataFileValidationStatus', 'LeadsController::checkMemberDataFileValidationStatus'); $routes->match(['get', 'post', 'delete'], 'nhanceBranchMaster', 'MasterController::nhanceBranchMaster'); + $routes->match(['get', 'post', 'delete'], 'vehicleTypeMaster', 'MasterController::vehicleTypeMaster'); + $routes->match(['get', 'post', 'delete'], 'rtoMaster', 'MasterController::rtoMaster'); + }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index bcadb66d..e09c74ec 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -518,8 +518,8 @@ class ClientController extends AdminController public function updateEmpAndPolicyStatus() { - $return = $this->clientPolicyModel->updateStatus(); + return $return; $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']]); } @@ -1613,7 +1613,7 @@ class ClientController extends AdminController if ($update) { - $policy_transaction_update = $this->deactivatePolicyTransactionsPolicy($id); + // $policy_transaction_update = $this->deactivatePolicyTransactionsPolicy($id); return $this->respond(['status' => true, 'code' => 200], 200); } else { @@ -4816,6 +4816,7 @@ class ClientController extends AdminController 'vehicle_no' => $data['vehicle_no'], 'type' => $data['type'], 'rc' => $data['rc'], + 'rto_id' => $data['rto_id'], 'branch_id' => $branch_insert, 'owner' => $client_insert, ]; @@ -4861,6 +4862,7 @@ class ClientController extends AdminController 'vehicle_no' => $data['vehicle_no'], 'type' => $data['type'], 'rc' => $data['rc'], + 'rto_id' => $data['rto_id'], 'branch_id' => $data['branch_id'] ?? null, 'owner' => $data['owner'], ]; @@ -5064,10 +5066,12 @@ class ClientController extends AdminController ->where('policy_no', $policy_no) ->countAllResults(); + $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('policy_status', 1)->where('policy_no', trim($policy_no))->first(); + 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 { - 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); } } diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 73c2e31a..369f9444 100755 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -225,20 +225,23 @@ class DashboardController extends AdminController $pendingActionsController = new PendingActionsController; $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; $session = \Config\Services::session(); $session->set('enrollment_data', json_encode($data)); - // echo "
";
             $data['pendingActionsData'] = $pendingActionsData;
             $data['businessTeamCount'] = count($businessTeamData) ?? 0;
-            // dd($businessTeamData);
             $data['financeTeamCount'] = count($financeTeamData) ?? 0;
             $data['businessTeamStatusData'] = $businessTeamStatusData;
             $data['financeTeamStatusData'] = $financeTeamStatusData;
diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php
index a4666518..3bf6a341 100755
--- a/app/Controllers/EmployeeController.php
+++ b/app/Controllers/EmployeeController.php
@@ -35,7 +35,7 @@ use App\Controllers\JobWorker;
 use App\Controllers\Jobs\SubJob;
 use App\Controllers\EmployeeServiceController;
 use App\Controllers\EmpDataServiceController;
-
+use App\Models\ThzMasterModel;
 use CodeIgniter\API\ResponseTrait;
 
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
@@ -1471,6 +1471,7 @@ class EmployeeController extends AdminController
             $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 = 'common.html';
+            // $tpa_short_name = 'new_ecard.html';
             $final_path = $template_data_path . $tpa_short_name;
         
             $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_ANDROID_2}' => base_url() . 'public/e_card_imgs/play_store.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['{NETWORK_HOSPITAL}'] = $this->generateNetworkHospitalsForEcard($value['network_hospitals']);
+       
                 foreach ($placeholders as $placeholder => $replaceValue) {
                     $htmlContent = str_replace($placeholder, $replaceValue, $htmlContent);
                 }
@@ -1534,13 +1537,23 @@ class EmployeeController extends AdminController
                 $html .= $htmlContent;
             }
 
+            // return $html;
             // DomPdf 
             $options = new Options();
             $options->set('isRemoteEnabled', true);
             $options->set('isHtml5ParserEnabled', true);
 
             $dompdf = new Dompdf($options);
-            $dompdf->loadHtml('' . $html); // remove the margin
+            // $dompdf->loadHtml('' . $html); // remove the margin
+            $dompdf->loadHtml('
+                
+                ' . $html
+            );
+
             $dompdf->setPaper('A4', 'portrait');
             $dompdf->render();
 
@@ -2939,20 +2952,43 @@ class EmployeeController extends AdminController
     
         // Generate the HTML content
         $html = '';
-    
+        
+        $level_index = 1;
         foreach ($levels as $level => $contacts) {
             $displayLevel = $level == 3 ? 1 : 2; // Switch levels for display
-            $html .= '
Level ' . $displayLevel . '
'; + if($level_index == 1){ + $html .= 'Level ' . $displayLevel . '
'; + }else{ + $html .= '
Level ' . $displayLevel . '
'; + } foreach ($contacts as $index => $contact) { $html .= ($index + 1) . '. ' . $contact['first_name'] . ' / ' . $contact['mobile'] . ' / ' . $contact['email'] . '
'; } + $level_index++; } - $html .= '


'; + $html .= '
'; return $html; } + public function generateNetworkHospitalsForEcard($network_hospitals) + { + $html = ""; + if (!empty($network_hospitals)) { + $html = '
+ Network Hospital: + ' . $network_hospitals . ' +
'; + } + + // For debugging + // print_r($html); die; + + return $html; + } + + public function getBatchFileData() { $file_id = $this->request->getGet('file_id'); @@ -3065,7 +3101,8 @@ class EmployeeController extends AdminController } else { $text = "create"; $data['created_by'] = get_session_userid(); - $this->thzMasterModel->insert($data); + $thzMasterModel = new ThzMasterModel(); + $thzMasterModel->insert($data); $insertID = $this->partnerEndorsementRequestModel->insertID(); $result = true; } diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index cde00cf7..19cde67b 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -36,6 +36,8 @@ use App\Models\InsurerExcelExportTemplateModel; use App\Models\NhanceBranchModel; use App\Models\SettingsModel; use App\Models\VehicleModel; +use App\Models\VehicleTypeModel; +use App\Models\RTOModel; use CodeIgniter\CLI\CLI; @@ -2022,15 +2024,19 @@ class MasterController extends AdminController dd($result); } + //---------------------------------------------------------------------------------------------------------- + public function nhanceBranchMaster() { $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; $data = $this->request->getPost(); - print_r($data); die; if (empty($id)) { $update_status = $nhanceBranchModel->insert($data); @@ -2054,7 +2060,7 @@ class MasterController extends AdminController ], 200); } - } elseif ($this->request->is('get')) { + } elseif ($method === 'get') { $id = $this->request->getGet('pk') ?? null; @@ -2070,7 +2076,7 @@ class MasterController extends AdminController $data = $nhanceBranchModel->where('is_active', 1)->findAll(); return $this->loadLayout('nhance_branch_list', ['data' => $data]); - } elseif ($this->request->is('delete')) { + } elseif ($method === 'delete') { $input = $this->request->getRawInput(); $id = $input['pk'] ?? null; @@ -2106,7 +2112,167 @@ class MasterController extends AdminController 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); + } + } } } \ No newline at end of file diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index d2b45648..41499b5a 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -151,6 +151,8 @@ class PolicyTransactionController extends BaseController // 'bicycle' => 'Bicycle' // ]; $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'] = [ 'commercial' => 'Commercial', 'private' => 'Private', @@ -261,6 +263,7 @@ class PolicyTransactionController extends BaseController $data = $this->preparePolicyData(); $data['cd_ac_pk'] = $this->request->getPost('cd_ac_no'); $data['issuer'] = 2; + $data['status'] = 'completed'; $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(); // print_r($data); die; - // var_dump($data); die; if (empty($data['policy_issue_date'])) { $data['policy_issue_date'] = null; @@ -304,7 +306,6 @@ class PolicyTransactionController extends BaseController $data['last_action_date'] = change_date_format($data['last_action_date']); } - // Separate Insurer and TPA Branch IDs and IDs if (isset($data['insurer_id']) && !empty($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); + $client_policy_id = null; if ($data['ct_type'] == 2) { $client_policy_insert_data = $this->prepareClientPolicyInsertData($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) { - $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(); $data['client_kyc_primary_table'] = $clientController->generateKycPrimaryTable($data['client_id']); $data['client_kyc_other_table'] = $clientController->generateKycOthersTable($data['client_id']); - $data['entity_type_id'] = $client_data['entity_type_id']; return $this->respondSuccess($insert, "Policy transaction created successfully", $data); @@ -432,20 +433,20 @@ class PolicyTransactionController extends BaseController } } - if($old_pt_data['status'] != "completed"){ - if ($data['status'] == 'completed' && $data['ct_type'] == 2) { - if ($data['client_type'] == 1 && $data['is_cd_reduce_from_bds'] == 1) { - $this->processCompletedStatus($data, $data['client_policy_id'], $data['insurer_id']); - } - } - } + // if($old_pt_data['status'] != "completed"){ + // if ($data['status'] == 'completed' && $data['ct_type'] == 2) { + // if ($data['client_type'] == 1 && $data['is_cd_reduce_from_bds'] == 1) { + // $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(); } if(isset($data['cd_amt_changed']) && !empty($data['cd_amt_changed'])){ $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(); @@ -467,10 +468,6 @@ class PolicyTransactionController extends BaseController { // Prepare data for insertion and updating $coShareDetails = []; - - // print_r($data); die; - // die; - if (isset($data['co_share_id']) && !empty($data['co_share_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($coShareDetails); // die; @@ -610,7 +606,7 @@ class PolicyTransactionController extends BaseController $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; $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(), 'event_name' => 'inception', '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); $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(), 'event_name' => 'inception', '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()); @@ -1026,20 +1029,28 @@ class PolicyTransactionController extends BaseController } } - public function removePolicyTransaction($id) - { + public function removePolicyTransaction($id, $type = 0) + { if ($id) { - $data['is_active'] = 0; $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->PTCOShareDetailsModel->where('pt_id', $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(); + + $cd_transaction_model = new ClientDepositModel(); + $this->$cd_transaction_model->where('policy_transaction_id', $id)->set($data)->update(); + }else{ $this->policyTransactionModel->where('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); } else { @@ -1167,6 +1178,7 @@ class PolicyTransactionController extends BaseController { $id = $this->request->getPost('id'); $data = $this->preparePolicyTransactionData(); + $data['status'] = 'completed'; // print_r($data); die; if (!$id) { @@ -1334,9 +1346,9 @@ class PolicyTransactionController extends BaseController if ($update) { $this->insertTransactionStatus($id, $data, 1); - if($old_endorse_data['status'] != "completed"){ - $this->handleCompletedStatus($data, $id); - } + // if($old_endorse_data['status'] != "completed"){ + // $this->handleCompletedStatus($data, $id); + // } $this->insertOrUpdateCoShareDetails($data, $id); @@ -1347,30 +1359,40 @@ class PolicyTransactionController extends BaseController } private function handleCompletedStatus($data, $policy_tran_id) - { + { if ($data['client_type'] == 1 && $data['status'] == 'completed' && $data['is_cd_reduce_from_bds'] == 1) { $tolamt = (int) $data['total'][0] ?? 0; - $description = 'The following amount of Rs. ' . round($tolamt, 2) . '/- has been' . - ($data['action_type'] == 'deletion' ? ' Credit ' : ' Debit ') . 'from the policy transaction (BDS)'; - $cd_tranction_data = [ - 'amount' => $tolamt, - 'sub_type_id' => $data['action_type'] == 'deletion' ? 3 : 4, - 'client_id' => $data['client_id'], - 'client_policy_id' => $data['client_policy_id'], - 'endorsement_no' => null, - 'cd_ac_no' => $data['cd_ac_no'] ?? null, - 'insurer_id' => $data['insurer_id'], - 'description' => $description, - 'transaction_type' => $data['action_type'] == 'deletion' ? 'Credit' : 'Debit', - 'updated_by' => get_session_userid(), - 'event_name' => $data['action_type'], - 'is_active' => 1, - 'cd_ac_pk' => $data['cd_ac_pk'] ?? null, - ]; + if(!empty($tolamt)){ + $description = 'The following amount of Rs. ' . round($tolamt, 2) . '/- has been' . + ($data['action_type'] == 'deletion' ? ' Credit ' : ' Debit ') . 'from the policy transaction (BDS)'; + + $cd_tranction_data = [ + 'amount' => abs($tolamt), + 'sub_type_id' => $data['action_type'] == 'deletion' ? 3 : 4, + 'client_id' => $data['client_id'], + 'client_policy_id' => $data['client_policy_id'], + 'endorsement_no' => null, + 'cd_ac_no' => $data['cd_ac_no'] ?? null, + 'insurer_id' => $data['insurer_id'], + 'description' => $description, + 'transaction_type' => $data['action_type'] == 'deletion' ? 'Credit' : 'Debit', + 'updated_by' => get_session_userid(), + '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') ->first(); - $pt_id = null; + $pt_id = null; + if(!empty($data)){ $inception_data = $this->policyTransactionModel->where('policy_no', $data['policy_no'])->where('client_id', $data['client_id'])->first(); $pt_id = $inception_data['id']; } - if (!empty($data['policy_start_date'])) { $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; + $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) { return $this->respond(['status' => true, 'data' => $data, 'pt_id' => $pt_id], 200); } else { @@ -2111,7 +2143,7 @@ class PolicyTransactionController extends BaseController //insurer statement list page 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(); $today = date('Y-m-d'); $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); $is_source_found = 0; // 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_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_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_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 - $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( '/[\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) { $is_source_found = 0; - $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_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_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]); // - $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 foreach ($source_data as $source_key => $source_row) { @@ -2485,9 +2517,10 @@ class PolicyTransactionController extends BaseController //calculate percentage first $total_amt = 0; - $actual_bp_per = trim($excel_row[9]); - $actual_bp_brokerage = trim($excel_row[12]); - $actual_bp_amt = trim($excel_row[6]); + // $actual_bp_per = trim($excel_row[9]); //commented becoz this filed removed tfrom excel file + $actual_bp_per = 0; //set default value 0 for maintaining existing code flow + $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 != "")) { $total_amt += $actual_bp_brokerage; @@ -2500,9 +2533,10 @@ class PolicyTransactionController extends BaseController $total_amt += $actual_bp_brokerage; } - $actual_tp_per = trim($excel_row[10]); - $actual_tp_brokerage = trim($excel_row[13]); - $actual_tp_amt = trim($excel_row[7]); + // $actual_tp_per = trim($excel_row[10]);//commented becoz this filed removed tfrom excel file + $actual_tp_per = 0;//set default value 0 for maintaining existing code flow + $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 != "") { $total_amt += $actual_tp_brokerage; @@ -2515,9 +2549,13 @@ class PolicyTransactionController extends BaseController $total_amt += $actual_tp_brokerage; } - $actual_tep_per = trim($excel_row[11]); - $actual_tep_brokerage = trim($excel_row[14]); - $actual_tep_amt = trim($excel_row[8]); + // $actual_tep_per = trim($excel_row[11]); + // $actual_tep_brokerage = trim($excel_row[14]); + // $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 != "") { $total_amt += $actual_tep_brokerage; @@ -2533,7 +2571,7 @@ class PolicyTransactionController extends BaseController //find variance $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]); continue 2; diff --git a/app/Helpers/DepositHelper.php b/app/Helpers/DepositHelper.php index 9549f8a1..495797f3 100755 --- a/app/Helpers/DepositHelper.php +++ b/app/Helpers/DepositHelper.php @@ -66,7 +66,8 @@ class DepositHelper 'updated_by' => $data['updated_by'], 'balance' => $newBalance, // Include the new balance in the data array '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 diff --git a/app/Models/ClientDepositModel.php b/app/Models/ClientDepositModel.php index 9d45f38f..8a61b204 100755 --- a/app/Models/ClientDepositModel.php +++ b/app/Models/ClientDepositModel.php @@ -28,7 +28,8 @@ class ClientDepositModel extends Model "event_name", "unit", "cd_ac_pk", - "record_date" + "record_date", + "policy_transaction_id", ]; diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 041ac791..bea76e50 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -1471,7 +1471,7 @@ class EmployeePolicyModel extends Model ep.tpa_id, ep.uhid, - ep.policy_end_date, + cp.policy_end_date, ep.basic_cover_si, clients.client_name, @@ -1537,7 +1537,7 @@ class EmployeePolicyModel extends Model ep.tpa_id, ep.uhid, - ep.policy_end_date, + cp.policy_end_date, ep.basic_cover_si, clients.client_name, diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index 6ea94e65..2e935ead 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -305,7 +305,7 @@ class PolicyTransactionModel extends Model 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'); $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) { - $fromDate = date('Y-m-d', strtotime('-60 days')); + $fromDate = date('Y-m-d', strtotime('-90 days')); $toDate = date('Y-m-d 23:59:59'); if (empty($where)) { @@ -1060,7 +1060,7 @@ class PolicyTransactionModel extends Model // 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)) { - $fromDate = date('Y-m-d', strtotime('-60 days')); + $fromDate = date('Y-m-d', strtotime('-90 days')); $toDate = date('Y-m-d 23:59:59'); $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('insurers', 'pt_co_share_details.insurer_id = insurers.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.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) { - $fromDate = date('Y-m-d', strtotime('-60 days')); + $fromDate = date('Y-m-d', strtotime('-90 days')); $toDate = date('Y-m-d 23:59:59'); $builder->where('policy_transaction.created_at >=', $fromDate) @@ -1313,7 +1313,7 @@ class PolicyTransactionModel extends Model ->where('policy_transaction.' . $date_type . '<=', $endDate); } 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'); $builder->where('policy_transaction.created_at >=', $fromDate) @@ -1416,7 +1416,7 @@ class PolicyTransactionModel extends Model ->where('policy_transaction.' . $date_type . '<=', $endDate); } 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'); $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) { - $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') ->select(" @@ -1519,7 +1519,7 @@ class PolicyTransactionModel extends Model ->where('policy_transaction.' . $date_type . '<=', $endDate); } 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'); $builder->where('policy_transaction.created_at >=', $fromDate) @@ -1624,7 +1624,7 @@ class PolicyTransactionModel extends Model $builder->where('policy_transaction.' . $date_type . '>=', $startDate) ->where('policy_transaction.' . $date_type . '<=', $endDate); } 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'); $builder->where('policy_transaction.created_at >=', $fromDate) @@ -1712,7 +1712,7 @@ class PolicyTransactionModel extends Model //function for fetch renewal report data 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'); if (!empty($start_date) && !empty($end_date)) { diff --git a/app/Models/RTOModel.php b/app/Models/RTOModel.php new file mode 100644 index 00000000..6f5abcab --- /dev/null +++ b/app/Models/RTOModel.php @@ -0,0 +1,57 @@ + -
  • Users
  • +
  • + Nhance Branch +
  • +
  • + Vehicle Type +
  • +
  • + RTO +
  • diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index cb17bb22..563c5933 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -452,6 +452,58 @@ if (isset($selected_lead_type)) { $('#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){ let client_type = $('#client_type').val(); diff --git a/app/Views/nhance_branch_list.php b/app/Views/nhance_branch_list.php index 97660071..f3655ec8 100644 --- a/app/Views/nhance_branch_list.php +++ b/app/Views/nhance_branch_list.php @@ -14,25 +14,43 @@ S.No. Branch Name + Action + $row) { ?> - +    + + + + No data available + + @@ -43,14 +61,15 @@